[PATCH v10 05/15] contrib: related: parse committish like format-patch

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

 



Signed-off-by: Felipe Contreras <felipe.contreras@xxxxxxxxx>
---
 contrib/related/git-related    | 15 +++++++++++++++
 contrib/related/test-related.t | 10 ++++++++++
 2 files changed, 25 insertions(+)

diff --git a/contrib/related/git-related b/contrib/related/git-related
index 4f78304..80e1f17 100755
--- a/contrib/related/git-related
+++ b/contrib/related/git-related
@@ -108,6 +108,21 @@ class Commits
   end
 
   def from_rev_args(args)
+    revs = []
+
+    File.popen(%w[git rev-parse --revs-only --default HEAD --symbolic] + args).each do |rev|
+      revs << rev.chomp
+    end
+
+    case revs.size
+    when 1
+      r = revs[0]
+      r = '^' + r if r[0] != '-'
+      args = [ r, 'HEAD' ]
+    else
+      args = revs
+    end
+
     File.popen(%w[git rev-list --reverse] + args) do |p|
       p.each do |e|
         id = e.chomp
diff --git a/contrib/related/test-related.t b/contrib/related/test-related.t
index b623d69..39b4fe9 100755
--- a/contrib/related/test-related.t
+++ b/contrib/related/test-related.t
@@ -74,4 +74,14 @@ test_expect_success "from committish" "
 	test_cmp expected actual
 "
 
+test_expect_success "from single rev committish" "
+	git related -1 master | sort > actual &&
+	cat > expected <<-EOF &&
+	John Doe <john@xxxxxxx>
+	John Poppins <john@xxxxxxx>
+	Jon Stewart <jon@xxxxxxxxxxx>
+	EOF
+	test_cmp expected actual
+"
+
 test_done
-- 
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]