我正在尝试从本地文件系统克隆git存储库:
using System;
using LibGit2Sharp;
class Program
{
static void Main()
{
var sourceUrl = @"file:///c:/work/libgit2sharp";
using (Repository.Clone(sourceUrl, "targetDir", bare: true))
{
Console.WriteLine("repository successfully cloned");
}
}
}
我得到一个例外:
Unhandled Exception: LibGit2Sharp.LibGit2SharpException: An error was raised by libgit2. Category = Odb (Error).
Failed to find the memory window file to deregister
at LibGit2Sharp.Core.Ensure.Success(Int32 result, Boolean allowPositiveResult) in c:\work\libgit2sharp\LibGit2Sharp\Core\Ensure.cs:line 85
at LibGit2Sharp.Core.Proxy.git_clone_bare(String url, String workdir, git_transfer_progress_callback transfer_cb) in c:\work\libgit2sharp\LibGit2Sharp\Core\Proxy.cs:line 219
at LibGit2Sharp.Repository.Clone(String sourceUrl, String workdirPath, Boolean bare, Boolean checkout, TransferProgressHandler onTransferProgress, CheckoutProgressHandler onCheckoutProgress) in c:\work\libgit2sharp\LibGit2Sharp\Repository.cs:line 431
at Program.Main() in c:\work\ConsoleApplication1\Program.cs:line 10
我也尝试了以下源网址:
var sourceUrl = @"c:\work\libgit2sharp\.git\";
并得到另一个例外:
Unhandled Exception: LibGit2Sharp.LibGit2SharpException: An error was raised by libgit2. Category = Config (Error).
Failed to parse config file: Unexpected end of file while parsing multine var (in c:/work/ConsoleApplication1/bin/Debug/targetDir/config:23, column 0)
at LibGit2Sharp.Core.Ensure.Success(Int32 result, Boolean allowPositiveResult) in c:\work\libgit2sharp\LibGit2Sharp\Core\Ensure.cs:line 85
at LibGit2Sharp.Core.Proxy.git_clone_bare(String url, String workdir, git_transfer_progress_callback transfer_cb) in c:\work\libgit2sharp\LibGit2Sharp\Core\Proxy.cs:line 219
at LibGit2Sharp.Repository.Clone(String sourceUrl, String workdirPath, Boolean bare, Boolean checkout, TransferProgressHandler onTransferProgress, CheckoutProgressHandler onCheckoutProgress) in c:\work\libgit2sharp\LibGit2Sharp\Repository.cs:line 431
at Program.Main() in c:\work\ConsoleApplication1\Program.cs:line 12
targetDir
永远不会被创建。
如果另一方面我使用HTTP传输,Repository.Clone
方法可以正常工作:
var sourceUrl = "https://github.com/libgit2/libgit2sharp";
所以我的问题是,如果我做错了,或者这是不受支持的功能还是原生git2.dll
中的错误?
答案 0 :(得分:4)
实际上,所以我的问题是,如果我做错了,或者这是不受支持的功能还是原生git2.dll中的错误?
两者都是。
好消息是最近合并了来自 BenStraub 的拉取请求。这个 pull request 实现了本地提取传输,这应该可以解决问题。
LibGit2Sharp将在接下来的几天内使用新版本的libgit2二进制文件进行更新,这将允许您执行本地克隆/获取。我会在完成后立即更新此答案。
此 test 显示如何对本地存储库进行克隆和推送。