Skip to content

Commit d34182b

Browse files
rjarrygitster
authored andcommitted
receive-pack: ignore SIGPIPE while reporting status to client
Before running the post-receive hook, status info is reported back to the client. If a remote client exits before or during the status report, receive-pack is killed by SIGPIPE and post-receive is never executed. The post-receive hook is often used to send email notifications (see contrib/hooks/post-receive-email), update bug trackers, start automatic builds, etc. Not executing it after an interrupted yet "successful" push can lead to inconsistencies. Ignore SIGPIPE before reporting status to the client to increase the chances of post-receive running if pre-receive was successful. This does not guarantee 100% consistency but it should resist early disconnection by the client. Signed-off-by: Robin Jarry <robin@jarry.cc> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 5fbd2fc commit d34182b

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

builtin/receive-pack.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2563,10 +2563,12 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
25632563
&push_options);
25642564
if (pack_lockfile)
25652565
unlink_or_warn(pack_lockfile);
2566+
sigchain_push(SIGPIPE, SIG_IGN);
25662567
if (report_status_v2)
25672568
report_v2(commands, unpack_status);
25682569
else if (report_status)
25692570
report(commands, unpack_status);
2571+
sigchain_pop(SIGPIPE);
25702572
run_receive_hook(commands, "post-receive", 1,
25712573
&push_options);
25722574
run_update_post_hook(commands);

0 commit comments

Comments
 (0)