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
30 test_expect_success
"$name: git-dir" \
31 "test '$1' = \"\$(git rev-parse --git-dir)\""
33 [ $# -eq 0 ] && return
36 # label is-bare is-inside-git is-inside-work prefix git-dir
40 test_rev_parse toplevel false false true
'' .git
43 test_rev_parse .git
/ false true false
'' .
45 test_rev_parse .git
/objects
/ false true false
'' "$ROOT/.git"
48 mkdir
-p sub
/dir ||
exit 1
50 test_rev_parse subdirectory false false true sub
/dir
/ "$ROOT/.git"
53 git config core.bare true
54 test_rev_parse
'core.bare = true' true false false
56 git config
--unset core.bare
57 test_rev_parse
'core.bare undefined' false false true
62 GIT_CONFIG
="$(pwd)"/..
/.git
/config
63 export GIT_DIR GIT_CONFIG
65 git config core.bare false
66 test_rev_parse
'GIT_DIR=../.git, core.bare = false' false false true
''
68 git config core.bare true
69 test_rev_parse
'GIT_DIR=../.git, core.bare = true' true false false
''
71 git config
--unset core.bare
72 test_rev_parse
'GIT_DIR=../.git, core.bare undefined' false false true
''
74 mv ..
/.git ..
/repo.git ||
exit 1
76 GIT_CONFIG
="$(pwd)"/..
/repo.git
/config
78 git config core.bare false
79 test_rev_parse
'GIT_DIR=../repo.git, core.bare = false' false false true
''
81 git config core.bare true
82 test_rev_parse
'GIT_DIR=../repo.git, core.bare = true' true false false
''
84 git config
--unset core.bare
85 test_rev_parse
'GIT_DIR=../repo.git, core.bare undefined' false false true
''