简体   繁体   English

LibGit2Sharp是否支持从本地文件系统克隆存储库?

[英]Does LibGit2Sharp support cloning a repository from the local file system?

I am trying to clone a git repository from the local file system: 我试图从本地文件系统克隆一个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");
        }
    }
}

and I get an exception: 我得到一个例外:

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

I've also tried the following source url: 我也尝试了以下源URL:

var sourceUrl = @"c:\work\libgit2sharp\.git\";

and got another exception: 并得到另一个例外:

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 is never created. 永远不会创建targetDir

If on the other hand I use HTTP transport, the Repository.Clone method works fine: 另一方面,如果我使用HTTP传输, Repository.Clone方法可以正常工作:

var sourceUrl = "https://github.com/libgit2/libgit2sharp";

So my question is if I am doing something wrong or if this is unsupported feature or a bug in the native git2.dll ? 所以我的问题是,如果我做错了,或者这是不受支持的功能还是原生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? 所以我的问题是,如果我做错了,或者这是不受支持的功能还是原生git2.dll中的错误?

A bit a both, actually. 实际上,两者都有点。

  • The first exception is clearly a bug. 第一个例外显然是一个错误。 This should not happen and will be troubleshot. 不应该发生,并且会遇到麻烦。
  • The second one requires a deeper analysis. 第二个需要更深入的分析。 Would you be so kind as to open a issue in the LibGit2Sharp project? 你是否愿意在LibGit2Sharp项目中打开一个问题?

Good news are that a pull request from BenStraub was recently merged. 好消息是BenStraub的拉动请求最近合并了。 This pull request implements the local fetch transport which should pretty solve the issue. 这个拉取请求实现了本地提取传输,这应该可以解决这个问题。

LibGit2Sharp will be updated in the following days with a new a new version of libgit2 binaries which should allow you perform a local clone/fetch. LibGit2Sharp将在接下来的几天内使用新版本的libgit2二进制文件进行更新,这将允许您执行本地克隆/获取。 I'll update this answer as soon as it's been done. 我会在完成后立即更新此答案。

Update 更新

This test shows how do to a Clone and a Push over against a local repository. 测试显示如何对本地存储库进行克隆和推送。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM