gabyx / Githooks

🦎 Githooks: per-repo and shared Git hooks with version control and auto update. [✩Star] if you're using it!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Access GIT_ env vars?

johnnybubonic opened this issue · comments

To ensure consistent behaviour/cross-compat with "vanilla" git hooks, ideally the GIT_ env vars would be recreated or exported where possible.

Relatedly, since I can't use GIT_WORK_TREE in a pre-commit now, is the PWD env var guaranteed to always be the work tree for non-bare repositories?

EDIT: Excellent work, to be clear. This is a much-needed tool. :)

Hi, @johnnybubonic, thanks for the kudos ;) much apprciated.

And sorry for the really late reply.

I thought that we replicate the whole environment it gets from git when executing hooks.
So Githooks does not change it, merely adds some defined values see in the Readme.md.

Note:
Its opaque to me which env variable leak through into the hooks. Git sometimes has bugs (or features?) which expose certain env. variables to hooks which then make troubles inside the scripted hook if you use git again because it might re-read from the env. etc...

GIT_WORK_TREE is not set in my case for a non worktree setup non-bare repo:

GIT_ASKPASS=/usr/share/code/resources/app/extensions/git/dist/askpass.sh
GIT_AUTHOR_DATE=@1652991860 +0200
GIT_AUTHOR_EMAIL=...
GIT_AUTHOR_NAME=....
GIT_EDITOR=:
GIT_EXEC_PATH=/usr/lib/git-core
GIT_INDEX_FILE=.git/index
GIT_PREFIX=

The pwd is always the repository, we rely on this! (also in bare repos its the repository).

I can absolutely work with PWD/CWD, especially if it's used internally. Thank you! Closing.

I would not rely on PWD beeing set. Use $(pwd) instead. Probably you meant this.