From d19339018e537f7ad4f6e29ef4161a7cd21108b0 Mon Sep 17 00:00:00 2001 From: Urbano Ustero Date: Tue, 8 Jul 2014 10:05:02 +0200 Subject: [PATCH] Allow running the script from any subdirectory The script assumes it is running from the root of the repository. This change allows using the script from any subdirectory as well. --- git-diff-blame | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/git-diff-blame b/git-diff-blame index 5db7702..642651a 100755 --- a/git-diff-blame +++ b/git-diff-blame @@ -15,6 +15,11 @@ sub get_blame_prefix { return $1; } +$git_root = `git rev-parse --show-toplevel`; +$git_root =~ s/^\s+//; +$git_root =~ s/\s+$//; +chdir($git_root) or die "$!"; + my ($oldrev, $newrev) = @ARGV; $oldrev ||= 'HEAD'; if ($newrev) {