diff options
author | Thomas Gummerer <t.gummerer@gmail.com> | 2019-07-11 17:08:51 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-07-11 14:29:27 -0700 |
commit | 499352c2adf9c038ec3469d73590b1c55b6a343b (patch) | |
tree | 4e624e227a990a0e9c1aacaa4498bf2f73ff6b75 /range-diff.c | |
parent | range-diff: add filename to inner diff (diff) | |
download | tgif-499352c2adf9c038ec3469d73590b1c55b6a343b.tar.xz |
range-diff: add headers to the outer hunk header
Add the section headers/hunk headers we introduced in the previous
commits to the outer diff's hunk headers. This makes it easier to
understand which change we are actually looking at. For example an
outer hunk header might now look like:
@@ Documentation/config/interactive.txt
while previously it would have only been
@@
which doesn't give a lot of context for the change that follows.
For completeness also add section headers for the commit metadata and
the commit message, although they are arguably less important.
Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'range-diff.c')
-rw-r--r-- | range-diff.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/range-diff.c b/range-diff.c index 7a96a587f1..ba1e9a4265 100644 --- a/range-diff.c +++ b/range-diff.c @@ -139,8 +139,10 @@ static int read_patches(const char *range, struct string_list *list) strbuf_addstr(&buf, " ##"); } else if (in_header) { if (starts_with(line, "Author: ")) { + strbuf_addstr(&buf, " ## Metadata ##\n"); strbuf_addstr(&buf, line); strbuf_addstr(&buf, "\n\n"); + strbuf_addstr(&buf, " ## Commit message ##\n"); } else if (starts_with(line, " ")) { p = line + len - 2; while (isspace(*p) && p >= line) @@ -402,8 +404,9 @@ static void output_pair_header(struct diff_options *diffopt, fwrite(buf->buf, buf->len, 1, diffopt->file); } -static struct userdiff_driver no_func_name = { - .funcname = { "$^", 0 } +static struct userdiff_driver section_headers = { + .funcname = { "^ ## (.*) ##$\n" + "^.?@@ (.*)$", REG_EXTENDED } }; static struct diff_filespec *get_filespec(const char *name, const char *p) @@ -415,7 +418,7 @@ static struct diff_filespec *get_filespec(const char *name, const char *p) spec->size = strlen(p); spec->should_munmap = 0; spec->is_stdin = 1; - spec->driver = &no_func_name; + spec->driver = §ion_headers; return spec; } |