Subject: Client exit whilst running pre-receive hook : commit accepted but no post-receive hook ran

From: Jan Smets <[email-masked]>
Date: Mon, 25 Jul 2016 12:34:04 +0200

Hi

I have always assumed the post-receive hook to be executed whenever a 
commit is "accepted" by the (gitolite) server. That does not seem to be 
true any more.

Since 9658846 is appears that, when a client bails out, the pre-receive 
hook continues to run and the commit is written to the repository, but 
no post-receive hook is executed. No signal of any kind is received in 
the hook, not even a sig pipe when the post- hook is writing to stdout 
whilst the client has disconnected.

commit 9658846ce3d379b9ff8010a2ed326fcafc10eb82
Author: Jeff King <[email-masked]>
Date:   Wed Feb 24 02:40:16 2016 -0500

     write_or_die: handle EPIPE in async threads

diff --git a/write_or_die.c b/write_or_die.c
...
  static void check_pipe(int err)
  {
         if (err == EPIPE) {
+               if (in_async())
+                       async_exit(141);

Please keep me in CC as I am not subscribed to the list.

Thanks
Jan

The pre-receive hook from my quick testing => press Ctrl-C on the client 
when it is busy processing the 'sleep 5'
In my testing I was committing/pushing 32MB+ binary files that take some 
time to process.

#!/bin/bash
trap 'echo TRAP >> /tmp/gittest/log' 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
IN=$(cat /dev/stdin)

echo -n $(date) >> /tmp/gittest/log
echo " : PRE START"  >> /tmp/gittest/log

for i in $(seq 1 10); do
   echo This is the pre-receive hook $i; sleep 0.1
done

# give time for client to ctrl-c out
sleep 5

echo -n $(date) >> /tmp/gittest/log
echo " : PRE END"  >> /tmp/gittest/log

# This should result in a sigpipe? but it isn't.
echo "Done !"
echo "Done !"

# no exit code -> accept commit