Sync with 'master'
[alt-git.git] / t / t7420-submodule-set-url.sh
blobd7fe910bbe1fe638818e52bb0191cd79b8dfd66c
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_PASSES_SANITIZE_LEAK=true
14 . ./test-lib.sh
16 test_expect_success 'setup' '
17 git config --global protocol.file.allow always
20 test_expect_success 'submodule config cache setup' '
21 mkdir submodule &&
23 cd submodule &&
24 git init &&
25 echo a >file &&
26 git add file &&
27 git commit -ma
28 ) &&
29 mkdir namedsubmodule &&
31 cd namedsubmodule &&
32 git init &&
33 echo 1 >file &&
34 git add file &&
35 git commit -m1
36 ) &&
37 mkdir super &&
39 cd super &&
40 git init &&
41 git submodule add ../submodule &&
42 git submodule add --name thename ../namedsubmodule thepath &&
43 git commit -m "add submodules"
47 test_expect_success 'test submodule set-url' '
48 # add commits and move the submodules (change the urls)
50 cd submodule &&
51 echo b >>file &&
52 git add file &&
53 git commit -mb
54 ) &&
55 mv submodule newsubmodule &&
58 cd namedsubmodule &&
59 echo 2 >>file &&
60 git add file &&
61 git commit -m2
62 ) &&
63 mv namedsubmodule newnamedsubmodule &&
65 git -C newsubmodule show >expect &&
66 git -C newnamedsubmodule show >>expect &&
68 cd super &&
69 test_must_fail git submodule update --remote &&
70 git submodule set-url submodule ../newsubmodule &&
71 test_cmp_config ../newsubmodule -f .gitmodules submodule.submodule.url &&
72 git submodule set-url thepath ../newnamedsubmodule &&
73 test_cmp_config ../newnamedsubmodule -f .gitmodules submodule.thename.url &&
74 test_cmp_config "" -f .gitmodules --default "" submodule.thepath.url &&
75 git submodule update --remote
76 ) &&
77 git -C super/submodule show >actual &&
78 git -C super/thepath show >>actual &&
79 test_cmp expect actual
82 test_done