github jdx/hk v2.11.1
v2.11.1: Fix stash restore under git --literal-pathspecs

2 hours ago

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). Running git --literal-pathspecs commit sets GIT_LITERAL_PATHSPECS=1 for every child process, including hooks. Some tools pass this flag on every git call. Under that variable, git read hk's :(literal)PATH pathspecs as part of the file name. As a result, hk couldn't restore a stashed untracked file or git add fixed 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 stash
    

    hk's own git commands now run with GIT_LITERAL_PATHSPECS, GIT_GLOB_PATHSPECS, GIT_NOGLOB_PATHSPECS and GIT_ICASE_PATHSPECS set to 0, so git reads its pathspecs as hk wrote them. Steps still get the environment the caller set. Plain git commit was 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.

Don't miss a new hk release

NewReleases is sending notifications on new releases.