{"thread":{"id":"34954","subject":"[PATCH] contacts: fix to work in subdirectories","startedAt":"2013-09-18T02:52:05Z","lastAt":"2013-09-18T02:52:05Z","messageCount":1,"participants":["Eric Sunshine"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"227819","messageId":"1379472725-1038-1-git-send-email-sunshine@sunshineco.com","threadId":"34954","inReplyTo":null,"subject":"[PATCH] contacts: fix to work in subdirectories","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2013-09-18T02:52:05Z","receivedAt":"2013-09-18T02:52:05Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"Unlike other git commands which work correctly at the top-level or in a\nsubdirectory, git-contacts fails when invoked in a subdirectory. This is\nbecause it invokes git-blame with pathnames relative to the top-level,\nbut git-blame interprets the pathnames as relative to the current\ndirectory. Fix this.\n\nSigned-off-by: Eric Sunshine <sunshine@sunshineco.com>\n---\n\ngit-contacts (in Perl) was born from Felipe's git-related v9 [1]\nRuby script. That version did not handle invocation from within\nsubdirectories, however, an earlier version (v5) of his script [2] did,\nand it was my intention all along to add such support, but I forgot\nafter being sidetracked adding the git-check-mailmap command and\ngit-blame multiple -L support (plus several bug fixes in existing -L\nsupport).\n\nThanks to Thomas Gummerer for reminding me about this in the form of a\npatch [3]. The current patch is intended to be a bit more efficient than\nThomas'.\n\n[1]: http://thread.gmane.org/gmane.comp.version-control.git/226065\n[2]: http://article.gmane.org/gmane.comp.version-control.git/224783\n[3]: http://thread.gmane.org/gmane.comp.version-control.git/234877\n\n contrib/contacts/git-contacts | 4 ++++\n 1 file changed, 4 insertions(+)\n\ndiff --git a/contrib/contacts/git-contacts b/contrib/contacts/git-contacts\nindex fb6429b..428cc1a 100755\n--- a/contrib/contacts/git-contacts\n+++ b/contrib/contacts/git-contacts\n@@ -181,6 +181,10 @@ if (@rev_args) {\n \tscan_rev_args(\\%sources, \\@rev_args)\n }\n \n+my $toplevel = `git rev-parse --show-toplevel`;\n+chomp $toplevel;\n+chdir($toplevel) or die \"chdir failure: $toplevel: $!\\n\";\n+\n my %commits;\n blame_sources(\\%sources, \\%commits);\n import_commits(\\%commits);\n-- \n1.8.4.535.g7b94f8e\n"}]}