Re: [QUESTION] Tracking HEAD changes?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



That indeed seems to do the trick.
I've done a little experiment and saw that when doing git reset the
hook gets called.

However, when switching branches the hook doesn't execute :(

I don't understand if it's intentional, since when I've moved to a new
branch HEAD pointed to another commit id.
The only workaround I see here is using the post-checkout hook in addition.

Thank you very much for helping me. I really appreciate it!!
     Yaron

On Tue, Feb 23, 2021 at 10:42 PM Jeff King <peff@xxxxxxxx> wrote:
>
> On Mon, Feb 22, 2021 at 07:38:30PM -0500, Jeff King wrote:
>
> > On Mon, Feb 22, 2021 at 11:12:11AM +0200, Yaron Wittenstein wrote:
> >
> > > Is there any possible way to track changes to HEAD using hooks?
> > >
> > > Being able to listen using hooks to events such as pre-head-checkout
> > > and post-head-checkout would be the best option (from my perspective).
> > >
> > > To my knowledge, the only possible way to do that today is by adding a
> > > file watch over the refs directory.
> >
> > No, I don't think there is currently a better way.
>
> Actually, I completely forgot about Patrick's recent ref-transaction
> hook. See the "reference-transaction" section of githooks(7). They do
> more than you'd need, but you should be able to write a hook that just
> looks for updates to HEAD, or updates to the ref that HEAD is pointing
> at.
>
> The code was introduced in 6754159767 (refs: implement reference
> transaction hook, 2020-06-19), so you'll need Git v2.28.0 or later.
>
> -Peff



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux