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

Re: Git push failure with update hook success

From
Bill Lear <rael@zopyra.com>
Date
Mar 7, 2007, 17:25 UTC
Message-ID
<17902.62836.920473.810183@lisa.zopyra.com>
In-Reply-To
<20070307170904.GB27922@spearce.org>
On Wednesday, March 7, 2007 at 12:09:04 (-0500) Shawn O. Pearce writes:
Show 13 quoted lines
>Bill Lear <rael@zopyra.com> wrote:
>> On Wednesday, March 7, 2007 at 10:29:29 (-0600) Bill Lear writes:
>> >...
>> >whether it might be better to call the update hook after everything
>> >had actually been written, including the log file.
>> 
>> I dug into the code: in receive-pack.c, the command 'update(struct
>> command *cmd)', calls write_ref_sha1() after run_update_hook()
>> and does not check the return code of write_ref_sha1().
>
>Please see the patch I just posted (and CC'd you on).  We should
>have caught the return error of write_ref_sha1, the patch now
>does that.  :)

Ok, thank you for fixing this. I guess the call run_update_hook() should not in fact come after the write_ref_sha1() block, and just before the 'return 0' line, because you don't want to run the write_ref_sha1() at all if the update hook complains.

Show 6 quoted lines
>You probably want to use the post-update hook to send email.
>This hook will always run if it exists and is executable, but it
>won't be given a ref that failed to be updated.
>
>Of course an unfortunate downside to the post-update hook is it
>does not receive the old SHA-1 of the ref; it just gets the ref name.

Hmm, I agree that this sounds like the better place, logically speaking, for the email report to be generated, but unfortunate since I'm lame with git, so writing a post-update hook from scratch will probably be beyond my abilities, but since I just watched "Touching the Void" last night, I might be inspired to brave it.

Since it just gets the ref name, would one (of sufficient skill) be able to reconstruct the same sort of report that the "pre" update hook does? That is, from the ref name can I get the old SHA-1? If I try to write this, what I think I would like to do is just call the existing update hook from the post-update hook, with the post update hook figuring out the proper arguments to pass along.

Also, I do notice in refs.c:create_symref() that it does not check the return code of log_ref_write(). I don't know if that is done explicitly or not ...

Bill
Previous: Shawn O. PearceNext: Shawn O. Pearce
Message 4 of 12 in “Git push failure with update hook success”
  1. Bill LearMar 7, 2007
  2. Bill LearMar 7, 2007
  3. Shawn O. PearceMar 7, 2007
  4. Bill LearMar 7, 2007
  5. Shawn O. PearceMar 7, 2007
  6. Shawn O. PearceMar 7, 2007
  7. Bill LearMar 7, 2007
  8. Andy ParkinsMar 8, 2007
  9. Shawn O. PearceMar 8, 2007
  10. Junio C HamanoMar 8, 2007
  11. Andy ParkinsMar 8, 2007
  12. Shawn O. PearceMar 8, 2007

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.