git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Bug: `git init` with hook `reference-transaction` running `git rev-parse --git-dir` fails
@ 2024-09-20 10:07 Gabriel Nützi
  2024-09-20 10:42 ` Gabriel Nützi
  2024-10-07  8:03 ` Patrick Steinhardt
  0 siblings, 2 replies; 14+ messages in thread
From: Gabriel Nützi @ 2024-09-20 10:07 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 2101 bytes --]

Thank you for filling out a Git bug report!
Please answer the following questions to help us understand your issue.

What did you do before the bug happened? (Steps to reproduce your
issue)

I set `git config --global core.hooksPath ~/myhooks` and placed a
`reference-transaction` hook in `~/myhooks/reference-transaction`
with the content:

```shell
#!/usr/bin/env bash

set -e
echo "$GIT_DIR"
git rev-parse --absolute-git-dir
```

then I ran

```shell
mkdir ~/test && cd test
git init
```

What did you expect to happen? (Expected behavior)

The Git repo `~/test` should have been initialized (and the hook
`reference-transaction` would have passed successfully.)


What happened instead? (Actual behavior)

The hook `reference-transaction` crashes since `git rev-parse --
absolute-git-dir` with
```
failed: not a git repository: ...
```

What's different between what you expected and what actually happened?

The documentation says that `git rev-parse --absolute-git-dir` inside
the `reference-transaction` hooks read "$GIT_DIR" if defined (which is
defined!) so the `reference-transaction` should have passed. I assume
that hooks should be executed on properly initialized repositories,
right? Therefore I do not understand why `git rev-parse --absolute-git-
dir` fails -> Bug?

Anything else you want to add:

This came up with `Githooks` hooks manager
https://github.com/gabyx/Githooks where we use this command
to locate the current Git dir...

Please review the rest of the bug report below.
You can delete any lines you don't wish to share.


[System Info]
git version:
git version 2.46.0
cpu: x86_64
no commit associated with this build
sizeof-long: 8
sizeof-size_t: 8
shell-path: /nix/store/izpf49b74i15pcr9708s3xdwyqs4jxwl-bash-
5.2p32/bin/bash
libcurl: 8.9.1
OpenSSL: OpenSSL 3.0.14 4 Jun 2024
zlib: 1.3.1
uname: Linux 6.6.45 #1-NixOS SMP PREEMPT_DYNAMIC Sun Aug 11 10:47:28
UTC 2024 x86_64
compiler info: gnuc: 13.3
libc info: glibc: 2.39
$SHELL (typically, interactive shell): /run/current-system/sw/bin/zsh


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2024-10-14 12:25 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-20 10:07 Bug: `git init` with hook `reference-transaction` running `git rev-parse --git-dir` fails Gabriel Nützi
2024-09-20 10:42 ` Gabriel Nützi
2024-10-07  8:03 ` Patrick Steinhardt
2024-10-07 10:54   ` Gabriel Nützi
2024-10-07 10:57     ` Patrick Steinhardt
2024-10-07 11:02       ` Gabriel Nützi
2024-10-07 11:24         ` Patrick Steinhardt
2024-10-07 21:02           ` Junio C Hamano
2024-10-09  9:39             ` Patrick Steinhardt
2024-10-09 10:09               ` Karthik Nayak
2024-10-09 11:53               ` Gabriel Nützi
2024-10-09 12:19                 ` Patrick Steinhardt
     [not found]                   ` <B0631C6D-0914-4C25-AAF7-E742129836FC@gmail.com>
2024-10-14 12:25                     ` Patrick Steinhardt
2024-10-09 17:31               ` Junio C Hamano

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 NNTP newsgroup(s).