Enable setting attach as the default in .gitconfig for git-format-patch.
Signed-off-by: Jeremy White <jwhite@codeweavers.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeremy White committed
Feb 12, 2009 at 09:51 UTC
0db5260bd033cc357186cc13fe23be9635ad69e7
2 files changed
+28
-2
Documentation/git-format-patch.txt
+9
-2
@@ -10,7 +10,8 @@ SYNOPSIS
10
--------
11
[verse]
12
'git format-patch' [-k] [-o <dir> | --stdout] [--thread]
13
- [--attach[=<boundary>] | --inline[=<boundary>]]
13
+ [--attach[=<boundary>] | --inline[=<boundary>] |
14
+ [--no-attach]]
15
[-s | --signoff] [<common diff options>]
16
[-n | --numbered | -N | --no-numbered]
17
[--start-number <n>] [--numbered-files]
@@ -117,6 +118,10 @@ include::diff-options.txt[]
118
which is the commit message and the patch itself in the
119
second part, with "Content-Disposition: attachment".
120
121
+--no-attach::
122
+ Disable the creation of an attachment, overriding the
123
+ configuration setting.
124
+
125
--inline[=<boundary>]::
126
Create multipart/mixed attachment, the first part of
127
which is the commit message and the patch itself in the
@@ -174,7 +179,8 @@ CONFIGURATION
179
-------------
180
You can specify extra mail header lines to be added to each message
181
in the repository configuration, new defaults for the subject prefix
177
-and file suffix, and number patches when outputting more than one.
182
+and file suffix, control attachements, and number patches when outputting
183
+more than one.
184
185
------------
186
[format]
@@ -183,6 +189,7 @@ and file suffix, and number patches when outputting more than one.
189
suffix = .txt
190
numbered = auto
191
cc = <email>
192
+ attach [ = mime-boundary-string ]
193
------------
194
195
builtin-log.c
+19
@@ -428,6 +428,8 @@ static const char *fmt_patch_suffix = ".patch";
428
static int numbered = 0;
429
static int auto_number = 1;
430
431
+static char *default_attach = NULL;
432
+
433
static char **extra_hdr;
434
static int extra_hdr_nr;
435
static int extra_hdr_alloc;
@@ -488,6 +490,14 @@ static int git_format_config(const char *var, const char *value, void *cb)
490
auto_number = auto_number && numbered;
491
return 0;
492
}
493
+ if (!strcmp(var, "format.attach")) {
494
+ if (value && *value)
495
+ default_attach = xstrdup(value);
496
+ else
497
+ default_attach = xstrdup(git_version_string);
498
+ return 0;
499
+ }
500
+
501
502
return git_log_config(var, value, cb);
503
}
@@ -787,6 +797,11 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
797
798
rev.subject_prefix = fmt_patch_subject_prefix;
799
800
+ if (default_attach) {
801
+ rev.mime_boundary = default_attach;
802
+ rev.no_inline = 1;
803
+ }
804
+
805
/*
806
* Parse the arguments before setup_revisions(), or something
807
* like "git format-patch -o a123 HEAD^.." may fail; a123 is
@@ -849,6 +864,10 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
864
rev.mime_boundary = argv[i] + 9;
865
rev.no_inline = 1;
866
}
867
+ else if (!strcmp(argv[i], "--no-attach")) {
868
+ rev.mime_boundary = NULL;
869
+ rev.no_inline = 0;
870
+ }
871
else if (!strcmp(argv[i], "--inline")) {
872
rev.mime_boundary = git_version_string;
873
rev.no_inline = 0;