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>
Junio C Hamano committed
Jan 15, 2008 at 03:13 UTC
a2d93aea25e33468622fbd6d9a6e02f8dd8b3c58
1 file changed
+28
-28
t/t7400-submodule-basic.sh
+28
-28
@@ -13,11 +13,11 @@ subcommands of git-submodule.
13
14
#
15
# Test setup:
16
-# -create a repository in directory lib
16
+# -create a repository in directory init
17
# -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
19
# -add a couple of regular files to enable testing of submodule filtering
20
-# -mv lib subrepo
20
+# -mv init subrepo
21
# -add an entry to .gitmodules for submodule 'example'
22
#
23
test_expect_success 'Prepare submodule testing' '
@@ -25,8 +25,8 @@ test_expect_success 'Prepare submodule testing' '
25
git-add t &&
26
git-commit -m "initial commit" &&
27
git branch initial HEAD &&
28
- mkdir lib &&
29
- cd lib &&
28
+ mkdir init &&
29
+ cd init &&
30
git init &&
31
echo a >a &&
32
git add a &&
@@ -41,10 +41,10 @@ test_expect_success 'Prepare submodule testing' '
41
cd .. &&
42
echo a >a &&
43
echo z >z &&
44
- git add a lib z &&
44
+ git add a init z &&
45
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
48
'
49
50
test_expect_success 'status should fail for unmapped paths' '
@@ -52,7 +52,7 @@ test_expect_success 'status should fail for unmapped paths' '
52
then
53
echo "[OOPS] submodule status succeeded"
54
false
55
- elif ! GIT_CONFIG=.gitmodules git config submodule.example.path lib
55
+ elif ! GIT_CONFIG=.gitmodules git config submodule.example.path init
56
then
57
echo "[OOPS] git config failed to update .gitmodules"
58
false
@@ -71,7 +71,7 @@ test_expect_success 'status should initially be "missing"' '
71
test_expect_success 'init should register submodule url in .git/config' '
72
git-submodule init &&
73
url=$(git config submodule.example.url) &&
74
- if test "$url" != "git://example.com/lib.git"
74
+ if test "$url" != "git://example.com/init.git"
75
then
76
echo "[OOPS] init succeeded but submodule url is wrong"
77
false
@@ -83,41 +83,41 @@ test_expect_success 'init should register submodule url in .git/config' '
83
'
84
85
test_expect_success 'update should fail when path is used by a file' '
86
- echo "hello" >lib &&
86
+ echo "hello" >init &&
87
if git-submodule update
88
then
89
echo "[OOPS] update should have failed"
90
false
91
- elif test "$(cat lib)" != "hello"
91
+ elif test "$(cat init)" != "hello"
92
then
93
- echo "[OOPS] update failed but lib file was molested"
93
+ echo "[OOPS] update failed but init file was molested"
94
false
95
else
96
- rm lib
96
+ rm init
97
fi
98
'
99
100
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 &&
103
if git-submodule update
104
then
105
echo "[OOPS] update should have failed"
106
false
107
- elif test "$(cat lib/a)" != "hello"
107
+ elif test "$(cat init/a)" != "hello"
108
then
109
- echo "[OOPS] update failed but lib/a was molested"
109
+ echo "[OOPS] update failed but init/a was molested"
110
false
111
else
112
- rm lib/a
112
+ rm init/a
113
fi
114
'
115
116
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 &&
119
git-submodule update &&
120
- head=$(cd lib && git rev-parse HEAD) &&
120
+ head=$(cd init && git rev-parse HEAD) &&
121
if test -z "$head"
122
then
123
echo "[OOPS] Failed to obtain submodule head"
@@ -134,7 +134,7 @@ test_expect_success 'status should be "up-to-date" after update' '
134
'
135
136
test_expect_success 'status should be "modified" after submodule commit' '
137
- cd lib &&
137
+ cd init &&
138
echo b >b &&
139
git add b &&
140
git-commit -m "submodule commit 2" &&
@@ -157,8 +157,8 @@ test_expect_success 'git diff should report the SHA1 of the new submodule commit
157
'
158
159
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) &&
162
if test -z "$head"
163
then
164
echo "[OOPS] submodule git rev-parse returned nothing"
@@ -182,13 +182,13 @@ test_expect_success 'checkout superproject with subproject already present' '
182
test_expect_success 'apply submodule diff' '
183
git branch second &&
184
(
185
- cd lib &&
185
+ cd init &&
186
echo s >s &&
187
git add s &&
188
git commit -m "change subproject"
189
) &&
190
- git update-index --add lib &&
191
- git-commit -m "change lib" &&
190
+ git update-index --add init &&
191
+ git-commit -m "change init" &&
192
git-format-patch -1 --stdout >P.diff &&
193
git checkout second &&
194
git apply --index P.diff &&