git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Shawn O. Pearce" <spearce@spearce.org>
To: Bill Lear <rael@zopyra.com>
Cc: git@vger.kernel.org
Subject: Re: Git push failure with update hook success
Date: Wed, 7 Mar 2007 12:38:04 -0500	[thread overview]
Message-ID: <20070307173804.GC27922@spearce.org> (raw)
In-Reply-To: <17902.62836.920473.810183@lisa.zopyra.com>

Bill Lear <rael@zopyra.com> wrote:
> 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.

Exactly.  :-)
 
> >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.

If you have a reflog enabled you can use name@{1}..name to generate
the list, but this is subject to a race condition as the ref could
be updated by someone else before you get to look at it to generate
the output.

I'm actually working on a patch right now to create a new hook
(hooks/post-receive ?) that takes the 3 arg form like hooks/update
does, avoiding the race condition entirely.
 
-- 
Shawn.

  reply	other threads:[~2007-03-07 17:38 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-07 16:29 Git push failure with update hook success Bill Lear
2007-03-07 16:46 ` Bill Lear
2007-03-07 17:09   ` Shawn O. Pearce
2007-03-07 17:25     ` Bill Lear
2007-03-07 17:38       ` Shawn O. Pearce [this message]
2007-03-07 23:09       ` Shawn O. Pearce
2007-03-07 23:15         ` Bill Lear
2007-03-08  9:22       ` Andy Parkins
2007-03-08  9:28         ` Shawn O. Pearce
2007-03-08  9:54           ` Junio C Hamano
2007-03-08 10:04           ` Andy Parkins
2007-03-08 10:06             ` Shawn O. Pearce

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070307173804.GC27922@spearce.org \
    --to=spearce@spearce.org \
    --cc=git@vger.kernel.org \
    --cc=rael@zopyra.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).