Skip to content

Getting patch with unicode characters confuses git apply #1974

Open
@tapika

Description

@tapika
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions