Skip to content

Conversation

kapral18
Copy link
Contributor

@kapral18 kapral18 commented Sep 13, 2025

Fixes: #4890

  • Fix file status parsing to handle Git copy operations when status.renames=copies is configured
  • Extend status parser to recognize both "R" (rename) and "C" (copy) prefixes
  • Add comprehensive test coverage for copy status codes

The same issue from #4890
now is fixed

image

@kapral18 kapral18 force-pushed the fix-copy-status-support branch 2 times, most recently from 048fcc8 to 605ab26 Compare October 8, 2025 21:57
@stefanhaller stefanhaller added the bug Something isn't working label Oct 14, 2025
Fixes jesseduffield#4890

When Git is configured with status.renames=copies, it can produce
status codes starting with "C" (copy) in addition to "R" (rename).
The file loader was only checking for "R" prefixes, causing copy
operations to be parsed incorrectly and breaking file staging.

This fix extends the status parser to handle both "R" and "C"
prefixes, ensuring proper support for Git's copy detection feature.

Fixes file staging issues when using status.renames=copies configuration.
@stefanhaller stefanhaller force-pushed the fix-copy-status-support branch from 605ab26 to e6f3313 Compare October 14, 2025 09:57
@stefanhaller
Copy link
Collaborator

Sorry for the long delay in reviewing this. LGTM, thanks for the contribution!

Just one observation because I'm not familiar with git's behavior here: the behavior of git's copy detection seems a little weird to me. It only seems to detect a file as being a copy if the original file also occurs in the diff somehow, either because it was moved (like in the example in #4890), or because it was modified. In other words, if I modify a file foo and then copy it, it shows M foo and C foo -> foo2, but if I then discard the modifications to foo, it says A foo2. I find this hard to understand. Nothing to do with your PR of course.

@stefanhaller stefanhaller merged commit 6b5b493 into jesseduffield:master Oct 14, 2025
12 checks passed
@kapral18 kapral18 deleted the fix-copy-status-support branch October 14, 2025 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

git config status.renames=copies messes up staging

2 participants