[PATCH v5 10/15] contrib: related: allow usage on other directories

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Not just the root one (of the project).

Signed-off-by: Felipe Contreras <felipe.contreras@xxxxxxxxx>
---
 contrib/related/git-related | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/contrib/related/git-related b/contrib/related/git-related
index 3b11930..def2af5 100755
--- a/contrib/related/git-related
+++ b/contrib/related/git-related
@@ -44,8 +44,12 @@ def get_mailmap(filename)
   end
 end
 
+git_dir = %x[git rev-parse --git-dir].chomp
+$base_dir = File.dirname(git_dir)
+$cur_dir = Dir.pwd
+
 get_aliases if $get_aliases
-get_mailmap('.mailmap')
+get_mailmap(File.join($base_dir, '.mailmap'))
 mailmap_file = %x[git config mailmap.file].chomp
 get_mailmap(mailmap_file)
 
@@ -180,6 +184,7 @@ class Commits
   def get_blame(source, start, len, from)
     return if len == 0
     len ||= 1
+    Dir.chdir($base_dir)
     File.popen(['git', 'blame', '--incremental', '-C',
                '-L', '%u,+%u' % [start, len],
                '--since', $since, from + '^',
@@ -191,6 +196,7 @@ class Commits
         end
       end
     end
+    Dir.chdir($cur_dir)
   end
 
   def from_patch(file)
-- 
1.8.3.rc2.542.g24820ba

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




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]