git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
JSJan Smets <jan.smets@nokia.com>
Date
Jul 25, 2016, 10:34 UTC
Message-ID
<5795EB1C.1080102@nokia.com>
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 <peff@peff.net>
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
Next: Jeff King
Message 1 of 6 in “Client exit whilst running pre-receive hook : commit accepted but no post-receive hook ran”
  1. Jan SmetsJul 25, 2016
  2. Jeff KingJul 25, 2016
  3. Stephen MortonAug 2, 2016
  4. Jeff KingAug 3, 2016
  5. Junio C HamanoAug 3, 2016
  6. Stephen MortonAug 4, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.