Skip to content

Commit a2d93ae

Browse files
committed
git-submodule: add test for the subcommand parser fix
This modifies the existing t7400 test to use 'init' as the pathname that a submodule is bound to. Without the earlier subcommand parser fix, this fails. Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 5c08dbb commit a2d93ae

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

t/t7400-submodule-basic.sh

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,20 @@ subcommands of git-submodule.
1313

1414
#
1515
# Test setup:
16-
# -create a repository in directory lib
16+
# -create a repository in directory init
1717
# -add a couple of files
18-
# -add directory lib to 'superproject', this creates a DIRLINK entry
18+
# -add directory init to 'superproject', this creates a DIRLINK entry
1919
# -add a couple of regular files to enable testing of submodule filtering
20-
# -mv lib subrepo
20+
# -mv init subrepo
2121
# -add an entry to .gitmodules for submodule 'example'
2222
#
2323
test_expect_success 'Prepare submodule testing' '
2424
: > t &&
2525
git-add t &&
2626
git-commit -m "initial commit" &&
2727
git branch initial HEAD &&
28-
mkdir lib &&
29-
cd lib &&
28+
mkdir init &&
29+
cd init &&
3030
git init &&
3131
echo a >a &&
3232
git add a &&
@@ -41,18 +41,18 @@ test_expect_success 'Prepare submodule testing' '
4141
cd .. &&
4242
echo a >a &&
4343
echo z >z &&
44-
git add a lib z &&
44+
git add a init z &&
4545
git-commit -m "super commit 1" &&
46-
mv lib .subrepo &&
47-
GIT_CONFIG=.gitmodules git config submodule.example.url git://example.com/lib.git
46+
mv init .subrepo &&
47+
GIT_CONFIG=.gitmodules git config submodule.example.url git://example.com/init.git
4848
'
4949

5050
test_expect_success 'status should fail for unmapped paths' '
5151
if git-submodule status
5252
then
5353
echo "[OOPS] submodule status succeeded"
5454
false
55-
elif ! GIT_CONFIG=.gitmodules git config submodule.example.path lib
55+
elif ! GIT_CONFIG=.gitmodules git config submodule.example.path init
5656
then
5757
echo "[OOPS] git config failed to update .gitmodules"
5858
false
@@ -71,7 +71,7 @@ test_expect_success 'status should initially be "missing"' '
7171
test_expect_success 'init should register submodule url in .git/config' '
7272
git-submodule init &&
7373
url=$(git config submodule.example.url) &&
74-
if test "$url" != "git://example.com/lib.git"
74+
if test "$url" != "git://example.com/init.git"
7575
then
7676
echo "[OOPS] init succeeded but submodule url is wrong"
7777
false
@@ -83,41 +83,41 @@ test_expect_success 'init should register submodule url in .git/config' '
8383
'
8484

8585
test_expect_success 'update should fail when path is used by a file' '
86-
echo "hello" >lib &&
86+
echo "hello" >init &&
8787
if git-submodule update
8888
then
8989
echo "[OOPS] update should have failed"
9090
false
91-
elif test "$(cat lib)" != "hello"
91+
elif test "$(cat init)" != "hello"
9292
then
93-
echo "[OOPS] update failed but lib file was molested"
93+
echo "[OOPS] update failed but init file was molested"
9494
false
9595
else
96-
rm lib
96+
rm init
9797
fi
9898
'
9999

100100
test_expect_success 'update should fail when path is used by a nonempty directory' '
101-
mkdir lib &&
102-
echo "hello" >lib/a &&
101+
mkdir init &&
102+
echo "hello" >init/a &&
103103
if git-submodule update
104104
then
105105
echo "[OOPS] update should have failed"
106106
false
107-
elif test "$(cat lib/a)" != "hello"
107+
elif test "$(cat init/a)" != "hello"
108108
then
109-
echo "[OOPS] update failed but lib/a was molested"
109+
echo "[OOPS] update failed but init/a was molested"
110110
false
111111
else
112-
rm lib/a
112+
rm init/a
113113
fi
114114
'
115115

116116
test_expect_success 'update should work when path is an empty dir' '
117-
rm -rf lib &&
118-
mkdir lib &&
117+
rm -rf init &&
118+
mkdir init &&
119119
git-submodule update &&
120-
head=$(cd lib && git rev-parse HEAD) &&
120+
head=$(cd init && git rev-parse HEAD) &&
121121
if test -z "$head"
122122
then
123123
echo "[OOPS] Failed to obtain submodule head"
@@ -134,7 +134,7 @@ test_expect_success 'status should be "up-to-date" after update' '
134134
'
135135

136136
test_expect_success 'status should be "modified" after submodule commit' '
137-
cd lib &&
137+
cd init &&
138138
echo b >b &&
139139
git add b &&
140140
git-commit -m "submodule commit 2" &&
@@ -157,8 +157,8 @@ test_expect_success 'git diff should report the SHA1 of the new submodule commit
157157
'
158158

159159
test_expect_success 'update should checkout rev1' '
160-
git-submodule update &&
161-
head=$(cd lib && git rev-parse HEAD) &&
160+
git-submodule update init &&
161+
head=$(cd init && git rev-parse HEAD) &&
162162
if test -z "$head"
163163
then
164164
echo "[OOPS] submodule git rev-parse returned nothing"
@@ -182,13 +182,13 @@ test_expect_success 'checkout superproject with subproject already present' '
182182
test_expect_success 'apply submodule diff' '
183183
git branch second &&
184184
(
185-
cd lib &&
185+
cd init &&
186186
echo s >s &&
187187
git add s &&
188188
git commit -m "change subproject"
189189
) &&
190-
git update-index --add lib &&
191-
git-commit -m "change lib" &&
190+
git update-index --add init &&
191+
git-commit -m "change init" &&
192192
git-format-patch -1 --stdout >P.diff &&
193193
git checkout second &&
194194
git apply --index P.diff &&

0 commit comments

Comments
 (0)