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

Getting patch with unicode characters confuses git apply #1974

Open
tapika opened this issue Jun 9, 2022 · 1 comment
Open

Getting patch with unicode characters confuses git apply #1974

tapika opened this issue Jun 9, 2022 · 1 comment

Comments

@tapika
Copy link

tapika commented Jun 9, 2022

var patches = repo0.Diff.Compare<Patch>(commit1?.Tree, commit2.Tree, Enumerable.Repeat(change.Path, 1), compareOptions: compareOptions);

Getting patches + applying them to file does not seems to work if there are unicode characters in file itself.

Have tried to save it in utf8, but problem still persists.

As a walkaround to this problem, I have added extra comparison that there aren't any unicode characters.

// If we have some unicode characters, then cannot be handled as text diff.
canBeHandledAsTextPatch = strpatches.All(c => c <= 255);

But, libgit itself has built in support for patching, See https://libgit2.org/libgit2/#HEAD, git_apply* function calls - but none of these operations seems to be supported in libgit2sharp.

@jburggraaf
Copy link

hi @tapika looks like a similiar issue to mine There is no way to make Diff Patch contain any binary deltas. I've submitted a PR !1967.

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

No branches or pull requests

2 participants