fix: allow --range/--pr on clean working tree#472
Merged
tomasz-tomczyk merged 1 commit intomainfrom May 6, 2026
Merged
Conversation
createSession previously called NewSessionFromVCS unconditionally, which returns ErrNoChangedFiles when the working tree is clean against the base. With --range or --pr, that check fires before SetFocus has a chance to rebuild the file list from the requested SHA range, so the daemon spawns, prints "Started crit daemon at...", then dies with "no changed files detected" — even though the requested range does have changes. Skip the empty-changes guard when sc.focus is set; SetFocus will populate Files from the focus's SHA range during applySessionOverrides. Closes #471
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (77.77%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #472 +/- ##
==========================================
+ Coverage 69.13% 69.20% +0.06%
==========================================
Files 36 36
Lines 10736 10744 +8
==========================================
+ Hits 7422 7435 +13
+ Misses 2748 2745 -3
+ Partials 566 564 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Summary
crit --range A..Bfailed with "no changed files detected" when the working tree was clean, even though the requested commit range had changes.createSessioncallsNewSessionFromVCS, which returnsErrNoChangedFilesfrom working-tree change detection — this fires beforeSetFocushas a chance to rebuild the file list from the SHA range.requireChangesflag through a new privatenewGitSession. Whensc.focus != nil, tolerate an empty working-tree diff;applySessionOverrides→SetFocuswill populateFilesfrom the focus's SHA range.Review
Test plan
TestCreateSession_RangeFocus_CleanWorkingTreecovers both default-branch and feature-branch shapes (the latter exercises the merge-base recovery branch).TestCreateSession_NoFocus_CleanWorkingTreepins the default behavior so a future refactor can't silently allow empty sessions.go test -race ./...,gofmt -l .,golangci-lint run ./....Closes #471
🤖 Generated with Claude Code