libgit2 / libgit2sharp

Git + .NET = ❤
http://libgit2.github.com
MIT License
3.12k stars 878 forks source link

Push fails with "No error message has been provided by the native library" when trying to push large files #2012

Open GirtsZemitis opened 1 year ago

GirtsZemitis commented 1 year ago

I am not able to push large files to origin with pre-release 0.27.0-preview-0182. The same code worked with latest stable release Ending up with exception and message: "No error message has been provided by the native library" Tried to push a new json file which is 18MB large. I did not check what file size is the breaking point, but if needed can try to investigate that too.

Adding reproduction steps with snippets of my code, hope this is enough, otherwise please ask for more.

Reproduction steps

  1. Clone repository and create branch
    
    Repository.Clone(githubRepoUrl, $"./{folderName}", 
    new CloneOptions { CredentialsProvider = _gitHubClientWrapper.CredentialsProvider() });

using (var repo = new Repository($"./{folderName}")) { repo.CreateBranch(newBranchName); }

2.  Create large file. I just generated a large list of objects serialized into json. Got around 18mb of json file.
3.  Commit and push the branch to origin

using (var repo = new Repository($"./{folderName}")) { Branch branch = repo.Branches[newBranchName]; Commands.Checkout(repo, branch); Commands.Stage(repo, "*"); Signature committer = new Signature("Github bot", "@bot", DateTime.Now);

try
{
    repo.Commit("Comit message", committer, committer);
    Remote remote = repo.Network.Remotes["origin"];
    repo.Branches.Update(branch, b => b.Remote = remote.Name, b => b.UpstreamBranch = branch.CanonicalName);
    repo.Network.Push(branch, new PushOptions
    {
        CredentialsProvider = _gitHubClientWrapper.CredentialsProvider(),
    });

}
catch (EmptyCommitException)
{
    _logger.LogInformation("There's nothing to commit.");
    return;
}

}


### Expected behavior
Push is successful.

### Actual behavior
Push fails with exception and message "No error message has been provided by the native library"

### Version of LibGit2Sharp (release number or SHA1)
0.27.0-preview-0182

### Operating system(s) tested; .NET runtime tested
Windows11, .NET 7
GirtsZemitis commented 1 year ago

I pinpointed the version where this starts to happen.

0.27.0-preview-0096 first pre-release that does not work 0.27.0-preview-0034 last pre-release that works