summaryrefslogtreecommitdiff
path: root/t/t5401-update-hooks.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2014-09-12 22:48:07 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-09-16 22:11:58 (GMT)
commitec7dbd145bd8ea27d958dcb16e19b5f0ef3fd643 (patch)
tree6f5c0fd4de8402985e2167e9e0104afaa61f5fcc /t/t5401-update-hooks.sh
parent96db324a73fdada6fbe7b63221986f8f18cc63b0 (diff)
downloadgit-ec7dbd145bd8ea27d958dcb16e19b5f0ef3fd643.zip
git-ec7dbd145bd8ea27d958dcb16e19b5f0ef3fd643.tar.gz
git-ec7dbd145bd8ea27d958dcb16e19b5f0ef3fd643.tar.bz2
receive-pack: allow hooks to ignore its standard input stream
The pre-receive and post-receive hooks were designed to be an improvement over old style update and post-update hooks, which take the update information on their command line and are limited by the command line length limit. The same information is fed from the standard input to pre/post-receive hooks instead to lift this limitation. It has been mandatory for these new style hooks to consume the update information fully from the standard input stream. Otherwise, they would risk killing the receive-pack process via SIGPIPE. If a hook does not want to look at all the information, it is easy to send its standard input to /dev/null (perhaps a niche use of hook might need to know only the fact that a push was made, without having to know what objects have been pushed to update which refs), and this has already been done by existing hooks that are written carefully. However, because there is no good way to consistently fail hooks that do not consume the input fully (a small push may result in a short update record that may fit within the pipe buffer, to which the receive-pack process may manage to write before the hook has a chance to exit without reading anything, which will not result in a death-by-SIGPIPE of receive-pack), it can lead to a hard to diagnose "once in a blue moon" phantom failure. Lift this "hooks must consume their input fully" mandate. A mandate that is not enforced strictly is not helping us to catch mistakes in hooks. If a hook has a good reason to decide the outcome of its operation without reading the information we feed it, let it do so as it pleases. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t5401-update-hooks.sh')
-rwxr-xr-xt/t5401-update-hooks.sh13
1 files changed, 13 insertions, 0 deletions
diff --git a/t/t5401-update-hooks.sh b/t/t5401-update-hooks.sh
index 17bcb0b..7f278d8c 100755
--- a/t/t5401-update-hooks.sh
+++ b/t/t5401-update-hooks.sh
@@ -135,4 +135,17 @@ test_expect_success 'send-pack stderr contains hook messages' '
test_cmp expect actual
'
+test_expect_success 'pre-receive hook that forgets to read its input' '
+ write_script victim.git/hooks/pre-receive <<-\EOF &&
+ exit 0
+ EOF
+ rm -f victim.git/hooks/update victim.git/hooks/post-update &&
+
+ for v in $(test_seq 100 999)
+ do
+ git branch branch_$v master || return
+ done &&
+ git push ./victim.git "+refs/heads/*:refs/heads/*"
+'
+
test_done