Skip to content

Keep both paths when a diff command names two files - #85

Open
SashaMIT wants to merge 1 commit into
bluekeyes:masterfrom
SashaMIT:fix/diff-command-names
Open

SashaMIT wants to merge 1 commit into
bluekeyes:masterfrom
SashaMIT:fix/diff-command-names

Conversation

@SashaMIT

@SashaMIT SashaMIT commented Oct 11, 2026 •

Copy link
Copy Markdown

Summary

A diff -u old new patch stored both paths as the new file. Parse then reported one path instead of a change from the old file to the new file. When the patch starts with a diff command that names two files, both paths are kept. Patches that are only --- and +++ still use the existing one-name heuristic, including backup names such as file and file~.

The parser looks one line further ahead so that command can see the fragment header the same way a traditional header does.

Fixes #65

Test plan

  • TestParseDiffCommandKeepsDistinctNames failed before the change (both names were the new path) and passes after it
  • go test ./...
  • golangci-lint run ./...

A diff -u of two different files was parsed as the new path only.
Patches that are only --- and +++ still use the existing name heuristic.
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.

File.OldName and File.NewName are the same when they shouldn't be

1 participant