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

[PATCH 1/2] revision: add rdiff_other_arg to rev_info

From
Kkristofferhaugsbakk@fastmail.com <kristofferhaugsbakk@fastmail.com>
Date
Sep 22, 2025, 21:10 UTC
Message-ID
<bb065767336.1758574974.git.code@khaugsbakk.name>
In-Reply-To
<cover.1758574974.git.code@khaugsbakk.name>
From: Kristoffer Haugsbakk <code@khaugsbakk.name>

git-format-patch(1) needs to pass `--[no-]notes` options on to the range-diff subprocess in `range-diff.c`. This is handled in `builtin/ log.c` by the local variable `other_arg` in the case of multiple commits, but not in the single commit case where there is no cover letter and the range-diff is on that single resulting patch; the range-diff is then made in `log-tree.c`, whither `other_arg` has not been propagated.

git-format-patch(1) is supposed to treat Git notes the same between notes output beneath the commit message and the notes output for the range-diff. But this lack of notes handling in `log-tree.c` breaks that expected behavior; range-diff notes handling for a single patch acts like a normal git-range-diff(1) invocation with regards to notes. You can, for example, end up with a patch where the note beneath the commit message has the correct notes namespace, but the range-diff has all the notes that are configured to be displayed by git-log(1).[1]

We need to fix this. But first lay the groundwork by converting `other_arg` to a struct member; next we can simply use that member in `log-tree.c` without having to thread it from `builtin/log.c`.

No functional changes.
† 1: See the configuration variable `format.notes` for git-format-
     patch(1); c.f. `notes.displayRef` for git-log(1).  These two
     have nothing to do with each other.
Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
---
Notes (series):
    There is also `other_arg` in `builtin/range-diff.c` but `rev_info` does
    not seem to be involved.
 builtin/log.c | 7 +++----
 revision.h    | 1 +
 2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/builtin/log.c b/builtin/log.c
index 5f552d14c0f..56dd9fbc057 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -1400,13 +1400,12 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,
 		 * can be added later if deemed desirable.
 		 */
 		struct diff_options opts;
-		struct strvec other_arg = STRVEC_INIT;
 		struct range_diff_options range_diff_opts = {
 			.creation_factor = rev->creation_factor,
 			.dual_color = 1,
 			.max_memory = RANGE_DIFF_MAX_MEMORY_DEFAULT,
 			.diffopt = &opts,
-			.other_arg = &other_arg
+			.other_arg = &rev->rdiff_other_arg
 		};
 
 		repo_diff_setup(the_repository, &opts);
@@ -1414,9 +1413,7 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,
 		opts.use_color = rev->diffopt.use_color;
 		diff_setup_done(&opts);
 		fprintf_ln(rev->diffopt.file, "%s", rev->rdiff_title);
-		get_notes_args(&other_arg, rev);
 		show_range_diff(rev->rdiff1, rev->rdiff2, &range_diff_opts);
-		strvec_clear(&other_arg);
 	}
 }
 
@@ -2328,6 +2325,7 @@ int cmd_format_patch(int argc,
 		rev.rdiff_title = diff_title(&rdiff_title, reroll_count,
 					     _("Range-diff:"),
 					     _("Range-diff against v%d:"));
+		get_notes_args(&(rev.rdiff_other_arg), &rev);
 	}
 
 	/*
@@ -2487,6 +2485,7 @@ int cmd_format_patch(int argc,
 	rev.diffopt.no_free = 0;
 	release_revisions(&rev);
 	format_config_release(&cfg);
+	strvec_clear(&rev.rdiff_other_arg);
 	return 0;
 }
 
diff --git a/revision.h b/revision.h
index 21e288c5baa..26c18a0934b 100644
--- a/revision.h
+++ b/revision.h
@@ -334,6 +334,7 @@ struct rev_info {
 	/* range-diff */
 	const char *rdiff1;
 	const char *rdiff2;
+	struct strvec rdiff_other_arg;
 	int creation_factor;
 	const char *rdiff_title;
 
-- 
2.51.0.270.gdb73cbc1bc1
Previous: kristofferhaugsbakk@fastmail.comNext: Junio C Hamano
Message 2 of 15 in “format-patch: handle range-diff on notes correctly for single patches”
  1. 0/2 format-patch: handle range-diff on notes correctly for single patcheskristofferhaugsbakk@fastmail.com, Sep 22, 2025
  2. 1/2 revision: add rdiff_other_arg to rev_infokristofferhaugsbakk@fastmail.com, Sep 22, 2025
  3. Junio C HamanoSep 22, 2025
  4. Kristoffer HaugsbakkSep 23, 2025
  5. Junio C HamanoSep 23, 2025
  6. Kristoffer HaugsbakkSep 23, 2025
  7. Junio C HamanoSep 23, 2025
  8. 2/2 format-patch: handle range-diff on notes correctly for single patcheskristofferhaugsbakk@fastmail.com, Sep 22, 2025
  9. Junio C HamanoSep 22, 2025
  10. Kristoffer HaugsbakkSep 23, 2025
  11. Junio C HamanoSep 23, 2025
  12. 0/3 format-patch: handle range-diff on notes correctly for single patcheskristofferhaugsbakk@fastmail.com, Sep 25, 2025
  13. 1/3 range-diff: rename other_arg to log_argkristofferhaugsbakk@fastmail.com, Sep 25, 2025
  14. 2/3 revision: add rdiff_log_arg to rev_infokristofferhaugsbakk@fastmail.com, Sep 25, 2025
  15. 3/3 format-patch: handle range-diff on notes correctly for single patcheskristofferhaugsbakk@fastmail.com, Sep 25, 2025

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.