c#-LibGit2Sharp是否支持从本地文件系统克隆存储库?
作者:互联网
我正在尝试从本地文件系统克隆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
我也尝试了以下源URL:
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中的错误?
解决方法:
So my question is if I am doing something wrong or if this is unsupported feature or a bug in the native git2.dll?
实际上,两者都有一点.
>第一个例外显然是一个错误.这不应该发生,并且会引起麻烦.
>第二个需要更深入的分析.您是否愿意在LibGit2Sharp项目中打开问题?
好消息是,最近合并了来自BenStraub的提取请求.该pull request实现了本地提取传输,应该可以很好地解决该问题.
LibGit2Sharp将在接下来的几天中使用新的libgit2二进制新版本进行更新,该版本应允许您执行本地克隆/获取.完成后,我将立即更新此答案.
更新资料
此test显示了如何对本地存储库进行克隆和推送.
标签:libgit2sharp,libgit2,c 来源: https://codeday.me/bug/20191031/1977259.html