git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] format-patch: add arbitrary email headers
@ 2009-03-25 15:58 Michael Hendricks
  2009-03-25 19:11 ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Hendricks @ 2009-03-25 15:58 UTC (permalink / raw)
  To: git, gitster; +Cc: Michael Hendricks

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@ndrix.org>
---
 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@example.com>$" patch5
 '
 
+test_expect_success 'command line headers' '
+
+	git config --unset-all format.headers &&
+	git format-patch --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 --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/ &&
-- 
1.6.2.1.318.ged85d

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] format-patch: add arbitrary email headers
  2009-03-25 15:58 [PATCH] format-patch: add arbitrary email headers Michael Hendricks
@ 2009-03-25 19:11 ` Junio C Hamano
  2009-03-26 16:42   ` Michael Hendricks
  0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2009-03-25 19:11 UTC (permalink / raw)
  To: Michael Hendricks; +Cc: git

Michael Hendricks <michael@ndrix.org> writes:

> 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.

How should this interact with the configuration variable?

Typically we allow command line options to override the matching config
variable, so that people can say "here are the settings I ordinarily use"
in the config file, and say "but I do not want the usual values to take
effect for this particular invocation; please use these _instead_" with
command line options.

Note that the above question is "how should this interact"; not "how does
this interact".  I can see you chose to make this cumulative in your patch
and the documentaiton.

I am asking if that is what the users want, overriding is preferred, or
perhaps another option to clear extra headers (say, "--no-extra-headers")
is necessary to allow both.

> 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 );

No extra SP immediately after ( and before ), please.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] format-patch: add arbitrary email headers
  2009-03-25 19:11 ` Junio C Hamano
@ 2009-03-26 16:42   ` Michael Hendricks
  2009-03-26 16:51     ` Michael Hendricks
  2009-03-26 20:29     ` Junio C Hamano
  0 siblings, 2 replies; 5+ messages in thread
From: Michael Hendricks @ 2009-03-26 16:42 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On Wed, Mar 25, 2009 at 12:11:02PM -0700, Junio C Hamano wrote:
> Michael Hendricks <michael@ndrix.org> writes:
> 
> > 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.
> 
> How should this interact with the configuration variable?
> 
> Typically we allow command line options to override the matching config
> variable, so that people can say "here are the settings I ordinarily use"
> in the config file, and say "but I do not want the usual values to take
> effect for this particular invocation; please use these _instead_" with
> command line options.
> 
> Note that the above question is "how should this interact"; not "how does
> this interact".  I can see you chose to make this cumulative in your patch
> and the documentaiton.
> 
> I am asking if that is what the users want, overriding is preferred, or
> perhaps another option to clear extra headers (say, "--no-extra-headers")
> is necessary to allow both.

In all the cases where I use custom headers on patch emails, I want
the command line headers to be cumulative with the config headers.  I
only configure headers which are constant (such as "X-Project:
project-name").  The ones that vary have no reasonable default value
since they typically represent a bug tracking number or something
similar.

Perhaps --add-header is a better name for this argument.  That name at
least makes it clear that headers specified on the command line are
cumulative.  If someone has a use case for --no-extra-headers, they
can add it later and --add-header retains the same meaning.

Follow-up patch coming shortly.

-- 
Michael

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] format-patch: add arbitrary email headers
  2009-03-26 16:42   ` Michael Hendricks
@ 2009-03-26 16:51     ` Michael Hendricks
  2009-03-26 20:29     ` Junio C Hamano
  1 sibling, 0 replies; 5+ messages in thread
From: Michael Hendricks @ 2009-03-26 16:51 UTC (permalink / raw)
  To: gitster, git; +Cc: Michael Hendricks

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>
---
 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..51fd716 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.
 
+--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
diff --git a/builtin-log.c b/builtin-log.c
index c7a5772..27bc0dc 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], "--add-header="))
+			add_header(argv[i] + 13);
 		else
 			argv[j++] = argv[i];
 	}
diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
index f187d15..11061dd 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@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/ &&
-- 
1.6.2.1.317.ga1cbc

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] format-patch: add arbitrary email headers
  2009-03-26 16:42   ` Michael Hendricks
  2009-03-26 16:51     ` Michael Hendricks
@ 2009-03-26 20:29     ` Junio C Hamano
  1 sibling, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2009-03-26 20:29 UTC (permalink / raw)
  To: Michael Hendricks; +Cc: git

Michael Hendricks <michael@ndrix.org> writes:

> Perhaps --add-header is a better name for this argument.  That name at
> least makes it clear that headers specified on the command line are
> cumulative.  If someone has a use case for --no-extra-headers, they
> can add it later and --add-header retains the same meaning.

Sounds very sane.  Thanks.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-03-26 20:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-25 15:58 [PATCH] format-patch: add arbitrary email headers Michael Hendricks
2009-03-25 19:11 ` Junio C Hamano
2009-03-26 16:42   ` Michael Hendricks
2009-03-26 16:51     ` Michael Hendricks
2009-03-26 20:29     ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).