CheckoutConflictException on Commands.Checkout

オープン
#1,597 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
csharp, git
領域
devtools

調査の方向性

再現された Commands.Checkout 呼び出し、その CheckoutConflictException の処理、および LibGit2Sharp v0.25.2 で観測された Repo.Index ConflictCollection の状態から始めます。指定された Windows および .NET 環境で、提供された Unity の例を使って checkout の通知フラグと例外の挙動を比較します。例外と競合状態の挙動を説明するか、必要なドキュメントまたは修正を特定できれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Hi!

I want to create a UI to make resolving conflicts for a user as easy as possible. At the moment after i have created a conflict by make some changes local and in the repository in the same line of the same file, i want to do first a checkout to get informations about the conflicted file

Reproduction steps

Here is my code to make the checkout of a given Repository:

public void Checkout()
    {
        try
        {
            UnityEngine.Debug.Log("starting checkout");
            CheckoutOptions opts = new CheckoutOptions();
            opts.OnCheckoutNotify = (string path, CheckoutNotifyFlags notify) =>
            {
                switch (notify)
                {
                    case CheckoutNotifyFlags.Conflict:
                        UnityEngine.Debug.Log("conflicted file found at: " + path);
                        return true;
                    case CheckoutNotifyFlags.Ignored:
                        UnityEngine.Debug.Log("ignored file found at: " + path);
                        return true;
                    case CheckoutNotifyFlags.None:
                        UnityEngine.Debug.Log("unchanged file found at: " + path);
                        return true;
                    case CheckoutNotifyFlags.Untracked:
                        UnityEngine.Debug.Log("untracked file found at: " + path);
                        return true;
                    case CheckoutNotifyFlags.Updated:
                        UnityEngine.Debug.Log("updated file found at: " + path);
                        return true;
                    default:
                        UnityEngine.Debug.Log("dirty file at: " + path);
                        return true;
                }
            };
            opts.CheckoutNotifyFlags = CheckoutNotifyFlags.None |
                                       CheckoutNotifyFlags.Dirty |
                                       CheckoutNotifyFlags.Ignored |
                                       CheckoutNotifyFlags.Conflict |
                                       CheckoutNotifyFlags.Untracked |
                                       CheckoutNotifyFlags.Updated;
            

            Branch actualRemote = Repo.Branches["origin/" + Repo.Head.FriendlyName];
            Commands.Checkout(Repo, actualRemote.Tip.Tree, opts, "");
        }
        catch (CheckoutConflictException e)
        {
            UnityEngine.Debug.Log(e.Message);
        }
    }

Repo is the actual Repository, and it contains in my test example 1 conflicted file.

Expected behavior

I don't find any detailed guide, how to resolve conflicts with LibGit2Sharp, but if i understand it right, the checkout command should write the conflicted files in the ConflictCollection of the index of the repository.

Actual behavior

If i do the checkout with the code above, the conflicted file(s) will be found, but the catch-clause will be triggered and the ConflictCollection of Repo.Index will be still empty. Can somebody explain how this whole process works, how i can use it right and why the exception in the code will be triggered?

Version of LibGit2Sharp (release number or SHA1)

LibGit2Sharp v0.25.2

Operating system(s) tested; .NET runtime tested

Win 10 64bit, .NET Framework 4.6.1

主要言語
C#
スター
3.5k
フォーク
925
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

libgit2/libgit2sharp のほかの issue

libgit2/libgit2sharp の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。