git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 3/3] diff-highlight: add support for --graph output.

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 1, 2016, 17:16 UTC
Message-ID
<xmqqk2g0l8a6.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20160730151149.15980-4-henderson.bj@gmail.com>
Brian Henderson <henderson.bj@gmail.com> writes:
Show 13 quoted lines
> ---
>  contrib/diff-highlight/diff-highlight | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/contrib/diff-highlight/diff-highlight b/contrib/diff-highlight/diff-highlight
> index ffefc31..ec31356 100755
> --- a/contrib/diff-highlight/diff-highlight
> +++ b/contrib/diff-highlight/diff-highlight
> @@ -20,6 +20,7 @@ my @NEW_HIGHLIGHT = (
>  my $RESET = "\x1b[m";
>  my $COLOR = qr/\x1b\[[0-9;]*m/;
>  my $BORING = qr/$COLOR|\s/;
> +my $GRAPH = qr/$COLOR?\|$COLOR?\s+/;

I didn't read the other parts (or existing code this patch changes, for that matter) of the series, but this looks like an attempt to catch the leading "|" bar showing direct ancestry. It makes a reader wonder what happens in a mergy histroy, though.

I _think_ that the patch portion of "log -p" output would only have "|" and never "\" or "/" that are used to adjust the number of tracks to deal with forks and merges, but perhaps the fact that this code relies on that assumption deserves to be written down here as an in-code comment?

Show 38 quoted lines
>  my @removed;
>  my @added;
> @@ -32,12 +33,12 @@ $SIG{PIPE} = 'DEFAULT';
>  while (<>) {
>  	if (!$in_hunk) {
>  		print;
> -		$in_hunk = /^$COLOR*\@/;
> +		$in_hunk = /^$GRAPH*$COLOR*\@/;
>  	}
> -	elsif (/^$COLOR*-/) {
> +	elsif (/^$GRAPH*$COLOR*-/) {
>  		push @removed, $_;
>  	}
> -	elsif (/^$COLOR*\+/) {
> +	elsif (/^$GRAPH*$COLOR*\+/) {
>  		push @added, $_;
>  	}
>  	else {
> @@ -46,7 +47,7 @@ while (<>) {
>  		@added = ();
>  
>  		print;
> -		$in_hunk = /^$COLOR*[\@ ]/;
> +		$in_hunk = /^$GRAPH*$COLOR*[\@ ]/;
>  	}
>  
>  	# Most of the time there is enough output to keep things streaming,
> @@ -211,8 +212,8 @@ sub is_pair_interesting {
>  	my $suffix_a = join('', @$a[($sa+1)..$#$a]);
>  	my $suffix_b = join('', @$b[($sb+1)..$#$b]);
>  
> -	return $prefix_a !~ /^$COLOR*-$BORING*$/ ||
> -	       $prefix_b !~ /^$COLOR*\+$BORING*$/ ||
> +	return $prefix_a !~ /^$GRAPH*$COLOR*-$BORING*$/ ||
> +	       $prefix_b !~ /^$GRAPH*$COLOR*\+$BORING*$/ ||
>  	       $suffix_a !~ /^$BORING*$/ ||
>  	       $suffix_b !~ /^$BORING*$/;
>  }
Previous: Brian HendersonNext: Brian Henderson
Message 3 of 24 in “diff-highlight: add support for git log --graph output.”
  1. 0/3 diff-highlight: add support for git log --graph output.Brian Henderson, Jul 30, 2016
  2. 3/3 diff-highlight: add support for --graph output.Brian Henderson, Jul 30, 2016
  3. Junio C HamanoAug 1, 2016
  4. diff-highlight: Add comment for our assumption about --graph output.Brian Henderson, Aug 4, 2016
  5. 2/3 diff-highlight: add failing test for handling --graph output.Brian Henderson, Jul 30, 2016
  6. 1/3 diff-highlight: add some tests.Brian Henderson, Jul 30, 2016
  7. Eric WongAug 10, 2016
  8. Brian HendersonAug 15, 2016
  9. Junio C HamanoAug 15, 2016
  10. 0/3 diff-highlight: add support for git log --graph output.Brian Henderson, Aug 17, 2016
  11. 2/3 diff-highlight: add failing test for handling --graph output.Brian Henderson, Aug 17, 2016
  12. Junio C HamanoAug 17, 2016
  13. 1/3 diff-highlight: add some tests.Brian Henderson, Aug 17, 2016
  14. Junio C HamanoAug 17, 2016
  15. Brian HendersonAug 19, 2016
  16. Jeff KingAug 19, 2016
  17. Brian HendersonAug 19, 2016
  18. 3/3 diff-highlight: add support for --graph output.Brian Henderson, Aug 17, 2016
  19. Jeff KingAug 19, 2016
  20. Eric WongAug 19, 2016
  21. Jeff KingAug 19, 2016
  22. Lars SchneiderAug 15, 2016
  23. Junio C HamanoAug 16, 2016
  24. Lars SchneiderAug 24, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.