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