LibGit2Sharp 1冲突阻止结账

时间:2015-11-05 13:30:20

标签: c# .net git libgit2 libgit2sharp

我目前遇到的问题是,使用libgit2sharp的应用程序总是会崩溃并显示消息:

  

1冲突阻止结账

尝试拨打repo.Pull

奇怪的是,如果我打印本地存储库的状态,它们在存储库中没有变化。

我甚至尝试重置存储库,或者检查文件,但没有任何帮助。这是我的代码:

using (LibGit2Sharp.Repository repo = new LibGit2Sharp.Repository(path))
{
    var tipId = repo.Head.Tip.Tree;
    Log.LogManagerInstance.Instance.Info("HEAD tree id: " + tipId.Id.ToString());

    // Pull changes
    PullOptions options = new PullOptions();

    options.FetchOptions = new FetchOptions();
    options.MergeOptions = new MergeOptions();

    // ! Only for trying to fix the bug. Should not be here
    options.MergeOptions.FileConflictStrategy = CheckoutFileConflictStrategy.Theirs;

    repo.Reset(repo.Head.Tip);
    // ! --

    options.FetchOptions.CredentialsProvider = CredentialsHandler;

    Log.LogManagerInstance.Instance.Info("Try pull from remote repository");

    // Pull changes from network
    var result = repo.Network.Pull(new LibGit2Sharp.Signature(username, mail, new DateTimeOffset(DateTime.Now)), options);

    if (result != null && result.Commit != null)
    {
        Log.LogManagerInstance.Instance.Info("Pulled from remote branch, new tree id: " + result.Commit.Tree.Id.ToString());

        // get difference in the git tree (file-system)
        var diffs = repo.Diff.Compare<TreeChanges>(tipId, result.Commit.Tree);

        MergeTreeChangesToDatabase(diffs, path);
    }
    else
    {
        Log.LogManagerInstance.Instance.Info("Local repository is up-to-date with the remote branch");
    }
}

非常感谢。

修改

  

使用预发布0.22似乎解决了我的问题。

1 个答案:

答案 0 :(得分:0)

版本0.22解决了所有问题。