Skip to content

Commit

Permalink
Merge branch 'jw/format-patch-attach'
Browse files Browse the repository at this point in the history
* jw/format-patch-attach:
  Enable setting attach as the default in .gitconfig for git-format-patch.
  • Loading branch information
Junio C Hamano committed Mar 5, 2009
2 parents e7cf1da + 0db5260 commit 2247b45
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Documentation/git-format-patch.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ SYNOPSIS
--------
[verse]
'git format-patch' [-k] [-o <dir> | --stdout] [--thread]
[--attach[=<boundary>] | --inline[=<boundary>]]
[--attach[=<boundary>] | --inline[=<boundary>] |
[--no-attach]]
[-s | --signoff] [<common diff options>]
[-n | --numbered | -N | --no-numbered]
[--start-number <n>] [--numbered-files]
Expand Down Expand Up @@ -117,6 +118,10 @@ include::diff-options.txt[]
which is the commit message and the patch itself in the
second part, with "Content-Disposition: attachment".

--no-attach::
Disable the creation of an attachment, overriding the
configuration setting.

--inline[=<boundary>]::
Create multipart/mixed attachment, the first part of
which is the commit message and the patch itself in the
Expand Down Expand Up @@ -174,7 +179,8 @@ CONFIGURATION
-------------
You can specify extra mail header lines to be added to each message
in the repository configuration, new defaults for the subject prefix
and file suffix, and number patches when outputting more than one.
and file suffix, control attachements, and number patches when outputting
more than one.

------------
[format]
Expand All @@ -183,6 +189,7 @@ and file suffix, and number patches when outputting more than one.
suffix = .txt
numbered = auto
cc = <email>
attach [ = mime-boundary-string ]
------------


Expand Down
19 changes: 19 additions & 0 deletions builtin-log.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,8 @@ static const char *fmt_patch_suffix = ".patch";
static int numbered = 0;
static int auto_number = 1;

static char *default_attach = NULL;

static char **extra_hdr;
static int extra_hdr_nr;
static int extra_hdr_alloc;
Expand Down Expand Up @@ -488,6 +490,14 @@ static int git_format_config(const char *var, const char *value, void *cb)
auto_number = auto_number && numbered;
return 0;
}
if (!strcmp(var, "format.attach")) {
if (value && *value)
default_attach = xstrdup(value);
else
default_attach = xstrdup(git_version_string);
return 0;
}


return git_log_config(var, value, cb);
}
Expand Down Expand Up @@ -787,6 +797,11 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)

rev.subject_prefix = fmt_patch_subject_prefix;

if (default_attach) {
rev.mime_boundary = default_attach;
rev.no_inline = 1;
}

/*
* Parse the arguments before setup_revisions(), or something
* like "git format-patch -o a123 HEAD^.." may fail; a123 is
Expand Down Expand Up @@ -849,6 +864,10 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
rev.mime_boundary = argv[i] + 9;
rev.no_inline = 1;
}
else if (!strcmp(argv[i], "--no-attach")) {
rev.mime_boundary = NULL;
rev.no_inline = 0;
}
else if (!strcmp(argv[i], "--inline")) {
rev.mime_boundary = git_version_string;
rev.no_inline = 0;
Expand Down

0 comments on commit 2247b45

Please sign in to comment.