diff options
author | Denton Liu <liu.denton@gmail.com> | 2019-11-20 22:18:43 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-11-21 01:29:52 +0100 |
commit | 9f726e1b879f6cc191cf18e0b81dbea45eaee60d (patch) | |
tree | 6da033af4f7aafdc669585d6aef66f5a1a88adf3 /range-diff.c | |
parent | t3206: range-diff compares logs with commit notes (diff) | |
download | git-9f726e1b879f6cc191cf18e0b81dbea45eaee60d.tar.xz git-9f726e1b879f6cc191cf18e0b81dbea45eaee60d.zip |
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>
Diffstat (limited to 'range-diff.c')
-rw-r--r-- | range-diff.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/range-diff.c b/range-diff.c index 7fed5a3b4b..623397221d 100644 --- a/range-diff.c +++ b/range-diff.c @@ -144,6 +144,12 @@ static int read_patches(const char *range, struct string_list *list) strbuf_addstr(&buf, line); strbuf_addstr(&buf, "\n\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, " ")) { p = line + len - 2; while (isspace(*p) && p >= line) |