-
-
Notifications
You must be signed in to change notification settings - Fork 605
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resolve core.hooksPath relative to GIT_WORK_TREE #2571
Conversation
22ad6a9
to
d66d148
Compare
d66d148
to
cda17c7
Compare
@Byron this might affect Gitbutler. Would love your pair of eyes |
cda17c7
to
0d06a50
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for calling me in @extrawurst , and thanks @naseschwarz for tackling this!
I'd arrive at the same conclusion on how the implementation should look like, and it's great to see all the right tests.
Of course, I'd have a few nits but they are not material.
It's worth noting that core.hooksPath
is very relevant to security on shared drives in particular, and since git2
follows Git and will refuse to open such repositories it should be safe to use core.hooksPath
here. In gitoxide
one would use trusted_path()
instead to obtain the fully-interpolated path if it's in a trusted configuration file.
53f36a1
to
0781291
Compare
Thank you for your time and input, @Byron. |
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.
0781291
to
892bced
Compare
Thank you! |
git supports a relative path in core.hooksPath.
man git-config
:man githooks
: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:
This Pull Request fixes/closes #2281.
It changes the following:
I followed the checklist:
make check
without errors