mirror of
https://github.com/git/git.git
synced 2024-11-28 04:23:30 +08:00
range-diff: output ## Notes ##
header
When notes were included in the output of range-diff, they were just mashed together with the rest of the commit message. As a result, users wouldn't be able to clearly distinguish where the commit message ended and where the notes started. Output a `## Notes ##` header when notes are detected so that notes can be compared more clearly. Note that we handle case of `Notes (<ref>): -> ## Notes (<ref>) ##` with this code as well. We can't test this in this patch, however, since there is currently no way to pass along different notes refs to `git log`. This will be fixed in a future patch. Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
3bdbdfb7a5
commit
9f726e1b87
@ -144,6 +144,12 @@ static int read_patches(const char *range, struct string_list *list)
|
|||||||
strbuf_addstr(&buf, line);
|
strbuf_addstr(&buf, line);
|
||||||
strbuf_addstr(&buf, "\n\n");
|
strbuf_addstr(&buf, "\n\n");
|
||||||
strbuf_addstr(&buf, " ## Commit message ##\n");
|
strbuf_addstr(&buf, " ## Commit message ##\n");
|
||||||
|
} else if (starts_with(line, "Notes") &&
|
||||||
|
line[strlen(line) - 1] == ':') {
|
||||||
|
strbuf_addstr(&buf, "\n\n");
|
||||||
|
/* strip the trailing colon */
|
||||||
|
strbuf_addf(&buf, " ## %.*s ##\n",
|
||||||
|
(int)(strlen(line) - 1), line);
|
||||||
} else if (starts_with(line, " ")) {
|
} else if (starts_with(line, " ")) {
|
||||||
p = line + len - 2;
|
p = line + len - 2;
|
||||||
while (isspace(*p) && p >= line)
|
while (isspace(*p) && p >= line)
|
||||||
|
@ -516,10 +516,10 @@ test_expect_success 'range-diff compares notes by default' '
|
|||||||
2: $(test_oid t2) = 2: $(test_oid u2) s/4/A/
|
2: $(test_oid t2) = 2: $(test_oid u2) s/4/A/
|
||||||
3: $(test_oid t3) = 3: $(test_oid u3) s/11/B/
|
3: $(test_oid t3) = 3: $(test_oid u3) s/11/B/
|
||||||
4: $(test_oid t4) ! 4: $(test_oid u4) s/12/B/
|
4: $(test_oid t4) ! 4: $(test_oid u4) s/12/B/
|
||||||
@@ Metadata
|
@@ Commit message
|
||||||
Z
|
Z
|
||||||
Z ## Commit message ##
|
Z
|
||||||
Z s/12/B/
|
Z ## Notes ##
|
||||||
- topic note
|
- topic note
|
||||||
+ unmodified note
|
+ unmodified note
|
||||||
Z
|
Z
|
||||||
@ -543,17 +543,17 @@ test_expect_success 'format-patch --range-diff compares notes by default' '
|
|||||||
grep "= 3: .* s/11/B" 0000-* &&
|
grep "= 3: .* s/11/B" 0000-* &&
|
||||||
grep "! 4: .* s/12/B" 0000-* &&
|
grep "! 4: .* s/12/B" 0000-* &&
|
||||||
sed s/Z/\ /g >expect <<-EOF &&
|
sed s/Z/\ /g >expect <<-EOF &&
|
||||||
@@ Metadata
|
@@ Commit message
|
||||||
Z
|
Z
|
||||||
Z ## Commit message ##
|
Z
|
||||||
Z s/12/B/
|
Z ## Notes ##
|
||||||
- topic note
|
- topic note
|
||||||
+ unmodified note
|
+ unmodified note
|
||||||
Z
|
Z
|
||||||
Z ## file ##
|
Z ## file ##
|
||||||
Z@@ file: A
|
Z@@ file: A
|
||||||
EOF
|
EOF
|
||||||
sed "/@@ Metadata/,/@@ file: A/!d" 0000-* >actual &&
|
sed "/@@ Commit message/,/@@ file: A/!d" 0000-* >actual &&
|
||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
'
|
'
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user