3 test_description='git init'
8 if test -d "$1" && test -f "$1/config" && test -d "$1/refs"
12 echo "expected a directory $1, a file $1/config and $1/refs"
15 bare=$(GIT_CONFIG="$1/config" git config --bool core.bare)
16 worktree=$(GIT_CONFIG="$1/config" git config core.worktree) ||
19 test "$bare" = "$2" && test "$worktree" = "$3" || {
20 echo "expected bare=$2 worktree=$3"
21 echo " got bare=$bare worktree=$worktree"
26 test_expect_success 'plain' '
28 unset GIT_DIR GIT_WORK_TREE &&
33 check_config plain/.git false unset
36 test_expect_success 'plain with GIT_WORK_TREE' '
41 GIT_WORK_TREE=$(pwd) git init
44 echo Should have failed -- GIT_WORK_TREE should not be used
49 test_expect_success 'plain bare' '
51 unset GIT_DIR GIT_WORK_TREE GIT_CONFIG &&
56 check_config plain-bare-1 true unset
59 test_expect_success 'plain bare with GIT_WORK_TREE' '
61 unset GIT_DIR GIT_CONFIG &&
64 GIT_WORK_TREE=$(pwd) git --bare init
67 echo Should have failed -- GIT_WORK_TREE should not be used
72 test_expect_success 'GIT_DIR bare' '
76 mkdir git-dir-bare.git &&
77 GIT_DIR=git-dir-bare.git git init
79 check_config git-dir-bare.git true unset
82 test_expect_success 'GIT_DIR non-bare' '
90 check_config non-bare/.git false unset
93 test_expect_success 'GIT_DIR & GIT_WORK_TREE (1)' '
97 mkdir git-dir-wt-1.git &&
98 GIT_WORK_TREE=$(pwd) GIT_DIR=git-dir-wt-1.git git init
100 check_config git-dir-wt-1.git false "$(pwd)"
103 test_expect_success 'GIT_DIR & GIT_WORK_TREE (2)' '
107 mkdir git-dir-wt-2.git &&
108 GIT_WORK_TREE=$(pwd) GIT_DIR=git-dir-wt-2.git git --bare init
111 echo Should have failed -- --bare should not be used