git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[RFC/PATCH 07/18] Add testcase for --index-only merges with the resolve strategy

From
Elijah Newren <newren@gmail.com>
Date
Apr 8, 2016, 06:58 UTC
Message-ID
<1460098726-5958-8-git-send-email-newren@gmail.com>
In-Reply-To
<1460098726-5958-1-git-send-email-newren@gmail.com>

Including both tests which can be handled without calling the actual git-merge-resolve program (because the merge is trivially resolvable without worrying about 3-way file merges), and ones that do need it to be invoked.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 t/t6043-merge-index-only.sh | 104 ++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 100 insertions(+), 4 deletions(-)
diff --git a/t/t6043-merge-index-only.sh b/t/t6043-merge-index-only.sh
index 67c8e92..4c3c40a 100755
--- a/t/t6043-merge-index-only.sh
+++ b/t/t6043-merge-index-only.sh
@@ -167,14 +167,22 @@ test_expect_failure 'recursive --index-only in bare repo' '
 	)
 '
 
-# Testcase for a simple ff update
+# Testcase for some simple merges
 #   A
-#   o-----o E
-#
+#   o-----o B
+#    \
+#     \---o C
+#      \
+#       \-o D
+#        \
+#         o E
 #   Commit A: some file a
+#   Commit B: adds file b, modifies end of a
+#   Commit C: adds file c
+#   Commit D: adds file d, modifies beginning of a
 #   Commit E: renames a->subdir/a, adds subdir/e
 
-test_expect_success 'setup simple ff update' '
+test_expect_success 'setup simple merges' '
 	git reset --hard &&
 	git rm -rf . &&
 	git clean -fdqx &&
@@ -186,8 +194,28 @@ test_expect_success 'setup simple ff update' '
 	test_tick && git commit -m A &&
 
 	git branch A &&
+	git branch B &&
+	git branch C &&
+	git branch D &&
 	git branch E &&
 
+	git checkout B &&
+	echo b >b &&
+	echo 11 >>a &&
+	git add a b &&
+	test_tick && git commit -m B &&
+
+	git checkout C &&
+	echo c >c &&
+	git add c &&
+	test_tick && git commit -m C &&
+
+	git checkout D &&
+	seq 2 10 >a &&
+	echo d >d &&
+	git add a d &&
+	test_tick && git commit -m D &&
+
 	git checkout E &&
 	mkdir subdir &&
 	git mv a subdir/a &&
@@ -237,4 +265,72 @@ test_expect_failure '--index-only ff update, non-bare with uncommitted changes'
 	test ! -d subdir
 '
 
+test_expect_failure '--index-only w/ resolve, trivial, non-bare' '
+	git clean -fdx &&
+	git reset --hard &&
+	git checkout B^0 &&
+
+	git merge --index-only -s resolve C^0 | grep Wonderful &&
+
+	test "$(git rev-list --count HEAD)" -eq 4 &&
+	test $(git rev-parse :a) = $(git rev-parse B:a) &&
+	test $(git rev-parse :b) = $(git rev-parse B:b) &&
+	test $(git rev-parse :c) = $(git rev-parse C:c) &&
+	test ! -f c
+'
+
+test_expect_failure '--index-only w/ resolve, trivial, bare' '
+	rm -rf bare.clone &&
+	git clone --bare . bare.clone &&
+	(cd bare.clone &&
+
+	 git update-ref --no-deref HEAD B &&
+	 git read-tree HEAD &&
+
+	 git merge --index-only -s resolve C^0 | grep Wonderful &&
+
+	 test "$(git rev-list --count HEAD)" -eq 4 &&
+	 test $(git rev-parse :a) = $(git rev-parse B:a) &&
+	 test $(git rev-parse :b) = $(git rev-parse B:b) &&
+	 test $(git rev-parse :c) = $(git rev-parse C:c) &&
+	 test ! -f a &&
+	 test ! -f b &&
+	 test ! -f c
+	)
+'
+
+test_expect_failure '--index-only w/ resolve, non-trivial, non-bare' '
+	git reset --hard &&
+	git checkout B^0 &&
+
+	git merge --index-only -s resolve D^0 &&
+
+	test "$(git rev-list --count HEAD)" -eq 4 &&
+	test $(git rev-parse :a) != $(git rev-parse B:a) &&
+	test $(git rev-parse :a) != $(git rev-parse D:a) &&
+	test $(git rev-parse :b) = $(git rev-parse B:b) &&
+	test $(git rev-parse :d) = $(git rev-parse D:d) &&
+	test $(git hash-object a) = $(git rev-parse B:a) &&
+	test ! -f d
+'
+
+test_expect_failure '--index-only w/ resolve, non-trivial, bare' '
+	rm -rf bare.clone &&
+	git clone --bare . bare.clone &&
+	(cd bare.clone &&
+
+	 git update-ref --no-deref HEAD B &&
+	 git read-tree HEAD &&
+
+	 git merge --index-only -s resolve D^0 &&
+
+	 test "$(git rev-list --count HEAD)" -eq 4 &&
+	 test $(git rev-parse :a) != $(git rev-parse B:a) &&
+	 test $(git rev-parse :a) != $(git rev-parse D:a) &&
+	 test $(git rev-parse :b) = $(git rev-parse B:b) &&
+	 test $(git rev-parse :d) = $(git rev-parse D:d) &&
+	 test ! -f a
+	)
+'
+
 test_done
-- 
2.8.0.18.gc685494
Previous: Elijah NewrenNext: Elijah Newren
Message 12 of 30 in “Add --index-only option to git merge”
  1. 00/18 Add --index-only option to git mergeElijah Newren, Apr 8, 2016
  2. 01/18 Remove duplicate codeElijah Newren, Apr 8, 2016
  3. Junio C HamanoApr 8, 2016
  4. 02/18 Avoid checking working copy when creating a virtual merge baseElijah Newren, Apr 8, 2016
  5. 03/18 Document weird bug in octopus merges via testcasesElijah Newren, Apr 8, 2016
  6. 04/18 merge-octopus: Abort if index not cleanElijah Newren, Apr 8, 2016
  7. Junio C HamanoApr 8, 2016
  8. 05/18 Add testcase for --index-only merges needing the recursive strategyElijah Newren, Apr 8, 2016
  9. Junio C HamanoApr 8, 2016
  10. Junio C HamanoApr 8, 2016
  11. 06/18 Add testcase for --index-only merges needing an ff updateElijah Newren, Apr 8, 2016
  12. 07/18 Add testcase for --index-only merges with the resolve strategyElijah Newren, Apr 8, 2016
  13. 08/18 Add testcase for --index-only merges with the octopus strategyElijah Newren, Apr 8, 2016
  14. 09/18 Add testcase for --index-only merges with the ours strategyElijah Newren, Apr 8, 2016
  15. 10/18 Add testcase for --index-only merges with the subtree strategyElijah Newren, Apr 8, 2016
  16. 11/18 merge: Add a new --index-only option, not yet implementedElijah Newren, Apr 8, 2016
  17. Junio C HamanoApr 8, 2016
  18. 12/18 Add --index-only support for recursive mergesElijah Newren, Apr 8, 2016
  19. 13/18 Add --index-only support with read_tree_trivial merges, kind ofElijah Newren, Apr 8, 2016
  20. 14/18 Add --index-only support for ff_only mergesElijah Newren, Apr 8, 2016
  21. 15/18 merge: Pass --index-only along to external merge strategy programsElijah Newren, Apr 8, 2016
  22. 16/18 git-merge-one-file.sh: support --index-only optionElijah Newren, Apr 8, 2016
  23. 17/18 git-merge-resolve.sh: support --index-only optionElijah Newren, Apr 8, 2016
  24. 18/18 git-merge-octopus.sh: support --index-only optionElijah Newren, Apr 8, 2016
  25. Michael J GruberApr 8, 2016
  26. Elijah NewrenApr 9, 2016
  27. Junio C HamanoApr 8, 2016
  28. Elijah NewrenApr 9, 2016
  29. Junio C HamanoApr 9, 2016
  30. Elijah NewrenApr 10, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.