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

[RFC PATCH 1/7] t6044: verify that merges expected to abort actually abort

From
Elijah Newren <newren@gmail.com>
Date
Jun 3, 2018, 06:58 UTC
Message-ID
<20180603065810.23841-2-newren@gmail.com>
In-Reply-To
<20180603065810.23841-1-newren@gmail.com>

t6044 has lots of tests for verifying that merge will abort as expected when there are changes staged before the merge starts. However, it only checked for non-zero exit code, which could mean that the merge ran to completion with conflicts. Check that the merge was actually correctly aborted, i.e. that .git/MERGE_HEAD is not present.

This changes one of the tests from expect_success to expect_failure.
Signed-off-by: Elijah Newren <newren@gmail.com>
---
 t/t6044-merge-unrelated-index-changes.sh | 32 ++++++++++++++++--------
 1 file changed, 21 insertions(+), 11 deletions(-)
diff --git a/t/t6044-merge-unrelated-index-changes.sh b/t/t6044-merge-unrelated-index-changes.sh
index 23b86fb977..f9c2f8179e 100755
--- a/t/t6044-merge-unrelated-index-changes.sh
+++ b/t/t6044-merge-unrelated-index-changes.sh
@@ -82,7 +82,8 @@ test_expect_success 'ff update, important file modified' '
 	touch subdir/e &&
 	git add subdir/e &&
 
-	test_must_fail git merge E^0
+	test_must_fail git merge E^0 &&
+	test_path_is_missing .git/MERGE_HEAD
 '
 
 test_expect_success 'resolve, trivial' '
@@ -91,7 +92,8 @@ test_expect_success 'resolve, trivial' '
 
 	touch random_file && git add random_file &&
 
-	test_must_fail git merge -s resolve C^0
+	test_must_fail git merge -s resolve C^0 &&
+	test_path_is_missing .git/MERGE_HEAD
 '
 
 test_expect_success 'resolve, non-trivial' '
@@ -100,7 +102,8 @@ test_expect_success 'resolve, non-trivial' '
 
 	touch random_file && git add random_file &&
 
-	test_must_fail git merge -s resolve D^0
+	test_must_fail git merge -s resolve D^0 &&
+	test_path_is_missing .git/MERGE_HEAD
 '
 
 test_expect_success 'recursive' '
@@ -109,16 +112,18 @@ test_expect_success 'recursive' '
 
 	touch random_file && git add random_file &&
 
-	test_must_fail git merge -s recursive C^0
+	test_must_fail git merge -s recursive C^0 &&
+	test_path_is_missing .git/MERGE_HEAD
 '
 
-test_expect_success 'recursive, when merge branch matches merge base' '
+test_expect_failure 'recursive, when merge branch matches merge base' '
 	git reset --hard &&
 	git checkout B^0 &&
 
 	touch random_file && git add random_file &&
 
-	test_must_fail git merge -s recursive F^0
+	test_must_fail git merge -s recursive F^0 &&
+	test_path_is_missing .git/MERGE_HEAD
 '
 
 test_expect_success 'octopus, unrelated file touched' '
@@ -127,7 +132,8 @@ test_expect_success 'octopus, unrelated file touched' '
 
 	touch random_file && git add random_file &&
 
-	test_must_fail git merge C^0 D^0
+	test_must_fail git merge C^0 D^0 &&
+	test_path_is_missing .git/MERGE_HEAD
 '
 
 test_expect_success 'octopus, related file removed' '
@@ -136,7 +142,8 @@ test_expect_success 'octopus, related file removed' '
 
 	git rm b &&
 
-	test_must_fail git merge C^0 D^0
+	test_must_fail git merge C^0 D^0 &&
+	test_path_is_missing .git/MERGE_HEAD
 '
 
 test_expect_success 'octopus, related file modified' '
@@ -145,7 +152,8 @@ test_expect_success 'octopus, related file modified' '
 
 	echo 12 >>a && git add a &&
 
-	test_must_fail git merge C^0 D^0
+	test_must_fail git merge C^0 D^0 &&
+	test_path_is_missing .git/MERGE_HEAD
 '
 
 test_expect_success 'ours' '
@@ -154,7 +162,8 @@ test_expect_success 'ours' '
 
 	touch random_file && git add random_file &&
 
-	test_must_fail git merge -s ours C^0
+	test_must_fail git merge -s ours C^0 &&
+	test_path_is_missing .git/MERGE_HEAD
 '
 
 test_expect_success 'subtree' '
@@ -163,7 +172,8 @@ test_expect_success 'subtree' '
 
 	touch random_file && git add random_file &&
 
-	test_must_fail git merge -s subtree E^0
+	test_must_fail git merge -s subtree E^0 &&
+	test_path_is_missing .git/MERGE_HEAD
 '
 
 test_done
-- 
2.18.0.rc0.49.g3c08dc0fef
Previous: Elijah NewrenNext: Elijah Newren
Message 15 of 30 in “merge requirement: index matches head”
  1. 0/7 merge requirement: index matches headElijah Newren, Jun 3, 2018
  2. 3/7 merge-recursive: make sure when we say we abort that we actually abortElijah Newren, Jun 3, 2018
  3. 2/7 t6044: add a testcase for index matching head, when head doesn't match HEADElijah Newren, Jun 3, 2018
  4. 5/7 t6044: add more testcases with staged changes before a merge is invokedElijah Newren, Jun 3, 2018
  5. 6/7 merge-recursive: enforce rule that index matches head before mergingElijah Newren, Jun 3, 2018
  6. 7/7 merge: fix misleading pre-merge check documentationElijah Newren, Jun 3, 2018
  7. Elijah NewrenJun 7, 2018
  8. 4/7 merge-recursive: fix assumption that head tree being merged is HEADElijah Newren, Jun 3, 2018
  9. Ramsay JonesJun 3, 2018
  10. brian m. carlsonJun 3, 2018
  11. Ramsay JonesJun 4, 2018
  12. Junio C HamanoJun 4, 2018
  13. Elijah NewrenJun 5, 2018
  14. Elijah NewrenJun 11, 2018
  15. 1/7 t6044: verify that merges expected to abort actually abortElijah Newren, Jun 3, 2018
  16. 0/9 Fix merge issues with index not matching HEADElijah Newren, Jul 1, 2018
  17. 1/9 read-cache.c: move index_has_changes() from merge.cElijah Newren, Jul 1, 2018
  18. 2/9 index_has_changes(): avoid assuming operating on the_indexElijah Newren, Jul 1, 2018
  19. Junio C HamanoJul 3, 2018
  20. 3/9 t6044: verify that merges expected to abort actually abortElijah Newren, Jul 1, 2018
  21. 4/9 t6044: add a testcase for index matching head, when head doesn't match HEADElijah Newren, Jul 1, 2018
  22. SZEDER GáborJul 10, 2018
  23. Elijah NewrenJul 11, 2018
  24. 8/9 merge-recursive: enforce rule that index matches head before mergingElijah Newren, Jul 1, 2018
  25. Junio C HamanoJul 3, 2018
  26. 5/9 merge-recursive: make sure when we say we abort that we actually abortElijah Newren, Jul 1, 2018
  27. 6/9 merge-recursive: fix assumption that head tree being merged is HEADElijah Newren, Jul 1, 2018
  28. Junio C HamanoJul 3, 2018
  29. 7/9 t6044: add more testcases with staged changes before a merge is invokedElijah Newren, Jul 1, 2018
  30. 9/9 merge: fix misleading pre-merge check documentationElijah Newren, Jul 1, 2018

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.