Skip to content

Reverse diff --git path arguments - #94

Merged
keegancsmith merged 1 commit into
masterfrom
k/reverse-diff-git-args
Sep 10, 2026
Merged

Reverse diff --git path arguments#94
keegancsmith merged 1 commit into
masterfrom
k/reverse-diff-git-args

Conversation

@keegancsmith

Copy link
Copy Markdown
Member

This follows #92 by reversing the two path arguments in the leading diff --git header, matching the direction emitted by git diff -R as 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 FileDiff names 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 ./..., and git diff --check pass.

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
keegancsmith marked this pull request as ready for review September 10, 2026 07:59
@keegancsmith
keegancsmith merged commit 688abd0 into master Sep 10, 2026
1 check passed
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.
@keegancsmith
keegancsmith deleted the k/reverse-diff-git-args branch September 10, 2026 08:03
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.

1 participant