提交 d7d9c2d0 编写于 作者: M Michael Hendricks 提交者: Junio C Hamano

format-patch: add arbitrary email headers

format-patch supports the format.headers configuration for adding
arbitrary email headers to the patches it outputs.  This patch adds
support for an --add-header argument which makes the same feature
available from the command line.  This is useful when the content of
custom email headers must change from branch to branch.

This patch has been sponsored by Grant Street Group
Signed-off-by: NMichael Hendricks <michael@ndrix.org>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 eed1fcd7
...@@ -161,6 +161,11 @@ if that is not set. ...@@ -161,6 +161,11 @@ if that is not set.
Add a "Cc:" header to the email headers. This is in addition Add a "Cc:" header to the email headers. This is in addition
to any configured headers, and may be used multiple times. to any configured headers, and may be used multiple times.
--add-header=<header>::
Add an arbitrary header to the email headers. This is in addition
to any configured headers, and may be used multiple times.
For example, --add-header="Organization: git-foo"
--cover-letter:: --cover-letter::
In addition to the patches, generate a cover letter file In addition to the patches, generate a cover letter file
containing the shortlog and the overall diffstat. You can containing the shortlog and the overall diffstat. You can
......
...@@ -918,6 +918,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) ...@@ -918,6 +918,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
cover_letter = 1; cover_letter = 1;
else if (!strcmp(argv[i], "--no-binary")) else if (!strcmp(argv[i], "--no-binary"))
no_binary_diff = 1; no_binary_diff = 1;
else if (!prefixcmp(argv[i], "--add-header="))
add_header(argv[i] + 13);
else else
argv[j++] = argv[i]; argv[j++] = argv[i];
} }
......
...@@ -128,6 +128,21 @@ test_expect_success 'additional command line cc' ' ...@@ -128,6 +128,21 @@ test_expect_success 'additional command line cc' '
grep "^ *S. E. Cipient <scipient@example.com>$" patch5 grep "^ *S. E. Cipient <scipient@example.com>$" patch5
' '
test_expect_success 'command line headers' '
git config --unset-all format.headers &&
git format-patch --add-header="Cc: R. E. Cipient <rcipient@example.com>" --stdout master..side | sed -e "/^$/q" >patch6 &&
grep "^Cc: R. E. Cipient <rcipient@example.com>$" patch6
'
test_expect_success 'configuration headers and command line headers' '
git config --replace-all format.headers "Cc: R. E. Cipient <rcipient@example.com>" &&
git format-patch --add-header="Cc: S. E. Cipient <scipient@example.com>" --stdout master..side | sed -e "/^$/q" >patch7 &&
grep "^Cc: R. E. Cipient <rcipient@example.com>,$" patch7 &&
grep "^ *S. E. Cipient <scipient@example.com>$" patch7
'
test_expect_success 'multiple files' ' test_expect_success 'multiple files' '
rm -rf patches/ && rm -rf patches/ &&
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册