]> git.ipfire.org Git - thirdparty/git.git/commitdiff
receive-pack: ignore SIGPIPE while reporting status to client
authorRobin Jarry <robin@jarry.cc>
Wed, 10 Nov 2021 09:29:42 +0000 (10:29 +0100)
committerJunio C Hamano <gitster@pobox.com>
Wed, 10 Nov 2021 21:43:04 +0000 (13:43 -0800)
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>
builtin/receive-pack.c

index 2d1f97e1ca7b5346d9cae3239165d6824df309af..89202830acd82c8bfed8500ed2b2474ab56a665d 100644 (file)
@@ -2563,10 +2563,12 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
                                 &push_options);
                if (pack_lockfile)
                        unlink_or_warn(pack_lockfile);
+               sigchain_push(SIGPIPE, SIG_IGN);
                if (report_status_v2)
                        report_v2(commands, unpack_status);
                else if (report_status)
                        report(commands, unpack_status);
+               sigchain_pop(SIGPIPE);
                run_receive_hook(commands, "post-receive", 1,
                                 &push_options);
                run_update_post_hook(commands);