Skip to content

Report removal failures with the surviving checkout and branch state - #4457

Merged
max-sixty merged 9 commits into
mainfrom
codex/branch-removal-errors
Oct 28, 2026
Merged

max-sixty merged 9 commits into
mainfrom
codex/branch-removal-errors

Conversation

@max-sixty

@max-sixty max-sixty commented Oct 12, 2026 •

Copy link
Copy Markdown
Owner

A branch-deletion failure can be lost after its checkout has already been removed. Return a contextual error through foreground and silent callers after arranging teardown, while preserving partial JSON results, including retained_failed, and the underlying cancellation signal. Later failures in an already detached cleanup child continue to go to its log.

The destructive Git command owns checkout-removal errors and surviving-entry details. Preflight and staging refusals keep their own diagnostic, so they do not imply that deletion partly succeeded; actual partial failures still list survivors.

Validation: 160 removal integration tests, 83 prune integration tests, and the cancellation and silent-picker unit regressions pass. The full project gate passes: 5,447 tests plus Clippy, formatting, docs, doctests, and lockfile checks. Independent source review found no remaining defects.

This was written by Codex on behalf of max-sixty

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new "not empty" gate on the remaining-entries listing makes code-coverage fail. integration_tests::git_error_display::worktree_errors_render drops the Remaining in directory: target/ line from its removal left one entry case, and that case is a permission-denied failure. Before accepting the new snapshot, consider whether hiding the listing there is intended. Details are inline.

Comment thread src/git/error.rs Resolved
worktrunk-bot
worktrunk-bot previously approved these changes Oct 12, 2026

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

codecov/patch fails on this head at 86.2%. The 19 missed lines are the new map_err in Repository::remove_worktree and the relocated list_remaining_entries (src/git/repository/worktrees.rs). On main the old handler-side wrapper was covered by remove_continues_dirty_foreground. That refusal now comes from staging and never reaches git worktree remove, so no test produces a real Git removal failure anymore. As a result, the listing that the earlier thread asked to keep for partial failures is now untested. A test that sends a locked worktree straight to remove_worktree would cover the boundary. Details are inline.

Comment thread src/git/repository/worktrees.rs Resolved
@worktrunk-bot
worktrunk-bot dismissed their stale review October 12, 2026 21:34

CI failed — codecov/patch: the Git removal-failure path is untested.

@max-sixty
max-sixty merged commit 16d52e5 into main Oct 28, 2026
38 checks passed
@max-sixty
max-sixty deleted the codex/branch-removal-errors branch October 28, 2026 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants