{{ message }}
Repository navigation
diff: report an xdiff failure instead of an empty diff - #7424
Open
cristianchiriac wants to merge 2 commits into
Open
cristianchiriac wants to merge 2 commits into
cristianchiriac wants to merge 2 commits into
Conversation
git_xdiff ignored the return value of xdl_diff and returned only the error recorded by the hunk and line callbacks. When xdiff fails, for example out of memory while preparing the diff, it does so before any callback runs, so git_patch_from_buffers and the other text diff users reported success with no hunks. Fixes libgit2#7420
patch_generated_from_sources set the patch's free function only once the file contents were loaded, so an earlier failure (such as running out of memory while normalizing the options) left git_patch_free unable to free the patch. Set it first.
This branch has not been deployed
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.

Fixes #7420.
git_xdiffdiscarded the return value ofxdl_diffand returned onlyxo->output.error, which only the hunk and line callbacks set. When xdiff fails (out of memory while preparing the environment or building the edit script), it fails before any callback runs, sogit_patch_from_buffersand the other text diff users (patch, diff, blame, merge) reported success with no hunks. A failure fromxdl_diffnow sets the output error when the callbacks didn't already. The allocation that failed has already set the out-of-memory error throughgit__malloc.Test:
diff::oom::patch_from_buffers_fails_or_has_the_hunkinstalls an allocator that fails the Nth allocation and runsgit_patch_from_bufferson a one-line change for every N, until it needs no more allocations. Each run must either fail or produce its one hunk.1 != 0(success reported with no hunks)-sdiff -sblame -smerge -sapply -spatch: 617 tests pass (MinGW gcc 16, Windows 11).