Skip to content

Pass --no-renames from Diff unless detection is requested, matching Patch [patch] - #180

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/136-diff-rename-detection
Oct 6, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/136-diff-rename-detection

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #136

What changed

  • When neither DetectRenames() nor DetectCopies() is called, GitDiffBuilder now passes --no-renames. Git has defaulted diff.renames to true since 2.9, and that default meant four problems:
  • The DetectRenames() / DetectCopies() XML docs now say detection is off unless requested, whatever diff.renames is set to. This matches IGitPatchBuilder.DetectRenames.
  • When DetectRenames() and/or DetectCopies() is called, the arguments are the same as before.

Tests

  • GitPatchRoundTripTests.DiffReportsAStagedRenameAsPatchDoesWhateverTheHostsDiffRenamesAsync runs against real git with diff.renames set to true, false and copies. It checks three things:
    • Without DetectRenames(), Diff().Staged() returns the same Added and Deleted entries as Patch().Staged().
    • With DetectRenames(), it returns Renamed old.txt -> new.txt.
    • The results are the same for all three settings.
  • GitDiffBuilderTests.TurnsRenameDetectionOffUnlessRequested is a new test, and BuildsTheDefaultDiffVector has been updated.

With the fix temporarily reverted, the unit tests and the true and copies rows fail. The false row passes either way, which is expected. With the fix in place, the full suite passes locally on Linux: 737/737.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GUKjHWJy9iwpdVJ1NKRU1M


Generated by Claude Code

…atch [patch]

Git defaults diff.renames to true, so Diff() reported a git mv as a rename
without DetectRenames(), could not have detection turned off, reported
copies under diff.renames=copies, and disagreed with Patch(), which already
pins rename detection explicitly.

Fixes #136

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01GUKjHWJy9iwpdVJ1NKRU1M
@sonarqubecloud

sonarqubecloud Bot commented Oct 6, 2026

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit f8e33af into main Oct 6, 2026
17 of 18 checks passed
@matt-edmondson
matt-edmondson deleted the fix/136-diff-rename-detection branch October 6, 2026 12:34
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.

Diff() reports renames without DetectRenames() (git's diff.renames default), so it disagrees with Patch() and rename detection can't be turned off

2 participants