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

$GIT_DIR is no longer set when pre-commit hooks are called

From
GOGregory Oschwald <oschwald@gmail.com>
Date
Aug 22, 2018, 23:16 UTC
Message-ID
<CAFKzd1qaMU=K6uc62xL0DUyZOWxY79Qakaog2dzBjiNrmq0ydg@mail.gmail.com>

As of the release of 2.18.0, $GIT_DIR is no longer set before calling pre-commit hooks. This change was introduced in "set_work_tree: use chdir_notify" (8500e0de) and is still present in master.

I reviewed the discussion when this change was initially submitted, and I don't think this behavior change was intentional.

I have several hooks that were broken like this, and from a quick Google search, using $GIT_DIR without setting a default does seem pretty common in hooks.

Greg
Next: Jeff King
Message 1 of 5 in “$GIT_DIR is no longer set when pre-commit hooks are called”
  1. Gregory OschwaldAug 22, 2018
  2. Jeff KingAug 26, 2018
  3. Johannes SchindelinAug 27, 2018
  4. Jeff KingAug 27, 2018
  5. Johannes SchindelinAug 28, 2018

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.