[PATCH v10 11/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 | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/contrib/related/git-related b/contrib/related/git-related
index 3399307..f15e4e7 100755
--- a/contrib/related/git-related
+++ b/contrib/related/git-related
@@ -8,6 +8,10 @@ $min_percent = 10
 $files = []
 $rev_args = []
 
+git_dir = %x[git rev-parse --git-dir].chomp
+$base_dir = File.dirname(git_dir)
+$cur_dir = Dir.pwd
+
 KNOWN_ROLES = {
   'Signed-off-by' => :signer,
   'Reviewed-by' => :reviewer,
@@ -130,6 +134,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', '-C',
                '-L', '%u,+%u' % [start, len],
                '--since', $since, from + '^',
@@ -141,6 +146,7 @@ class Commits
         end
       end
     end
+    Dir.chdir($cur_dir)
   end
 
   def scan_patch(f, id = nil)
-- 
1.8.4-fc

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