Skip to content

v0.17.0

Choose a tag to compare

@github-actions github-actions released this 07 Aug 14:56
· 82 commits to main since this release
499a563

Fixed

  • Line specs now work on reset and restore at any context width. Both commands reverse-apply their patch, but the filtered patch was built for forward apply only: deselected + lines were dropped instead of kept as context, so the patch's new side no longer matched the index/worktree and git rejected it with "patch does not apply". git hunk reset <sha>:2 and git hunk restore <sha>:2 failed on any hunk containing more than one change. Only --unified 0 worked, because zero context puts every change in its own hunk and leaves nothing deselected to mishandle. Deselected lines are now kept on whichever side the apply direction matches against, mirrored per direction.
  • git hunk commit --dry-run no longer requires -m. The message check ran ahead of the dry-run branch, so the behaviour documented in --help ("required unless --dry-run") — and already allowed by the argument parser — was unreachable.

Added

  • git hunk add --dry-run and git hunk reset --dry-run report what would be staged/unstaged and exit, touching neither the index nor the worktree. Partial staging is the hardest operation to eyeball after the fact, and the previous workaround — diff <sha>:<lines> — was a different command with different output, so it was easy to preview one spec and then stage another. Output follows restore --dry-run (would stage <sha>[:lines] <file>, would-stage in porcelain) and reports the input hunks rather than post-apply result hashes, which cannot exist without applying.
  • --files-from <path> reads file paths from a file, one per line, with - for stdin. Accepted anywhere --file is, and merges with it. NUL-separated input is detected automatically (NUL cannot occur in a path), so git ls-files -z | git hunk add --files-from - is safe for paths containing newlines without a second flag.
  • git hunk diff -n / --number numbers a hunk's body lines without requiring a line spec, so the numbers a :lines spec expects can be read off the screen instead of counted by hand. The numbered gutter already existed but was reachable only by passing a spec — i.e. only once you knew the answer. -n and a spec share one renderer, so their numbering cannot drift; with both, selected lines keep their > markers. Human output only, a deliberate no-op under --porcelain; plain diff output is unchanged byte-for-byte.
  • Regression tests for line specs at default context on reset (test 237) and restore (tests 525–527, covering insertions, deletions, and a mixed add+delete hunk), plus commit --dry-run without -m (tests 1020–1021). The previously existing line-spec tests for these commands all passed --unified 0, which is why the bug survived; the new tests deliberately do not.
  • diff -n tests (924–929), including one that stages a spec read straight off the gutter to pin the numbering to what add actually selects.

Changed

  • A hash that --file excluded now says so instead of reporting as missing: no hunk matching 'da35d28' in the --file selection (it is in 'internal/cli/root.go'), plus a hint to run the file and hash selections as separate commands. --file scopes which hunks a hash may match (this is also how an ambiguous prefix is disambiguated), so passing hashes alongside it reads as a union but behaves as a filter — and the old message was indistinguishable from a stale hash, sending people to look for the wrong problem. A genuinely unknown hash keeps the original wording.
  • Docs: --file is described as scoping rather than addition on every command that takes hashes, with the two-command idiom for "whole files plus specific hunks" written out; and the staging workflow now warns that a build which skips test files (go build, and equivalents) cannot verify a commit produced by splitting an implementation from its tests.
  • Test harness: completion display capture ends on the explicit dumpbuf signal rather than a fixed quiet period, fixing an intermittent test_completions failure (~1 run in 10 under load, measured 5/5 → 0/6 across the change). run-all.sh and one test no longer use fixed /tmp paths that collide between concurrent runs.