Closed Matt-Rouse closed 8 years ago
What version of libgit2/libgit2sharp are you using? Could you provide us with the stacktrace of the exception?
Libgit2sharp: Runtime version: v2.0.50727 Version: 0.16.0.0
Stacktrace: {"An error was raised by libgit2. Category = NoMemory (User).\r\nOut of memory"} at LibGit2Sharp.Core.Ensure.HandleError(Int32 result) at LibGit2Sharp.Core.Ensure.ZeroResult(Int32 result) at LibGit2Sharp.Core.Proxy.git_remote_connect(RemoteSafeHandle remote, GitDirection direction) at LibGit2Sharp.Network.DoFetch(RemoteSafeHandle remoteHandle, FetchOptions options) at LibGit2Sharp.Network.Fetch(Remote remote, IEnumerable`1 refspecs, FetchOptions options) at GitInterface.GitRepo.Pull() in c:\repos\git_tfs\gitTFS\GitInterface\GitRepo.cs:line 114
FWIW, I can't reproduce this on the libgit2 side, either on dev or on 65e9dc6 which should be the libgit2 version used by that libgit2sharp version.
Could you upload the solution you used please? Just as another confirmation that it's something I'm doing wrong rather than a bug in the code.
Either that or I could upload my example solution for you to take a look over?
@steamos
Indeed, we would be very interested if you could share with us a stripped down repro case
I did this on the libgit2 side, so there is nothing like a solution. I used the git-fetch example, with and without calling git_remote_set_fetch_refspecs
, but from the stacktrace you provided, a no-modifications version would do the same. The exact code you're using that causes the issue would be helpful. Does the issue happen with other hosting providers?
Ok so I created another solution and tried to fetch again, in this solution the fetch works... I'll continue to investigate.
I have done a bit more testing, it seems that my code works from everywhere except a UnitTest class, I've uploaded an example solution, with the username and password removed, which works fine when running the application normally, however when I run the unit test, it fails, I'm not sure if the error is related.
Solution can be found here: http://www.speedyshare.com/qR982/aRepoTest.zip
We were never able to reproduce this issue, and the code has changed so much since then that even if we did, a fix wouldn't make sense.
Been advised by nulltoken to open an issue re: http://stackoverflow.com/questions/22155904/libgit2sharp-nomemory-exception-on-fetch There's a bit more info on the StackOverflow thread but I'll summarise below.
I seem to be having an issue using fetch with a BitBucket repo over HTTPS, the code I'm using is:
this._repo = new Repository(workingDir); Credentials credentials = new Credentials() {Username = this._username, Password = this._password}; Remote remote = this._repo.Network.Remotes["origin"]; FetchOptions fetchOptions = new FetchOptions(); fetchOptions.Credentials = credentials; var branch = @"refs/heads/TestBranch:refs/remotes/origin/TestBranch"; this._repo.Network.Fetch(remote, new string[] { branch }, fetchOptions);
Only the final line it gives the following exception:
An error was raised by libgit2. Category = NoMemory (User).
Out of memory
I've added a public repo (https://bitbucket.org/matthewrouse1/testrepo/overview) or to use with git: htttps: https://bitbucket.org/matthewrouse1/testrepo.git this wasn't the original repo that I used however I have been able to reproduce the problem with.
The reproduction steps are pretty simple: Initialise repo (create bitbucket, do intiial commit etc) From libgit2sharp, try to pull using the above code.