Git 结帐并通过 Lib2 提取 GitSharp

Git Checkout and Pull through Lib2GitSharp

我正在尝试构建一个应用程序,定期扫描各种 Git 分支上的提交历史记录,并报告作者和有关提交消息的各种详细信息。为此,我已经开始使用 LibGit2Sharp。它本身非常适合访问提交,但是我 运行 在尝试更新存储库时遇到了麻烦。

每次我的任务 运行s,我都需要从远程存储库中获取最新的更改。我的理解是我需要检查跟踪有问题的远程分支的本地分支,然后执行提取或拉取。我正尝试在我的应用程序中按如下方式执行此操作:

// Get the branch
var localBranch = repo.Branches[localbranchName];

// Switch to this branch
if (!localBranch.IsCurrentRepositoryHead)
{
    repo.Checkout(localBranch);
}

// Do a pull to get latest
var result = repo.Network.Pull(signature, new PullOptions());

但是,当运行ning repo.Checkout(localBranch);

时,我总是得到以下异常
LibGit2Sharp.LibGit2SharpException: Failed to mmap. No data written: Not enough storage is available to process this command.
  at LibGit2Sharp.Core.Ensure.HandleError(Int32 result) in c:\Git\libgit2sharp\LibGit2Sharp\Core\Ensure.cs:line 160
  at LibGit2Sharp.Core.Ensure.ZeroResult(Int32 result) in c:\Git\libgit2sharp\LibGit2Sharp\Core\Ensure.cs:line 178
  at LibGit2Sharp.Core.Proxy.git_checkout_tree(RepositorySafeHandle repo, ObjectId treeId, GitCheckoutOpts& opts) in c:\Git\libgit2sharp\LibGit2Sharp\Core\Proxy.cs:line 295
  at LibGit2Sharp.Repository.CheckoutTree(Tree tree, IList`1 paths, IConvertableToGitCheckoutOpts opts)...

当我在 Git Bash 和 运行 我的程序中手动签出该分支(绕过对签出命令的需要)时,它在调用 Pull 时失败同样的例外。

关于这个错误的内容并不多,但到目前为止我所看到的一切都导致了 "Your repository is just too large for the library to handle." 我使用的存储库是一个中等规模的企业存储库,但是这些命令在控制台中执行得非常快。我现在想知道是否需要将我的控制台包装在处理程序中并执行结帐并直接通过 CLI 拉取(糟糕)。

有什么想法吗?

对此深表歉意。对 libgit2 和 LibGit2Sharp 进行了一些更改以处理内存使用和更好地处理内存映射,尤其是对于大型(或大量)包文件。

您将在下一个版本的 LibGit2Sharp 中看到这些改进。在那之前,从 nuget.org 安装预发布包应该可以解决这个问题。