Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-07-25 00:10:16 +0400
committerRussell Belfer <rb@github.com>2013-07-25 00:10:16 +0400
commit18e9efc425bd617655782188056fe43ecdc673e4 (patch)
treeb772434b7b3ba8cd1ea14efdb5a88f1da8518caf /src/diff_tform.c
parent69c66b554e1072d8b6c63366834e15310fecaea7 (diff)
Don't check rename if file size difference is huge
Diffstat (limited to 'src/diff_tform.c')
-rw-r--r--src/diff_tform.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/diff_tform.c b/src/diff_tform.c
index ac5356a8c..ab43a3a14 100644
--- a/src/diff_tform.c
+++ b/src/diff_tform.c
@@ -446,6 +446,8 @@ static int similarity_calc(
}
blobsize = git_blob_rawsize(blob);
+ if (!file->size)
+ file->size = blobsize;
if (!git__is_sizet(blobsize)) /* ? what to do ? */
blobsize = (size_t)-1;
@@ -510,6 +512,13 @@ static int similarity_measure(
return 0;
}
+ /* check if file sizes too small or nowhere near each other */
+ if (a_file->size > 127 &&
+ b_file->size > 127 &&
+ (a_file->size > (b_file->size << 4) ||
+ b_file->size > (a_file->size << 4)))
+ return 0;
+
/* update signature cache if needed */
if (!cache[a_idx] && similarity_calc(diff, opts, a_idx, cache) < 0)
return -1;