{"thread":{"id":"6172","subject":"[PATCH] Add test case for update hooks in receive-pack.","startedAt":"2006-12-31T07:20:23Z","lastAt":"2006-12-31T07:20:23Z","messageCount":1,"participants":["Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"30567","messageId":"20061231072023.GA6479@spearce.org","threadId":"6172","inReplyTo":null,"subject":"[PATCH] Add test case for update hooks in receive-pack.","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2006-12-31T07:20:23Z","receivedAt":"2006-12-31T07:20:23Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Verify that the update hooks work as documented/advertised.  This is\na simple set of tests to check that the update hooks run with the\nparameters expected, have their STDOUT and STDERR redirected to\nthe client side of the connection, and that their STDIN does not\ncontain any data (as its actually /dev/null).\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n\n On top of my previous series of patches for receive-pack.  This test\n fails unless those patches are applied.  ;-)\n\n t/t5401-update-hooks.sh |   77 +++++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 77 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t5401-update-hooks.sh b/t/t5401-update-hooks.sh\nnew file mode 100755\nindex 0000000..8a879f7\n--- /dev/null\n+++ b/t/t5401-update-hooks.sh\n@@ -0,0 +1,77 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2006 Shawn O. Pearce\n+#\n+\n+test_description='Test the update hook infrastructure.'\n+. ./test-lib.sh\n+\n+test_expect_success setup '\n+\techo This is a test. >a &&\n+\tgit-update-index --add a &&\n+\ttree0=$(git-write-tree) &&\n+\tcommit0=$(echo setup | git-commit-tree $tree0) &&\n+\tgit-update-ref HEAD $commit0 &&\n+\tgit-clone ./. victim &&\n+\techo We hope it works. >a &&\n+\tgit-update-index a &&\n+\ttree1=$(git-write-tree) &&\n+\tcommit1=$(echo modify | git-commit-tree $tree1 -p $commit0) &&\n+\tgit-update-ref HEAD $commit1\n+\t'\n+\n+cat >victim/.git/hooks/update <<'EOF'\n+#!/bin/sh\n+echo \"$@\" >$GIT_DIR/update.args\n+read x; echo -n \"$x\" >$GIT_DIR/update.stdin\n+echo STDOUT update\n+echo STDERR update >&2\n+EOF\n+chmod u+x victim/.git/hooks/update\n+\n+cat >victim/.git/hooks/post-update <<'EOF'\n+#!/bin/sh\n+echo \"$@\" >$GIT_DIR/post-update.args\n+read x; echo -n \"$x\" >$GIT_DIR/post-update.stdin\n+echo STDOUT post-update\n+echo STDERR post-update >&2\n+EOF\n+chmod u+x victim/.git/hooks/post-update\n+\n+test_expect_success push '\n+\tgit-send-pack ./victim/.git/ master >send.out 2>send.err\n+\t'\n+test_expect_success 'hooks ran' '\n+\ttest -f victim/.git/update.args &&\n+\ttest -f victim/.git/update.stdin &&\n+\ttest -f victim/.git/post-update.args &&\n+\ttest -f victim/.git/post-update.stdin\n+\t'\n+\n+test_expect_success 'update hook arguments' '\n+\techo refs/heads/master $commit0 $commit1 \\\n+\t | diff -u - victim/.git/update.args\n+\t'\n+test_expect_success 'post-update hook arguments' '\n+\techo refs/heads/master \\\n+\t | diff -u - victim/.git/post-update.args\n+\t'\n+\n+test_expect_failure 'update hook stdin is /dev/null' '\n+\ttest -s victim/.git/update.stdin\n+\t'\n+test_expect_failure 'post-update hook stdin is /dev/null' '\n+\ttest -s victim/.git/post-update.stdin\n+\t'\n+\n+test_expect_failure 'send-pack produced no output' '\n+\ttest -s send.out\n+\t'\n+test_expect_success 'send-pack stderr contains hook messages' '\n+\tgrep \"STDOUT update\" send.err &&\n+\tgrep \"STDERR update\" send.err &&\n+\tgrep \"STDOUT post-update\" send.err &&\n+\tgrep \"STDERR post-update\" send.err\n+\t'\n+\n+test_done\n-- \n1.5.0.rc0.g7200\n"}]}