pre-push broken: git passes pre-push args twice, steps silently skipped as "no file matches" #1063
Unanswered
sherifabdlnaby
asked this question in
Troubleshooting and Bug Reports
Replies: 1 comment
-
|
Thanks for the detailed report. I confirmed the config-based hook runner already forwards hook arguments, so the explicit The fix is ready for review in #1065. It removes the redundant forwarding from config-based hooks, preserves it for legacy shims, and adds an end-to-end config-based pre-push regression test. This comment was generated by Codex. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Note
🧍🏻 Human Note
Hey! The below was drafted by Fable Claude to help describe the Bug. I did face this bug, and verified the findings myself.
Summary
On Git 2.54+, where
hk installwrites config-based hooks, git passes the pre-push arguments (remote name and URL) twice. hk parses the first pair as[REMOTE] [URL]and the duplicate pair as[FILES]..., and an explicit file list overrides push-range file resolution. Sinceoriginand a URL never match any step's glob, every pre-push step is skipped withno file matches for stepand hk exits 0.Warning
Push gates on config-based installs never block anything. Every push passes, and there is no error or warning to notice. pre-commit is unaffected (git passes it no args). commit-msg gets the message-file path duplicated into
[FILES]..., harmless today but wrong for the same reason.Verified on hk 1.50.0 (latest) and 1.48.0, git 2.55.0, macOS, hooks installed via
hk install --mise. The 1.49.0 and 1.50.0 changelogs don't touch pre-push argument handling.Repro
hk.pkl with a pre-push step that should always fail:
hk install --misesrc/git pushThe push should be blocked. It succeeds instead, and the step never runs.
Root cause
The installed command is:
Git's config-hook runner already appends the hook arguments to the command. With the literal
"$@"also present, hk's argv ends up as:The stdin refs parse fine; the args just land in
[FILES]...a second time. The same behavior reproduces without git at all by doubling the args on a manual invocation, and passing them once parses correctly (REMOTE and URL filled, FILES empty, steps run against the push range).Debug log: git-invoked hook on hk 1.50.0 (bypass)
HK_LOG=debug git hook run --to-stdin=<refs-file> pre-push -- origin https://github.com/sherifabdlnaby/skills.gitThe "2 files" are the remote name and the URL.
git pushitself behaves the same;git hook runis just easier to capture.Debug log: same refs and args passed once on hk 1.50.0 (works)
Minimal repro without git: doubled args
Identical input with
origin <url>passed once runs the steps against the refs.Seen in the wild
sherifabdlnaby/skills guards pushes with a
version-bumppush gate that fails when plugin content changes without a manifest version bump. Two pushes shippedskills/**changes with the version untouched and went straight through: 70b69b7 and 241b803. Running the gate's task by hand against the same range fails as designed; only the hook path lets it through.Suggested fix
Omit
"$@"from the commandhk installwrites for config-based hooks, since git appends the arguments itself. The legacy script shims still need it.Workaround
Rewrite the installed commands without
"$@":This gets reverted the next time
hk installruns (confirmed: the 1.50.0 postinstall rewrote both commands with"$@"again). Installing withhk install --legacyavoids the problem entirely.🤝 Human Guided: Posted by Claude on behalf of @sherifabdlnaby.
Beta Was this translation helpful? Give feedback.
All reactions