Raw
1 #!/bin/sh
2
3 test_description='check that certain rev-parse options work outside repo'
4
5 . ./test-lib.sh
6
7 test_expect_success 'set up non-repo directory' '
8 GIT_CEILING_DIRECTORIES=$(pwd) &&
9 export GIT_CEILING_DIRECTORIES &&
10 mkdir non-repo &&
11 cd non-repo &&
12 # confirm that git does not find a repo
13 test_must_fail git rev-parse --git-dir
14 '
15
16 # Rather than directly test the output of sq-quote directly,
17 # make sure the shell can read back a tricky case, since
18 # that's what we really care about anyway.
19 tricky="really tricky with \\ and \" and '"
20 dump_args () {
21 for i in "$@"; do
22 echo "arg: $i"
23 done
24 }
25 test_expect_success 'rev-parse --sq-quote' '
26 dump_args "$tricky" easy >expect &&
27 eval "dump_args $(git rev-parse --sq-quote "$tricky" easy)" >actual &&
28 test_cmp expect actual
29 '
30
31 test_expect_success 'rev-parse --local-env-vars' '
32 git rev-parse --local-env-vars >actual &&
33 # we do not want to depend on the complete list here,
34 # so just look for something plausible
35 grep ^GIT_DIR actual
36 '
37
38 test_expect_success 'rev-parse --resolve-git-dir' '
39 git init --separate-git-dir repo dir &&
40 test_must_fail git rev-parse --resolve-git-dir . &&
41 echo "$(pwd)/repo" >expect &&
42 git rev-parse --resolve-git-dir dir/.git >actual &&
43 test_cmp expect actual
44 '
45
46 test_done