[PATCH] submodule: Test a shallow branch
From: Stefan Beller <hidden>
Date: 2016-06-15 23:06:50
Subsystem:
the rest · Maintainer:
Linus Torvalds
Instead of tracking the submodule at the specified branch, using a shallow clone, we get the following error: fatal: Cannot update paths and switch to branch 'anotherbranch' at the same time. Did you intend to checkout 'origin/anotherbranch' which can not be resolved as commit? Unable to checkout submodule 'submodule' Noticed-by: Carlos Pita [off-list ref] Signed-off-by: Stefan Beller <redacted> --- Hi Carlos, I can reproduce your issue and have a patch which we can add to the testing suite to document this faulty behavior. Thanks, Stefan t/t7400-submodule-basic.sh | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
index 540771c..cee74cb 100755
--- a/t/t7400-submodule-basic.sh
+++ b/t/t7400-submodule-basic.sh@@ -846,7 +846,8 @@ test_expect_success 'submodule add with an existing name fails unless forced' ' test_expect_success 'set up a second submodule' ' git submodule add ./init2 example2 && - git commit -m "submodule example2 added" + git commit -m "submodule example2 added" && + git checkout -b anotherbranch ' test_expect_success 'submodule deinit should remove the whole submodule section from .git/config' '
@@ -987,6 +988,7 @@ test_expect_success 'submodule with UTF-8 name' ' test_expect_success 'submodule add clone shallow submodule' ' mkdir super && + test_when_finished "rm -rf super" && pwd=$(pwd) && ( cd super &&
@@ -999,5 +1001,21 @@ test_expect_success 'submodule add clone shallow submodule' ' ) ' +test_expect_failure 'submodule add a shallow branch' ' + mkdir super && + test_when_finished "rm -rf super" && + pwd=$(pwd) && + ( + cd super && + git init && + git submodule add --depth=1 --branch anotherbranch file://"$pwd"/example2 submodule && + ( + cd submodule && + test 1 = $(git log --oneline | wc -l) + ) + ) +' + + test_done
--
2.5.0.268.g453a26a