Skip to content

Commit ecc034e

Browse files
committed
Merge branch 'kh/range-diff-notes' into seen
"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 18aa801 + 4341c14 commit ecc034e

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

range-diff.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,20 @@ static int read_patches(const char *range, struct string_list *list,
4141
struct child_process cp = CHILD_PROCESS_INIT;
4242
struct strbuf buf = STRBUF_INIT, contents = STRBUF_INIT;
4343
struct patch_util *util = NULL;
44-
int in_header = 1;
44+
int i, implicit_notes_arg = 1, in_header = 1;
4545
char *line, *current_filename = NULL;
4646
ssize_t len;
4747
size_t size;
4848
int ret = -1;
4949

50+
for (i = 0; other_arg && i < other_arg->nr; i++)
51+
if (!strcmp(other_arg->v[i], "--notes") ||
52+
starts_with(other_arg->v[i], "--notes=") ||
53+
!strcmp(other_arg->v[i], "--no-notes")) {
54+
implicit_notes_arg = 0;
55+
break;
56+
}
57+
5058
strvec_pushl(&cp.args, "log", "--no-color", "-p", "--no-merges",
5159
"--reverse", "--date-order", "--decorate=no",
5260
"--no-prefix", "--submodule=short",
@@ -60,8 +68,9 @@ static int read_patches(const char *range, struct string_list *list,
6068
"--output-indicator-context=#",
6169
"--no-abbrev-commit",
6270
"--pretty=medium",
63-
"--notes",
6471
NULL);
72+
if (implicit_notes_arg)
73+
strvec_push(&cp.args, "--notes");
6574
strvec_push(&cp.args, range);
6675
if (other_arg)
6776
strvec_pushv(&cp.args, other_arg->v);

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)