Commit 7e96b0f
fix(worktrees): also refuse removal of a worktree with staged changes
The removal guard used only `is_workdir_clean`, which compares the
index to the working directory and therefore misses staged-but-
uncommitted changes (HEAD vs index). A worktree whose only changes were
`git add`ed (workdir matching the index) was treated as clean and its
working directory pruned, whereas `git worktree remove` refuses it.
Compose an additional `get_status(StatusType::Stage)` check in
`remove_worktree` so the guard matches its "uncommitted changes"
contract. Adds a regression test.
Found by an independent code review of #2995.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BMQxBdr5f3B3jmDtdvGtTu1 parent 80322f0 commit 7e96b0f
1 file changed
Lines changed: 32 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
215 | 216 | | |
216 | 217 | | |
217 | 218 | | |
218 | | - | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
219 | 226 | | |
220 | 227 | | |
221 | 228 | | |
| |||
454 | 461 | | |
455 | 462 | | |
456 | 463 | | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
457 | 488 | | |
458 | 489 | | |
459 | 490 | | |
| |||
0 commit comments