{"thread":{"id":"18536","subject":"[PATCH] format-patch: add arbitrary email headers","startedAt":"2009-03-25T15:58:32Z","lastAt":"2009-03-26T20:29:34Z","messageCount":5,"participants":["Michael Hendricks","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"109363","messageId":"1237996712-61859-1-git-send-email-michael@ndrix.org","threadId":"18536","inReplyTo":null,"subject":"[PATCH] format-patch: add arbitrary email headers","fromName":"Michael Hendricks","fromEmail":"michael@ndrix.org","sentAt":"2009-03-25T15:58:32Z","receivedAt":"2009-03-25T15:58:32Z","isPatch":true,"sender":{"key":"michael@ndrix.org","avatar":"https://gravatar.com/avatar/315311e6daa79f24e5648f9534420c24ec48eada42efd4110f1d17167ff44fa8?d=mp&s=160"},"body":"format-patch supports the format.headers configuration for adding\narbitrary email headers to the patches it outputs.  This patch adds\nsupport for a --header argument which makes the same feature available\nfrom the command line.  This is useful when the content of custom\nemail headers must change from branch to branch.\n\nThis patch has been sponsored by Grant Street Group\n\nSigned-off-by: Michael Hendricks <michael@ndrix.org>\n---\n Documentation/git-format-patch.txt |    5 +++++\n builtin-log.c                      |    2 ++\n t/t4014-format-patch.sh            |   15 +++++++++++++++\n 3 files changed, 22 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt\nindex c2eb5fa..e6fe7f3 100644\n--- a/Documentation/git-format-patch.txt\n+++ b/Documentation/git-format-patch.txt\n@@ -161,6 +161,11 @@ if that is not set.\n \tAdd a \"Cc:\" header to the email headers. This is in addition\n \tto any configured headers, and may be used multiple times.\n \n+--header=<header>::\n+\tAdd an arbitrary header to the email headers.  This is in addition\n+\tto any configured headers, and may be used multiple times.\n+\tFor example, --header=\"Organization: git-foo\"\n+\n --cover-letter::\n \tIn addition to the patches, generate a cover letter file\n \tcontaining the shortlog and the overall diffstat.  You can\ndiff --git a/builtin-log.c b/builtin-log.c\nindex c7a5772..35701a7 100644\n--- a/builtin-log.c\n+++ b/builtin-log.c\n@@ -918,6 +918,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \t\t\tcover_letter = 1;\n \t\telse if (!strcmp(argv[i], \"--no-binary\"))\n \t\t\tno_binary_diff = 1;\n+\t\telse if (!prefixcmp(argv[i], \"--header=\"))\n+\t\t\tadd_header( argv[i] + 9 );\n \t\telse\n \t\t\targv[j++] = argv[i];\n \t}\ndiff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh\nindex f187d15..5f8d9b4 100755\n--- a/t/t4014-format-patch.sh\n+++ b/t/t4014-format-patch.sh\n@@ -128,6 +128,21 @@ test_expect_success 'additional command line cc' '\n \tgrep \"^ *S. E. Cipient <scipient@example.com>$\" patch5\n '\n \n+test_expect_success 'command line headers' '\n+\n+\tgit config --unset-all format.headers &&\n+\tgit format-patch --header=\"Cc: R. E. Cipient <rcipient@example.com>\" --stdout master..side | sed -e \"/^$/q\" >patch6 &&\n+\tgrep \"^Cc: R. E. Cipient <rcipient@example.com>$\" patch6\n+'\n+\n+test_expect_success 'configuration headers and command line headers' '\n+\n+\tgit config --replace-all format.headers \"Cc: R. E. Cipient <rcipient@example.com>\" &&\n+\tgit format-patch --header=\"Cc: S. E. Cipient <scipient@example.com>\" --stdout master..side | sed -e \"/^$/q\" >patch7 &&\n+\tgrep \"^Cc: R. E. Cipient <rcipient@example.com>,$\" patch7 &&\n+\tgrep \"^ *S. E. Cipient <scipient@example.com>$\" patch7\n+'\n+\n test_expect_success 'multiple files' '\n \n \trm -rf patches/ &&\n-- \n1.6.2.1.318.ged85d\n"},{"id":"109401","messageId":"7v3ad11kqh.fsf@gitster.siamese.dyndns.org","threadId":"18536","inReplyTo":"1237996712-61859-1-git-send-email-michael@ndrix.org","subject":"Re: [PATCH] format-patch: add arbitrary email headers","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-03-25T19:11:02Z","receivedAt":"2009-03-25T19:11:02Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael Hendricks <michael@ndrix.org> writes:\n\n> format-patch supports the format.headers configuration for adding\n> arbitrary email headers to the patches it outputs.  This patch adds\n> support for a --header argument which makes the same feature available\n> from the command line.  This is useful when the content of custom\n> email headers must change from branch to branch.\n\nHow should this interact with the configuration variable?\n\nTypically we allow command line options to override the matching config\nvariable, so that people can say \"here are the settings I ordinarily use\"\nin the config file, and say \"but I do not want the usual values to take\neffect for this particular invocation; please use these _instead_\" with\ncommand line options.\n\nNote that the above question is \"how should this interact\"; not \"how does\nthis interact\".  I can see you chose to make this cumulative in your patch\nand the documentaiton.\n\nI am asking if that is what the users want, overriding is preferred, or\nperhaps another option to clear extra headers (say, \"--no-extra-headers\")\nis necessary to allow both.\n\n> diff --git a/builtin-log.c b/builtin-log.c\n> index c7a5772..35701a7 100644\n> --- a/builtin-log.c\n> +++ b/builtin-log.c\n> @@ -918,6 +918,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n>  \t\t\tcover_letter = 1;\n>  \t\telse if (!strcmp(argv[i], \"--no-binary\"))\n>  \t\t\tno_binary_diff = 1;\n> +\t\telse if (!prefixcmp(argv[i], \"--header=\"))\n> +\t\t\tadd_header( argv[i] + 9 );\n\nNo extra SP immediately after ( and before ), please.\n"},{"id":"109550","messageId":"20090326164212.GF29569@ginosko.ndrix.org","threadId":"18536","inReplyTo":"7v3ad11kqh.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] format-patch: add arbitrary email headers","fromName":"Michael Hendricks","fromEmail":"michael@ndrix.org","sentAt":"2009-03-26T16:42:12Z","receivedAt":"2009-03-26T16:42:12Z","isPatch":true,"sender":{"key":"michael@ndrix.org","avatar":"https://gravatar.com/avatar/315311e6daa79f24e5648f9534420c24ec48eada42efd4110f1d17167ff44fa8?d=mp&s=160"},"body":"On Wed, Mar 25, 2009 at 12:11:02PM -0700, Junio C Hamano wrote:\n> Michael Hendricks <michael@ndrix.org> writes:\n> \n> > format-patch supports the format.headers configuration for adding\n> > arbitrary email headers to the patches it outputs.  This patch adds\n> > support for a --header argument which makes the same feature available\n> > from the command line.  This is useful when the content of custom\n> > email headers must change from branch to branch.\n> \n> How should this interact with the configuration variable?\n> \n> Typically we allow command line options to override the matching config\n> variable, so that people can say \"here are the settings I ordinarily use\"\n> in the config file, and say \"but I do not want the usual values to take\n> effect for this particular invocation; please use these _instead_\" with\n> command line options.\n> \n> Note that the above question is \"how should this interact\"; not \"how does\n> this interact\".  I can see you chose to make this cumulative in your patch\n> and the documentaiton.\n> \n> I am asking if that is what the users want, overriding is preferred, or\n> perhaps another option to clear extra headers (say, \"--no-extra-headers\")\n> is necessary to allow both.\n\nIn all the cases where I use custom headers on patch emails, I want\nthe command line headers to be cumulative with the config headers.  I\nonly configure headers which are constant (such as \"X-Project:\nproject-name\").  The ones that vary have no reasonable default value\nsince they typically represent a bug tracking number or something\nsimilar.\n\nPerhaps --add-header is a better name for this argument.  That name at\nleast makes it clear that headers specified on the command line are\ncumulative.  If someone has a use case for --no-extra-headers, they\ncan add it later and --add-header retains the same meaning.\n\nFollow-up patch coming shortly.\n\n-- \nMichael\n"},{"id":"109552","messageId":"1238086265-71476-1-git-send-email-michael@ndrix.org","threadId":"18536","inReplyTo":"20090326164212.GF29569@ginosko.ndrix.org","subject":"[PATCH] format-patch: add arbitrary email headers","fromName":"Michael Hendricks","fromEmail":"michael@ndrix.org","sentAt":"2009-03-26T16:51:05Z","receivedAt":"2009-03-26T16:51:05Z","isPatch":true,"sender":{"key":"michael@ndrix.org","avatar":"https://gravatar.com/avatar/315311e6daa79f24e5648f9534420c24ec48eada42efd4110f1d17167ff44fa8?d=mp&s=160"},"body":"format-patch supports the format.headers configuration for adding\narbitrary email headers to the patches it outputs.  This patch adds\nsupport for an --add-header argument which makes the same feature\navailable from the command line.  This is useful when the content of\ncustom email headers must change from branch to branch.\n\nThis patch has been sponsored by Grant Street Group\n\nSigned-off-by: Michael Hendricks <michael@ndrix.org>\n---\n Documentation/git-format-patch.txt |    5 +++++\n builtin-log.c                      |    2 ++\n t/t4014-format-patch.sh            |   15 +++++++++++++++\n 3 files changed, 22 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt\nindex c2eb5fa..51fd716 100644\n--- a/Documentation/git-format-patch.txt\n+++ b/Documentation/git-format-patch.txt\n@@ -161,6 +161,11 @@ if that is not set.\n \tAdd a \"Cc:\" header to the email headers. This is in addition\n \tto any configured headers, and may be used multiple times.\n \n+--add-header=<header>::\n+\tAdd an arbitrary header to the email headers.  This is in addition\n+\tto any configured headers, and may be used multiple times.\n+\tFor example, --add-header=\"Organization: git-foo\"\n+\n --cover-letter::\n \tIn addition to the patches, generate a cover letter file\n \tcontaining the shortlog and the overall diffstat.  You can\ndiff --git a/builtin-log.c b/builtin-log.c\nindex c7a5772..27bc0dc 100644\n--- a/builtin-log.c\n+++ b/builtin-log.c\n@@ -918,6 +918,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \t\t\tcover_letter = 1;\n \t\telse if (!strcmp(argv[i], \"--no-binary\"))\n \t\t\tno_binary_diff = 1;\n+\t\telse if (!prefixcmp(argv[i], \"--add-header=\"))\n+\t\t\tadd_header(argv[i] + 13);\n \t\telse\n \t\t\targv[j++] = argv[i];\n \t}\ndiff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh\nindex f187d15..11061dd 100755\n--- a/t/t4014-format-patch.sh\n+++ b/t/t4014-format-patch.sh\n@@ -128,6 +128,21 @@ test_expect_success 'additional command line cc' '\n \tgrep \"^ *S. E. Cipient <scipient@example.com>$\" patch5\n '\n \n+test_expect_success 'command line headers' '\n+\n+\tgit config --unset-all format.headers &&\n+\tgit format-patch --add-header=\"Cc: R. E. Cipient <rcipient@example.com>\" --stdout master..side | sed -e \"/^$/q\" >patch6 &&\n+\tgrep \"^Cc: R. E. Cipient <rcipient@example.com>$\" patch6\n+'\n+\n+test_expect_success 'configuration headers and command line headers' '\n+\n+\tgit config --replace-all format.headers \"Cc: R. E. Cipient <rcipient@example.com>\" &&\n+\tgit format-patch --add-header=\"Cc: S. E. Cipient <scipient@example.com>\" --stdout master..side | sed -e \"/^$/q\" >patch7 &&\n+\tgrep \"^Cc: R. E. Cipient <rcipient@example.com>,$\" patch7 &&\n+\tgrep \"^ *S. E. Cipient <scipient@example.com>$\" patch7\n+'\n+\n test_expect_success 'multiple files' '\n \n \trm -rf patches/ &&\n-- \n1.6.2.1.317.ga1cbc\n"},{"id":"109567","messageId":"7viqlwm3ip.fsf@gitster.siamese.dyndns.org","threadId":"18536","inReplyTo":"20090326164212.GF29569@ginosko.ndrix.org","subject":"Re: [PATCH] format-patch: add arbitrary email headers","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-03-26T20:29:34Z","receivedAt":"2009-03-26T20:29:34Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael Hendricks <michael@ndrix.org> writes:\n\n> Perhaps --add-header is a better name for this argument.  That name at\n> least makes it clear that headers specified on the command line are\n> cumulative.  If someone has a use case for --no-extra-headers, they\n> can add it later and --add-header retains the same meaning.\n\nSounds very sane.  Thanks.\n"}]}