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

Re: git-format-patch possible regressions

From
MCMarco Costalba <mcostalba@gmail.com>
Date
May 27, 2006, 09:12 UTC
Message-ID
<e5bfff550605270212n267661rd0463a301cbe1b95@mail.gmail.com>
In-Reply-To
<7v4pzdqpit.fsf@assigned-by-dhcp.cox.net>
On 5/26/06, Junio C Hamano <junkio@cox.net> wrote:
Show 6 quoted lines
>
> What Johannes and I were discussing was the other number -- the
> total in the series.  IOW, y in "[PATCH x/y]".  OTOH, the number
> used for disambiguation you care about is x, which is made
> adjustable with --start-number patch.
>
New --start-number patch says:

"Since the "a..b c..d" syntax is interpreted as "b ^a d ^c" as other range-ish commands, if you want to format a..b and then c..d and end up with files consecutively numbered, the second run needs to be able to tell the command what number to start from.

This does not imply --numbered (which gives [PATCH n/m] to the subject)."
Actually it seems that --numbered is needed anyway.

$ git-format-patch HEAD^..HEAD 0000-git-format-patch-start-number-n.txt $ git-format-patch --start-number=7 HEAD^..HEAD 0000-git-format-patch-start-number-n.txt $ git-format-patch --numbered --start-number=7 HEAD^..HEAD 0007-git-format-patch-start-number-n.txt

But with numbered also the patch subject is changed with added [PATCH n/m] that is not needed.

Also mutually exclusive check is not performed git-format-patch -n -k HEAD^..HEAD 0001-git-format-patch-start-number-n.txt

This patch should fix all.
Subject: [PATCH] Let git-format-patch --start-number option to work
also without --numbered
While there also fix the check for mutually exclusive -n and -k option
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
---
 builtin-log.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/builtin-log.c b/builtin-log.c
index 71f4ff9..c35733f 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -148,7 +148,7 @@ int cmd_format_patch(int argc, const cha
 	int nr = 0, total, i, j;
 	int use_stdout = 0;
 	int numbered = 0;
-	int start_number = -1;
+	int start_number = 0;
 	int keep_subject = 0;

 	init_revisions(&rev);
@@ -201,9 +201,9 @@ int cmd_format_patch(int argc, const cha
 	}
 	argc = j;

-	if (numbered && start_number < 0)
+	if (numbered && start_number == 0)
 		start_number = 1;
-	if (numbered && keep_subject < 0)
+	if (numbered && keep_subject)
 		die ("-n and -k are mutually exclusive.");

 	argc = setup_revisions(argc, argv, &rev, "HEAD");
@@ -233,7 +233,7 @@ int cmd_format_patch(int argc, const cha
 	while (0 <= --nr) {
 		int shown;
 		commit = list[nr];
-		rev.nr = rev.total - nr;
+		rev.nr = start_number + total - nr - 1;
 		if (!use_stdout)
 			reopen_stdout(commit, rev.nr, keep_subject);
 		shown = log_tree_commit(&rev, commit);
-- 
1.3.3.gfa0f-dirty
Previous: Jakub NarebskiNext: Johannes Schindelin
Message 13 of 14 in “git-format-patch possible regressions”
  1. Marco CostalbaMay 25, 2006
  2. Linus TorvaldsMay 25, 2006
  3. Marco CostalbaMay 25, 2006
  4. Junio C HamanoMay 25, 2006
  5. Marco CostalbaMay 25, 2006
  6. Johannes SchindelinMay 25, 2006
  7. Johannes SchindelinMay 25, 2006
  8. Junio C HamanoMay 25, 2006
  9. Johannes SchindelinMay 25, 2006
  10. Marco CostalbaMay 26, 2006
  11. Junio C HamanoMay 26, 2006
  12. Jakub NarebskiMay 26, 2006
  13. Marco CostalbaMay 27, 2006
  14. Johannes SchindelinMay 28, 2006

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.