]> ruderich.org/simon Gitweb - config/dotfiles.git/blobdiff - tig.pl
gitconfig: Add aliases for commit --amend (ca, cad).
[config/dotfiles.git] / tig.pl
diff --git a/tig.pl b/tig.pl
index e08d79c502c1409b41b8f7c80da46c86f7108781..c5648a81c321589dde508ad92586aebc8de2c7e0 100755 (executable)
--- a/tig.pl
+++ b/tig.pl
@@ -34,6 +34,14 @@ my $color_ref_reference = 'red bold';
 my $color_author        = 'magenta';
 
 
+# Aliases in Git with "! ..." are always run in the top-level-directory.
+# GIT_PREFIX contains the relative path to the current subdirectory. Thanks to
+# dr_lepper in #git on Freenode (2013-04-03 23:17) for telling me about
+# GIT_PREFIX.
+if (defined $ENV{GIT_PREFIX} and $ENV{GIT_PREFIX} ne '') {
+    chdir $ENV{GIT_PREFIX} or die $!;
+}
+
 my $format = '%x00'         # separator from --graph
            . '%h'  . '%x00' # abbreviated commit hash
            . '%at' . '%x00' # author date
@@ -68,7 +76,7 @@ while (my $line = <$fh>) {
     }
 
     # Commit line.
-    $line =~ /^([ *|.-]+)\x00(.+)\x00(.+)\x00(.+)\x00(.+)\x00(.*)$/
+    $line =~ /^([ *|.\\-]+)\x00(.+)\x00(.+)\x00(.+)\x00(.*)\x00(.*)$/
         or die $line;
     my $prefix  = $1;
     my $hash    = colored($2, $color_hash);