Skip to content

Commit ac8463d

Browse files
Michael J Grubergitster
authored andcommitted
git submodule: Add test cases for git submodule add
Add simple test cases for adding and initialising submodules. The init step is necessary in order to verify the added information. The second test exposes a known breakage due to './' in the path: git ls-files simplifies the path but git add does not, which leads to git init looking for different lines in .gitmodules than git add adds. The other tests add test cases for '//' and '..' in the path which currently fail for the same reason. Signed-off-by: Michael J Gruber <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent dcc901b commit ac8463d

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

t/t7400-submodule-basic.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,55 @@ test_expect_success 'Prepare submodule testing' '
4747
GIT_CONFIG=.gitmodules git config submodule.example.url git://example.com/init.git
4848
'
4949

50+
test_expect_success 'Prepare submodule add testing' '
51+
submodurl=$(pwd)
52+
(
53+
mkdir addtest &&
54+
cd addtest &&
55+
git init
56+
)
57+
'
58+
59+
test_expect_success 'submodule add' '
60+
(
61+
cd addtest &&
62+
git submodule add "$submodurl" submod &&
63+
git submodule init
64+
)
65+
'
66+
67+
test_expect_failure 'submodule add with ./ in path' '
68+
(
69+
cd addtest &&
70+
git submodule add "$submodurl" ././dotsubmod/./frotz/./ &&
71+
git submodule init
72+
)
73+
'
74+
75+
test_expect_failure 'submodule add with // in path' '
76+
(
77+
cd addtest &&
78+
git submodule add "$submodurl" slashslashsubmod///frotz// &&
79+
git submodule init
80+
)
81+
'
82+
83+
test_expect_failure 'submodule add with /.. in path' '
84+
(
85+
cd addtest &&
86+
git submodule add "$submodurl" dotdotsubmod/../realsubmod/frotz/.. &&
87+
git submodule init
88+
)
89+
'
90+
91+
test_expect_failure 'submodule add with ./, /.. and // in path' '
92+
(
93+
cd addtest &&
94+
git submodule add "$submodurl" dot/dotslashsubmod/./../..////realsubmod2/a/b/c/d/../../../../frotz//.. &&
95+
git submodule init
96+
)
97+
'
98+
5099
test_expect_success 'status should fail for unmapped paths' '
51100
if git submodule status
52101
then

0 commit comments

Comments
 (0)