Skip to content

fix: add support for unstaged rename and copy status codes#142

Merged
mroth merged 1 commit intomainfrom
mroth/push-nukqmyvsnwqu
Feb 21, 2026
Merged

fix: add support for unstaged rename and copy status codes#142
mroth merged 1 commit intomainfrom
mroth/push-nukqmyvsnwqu

Conversation

@mroth
Copy link
Owner

@mroth mroth commented Feb 21, 2026

Summary

  • Add ChangeUnstagedRenamed (Y=R) and ChangeUnstagedCopied (Y=C) — the last two currently known unhandled XY codes from the git status short format
  • R and C previously caused a fatal parse error; compound codes like MR or CR silently dropped the unstaged rename/copy
  • Follows the same pattern established in fix: add support for intent-to-add ([ A]) git status code #141 for intent-to-add (Y='A')

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ChangeUnstagedRenamed and ChangeUnstagedCopied enum 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>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +93 to +116
{
// 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,
},
},
Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@mroth mroth merged commit fe6f83a into main Feb 21, 2026
19 checks passed
@mroth mroth deleted the mroth/push-nukqmyvsnwqu branch February 21, 2026 03:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants