Commit 09fae31d by Russell Belfer

Improve robustness of diff rename detection

Under some strange circumstances, diffs can end up listing files
that we can't actually open successfully.  Instead of aborting
the git_diff_find_similar, this makes it so that those files just
won't be considered as valid rename/copy targets instead.
parent dcb0f7c0
...@@ -386,8 +386,12 @@ static int similarity_calc( ...@@ -386,8 +386,12 @@ static int similarity_calc(
/* TODO: apply wd-to-odb filters to file data if necessary */ /* TODO: apply wd-to-odb filters to file data if necessary */
if (!(error = git_buf_joinpath( if ((error = git_buf_joinpath(
&path, git_repository_workdir(diff->repo), file->path))) &path, git_repository_workdir(diff->repo), file->path)) < 0)
return error;
/* if path is not a regular file, just skip this item */
if (git_path_isfile(path.ptr))
error = opts->metric->file_signature( error = opts->metric->file_signature(
&cache[file_idx], file, path.ptr, opts->metric->payload); &cache[file_idx], file, path.ptr, opts->metric->payload);
...@@ -398,8 +402,11 @@ static int similarity_calc( ...@@ -398,8 +402,11 @@ static int similarity_calc(
/* TODO: add max size threshold a la diff? */ /* TODO: add max size threshold a la diff? */
if ((error = git_blob_lookup(&blob, diff->repo, &file->oid)) < 0) if (git_blob_lookup(&blob, diff->repo, &file->oid) < 0) {
return error; /* if lookup fails, just skip this item in similarity calc */
giterr_clear();
return 0;
}
blobsize = git_blob_rawsize(blob); blobsize = git_blob_rawsize(blob);
if (!git__is_sizet(blobsize)) /* ? what to do ? */ if (!git__is_sizet(blobsize)) /* ? what to do ? */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment