Adjust pre-commit/pre-push hooks to be compatible with git-worktree #17706
+10
−8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Updates pre-commit/pre-push hooks to work with git-worktree.
git-worktree
doesn't have.git
folder. The.git
in a git worktree directory is a file, e.g. this is the content of thehooks-config
worktree in my local env:The content in this
gitdir
is less compared with a regular git directory.The git layout in a worktree doesn't have
refs
,objects
,hooks
. The hooks would still be triggered when working in agit-worktree
, since it looks up theGIT_COMMON_DIR
, which is/Users/cecemei/codespace/oss-druid/.git
.Note that for a regular git directory,
GIT_COMMON_DIR
is not set, thusgit rev-parse --path-format=absolute --git-common-dir
just returnsGIT_DIR
(e.x. /Users/cecemei/codespace/oss-druid/.git).This PR has: