[PATCH] format-patch: add arbitrary email headers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



format-patch supports the format.headers configuration for adding
arbitrary email headers to the patches it outputs.  This patch adds
support for a --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@xxxxxxxxx>
---
 Documentation/git-format-patch.txt |    5 +++++
 builtin-log.c                      |    2 ++
 t/t4014-format-patch.sh            |   15 +++++++++++++++
 3 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt
index c2eb5fa..e6fe7f3 100644
--- a/Documentation/git-format-patch.txt
+++ b/Documentation/git-format-patch.txt
@@ -161,6 +161,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.
 
+--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, --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
diff --git a/builtin-log.c b/builtin-log.c
index c7a5772..35701a7 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -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], "--header="))
+			add_header( argv[i] + 9 );
 		else
 			argv[j++] = argv[i];
 	}
diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
index f187d15..5f8d9b4 100755
--- a/t/t4014-format-patch.sh
+++ b/t/t4014-format-patch.sh
@@ -128,6 +128,21 @@ test_expect_success 'additional command line cc' '
 	grep "^ *S. E. Cipient <scipient@xxxxxxxxxxx>$" patch5
 '
 
+test_expect_success 'command line headers' '
+
+	git config --unset-all format.headers &&
+	git format-patch --header="Cc: R. E. Cipient <rcipient@xxxxxxxxxxx>" --stdout master..side | sed -e "/^$/q" >patch6 &&
+	grep "^Cc: R. E. Cipient <rcipient@xxxxxxxxxxx>$" patch6
+'
+
+test_expect_success 'configuration headers and command line headers' '
+
+	git config --replace-all format.headers "Cc: R. E. Cipient <rcipient@xxxxxxxxxxx>" &&
+	git format-patch --header="Cc: S. E. Cipient <scipient@xxxxxxxxxxx>" --stdout master..side | sed -e "/^$/q" >patch7 &&
+	grep "^Cc: R. E. Cipient <rcipient@xxxxxxxxxxx>,$" patch7 &&
+	grep "^ *S. E. Cipient <scipient@xxxxxxxxxxx>$" patch7
+'
+
 test_expect_success 'multiple files' '
 
 	rm -rf patches/ &&
-- 
1.6.2.1.318.ged85d

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux