#!/bin/sh global test_description := ''check quarantine of objects during push'' source ./test-lib.sh test_expect_success 'create picky dest repo' ' git init --bare dest.git && write_script dest.git/hooks/pre-receive <<-\EOF while read old new ref; do test "$(git log -1 --format=%s $new)" = reject && exit 1 done exit 0 EOF ' test_expect_success 'accepted objects work' ' test_commit ok && git push dest.git HEAD && commit=$(git rev-parse HEAD) && git --git-dir=dest.git cat-file commit $commit ' test_expect_success 'rejected objects are not installed' ' test_commit reject && commit=$(git rev-parse HEAD) && test_must_fail git push dest.git reject && test_must_fail git --git-dir=dest.git cat-file commit $commit ' test_expect_success 'rejected objects are removed' ' echo "incoming-*" >expect && (cd dest.git/objects && echo incoming-*) >actual && test_cmp expect actual ' test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"check quarantine of objects during push">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (C {(test_expect_success)} {(SQ <"create picky dest repo">)} { (SQ <"\n"> <"\tgit init --bare dest.git &&\n"> <"\twrite_script dest.git/hooks/pre-receive <<-\\EOF\n"> <"\twhile read old new ref; do\n"> <"\t\ttest \"$(git log -1 --format=%s $new)\" = reject && exit 1\n"> <"\tdone\n"> <"\texit 0\n"> <"\tEOF\n"> ) } ) (C {(test_expect_success)} {(SQ <"accepted objects work">)} { (SQ <"\n"> <"\ttest_commit ok &&\n"> <"\tgit push dest.git HEAD &&\n"> <"\tcommit=$(git rev-parse HEAD) &&\n"> <"\tgit --git-dir=dest.git cat-file commit $commit\n"> ) } ) (C {(test_expect_success)} {(SQ <"rejected objects are not installed">)} { (SQ <"\n"> <"\ttest_commit reject &&\n"> <"\tcommit=$(git rev-parse HEAD) &&\n"> <"\ttest_must_fail git push dest.git reject &&\n"> <"\ttest_must_fail git --git-dir=dest.git cat-file commit $commit\n"> ) } ) (C {(test_expect_success)} {(SQ <"rejected objects are removed">)} { (SQ <"\n"> <"\techo \"incoming-*\" >expect &&\n"> <"\t(cd dest.git/objects && echo incoming-*) >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_done)}) ] )