$GIT_DIR is no longer set when pre-commit hooks are called
- From
- Gregory 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