git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] contacts: fix to work in subdirectories

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Sep 18, 2013, 02:52 UTC
Message-ID
<1379472725-1038-1-git-send-email-sunshine@sunshineco.com>

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>
---

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
Message 1 of 1 in “contacts: fix to work in subdirectories”
  1. contacts: fix to work in subdirectoriesEric Sunshine, Sep 18, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.