{"thread":{"id":"40541","subject":"Add submodule specifying depth and branch at the same time won't work","startedAt":"2015-10-12T19:48:09Z","lastAt":"2015-10-12T21:59:32Z","messageCount":3,"participants":["Carlos Pita","Stefan Beller"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"271484","messageId":"CAELgYhcmzDEVRH9neGwZeqVBduL-nb=d+XoSMwRGKpmLUeX83g@mail.gmail.com","threadId":"40541","inReplyTo":null,"subject":"Add submodule specifying depth and branch at the same time won't work","fromName":"Carlos Pita","fromEmail":"carlosjosepita@gmail.com","sentAt":"2015-10-12T19:48:09Z","receivedAt":"2015-10-12T19:48:09Z","isPatch":false,"sender":{"key":"carlosjosepita@gmail.com","avatar":"https://gravatar.com/avatar/cf95d94f5258e3cbf21c26fb6fee0d7b16a1b26b6a19e33c805527c598197321?d=mp&s=160"},"body":"For example, I can do:\n\ngit clone --depth 1 --branch devel git@gitlab.com:memeplex/bash.git\n\nBut if I try:\n\ngit submodule add --depth 1 -b devel git@gitlab.com:memeplex/bash.git\n\nI get:\n\nfatal: Cannot update paths and switch to branch 'devel' at the same time.\nDid you intend to checkout 'origin/devel' which can not be resolved as commit?\nUnable to checkout submodule 'src/aur/bash'\n\n\nI think the devel branch is left outside the update because depth is\njust 1, but then the same could be said for the clone, which just\nworks. The request should be interpreted as depth 1 inside devel\nbranch.\n"},{"id":"271493","messageId":"1444685784-29598-1-git-send-email-sbeller@google.com","threadId":"40541","inReplyTo":"CAELgYhcmzDEVRH9neGwZeqVBduL-nb=d+XoSMwRGKpmLUeX83g@mail.gmail.com","subject":"[PATCH] submodule: Test a shallow branch","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2015-10-12T21:36:24Z","receivedAt":"2015-10-12T21:36:24Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Instead of tracking the submodule at the specified branch, using a shallow\nclone, we get the following error:\n\nfatal: Cannot update paths and switch to branch 'anotherbranch' at the same time.\nDid you intend to checkout 'origin/anotherbranch' which can not be resolved as commit?\nUnable to checkout submodule 'submodule'\n\nNoticed-by: Carlos Pita <carlosjosepita@gmail.com>\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n\n Hi Carlos,\n \n I can reproduce your issue and have a patch which we can add to the\n testing suite to document this faulty behavior.\n \n Thanks,\n Stefan\n\n t/t7400-submodule-basic.sh | 20 +++++++++++++++++++-\n 1 file changed, 19 insertions(+), 1 deletion(-)\n\ndiff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh\nindex 540771c..cee74cb 100755\n--- a/t/t7400-submodule-basic.sh\n+++ b/t/t7400-submodule-basic.sh\n@@ -846,7 +846,8 @@ test_expect_success 'submodule add with an existing name fails unless forced' '\n \n test_expect_success 'set up a second submodule' '\n \tgit submodule add ./init2 example2 &&\n-\tgit commit -m \"submodule example2 added\"\n+\tgit commit -m \"submodule example2 added\" &&\n+\tgit checkout -b anotherbranch\n '\n \n test_expect_success 'submodule deinit should remove the whole submodule section from .git/config' '\n@@ -987,6 +988,7 @@ test_expect_success 'submodule with UTF-8 name' '\n \n test_expect_success 'submodule add clone shallow submodule' '\n \tmkdir super &&\n+\ttest_when_finished \"rm -rf super\" &&\n \tpwd=$(pwd) &&\n \t(\n \t\tcd super &&\n@@ -999,5 +1001,21 @@ test_expect_success 'submodule add clone shallow submodule' '\n \t)\n '\n \n+test_expect_failure 'submodule add a shallow branch' '\n+\tmkdir super &&\n+\ttest_when_finished \"rm -rf super\" &&\n+\tpwd=$(pwd) &&\n+\t(\n+\t\tcd super &&\n+\t\tgit init &&\n+\t\tgit submodule add --depth=1 --branch anotherbranch file://\"$pwd\"/example2 submodule &&\n+\t\t(\n+\t\t\tcd submodule &&\n+\t\t\ttest 1 = $(git log --oneline | wc -l)\n+\t\t)\n+\t)\n+'\n+\n+\n \n test_done\n-- \n2.5.0.268.g453a26a\n"},{"id":"271538","messageId":"CAGZ79kYHZcByZc5Ju5K6YCcrWDt7Wt2Q0z4YYA4NTezg=358OQ@mail.gmail.com","threadId":"40541","inReplyTo":"1444685784-29598-1-git-send-email-sbeller@google.com","subject":"Fwd: [PATCH] submodule: Test a shallow branch","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2015-10-12T21:59:32Z","receivedAt":"2015-10-12T21:59:32Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"I forgot to CC you guys.\n\n---------- Forwarded message ----------\nFrom: Stefan Beller <sbeller@google.com>\nDate: Mon, Oct 12, 2015 at 2:36 PM\nSubject: [PATCH] submodule: Test a shallow branch\nTo: gitster@pobox.com\nCc: git@vger.kernel.org, carlosjosepita@gmail.com, Stefan Beller\n<sbeller@google.com>\n\n\nInstead of tracking the submodule at the specified branch, using a shallow\nclone, we get the following error:\n\nfatal: Cannot update paths and switch to branch 'anotherbranch' at the\nsame time.\nDid you intend to checkout 'origin/anotherbranch' which can not be\nresolved as commit?\nUnable to checkout submodule 'submodule'\n\nNoticed-by: Carlos Pita <carlosjosepita@gmail.com>\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n\n Hi Carlos,\n\n I can reproduce your issue and have a patch which we can add to the\n testing suite to document this faulty behavior.\n\n Thanks,\n Stefan\n\n t/t7400-submodule-basic.sh | 20 +++++++++++++++++++-\n 1 file changed, 19 insertions(+), 1 deletion(-)\n\ndiff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh\nindex 540771c..cee74cb 100755\n--- a/t/t7400-submodule-basic.sh\n+++ b/t/t7400-submodule-basic.sh\n@@ -846,7 +846,8 @@ test_expect_success 'submodule add with an\nexisting name fails unless forced' '\n\n test_expect_success 'set up a second submodule' '\n        git submodule add ./init2 example2 &&\n-       git commit -m \"submodule example2 added\"\n+       git commit -m \"submodule example2 added\" &&\n+       git checkout -b anotherbranch\n '\n\n test_expect_success 'submodule deinit should remove the whole\nsubmodule section from .git/config' '\n@@ -987,6 +988,7 @@ test_expect_success 'submodule with UTF-8 name' '\n\n test_expect_success 'submodule add clone shallow submodule' '\n        mkdir super &&\n+       test_when_finished \"rm -rf super\" &&\n        pwd=$(pwd) &&\n        (\n                cd super &&\n@@ -999,5 +1001,21 @@ test_expect_success 'submodule add clone shallow\nsubmodule' '\n        )\n '\n\n+test_expect_failure 'submodule add a shallow branch' '\n+       mkdir super &&\n+       test_when_finished \"rm -rf super\" &&\n+       pwd=$(pwd) &&\n+       (\n+               cd super &&\n+               git init &&\n+               git submodule add --depth=1 --branch anotherbranch\nfile://\"$pwd\"/example2 submodule &&\n+               (\n+                       cd submodule &&\n+                       test 1 = $(git log --oneline | wc -l)\n+               )\n+       )\n+'\n+\n+\n\n test_done\n--\n2.5.0.268.g453a26a\n"}]}