]>
Commit | Line | Data |
---|---|---|
a4e21fb4 JK |
1 | #!/bin/sh |
2 | ||
3 | test_description='check that certain rev-parse options work outside repo' | |
f442c946 ÆAB |
4 | |
5 | TEST_PASSES_SANITIZE_LEAK=true | |
a4e21fb4 JK |
6 | . ./test-lib.sh |
7 | ||
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 | |
15 | ' | |
16 | ||
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 | |
25 | } | |
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 | |
30 | ' | |
31 | ||
fc7d47f0 | 32 | test_expect_success 'rev-parse --local-env-vars' ' |
a4e21fb4 JK |
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 | |
37 | ' | |
38 | ||
fc7d47f0 | 39 | test_expect_success 'rev-parse --resolve-git-dir' ' |
a4e21fb4 JK |
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 | |
45 | ' | |
46 | ||
47 | test_done |