Skip to content

Commit bd1c20c

Browse files
heftiggitster
authored andcommitted
t7420: test that we correctly handle renamed submodules
Create a second submodule with a name that differs from its path. Test that calling set-url modifies the correct .gitmodules entries. Make sure we don't create a section named after the path instead of the name. Signed-off-by: Jan Alexander Steffens (heftig) <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 32bff36 commit bd1c20c

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

t/t7420-submodule-set-url.sh

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,26 @@ test_expect_success 'submodule config cache setup' '
2525
git add file &&
2626
git commit -ma
2727
) &&
28+
mkdir namedsubmodule &&
29+
(
30+
cd namedsubmodule &&
31+
git init &&
32+
echo 1 >file &&
33+
git add file &&
34+
git commit -m1
35+
) &&
2836
mkdir super &&
2937
(
3038
cd super &&
3139
git init &&
3240
git submodule add ../submodule &&
33-
git commit -m "add submodule"
41+
git submodule add --name thename ../namedsubmodule thepath &&
42+
git commit -m "add submodules"
3443
)
3544
'
3645

3746
test_expect_success 'test submodule set-url' '
38-
# add a commit and move the submodule (change the url)
47+
# add commits and move the submodules (change the urls)
3948
(
4049
cd submodule &&
4150
echo b >>file &&
@@ -44,15 +53,28 @@ test_expect_success 'test submodule set-url' '
4453
) &&
4554
mv submodule newsubmodule &&
4655
56+
(
57+
cd namedsubmodule &&
58+
echo 2 >>file &&
59+
git add file &&
60+
git commit -m2
61+
) &&
62+
mv namedsubmodule newnamedsubmodule &&
63+
4764
git -C newsubmodule show >expect &&
65+
git -C newnamedsubmodule show >>expect &&
4866
(
4967
cd super &&
5068
test_must_fail git submodule update --remote &&
5169
git submodule set-url submodule ../newsubmodule &&
5270
test_cmp_config ../newsubmodule -f .gitmodules submodule.submodule.url &&
71+
git submodule set-url thepath ../newnamedsubmodule &&
72+
test_cmp_config ../newnamedsubmodule -f .gitmodules submodule.thename.url &&
73+
test_cmp_config "" -f .gitmodules --default "" submodule.thepath.url &&
5374
git submodule update --remote
5475
) &&
5576
git -C super/submodule show >actual &&
77+
git -C super/thepath show >>actual &&
5678
test_cmp expect actual
5779
'
5880

0 commit comments

Comments
 (0)