gabriel / muse public
fix patch task/fix-checkout-dirty-bleedthrough #1 / 1
AI Agent gabriel · 153 days ago · Apr 22, 2026 · Diff

fix: checkout now refuses on any dirty tracked file

The old require_clean_workdir only blocked files that the target branch would overwrite (different object_id between HEAD and target). Files that were modified locally but identical on both branches silently bled through — exactly the bug that left 80+ modified files on branches the user never touched.

Fix: remove the permissive target_manifest narrowing path from require_clean_workdir. Any dirty tracked file now blocks checkout; users must commit, shelf, --autoshelf, or --force explicitly.

Fix --force on branch switch: pass current_snapshot_id=None so _checkout_snapshot diffs empty→target, restoring ALL target files and discarding local modifications (consistent with what --force implies).

Tests: TestDirtyWorkdirBleedThrough (9 tests) — red before, green after. Delete TestSwitchWithNonConflictingChanges tests that asserted the bug.

sha256:3d2ec5a1f34b82c1c61ce7ed91de1c2b8ae50a3239a683248e10e7e8f5f00737 sha
+11 ~3 −2 symbols
sha256:a54b2214b6595f85364ecc903c7e8da403b95de694ca158a79d15ed8d1700120 snapshot
+11
symbols added
~3
symbols modified
−2
symbols removed
0
dead code introduced
Semantic Changes 16 symbols
~ muse/cli/commands/checkout.py .py 1 symbol modified
~ run
~ muse/cli/guard.py .py 1 symbol modified
~ tests/test_cmd_checkout.py .py 11 symbols added, 2 symbols removed, 1 symbol modified
test_switch_carries_change_not_in_target method method test_switch_carries_change_not_in_target L1133–1142
test_switch_preserves_non_conflicting_change method method test_switch_preserves_non_conflicting_change L1144–1151
+ TestDirtyWorkdirBleedThrough class class TestDirtyWorkdirBleedThrough L406–507
+ test_autoshelf_bypasses_dirty_check method method test_autoshelf_bypasses_dirty_check L480–487
+ test_create_branch_allows_dirty_workdir method method test_create_branch_allows_dirty_workdir L499–507
+ test_deleted_shared_file_blocks_checkout method method test_deleted_shared_file_blocks_checkout L461–467
+ test_dirty_shared_file_blocks_checkout method method test_dirty_shared_file_blocks_checkout L419–428
+ test_dirty_shared_file_error_names_file method method test_dirty_shared_file_error_names_file L430–438
+ test_dirty_shared_file_json_error method method test_dirty_shared_file_json_error L440–449
+ test_dirty_shared_file_not_silently_moved method method test_dirty_shared_file_not_silently_moved L451–459
+ test_force_bypasses_dirty_check method method test_force_bypasses_dirty_check L469–478
+ test_untracked_file_does_not_block_checkout method method test_untracked_file_does_not_block_checkout L489–497
+ shared_file_repo function function shared_file_repo L382–403
← Older Oldest on task/fix-checkout-dirty-bleedthrough
All commits
Newer → Latest on task/fix-checkout-dirty-bleedthrough

0 comments

No comments yet. Be the first to start the discussion.

To add a comment, use the Muse CLI: muse hub commit comment sha256:3d2ec5a1f34b82c1c61ce7ed91de1c2b8ae50a3239a683248e10e7e8f5f00737 --body "your comment"