All of lore.kernel.org
 help / color / mirror / Atom feed
* Add submodule specifying depth and branch at the same time won't work
@ 2015-10-12 19:48 Carlos Pita
  2015-10-12 21:36 ` [PATCH] submodule: Test a shallow branch Stefan Beller
  0 siblings, 1 reply; 3+ messages in thread
From: Carlos Pita @ 2015-10-12 19:48 UTC (permalink / raw)
  To: git

For example, I can do:

git clone --depth 1 --branch devel git@gitlab.com:memeplex/bash.git

But if I try:

git submodule add --depth 1 -b devel git@gitlab.com:memeplex/bash.git

I get:

fatal: Cannot update paths and switch to branch 'devel' at the same time.
Did you intend to checkout 'origin/devel' which can not be resolved as commit?
Unable to checkout submodule 'src/aur/bash'


I think the devel branch is left outside the update because depth is
just 1, but then the same could be said for the clone, which just
works. The request should be interpreted as depth 1 inside devel
branch.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] submodule: Test a shallow branch
  2015-10-12 19:48 Add submodule specifying depth and branch at the same time won't work Carlos Pita
@ 2015-10-12 21:36 ` Stefan Beller
  2015-10-12 21:59   ` Fwd: " Stefan Beller
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Beller @ 2015-10-12 21:36 UTC (permalink / raw)
  To: gitster; +Cc: git, carlosjosepita, Stefan Beller

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 <carlosjosepita@gmail.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
---

 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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Fwd: [PATCH] submodule: Test a shallow branch
  2015-10-12 21:36 ` [PATCH] submodule: Test a shallow branch Stefan Beller
@ 2015-10-12 21:59   ` Stefan Beller
  0 siblings, 0 replies; 3+ messages in thread
From: Stefan Beller @ 2015-10-12 21:59 UTC (permalink / raw)
  To: Heiko Voigt, Jens Lehmann, git, Junio C Hamano, carlosjosepita

I forgot to CC you guys.

---------- Forwarded message ----------
From: Stefan Beller <sbeller@google.com>
Date: Mon, Oct 12, 2015 at 2:36 PM
Subject: [PATCH] submodule: Test a shallow branch
To: gitster@pobox.com
Cc: git@vger.kernel.org, carlosjosepita@gmail.com, Stefan Beller
<sbeller@google.com>


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 <carlosjosepita@gmail.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
---

 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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-10-12 21:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-12 19:48 Add submodule specifying depth and branch at the same time won't work Carlos Pita
2015-10-12 21:36 ` [PATCH] submodule: Test a shallow branch Stefan Beller
2015-10-12 21:59   ` Fwd: " Stefan Beller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.