Skip to content

Commit 37a13ac

Browse files
committed
Merge branch 'mh/format-patch-add-header'
* mh/format-patch-add-header: format-patch: add arbitrary email headers
2 parents 85b7bd5 + d7d9c2d commit 37a13ac

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

Documentation/git-format-patch.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@ if that is not set.
157157
Add a "Cc:" header to the email headers. This is in addition
158158
to any configured headers, and may be used multiple times.
159159

160+
--add-header=<header>::
161+
Add an arbitrary header to the email headers. This is in addition
162+
to any configured headers, and may be used multiple times.
163+
For example, --add-header="Organization: git-foo"
164+
160165
--cover-letter::
161166
In addition to the patches, generate a cover letter file
162167
containing the shortlog and the overall diffstat. You can

builtin-log.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -918,6 +918,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
918918
cover_letter = 1;
919919
else if (!strcmp(argv[i], "--no-binary"))
920920
no_binary_diff = 1;
921+
else if (!prefixcmp(argv[i], "--add-header="))
922+
add_header(argv[i] + 13);
921923
else
922924
argv[j++] = argv[i];
923925
}

t/t4014-format-patch.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,21 @@ test_expect_success 'additional command line cc' '
128128
grep "^ *S. E. Cipient <scipient@example.com>$" patch5
129129
'
130130

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+
131146
test_expect_success 'multiple files' '
132147
133148
rm -rf patches/ &&

0 commit comments

Comments
 (0)