Centralize Git extended-header parsing - #96
Merged
Conversation
keegancsmith
force-pushed
the
k/git-extended-header-parser
branch
from
September 10, 2026 08:04
8aa20ef to
a2748ad
Compare
Parsing empty Git diffs and reversing them must agree on which headers and directional pairs carry meaning. A single internal parsed view now owns that vocabulary while retaining raw lines, so future changes cannot make those paths drift apart. Amp-Thread-ID: https://ampcode.com/threads/T-01a08a2d-b04d-71bd-a9b5-cf65f1543481 Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-01a08a17-d51a-71a5-a028-1399ee2700e4
keegancsmith
force-pushed
the
k/git-extended-header-parser
branch
from
September 10, 2026 08:07
a2748ad to
2141c21
Compare
keegancsmith
marked this pull request as ready for review
September 10, 2026 08:08
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.
PR #92 taught both empty-diff parsing and reversal about the same Git extended headers, but each path independently encoded the recognized prefixes and directional pairs. This follow-up introduces an unexported parsed view that classifies those raw header lines once and defines the mode, rename, and copy pairs in one place.
handleEmptyuses that view to recognize the same exact layouts as before, while reversal uses it to preserve the existing transformations and copy rejection.FileDiff.Extendedremains a slice of the original strings. Unknown headers remain unclassified and untouched, CRLF suffixes remain part of raw values whenKeepCRis enabled, and malformed layouts retain their existing parse errors and reversal behavior. The tests exercise raw CRLF preservation, unknown and malformed headers, incomplete directional pairs, and copy rejection.The rebase incorporates the exported copy sentinel from #93 and
diff --gitargument reversal from #94 without changing either behavior.Validated with
go test -race ./...,go vet ./..., andgit diff --check.