3 test_description
='test git rev-parse'
6 # usage: [options] label is-bare is-inside-git is-inside-work prefix git-dir
13 -C) d
="$2"; shift; shift ;;
15 [tfu
]*) bare
="$2"; shift; shift ;;
16 *) error
"test_rev_parse: bogus core.bare value '$2'" ;;
18 -*) error
"test_rev_parse: unrecognized option '$1'" ;;
26 for o
in --is-bare-repository \
28 --is-inside-work-tree \
32 test $# -eq 0 && break
34 test_expect_success
"$name: $o" '
36 t*) test_config ${d:+-C} ${d:+"$d"} core.bare true ;;
37 f*) test_config ${d:+-C} ${d:+"$d"} core.bare false ;;
38 u*) test_unconfig ${d:+-C} ${d:+"$d"} core.bare ;;
41 echo "$expect" >expect &&
42 git ${d:+-C} ${d:+"$d"} rev-parse $o >actual &&
43 test_cmp expect actual
51 test_expect_success
'setup' '
52 mkdir -p sub/dir work &&
56 test_rev_parse toplevel false false true
'' .git
58 test_rev_parse
-C .git .git
/ false true false
'' .
59 test_rev_parse
-C .git
/objects .git
/objects
/ false true false
'' "$ROOT/.git"
61 test_rev_parse
-C sub
/dir subdirectory false false true sub
/dir
/ "$ROOT/.git"
63 test_rev_parse
-b t
'core.bare = true' true false false
65 test_rev_parse
-b u
'core.bare undefined' false false true
70 test_rev_parse
-C work
-b f
'GIT_DIR=../.git, core.bare = false' false false true
''
72 test_rev_parse
-C work
-b t
'GIT_DIR=../.git, core.bare = true' true false false
''
74 test_rev_parse
-C work
-b u
'GIT_DIR=../.git, core.bare undefined' false false true
''
78 test_rev_parse
-C work
-b f
'GIT_DIR=../repo.git, core.bare = false' false false true
''
80 test_rev_parse
-C work
-b t
'GIT_DIR=../repo.git, core.bare = true' true false false
''
82 test_rev_parse
-C work
-b u
'GIT_DIR=../repo.git, core.bare undefined' false false true
''