revision: fix leaking parents when simplifying commits
[git/gitster.git] / t / t1517-outside-repo.sh
blob990a03658214a4cd2c5fa742346f9d939c92a254
1 #!/bin/sh
3 test_description='check random commands outside repo'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 test_expect_success 'set up a non-repo directory and test file' '
9 GIT_CEILING_DIRECTORIES=$(pwd) &&
10 export GIT_CEILING_DIRECTORIES &&
11 mkdir non-repo &&
13 cd non-repo &&
14 # confirm that git does not find a repo
15 test_must_fail git rev-parse --git-dir
16 ) &&
17 test_write_lines one two three four >nums &&
18 git add nums &&
19 cp nums nums.old &&
20 test_write_lines five >>nums &&
21 git diff >sample.patch
24 test_expect_success 'compute a patch-id outside repository (uses SHA-1)' '
25 nongit env GIT_DEFAULT_HASH=sha1 \
26 git patch-id <sample.patch >patch-id.expect &&
27 nongit \
28 git patch-id <sample.patch >patch-id.actual &&
29 test_cmp patch-id.expect patch-id.actual
32 test_expect_success 'hash-object outside repository (uses SHA-1)' '
33 nongit env GIT_DEFAULT_HASH=sha1 \
34 git hash-object --stdin <sample.patch >hash.expect &&
35 nongit \
36 git hash-object --stdin <sample.patch >hash.actual &&
37 test_cmp hash.expect hash.actual
40 test_expect_success 'apply a patch outside repository' '
42 cd non-repo &&
43 cp ../nums.old nums &&
44 git apply ../sample.patch
45 ) &&
46 test_cmp nums non-repo/nums
49 test_expect_success 'grep outside repository' '
50 git grep --cached two >expect &&
52 cd non-repo &&
53 cp ../nums.old nums &&
54 git grep --no-index two >../actual
55 ) &&
56 test_cmp expect actual
59 test_expect_success 'imap-send outside repository' '
60 test_config_global imap.host imaps://localhost &&
61 test_config_global imap.folder Drafts &&
63 echo nothing to send >expect &&
64 test_must_fail git imap-send -v </dev/null 2>actual &&
65 test_cmp expect actual &&
68 cd non-repo &&
69 test_must_fail git imap-send -v </dev/null 2>../actual
70 ) &&
71 test_cmp expect actual
74 test_expect_success 'check-ref-format outside repository' '
75 git check-ref-format --branch refs/heads/xyzzy >expect &&
76 nongit git check-ref-format --branch refs/heads/xyzzy >actual &&
77 test_cmp expect actual
80 test_expect_success 'diff outside repository' '
81 echo one >one &&
82 echo two >two &&
83 test_must_fail git diff --no-index one two >expect.raw &&
85 cd non-repo &&
86 cp ../one . &&
87 cp ../two . &&
88 test_must_fail git diff one two >../actual.raw
89 ) &&
90 # outside repository diff falls back to SHA-1 but
91 # GIT_DEFAULT_HASH may be set to sha256 on the in-repo side.
92 sed -e "/^index /d" expect.raw >expect &&
93 sed -e "/^index /d" actual.raw >actual &&
94 test_cmp expect actual
97 test_expect_success 'stripspace outside repository' '
98 nongit git stripspace -s </dev/null
101 test_expect_success 'remote-http outside repository' '
102 test_must_fail git remote-http 2>actual &&
103 test_grep "^error: remote-curl" actual &&
105 cd non-repo &&
106 test_must_fail git remote-http 2>../actual
107 ) &&
108 test_grep "^error: remote-curl" actual
111 test_done