Use the available vsnprintf replacement instead of rolling our own.
[git/platforms/storm.git] / t / t1500-rev-parse.sh
blob38a2bf09af286bf681deadb9cdaec80175d13e0c
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 # label is-bare is-inside-git is-inside-work prefix
33 test_rev_parse toplevel false false true ''
35 cd .git || exit 1
36 test_rev_parse .git/ false true false ''
37 cd objects || exit 1
38 test_rev_parse .git/objects/ false true false ''
39 cd ../.. || exit 1
41 mkdir -p sub/dir || exit 1
42 cd sub/dir || exit 1
43 test_rev_parse subdirectory false false true sub/dir/
44 cd ../.. || exit 1
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
52 mkdir work || exit 1
53 cd work || exit 1
54 export GIT_DIR=../.git
55 export GIT_CONFIG="$(pwd)"/../.git/config
57 git config core.bare false
58 test_rev_parse 'GIT_DIR=../.git, core.bare = false' false false true ''
60 git config core.bare true
61 test_rev_parse 'GIT_DIR=../.git, core.bare = true' true false false ''
63 git config --unset core.bare
64 test_rev_parse 'GIT_DIR=../.git, core.bare undefined' false false true ''
66 mv ../.git ../repo.git || exit 1
67 export GIT_DIR=../repo.git
68 export GIT_CONFIG="$(pwd)"/../repo.git/config
70 git config core.bare false
71 test_rev_parse 'GIT_DIR=../repo.git, core.bare = false' false false true ''
73 git config core.bare true
74 test_rev_parse 'GIT_DIR=../repo.git, core.bare = true' true false false ''
76 git config --unset core.bare
77 test_rev_parse 'GIT_DIR=../repo.git, core.bare undefined' false false true ''
79 test_done