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 calling git apply using 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 the libgit2 library. To give library users access to this flag I added it as a property of the CompareOptions class (ShowBinary) defaults false and maintains current expected functionality. Finally checking the value of CompareOptions.ShowBinary in the function Diff.BuildOptions so that the options are populated with this flag before being passed through to libgit2
Outcome:
If an instance of CompareOptions with the ShowBinary flag set to true is passed to any overload of Diff.Compare<Patch> that takes CompareOptions as a parameter, the resulting patch will have the necessary delta to create/update binary files when it is applied.
Testing:
Added 2 test scenarios:
confirm that the default behaviour for binaries has not changed.
confirm that if the ShowBinary flag is set to true that the diff contains delta information as expected
ran the full test suite to verify nothing was broken by this change.
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 apply
using 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 thelibgit2
library. To give library users access to this flag I added it as a property of theCompareOptions
class (ShowBinary
) defaults false and maintains current expected functionality. Finally checking the value ofCompareOptions.ShowBinary
in the functionDiff.BuildOptions
so that the options are populated with this flag before being passed through tolibgit2
Outcome:
If an instance of
CompareOptions
with theShowBinary
flag set to true is passed to any overload ofDiff.Compare<Patch>
that takesCompareOptions
as 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.