Skip to content

Commit 9f7e4bf

Browse files
newrengitster
authored andcommitted
diff: remove silent clamp of renameLimit
In commit 0024a54 (Fix the rename detection limit checking; 2007-09-14), the renameLimit was clamped to 32767. This appears to have been to simply avoid integer overflow in the following computation: num_create * num_src <= rename_limit * rename_limit although it also could be viewed as a hardcoded bound on the amount of CPU time we're willing to allow users to tell git to spend on handling renames. An upper bound may make sense, but unfortunately this upper bound was neither communicated to the users, nor documented anywhere. Although large limits can make things slow, we have users who would be ecstatic to have a small five file change be correctly cherry picked even if they have to manually specify a large limit and wait ten minutes for the renames to be detected. Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d6861d0 commit 9f7e4bf

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

diff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5454,7 +5454,7 @@ void diff_warn_rename_limit(const char *varname, int needed, int degraded_cc)
54545454
warning(_(rename_limit_warning));
54555455
else
54565456
return;
5457-
if (0 < needed && needed < 32767)
5457+
if (0 < needed)
54585458
warning(_(rename_limit_advice), varname, needed);
54595459
}
54605460

diffcore-rename.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -391,14 +391,10 @@ static int too_many_rename_candidates(int num_create,
391391
* growing larger than a "rename_limit" square matrix, ie:
392392
*
393393
* num_create * num_src > rename_limit * rename_limit
394-
*
395-
* but handles the potential overflow case specially (and we
396-
* assume at least 32-bit integers)
397394
*/
398-
if (rename_limit <= 0 || rename_limit > 32767)
399-
rename_limit = 32767;
400395
if ((num_create <= rename_limit || num_src <= rename_limit) &&
401-
(num_create * num_src <= rename_limit * rename_limit))
396+
((uint64_t)num_create * (uint64_t)num_src
397+
<= (uint64_t)rename_limit * (uint64_t)rename_limit))
402398
return 0;
403399

404400
options->needed_rename_limit =
@@ -415,7 +411,8 @@ static int too_many_rename_candidates(int num_create,
415411
num_src++;
416412
}
417413
if ((num_create <= rename_limit || num_src <= rename_limit) &&
418-
(num_create * num_src <= rename_limit * rename_limit))
414+
((uint64_t)num_create * (uint64_t)num_src
415+
<= (uint64_t)rename_limit * (uint64_t)rename_limit))
419416
return 2;
420417
return 1;
421418
}

0 commit comments

Comments
 (0)