Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make GIT_DIFF_SHOW_BINARY flag settable by users through CompareOptions #1967

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jburggraaf
Copy link

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 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:

  1. confirm that the default behaviour for binaries has not changed.
  2. 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.

Give users access to GIT_DIFF_SHOW_BINARY flag through CompareOptions to allow Patch data to contain binary deltas.

Add 2 test cases to verify default behaviour has not changed and that when the new option is exercised patches contains binary delta info as expected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant