From: kristofferhaugsbakk@fastmail.com Date: Mon, 22 Sep 2025 21:10:23 GMT Subject: [PATCH 2/2] format-patch: handle range-diff on notes correctly for single patches Message-ID: <7f2487af433.1758574974.git.code@khaugsbakk.name> In-Reply-To: From: Kristoffer Haugsbakk No `--[no-]notes` options are sent to the range-diff subprocess in `range-diff.c` when making a single patch. This means that you can get different Git notes below the commit message and in the range-diff part. (See the previous commit for elaboration.) Use the struct member that we introduced and populated in the previous commit. Signed-off-by: Kristoffer Haugsbakk --- Notes (series): I’ve tried to conform to 6caa96c2 (t3206: test_when_finished before dirtying operations, not after, 2024-08-06) in the test here. log-tree.c | 3 ++- t/t3206-range-diff.sh | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/log-tree.c b/log-tree.c index 73d21f71764..831284288f9 100644 --- a/log-tree.c +++ b/log-tree.c @@ -718,7 +718,8 @@ static void show_diff_of_diff(struct rev_info *opt) .creation_factor = opt->creation_factor, .dual_color = 1, .max_memory = RANGE_DIFF_MAX_MEMORY_DEFAULT, - .diffopt = &opts + .diffopt = &opts, + .other_arg = &opt->rdiff_other_arg }; memcpy(&dq, &diff_queued_diff, sizeof(diff_queued_diff)); diff --git a/t/t3206-range-diff.sh b/t/t3206-range-diff.sh index e091df6d01d..1e812df806b 100755 --- a/t/t3206-range-diff.sh +++ b/t/t3206-range-diff.sh @@ -707,7 +707,7 @@ test_expect_success 'format-patch --range-diff does not compare notes by default ! grep "note" 0000-* ' -test_expect_success 'format-patch --notes=custom --range-diff only compares custom notes' ' +test_expect_success 'format-patch --notes=custom --range-diff --cover-letter only compares custom notes' ' test_when_finished "git notes remove topic unmodified || :" && git notes add -m "topic note" topic && git notes add -m "unmodified note" unmodified && @@ -721,6 +721,20 @@ test_expect_success 'format-patch --notes=custom --range-diff only compares cust ! grep "## Notes ##" 0000-* ' +# --range-diff on a single commit requires --no-cover-letter +test_expect_success 'format-patch --notes=custom --range-diff on single commit only compares custom notes' ' + test_when_finished "git notes remove HEAD unmodified || :" && + git notes add -m "topic note" HEAD && + test_when_finished "git notes --ref=custom remove HEAD unmodified || :" && + git notes add -m "unmodified note" unmodified && + git notes --ref=custom add -m "topic note (custom)" HEAD && + git notes --ref=custom add -m "unmodified note (custom)" unmodified && + git format-patch --notes=custom --range-diff=$prev \ + -1 --stdout >actual && + test_grep "## Notes (custom) ##" actual && + test_grep ! "## Notes ##" actual +' + test_expect_success 'format-patch --range-diff with --no-notes' ' test_when_finished "git notes remove topic unmodified || :" && git notes add -m "topic note" topic && -- 2.51.0.270.gdb73cbc1bc1