]> ruderich.org/simon Gitweb - config/dotfiles.git/blobdiff - tig.pl
tig.pl: Use array as argument for open().
[config/dotfiles.git] / tig.pl
diff --git a/tig.pl b/tig.pl
index f753408bba21d20eb89af891c55b82e19578349f..3939deb1f5f25bfed13b957fc3fcd43caa6eb2ac 100755 (executable)
--- a/tig.pl
+++ b/tig.pl
@@ -34,13 +34,14 @@ my $color_ref_reference = 'red bold';
 my $color_author        = 'magenta';
 
 
-my $format = '%h'  . '%x00' # abbreviated commit hash
+my $format = '%x00'         # separator from --graph
+           . '%h'  . '%x00' # abbreviated commit hash
            . '%at' . '%x00' # author date
            . '%an' . '%x00' # author name
            . '%s'  . '%x00' # subject
            . '%d';          # ref names
-my $cmd = "git log --all --graph --format='$format'";
-open my $fh, '-|', $cmd or die $!;
+my @cmd = ('git', 'log', '--all', '--graph', "--format=$format");
+open my $fh, '-|', @cmd or die $!;
 
 while (my $line = <$fh>) {
     # History graph line.
@@ -50,7 +51,8 @@ while (my $line = <$fh>) {
     }
 
     # Commit line.
-    $line =~ /^([ *|]+) (.+)\x00(.+)\x00(.+)\x00(.+)\x00(.*)$/ or die;
+    $line =~ /^([ *|.-]+)\x00(.+)\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));
@@ -58,6 +60,8 @@ while (my $line = <$fh>) {
     my $message = $5;
     my $refs    = $6;
 
+    # Strip trailing whitespace.
+    $prefix =~ s/\s+$//;
     # Color "graph".
     $prefix =~ s/\|/colored($&, $color_graph)/ge;