From 2662b1e614e86904bbf4d9403ca9ea4432061f8d Mon Sep 17 00:00:00 2001
From: Stephen Haberman <stephen@exigencecorp.com>
Date: Thu, 24 Jul 2008 01:11:37 -0500
Subject: [PATCH] Handle multiple base revisions between the parents we're
 examining.

---
 ...ver-update-prefer-rebase-even-if-merges.sh | 56 +++++++++++++++++++
 1 file changed, 56 insertions(+)

diff --git a/tests/t2301-server-update-prefer-rebase-even-if-merges.sh b/tests/t2301-server-update-prefer-rebase-even-if-merges.sh
index 1f3cb20..470cb1c 100644
--- a/tests/t2301-server-update-prefer-rebase-even-if-merges.sh
+++ b/tests/t2301-server-update-prefer-rebase-even-if-merges.sh
@@ -62,5 +62,61 @@ test_expect_success 'merging in stable does not fool the script' '
 	cat push.err | grep "It looks like you should rebase instead of merging"
 '
 
+#
+# A --C------            stable
+#  \  |      \
+#   B -- D -- E -- F     topic2
+#    \|             \
+#     G -- H ------- I   attempted push
+#
+# Trying to push F..I
+#
+# merge-base(F, H) has two options: B and C
+#
+test_expect_success 'merging in stable with tricky double baserev does not fool the script' '
+	# start our branch, and share it--commit B
+	git checkout -b topic2 stable &&
+	git config --add branch.topic2.remote origin &&
+	git config --add branch.topic2.merge refs/heads/topic2 &&
+	echo "commit B" >a.topic2 &&
+	git add a.topic2 &&
+	git commit -m "commit B created topic2" &&
+	git push origin topic2 &&
+
+	# now, separately, move ahead stable, and share it--commit C
+	git checkout stable
+	echo "commit C" >a &&
+	git commit -a -m "commit C moved stable" &&
+	git push origin stable &&
+
+	# have another client commit (in this case, it is the server, but close enough) moves topic2
+	cd server &&
+	git checkout topic2 &&
+	echo "commit D continuing topic2" >a.client2 &&
+	git add a.client2 &&
+	git commit -m "commit D by client2" &&
+
+	# Go ahead and merge in stable by the other client--commit E
+	git merge stable &&
+
+	# Then move topic2 put to--commit F
+	echo "commit F" >a.client2 &&
+	git commit -a -m "commit F by client2" &&
+	cd .. &&
+
+	# now locally try and merge in stable (even though we are out of date)--commit G
+	git checkout topic2 &&
+	git merge stable &&
+
+	# Go ahead and move our local topic2
+	echo "commit H" >a.topic2 &&
+	git commit -a -m "commit H continues local fork" &&
+
+	# Make a new merge commit
+	git pull &&
+	! git push origin topic2
+	cat push.err | grep "It looks like you should rebase instead of merging"
+'
+
 test_done
 
-- 
2.39.5