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