Merge branch 'ob/sequencer-rearrange-cleanup'
[git.git] / t / t7420-submodule-set-url.sh
blobd6bf62b3ac670fc0be8167150cdf79cbd9000a45
1 #!/bin/sh
3 # Copyright (c) 2019 Denton Liu
6 test_description='Test submodules set-url subcommand
8 This test verifies that the set-url subcommand of git-submodule is working
9 as expected.
12 TEST_NO_CREATE_REPO=1
13 . ./test-lib.sh
15 test_expect_success 'setup' '
16 git config --global protocol.file.allow always
19 test_expect_success 'submodule config cache setup' '
20 mkdir submodule &&
22 cd submodule &&
23 git init &&
24 echo a >file &&
25 git add file &&
26 git commit -ma
27 ) &&
28 mkdir super &&
30 cd super &&
31 git init &&
32 git submodule add ../submodule &&
33 git commit -m "add submodule"
37 test_expect_success 'test submodule set-url' '
38 # add a commit and move the submodule (change the url)
40 cd submodule &&
41 echo b >>file &&
42 git add file &&
43 git commit -mb
44 ) &&
45 mv submodule newsubmodule &&
47 git -C newsubmodule show >expect &&
49 cd super &&
50 test_must_fail git submodule update --remote &&
51 git submodule set-url submodule ../newsubmodule &&
52 grep -F "url = ../newsubmodule" .gitmodules &&
53 git submodule update --remote
54 ) &&
55 git -C super/submodule show >actual &&
56 test_cmp expect actual
59 test_done