Git fork

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 <code@khaugsbakk.name>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Kristoffer Haugsbakk and committed by
Junio C Hamano
155986b4 85bd88a7

+17 -2
+2 -1
log-tree.c
··· 718 718 .creation_factor = opt->creation_factor, 719 719 .dual_color = 1, 720 720 .max_memory = RANGE_DIFF_MAX_MEMORY_DEFAULT, 721 - .diffopt = &opts 721 + .diffopt = &opts, 722 + .log_arg = &opt->rdiff_log_arg 722 723 }; 723 724 724 725 memcpy(&dq, &diff_queued_diff, sizeof(diff_queued_diff));
+15 -1
t/t3206-range-diff.sh
··· 707 707 ! grep "note" 0000-* 708 708 ' 709 709 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' ' 711 711 test_when_finished "git notes remove topic unmodified || :" && 712 712 git notes add -m "topic note" topic && 713 713 git notes add -m "unmodified note" unmodified && ··· 719 719 main..unmodified >actual && 720 720 grep "## Notes (custom) ##" 0000-* && 721 721 ! grep "## Notes ##" 0000-* 722 + ' 723 + 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 722 736 ' 723 737 724 738 test_expect_success 'format-patch --range-diff with --no-notes' '