Skip to content

Commit 410c342

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 99e1c73 commit 410c342

File tree

1 file changed

+9
-47
lines changed

1 file changed

+9
-47
lines changed

t/t0001-init.sh

Lines changed: 9 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,7 @@ check_config () {
2424
}
2525

2626
test_expect_success 'plain' '
27-
(
28-
mkdir plain &&
29-
cd plain &&
30-
git init
31-
) &&
27+
git init plain &&
3228
check_config plain/.git false unset
3329
'
3430

@@ -90,11 +86,7 @@ test_expect_success 'plain with GIT_WORK_TREE' '
9086
'
9187

9288
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 &&
9890
check_config plain-bare-1 true unset
9991
'
10092

@@ -112,12 +104,7 @@ test_expect_success 'GIT_DIR bare' '
112104
'
113105

114106
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 &&
121108
check_config init-bare.git true unset
122109
'
123110

@@ -166,26 +153,14 @@ test_expect_success 'reinit' '
166153
test_expect_success 'init with --template' '
167154
mkdir template-source &&
168155
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 &&
174157
test_cmp template-source/file template-custom/.git/file
175158
'
176159

177160
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 &&
183162
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 &&
189164
test_path_is_missing template-blank/.git/info/exclude
190165
'
191166

@@ -207,34 +182,21 @@ test_expect_success 'init with init.templatedir set' '
207182
test_expect_success 'init --bare/--shared overrides system/global config' '
208183
test_config_global core.bare false &&
209184
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 &&
215186
check_config init-bare-shared-override true unset &&
216187
test x0666 = \
217188
x`git config -f init-bare-shared-override/config core.sharedRepository`
218189
'
219190

220191
test_expect_success 'init honors global core.sharedRepository' '
221192
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 &&
227194
test x0666 = \
228195
x`git config -f shared-honor-global/.git/config core.sharedRepository`
229196
'
230197

231198
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
238200
'
239201

240202
test_expect_success 'init creates a new directory' '

0 commit comments

Comments
 (0)