提交 89973554 编写于 作者: J Jonathan Tan 提交者: Junio C Hamano

diffcore-rename: make diff-tree -l0 mean -l<large>

In the documentation of diff-tree, it is stated that the -l option
"prevents rename/copy detection from running if the number of
rename/copy targets exceeds the specified number". The documentation
does not mention any special handling for the number 0, but the
implementation before commit 9f7e4bfa ("diff: remove silent clamp of
renameLimit", 2017-11-13) treated 0 as a special value indicating that
the rename limit is to be a very large number instead.

The commit 9f7e4bfa changed that behavior, treating 0 as 0. Revert
this behavior to what it was previously. This allows existing scripts
and tools that use "-l0" to continue working. The alternative (to have
"-l0" suppress rename detection) is probably much less useful, since
users can just refrain from specifying -M and/or -C to have the same
effect.
Signed-off-by: NJonathan Tan <jonathantanmy@google.com>
Reviewed-by: NJonathan Nieder <jrnieder@gmail.com>
Reviewed-by: NElijah Newren <newren@gmail.com>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 9268cf4a
......@@ -392,6 +392,8 @@ static int too_many_rename_candidates(int num_create,
*
* num_create * num_src > rename_limit * rename_limit
*/
if (rename_limit <= 0)
rename_limit = 32767;
if ((num_create <= rename_limit || num_src <= rename_limit) &&
((uint64_t)num_create * (uint64_t)num_src
<= (uint64_t)rename_limit * (uint64_t)rename_limit))
......
......@@ -230,4 +230,19 @@ test_expect_success 'rename pretty print common prefix and suffix overlap' '
test_i18ngrep " d/f/{ => f}/e " output
'
test_expect_success 'diff-tree -l0 defaults to a big rename limit, not zero' '
test_write_lines line1 line2 line3 >myfile &&
git add myfile &&
git commit -m x &&
test_write_lines line1 line2 line4 >myotherfile &&
git rm myfile &&
git add myotherfile &&
git commit -m x &&
git diff-tree -M -l0 HEAD HEAD^ >actual &&
# Verify that a rename from myotherfile to myfile was detected
grep "myotherfile.*myfile" actual
'
test_done
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册