Skip to content

Commit 5cd3f68

Browse files
committed
Merge branch 'kh/range-diff-notes'
"git range-diff --notes=foo" compared "log --notes=foo --notes" of the two ranges, instead of using just the specified notes tree. * kh/range-diff-notes: range-diff: treat notes like `log`
2 parents 0b493d2 + 2e0d30d commit 5cd3f68

File tree

5 files changed

+41
-1
lines changed

5 files changed

+41
-1
lines changed

Documentation/pretty-options.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ being displayed. Examples: "--notes=foo" will show only notes from
8787
"--notes --notes=foo --no-notes --notes=bar" will only show notes
8888
from "refs/notes/bar".
8989

90+
--show-notes-by-default::
91+
Show the default notes unless options for displaying specific
92+
notes are given.
93+
9094
--show-notes[=<ref>]::
9195
--[no-]standard-notes::
9296
These options are deprecated. Use the above --notes/--no-notes

range-diff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ static int read_patches(const char *range, struct string_list *list,
6060
"--output-indicator-context=#",
6161
"--no-abbrev-commit",
6262
"--pretty=medium",
63-
"--notes",
63+
"--show-notes-by-default",
6464
NULL);
6565
strvec_push(&cp.args, range);
6666
if (other_arg)

revision.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2484,6 +2484,8 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
24842484
revs->break_bar = xstrdup(optarg);
24852485
revs->track_linear = 1;
24862486
revs->track_first_time = 1;
2487+
} else if (!strcmp(arg, "--show-notes-by-default")) {
2488+
revs->show_notes_by_default = 1;
24872489
} else if (skip_prefix(arg, "--show-notes=", &optarg) ||
24882490
skip_prefix(arg, "--notes=", &optarg)) {
24892491
if (starts_with(arg, "--show-notes=") &&
@@ -3054,6 +3056,11 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
30543056
if (revs->expand_tabs_in_log < 0)
30553057
revs->expand_tabs_in_log = revs->expand_tabs_in_log_default;
30563058

3059+
if (!revs->show_notes_given && revs->show_notes_by_default) {
3060+
enable_default_display_notes(&revs->notes_opt, &revs->show_notes);
3061+
revs->show_notes_given = 1;
3062+
}
3063+
30573064
return left;
30583065
}
30593066

revision.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ struct rev_info {
253253
shown_dashes:1,
254254
show_merge:1,
255255
show_notes_given:1,
256+
show_notes_by_default:1,
256257
show_signature:1,
257258
pretty_given:1,
258259
abbrev_commit:1,

t/t3206-range-diff.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,20 @@ test_expect_success 'range-diff with multiple --notes' '
662662
test_cmp expect actual
663663
'
664664

665+
# `range-diff` should act like `log` with regards to notes
666+
test_expect_success 'range-diff with --notes=custom does not show default notes' '
667+
git notes add -m "topic note" topic &&
668+
git notes add -m "unmodified note" unmodified &&
669+
git notes --ref=custom add -m "topic note" topic &&
670+
git notes --ref=custom add -m "unmodified note" unmodified &&
671+
test_when_finished git notes remove topic unmodified &&
672+
test_when_finished git notes --ref=custom remove topic unmodified &&
673+
git range-diff --notes=custom main..topic main..unmodified \
674+
>actual &&
675+
! grep "## Notes ##" actual &&
676+
grep "## Notes (custom) ##" actual
677+
'
678+
665679
test_expect_success 'format-patch --range-diff does not compare notes by default' '
666680
git notes add -m "topic note" topic &&
667681
git notes add -m "unmodified note" unmodified &&
@@ -679,6 +693,20 @@ test_expect_success 'format-patch --range-diff does not compare notes by default
679693
! grep "note" 0000-*
680694
'
681695

696+
test_expect_success 'format-patch --notes=custom --range-diff only compares custom notes' '
697+
git notes add -m "topic note" topic &&
698+
git notes --ref=custom add -m "topic note (custom)" topic &&
699+
git notes add -m "unmodified note" unmodified &&
700+
git notes --ref=custom add -m "unmodified note (custom)" unmodified &&
701+
test_when_finished git notes remove topic unmodified &&
702+
test_when_finished git notes --ref=custom remove topic unmodified &&
703+
git format-patch --notes=custom --cover-letter --range-diff=$prev \
704+
main..unmodified >actual &&
705+
test_when_finished "rm 000?-*" &&
706+
grep "## Notes (custom) ##" 0000-* &&
707+
! grep "## Notes ##" 0000-*
708+
'
709+
682710
test_expect_success 'format-patch --range-diff with --no-notes' '
683711
git notes add -m "topic note" topic &&
684712
git notes add -m "unmodified note" unmodified &&

0 commit comments

Comments
 (0)