Skip to content

fix(git-hooks): set worktree-safe core.hooksPath#2503

Closed
schickling wants to merge 7 commits into
cachix:mainfrom
schickling:schickling/2026-02-16-fix-hooks-worktree
Closed

fix(git-hooks): set worktree-safe core.hooksPath#2503
schickling wants to merge 7 commits into
cachix:mainfrom
schickling:schickling/2026-02-16-fix-hooks-worktree

Conversation

@schickling

@schickling schickling commented Feb 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • reset core.hooksPath before running prek install so repeated installs do not fail when hooksPath is already set
  • set core.hooksPath after install using git rev-parse --path-format=relative --git-common-dir, which works for linked worktrees where the common dir is outside the worktree root
  • keep hook installation behavior unchanged otherwise (same install stages/default stage logic)

Verification

  • reproduced the setup from cachix/git-hooks.nix#688 with a bare repo at /tmp/gh688-devenv-repro3/test-repo/.bare and linked worktree at /tmp/gh688-devenv-repro3/test-worktree
  • ran local devenv from this branch in that worktree (nix develop <repo> -c cargo run --manifest-path <repo>/Cargo.toml -- shell true)
  • confirmed git config --local --get core.hooksPath is now ../test-repo/.bare/hooks
  • created a commit in the worktree and verified the installed no-op hook executed (.hook-ran created with one line)

Fixes cachix/git-hooks.nix#688


Updated by OpenCode on behalf of @schickling.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e9c8608f4f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/modules/integrations/git-hooks.nix Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dce8ea911d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/modules/integrations/git-hooks.nix Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1fcf04c20f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/modules/integrations/git-hooks.nix

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 94046b3466

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/modules/integrations/git-hooks.nix Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 884b211d93

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/modules/integrations/git-hooks.nix

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b36c68cd3c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/modules/integrations/git-hooks.nix Outdated
@schickling

Copy link
Copy Markdown
Contributor Author

Plan update: we are moving this fix upstream into prek first (see j178/prek#1672), then will open a fresh minimal devenv PR from a clean branch that depends on the upstream behavior (tracked in #2511).

I will keep this PR as investigation history and post the replacement PR once upstream is ready.

Commented by OpenCode on behalf of @schickling.

@domenkozar

Copy link
Copy Markdown
Member

upstream fix in j178/prek#1892

@domenkozar domenkozar closed this Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

core.hooksPath incorrectly calculated for git worktrees

2 participants