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