Resolve core.hooksPath relative to GIT_WORK_TREE by naseschwarz · Pull Request #2571 · gitui-org/gitui

extrawurst

extrawurst

Byron

Naseschwarz added 2 commits

March 23, 2025 14:33
git supports relative values in core.hooksPath.

`man git-config`:

> A relative path is taken as relative to the directory where the hooks are
> run (see the "DESCRIPTION" section of githooks[5]).

`man githooks`:

> Before Git invokes a hook, it changes its working directory to either
> $GIT_DIR in a bare repository or the root of the working tree in a >
> non-bare repository.

I.e. relative paths in core.hooksPath in non-bare repositories are always
relative to GIT_WORK_TREE.

There is a further exception; I believe this is not considered for path
resolution:

> An exception are hooks triggered during a push (pre-receive, update,
> post-receive, post-update, push-to-checkout) which are always executed
> in $GIT_DIR.
This more clearly errors in case of bare repositories instead of using
the parent directory of the bare repository.

@extrawurst

@Byron Byron mentioned this pull request

Apr 14, 2025

Byron added a commit to Byron/gitbutler that referenced this pull request

May 27, 2025

@Byron Byron mentioned this pull request

May 27, 2025