Web lists-archives.com

GIT_DIR not passed to script if hooksPath is set




Hello

If git commit executes .git/hooks/post-commit it will pass GIT_DIR env
variable to the script. However, if hooksPath is set in
$HOME/.gitconfig, git commit executes hooksPath/post-commit without
passing GIT_DIR env variable to the script.

Expected behavior: GIT_DIR is passed to hooksPath/post-commit
Actual behavior: GIT_DIR isn't passed to hooksPath/post-commit

Please run the attached shell script in an empty directory to
reproduce this issue. The script is using strace to determine whether
GIT_DIR is passed to the hook script. The script will run "git gui":
the user is expected to simply commit changes from the gui and then
close the gui for the script to finish. The script is exploiting the
fact that (currently) command-line "git commit" and graphical "git
gui" commit are invoking different commit hooks.

Script output:
  - !!! missing GIT_DIR in git-commit.strace
  - execve(".git/hooks/post-commit", [... "GIT_DIR=.git" ...

$ cat ~/.gitconfig
[core]
    hooksPath = /home/atom/dev/git-hooks

git version 2.21.0

Sincerely
Jan

Attachment: a.sh
Description: application/shellscript