diff options
| author | Junio C Hamano <gitster@pobox.com> | 2023-02-27 10:08:57 -0800 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2023-02-27 10:08:57 -0800 |
| commit | 630501ceef6a70203f89ab62c9909c96a2d751ec (patch) | |
| tree | 3c5c2719dbb9958b37c12ffd98aa368dbc73c1e2 | |
| parent | Merge branch 'jk/shorten-unambiguous-ref-wo-sscanf' (diff) | |
| parent | format.attach: allow empty value to disable multi-part messages (diff) | |
| download | git-630501ceef6a70203f89ab62c9909c96a2d751ec.tar.gz git-630501ceef6a70203f89ab62c9909c96a2d751ec.zip | |
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
| -rw-r--r-- | Documentation/config/format.txt | 3 | ||||
| -rw-r--r-- | builtin/log.c | 2 | ||||
| -rwxr-xr-x | t/t4014-format-patch.sh | 18 |
3 files changed, 22 insertions, 1 deletions
diff --git a/Documentation/config/format.txt b/Documentation/config/format.txt index 3bd78269e2..73678d88a1 100644 --- a/Documentation/config/format.txt +++ b/Documentation/config/format.txt @@ -3,7 +3,8 @@ format.attach:: 'format-patch'. The value can also be a double quoted string which will enable attachments as the default and set the value as the boundary. See the --attach option in - linkgit:git-format-patch[1]. + linkgit:git-format-patch[1]. To countermand an earlier + value, set it to an empty string. format.from:: Provides the default value for the `--from` option to format-patch. diff --git a/builtin/log.c b/builtin/log.c index 04412dd9c9..a70fba198f 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -1007,6 +1007,8 @@ static int git_format_config(const char *var, const char *value, void *cb) if (!strcmp(var, "format.attach")) { if (value && *value) default_attach = xstrdup(value); + else if (value && !*value) + FREE_AND_NULL(default_attach); else default_attach = xstrdup(git_version_string); return 0; diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index 012f155e10..f3313b8c58 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -2281,6 +2281,24 @@ test_expect_success 'format-patch --attach cover-letter only is non-multipart' ' test_line_count = 1 output ' +test_expect_success 'format-patch with format.attach' ' + test_when_finished "rm -fr patches" && + separator=attachment-separator && + test_config format.attach "$separator" && + filename=$(git format-patch -o patches -1) && + grep "^Content-Type: multipart/.*$separator" "$filename" +' + +test_expect_success 'format-patch with format.attach=disabled' ' + test_when_finished "rm -fr patches" && + separator=attachment-separator && + test_config_global format.attach "$separator" && + test_config format.attach "" && + filename=$(git format-patch -o patches -1) && + # The output should not even declare content type for text/plain. + ! grep "^Content-Type: multipart/" "$filename" +' + test_expect_success '-c format.mboxrd format-patch' ' sp=" " && cat >msg <<-INPUT_END && |
