Unable to force checkout a modified working tree file that differs only in the type of line endings
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 42/100
Direzione di ricerca
Inizia in src/libgit2/checkout.c, in corrispondenza di checkout_is_workdir_modified, e analizza come checkout_action_with_wd gestisce i file filtrati dell’albero di lavoro. Riproduci il problema con il test point checkout::crlf, incluso checkout::crlf::with_ident, e segui i confronti OID esistenti. Il lavoro è completo quando un checkout forzato sostituisce un file modificato da CRLF con il contenuto di destinazione senza causare regressioni o fallimenti sporadici dei test.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- C
- Stelle
- 10.6k
- Fork
- 2.7k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di libgit2/libgit2
-
hashsig: the similarity heap evicts but never inserts, so the retained set is not the extremes Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
Tutte le issue di libgit2/libgit2
Issue simili
-
task
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
vsanthanam/JBird#429 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
bug documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
es-ude/OnDeviceTraining#459 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
bilelmoussaoui/gobject-linter#199 · 1 commento ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
bradcypert/plum#53 ·