Thread (38 messages) 38 messages, 5 authors, 2016-06-15

[PATCH v4 5/6] t7406: Add explicit tests for head attachement after cloning updates

DORMANTno replies

From: W. Trevor King <hidden>
Date: 2016-06-15 22:59:40
Subsystem: the rest · Maintainer: Linus Torvalds

Test that cloning updates checkout the appropriate local branch for
their update-mode:

* Checkout-mode updates get detached HEADs
* Everyone else gets a local branch, matching the configured
  submodule.<name>.branch and defaulting to master.

The 'initial-setup' tag makes it easy to reset the superproject to a
known state, as several earlier tests commit to submodules and commit
the changed gitlinks to the superproject, but don't push the new
submodule commits to the upstream subprojects.  This makes it
impossible to checkout the current super master, because it references
submodule commits that don't exist in the upstream subprojects.  For a
specific example, see the tests that currently generate the
'two_new_submodule_commits' commits.

Signed-off-by: W. Trevor King <redacted>
---
 t/t7406-submodule-update.sh | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh
index 5aa9591..f056c01 100755
--- a/t/t7406-submodule-update.sh
+++ b/t/t7406-submodule-update.sh
@@ -63,6 +63,9 @@ test_expect_success 'setup a submodule tree' '
 	 git submodule add ../none none &&
 	 test_tick &&
 	 git commit -m "none"
+	) &&
+	(cd super &&
+	 git tag initial-setup
 	)
 '
 
@@ -764,4 +767,38 @@ test_expect_success 'submodule update clone shallow submodule' '
 	 )
 	)
 '
+
+test_expect_success 'submodule update --checkout clones detached HEAD' '
+	git clone super super4 &&
+	echo "detached HEAD" >expected &&
+	(cd super4 &&
+	 git reset --hard initial-setup &&
+	 git submodule init submodule &&
+	 git submodule update >> /tmp/log 2>&1 &&
+	 (cd submodule &&
+	  git symbolic-ref HEAD > ../../actual ||
+	  echo "detached HEAD" > ../../actual
+	 )
+	) &&
+	test_cmp actual expected &&
+	rm -rf super4
+'
+
+test_expect_success 'submodule update --merge clones attached HEAD' '
+	git clone super super4 &&
+	echo "refs/heads/master" >expected &&
+	(cd super4 &&
+	 git reset --hard initial-setup &&
+	 git submodule init submodule &&
+	 git config submodule.submodule.update merge &&
+	 git submodule update --merge &&
+	 (cd submodule &&
+	  git symbolic-ref HEAD > ../../actual ||
+	  echo "detached HEAD" > ../../actual
+	 )
+	) &&
+	test_cmp actual expected &&
+	rm -rf super4
+'
+
 test_done
-- 
1.8.5.2.8.g0f6c0d1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help