{"thread":{"id":"40782","subject":"[PATCH v1] add test to demonstrate that shallow recursive clones fail","startedAt":"2015-11-12T09:04:09Z","lastAt":"2015-11-12T09:04:09Z","messageCount":1,"participants":["larsxschneider@gmail.com"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"273240","messageId":"1447319049-51371-1-git-send-email-larsxschneider@gmail.com","threadId":"40782","inReplyTo":null,"subject":"[PATCH v1] add test to demonstrate that shallow recursive clones fail","fromName":"","fromEmail":"larsxschneider@gmail.com","sentAt":"2015-11-12T09:04:09Z","receivedAt":"2015-11-12T09:04:09Z","isPatch":true,"sender":{"key":"larsxschneider@gmail.com","avatar":"https://avatars.githubusercontent.com/u/477434?v=4"},"body":"From: Lars Schneider <larsxschneider@gmail.com>\n\n\"git clone --recursive --depth 1 --single-branch <url>\" clones the\nsubmodules successfully. However, it does not obey \"--depth 1\" for\nsubmodule cloning.\n\nThe following workaround does only work if the used submodule pointer\nis on the default branch. Otherwise \"git submodule update\" fails with\n\"fatal: reference is not a tree:\" and \"Unable to checkout\".\ngit clone --depth 1 --single-branch <url>\ncd <repo-name>\ngit submodule update --init --recursive --depth 1\n\nSigned-off-by: Lars Schneider <larsxschneider@gmail.com>\n---\n t/t7412-submodule-recursive.sh | 64 ++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 64 insertions(+)\n create mode 100755 t/t7412-submodule-recursive.sh\n\ndiff --git a/t/t7412-submodule-recursive.sh b/t/t7412-submodule-recursive.sh\nnew file mode 100755\nindex 0000000..c639f96\n--- /dev/null\n+++ b/t/t7412-submodule-recursive.sh\n@@ -0,0 +1,64 @@\n+#!/bin/sh\n+\n+test_description='Test shallow cloning of repos with submodules'\n+\n+. ./test-lib.sh\n+\n+test_expect_success setup '\n+\tgit checkout -b master &&\n+\techo file >file &&\n+\tgit add file &&\n+\ttest_tick &&\n+\tgit commit -m \"master commit\" &&\n+\n+\tgit checkout -b branch &&\n+\techo file >branch-file &&\n+\tgit add branch-file &&\n+\ttest_tick &&\n+\tgit commit -m \"branch commit\" &&\n+\n+\tgit checkout master &&\n+\n+\tgit clone . repo &&\n+\t(\n+\t\tcd repo &&\n+\t\tgit submodule add ../. submodule &&\n+\t\t(\n+\t\t\tcd submodule &&\n+\t\t\tgit checkout branch\n+\t\t) &&\n+\t\tgit add submodule &&\n+\t\ttest_tick &&\n+\t\tgit commit -m \"submodule\"\n+\t)\n+'\n+\n+test_expect_failure shallow-clone-recursive '\n+\tURL=\"file://$(pwd | sed \"s/[[:space:]]/%20/g\")/repo\" &&\n+\techo $URL &&\n+\tgit clone --recursive --depth 1 --single-branch $URL clone-recursive &&\n+\t(\n+\t\tcd \"clone-recursive\" &&\n+\t\tgit log --oneline >lines &&\n+\t\ttest_line_count = 1 lines\n+\t) &&\n+\t(\n+\t\tcd \"clone-recursive/submodule\" &&\n+\t\tgit log --oneline >lines &&\n+\t\ttest_line_count = 1 lines\n+\t)\n+'\n+\n+test_expect_failure shallow-clone-recursive-workaround '\n+\tURL=\"file://$(pwd | sed \"s/[[:space:]]/%20/g\")/repo\" &&\n+\techo $URL &&\n+\tgit clone --depth 1 --single-branch $URL clone-recursive-workaround &&\n+\t(\n+\t\tcd \"clone-recursive-workaround\" &&\n+\t\tgit log --oneline >lines &&\n+\t\ttest_line_count = 1 lines &&\n+\t\tgit submodule update --init --recursive --depth 1\n+\t)\n+'\n+\n+test_done\n-- \n2.5.1\n"}]}