Re: [QUESTION] Tracking HEAD changes?

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

 



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.

If you do go the file watch route, make sure you put one on HEAD, too
(to catch the case of checking out a different branch, as opposed to
updating it with a new commit). I use:

  gitdir=$(git rev-parse --git-dir)
  # We need delete_self to pick up changes to HEAD (since it gets renamed
  # over), and "move" to pick up changes in the refs directories.
  inotifywait -qq -t 60 -e delete_self -e move -r "$gitdir/HEAD" "$gitdir/refs"

in a script that I use for automatically running tests against the
current commit. (if you are doing something similar, I also recommend
https://github.com/mhagger/git-test for avoiding re-running against the
same commits repeatedly).

-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