Skip to content

Centralize Git extended-header parsing - #96

Merged
keegancsmith merged 1 commit into
masterfrom
k/git-extended-header-parser
Sep 10, 2026
Merged

Centralize Git extended-header parsing#96
keegancsmith merged 1 commit into
masterfrom
k/git-extended-header-parser

Conversation

@keegancsmith

@keegancsmith keegancsmith commented Sep 10, 2026

Copy link
Copy Markdown
Member

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. handleEmpty uses that view to recognize the same exact layouts as before, while reversal uses it to preserve the existing transformations and copy rejection.

FileDiff.Extended remains a slice of the original strings. Unknown headers remain unclassified and untouched, CRLF suffixes remain part of raw values when KeepCR is 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 --git argument reversal from #94 without changing either behavior.

Validated with go test -race ./..., go vet ./..., and git diff --check.

@keegancsmith
keegancsmith force-pushed the k/git-extended-header-parser branch from 8aa20ef to a2748ad Compare September 10, 2026 08:04
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
keegancsmith force-pushed the k/git-extended-header-parser branch from a2748ad to 2141c21 Compare September 10, 2026 08:07
@keegancsmith
keegancsmith marked this pull request as ready for review September 10, 2026 08:08
@keegancsmith
keegancsmith merged commit cf64c62 into master Sep 10, 2026
1 check passed
@keegancsmith
keegancsmith deleted the k/git-extended-header-parser branch September 10, 2026 08:10
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