Re: Bug: `git init` with hook `reference-transaction` running `git rev-parse --git-dir` fails
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Oct 14, 2024, 12:25 UTC
- Message-ID
- <Zw0NskRJUSmpNxLe@pks.im>
- In-Reply-To
- <B0631C6D-0914-4C25-AAF7-E742129836FC@gmail.com>
On Fri, Oct 11, 2024 at 12:09:18PM +0200, Gabriel Nützi wrote:
Show 10 quoted lines
> > namely by checking whether the HEAD file exists in the Git directory. > > The problem here is the chicken-egg problem: How do I know inside a > hook where to look for HEAD, so the non. env. way of doing this would > be 'git rev-parse —git-dir' which crahshes… So there should be cleary > some better way of knowing if a Git repo is on the way of beeing > created, and when it is fully initialized. What about > GIT_DIR_INITIALIZING and this variable does not exist once it is done > or whats about making ‚git rev-parse —git-dir‘ not panic if the env. > variables are defined. I guess for a good solution we need both?
Our documentation in githooks(5) says that the GIT_DIR environment variable is always set so that the hook can identify the location of the Git repository. So I'd argue that using git-rev-parse(1) is unnecessary in the first place. Or am I missing something?
Patrick