git/list[1] front-page[2] threads[3] people[4] search[5] about
 

GIT_DIR not passed to script if hooksPath is set

From
Jan Ziak <0xe2.0x9a.0x9b@gmail.com>
Date
Apr 1, 2019, 14:14 UTC
Message-ID
<CAODFU0osBF5RCe-gwEJiPOd90nqdnFycmWSEq-2EaLVQMeRpcw@mail.gmail.com>
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

Message 1 of 1 in “GIT_DIR not passed to script if hooksPath is set”
  1. Jan ZiakApr 1, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.