434
* 1 if we need to disable inexact rename detection;
435
* 2 if we would be under the limit if we were given -C instead of -C -C.
436
*/
437
-static int too_many_rename_candidates(int num_destinations,
437
+static int too_many_rename_candidates(int num_destinations, int num_sources,
438
struct diff_options *options)
439
{
440
int rename_limit = options->rename_limit;
441
- int num_src = rename_src_nr;
442
- int i;
441
+ int i, limited_sources;
442
443
options->needed_rename_limit = 0;
444
446
* This basically does a test for the rename matrix not
447
* growing larger than a "rename_limit" square matrix, ie:
448
*
450
- * num_destinations * num_src > rename_limit * rename_limit
449
+ * num_destinations * num_sources > rename_limit * rename_limit
450
*/
451
if (rename_limit <= 0)
452
rename_limit = 32767;
454
- if ((num_destinations <= rename_limit || num_src <= rename_limit) &&
455
- ((uint64_t)num_destinations * (uint64_t)num_src
453
+ if ((num_destinations <= rename_limit || num_sources <= rename_limit) &&
454
+ ((uint64_t)num_destinations * (uint64_t)num_sources
455
<= (uint64_t)rename_limit * (uint64_t)rename_limit))
456
return 0;
457
458
options->needed_rename_limit =
460
- num_src > num_destinations ? num_src : num_destinations;
459
+ num_sources > num_destinations ? num_sources : num_destinations;
460
461
/* Are we running under -C -C? */
462
if (!options->flags.find_copies_harder)
463
return 1;
464
465
/* Would we bust the limit if we were running under -C? */
467
- for (num_src = i = 0; i < rename_src_nr; i++) {
466
+ for (limited_sources = i = 0; i < num_sources; i++) {
467
if (diff_unmodified_pair(rename_src[i].p))
468
continue;
470
- num_src++;
469
+ limited_sources++;
470
}
472
- if ((num_destinations <= rename_limit || num_src <= rename_limit) &&
473
- ((uint64_t)num_destinations * (uint64_t)num_src
471
+ if ((num_destinations <= rename_limit || limited_sources <= rename_limit) &&
472
+ ((uint64_t)num_destinations * (uint64_t)limited_sources
473
<= (uint64_t)rename_limit * (uint64_t)rename_limit))
474
return 2;
475
return 1;
575
if (!num_destinations)
576
goto cleanup;
577
579
- switch (too_many_rename_candidates(num_destinations, options)) {
578
+ switch (too_many_rename_candidates(num_destinations, rename_src_nr,
579
+ options)) {
580
case 1:
581
goto cleanup;
582
case 2: