hk 2.11.1 fixes pre-commit hooks that failed to restore stashed files when git ran with --literal-pathspecs (or GIT_LITERAL_PATHSPECS=1).
Fixed
-
Stash restore under
GIT_LITERAL_PATHSPECS(#1796, @jdx). Runninggit --literal-pathspecs commitsetsGIT_LITERAL_PATHSPECS=1for every child process, including hooks. Some tools pass this flag on every git call. Under that variable, git read hk's:(literal)PATHpathspecs as part of the file name. As a result, hk couldn't restore a stashed untracked file orgit addfixed files, and the commit failed with errors like:git error: pathspec ':(literal)src/affected/cargo.rs' did not match any file(s) known to git hk ERROR pre-commit: hook finished with error: failed to restore stashhk's own git commands now run with
GIT_LITERAL_PATHSPECS,GIT_GLOB_PATHSPECS,GIT_NOGLOB_PATHSPECSandGIT_ICASE_PATHSPECSset to0, so git reads its pathspecs as hk wrote them. Steps still get the environment the caller set. Plaingit commitwas not affected.
Full Changelog: v2.11.0...v2.11.1
💚 Sponsor hk
hk is built and maintained by @jdx, an open source developer at entire.io, the title sponsor of his open source work.
If hk speeds up your pre-commit loop or makes linting less painful, please consider becoming an individual or company sponsor. Your support funds ongoing development and helps keep hk fast, free, and independent.