]> git.ipfire.org Git - thirdparty/git.git/commitdiff
contacts: fix to work in subdirectories
authorEric Sunshine <sunshine@sunshineco.com>
Wed, 18 Sep 2013 02:52:05 +0000 (22:52 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 18 Sep 2013 05:16:22 +0000 (22:16 -0700)
Unlike other git commands which work correctly at the top-level or in a
subdirectory, git-contacts fails when invoked in a subdirectory. This is
because it invokes git-blame with pathnames relative to the top-level,
but git-blame interprets the pathnames as relative to the current
directory. Fix this.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/contacts/git-contacts

index fb6429b64be3cf7011ce69950987a8b328e0e758..428cc1a9a1367e36c2739cb226a0ffdd2704ce82 100755 (executable)
@@ -181,6 +181,10 @@ if (@rev_args) {
        scan_rev_args(\%sources, \@rev_args)
 }
 
+my $toplevel = `git rev-parse --show-toplevel`;
+chomp $toplevel;
+chdir($toplevel) or die "chdir failure: $toplevel: $!\n";
+
 my %commits;
 blame_sources(\%sources, \%commits);
 import_commits(\%commits);