git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Miklos Vajna <vmiklos@frugalware.org>
Date
Mar 6, 2010, 21:06 UTC
Message-ID
<20100306210650.GO27414@genesis.frugalware.org>
In-Reply-To
<7vr5nykx55.fsf@alter.siamese.dyndns.org>
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:
> This reveals that --to does not follow the usual rule to override
> corresponding configuration.  Is that really what we want?  IOW, when the
> command line says scipient, shouldn't we stop sending to recipient that
> comes from the configuration?  How else would a user override this?

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
Previous: Junio C HamanoNext: Stephen Boyd
Message 18 of 38 in “What's cooking in git.git (Mar 2010, #01; Wed, 03)”
  1. Junio C HamanoMar 4, 2010
  2. Adam SimpkinsMar 4, 2010
  3. Björn GustavssonMar 4, 2010
  4. Junio C HamanoMar 4, 2010
  5. Tay Ray ChuanMar 4, 2010
  6. Junio C HamanoMar 4, 2010
  7. Junio C HamanoMar 4, 2010
  8. Junio C HamanoMar 5, 2010
  9. git reset --keep (Re: What's cooking in git.git (Mar 2010, #01; Wed, 03))Jonathan Nieder, Mar 5, 2010
  10. Christian CouderMar 5, 2010
  11. Christian CouderMar 5, 2010
  12. Thomas RastMar 4, 2010
  13. Mark LodatoMar 5, 2010
  14. Mark LodatoMar 5, 2010
  15. Junio C HamanoMar 5, 2010
  16. Add tests for git format-patch --to and format.to config optionMiklos Vajna, Mar 6, 2010
  17. Junio C HamanoMar 6, 2010
  18. format-patch --to: overwrite format.to contents, don't append itMiklos Vajna, Mar 6, 2010
  19. Stephen BoydMar 7, 2010
  20. Miklos VajnaMar 7, 2010
  21. Junio C HamanoMar 7, 2010
  22. Stephen BoydMar 7, 2010
  23. Junio C HamanoMar 7, 2010
  24. 0/4 format-patch and send-email ignoring config settingsStephen Boyd, Mar 7, 2010
  25. 0/3 format-patch and send-email ignoring config settingsStephen Boyd, Mar 7, 2010
  26. 1/3 format-patch: use a string_list for headersStephen Boyd, Mar 7, 2010
  27. 2/3 format-patch: add --no-cc, --no-to, and --no-add-headersStephen Boyd, Mar 7, 2010
  28. 3/3 send-email: add --no-cc, --no-to, and --no-bccStephen Boyd, Mar 7, 2010
  29. Junio C HamanoMar 9, 2010
  30. 1/4 send-email: actually add bcc headersStephen Boyd, Mar 7, 2010
  31. Stephen BoydMar 7, 2010
  32. 2/4 format-patch: use a string_list for headersStephen Boyd, Mar 7, 2010
  33. Erik Faye-LundMar 7, 2010
  34. Stephen BoydMar 7, 2010
  35. Johannes SchindelinMar 7, 2010
  36. 3/4 format-patch: add --no-cc, --no-to, and --no-add-headersStephen Boyd, Mar 7, 2010
  37. 4/4 send-email: add --no-cc, --no-to, and --no-bccStephen Boyd, Mar 7, 2010
  38. Steven DrakeMar 10, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.