[PATCH] format-patch --to: overwrite format.to contents, don't append it

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Miklos Vajna
Date: Saturday, March 6, 2010 - 2:06 pm

Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
---

On Fri, Mar 05, 2010 at 06:21:42PM -0800, Junio C Hamano <gitster@pobox.com> wrote:

Fair enough, here is a patch to update both the testcase and the code to
the wished behaviour.

 builtin-log.c           |    6 ++++++
 t/t4014-format-patch.sh |    5 +++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/builtin-log.c b/builtin-log.c
index 5d23a67..cc28357 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -465,6 +465,7 @@ static int extra_hdr_alloc;
 static char **extra_to;
 static int extra_to_nr;
 static int extra_to_alloc;
+static int extra_to_config = 0;
 
 static char **extra_cc;
 static int extra_cc_nr;
@@ -507,6 +508,7 @@ static int git_format_config(const char *var, const char *value, void *cb)
 	if (!strcmp(var, "format.to")) {
 		if (!value)
 			return config_error_nonbool(var);
+		extra_to_config = 1;
 		ALLOC_GROW(extra_to, extra_to_nr + 1, extra_to_alloc);
 		extra_to[extra_to_nr++] = xstrdup(value);
 		return 0;
@@ -884,6 +886,10 @@ static int header_callback(const struct option *opt, const char *arg, int unset)
 
 static int to_callback(const struct option *opt, const char *arg, int unset)
 {
+	if (extra_to_config) {
+		extra_to_config = 0;
+		extra_to_nr = 0;
+	}
 	ALLOC_GROW(extra_to, extra_to_nr + 1, extra_to_alloc);
 	extra_to[extra_to_nr++] = xstrdup(arg);
 	return 0;
diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
index 9305c98..6fc071a 100755
--- a/t/t4014-format-patch.sh
+++ b/t/t4014-format-patch.sh
@@ -546,9 +546,10 @@ test_expect_success 'configuration to' '
 
 test_expect_success 'additional command line to' '
 
+	git config --unset-all format.headers &&
 	git format-patch --to="S. E. Cipient <scipient@example.com>" --stdout master..side | sed -e "/^\$/q" >patch11 &&
-	grep "^To: R. E. Cipient <rcipient@example.com>,\$" patch11 &&
-	grep "^ *S. E. Cipient <scipient@example.com>\$" patch11
+	! grep "R. E. Cipient <rcipient@example.com>" patch11 &&
+	grep "^To: S. E. Cipient <scipient@example.com>\$" patch11
 '
 
 test_expect_success 'format-patch --signoff' '
-- 
1.7.0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
What's cooking in git.git (Mar 2010, #01; Wed, 03), Junio C Hamano, (Wed Mar 3, 5:02 pm)
Re: What's cooking in git.git (Mar 2010, #01; Wed, 03), Adam Simpkins, (Wed Mar 3, 5:36 pm)
Re: What's cooking in git.git (Mar 2010, #01; Wed, 03), =?UTF-8?Q?Bj=C3=B6rn ..., (Thu Mar 4, 1:26 am)
Re: What's cooking in git.git (Mar 2010, #01; Wed, 03), Tay Ray Chuan, (Thu Mar 4, 5:09 am)
Re: What's cooking in git.git (Mar 2010, #01; Wed, 03), Junio C Hamano, (Thu Mar 4, 11:26 am)
Re: What's cooking in git.git (Mar 2010, #01; Wed, 03), Junio C Hamano, (Thu Mar 4, 11:26 am)
Re: What's cooking in git.git (Mar 2010, #01; Wed, 03), Junio C Hamano, (Thu Mar 4, 2:42 pm)
Re: What's cooking in git.git (Mar 2010, #01; Wed, 03), Junio C Hamano, (Thu Mar 4, 5:49 pm)
Re: What's cooking in git.git (Mar 2010, #01; Wed, 03), Junio C Hamano, (Thu Mar 4, 8:23 pm)
Re: What's cooking in git.git (Mar 2010, #01; Wed, 03), Christian Couder, (Fri Mar 5, 10:32 am)
[PATCH] format-patch --to: overwrite format.to contents, d ..., Miklos Vajna, (Sat Mar 6, 2:06 pm)
[PATCH 1/4] send-email: actually add bcc headers, Stephen Boyd, (Sun Mar 7, 2:33 pm)
Re: [PATCH 1/4] send-email: actually add bcc headers, Stephen Boyd, (Sun Mar 7, 2:53 pm)
Re: [PATCH 2/4] format-patch: use a string_list for headers, Johannes Schindelin, (Sun Mar 7, 3:13 pm)