[PATCH v2 40/44] ruby: request-pull: use native diff_tree stuff

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

 



Signed-off-by: Felipe Contreras <felipe.contreras@xxxxxxxxx>
---

Notes:
    We finally got rid of all the system() calls, and thus all the forks.

 git-request-pull.rb | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/git-request-pull.rb b/git-request-pull.rb
index 0db64c3..e884d0d 100755
--- a/git-request-pull.rb
+++ b/git-request-pull.rb
@@ -4,7 +4,7 @@ require 'date'
 
 ENV['GIT_PAGER'] =
 
-patch = ''
+patch = nil
 
 def usage
   puts <<EOF
@@ -84,6 +84,19 @@ def show_shortlog(base, head)
   shortlog(rev.to_a)
 end
 
+def show_diff(patch, base, head)
+  rev = Git::RevInfo.setup(nil, ['^' + sha1_to_hex(base), sha1_to_hex(head)], nil)
+  rev.diffopt.stat_width = -1
+  rev.diffopt.stat_graph_width = -1
+  rev.diffopt.output_format = patch ? DIFF_FORMAT_PATCH : DIFF_FORMAT_DIFFSTAT
+  rev.diffopt.output_format |= DIFF_FORMAT_SUMMARY
+  rev.diffopt.detect_rename = DIFF_DETECT_RENAME
+  rev.diffopt.flags |= DIFF_OPT_RECURSIVE
+
+  diff_tree_sha1(base, head, "", rev.diffopt)
+  log_tree_diff_flush(rev)
+end
+
 until ARGV.empty?
   case ARGV.first
   when '-p'
@@ -180,7 +193,7 @@ for you to fetch changes up to %s:
   end
 
   show_shortlog(base, head)
-  run(%[git diff -M --stat --summary #{patch} ^#{merge_base_commit} #{head}])
+  show_diff(patch, merge_base_id, head_id)
 
   if ! ref
     $stderr.puts "warn: No branch of #{url} is at:"
-- 
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]