]>
Commit | Line | Data |
---|---|---|
722ff7f8 JK |
1 | #!/bin/sh |
2 | ||
3 | test_description='check quarantine of objects during push' | |
c65d18cb ÆAB |
4 | |
5 | TEST_PASSES_SANITIZE_LEAK=true | |
722ff7f8 JK |
6 | . ./test-lib.sh |
7 | ||
8 | test_expect_success 'create picky dest repo' ' | |
9 | git init --bare dest.git && | |
7da7f63c | 10 | test_hook --setup -C dest.git pre-receive <<-\EOF |
722ff7f8 JK |
11 | while read old new ref; do |
12 | test "$(git log -1 --format=%s $new)" = reject && exit 1 | |
13 | done | |
14 | exit 0 | |
15 | EOF | |
16 | ' | |
17 | ||
18 | test_expect_success 'accepted objects work' ' | |
19 | test_commit ok && | |
20 | git push dest.git HEAD && | |
21 | commit=$(git rev-parse HEAD) && | |
22 | git --git-dir=dest.git cat-file commit $commit | |
23 | ' | |
24 | ||
25 | test_expect_success 'rejected objects are not installed' ' | |
26 | test_commit reject && | |
27 | commit=$(git rev-parse HEAD) && | |
28 | test_must_fail git push dest.git reject && | |
29 | test_must_fail git --git-dir=dest.git cat-file commit $commit | |
30 | ' | |
31 | ||
32 | test_expect_success 'rejected objects are removed' ' | |
33 | echo "incoming-*" >expect && | |
34 | (cd dest.git/objects && echo incoming-*) >actual && | |
35 | test_cmp expect actual | |
36 | ' | |
37 | ||
eaa76de0 | 38 | test_expect_success 'push to repo path with path separator (colon)' ' |
aae2ae4f JK |
39 | # The interesting failure case here is when the |
40 | # receiving end cannot access its original object directory, | |
41 | # so make it likely for us to generate a delta by having | |
42 | # a non-trivial file with multiple versions. | |
43 | ||
c680668d | 44 | test-tool genrandom foo 4096 >file.bin && |
aae2ae4f JK |
45 | git add file.bin && |
46 | git commit -m bin && | |
eaa76de0 JS |
47 | |
48 | if test_have_prereq MINGW | |
49 | then | |
50 | pathsep=";" | |
51 | else | |
52 | pathsep=":" | |
53 | fi && | |
54 | git clone --bare . "xxx${pathsep}yyy.git" && | |
aae2ae4f JK |
55 | |
56 | echo change >>file.bin && | |
57 | git commit -am change && | |
58 | # Note that we have to use the full path here, or it gets confused | |
59 | # with the ssh host:path syntax. | |
eaa76de0 | 60 | git push "$(pwd)/xxx${pathsep}yyy.git" HEAD |
aae2ae4f JK |
61 | ' |
62 | ||
d8f4481c JK |
63 | test_expect_success 'updating a ref from quarantine is forbidden' ' |
64 | git init --bare update.git && | |
7da7f63c | 65 | test_hook -C update.git pre-receive <<-\EOF && |
d8f4481c JK |
66 | read old new refname |
67 | git update-ref refs/heads/unrelated $new | |
68 | exit 1 | |
69 | EOF | |
70 | test_must_fail git push update.git HEAD && | |
71 | git -C update.git fsck | |
72 | ' | |
73 | ||
722ff7f8 | 74 | test_done |