Skip to content

Commit

Permalink
Merge branch 'jc/ignore-sigpipe-while-running-hooks'
Browse files Browse the repository at this point in the history
pre- and post-receive hooks are no longer required to read all
their inputs.

* jc/ignore-sigpipe-while-running-hooks:
  receive-pack: allow hooks to ignore its standard input stream
  • Loading branch information
gitster committed Sep 26, 2014
2 parents c0f5f31 + ec7dbd1 commit bdab1bc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions builtin/receive-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "connected.h"
#include "argv-array.h"
#include "version.h"
#include "sigchain.h"

static const char receive_pack_usage[] = "git receive-pack <git-dir>";

Expand Down Expand Up @@ -287,6 +288,8 @@ static int run_and_feed_hook(const char *hook_name, feed_fn feed, void *feed_sta
return code;
}

sigchain_push(SIGPIPE, SIG_IGN);

while (1) {
const char *buf;
size_t n;
Expand All @@ -298,6 +301,9 @@ static int run_and_feed_hook(const char *hook_name, feed_fn feed, void *feed_sta
close(proc.in);
if (use_sideband)
finish_async(&muxer);

sigchain_pop(SIGPIPE);

return finish_command(&proc);
}

Expand Down
13 changes: 13 additions & 0 deletions t/t5401-update-hooks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit bdab1bc

Please sign in to comment.