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: Michael Hendricks <michael@ndrix.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Hendricks committed
Mar 26, 2009 at 10:51 UTC
d7d9c2d04962b5aec34ec891d82dd74262306c56
3 files changed
+22
Documentation/git-format-patch.txt
+5
@@ -161,6 +161,11 @@ if that is not set.
161
Add a "Cc:" header to the email headers. This is in addition
162
to any configured headers, and may be used multiple times.
163
164
+--add-header=<header>::
165
+ Add an arbitrary header to the email headers. This is in addition
166
+ to any configured headers, and may be used multiple times.
167
+ For example, --add-header="Organization: git-foo"
168
+
169
--cover-letter::
170
In addition to the patches, generate a cover letter file
171
containing the shortlog and the overall diffstat. You can
builtin-log.c
+2
@@ -918,6 +918,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
918
cover_letter = 1;
919
else if (!strcmp(argv[i], "--no-binary"))
920
no_binary_diff = 1;
921
+ else if (!prefixcmp(argv[i], "--add-header="))
922
+ add_header(argv[i] + 13);
923
else
924
argv[j++] = argv[i];
925
}
t/t4014-format-patch.sh
+15
@@ -128,6 +128,21 @@ test_expect_success 'additional command line cc' '
128
grep "^ *S. E. Cipient <scipient@example.com>$" patch5
129
'
130
131
+test_expect_success 'command line headers' '
132
+
133
+ git config --unset-all format.headers &&
134
+ git format-patch --add-header="Cc: R. E. Cipient <rcipient@example.com>" --stdout master..side | sed -e "/^$/q" >patch6 &&
135
+ grep "^Cc: R. E. Cipient <rcipient@example.com>$" patch6
136
+'
137
+
138
+test_expect_success 'configuration headers and command line headers' '
139
+
140
+ git config --replace-all format.headers "Cc: R. E. Cipient <rcipient@example.com>" &&
141
+ git format-patch --add-header="Cc: S. E. Cipient <scipient@example.com>" --stdout master..side | sed -e "/^$/q" >patch7 &&
142
+ grep "^Cc: R. E. Cipient <rcipient@example.com>,$" patch7 &&
143
+ grep "^ *S. E. Cipient <scipient@example.com>$" patch7
144
+'
145
+
146
test_expect_success 'multiple files' '
147
148
rm -rf patches/ &&