Merge branch 'jk/repack-leakfix'
[git.git] / t / t5547-push-quarantine.sh
blob9f899b8c7d7bcc63ba5fe97c513748eeba436edb
1 #!/bin/sh
3 test_description='check quarantine of objects during push'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 test_expect_success 'create picky dest repo' '
9 git init --bare dest.git &&
10 test_hook --setup -C dest.git pre-receive <<-\EOF
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
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
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
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
38 test_expect_success 'push to repo path with path separator (colon)' '
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.
44 test-tool genrandom foo 4096 >file.bin &&
45 git add file.bin &&
46 git commit -m bin &&
48 if test_have_prereq MINGW
49 then
50 pathsep=";"
51 else
52 pathsep=":"
53 fi &&
54 git clone --bare . "xxx${pathsep}yyy.git" &&
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.
60 git push "$(pwd)/xxx${pathsep}yyy.git" HEAD
63 test_expect_success 'updating a ref from quarantine is forbidden' '
64 git init --bare update.git &&
65 test_hook -C update.git pre-receive <<-\EOF &&
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
74 test_done