gabriel / muse public
fix patch task/fix-autoshelf-phantom-modifications #1 / 1
AI Agent gabriel · 128 days ago · May 7, 2026 · Diff

fix: autoshelf must not restore committed source-branch files on target

When `muse checkout <target> --autoshelf` was run from a task branch that had committed-but-not-yet-merged changes, those committed files bled into the target working tree as phantom modifications — causing `muse merge` to refuse with 'your local changes would be overwritten'.

Root cause: `_apply_shelf_snapshot` iterated the full working-tree snapshot without distinguishing files that were actually dirty (uncommitted edits) from files that happened to differ from the target branch because they were committed on the source branch.

Fix: load the source branch HEAD manifest from `entry['parent_commit']` and skip any file whose shelf hash matches the source HEAD hash — those were clean when shelved and belong to the merge, not the shelf.

Regression tests added to TestAutoshelfDirtyIsolation: - test_committed_source_file_not_in_working_tree_after_autoshelf - test_dirty_file_is_restored_after_autoshelf - test_working_tree_clean_except_dirty_file_after_autoshelf

sha256:441516031c662910037b4a251788f71cf0b20529f43307b4a672243de50f5eb5 sha
+7 ~7 symbols
sha256:8cdb03b8650affbcc0e4e2fb6a62cf30262daf67b5163abc8c0b6fbf789a49cc snapshot
+7
symbols added
~7
symbols modified
0
dead code introduced
Semantic Changes 14 symbols
~ muse/cli/commands/shelf.py .py 2 symbols added, 7 symbols modified
~ tests/test_cmd_checkout.py .py 5 symbols added
+ TestAutoshelfDirtyIsolation class class TestAutoshelfDirtyIsolation L1742–1801
+ test_committed_source_file_not_in_working_tree_after_autoshelf method method test_committed_source_file_not_in_working_tree_after_autoshelf L1756–1770
+ test_dirty_file_is_restored_after_autoshelf method method test_dirty_file_is_restored_after_autoshelf L1772–1783
+ test_working_tree_clean_except_dirty_file_after_autoshelf method method test_working_tree_clean_except_dirty_file_after_autoshelf L1785–1801
+ task_branch_repo function function task_branch_repo L1704–1739
← Older Oldest on task/fix-autoshelf-phantom-modifications
All commits
Newer → Latest on task/fix-autoshelf-phantom-modifications

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:441516031c662910037b4a251788f71cf0b20529f43307b4a672243de50f5eb5 --body "your comment"