X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=tig.pl;h=77b7d9416600f812fd760bbf7f05df208e99effa;hb=4bf926384a26bbdbe7c6bb6476aa6093381667c8;hp=1ae3e75ef5a9931868a946f1b431148251c68475;hpb=a0cd1f8574a9afd9e6fea4aba20cea49d72a3041;p=config%2Fdotfiles.git diff --git a/tig.pl b/tig.pl index 1ae3e75..77b7d94 100755 --- a/tig.pl +++ b/tig.pl @@ -50,7 +50,7 @@ while (my $line = <$fh>) { } # Commit line. - $line =~ /^([ *|]+) (.+)\x00(.+)\x00(.+)\x00(.+)\x00(.*)$/ or die; + $line =~ /^([ *|]+) (.+)\x00(.+)\x00(.+)\x00(.+)\x00(.*)$/ or die $line; my $prefix = $1; my $hash = colored($2, $color_hash); my $date = POSIX::strftime('%Y-%m-%d', localtime($3)); @@ -61,11 +61,32 @@ while (my $line = <$fh>) { # Color "graph". $prefix =~ s/\|/colored($&, $color_graph)/ge; - # Strip leading whitespace. + # Strip leading whitespace and braces. $refs =~ s/^\s+//; + $refs =~ tr/()//d; - printf "%s %s %s %s %s %s\n", - $prefix, $hash, $date, $author, $message, $refs; + # Color refs. + $refs = join colored(', ', $color_ref_sep), map { + my $color; + if ($_ eq 'HEAD') { + $color = $color_ref_head; + } elsif (m{/}) { + $color = $color_ref_reference; + } else { + $color = $color_ref_branch; + } + colored($_, $color); + } split /, /, $refs; + + if ($refs ne '') { + $refs = ' ' + . colored('(', $color_ref_sep) + . $refs + . colored(')', $color_ref_sep); + } + + printf "%s %s %s %s%s %s\n", + $prefix, $hash, $date, $author, $refs, $message; } close $fh or die $!;