Merge branch 'mh/format-patch-add-header'
authorJunio C Hamano <gitster@pobox.com>
Thu, 2 Apr 2009 05:49:24 +0000 (22:49 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 2 Apr 2009 05:49:24 +0000 (22:49 -0700)
* mh/format-patch-add-header:
format-patch: add arbitrary email headers

Documentation/git-format-patch.txt
builtin-log.c
t/t4014-format-patch.sh
index c105925df8f3e56c6d660a8f88fa5d7c2c935b92..db3bdb5657e4c4c55122ec7f0cd735e623f1dec2 100644 (file)
@@ -157,6 +157,11 @@ if that is not set.
        Add a "Cc:" header to the email headers. This is in addition
        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::
        In addition to the patches, generate a cover letter file
        containing the shortlog and the overall diffstat.  You can
index c7a57725948553a955f49ab891aed3fbdd3aa33d..27bc0dce23d364bd763b7ca92316eef5966c5908 100644 (file)
@@ -918,6 +918,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
                        cover_letter = 1;
                else if (!strcmp(argv[i], "--no-binary"))
                        no_binary_diff = 1;
+               else if (!prefixcmp(argv[i], "--add-header="))
+                       add_header(argv[i] + 13);
                else
                        argv[j++] = argv[i];
        }
index f187d15e328aa43f3d7a7b9030158e0128cc4812..11061ddd5bd122a1e180509c018e1b8bea42ddc3 100755 (executable)
@@ -128,6 +128,21 @@ test_expect_success 'additional command line cc' '
        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' '
 
        rm -rf patches/ &&