fix: add support for unstaged rename and copy status codes#142
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds support for two previously unhandled git status codes: unstaged rename ( R) and unstaged copy ( C). These status codes could previously cause fatal parse errors or be silently dropped in compound codes like MR or CR. The implementation follows the same pattern established in PR #141 for intent-to-add support.
Changes:
- Added
ChangeUnstagedRenamedandChangeUnstagedCopiedenum variants with corresponding metadata - Added decoding logic for Y='R' and Y='C' in the secondary status code parser
- Added comprehensive test coverage including unit tests and rendering tests with golden files
- Updated documentation to reflect the addition of 2 new variants (18 → 20 total)
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/gitstatus/gitstatus.go | Added two new ChangeType enum variants and their metadata entries |
| internal/gitstatus/porcelainv1/process.go | Added decoding logic for Y='R' and Y='C' status codes |
| internal/gitstatus/porcelainv1/process_test.go | Added unit tests for R, C, and compound MR codes |
| internal/cmd/status/render_test.go | Added integration test case with multiple rename/copy scenarios |
| internal/cmd/status/testdata/statuslist-unstaged_rename_copy.display.ansi.golden | Golden file for visual output validation |
| internal/cmd/status/testdata/statuslist-unstaged_rename_copy.parsedata.txt.golden | Golden file for parse data validation |
| docs/git-status-parsing.md | Updated ChangeType count and table to include new variants |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
These were the last two currently known unhandled XY codes from the git status short format. ` R` and ` C` caused a fatal parse error; compound codes like `MR` or `CR` silently dropped the unstaged rename/copy. Follows the same pattern established in #141 for intent-to-add [.A]. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
d376aa1 to
d7ca1c8
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| { | ||
| // Compound code: staged modified + unstaged renamed | ||
| []byte("MR"), | ||
| []gitstatus.ChangeType{ | ||
| gitstatus.ChangeStagedModified, | ||
| gitstatus.ChangeUnstagedRenamed, | ||
| }, | ||
| }, | ||
| { | ||
| // Compound code: staged copied + unstaged renamed | ||
| []byte("CR"), | ||
| []gitstatus.ChangeType{ | ||
| gitstatus.ChangeStagedCopied, | ||
| gitstatus.ChangeUnstagedRenamed, | ||
| }, | ||
| }, | ||
| { | ||
| // Compound code: staged modified + unstaged copied | ||
| []byte("MC"), | ||
| []gitstatus.ChangeType{ | ||
| gitstatus.ChangeStagedModified, | ||
| gitstatus.ChangeUnstagedCopied, | ||
| }, | ||
| }, |
There was a problem hiding this comment.
The new XY decoding is covered at the unit level via Test_extractChangeTypes, but there’s still no Process()-level regression fixture that includes actual R / C entries from git status --porcelain=v1 -z (including the rename/copy path/origpath encoding). Adding a small v1z fixture + TestProcess case would better protect against future regressions in entry conversion and OrigPath handling.
There was a problem hiding this comment.
In the future, I plan to add a "mega case" porcelain file from big real world scenario, which should hopefully handle many of these cases. For now, I will keep this PR fairly atomic.
Summary
ChangeUnstagedRenamed(Y=R) andChangeUnstagedCopied(Y=C) — the last two currently known unhandled XY codes from the git status short formatRandCpreviously caused a fatal parse error; compound codes likeMRorCRsilently dropped the unstaged rename/copyY='A')