Skip to content

Commit 155986b

Browse files
LemmingAvalanchegitster
authored andcommitted
format-patch: handle range-diff on notes correctly for single patches
(The two next paragraphs are taken from the previous commit.) git-format-patch(1) supports Git notes by showing them beneath the patch/commit message, similar to git-log(1). The command also supports showing those same notes ref names in the range diff output. Note *the same* ref names; any Git notes options or configuration variables need to be handed off to the range-diff machinery. This works correctly in the case when the range diff is on the cover letter. But it does not work correctly when the output is a single patch with an embedded range diff. Concretely, git-format-patch(1) needs to pass `--[no-]notes` options on to the range-diff subprocess in `range-diff.c`. Range diffs for single- commit series are handled in `log-tree.c`. But `log-tree.c` had no access to any `log_arg` variable before we added it to `rev_info` in the previous commit. Use that new struct member to fix this inconsistency. Signed-off-by: Kristoffer Haugsbakk <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 85bd88a commit 155986b

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

log-tree.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,8 @@ static void show_diff_of_diff(struct rev_info *opt)
718718
.creation_factor = opt->creation_factor,
719719
.dual_color = 1,
720720
.max_memory = RANGE_DIFF_MAX_MEMORY_DEFAULT,
721-
.diffopt = &opts
721+
.diffopt = &opts,
722+
.log_arg = &opt->rdiff_log_arg
722723
};
723724

724725
memcpy(&dq, &diff_queued_diff, sizeof(diff_queued_diff));

t/t3206-range-diff.sh

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ test_expect_success 'format-patch --range-diff does not compare notes by default
707707
! grep "note" 0000-*
708708
'
709709

710-
test_expect_success 'format-patch --notes=custom --range-diff only compares custom notes' '
710+
test_expect_success 'format-patch --notes=custom --range-diff --cover-letter only compares custom notes' '
711711
test_when_finished "git notes remove topic unmodified || :" &&
712712
git notes add -m "topic note" topic &&
713713
git notes add -m "unmodified note" unmodified &&
@@ -721,6 +721,20 @@ test_expect_success 'format-patch --notes=custom --range-diff only compares cust
721721
! grep "## Notes ##" 0000-*
722722
'
723723

724+
# --range-diff on a single commit requires --no-cover-letter
725+
test_expect_success 'format-patch --notes=custom --range-diff on single commit only compares custom notes' '
726+
test_when_finished "git notes remove HEAD unmodified || :" &&
727+
git notes add -m "topic note" HEAD &&
728+
test_when_finished "git notes --ref=custom remove HEAD unmodified || :" &&
729+
git notes add -m "unmodified note" unmodified &&
730+
git notes --ref=custom add -m "topic note (custom)" HEAD &&
731+
git notes --ref=custom add -m "unmodified note (custom)" unmodified &&
732+
git format-patch --notes=custom --range-diff=$prev \
733+
-1 --stdout >actual &&
734+
test_grep "## Notes (custom) ##" actual &&
735+
test_grep ! "## Notes ##" actual
736+
'
737+
724738
test_expect_success 'format-patch --range-diff with --no-notes' '
725739
test_when_finished "git notes remove topic unmodified || :" &&
726740
git notes add -m "topic note" topic &&

0 commit comments

Comments
 (0)