gitweb: Simplify 'opt' parameter validation, add "no merges" feeds
[git/jnareb-git.git] / t / t1500-rev-parse.sh
blobec4996637d3f9f26e8d8dd6fd41f1cc9c66d893b
1 #!/bin/sh
3 test_description='test git rev-parse'
4 . ./test-lib.sh
6 test_rev_parse() {
7 name=$1
8 shift
10 test_expect_success "$name: is-bare-repository" \
11 "test '$1' = \"\$(git rev-parse --is-bare-repository)\""
12 shift
13 [ $# -eq 0 ] && return
15 test_expect_success "$name: is-inside-git-dir" \
16 "test '$1' = \"\$(git rev-parse --is-inside-git-dir)\""
17 shift
18 [ $# -eq 0 ] && return
20 test_expect_success "$name: is-inside-work-tree" \
21 "test '$1' = \"\$(git rev-parse --is-inside-work-tree)\""
22 shift
23 [ $# -eq 0 ] && return
25 test_expect_success "$name: prefix" \
26 "test '$1' = \"\$(git rev-parse --show-prefix)\""
27 shift
28 [ $# -eq 0 ] && return
31 test_rev_parse toplevel false false true ''
33 cd .git || exit 1
34 test_rev_parse .git/ false true true .git/
35 cd objects || exit 1
36 test_rev_parse .git/objects/ false true true .git/objects/
37 cd ../.. || exit 1
39 mkdir -p sub/dir || exit 1
40 cd sub/dir || exit 1
41 test_rev_parse subdirectory false false true sub/dir/
42 cd ../.. || exit 1
44 git config core.bare true
45 test_rev_parse 'core.bare = true' true false true
47 git config --unset core.bare
48 test_rev_parse 'core.bare undefined' false false true
50 mkdir work || exit 1
51 cd work || exit 1
52 export GIT_DIR=../.git
53 export GIT_CONFIG="$GIT_DIR"/config
55 git config core.bare false
56 test_rev_parse 'GIT_DIR=../.git, core.bare = false' false false true ''
58 git config core.bare true
59 test_rev_parse 'GIT_DIR=../.git, core.bare = true' true false true ''
61 git config --unset core.bare
62 test_rev_parse 'GIT_DIR=../.git, core.bare undefined' false false true ''
64 mv ../.git ../repo.git || exit 1
65 export GIT_DIR=../repo.git
66 export GIT_CONFIG="$GIT_DIR"/config
68 git config core.bare false
69 test_rev_parse 'GIT_DIR=../repo.git, core.bare = false' false false true ''
71 git config core.bare true
72 test_rev_parse 'GIT_DIR=../repo.git, core.bare = true' true false true ''
74 git config --unset core.bare
75 test_rev_parse 'GIT_DIR=../repo.git, core.bare undefined' true false true ''
77 test_done