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

[PATCH 3/3] clone: add t5614 to test cloning submodules with shallowness involved

From
Stefan Beller <sbeller@google.com>
Date
Apr 12, 2016, 23:48 UTC
Message-ID
<1460504929-19208-4-git-send-email-sbeller@google.com>
In-Reply-To
<1460504929-19208-1-git-send-email-sbeller@google.com>

There are some inherent issues with shallow clones and submodules, such as having not having a commit available the superproject may point to in the submodule due to being shallow. Use the new file t5614 to document and test expectations in this area.

Signed-off-by: Stefan Beller <sbeller@google.com>
---
 t/t5614-clone-submodules.sh | 82 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 82 insertions(+)
 create mode 100755 t/t5614-clone-submodules.sh
diff --git a/t/t5614-clone-submodules.sh b/t/t5614-clone-submodules.sh
new file mode 100755
index 0000000..a66c2db
--- /dev/null
+++ b/t/t5614-clone-submodules.sh
@@ -0,0 +1,82 @@
+#!/bin/sh
+
+test_description='Test shallow cloning of repos with submodules'
+
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+	git checkout -b master &&
+	test_commit commit1 &&
+	test_commit commit2 &&
+	mkdir sub &&
+	(
+		cd sub &&
+		git init &&
+		test_commit subcommit1 &&
+		test_commit subcommit2
+	) &&
+	git submodule add ./sub &&
+	git commit -m "add submodule"
+'
+
+test_expect_success 'nonshallow clone implies nonshallow submodule' '
+	test_when_finished "rm -rf super_clone" &&
+	git clone --recurse-submodules . super_clone &&
+	(
+		cd super_clone &&
+		git log --oneline >lines &&
+		test_line_count = 3 lines
+	) &&
+	(
+		cd super_clone/sub &&
+		git log --oneline >lines &&
+		test_line_count = 2 lines
+	)
+'
+
+test_expect_success 'shallow clone implies shallow submodule' '
+	test_when_finished "rm -rf super_clone" &&
+	git clone --recurse-submodules --no-local --depth 1 . super_clone &&
+	(
+		cd super_clone &&
+		git log --oneline >lines &&
+		test_line_count = 1 lines
+	) &&
+	(
+		cd super_clone/sub &&
+		git log --oneline >lines &&
+		test_line_count = 1 lines
+	)
+'
+
+test_expect_success 'shallow clone with non shallow submodule' '
+	test_when_finished "rm -rf super_clone" &&
+	git clone --recurse-submodules --no-local --depth 1 --no-shallow-submodules . super_clone &&
+	(
+		cd super_clone &&
+		git log --oneline >lines &&
+		test_line_count = 1 lines
+	) &&
+	(
+		cd super_clone/sub &&
+		git log --oneline >lines &&
+		test_line_count = 2 lines
+	)
+'
+
+test_expect_success 'non shallow clone with shallow submodule' '
+	test_when_finished "rm -rf super_clone" &&
+	git clone --recurse-submodules --no-local --shallow-submodules . super_clone &&
+	(
+		cd super_clone &&
+		git log --oneline >lines &&
+		test_line_count = 3 lines
+	) &&
+	(
+		cd super_clone/sub &&
+		git log --oneline >lines &&
+		test_line_count = 1 lines
+	)
+'
+
+test_done
-- 
2.5.0.264.gc776916.dirty
Previous: Stefan BellerNext: Jacob Keller
Message 6 of 9 in “clone --shallow-submodules flag”
  1. 0/3 clone --shallow-submodules flagStefan Beller, Apr 12, 2016
  2. 1/3 submodule clone: pass along `local` optionStefan Beller, Apr 12, 2016
  3. Lars SchneiderApr 25, 2016
  4. Stefan BellerApr 25, 2016
  5. 2/3 clone: add `--shallow-submodules` flagStefan Beller, Apr 12, 2016
  6. 3/3 clone: add t5614 to test cloning submodules with shallowness involvedStefan Beller, Apr 12, 2016
  7. Jacob KellerApr 13, 2016
  8. Stefan BellerApr 25, 2016
  9. Lars SchneiderApr 25, 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.