feat(branch): reflog copy/rename parity with git, standardize operation strings (muse#48)
Phases 1-3 of muse#48: - New muse/core/reflog.py::copy_branch_reflog — mirrors `git branch -c`: copies the source branch's reflog to the destination and appends one new "branch: copied from <src>" entry (old_id=null, new_id=src tip). Reflog files are oldest-first on disk (read_reflog reverses for @{0} display), so the new entry is appended after the copied bytes, not prepended before them, despite the ticket's "prepended at the top" phrasing (which describes display order, not file bytes). - New rename_branch_reflog — mirrors `git branch -m`: moves the reflog file and appends a "branch: renamed from <old>" entry (old_id=new_id=tip, since the commit doesn't change). Destination written and os.replace'd before the source is unlinked, so a failed write preserves the original. - New append_head_only_reflog: when renaming the checked-out branch, the HEAD log needs its own "renamed from X to Y" entry without double-writing the branch log (append_reflog always writes both logs). - branch.py's create/copy/rename paths wired to the above; operation strings standardized to lowercase-first present-tense ("branch: created from", "branch: copied from", "branch: renamed from") matching checkout.py's existing convention, replacing the old inconsistent "branch: Created from" capitalization.
Real bug found and fixed while building this: append_reflog's on-disk line format collapses to 4 whitespace-split tokens (instead of the 5 _parse_line requires) whenever author="" — which branch.py's create path had used since inception — making every "branch: created from X" entry silently unparseable and invisible to read_reflog/muse reflog. Fixed by switching branch.py's reflog writes to author="user", matching checkout.py's convention; the blast radius was isolated to branch.py (the only writer that ever used an empty author).
18 new/updated tests across tests/test_cmd_branch_copy_reflog.py (BC_01-07), tests/test_cmd_branch_rename_reflog.py (BC_08-15), and additions to tests/test_cmd_branch.py (BC_16-18) — all confirmed via genuine RED (reverted the branch.py wiring, 13/17 new tests failed as expected) → GREEN. Live-verified via muse-dev against a disposable /tmp repo: copy/rename both preserve full history, HEAD log correctly records a checked-out rename, old reflog path removed after rename.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Semantic Changes
55 symbols
Files Changed
+2
~3
1249 in snapshot
0 comments
muse hub commit comment sha256:f7bf283e6cd64892d61560b1d4508b52612b0d8cd2c7d02a17fcdbbd3ae75b66 --body "your comment"
No comments yet. Be the first to start the discussion.