libgit2 / libgit2/libgit2sharp

CheckoutConflictException on Commands.Checkout

Aberta
#1,597 1 comentário 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Linguagem predominante
C#
Estrelas
3.5k
Forks
925
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

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

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Direção de pesquisa

Comece com a chamada reproduzida de Commands.Checkout, o tratamento de CheckoutConflictException e o estado observado de Repo.Index ConflictCollection no LibGit2Sharp v0.25.2. Compare as flags de notificação do checkout e o comportamento da exceção usando o exemplo de Unity fornecido no ambiente Windows e .NET indicado. O trabalho estará concluído quando o comportamento da exceção e do estado de conflito for explicado, ou quando a documentação ou correção necessária for identificada.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
csharp, git
Domínio
devtools
Tipo de issue
Bug
Dificuldade
3/5
Tempo estimado
1-2 dias
Status de atividade
Estagnada
Clareza
Precisa de esclarecimento
Facilidade para iniciantes
25/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.