Skip to content

Commit 630501c

Browse files
committed
Merge branch 'jc/countermand-format-attach'
The format.attach configuration variable lacked a way to override a value defined in a lower-priority configuration file (e.g. the system one) by redefining it in a higher-priority configuration file. Now, setting format.attach to an empty string means show the patch inline in the e-mail message, without using MIME attachment. This is a backward incompatible change. * jc/countermand-format-attach: format.attach: allow empty value to disable multi-part messages
2 parents dda83e6 + 50bebf9 commit 630501c

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

Documentation/config/format.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ format.attach::
33
'format-patch'. The value can also be a double quoted string
44
which will enable attachments as the default and set the
55
value as the boundary. See the --attach option in
6-
linkgit:git-format-patch[1].
6+
linkgit:git-format-patch[1]. To countermand an earlier
7+
value, set it to an empty string.
78

89
format.from::
910
Provides the default value for the `--from` option to format-patch.

builtin/log.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,6 +1007,8 @@ static int git_format_config(const char *var, const char *value, void *cb)
10071007
if (!strcmp(var, "format.attach")) {
10081008
if (value && *value)
10091009
default_attach = xstrdup(value);
1010+
else if (value && !*value)
1011+
FREE_AND_NULL(default_attach);
10101012
else
10111013
default_attach = xstrdup(git_version_string);
10121014
return 0;

t/t4014-format-patch.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2281,6 +2281,24 @@ test_expect_success 'format-patch --attach cover-letter only is non-multipart' '
22812281
test_line_count = 1 output
22822282
'
22832283

2284+
test_expect_success 'format-patch with format.attach' '
2285+
test_when_finished "rm -fr patches" &&
2286+
separator=attachment-separator &&
2287+
test_config format.attach "$separator" &&
2288+
filename=$(git format-patch -o patches -1) &&
2289+
grep "^Content-Type: multipart/.*$separator" "$filename"
2290+
'
2291+
2292+
test_expect_success 'format-patch with format.attach=disabled' '
2293+
test_when_finished "rm -fr patches" &&
2294+
separator=attachment-separator &&
2295+
test_config_global format.attach "$separator" &&
2296+
test_config format.attach "" &&
2297+
filename=$(git format-patch -o patches -1) &&
2298+
# The output should not even declare content type for text/plain.
2299+
! grep "^Content-Type: multipart/" "$filename"
2300+
'
2301+
22842302
test_expect_success '-c format.mboxrd format-patch' '
22852303
sp=" " &&
22862304
cat >msg <<-INPUT_END &&

0 commit comments

Comments
 (0)