Reverse diff --git path arguments - #94
Merged
Merged
Conversation
A reversed patch should identify its paths in the same order as git diff -R. Preserve Git’s original argument spelling so quoted and escaped names remain exact, and decline to rewrite headers whose boundaries cannot be established safely. Amp-Thread-ID: https://ampcode.com/threads/T-01a08a2d-ba87-7779-89ec-92cdd2c8b8cf Co-authored-by: Amp <amp@ampcode.com>
keegancsmith
added a commit
that referenced
this pull request
Sep 10, 2026
Git-derived fixtures guard the directional metadata and hunk behavior added in PR #92 without requiring Git during tests. Binary expectations retain the dual payload ordering because swapped index hashes select the inverse data, while diff header argument rendering stays orthogonal for compatibility with PR #94. Amp-Thread-ID: https://ampcode.com/threads/T-01a08a2d-c34e-7623-88c1-084780f7dd6d Co-authored-by: Amp <amp@ampcode.com>
keegancsmith
marked this pull request as ready for review
September 10, 2026 07:59
keegancsmith
added a commit
that referenced
this pull request
Sep 10, 2026
Git-derived fixtures guard the directional metadata and hunk behavior added in PR #92 without requiring Git during tests. Binary expectations retain the dual payload ordering because swapped index hashes select the inverse data, while diff header argument rendering stays orthogonal for compatibility with PR #94.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This follows #92 by reversing the two path arguments in the leading
diff --githeader, matching the direction emitted bygit diff -Ras well as the already-reversed extended headers.The implementation validates paths with the existing filename parser and swaps their original argument spellings, preserving Git quoting, escapes, non-ASCII path encodings, prefixes, spaces, and CRLF. Unquoted spaced paths are rewritten only when the parsed
FileDiffnames establish the exact boundary; genuinely ambiguous or malformed arguments are left unchanged instead of guessed.The tests use expectations captured from Git without invoking Git at runtime.
go test -race ./...,go vet ./..., andgit diff --checkpass.