git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Thomas Gummerer <t.gummerer@gmail.com>
To: git@vger.kernel.org
Cc: Duy Nguyen <pclouds@gmail.com>,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	Junio C Hamano <gitster@pobox.com>,
	Thomas Gummerer <t.gummerer@gmail.com>
Subject: [RFC PATCH 4/4] range-diff: add section headers to the outer hunk header
Date: Sun, 14 Apr 2019 22:09:33 +0100	[thread overview]
Message-ID: <20190414210933.20875-5-t.gummerer@gmail.com> (raw)
In-Reply-To: <20190414210933.20875-1-t.gummerer@gmail.com>

Add the section headers we introduced in the previous commit 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:

    @@ -77,15 +78,43 @@ modified file Documentation/config/interactive.txt

while previously it would have only been

    @@ -77,15 +78,43 @@

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>
---
 range-diff.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/range-diff.c b/range-diff.c
index aa466060ef..15ac54f369 100644
--- a/range-diff.c
+++ b/range-diff.c
@@ -124,8 +124,10 @@ static int read_patches(const char *range, struct string_list *list)
 			strbuf_addstr(&buf, " ##\n");
 		} else if (in_header) {
 			if (starts_with(line.buf, "Author: ")) {
+				strbuf_addstr(&buf, " ## Metadata ##\n");
 				strbuf_addbuf(&buf, &line);
 				strbuf_addstr(&buf, "\n\n");
+				strbuf_addstr(&buf, " ## Commit message ##\n");
 			} else if (starts_with(line.buf, "    ")) {
 				strbuf_rtrim(&line);
 				strbuf_addbuf(&buf, &line);
@@ -387,8 +389,8 @@ 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 = { "^ ## (.*) ##$", REG_EXTENDED }
 };
 
 static struct diff_filespec *get_filespec(const char *name, const char *p)
@@ -400,7 +402,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 = &section_headers;
 
 	return spec;
 }
-- 
2.21.0.593.g511ec345e1


  parent reply	other threads:[~2019-04-14 21:09 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-11 11:17 incorrect range-diff output? Duy Nguyen
2019-04-11 22:05 ` Thomas Gummerer
2019-04-12  8:41   ` Johannes Schindelin
2019-04-14 21:12     ` Thomas Gummerer
2019-04-12  9:21   ` Duy Nguyen
2019-04-12 15:02   ` Junio C Hamano
2019-04-14 21:20     ` Thomas Gummerer
2019-04-15  2:01       ` Junio C Hamano
2019-04-15 12:40     ` Johannes Schindelin
2019-04-14 21:09   ` [RFC PATCH 0/4] output improvements for git range-diff Thomas Gummerer
2019-04-14 21:09     ` [RFC PATCH 1/4] range-diff: fix function parameter indentation Thomas Gummerer
2019-04-14 21:09     ` [RFC PATCH 2/4] range-diff: don't remove funcname from inner diff Thomas Gummerer
2019-04-14 23:21       ` Eric Sunshine
2019-04-15 12:54         ` Johannes Schindelin
2019-04-15 18:56           ` Thomas Gummerer
2019-04-17 11:52             ` Johannes Schindelin
2019-04-24 18:15               ` Thomas Gummerer
2019-04-15 12:53       ` Johannes Schindelin
2019-04-15 18:57         ` Thomas Gummerer
2019-04-14 21:09     ` [RFC PATCH 3/4] range-diff: add section header instead of diff header Thomas Gummerer
2019-04-14 23:29       ` Eric Sunshine
2019-04-15  6:28         ` Johannes Sixt
2019-04-15 13:01         ` Johannes Schindelin
2019-04-15 19:09           ` Thomas Gummerer
2019-04-14 21:09     ` Thomas Gummerer [this message]
2019-04-15 12:44       ` [RFC PATCH 4/4] range-diff: add section headers to the outer hunk header Johannes Schindelin
2019-04-15 18:48         ` Thomas Gummerer
2019-04-15 12:47     ` [RFC PATCH 0/4] output improvements for git range-diff Johannes Schindelin
2019-04-15 19:25       ` Thomas Gummerer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190414210933.20875-5-t.gummerer@gmail.com \
    --to=t.gummerer@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=pclouds@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).