Skip to content

Commit

Permalink
t0001: drop subshells just for "cd"
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
peff authored and gitster committed Mar 21, 2014
1 parent 99e1c73 commit 410c342
Showing 1 changed file with 9 additions and 47 deletions.
56 changes: 9 additions & 47 deletions t/t0001-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@ check_config () {
}

test_expect_success 'plain' '
(
mkdir plain &&
cd plain &&
git init
) &&
git init plain &&
check_config plain/.git false unset
'

Expand Down Expand Up @@ -90,11 +86,7 @@ test_expect_success 'plain with GIT_WORK_TREE' '
'

test_expect_success 'plain bare' '
(
mkdir plain-bare-1 &&
cd plain-bare-1 &&
git --bare init
) &&
git --bare init plain-bare-1 &&
check_config plain-bare-1 true unset
'

Expand All @@ -112,12 +104,7 @@ test_expect_success 'GIT_DIR bare' '
'

test_expect_success 'init --bare' '
(
mkdir init-bare.git &&
cd init-bare.git &&
git init --bare
) &&
git init --bare init-bare.git &&
check_config init-bare.git true unset
'

Expand Down Expand Up @@ -166,26 +153,14 @@ test_expect_success 'reinit' '
test_expect_success 'init with --template' '
mkdir template-source &&
echo content >template-source/file &&
(
mkdir template-custom &&
cd template-custom &&
git init --template=../template-source
) &&
git init --template=../template-source template-custom &&
test_cmp template-source/file template-custom/.git/file
'

test_expect_success 'init with --template (blank)' '
(
mkdir template-plain &&
cd template-plain &&
git init
) &&
git init template-plain &&
test_path_is_file template-plain/.git/info/exclude &&
(
mkdir template-blank &&
cd template-blank &&
git init --template=
) &&
git init --template= template-blank &&
test_path_is_missing template-blank/.git/info/exclude
'

Expand All @@ -207,34 +182,21 @@ test_expect_success 'init with init.templatedir set' '
test_expect_success 'init --bare/--shared overrides system/global config' '
test_config_global core.bare false &&
test_config_global core.sharedRepository 0640 &&
(
mkdir init-bare-shared-override &&
cd init-bare-shared-override &&
git init --bare --shared=0666
) &&
git init --bare --shared=0666 init-bare-shared-override &&
check_config init-bare-shared-override true unset &&
test x0666 = \
x`git config -f init-bare-shared-override/config core.sharedRepository`
'

test_expect_success 'init honors global core.sharedRepository' '
test_config_global core.sharedRepository 0666 &&
(
mkdir shared-honor-global &&
cd shared-honor-global &&
git init
) &&
git init shared-honor-global &&
test x0666 = \
x`git config -f shared-honor-global/.git/config core.sharedRepository`
'

test_expect_success 'init rejects insanely long --template' '
(
insane=$(printf "x%09999dx" 1) &&
mkdir test &&
cd test &&
test_must_fail git init --template=$insane
)
test_must_fail git init --template=$(printf "x%09999dx" 1) test
'

test_expect_success 'init creates a new directory' '
Expand Down

0 comments on commit 410c342

Please sign in to comment.