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