Skip to content

Commit 32bff36

Browse files
heftiggitster
authored andcommitted
t7419: test that we correctly handle renamed submodules
Add the submodule again with an explicitly different name and path. Test that calling set-branch 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 5fc8806 commit 32bff36

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

t/t7419-submodule-set-branch.sh

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ test_expect_success 'submodule config cache setup' '
3838
(cd super &&
3939
git init &&
4040
git submodule add ../submodule &&
41-
git commit -m "add submodule"
41+
git submodule add --name thename ../submodule thepath &&
42+
git commit -m "add submodules"
4243
)
4344
'
4445

@@ -100,4 +101,31 @@ test_expect_success 'test submodule set-branch -d' '
100101
)
101102
'
102103

104+
test_expect_success 'test submodule set-branch --branch with named submodule' '
105+
(cd super &&
106+
git submodule set-branch --branch topic thepath &&
107+
test_cmp_config topic -f .gitmodules submodule.thename.branch &&
108+
test_cmp_config "" -f .gitmodules --default "" submodule.thepath.branch &&
109+
git submodule update --remote &&
110+
cat <<-\EOF >expect &&
111+
b
112+
EOF
113+
git -C thepath show -s --pretty=%s >actual &&
114+
test_cmp expect actual
115+
)
116+
'
117+
118+
test_expect_success 'test submodule set-branch --default with named submodule' '
119+
(cd super &&
120+
git submodule set-branch --default thepath &&
121+
test_cmp_config "" -f .gitmodules --default "" submodule.thename.branch &&
122+
git submodule update --remote &&
123+
cat <<-\EOF >expect &&
124+
a
125+
EOF
126+
git -C thepath show -s --pretty=%s >actual &&
127+
test_cmp expect actual
128+
)
129+
'
130+
103131
test_done

0 commit comments

Comments
 (0)