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

[RFC 1/2] submodules: test for fetch of non-init subsub-repo

From
PKPeter Kaestle <peter.kaestle@nokia.com>
Date
Nov 9, 2020, 08:33 UTC
Message-ID
<1604910829-49109-2-git-send-email-peter.kaestle@nokia.com>
In-Reply-To
<1604910829-49109-1-git-send-email-peter.kaestle@nokia.com>

This test case triggers a regression, which was introduced by a62387b3fc9f5aeeb04a2db278121d33a9caafa7 in following setup: outer_repo/middle_repo/inner_repo and a change in the remote of inner_repo happens. Then it's being fetched by a second clone of the outer repo, in which the middle is initialized, but the inner is not.

This causes is_empty_dir() in submodule.c:get_next_submodule() to check for a directory only existing in the actual worktree, while the is_empty_dir() being called from .git/modules.

Signed-off-by: Peter Kaestle <peter.kaestle@nokia.com>
---
 t/t5526-fetch-submodules.sh | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)
diff --git a/t/t5526-fetch-submodules.sh b/t/t5526-fetch-submodules.sh
index dd8e423..9fbd481 100755
--- a/t/t5526-fetch-submodules.sh
+++ b/t/t5526-fetch-submodules.sh
@@ -719,4 +719,42 @@ test_expect_success 'fetch new submodule commit intermittently referenced by sup
 	)
 '
 
+add_commit_push()
+{
+	dir="$1"
+	msg="$2"
+	shift 2
+	git -C "$dir" add "$@" &&
+	git -C "$dir" commit -a -m "$msg" &&
+	git -C "$dir" push
+}
+
+test_expect_failure 'fetching a superproject containing an uninitialized sub/sub project' '
+	# does not depend on any previous test setups
+
+	for repo in outer middle inner
+	do
+		git init --bare $repo &&
+		git clone $repo ${repo}_content &&
+		echo $repo > ${repo}_content/file &&
+		add_commit_push ${repo}_content "initial" file
+	done &&
+
+	git clone outer A &&
+	git -C A submodule add "$pwd/middle" &&
+	git -C A/middle/ submodule add "$pwd/inner" &&
+	add_commit_push A/middle/ "adding inner sub" .gitmodules inner &&
+	add_commit_push A/ "adding middle sub" .gitmodules middle &&
+
+	git clone outer B &&
+	git -C B/ submodule update --init middle &&
+
+	echo "change on inner repo of A" > A/middle/inner/file &&
+	add_commit_push A/middle/inner "change on inner" file &&
+	add_commit_push A/middle "change on inner" inner &&
+	add_commit_push A "change on inner" middle &&
+
+	git -C B/ fetch
+'
+
 test_done
-- 
2.6.2
Previous: Johannes SchindelinNext: Junio C Hamano
Message 7 of 14 in “[REGRESSION FIX 0/2] Handling regression introduced by a62387b”
  1. Peter KaestleNov 3, 2020
  2. 1/2 submodules: test for fetch of non-init subsub-repoPeter Kaestle, Nov 3, 2020
  3. 2/2 Revert "submodule.c: fetch in submodules git directory instead of in worktree"Peter Kaestle, Nov 3, 2020
  4. 0/2 Handling regression introduced by a62387bPeter Kaestle, Nov 9, 2020
  5. 2/2 Revert "submodule.c: fetch in submodules git directory instead of in worktree"Peter Kaestle, Nov 9, 2020
  6. Johannes SchindelinNov 10, 2020
  7. 1/2 submodules: test for fetch of non-init subsub-repoPeter Kaestle, Nov 9, 2020
  8. Junio C HamanoNov 9, 2020
  9. Peter KästleNov 11, 2020
  10. Philip OakleyNov 11, 2020
  11. [RFCv2] submodules: fix of regression on fetching of non-init subsub-repoPeter Kaestle, Nov 12, 2020
  12. Philippe BlainNov 11, 2020
  13. Junio C HamanoNov 11, 2020
  14. Philippe BlainNov 11, 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.