Unable to force checkout a modified working tree file that differs only in the type of line endings
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 42/100
Direção de pesquisa
Comece em src/libgit2/checkout.c, em checkout_is_workdir_modified, e inspecione como checkout_action_with_wd lida com arquivos filtrados da árvore de trabalho. Reproduza a falha com o ponto de teste checkout::crlf, incluindo checkout::crlf::with_ident, e rastreie as comparações de OID existentes. Está concluído quando um checkout forçado substitui um arquivo modificado por CRLF pelo conteúdo de destino sem causar regressões ou falhas esporádicas nos testes.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Scenario: A file is stored in the repository using LF line endings and checked out in the working tree with LF line endings. If the working tree file then has its line endings changed to CRLF, a force checkout of the file does not replace the content, and the file remains modified.
Here is a test point that fails:
void test_checkout_crlf__filtered_working_tree_file_equals_target(void)
{
git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
opts.checkout_strategy = GIT_CHECKOUT_FORCE;
cl_git_mkfile("./crlf/.gitattributes", "* text=auto\n");
if (GIT_EOL_NATIVE == GIT_EOL_CRLF) {
cl_git_mkfile("./crlf/all-lf", ALL_LF_TEXT_AS_LF);
cl_git_mkfile("./crlf/all-crlf", ALL_CRLF_TEXT_AS_LF);
} else {
cl_git_mkfile("./crlf/all-lf", ALL_LF_TEXT_AS_CRLF);
cl_git_mkfile("./crlf/all-crlf", ALL_CRLF_TEXT_AS_LF);
}
cl_git_pass(git_checkout_head(g_repo, &opts));
if (GIT_EOL_NATIVE == GIT_EOL_CRLF) {
check_file_contents("./crlf/all-lf", ALL_LF_TEXT_AS_CRLF);
check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_AS_CRLF);
} else {
check_file_contents("./crlf/all-lf", ALL_LF_TEXT_RAW);
check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_RAW);
}
}
I debugged this and found that checkout_is_workdir_modified compares the base/target oid with the FILTERED oid of the working tree file. As the filtered version would have the CRLF line endings switched to LF line endings, checkout_is_workdir_modified returns false.
I tried to augment is_workdir_base_or_new to also compare the oid of the actual file on disk computed with git_odb__hashfile, but another test point checkout::crlf::with_ident then (sporadically!) fails. Probably a performance issue too.
Checkout logic looks quite complicated and I wonder if the cases in checkout_action_with_wd need splitting out further.
- Linguagem predominante
- C
- Estrelas
- 10.6k
- Forks
- 2.7k
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de libgit2/libgit2
-
hashsig: the similarity heap evicts but never inserts, so the retained set is not the extremes Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 86/100
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 74/100
Todas as issues de libgit2/libgit2
Issues semelhantes
-
task
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
vsanthanam/JBird#429 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
-
bug documentation
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
es-ude/OnDeviceTraining#459 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
bilelmoussaoui/gobject-linter#199 · 1 comentário ·
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
bradcypert/plum#53 ·