]> git.ipfire.org Git - thirdparty/git.git/blob - t/t7420-submodule-set-url.sh
The sixth batch for 2.26
[thirdparty/git.git] / t / t7420-submodule-set-url.sh
1 #!/bin/sh
2 #
3 # Copyright (c) 2019 Denton Liu
4 #
5
6 test_description='Test submodules set-url subcommand
7
8 This test verifies that the set-url subcommand of git-submodule is working
9 as expected.
10 '
11
12 TEST_NO_CREATE_REPO=1
13 . ./test-lib.sh
14
15 test_expect_success 'submodule config cache setup' '
16 mkdir submodule &&
17 (
18 cd submodule &&
19 git init &&
20 echo a >file &&
21 git add file &&
22 git commit -ma
23 ) &&
24 mkdir super &&
25 (
26 cd super &&
27 git init &&
28 git submodule add ../submodule &&
29 git commit -m "add submodule"
30 )
31 '
32
33 test_expect_success 'test submodule set-url' '
34 # add a commit and move the submodule (change the url)
35 (
36 cd submodule &&
37 echo b >>file &&
38 git add file &&
39 git commit -mb
40 ) &&
41 mv submodule newsubmodule &&
42
43 git -C newsubmodule show >expect &&
44 (
45 cd super &&
46 test_must_fail git submodule update --remote &&
47 git submodule set-url submodule ../newsubmodule &&
48 grep -F "url = ../newsubmodule" .gitmodules &&
49 git submodule update --remote
50 ) &&
51 git -C super/submodule show >actual &&
52 test_cmp expect actual
53 '
54
55 test_done