Repository navigation
diff: emit deletions before insertions in unified diff on missing newline - #425
Closed
yunusarda-sudo wants to merge 1 commit into
Closed
yunusarda-sudo wants to merge 1 commit into
yunusarda-sudo wants to merge 1 commit into
Conversation
…line When the last line differs only by its newline, ensure that the deletion line (-) is placed before the insertion lines (+) in the unified diff hunk, matching GNU diff. Fixes uutils#405
Contributor
|
Isn't this a duplicate of #420? That PR already has a review from @sylvestre (asking to reuse |
Author
|
Closing in favor of #420 (addressed review feedback there). |
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.
When the last line of both files has the same text but only one of them ends with a newline,
-umust show it as a deletion plus an insertion.Previously, the deletion (
-) line was appended at the point where the line was matched inResult::Both, which caused it to appear in the middle of preceding+insertions in the hunk.Changes
Mismatch::expected_insert_pos(&self)to locate the start of insertions in the current change block, ensuring all deletion lines (-) and their optional trailing\ No newlineare inserted before additions (+).Result::Both(when one file is missing a trailing newline) as well asResult::Left.unified_missing_newline_deletions_firstintests/by-util/test_diff.rscovering both newline-difference directions.Fixes #405