Skip to content

Commit 45d5579

Browse files
author
Edward Thomson
authored
Merge pull request libgit2#4119 from libgit2/ethomson/submodule_renames
rename detection: don't try to detect submodule renames
2 parents b4bd5e8 + 191474a commit 45d5579

19 files changed

+32
-3
lines changed

src/diff_tform.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -553,8 +553,8 @@ static int similarity_measure(
553553

554554
*score = -1;
555555

556-
/* don't try to compare files of different types */
557-
if (GIT_MODE_TYPE(a_file->mode) != GIT_MODE_TYPE(b_file->mode))
556+
/* don't try to compare things that aren't files */
557+
if (!GIT_MODE_ISBLOB(a_file->mode) || !GIT_MODE_ISBLOB(b_file->mode))
558558
return 0;
559559

560560
/* if exact match is requested, force calculation of missing OIDs now */

src/merge.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1075,7 +1075,7 @@ static int index_entry_similarity_inexact(
10751075
int score = 0;
10761076
int error = 0;
10771077

1078-
if (GIT_MODE_TYPE(a->mode) != GIT_MODE_TYPE(b->mode))
1078+
if (!GIT_MODE_ISBLOB(a->mode) || !GIT_MODE_ISBLOB(b->mode))
10791079
return 0;
10801080

10811081
/* update signature cache if needed */

tests/merge/trees/renames.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,3 +252,25 @@ void test_merge_trees_renames__no_rename_index(void)
252252

253253
git_index_free(index);
254254
}
255+
256+
void test_merge_trees_renames__submodules(void)
257+
{
258+
git_index *index;
259+
git_merge_options *opts = NULL;
260+
261+
struct merge_index_entry merge_index_entries[] = {
262+
{ 0100644, "cd3e8d4aa06bdc781f264171030bc28f2b370fee", 0, ".gitmodules" },
263+
{ 0100644, "4dd1ef7569b18d92d93c0a35bb6b93049137b355", 1, "file.txt" },
264+
{ 0100644, "a2d8d1824c68541cca94ffb90f79291eba495921", 2, "file.txt" },
265+
{ 0100644, "63ec604d491161ddafdae4179843c26d54bd999a", 3, "file.txt" },
266+
{ 0160000, "0000000000000000000000000000000000000001", 1, "submodule1" },
267+
{ 0160000, "0000000000000000000000000000000000000002", 3, "submodule1" },
268+
{ 0160000, "0000000000000000000000000000000000000003", 0, "submodule2" },
269+
};
270+
271+
cl_git_pass(merge_trees_from_branches(&index, repo,
272+
"submodule_rename1", "submodule_rename2",
273+
opts));
274+
cl_assert(merge_test_index(index, merge_index_entries, 7));
275+
git_index_free(index);
276+
}
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
x��AjC1 D��)�ّe}%z�^�ߖ�,�wpr�:� tV����Զ�6�����RBB�Lh�,���9��+�%r��Ǯ��h1���%�p�"��=���Iue����{��ڶ߶�Ig�r��m����������-�23�/���'|��R�~U��k�{���dJ�
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

tests/resources/merge-resolve/.gitted/objects/a1/07e18a58f38c46086c8f8f1dcd54c40154eeb6

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
x��K
2+
1]��$��|`7.�{��g��@&��7^�Z=
3+
j��a���[J p�����FH �Z�QIg#P4��}�n�-�c�y��4�o]���ݟB�����l�Vp�6����� u�����ja_� ?H

0 commit comments

Comments
 (0)