CheckoutConflictException on Commands.Checkout

Offen
#1,597 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
25/100
Issue-Typ
Bug
Klarheit
Muss geklärt werden
Aktivitätsstatus
Veraltet
Tech-Stack
csharp, git
Bereich
devtools

Rechercherichtung

Beginnen Sie mit dem reproduzierten Aufruf von Commands.Checkout, seiner Behandlung von CheckoutConflictException und dem beobachteten Zustand von Repo.Index ConflictCollection unter LibGit2Sharp v0.25.2. Vergleichen Sie die Checkout-Benachrichtigungsflags und das Ausnahmeverhalten anhand des bereitgestellten Unity-Beispiels in der angegebenen Windows- und .NET-Umgebung. Erledigt ist die Aufgabe, wenn das Ausnahme- und Konfliktzustandsverhalten erklärt oder die erforderliche Dokumentation oder Korrektur identifiziert wurde.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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

Vorherrschende Sprache
C#
Sterne
3.5k
Forks
925
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus libgit2/libgit2sharp

Alle Issues in libgit2/libgit2sharp

Ähnliche Issues

Weitere Issues zu C#

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.