summaryrefslogtreecommitdiff
path: root/t/t5547-push-quarantine.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2016-10-17 20:25:20 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-10-17 20:25:20 (GMT)
commit25ab004c53cdcfea485e5bf437aeaa74df47196d (patch)
tree3d697166144f66978d47bbd2d50c00d385fc4c36 /t/t5547-push-quarantine.sh
parentdec040192fde87fb3249a3d53f802decd84fa7b7 (diff)
parent62fe0eb4804c297486a1d421a4f893865fcbc911 (diff)
downloadgit-25ab004c53cdcfea485e5bf437aeaa74df47196d.zip
git-25ab004c53cdcfea485e5bf437aeaa74df47196d.tar.gz
git-25ab004c53cdcfea485e5bf437aeaa74df47196d.tar.bz2
Merge branch 'jk/quarantine-received-objects'
In order for the receiving end of "git push" to inspect the received history and decide to reject the push, the objects sent from the sending end need to be made available to the hook and the mechanism for the connectivity check, and this was done traditionally by storing the objects in the receiving repository and letting "git gc" to expire it. Instead, store the newly received objects in a temporary area, and make them available by reusing the alternate object store mechanism to them only while we decide if we accept the check, and once we decide, either migrate them to the repository or purge them immediately. * jk/quarantine-received-objects: tmp-objdir: do not migrate files starting with '.' tmp-objdir: put quarantine information in the environment receive-pack: quarantine objects until pre-receive accepts tmp-objdir: introduce API for temporary object directories check_connected: accept an env argument
Diffstat (limited to 't/t5547-push-quarantine.sh')
-rwxr-xr-xt/t5547-push-quarantine.sh36
1 files changed, 36 insertions, 0 deletions
diff --git a/t/t5547-push-quarantine.sh b/t/t5547-push-quarantine.sh
new file mode 100755
index 0000000..1e5d32d
--- /dev/null
+++ b/t/t5547-push-quarantine.sh
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+test_description='check quarantine of objects during push'
+. ./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