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 <sunsh...@sunshineco.com>
---

git-contacts (in Perl) was born from Felipe's git-related v9 [1]
Ruby script. That version did not handle invocation from within
subdirectories, however, an earlier version (v5) of his script [2] did,
and it was my intention all along to add such support, but I forgot
after being sidetracked adding the git-check-mailmap command and
git-blame multiple -L support (plus several bug fixes in existing -L
support).

Thanks to Thomas Gummerer for reminding me about this in the form of a
patch [3]. The current patch is intended to be a bit more efficient than
Thomas'.

[1]: http://thread.gmane.org/gmane.comp.version-control.git/226065
[2]: http://article.gmane.org/gmane.comp.version-control.git/224783
[3]: http://thread.gmane.org/gmane.comp.version-control.git/234877

 contrib/contacts/git-contacts | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/contrib/contacts/git-contacts b/contrib/contacts/git-contacts
index fb6429b..428cc1a 100755
--- a/contrib/contacts/git-contacts
+++ b/contrib/contacts/git-contacts
@@ -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);
-- 
1.8.4.535.g7b94f8e

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to