contacts: allow execution from other directories
PATCH 1/1 contacts: allow execution from other directories
Currently git-contacts only works if it is executed from the top level of the git repository. Enable the execution in sub directories of that repository.
---
I have no experience in perl, so there may be nicer implementations. It works when tested manually.
contrib/contacts/git-contacts | 3 +++ 1 file changed, 3 insertions(+)
contrib/contacts/git-contacts +3 -0
@@ -61,6 +61,9 @@ sub import_commits { sub get_blame { my ($commits, $source, $from, $ranges) = @_; return unless @$ranges; + my $git_dir = `git rev-parse --show-toplevel`; + chomp($git_dir); + $source = $git_dir . '/' . $source; open my $f, '-|', qw(git blame --porcelain -C), map({"-L$_->[0],+$_->[1]"} @$ranges),
Signature · 1 line
1.8.4.535.g7b94f8e.dirty
Quoted 3 lines · Thomas Gummerer
Currently git-contacts only works if it is executed from the top level of the git repository. Enable the execution in sub directories of that repository.
Thanks. This was on my to-do list but fell off my radar when I accidentally deleted the to-do list (which, oddly, was not under version control).
I have a patch in my local tree accomplishing the same thing, but in a less expensive manner. I'll post it a bit later today for review.
Quoted 25 lines
Signed-off-by Thomas Gummerer <[email protected]>---
I have no experience in perl, so there may be nicer implementations. It works when tested manually.
contrib/contacts/git-contacts | 3 +++ 1 file changed, 3 insertions(+)contrib/contacts/git-contacts +3
-1@@ -61,6 +61,9 @@ sub import_commits { sub get_blame { my ($commits, $source, $from, $ranges) = @_; return unless @$ranges; + my $git_dir = `git rev-parse --show-toplevel`; + chomp($git_dir); + $source = $git_dir . '/' . $source; open my $f, '-|', qw(git blame --porcelain -C), map({"-L$_->[0],+$_->[1]"} @$ranges), --1.8.4.535.g7b94f8e.dirty