3 test_description='test git rev-parse'
10 test_expect_success "$name: is-bare-repository" \
11 "test '$1' = \"\$(git rev-parse --is-bare-repository)\""
13 [ $# -eq 0 ] && return
15 test_expect_success "$name: is-inside-git-dir" \
16 "test '$1' = \"\$(git rev-parse --is-inside-git-dir)\""
18 [ $# -eq 0 ] && return
20 test_expect_success "$name: is-inside-work-tree" \
21 "test '$1' = \"\$(git rev-parse --is-inside-work-tree)\""
23 [ $# -eq 0 ] && return
25 test_expect_success "$name: prefix" \
26 "test '$1' = \"\$(git rev-parse --show-prefix)\""
28 [ $# -eq 0 ] && return
31 # label is-bare is-inside-git is-inside-work prefix
33 test_rev_parse toplevel false false true ''
36 test_rev_parse .git/ false true false ''
38 test_rev_parse .git/objects/ false true false ''
41 mkdir -p sub/dir || exit 1
43 test_rev_parse subdirectory false false true sub/dir/
46 git config core.bare true
47 test_rev_parse 'core.bare = true' true false false
49 git config --unset core.bare
50 test_rev_parse 'core.bare undefined' false false true
55 GIT_CONFIG="$(pwd)"/../.git/config
56 export GIT_DIR GIT_CONFIG
58 git config core.bare false
59 test_rev_parse 'GIT_DIR=../.git, core.bare = false' false false true ''
61 git config core.bare true
62 test_rev_parse 'GIT_DIR=../.git, core.bare = true' true false false ''
64 git config --unset core.bare
65 test_rev_parse 'GIT_DIR=../.git, core.bare undefined' false false true ''
67 mv ../.git ../repo.git || exit 1
69 GIT_CONFIG="$(pwd)"/../repo.git/config
71 git config core.bare false
72 test_rev_parse 'GIT_DIR=../repo.git, core.bare = false' false false true ''
74 git config core.bare true
75 test_rev_parse 'GIT_DIR=../repo.git, core.bare = true' true false false ''
77 git config --unset core.bare
78 test_rev_parse 'GIT_DIR=../repo.git, core.bare undefined' false false true ''