]> git.ipfire.org Git - thirdparty/git.git/blame - t/t1515-rev-parse-outside-repo.sh
The third batch
[thirdparty/git.git] / t / t1515-rev-parse-outside-repo.sh
CommitLineData
a4e21fb4
JK
1#!/bin/sh
2
3test_description='check that certain rev-parse options work outside repo'
f442c946
ÆAB
4
5TEST_PASSES_SANITIZE_LEAK=true
a4e21fb4
JK
6. ./test-lib.sh
7
8test_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.
20tricky="really tricky with \\ and \" and '"
21dump_args () {
22 for i in "$@"; do
23 echo "arg: $i"
24 done
25}
26test_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 32test_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 39test_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
47test_done