# Why isn't there a hook for all operations that update the working tree?

3 messages from 2011-07-28 to 2011-08-04. Participants: Ævar Arnfjörð Bjarmason, Neal Kreitzinger, Junio C Hamano.
Thread: https://gitlist.dev/t/27944

## Ævar Arnfjörð Bjarmason, 2011-07-28 11:59

Subject: Why isn't there a hook for all operations that update the working tree?
Message-ID: <CACBZZX7dJhGT0H8JZRbQ_t9mNnJocaktYAXgMSihfLBuFmL3nw@mail.gmail.com>
URL: https://gitlist.dev/e/CACBZZX7dJhGT0H8JZRbQ_t9mNnJocaktYAXgMSihfLBuFmL3nw%40mail.gmail.com

```
I have a repository where I'd like to run a program every time the
working tree is updated. githooks(5) specifies that you can use
post-{checkout,merge} hooks to hook into those two operations.

However that doesn't catch e.g. "git reset --hard". Is there any
reason beside omission that there isn't a post-reset hook? Or hooks
for any other thing (most of which surely slip my mind) which can
update the working tree?

```

## Neal Kreitzinger, 2011-08-04 01:56

Subject: Re: Why isn't there a hook for all operations that update the working tree?
Message-ID: <4E39FC55.206@gmail.com>
URL: https://gitlist.dev/e/4E39FC55.206%40gmail.com
In-Reply-To: <CACBZZX7dJhGT0H8JZRbQ_t9mNnJocaktYAXgMSihfLBuFmL3nw@mail.gmail.com>

```
On 7/28/2011 6:59 AM, Ævar Arnfjörð Bjarmason wrote:
> I have a repository where I'd like to run a program every time the
> working tree is updated. githooks(5) specifies that you can use
> post-{checkout,merge} hooks to hook into those two operations.
>
> However that doesn't catch e.g. "git reset --hard". Is there any
> reason beside omission that there isn't a post-reset hook? Or hooks
> for any other thing (most of which surely slip my mind) which can
> update the working tree?

You could create an alias like "git resetr" that runs the script.

v/r,
neal

```

## Junio C Hamano, 2011-08-04 02:06

Subject: Re: Why isn't there a hook for all operations that update the working tree?
Message-ID: <7v1ux26icd.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7v1ux26icd.fsf%40alter.siamese.dyndns.org
In-Reply-To: <CACBZZX7dJhGT0H8JZRbQ_t9mNnJocaktYAXgMSihfLBuFmL3nw@mail.gmail.com>

```
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:

> ... Is there any
> reason beside omission that there isn't a post-reset hook?
> Or hooks for any other thing ...

In principle, we historically tended to avoid hooks unless absolutely
necessary. Even having to check to find out no hook needs to be run is
considered wasted cycles.

  http://thread.gmane.org/gmane.comp.version-control.git/79314/focus=79321

I'd especially rather not to see a hook on something as low level as
"reset". It would be too tempting to use "reset" itself inside a hook that
is run from the post-reset hook, and I do not want to complicate the code
even further to give callers to ask disabling the hook.

```
