Thread (12 messages) 12 messages, 3 authors, 2021-03-01

Re: [QUESTION] Tracking HEAD changes?

flat view

From: Jeff King <hidden>
Date: 2021-02-23 00:39:12

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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help