Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Avison <bavison@riscosopen.org>2019-05-19 17:26:49 +0300
committerJunio C Hamano <gitster@pobox.com>2019-05-28 19:22:02 +0300
commit4c6910163ab59f334becca39f5a83d3b7a622df4 (patch)
treebb72bfb03d00e6a15e8187f02a5070fe6c8498ec /t/t5617-clone-submodules-remote.sh
parentab15ad1a3b4b04a29415aef8c9afa2f64fc194a2 (diff)
clone: add `--remote-submodules` flag
When using `git clone --recurse-submodules` there was previously no way to pass a `--remote` switch to the implicit `git submodule update` command for any use case where you want the submodules to be checked out on their remote-tracking branch rather than with the SHA-1 recorded in the superproject. This patch rectifies this situation. It actually passes `--no-fetch` to `git submodule update` as well on the grounds they the submodule has only just been cloned, so fetching from the remote again only serves to slow things down. Signed-off-by: Ben Avison <bavison@riscosopen.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t5617-clone-submodules-remote.sh')
-rwxr-xr-xt/t5617-clone-submodules-remote.sh54
1 files changed, 54 insertions, 0 deletions
diff --git a/t/t5617-clone-submodules-remote.sh b/t/t5617-clone-submodules-remote.sh
new file mode 100755
index 0000000000..37fcce9c40
--- /dev/null
+++ b/t/t5617-clone-submodules-remote.sh
@@ -0,0 +1,54 @@
+#!/bin/sh
+
+test_description='Test cloning repos with submodules using remote-tracking branches'
+
+. ./test-lib.sh
+
+pwd=$(pwd)
+
+test_expect_success 'setup' '
+ git checkout -b master &&
+ test_commit commit1 &&
+ mkdir sub &&
+ (
+ cd sub &&
+ git init &&
+ test_commit subcommit1 &&
+ git tag sub_when_added_to_super
+ ) &&
+ git submodule add "file://$pwd/sub" sub &&
+ git commit -m "add submodule" &&
+ (
+ cd sub &&
+ test_commit subcommit2
+ )
+'
+
+test_expect_success 'clone with --no-remote-submodules' '
+ test_when_finished "rm -rf super_clone" &&
+ git clone --recurse-submodules --no-remote-submodules "file://$pwd/." super_clone &&
+ (
+ cd super_clone/sub &&
+ git diff --exit-code sub_when_added_to_super
+ )
+'
+
+test_expect_success 'clone with --remote-submodules' '
+ test_when_finished "rm -rf super_clone" &&
+ git clone --recurse-submodules --remote-submodules "file://$pwd/." super_clone &&
+ (
+ cd super_clone/sub &&
+ git diff --exit-code remotes/origin/master
+ )
+'
+
+test_expect_success 'check the default is --no-remote-submodules' '
+ test_when_finished "rm -rf super_clone" &&
+ git clone --recurse-submodules "file://$pwd/." super_clone &&
+ (
+ cd super_clone/sub &&
+ git diff --exit-code sub_when_added_to_super
+ )
+'
+
+test_done