git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Yaron Wittenstein <yaron.wittenstein@gmail.com>
Cc: Patrick Steinhardt <ps@pks.im>, git@vger.kernel.org
Subject: Re: [QUESTION] Tracking HEAD changes?
Date: Tue, 23 Feb 2021 15:42:58 -0500	[thread overview]
Message-ID: <YDVo0kGYODP0JjqT@coredump.intra.peff.net> (raw)
In-Reply-To: <YDROhhrM5qJti1ir@coredump.intra.peff.net>

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

  reply	other threads:[~2021-02-23 20:47 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-22  9:12 [QUESTION] Tracking HEAD changes? Yaron Wittenstein
2021-02-23  0:38 ` Jeff King
2021-02-23 20:42   ` Jeff King [this message]
2021-02-24 20:21     ` Yaron Wittenstein
2021-02-24 21:03       ` Jeff King
2021-02-25  5:36         ` Patrick Steinhardt
2021-02-25  6:01           ` Yaron Wittenstein
2021-02-25  6:27             ` Patrick Steinhardt
2021-02-25  7:13               ` Junio C Hamano
2021-02-25  7:28                 ` Patrick Steinhardt
2021-02-25  7:50                   ` Yaron Wittenstein
2021-02-26  5:59           ` Jeff King
2021-02-26 20:58             ` Yaron Wittenstein
2021-03-01  9:03               ` Jeff King
2021-03-01 10:02                 ` Yaron Wittenstein

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=YDVo0kGYODP0JjqT@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=ps@pks.im \
    --cc=yaron.wittenstein@gmail.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).