{"thread":{"id":"1041","subject":"[PATCH] Use enhanced diff_delta() in the similarity estimator.","startedAt":"2005-06-28T23:58:27Z","lastAt":"2005-06-28T23:58:27Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"5388","messageId":"7vr7emrq3g.fsf@assigned-by-dhcp.cox.net","threadId":"1041","inReplyTo":null,"subject":"[PATCH] Use enhanced diff_delta() in the similarity estimator.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-06-28T23:58:27Z","receivedAt":"2005-06-28T23:58:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"The diff_delta() interface has been extended to reject\ngenerating too big a delta while we were working on the packed\nGIT archive format.  Take advantage of that when generating\ndelta in the similarity estimator used in diffcore-rename.c\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n\n diffcore-rename.c |    7 ++++++-\n 1 files changed, 6 insertions(+), 1 deletions(-)\n\ne4495245cf1ffc1c443df9177c95ce9d1b5052b0\ndiff --git a/diffcore-rename.c b/diffcore-rename.c\n--- a/diffcore-rename.c\n+++ b/diffcore-rename.c\n@@ -136,6 +136,7 @@ static int estimate_similarity(struct di\n \t */\n \tvoid *delta;\n \tunsigned long delta_size, base_size, src_copied, literal_added;\n+\tunsigned long delta_limit;\n \tint score;\n \n \t/* We deal only with regular files.  Symlink renames are handled\n@@ -163,9 +164,13 @@ static int estimate_similarity(struct di\n \tif (diff_populate_filespec(src, 0) || diff_populate_filespec(dst, 0))\n \t\treturn 0; /* error but caught downstream */\n \n+\tdelta_limit = base_size * (MAX_SCORE-minimum_score) / MAX_SCORE;\n \tdelta = diff_delta(src->data, src->size,\n \t\t\t   dst->data, dst->size,\n-\t\t\t   &delta_size, ~0UL);\n+\t\t\t   &delta_size, delta_limit);\n+\tif (!delta)\n+\t\t/* If delta_limit is exceeded, we have too much differences */\n+\t\treturn 0;\n \n \t/* A delta that has a lot of literal additions would have\n \t * big delta_size no matter what else it does.\n------------\n"}]}