t0001: drop subshells just for "cd"

Many tests do something like: ( mkdir foo && cd foo && git init ) You can do the same these days with "git init foo", which makes the tests shorter and simpler to read. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Mar 20, 2014 at 19:23 UTC 410c3428ed42bc0978e2917236e95cd5f860864f
1 file changed +9 -47
t/t0001-init.sh
+9 -47
@@ -24,11 +24,7 @@ check_config () {
24 }
25
26 test_expect_success 'plain' '
27 - (
28 - mkdir plain &&
29 - cd plain &&
30 - git init
31 - ) &&
27 + git init plain &&
28 check_config plain/.git false unset
29 '
30
@@ -90,11 +86,7 @@ test_expect_success 'plain with GIT_WORK_TREE' '
86 '
87
88 test_expect_success 'plain bare' '
93 - (
94 - mkdir plain-bare-1 &&
95 - cd plain-bare-1 &&
96 - git --bare init
97 - ) &&
89 + git --bare init plain-bare-1 &&
90 check_config plain-bare-1 true unset
91 '
92
@@ -112,12 +104,7 @@ test_expect_success 'GIT_DIR bare' '
104 '
105
106 test_expect_success 'init --bare' '
115 -
116 - (
117 - mkdir init-bare.git &&
118 - cd init-bare.git &&
119 - git init --bare
120 - ) &&
107 + git init --bare init-bare.git &&
108 check_config init-bare.git true unset
109 '
110
@@ -166,26 +153,14 @@ test_expect_success 'reinit' '
153 test_expect_success 'init with --template' '
154 mkdir template-source &&
155 echo content >template-source/file &&
169 - (
170 - mkdir template-custom &&
171 - cd template-custom &&
172 - git init --template=../template-source
173 - ) &&
156 + git init --template=../template-source template-custom &&
157 test_cmp template-source/file template-custom/.git/file
158 '
159
160 test_expect_success 'init with --template (blank)' '
178 - (
179 - mkdir template-plain &&
180 - cd template-plain &&
181 - git init
182 - ) &&
161 + git init template-plain &&
162 test_path_is_file template-plain/.git/info/exclude &&
184 - (
185 - mkdir template-blank &&
186 - cd template-blank &&
187 - git init --template=
188 - ) &&
163 + git init --template= template-blank &&
164 test_path_is_missing template-blank/.git/info/exclude
165 '
166
@@ -207,11 +182,7 @@ test_expect_success 'init with init.templatedir set' '
182 test_expect_success 'init --bare/--shared overrides system/global config' '
183 test_config_global core.bare false &&
184 test_config_global core.sharedRepository 0640 &&
210 - (
211 - mkdir init-bare-shared-override &&
212 - cd init-bare-shared-override &&
213 - git init --bare --shared=0666
214 - ) &&
185 + git init --bare --shared=0666 init-bare-shared-override &&
186 check_config init-bare-shared-override true unset &&
187 test x0666 = \
188 x`git config -f init-bare-shared-override/config core.sharedRepository`
@@ -219,22 +190,13 @@ test_expect_success 'init --bare/--shared overrides system/global config' '
190
191 test_expect_success 'init honors global core.sharedRepository' '
192 test_config_global core.sharedRepository 0666 &&
222 - (
223 - mkdir shared-honor-global &&
224 - cd shared-honor-global &&
225 - git init
226 - ) &&
193 + git init shared-honor-global &&
194 test x0666 = \
195 x`git config -f shared-honor-global/.git/config core.sharedRepository`
196 '
197
198 test_expect_success 'init rejects insanely long --template' '
232 - (
233 - insane=$(printf "x%09999dx" 1) &&
234 - mkdir test &&
235 - cd test &&
236 - test_must_fail git init --template=$insane
237 - )
199 + test_must_fail git init --template=$(printf "x%09999dx" 1) test
200 '
201
202 test_expect_success 'init creates a new directory' '