X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=diffcore-rename.c;h=daddd9b28af1e20fe82aefa654bad04f4b52c1d3;hb=927c77e7d4d1e42c1e523d4651a7fe2c9122fe32;hp=0d8c3d2ee480d70718f1e6f0b43a1175a14e4584;hpb=902df9f5c45cd99720d4ca0a38d0538eb0126ad7;p=thirdparty%2Fgit.git diff --git a/diffcore-rename.c b/diffcore-rename.c index 0d8c3d2ee4..daddd9b28a 100644 --- a/diffcore-rename.c +++ b/diffcore-rename.c @@ -4,6 +4,7 @@ #include "cache.h" #include "diff.h" #include "diffcore.h" +#include "object-store.h" #include "hashmap.h" #include "progress.h" @@ -57,8 +58,8 @@ static int add_rename_dst(struct diff_filespec *two) ALLOC_GROW(rename_dst, rename_dst_nr + 1, rename_dst_alloc); rename_dst_nr++; if (first < rename_dst_nr) - memmove(rename_dst + first + 1, rename_dst + first, - (rename_dst_nr - first - 1) * sizeof(*rename_dst)); + MOVE_ARRAY(rename_dst + first + 1, rename_dst + first, + rename_dst_nr - first - 1); rename_dst[first].two = alloc_filespec(two->path); fill_filespec(rename_dst[first].two, &two->oid, two->oid_valid, two->mode); @@ -98,8 +99,8 @@ static struct diff_rename_src *register_rename_src(struct diff_filepair *p) ALLOC_GROW(rename_src, rename_src_nr + 1, rename_src_alloc); rename_src_nr++; if (first < rename_src_nr) - memmove(rename_src + first + 1, rename_src + first, - (rename_src_nr - first - 1) * sizeof(*rename_src)); + MOVE_ARRAY(rename_src + first + 1, rename_src + first, + rename_src_nr - first - 1); rename_src[first].p = p; rename_src[first].score = score; return &(rename_src[first]); @@ -260,8 +261,8 @@ static unsigned int hash_filespec(struct diff_filespec *filespec) if (!filespec->oid_valid) { if (diff_populate_filespec(filespec, 0)) return 0; - hash_sha1_file(filespec->data, filespec->size, "blob", - filespec->oid.hash); + hash_object_file(filespec->data, filespec->size, "blob", + &filespec->oid); } return sha1hash(filespec->oid.hash); } @@ -285,7 +286,7 @@ static int find_identical_files(struct hashmap *srcs, struct diff_filespec *source = p->filespec; /* False hash collision? */ - if (oidcmp(&source->oid, &target->oid)) + if (!oideq(&source->oid, &target->oid)) continue; /* Non-regular files? If so, the modes must match! */ if (!S_ISREG(source->mode) || !S_ISREG(target->mode)) { @@ -391,21 +392,19 @@ static int too_many_rename_candidates(int num_create, * growing larger than a "rename_limit" square matrix, ie: * * num_create * num_src > rename_limit * rename_limit - * - * but handles the potential overflow case specially (and we - * assume at least 32-bit integers) */ - if (rename_limit <= 0 || rename_limit > 32767) + if (rename_limit <= 0) rename_limit = 32767; if ((num_create <= rename_limit || num_src <= rename_limit) && - (num_create * num_src <= rename_limit * rename_limit)) + ((uint64_t)num_create * (uint64_t)num_src + <= (uint64_t)rename_limit * (uint64_t)rename_limit)) return 0; options->needed_rename_limit = num_src > num_create ? num_src : num_create; /* Are we running under -C -C? */ - if (!DIFF_OPT_TST(options, FIND_COPIES_HARDER)) + if (!options->flags.find_copies_harder) return 1; /* Would we bust the limit if we were running under -C? */ @@ -415,7 +414,8 @@ static int too_many_rename_candidates(int num_create, num_src++; } if ((num_create <= rename_limit || num_src <= rename_limit) && - (num_create * num_src <= rename_limit * rename_limit)) + ((uint64_t)num_create * (uint64_t)num_src + <= (uint64_t)rename_limit * (uint64_t)rename_limit)) return 2; return 1; } @@ -463,7 +463,7 @@ void diffcore_rename(struct diff_options *options) else if (options->single_follow && strcmp(options->single_follow, p->two->path)) continue; /* not interested */ - else if (!DIFF_OPT_TST(options, RENAME_EMPTY) && + else if (!options->flags.rename_empty && is_empty_blob_oid(&p->two->oid)) continue; else if (add_rename_dst(p->two) < 0) { @@ -473,7 +473,7 @@ void diffcore_rename(struct diff_options *options) goto cleanup; } } - else if (!DIFF_OPT_TST(options, RENAME_EMPTY) && + else if (!options->flags.rename_empty && is_empty_blob_oid(&p->one->oid)) continue; else if (!DIFF_PAIR_UNMERGED(p) && !DIFF_FILE_VALID(p->two)) { @@ -534,7 +534,7 @@ void diffcore_rename(struct diff_options *options) if (options->show_rename_progress) { progress = start_delayed_progress( _("Performing inexact rename detection"), - rename_dst_nr * rename_src_nr); + (uint64_t)rename_dst_nr * (uint64_t)rename_src_nr); } mx = xcalloc(st_mult(NUM_CANDIDATE_PER_DST, num_create), sizeof(*mx)); @@ -571,7 +571,7 @@ void diffcore_rename(struct diff_options *options) diff_free_filespec_blob(two); } dst_cnt++; - display_progress(progress, (i+1)*rename_src_nr); + display_progress(progress, (uint64_t)(i+1)*(uint64_t)rename_src_nr); } stop_progress(&progress);