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

Re: [PATCH] format-patch let -k override a config-specified format.numbered

From
Jim Meyering <jim@meyering.net>
Date
May 9, 2009, 08:12 UTC
Message-ID
<878wl6ofu6.fsf@meyering.net>
In-Reply-To
<7vbpq2da8v.fsf@alter.siamese.dyndns.org>
Let a command-line --keep-subject (-k) override a config-specified
format.numbered (--numbered (-n)), rather than provoking the
"-n and -k are mutually exclusive" failure.
* t4021-format-patch-numbered.sh: Test for the above
Signed-off-by: Jim Meyering <meyering@redhat.com>
---
Junio C Hamano wrote:
Show 8 quoted lines
> Jim Meyering <meyering@redhat.com> writes:
>> Let a command-line --keep-subject (-k) override a config-specified
>> format.numbered (--numbered (-n)), rather than provoking the
>> "-n and -k are mutually exclusive" failure.
>> * t4021-format-patch-numbered.sh: Test for the above
>> ---
>
> Sign-off?
Whoops. Here you go.
 builtin-log.c                    |   14 +++++++++++++-
 t/t4021-format-patch-numbered.sh |    7 +++++++
 2 files changed, 20 insertions(+), 1 deletions(-)
diff --git a/builtin-log.c b/builtin-log.c
index 5eaec5d..f10cfeb 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -755,6 +755,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 	int cover_letter = 0;
 	int boundary_count = 0;
 	int no_binary_diff = 0;
+	int numbered_cmdline_opt = 0;
 	struct commit *origin = NULL, *head = NULL;
 	const char *in_reply_to = NULL;
 	struct patch_ids ids;
@@ -786,8 +787,10 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 		if (!strcmp(argv[i], "--stdout"))
 			use_stdout = 1;
 		else if (!strcmp(argv[i], "-n") ||
-				!strcmp(argv[i], "--numbered"))
+				!strcmp(argv[i], "--numbered")) {
 			numbered = 1;
+			numbered_cmdline_opt = 1;
+		}
 		else if (!strcmp(argv[i], "-N") ||
 				!strcmp(argv[i], "--no-numbered")) {
 			numbered = 0;
@@ -918,6 +921,15 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)

 	if (start_number < 0)
 		start_number = 1;
+
+	/*
+	 * If numbered is set solely due to format.numbered in config,
+	 * and it would conflict with --keep-subject (-k) from the
+	 * command line, reset "numbered".
+	 */
+	if (numbered && keep_subject && !numbered_cmdline_opt)
+		numbered = 0;
+
 	if (numbered && keep_subject)
 		die ("-n and -k are mutually exclusive.");
 	if (keep_subject && subject_prefix)
diff --git a/t/t4021-format-patch-numbered.sh b/t/t4021-format-patch-numbered.sh
index 390af23..9b6e1be 100755
--- a/t/t4021-format-patch-numbered.sh
+++ b/t/t4021-format-patch-numbered.sh
@@ -86,6 +86,13 @@ test_expect_success 'format.numbered && --no-numbered' '

 '

+test_expect_success 'format.numbered && --keep-subject' '
+
+	git format-patch --keep-subject --stdout HEAD^ >patch4a &&
+	grep "^Subject: Third" patch4a
+
+'
+
 test_expect_success 'format.numbered = auto' '

 	git config format.numbered auto
--
1.6.3.195.gad81
Previous: Junio C Hamano
Message 4 of 4 in “format-patch let -k override a config-specified format.numbered”
  1. format-patch let -k override a config-specified format.numberedJim Meyering, May 7, 2009
  2. Stephen BoydMay 8, 2009
  3. Junio C HamanoMay 9, 2009
  4. Jim MeyeringMay 9, 2009

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.