Signed-off-by: Felipe Contreras <[email protected]>
---
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 <[email protected]>
+ John Poppins <[email protected]>
+ Jon Stewart <[email protected]>
+ 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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html