feat(diff): default dunk diff to staged + unstaged, add --unstaged#11
Merged
Conversation
`dunk diff` compared the working tree against the index, so anything already `git add`ed silently dropped out of the review. Default it to working tree vs `HEAD` (range "HEAD") so one `dunk diff` shows everything since the last commit. `--staged`/`--cached` keeps index-vs-`HEAD`; new `--unstaged` scopes to working-tree-vs-index. Working-tree scope stays encoded purely as the comparison base — no new input field. `classifyVcsScope` is the single source for title/label so the mapping can't drift. A repo with no commits has an unborn HEAD where `git diff HEAD` would fail, so the loader and the watch-signature path resolve the base through `resolveWorktreeBaseRef`, which falls back to git's empty tree (still surfaces staged-but-uncommitted files). The fallback is loader-local; the session keeps the original HEAD base so a later reload re-evaluates it. HEAD existence is cached per repo so the common already-committed path adds no extra git spawn after the first. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
dunk diffdiffed the working tree against the index, so anything alreadygit added silently dropped out of the review. A quickdunk diffshould show everything you've touched since the last commit.What was changed
dunk diffnow defaults to working tree vsHEAD(staged + unstaged together). Untracked files still included.--staged/--cached→ index-vs-HEADonly. New--unstaged→ working-tree-vs-index only.range); no new input field.classifyVcsScopeis the single source for title + command label so the mapping can't drift.resolveWorktreeBaseReffalls back to git's empty tree (resolved per object format, SHA-1/SHA-256), so staged-but-uncommitted files still show instead ofgit diff HEADhard-failing. Fallback is loader-local; the session keeps the originalHEADbase so a later reload re-evaluates it. The watch-signature path resolves the same base so--watchdoesn't crash in a fresh repo.--staged+--unstaged,--branch+--unstaged, and--unstaged <revision>are rejected with actionable errors.Reviewed with Doistbot (2 rounds) and an expert pass (Codex); applied the P1 unborn-HEAD fix, dropped a staleness-prone HEAD-existence cache, and added SHA-256 regression coverage.
Out of scope
--branch --watchalready used a plaingit diff --rawsignature (pre-existing; watch never resolved the merge-base). Not introduced or worsened here — left for a follow-up.branchReview.ts(cross-module refactor).Refs
CHANGELOG under
## [Unreleased].🤖 Generated with Claude Code