Skip to content

Commit abece6e

Browse files
committed
t1517: test commands that are designed to be run outside repository
A few commands, like "git apply" and "git patch-id", have been broken with a recent change to stop setting the default hash algorithm to SHA-1. Test them and fix them in later commits. Signed-off-by: Junio C Hamano <[email protected]>
1 parent d3b2ff7 commit abece6e

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

t/t1517-outside-repo.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/sh
2+
3+
test_description='check random commands outside repo'
4+
5+
TEST_PASSES_SANITIZE_LEAK=true
6+
. ./test-lib.sh
7+
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 &&
12+
(
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
22+
'
23+
24+
test_expect_failure '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
30+
'
31+
32+
test_expect_failure '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
38+
'
39+
40+
test_expect_failure 'apply a patch outside repository' '
41+
(
42+
cd non-repo &&
43+
cp ../nums.old nums &&
44+
git apply ../sample.patch
45+
) &&
46+
test_cmp nums non-repo/nums
47+
'
48+
49+
test_expect_success 'grep outside repository' '
50+
git grep --cached two >expect &&
51+
(
52+
cd non-repo &&
53+
cp ../nums.old nums &&
54+
git grep --no-index two >../actual
55+
) &&
56+
test_cmp expect actual
57+
'
58+
59+
test_done

0 commit comments

Comments
 (0)