git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Jack Bates via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Jack Bates <jack@nottheoilrig.com>,
	Junio C Hamano <gitster@pobox.com>,
	Jack Bates <jack@nottheoilrig.com>
Subject: [PATCH 1/1] diff-highlight: highlight range-diff
Date: Sun, 29 Dec 2019 15:49:50 +0000	[thread overview]
Message-ID: <547b3087ac2e8e05af86b4b9972cef8c20da1cdf.1577634590.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.684.git.git.1577634590.gitgitgadget@gmail.com>

From: Jack Bates <jack@nottheoilrig.com>

Piping `git range-diff` through diff-highlight currently has no effect,
for two reasons:

  1. There are ANSI escapes before and after the `@@` hunk headers (when
     color is enabled) which diff-highlight fails to match. One solution
     is to match both escapes (`/^$COLOR*\@\@$COLOR* /`). This patch
     drops the trailing space from the existing pattern instead.

  2. Unlike `git log`, `git range-diff` diffs are indented, which
     diff-highlight also fails to match. This patch allows hunk headers
     preceded by any amount of whitespace, and then skips past that
     indentation when parsing subsequent lines, by reusing the machinery
     that handles the --graph output.

Signed-off-by: Jack Bates <jack@nottheoilrig.com>
---
 contrib/diff-highlight/DiffHighlight.pm | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/contrib/diff-highlight/DiffHighlight.pm b/contrib/diff-highlight/DiffHighlight.pm
index e2589922a6..74f53e53c9 100644
--- a/contrib/diff-highlight/DiffHighlight.pm
+++ b/contrib/diff-highlight/DiffHighlight.pm
@@ -90,7 +90,8 @@ sub handle_line {
 
 	if (!$in_hunk) {
 		$line_cb->($orig);
-		$in_hunk = /^$COLOR*\@\@ /;
+		$in_hunk = /^( *)$COLOR*\@\@/;
+		$graph_indent = length($1);
 	}
 	elsif (/^$COLOR*-/) {
 		push @removed, $orig;
-- 
gitgitgadget

  reply	other threads:[~2019-12-29 15:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-29 15:49 [PATCH 0/1] diff-highlight: highlight range-diff Jack Bates via GitGitGadget
2019-12-29 15:49 ` Jack Bates via GitGitGadget [this message]
2020-01-28  7:52   ` [PATCH 1/1] " Jeff King

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=547b3087ac2e8e05af86b4b9972cef8c20da1cdf.1577634590.git.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jack@nottheoilrig.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).