3 test_description
='test git rev-parse'
6 # usage: [options] label is-bare is-inside-git is-inside-work prefix git-dir
14 -C) d
="$2"; shift; shift ;;
16 [tfu
]*) bare
="$2"; shift; shift ;;
17 *) error
"test_rev_parse: bogus core.bare value '$2'" ;;
19 -g) gitdir
="$2"; shift; shift ;;
20 -*) error
"test_rev_parse: unrecognized option '$1'" ;;
28 for o
in --is-bare-repository \
30 --is-inside-work-tree \
34 test $# -eq 0 && break
36 test_expect_success
"$name: $o" '
39 test_when_finished "unset GIT_DIR" &&
45 t*) test_config ${d:+-C} ${d:+"$d"} core.bare true ;;
46 f*) test_config ${d:+-C} ${d:+"$d"} core.bare false ;;
47 u*) test_unconfig ${d:+-C} ${d:+"$d"} core.bare ;;
50 echo "$expect" >expect &&
51 git ${d:+-C} ${d:+"$d"} rev-parse $o >actual &&
52 test_cmp expect actual
60 test_expect_success
'setup' '
61 mkdir -p sub/dir work &&
65 test_rev_parse toplevel false false true
'' .git
67 test_rev_parse
-C .git .git
/ false true false
'' .
68 test_rev_parse
-C .git
/objects .git
/objects
/ false true false
'' "$ROOT/.git"
70 test_rev_parse
-C sub
/dir subdirectory false false true sub
/dir
/ "$ROOT/.git"
72 test_rev_parse
-b t
'core.bare = true' true false false
74 test_rev_parse
-b u
'core.bare undefined' false false true
77 test_rev_parse
-C work
-g ..
/.git
-b f
'GIT_DIR=../.git, core.bare = false' false false true
''
79 test_rev_parse
-C work
-g ..
/.git
-b t
'GIT_DIR=../.git, core.bare = true' true false false
''
81 test_rev_parse
-C work
-g ..
/.git
-b u
'GIT_DIR=../.git, core.bare undefined' false false true
''
84 test_rev_parse
-C work
-g ..
/repo.git
-b f
'GIT_DIR=../repo.git, core.bare = false' false false true
''
86 test_rev_parse
-C work
-g ..
/repo.git
-b t
'GIT_DIR=../repo.git, core.bare = true' true false false
''
88 test_rev_parse
-C work
-g ..
/repo.git
-b u
'GIT_DIR=../repo.git, core.bare undefined' false false true
''