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

[PATCH 3/6] t/lib-submodule-update: move a test to the right section

From
Philippe Blain via GitGitGadget <gitgitgadget@gmail.com>
Date
Feb 17, 2020, 04:53 UTC
Message-ID
<fa64ff03647e85d79414da6776309ab7488bc2be.1581915186.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.555.git.1581915186.gitgitgadget@gmail.com>
From: Philippe Blain <levraiphilippeblain@gmail.com>

The test "$command: submodule branch is not changed, detach HEAD instead" is in the "Appearing submodule" section of test_submodule_recursing_with_args_common(), but this test updates a submodule; it does not test a transition from a state with no submodule to a state with a submodule.

As such, for consistency, move it to the "Modified submodule" section of the same function. While at it, add a comment describing the test.

Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
---
 t/lib-submodule-update.sh | 33 +++++++++++++++++----------------
 1 file changed, 17 insertions(+), 16 deletions(-)
diff --git a/t/lib-submodule-update.sh b/t/lib-submodule-update.sh
index 5f9eb682f6a..417da3602ae 100755
--- a/t/lib-submodule-update.sh
+++ b/t/lib-submodule-update.sh
@@ -658,22 +658,6 @@ test_submodule_recursing_with_args_common() {
 			test_submodule_content sub1 origin/add_sub1
 		)
 	'
-	test_expect_success "$command: submodule branch is not changed, detach HEAD instead" '
-		prolog &&
-		reset_work_tree_to_interested add_sub1 &&
-		(
-			cd submodule_update &&
-			git -C sub1 checkout -b keep_branch &&
-			git -C sub1 rev-parse HEAD >expect &&
-			git branch -t modify_sub1 origin/modify_sub1 &&
-			$command modify_sub1 &&
-			test_superproject_content origin/modify_sub1 &&
-			test_submodule_content sub1 origin/modify_sub1 &&
-			git -C sub1 rev-parse keep_branch >actual &&
-			test_cmp expect actual &&
-			test_must_fail git -C sub1 symbolic-ref HEAD
-		)
-	'
 
 	# Replacing a tracked file with a submodule produces a checked out submodule
 	test_expect_success "$command: replace tracked file with submodule checks out submodule" '
@@ -789,6 +773,23 @@ test_submodule_recursing_with_args_common() {
 			test_submodule_content sub1 origin/add_sub1
 		)
 	'
+	# Updating a submodule does not touch the currently checked out branch in the submodule
+	test_expect_success "$command: submodule branch is not changed, detach HEAD instead" '
+		prolog &&
+		reset_work_tree_to_interested add_sub1 &&
+		(
+			cd submodule_update &&
+			git -C sub1 checkout -b keep_branch &&
+			git -C sub1 rev-parse HEAD >expect &&
+			git branch -t modify_sub1 origin/modify_sub1 &&
+			$command modify_sub1 &&
+			test_superproject_content origin/modify_sub1 &&
+			test_submodule_content sub1 origin/modify_sub1 &&
+			git -C sub1 rev-parse keep_branch >actual &&
+			test_cmp expect actual &&
+			test_must_fail git -C sub1 symbolic-ref HEAD
+		)
+	'
 }
 
 # Declares and invokes several tests that, in various situations, checks that
-- 
gitgitgadget
Previous: Junio C HamanoNext: Philippe Blain via GitGitGadget
Message 8 of 9 in “unpack-trees: fix '--recurse-submodules' when switching from no submodules to nested submodules”
  1. 0/6 unpack-trees: fix '--recurse-submodules' when switching from no submodules to nested submodulesPhilippe Blain via GitGitGadget, Feb 17, 2020
  2. 2/6 t/lib-submodule-update: remove outdated test descriptionPhilippe Blain via GitGitGadget, Feb 17, 2020
  3. 4/6 unpack-trees: remove outdated description for verify_clean_submodulePhilippe Blain via GitGitGadget, Feb 17, 2020
  4. 5/6 unpack-trees: check for missing submodule directory in merged_entryPhilippe Blain via GitGitGadget, Feb 17, 2020
  5. Junio C HamanoFeb 19, 2020
  6. 1/6 t7112: remove mention of KNOWN_FAILURE_SUBMODULE_RECURSIVE_NESTEDPhilippe Blain via GitGitGadget, Feb 17, 2020
  7. Junio C HamanoFeb 19, 2020
  8. 3/6 t/lib-submodule-update: move a test to the right sectionPhilippe Blain via GitGitGadget, Feb 17, 2020
  9. 6/6 t/lib-submodule-update: add test removing nested submodulesPhilippe Blain via GitGitGadget, Feb 17, 2020

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.