Make GIT_DIFF_SHOW_BINARY flag settable by users through CompareOptions #1967
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.
Addresses Bug#1966
Scenario:
Need to create a patch file that contains binary deltas using
Diff.Compare<T>function. This is needed for binary files to be created/updated when callinggit applyusing the generated patch file.Effort:
The necessary flag already existed in
Core.GitDiff.GitDiffOptionFlags(GIT_DIFF_SHOW_BINARY) and some quick research showed that this flag is recognized by thelibgit2library. To give library users access to this flag I added it as a property of theCompareOptionsclass (ShowBinary) defaults false and maintains current expected functionality. Finally checking the value ofCompareOptions.ShowBinaryin the functionDiff.BuildOptionsso that the options are populated with this flag before being passed through tolibgit2Outcome:
If an instance of
CompareOptionswith theShowBinaryflag set to true is passed to any overload ofDiff.Compare<Patch>that takesCompareOptionsas a parameter, the resulting patch will have the necessary delta to create/update binary files when it is applied.Testing:
Added 2 test scenarios:
ran the full test suite to verify nothing was broken by this change.