@matheusbsbs / matheus-bagliano / commits / 42899ac898
Fork 0

Do the fuzzy rename detection limits with the exact renames removed

When we do the fuzzy rename detection, we don't care about the destinations that we already handled with the exact rename detector. And, in fact, the code already knew that - but the rename limiter, which used to run *before* exact renames were detected, did not. This fixes it so that the rename detection limiter now bases its decisions on the *remaining* rename counts, rather than the original ones. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Linus Torvalds committed Oct 26, 2007 at 16:56 UTC 42899ac898f2b539fc762c8452da2c981ccbd815
1 file changed +18 -14
diffcore-rename.c
+18 -14
@@ -435,33 +435,37 @@ void diffcore_rename(struct diff_options *options)
435 */
436 rename_count = find_exact_renames();
437
438 + /* Did we only want exact renames? */
439 + if (minimum_score == MAX_SCORE)
440 + goto cleanup;
441 +
442 + /*
443 + * Calculate how many renames are left (but all the source
444 + * files still remain as options for rename/copies!)
445 + */
446 + num_create = (rename_dst_nr - rename_count);
447 + num_src = rename_src_nr;
448 +
449 + /* All done? */
450 + if (!num_create)
451 + goto cleanup;
452 +
453 /*
454 * This basically does a test for the rename matrix not
455 * growing larger than a "rename_limit" square matrix, ie:
456 *
442 - * rename_dst_nr * rename_src_nr > rename_limit * rename_limit
457 + * num_create * num_src > rename_limit * rename_limit
458 *
459 * but handles the potential overflow case specially (and we
460 * assume at least 32-bit integers)
461 */
462 if (rename_limit <= 0 || rename_limit > 32767)
463 rename_limit = 32767;
449 - if (rename_dst_nr > rename_limit && rename_src_nr > rename_limit)
464 + if (num_create > rename_limit && num_src > rename_limit)
465 goto cleanup;
451 - if (rename_dst_nr * rename_src_nr > rename_limit * rename_limit)
466 + if (num_create * num_src > rename_limit * rename_limit)
467 goto cleanup;
468
454 - /* Have we run out the created file pool? If so we can avoid
455 - * doing the delta matrix altogether.
456 - */
457 - if (rename_count == rename_dst_nr)
458 - goto cleanup;
459 -
460 - if (minimum_score == MAX_SCORE)
461 - goto cleanup;
462 -
463 - num_create = (rename_dst_nr - rename_count);
464 - num_src = rename_src_nr;
469 mx = xmalloc(sizeof(*mx) * num_create * num_src);
470 for (dst_cnt = i = 0; i < rename_dst_nr; i++) {
471 int base = dst_cnt * num_src;