Honour GIT_INDEX_FILE so hook processes can operate on git's temporary index #2890
Closed
Adam Bouqdib (abemedia)
started this conversation in
Feature Proposal
Replies: 2 comments
|
Thanks for letting me know and for the initial research! The goal of making |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
git's hook protocol passes the index to operate on via
GIT_INDEX_FILE(githooks(5)). Forgit commit -aandgit commit <paths>this is a temporary index, notgit_dir/index, and git holds the real index's lock for the duration of the commit.gix has no way to honour this:
index_path()is hardcoded togit_dir/index, andopen_with_environment_overrides()reads onlyGIT_DIRandGIT_WORK_TREE. A gix-based pre-commit hook therefore sees an empty staged set undergit commit -a(silently does nothing), and fails to lock the index undergit commit <paths>(git holds it). libgit2 honours the variable for comparison.Proposal, with
index_path()as the single choke point so all internal consumers (index opening/caching, status, filter pipeline) pick it up for free:open::Optionsgains an explicit override, e.g.index_file(path).index_path()returns the override when set.open_with_environment_overrides()also readsGIT_INDEX_FILE(gated by gix-sec permissions like the other env vars), absolutising relative values against the cwd at open time.A nonexistent override file should keep the usual empty-index semantics, and bare repos are unaffected.
Happy to contribute the PR if the direction is acceptable.
All reactions