puns are not funny; type punning especially so
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
diff --git a/src/merge.c b/src/merge.c
index 320be00..56290bf 100644
--- a/src/merge.c
+++ b/src/merge.c
@@ -357,7 +357,7 @@ static int merge_conflict_resolve_trivial(
git_merge_diff_list *diff_list,
const git_merge_diff *conflict)
{
- int ancestor_empty, ours_empty, theirs_empty;
+ int ours_empty, theirs_empty;
int ours_changed, theirs_changed, ours_theirs_differ;
git_index_entry const *result = NULL;
int error = 0;
@@ -374,7 +374,6 @@ static int merge_conflict_resolve_trivial(
conflict->their_status == GIT_DELTA_RENAMED)
return 0;
- ancestor_empty = !GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->ancestor_entry);
ours_empty = !GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->our_entry);
theirs_empty = !GIT_MERGE_INDEX_ENTRY_EXISTS(conflict->their_entry);
@@ -678,6 +677,7 @@ static int index_entry_similarity_calc(
{
git_blob *blob;
git_diff_file diff_file = {{{0}}};
+ git_off_t blobsize;
int error;
*out = NULL;
@@ -691,8 +691,14 @@ static int index_entry_similarity_calc(
diff_file.mode = entry->mode;
diff_file.flags = 0;
+ blobsize = git_blob_rawsize(blob);
+
+ /* file too big for rename processing */
+ if (!git__is_sizet(blobsize))
+ return 0;
+
error = opts->metric->buffer_signature(out, &diff_file,
- git_blob_rawcontent(blob), git_blob_rawsize(blob),
+ git_blob_rawcontent(blob), (size_t)blobsize,
opts->metric->payload);
git_blob_free(blob);
@@ -1273,7 +1279,7 @@ int git_merge_diff_list__find_differences(
git_vector_cmp entry_compare = git_index_entry__cmp;
struct merge_diff_df_data df_data = {0};
int cur_item_modified;
- size_t i;
+ size_t i, j;
int error = 0;
assert(diff_list && our_tree && their_tree);
@@ -1290,7 +1296,9 @@ int git_merge_diff_list__find_differences(
}
while (true) {
- memset(cur_items, 0x0, sizeof(git_index_entry *) * 3);
+ for (i = 0; i < 3; i++)
+ cur_items[i] = NULL;
+
best_cur_item = NULL;
cur_item_modified = 0;
@@ -1312,7 +1320,9 @@ int git_merge_diff_list__find_differences(
* Found an item that sorts before our current item, make
* our current item this one.
*/
- memset(cur_items, 0x0, sizeof(git_index_entry *) * 3);
+ for (j = 0; j < i; j++)
+ cur_items[j] = NULL;
+
cur_item_modified = 1;
best_cur_item = items[i];
cur_items[i] = items[i];
diff --git a/tests-clar/merge/merge_helpers.c b/tests-clar/merge/merge_helpers.c
index 5c3421e..71bb967 100644
--- a/tests-clar/merge/merge_helpers.c
+++ b/tests-clar/merge/merge_helpers.c
@@ -149,9 +149,9 @@ static int name_entry_eq_merge_name_entry(const struct merge_name_entry *expecte
static int index_conflict_data_eq_merge_diff(const struct merge_index_conflict_data *expected, git_merge_diff *actual)
{
- if (!index_entry_eq_merge_index_entry((const struct merge_index_entry *)&expected->ancestor, &actual->ancestor_entry) ||
- !index_entry_eq_merge_index_entry((const struct merge_index_entry *)&expected->ours, &actual->our_entry) ||
- !index_entry_eq_merge_index_entry((const struct merge_index_entry *)&expected->theirs, &actual->their_entry))
+ if (!index_entry_eq_merge_index_entry(&expected->ancestor.entry, &actual->ancestor_entry) ||
+ !index_entry_eq_merge_index_entry(&expected->ours.entry, &actual->our_entry) ||
+ !index_entry_eq_merge_index_entry(&expected->theirs.entry, &actual->their_entry))
return 0;
if (expected->ours.status != actual->our_status ||
diff --git a/tests-clar/merge/merge_helpers.h b/tests-clar/merge/merge_helpers.h
index 1a0b892..cb718e0 100644
--- a/tests-clar/merge/merge_helpers.h
+++ b/tests-clar/merge/merge_helpers.h
@@ -18,11 +18,8 @@ struct merge_name_entry {
};
struct merge_index_with_status {
- uint16_t mode;
- char oid_str[41];
- int stage;
- char path[128];
- unsigned int status;
+ struct merge_index_entry entry;
+ unsigned int status;
};
struct merge_reuc_entry {