Merge pull request #6717 from herrerog/fix-rename-detection

merge: fix incorrect rename detection for empty files.
This commit is contained in:
Edward Thomson
2024-02-20 16:41:40 +00:00
committed by GitHub
15 changed files with 36 additions and 0 deletions

View File

@@ -1225,6 +1225,13 @@ static int merge_diff_mark_similarity_exact(
if (!GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_src->ancestor_entry))
continue;
/*
* Ignore empty files because it has always the same blob sha1
* and will lead to incorrect matches between all entries.
*/
if (git_oid_equal(&conflict_src->ancestor_entry.id, &git_oid__empty_blob_sha1))
continue;
if (!GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_src->our_entry)) {
error = deletes_by_oid_enqueue(ours_deletes_by_oid, &diff_list->pool, &conflict_src->ancestor_entry.id, i);
if (error < 0)

View File

@@ -350,3 +350,22 @@ void test_merge_trees_renames__cache_recomputation(void)
git_tree_free(our_tree);
git__free(data);
}
void test_merge_trees_renames__emptyfile_renames(void)
{
git_index *index;
git_merge_options *opts = NULL;
struct merge_index_entry merge_index_entries[] = {
{ 0100644, "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", 1, "bar" },
{ 0100644, "60b12be2d2f57977ce83d8dfd32e2394ac1ba1a2", 3, "bar" },
{ 0100644, "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", 0, "boo" },
{ 0100644, "e50a49f9558d09d4d3bfc108363bb24c127ed263", 0, "foo" },
};
cl_git_pass(merge_trees_from_branches(&index, repo,
"emptyfile_renames", "emptyfile_renames-branch",
opts));
cl_assert(merge_test_index(index, merge_index_entries, 4));
git_index_free(index);
}

Binary file not shown.

View File

@@ -0,0 +1,3 @@
x¥NI
1ôœWô]<5D>žì/þÀ´<>Žãa&#~ß(þÀ:ÕFQ\—åÖAÛ¸éMtrš8K0YàK&Ž¥Xk¢w—É™"è$pPwj²vÕ\RðhÑgI<>=ŘK*SDaMÚ*zö¹68åµ ç¹.<2E>ºÂ^†ûaGù?µãº`
­q6YØâ€î8ÛåÏÅ3­W<C2AD>^áBM½ùiQ†

View File

@@ -0,0 +1,2 @@
x<01><>A
B1C]<5D><14>¤<>س<EFBFBD> "n<><6E><17>س)<><7F>Bصً[إ<1B> صR¤أ^<5E>Moج<10>3<EFBFBD><33>c:d غc<D8BA><06>ْؤhCِ<43>i2FإG<D8A5>k<EFBFBD>Kzإ<7A>ـ:ط<>ض<05>ا<D988><D8A7>[<5B>ز<EFBFBD>j9<6A> zBً0Xظي!5و8ُ<38>ه<EFBFBD><D987>E<EFBFBD>ؤ;4~ت*uQo<51>$D<>

View File

@@ -0,0 +1,3 @@
x¥OIj1ÌY¯è»!´¶‘Áøâä­VÉA£ ËøûM~<7E>E÷Ö~&o>æ<10>ÌZ;§uB[¡JärN9z)ÚVÄb¼ú¥!Ç.Rj

‡$ÈŘKª:¢°!c ÝçÞ\˃F<C692>ï½·[?àKûbyê“{;ƒ<18>õÞ œpA-w<><77>òϵS[_iÀì<C380>{WOG‰Rï

View File

@@ -0,0 +1 @@
ea789495e0a72efadcd0f86a48f4c9ed435bb8a3

View File

@@ -0,0 +1 @@
ab347abd8cda4a0e3b8bb42bb620c0c72c7df779