This release adds a new {{ hook_args }} template variable for forwarding git hook arguments to downstream commands, and fixes a Windows-specific bug where {{files}} expansion silently broke file-based checks.
Added
-
{{ hook_args }}template variable: Step commands can now access the arguments that git passes to hook scripts via{{ hook_args }}. This is essential for tools like git-lfs, whose hooks (post-checkout,post-merge,pre-push) require the original positional arguments from git to function correctly. Without this, commands likegit lfs post-checkoutwould fail with "This should be run through Git's post-checkout hook." (@JohanLorenzo) #807hooks { ["post-checkout"] { steps { ["git-lfs"] { check = "git lfs post-checkout {{ hook_args }}" } } } ["post-merge"] { steps { ["git-lfs"] { check = "git lfs post-merge {{ hook_args }}" } } } ["pre-push"] { steps { ["git-lfs"] { check = "git lfs pre-push {{ hook_args }}" } } } }
The variable is populated for all hook types:
pre-pushgets<remote-name> <remote-url>,commit-msggets the message file path,post-checkoutgets<prev-head> <new-head> <is-branch>, and so on. For hooks that receive no arguments (likepre-commit), it expands to an empty string. -
First-class
post-checkout,post-merge, andpost-rewritehooks: These three hook types now have dedicated subcommands (hk run post-checkout,hk run post-merge,hk run post-rewrite) with proper argument parsing, rather than being handled as generic hooks. (@JohanLorenzo) #807
Fixed
{{files}}expansion on Windows no longer silently breaks checks: On Windows, Rust'sCommand::argapplies MSVCRT-style argv escaping that collides withcmd.exe's own quoting rules. This caused the already-quoted{{files}}payload to reach tools with literal"characters embedded in arguments. Tools like ruff, biome, and others would silently exit 0 while processing zero files, making hk report success on broken invocations. The fix switches the Windowscmd.exe /ccode path to useraw_arg, passing the rendered command string verbatim so cmd.exe can parse its own quoting without Rust interference. This also affects{{workspace_files}}. (@jdx) #824
New Contributors
- @JohanLorenzo made their first contribution in #807
Full Changelog: v1.41.1...v1.42.0