New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
diff-highlight: highlight range-diff #684
base: master
Are you sure you want to change the base?
Conversation
Welcome to GitGitGadgetHi @jablko, and welcome to GitGitGadget, the GitHub App to send patch series to the Git mailing list from GitHub Pull Requests. Please make sure that this Pull Request has a good description, as it will be used as cover letter. Also, it is a good idea to review the commit messages one last time, as the Git project expects them in a quite specific form:
It is in general a good idea to await the automated test ("Checks") in this Pull Request before contributing the patches, e.g. to avoid trivial issues such as unportable code. Contributing the patchesBefore you can contribute the patches, your GitHub username needs to be added to the list of permitted users. Any already-permitted user can do that, by adding a comment to your PR of the form Both the person who commented An alternative is the channel
Once on the list of permitted usernames, you can contribute the patches to the Git mailing list by adding a PR comment After you submit, GitGitGadget will respond with another comment that contains the link to the cover letter mail in the Git mailing list archive. Please make sure to monitor the discussion in that thread and to address comments and suggestions. If you want to see what email(s) would be sent for a submit request, add a PR comment If you do not want to subscribe to the Git mailing list just to be able to respond to a mail, you can download the mbox ("raw") file corresponding to the mail you want to reply to from the Git mailing list. If you use GMail, you can upload that raw mbox file via: curl -g --user "<EMailAddress>:<Password>" --url "imaps://imap.gmail.com/INBOX" -T /path/to/raw.txt Need help?New contributors who want advice are encouraged to join git-mentoring@googlegroups.com, where volunteers who regularly contribute to Git are willing to answer newbie questions, give advice, or otherwise provide mentoring to interested contributors. You must join in order to post or view messages, but anyone can join. You may also be able to find help in real time in the developer IRC channel, |
/submit |
Error: User jablko is not permitted to use GitGitGadget |
/allow |
User jablko is now allowed to use GitGitGadget. |
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>
/submit |
Submitted as pull.684.git.git.1577634590.gitgitgadget@gmail.com |
@dscho Thanks a lot for your help! I've now signed-off. ✔️ |
With many Git contributors trickling back in from holidays, you might want to reply to your cover letter on the mailing list, with a "gentle ping" or something like that ;-) |
@jablko I still think that you may want to re-start the conversation on the Git mailing list by replying with a gentle ping. |
@@ -90,7 +90,8 @@ sub handle_line { | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the Git mailing list, Jeff King wrote (reply to this):
On Sun, Dec 29, 2019 at 03:49:50PM +0000, Jack Bates via GitGitGadget wrote:
> From: Jack Bates <jack@nottheoilrig.com>
>
> Piping `git range-diff` through diff-highlight currently has no effect,
> for two reasons:
Sorry for the slow review; this got overlooked over the holidays.
> 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.
Hmm. Matching $COLOR on either side would be stricter. In particular,
with your patch I think we'd match "@@@", undoing 3dbfe2b8ae
(diff-highlight: avoid highlighting combined diffs, 2016-08-31).
> 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.
This also means we'd start trying to highlight diffs that are inside
commit messages. That might not be the end of the world.
You can see some examples in git.git by doing:
git log | /path/to/original/diff-highlight >old
git log | /path/to/your/new/diff-highlight >new
diff -u old new
> 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*\@\@/;
There's a similar regex a few lines below to decide of we should remain
in a hunk. Would you need to modify that, too?
> + $graph_indent = length($1);
This throws away the existing $graph_indent. I know we wouldn't have a
range-diff mixed with a graph, but I think it breaks normal graph usage.
At least "make test" in contrib/diff-highlight seems to complain, and
adding "--graph -p" to the "git log" invocations above shows that we're
not highlighting a bunch of cases (perhaps all?).
-Peff
@jablko have you received the mail with Jeff King's review? If so, please do reply (the custom on the Git mailing list is to use reply-to-all and to avoid top-posting but to reply inline like Jeff did). |
@jablko today I wanted to use this feature, remembered seeing a PR about it, googled it and discovered it was not ready yet. Thus, I also encourage you to continue working on this :) |
Piping
git range-diff
through diff-highlight currently has no effect,for two reasons:
There are ANSI escapes before and after the
@@
hunk headers (whencolor is enabled) which diff-highlight fails to match. One solution
is to match both escapes (
/^$COLOR*\@\@$COLOR* /
). This patchdrops the trailing space from the existing pattern instead.
Unlike
git log
,git range-diff
diffs are indented, whichdiff-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