From: Simon Ruderich Date: Wed, 3 Apr 2013 21:31:06 +0000 (+0200) Subject: tig.pl: Fix running in subdirectories. X-Git-Url: https://ruderich.org/simon/gitweb/?a=commitdiff_plain;h=bd73e2f0389d6da9fe54edf6e320c72dacb9891a;p=config%2Fdotfiles.git tig.pl: Fix running in subdirectories. --- diff --git a/tig.pl b/tig.pl index d7272a3..c5648a8 100755 --- 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