Merge branch 'ep/shell-command-substitution'
[gitweb.git] / t / t0001-init.sh
index 9515da3024ebfee7c3af1d87dcd09a4fe2836dc0..2f3020342a75f0d382af88e6ad35691ad0f183d5 100755 (executable)
@@ -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
 '
 
@@ -85,54 +81,30 @@ test_expect_failure 'plain nested in bare through aliased command' '
 '
 
 test_expect_success 'plain with GIT_WORK_TREE' '
-       if (
-               mkdir plain-wt &&
-               cd plain-wt &&
-               GIT_WORK_TREE=$(pwd) git init
-       )
-       then
-               echo Should have failed -- GIT_WORK_TREE should not be used
-               false
-       fi
+       mkdir plain-wt &&
+       test_must_fail env GIT_WORK_TREE="$(pwd)/plain-wt" git init plain-wt
 '
 
 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
 '
 
 test_expect_success 'plain bare with GIT_WORK_TREE' '
-       if (
-               mkdir plain-bare-2 &&
-               cd plain-bare-2 &&
-               GIT_WORK_TREE=$(pwd) git --bare init
-       )
-       then
-               echo Should have failed -- GIT_WORK_TREE should not be used
-               false
-       fi
+       mkdir plain-bare-2 &&
+       test_must_fail \
+               env GIT_WORK_TREE="$(pwd)/plain-bare-2" \
+               git --bare init plain-bare-2
 '
 
 test_expect_success 'GIT_DIR bare' '
-
-       (
-               mkdir git-dir-bare.git &&
-               GIT_DIR=git-dir-bare.git git init
-       ) &&
+       mkdir git-dir-bare.git &&
+       GIT_DIR=git-dir-bare.git git init &&
        check_config git-dir-bare.git true unset
 '
 
 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
 '
 
@@ -156,15 +128,11 @@ test_expect_success 'GIT_DIR & GIT_WORK_TREE (1)' '
 '
 
 test_expect_success 'GIT_DIR & GIT_WORK_TREE (2)' '
-
-       if (
-               mkdir git-dir-wt-2.git &&
-               GIT_WORK_TREE=$(pwd) GIT_DIR=git-dir-wt-2.git git --bare init
-       )
-       then
-               echo Should have failed -- --bare should not be used
-               false
-       fi
+       mkdir git-dir-wt-2.git &&
+       test_must_fail env \
+               GIT_WORK_TREE="$(pwd)" \
+               GIT_DIR=git-dir-wt-2.git \
+               git --bare init
 '
 
 test_expect_success 'reinit' '
@@ -185,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
 '
 
@@ -226,68 +182,47 @@ 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`
+       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`
+       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' '
        rm -fr newdir &&
-       (
-               git init newdir &&
-               test_path_is_dir newdir/.git/refs
-       )
+       git init newdir &&
+       test_path_is_dir newdir/.git/refs
 '
 
 test_expect_success 'init creates a new bare directory' '
        rm -fr newdir &&
-       (
-               git init --bare newdir &&
-               test_path_is_dir newdir/refs
-       )
+       git init --bare newdir &&
+       test_path_is_dir newdir/refs
 '
 
 test_expect_success 'init recreates a directory' '
        rm -fr newdir &&
-       (
-               mkdir newdir &&
-               git init newdir &&
-               test_path_is_dir newdir/.git/refs
-       )
+       mkdir newdir &&
+       git init newdir &&
+       test_path_is_dir newdir/.git/refs
 '
 
 test_expect_success 'init recreates a new bare directory' '
        rm -fr newdir &&
-       (
-               mkdir newdir &&
-               git init --bare newdir &&
-               test_path_is_dir newdir/refs
-       )
+       mkdir newdir &&
+       git init --bare newdir &&
+       test_path_is_dir newdir/refs
 '
 
 test_expect_success 'init creates a new deep directory' '
@@ -313,30 +248,24 @@ test_expect_success POSIXPERM 'init creates a new deep directory (umask vs. shar
 
 test_expect_success 'init notices EEXIST (1)' '
        rm -fr newdir &&
-       (
-               >newdir &&
-               test_must_fail git init newdir &&
-               test_path_is_file newdir
-       )
+       >newdir &&
+       test_must_fail git init newdir &&
+       test_path_is_file newdir
 '
 
 test_expect_success 'init notices EEXIST (2)' '
        rm -fr newdir &&
-       (
-               mkdir newdir &&
-               >newdir/a
-               test_must_fail git init newdir/a/b &&
-               test_path_is_file newdir/a
-       )
+       mkdir newdir &&
+       >newdir/a &&
+       test_must_fail git init newdir/a/b &&
+       test_path_is_file newdir/a
 '
 
 test_expect_success POSIXPERM,SANITY 'init notices EPERM' '
        rm -fr newdir &&
-       (
-               mkdir newdir &&
-               chmod -w newdir &&
-               test_must_fail git init newdir/a/b
-       )
+       mkdir newdir &&
+       chmod -w newdir &&
+       test_must_fail git init newdir/a/b
 '
 
 test_expect_success 'init creates a new bare directory with global --bare' '
@@ -356,7 +285,7 @@ test_expect_success 'init prefers command line to GIT_DIR' '
 test_expect_success 'init with separate gitdir' '
        rm -rf newdir &&
        git init --separate-git-dir realgitdir newdir &&
-       echo "gitdir: `pwd`/realgitdir" >expected &&
+       echo "gitdir: $(pwd)/realgitdir" >expected &&
        test_cmp expected newdir/.git &&
        test_path_is_dir realgitdir/refs
 '
@@ -370,7 +299,7 @@ test_expect_success 're-init to update git link' '
        cd newdir &&
        git init --separate-git-dir ../surrealgitdir
        ) &&
-       echo "gitdir: `pwd`/surrealgitdir" >expected &&
+       echo "gitdir: $(pwd)/surrealgitdir" >expected &&
        test_cmp expected newdir/.git &&
        test_path_is_dir surrealgitdir/refs &&
        test_path_is_missing realgitdir/refs
@@ -383,7 +312,7 @@ test_expect_success 're-init to move gitdir' '
        cd newdir &&
        git init --separate-git-dir ../realgitdir
        ) &&
-       echo "gitdir: `pwd`/realgitdir" >expected &&
+       echo "gitdir: $(pwd)/realgitdir" >expected &&
        test_cmp expected newdir/.git &&
        test_path_is_dir realgitdir/refs
 '
@@ -397,7 +326,7 @@ test_expect_success SYMLINKS 're-init to move gitdir symlink' '
        ln -s here .git &&
        git init --separate-git-dir ../realgitdir
        ) &&
-       echo "gitdir: `pwd`/realgitdir" >expected &&
+       echo "gitdir: $(pwd)/realgitdir" >expected &&
        test_cmp expected newdir/.git &&
        test_cmp expected newdir/here &&
        test_path_is_dir realgitdir/refs