Ignore user-configured Git hooks for tap operations - #23352
Merged
MikeMcQuaid merged 3 commits intoJul 29, 2026
Conversation
MikeMcQuaid
reviewed
Jul 29, 2026
MikeMcQuaid
approved these changes
Jul 29, 2026
MikeMcQuaid
left a comment
Member
There was a problem hiding this comment.
Thanks! Looks good when 🟢
boblail
force-pushed
the
lail/tap-ignore-core-hookspath
branch
from
July 29, 2026 16:21
1918e98 to
d1246ef
Compare
boblail
marked this pull request as ready for review
July 29, 2026 16:31
Contributor
There was a problem hiding this comment.
Pull request overview
This PR prevents user-defined Git hooks (via core.hooksPath, commonly set by git lfs install) from running during Homebrew tap and update Git operations, avoiding failures caused by Homebrew’s sanitized PATH (e.g., missing git-lfs).
Changes:
- Prepends
git -c core.hooksPath=/dev/nulltoTap#git_command!and related worktree operations. - Wraps
gitinvocations incmd/update.shandcmd/update-reset.shwith the same-c core.hooksPath=/dev/nullbehavior. - Updates/adds RSpec coverage to exercise the new hook-bypass behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| Library/Homebrew/tap.rb | Forces core.hooksPath to null for tap clone/fetch and worktree add operations. |
| Library/Homebrew/cmd/update.sh | Ensures brew update Git calls ignore core.hooksPath hooks. |
| Library/Homebrew/cmd/update-reset.sh | Ensures brew update-reset Git calls ignore core.hooksPath hooks. |
| Library/Homebrew/test/tap_spec.rb | Updates expectations for new Git args and adds a spec intended to cover hook bypassing. |
Comments suppressed due to low confidence (1)
Library/Homebrew/tap.rb:726
- Same as above: this comment refers to "user-configured hooks", but the implementation forces
core.hooksPathfor the invocation regardless of config scope. Rewording helps avoid implying only global config is affected.
# Ignore user-configured hooks as in `git_command!`.
worktree_args = ["-c", "core.hooksPath=#{File::NULL}", "-C", worktree_source_tap_path, "worktree", "add"]
worktree_args << "--quiet" if quiet
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
Author
|
Applying Copilot's suggestions... |
A global `core.hooksPath` (e.g. set by `git lfs install`) breaks `brew tap` and `brew update`: hooks run with Homebrew's filtered `PATH`, which lacks `git-lfs`, so every tap clone or update fails. Pass `-c core.hooksPath=/dev/null` to tap and update Git operations, as `package/scripts/postinstall` already does for the installer. Requested in Homebrew#21621.
The hook spec now verifies via a side effect that the hook never executes, rather than only that `git clone` succeeds. Comments no longer say "user-configured" since `-c core.hooksPath` overrides every configuration scope.
boblail
force-pushed
the
lail/tap-ignore-core-hookspath
branch
from
July 29, 2026 16:57
d1246ef to
cbd163b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
A global
core.hooksPath(e.g. set bygit lfs install) breaksbrew tapandbrew update: Git hooks run with Homebrew's filteredPATH, which lacksgit-lfs, so every tap clone and tap update fails. Pass-c core.hooksPath=/dev/nullto tap and update Git operations, aspackage/scripts/postinstallalready does for the installer. Requested in #21621; same failure mode as #4988, #7014 and https://github.com/orgs/Homebrew/discussions/5047. No other user Git configuration is bypassed, so credential helpers for private taps keep working (cf. #22774).To reproduce:
brewcommands to reproduce the bug?brew lgtm(style, typechecking and tests) locally?Written with Claude Code, reviewed and directed by me. Verified with a red/green RSpec cycle (the new spec reproduces the hook failure before the fix) and a manual end-to-end reproduction:
brew tapof a local repository with a hostile globalcore.hooksPathfails onmainand succeeds with this change, with the hook confirmed not to run.brew lgtmpasses locally.🤖 Generated with Claude Code