summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2013-03-11 10:57:19 -0700
committerEdward Thomson <ethomson@microsoft.com>2013-03-11 10:57:19 -0700
commiteef7e80e68a530f8ce1d1ec196d41fc33a1ced6e (patch)
tree02210552d4b2edd791a769b9854755bc000de2e6 /src
parentd768f9add943e0ca220c81d7ffa29fc3215cd119 (diff)
parentaa408cbfc4940e05cb7843383264623e45737bb9 (diff)
downloadlibgit2-eef7e80e68a530f8ce1d1ec196d41fc33a1ced6e.tar.gz
Merge pull request #1407 from ethomson/tform_small_files
handle small files in similarity metrics
Diffstat (limited to 'src')
-rw-r--r--src/diff_tform.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/diff_tform.c b/src/diff_tform.c
index 958d2bfec..e9969d9a8 100644
--- a/src/diff_tform.c
+++ b/src/diff_tform.c
@@ -174,16 +174,34 @@ static int find_similar__hashsig_for_file(
void **out, const git_diff_file *f, const char *path, void *p)
{
git_hashsig_option_t opt = (git_hashsig_option_t)p;
+ int error = 0;
+
GIT_UNUSED(f);
- return git_hashsig_create_fromfile((git_hashsig **)out, path, opt);
+ error = git_hashsig_create_fromfile((git_hashsig **)out, path, opt);
+
+ if (error == GIT_EBUFS) {
+ error = 0;
+ giterr_clear();
+ }
+
+ return error;
}
static int find_similar__hashsig_for_buf(
void **out, const git_diff_file *f, const char *buf, size_t len, void *p)
{
git_hashsig_option_t opt = (git_hashsig_option_t)p;
+ int error = 0;
+
GIT_UNUSED(f);
- return git_hashsig_create((git_hashsig **)out, buf, len, opt);
+ error = git_hashsig_create((git_hashsig **)out, buf, len, opt);
+
+ if (error == GIT_EBUFS) {
+ error = 0;
+ giterr_clear();
+ }
+
+ return error;
}
static void find_similar__hashsig_free(void *sig, void *payload)
@@ -414,6 +432,10 @@ static int similarity_measure(
return -1;
if (!cache[b_idx] && similarity_calc(diff, opts, b_idx, cache) < 0)
return -1;
+
+ /* some metrics may not wish to process this file (too big / too small) */
+ if (!cache[a_idx] || !cache[b_idx])
+ return 0;
/* compare signatures */
if (opts->metric->similarity(