Ben Avison | 4c69101 | 2019-05-19 15:26:49 +0100 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='Test cloning repos with submodules using remote-tracking branches' |
| 4 | |
Johannes Schindelin | 95cf2c0 | 2020-11-18 23:44:35 +0000 | [diff] [blame^] | 5 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
Johannes Schindelin | 334afbc | 2020-11-18 23:44:19 +0000 | [diff] [blame] | 6 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
| 7 | |
Ben Avison | 4c69101 | 2019-05-19 15:26:49 +0100 | [diff] [blame] | 8 | . ./test-lib.sh |
| 9 | |
| 10 | pwd=$(pwd) |
| 11 | |
| 12 | test_expect_success 'setup' ' |
Johannes Schindelin | 95cf2c0 | 2020-11-18 23:44:35 +0000 | [diff] [blame^] | 13 | git checkout -b main && |
Ben Avison | 4c69101 | 2019-05-19 15:26:49 +0100 | [diff] [blame] | 14 | test_commit commit1 && |
| 15 | mkdir sub && |
| 16 | ( |
| 17 | cd sub && |
| 18 | git init && |
| 19 | test_commit subcommit1 && |
Emily Shaffer | 132f600 | 2020-02-20 19:10:27 -0800 | [diff] [blame] | 20 | git tag sub_when_added_to_super && |
| 21 | git branch other |
Ben Avison | 4c69101 | 2019-05-19 15:26:49 +0100 | [diff] [blame] | 22 | ) && |
| 23 | git submodule add "file://$pwd/sub" sub && |
| 24 | git commit -m "add submodule" && |
| 25 | ( |
| 26 | cd sub && |
| 27 | test_commit subcommit2 |
| 28 | ) |
| 29 | ' |
| 30 | |
| 31 | test_expect_success 'clone with --no-remote-submodules' ' |
| 32 | test_when_finished "rm -rf super_clone" && |
| 33 | git clone --recurse-submodules --no-remote-submodules "file://$pwd/." super_clone && |
| 34 | ( |
| 35 | cd super_clone/sub && |
| 36 | git diff --exit-code sub_when_added_to_super |
| 37 | ) |
| 38 | ' |
| 39 | |
| 40 | test_expect_success 'clone with --remote-submodules' ' |
| 41 | test_when_finished "rm -rf super_clone" && |
| 42 | git clone --recurse-submodules --remote-submodules "file://$pwd/." super_clone && |
| 43 | ( |
| 44 | cd super_clone/sub && |
Johannes Schindelin | 95cf2c0 | 2020-11-18 23:44:35 +0000 | [diff] [blame^] | 45 | git diff --exit-code remotes/origin/main |
Ben Avison | 4c69101 | 2019-05-19 15:26:49 +0100 | [diff] [blame] | 46 | ) |
| 47 | ' |
| 48 | |
| 49 | test_expect_success 'check the default is --no-remote-submodules' ' |
| 50 | test_when_finished "rm -rf super_clone" && |
| 51 | git clone --recurse-submodules "file://$pwd/." super_clone && |
| 52 | ( |
| 53 | cd super_clone/sub && |
| 54 | git diff --exit-code sub_when_added_to_super |
| 55 | ) |
| 56 | ' |
| 57 | |
Emily Shaffer | 132f600 | 2020-02-20 19:10:27 -0800 | [diff] [blame] | 58 | test_expect_success 'clone with --single-branch' ' |
| 59 | test_when_finished "rm -rf super_clone" && |
| 60 | git clone --recurse-submodules --single-branch "file://$pwd/." super_clone && |
| 61 | ( |
| 62 | cd super_clone/sub && |
Johannes Schindelin | 95cf2c0 | 2020-11-18 23:44:35 +0000 | [diff] [blame^] | 63 | git rev-parse --verify origin/main && |
Emily Shaffer | 132f600 | 2020-02-20 19:10:27 -0800 | [diff] [blame] | 64 | test_must_fail git rev-parse --verify origin/other |
| 65 | ) |
| 66 | ' |
| 67 | |
Ben Avison | 4c69101 | 2019-05-19 15:26:49 +0100 | [diff] [blame] | 68 | test_done |