On Wed, Oct 09, 2024 at 01:53:17PM +0200, Gabriel Nützi wrote: > > > We have another solution that is even simpler: just do nothing. I do not > > think that the behaviour we exhibit is wrong. Unwieldy? Maybe. But it is > > merely stating facts: we are executing a transaction in a repository > > that is not yet fully set up. If you don't want that, either don't set > > up a global reference-transaction hook, or alternatively handle that > > edge case in your script. > > But then Git should at least give the hooks maintainers a chance to know what it is doing. > Could we have a new env. variable or mechanism stating that the repository is not yet setup or so? > The issue here comes from the fact that Githooks is a hooks manager which basically calls `reference-transaction` for you, but before > it does it calls `git rev-parse --git-dir` to get the correct Git directory, basically not doing env. lookup on GIT_DIR which this command actually does, but that apparently only works on a "initialized" repo, so currently I do a workaround and looking directly at GIT_DIR. > I would be really happy also if I could somehow know when Git is creating a new repository (clone, or init), that would also improve other scenarios I came across. Basically you cannot react on hook `post-checkout` only when a new repo is created... Yeah, that's fair indeed, thanks for the background. In practice you already have a unique way to identify whether the repo is about to be created or whether you're using "normal" operations, namely by checking whether the HEAD file exists in the Git directory. Is that an acceptable workaround for you? As said, we're currently just exploring options. I'm not yet saying that this is the way we'll go, even though it seems like the most sensible solution to me right now. That picture of course changes when there are valid usecases like what you present here. Patrick