fix: prepend line origin chars in diff.print() output#213
Draft
monotykamary wants to merge 1 commit into
Draft
Conversation
The print() callback was using line.content() without the origin character, producing patch output missing +/-/ space prefixes on hunk body lines. Context lines got no space prefix, additions got no +, deletions got no -. Prepend the origin for context (space), addition (+), and deletion (-) lines. Other origins (F for file headers, H for hunk headers, B for binary, = > < for EOFNL markers) are excluded because their content is already fully formatted by libgit2 and should not have a prefix. Closes toss#212
|
@monotykamary is attempting to deploy a commit to the Toss Team on Vercel. A member of the Team first needs to authorize it. |
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.
Problem
diff.print()(default Patch format) was stripping the+/-/(space) line origin prefixes from hunk body lines, making the output unparseable for consumers that need to distinguish additions from deletions from context. Closes #212.Before
After
What changed
In
src/diff.rs, theprintcallback now readsline.origin()and prepends it for the three content-line origins (context,+addition,-deletion). Other origin types are excluded because their content is already fully formatted by libgit2:+-=\ No newline at end of file)><Fdiff --git,---,+++)H@@ ... @@)BBinary files ... differ)This applies to all
DiffFormatvariants that go through the print callback, not just Patch.Test plan
tests/diff.spec.ts"print diff with formatting" expectations to include+/-prefixes