0
votes

I am trying to use LibGit2Sharp in Unity 2018.2 beta, because previous versions of Unity doesn't support .NET Framework 4.7.1, which will be needed for LibGit2Sharp.

I wanted to try a few things first and came across the following problems:

  1. if I try to clone a repository (I have used the example on GitHub first: https://github.com/libgit2/libgit2sharp/wiki/git-clone), I get an "LibGit2SharpException: failed to send request" error in Unity.

  2. I have also tried to get information from a working copy. I create a Repository with new Repository(string path), get the RepositoryStatus from it with rep.RetrieveStatus(new StatusOptions()). Now, if I try to access the state of files, it causes a crash in Unity. No matter if I iterate through all files and want to print file.State, or want to get a specific FileStatus list from the whole status (example: status.Added). However, printing the filepaths works.

  3. Fetching does not works either for me, it throws the same exception as the clone command.

I think the second one is maybe just an issue, but clone and fetch should work.


Update: sadly, I keep facing problems in my project with libgit2sharp in Unity. I want to make a commit, now if i try to iterate through the StatusEntries to stage the files, Unity just crashes, but sometimes it works. It is really hard to reproduce the bug, and often I get different crashlog-entries for the same process. The last time I have tried today the error was:

0x00007FFB417386CE (git2-6311e88) [c:\projects\libgit2sharp-nativebinaries\libgit2\src\diff_generate.c:1352] git_diff_tree_to_index

I have created a test-repository in my program using the Github API and cloned this to my pc, this works fine so far. And then if I create some files in the folder and want to make a commit, I run into the error above. Sadly this is one of several other issues and I can't really make progress with my project.

I have installed libgit2sharp and binaries with the Nuget Package Manager of Visual Studio.

Does anyone have experience with LibGit2Sharp and maybe some ideas of what I could be doing wrong, or why these things don't work for me?

Update 2: I'm still trying to solve the problem. I have now tested multiple times the different ways to get informations about the file-status of a repository. The best way to do it in my project would be with Repository.RetrieveStatus(filePath), now if I try this, it throws an AmbiguousSpecificationException. Can somebody explain, what does this exactly mean and how can I avoid it? I have also tried to force a literal path evaluation with Repository.RetrieveStatus(new StatusOptions() { DisablePathSpecMatch = true }); as recommended in the message of the AmbiguousSpecificationException, but then Unity crashes with the error-log in the first Update of this Post.

1
I don't have any experience with Unity. But to clarify your point (2), you're actually crashing Unity? That's very odd... Is Unity doing something non-standard? Is it possible that they use Mono on Windows instead of the standard .NET Framework? - Edward Thomson
Thanks for your answer! Yes, exactly. Theoretisch exceptions in Point 1 anderen 3 was caused by instabile Internet Connection. As i have tried Point 2 a couple of time today again, suddenly it worked in the most tried. Unity Crashed only one time...so i keep testing and can find hopefully the exact Problem soon. - Kett Attila
Sorry for the bad english, my Phone tries to autocorrect words to german. "Theoretisch" = the, "anderen" = and - Kett Attila
Interesting! Yes, an unstable internet connection would definitely cause the behavior that you're seeing in (1) and (3). I'm glad that (2) worked, but yes, it would be good to be able to get a root cause to understand why it sometimes fails. - Edward Thomson

1 Answers

0
votes

I had the same problem where Unity crashed on RetrieveStatus(); call. Seems like this might be a bug in LibGit2Sharp since RetrieveStatus("filepath") worked for me. I used the latest libgit2sharp commit (0dcaefc) and Unity 2018.3.0f2.

I used the absolute filepath and "\" instead of "/" (running on Windows 10).