diff options
| author | Russell Belfer <rb@github.com> | 2013-07-25 12:27:39 -0700 |
|---|---|---|
| committer | Russell Belfer <rb@github.com> | 2013-07-25 12:27:39 -0700 |
| commit | a16e41729d5dec4acd30302c4a217622de00d290 (patch) | |
| tree | 7b96eda1d029e22589321384aa5bcd94e367b693 /src/diff_tform.c | |
| parent | effdbeb3239b777e2b19fc4944643fc7f2a768c3 (diff) | |
| download | libgit2-a16e41729d5dec4acd30302c4a217622de00d290.tar.gz | |
Fix rename detection to use actual blob size
The size data in the index may not reflect the actual size of the
blob data from the ODB when content filtering comes into play.
This commit fixes rename detection to use the actual blob size when
calculating data signatures instead of the value from the index.
Because of a misunderstanding on my part, I first converted the
git_index_add_bypath API to use the post-filtered blob data size
in creating the index entry. I backed that change out, but I
kept the overall refactoring of that routine and the new internal
git_blob__create_from_paths API because it eliminates an extra
stat() call from the code that adds a file to the index.
The existing tests actually cover this code path, at least when
running on Windows, so at this point I'm not adding new tests to
cover the changes.
Diffstat (limited to 'src/diff_tform.c')
| -rw-r--r-- | src/diff_tform.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/diff_tform.c b/src/diff_tform.c index 8fd2a4fe9..d4b8cf30a 100644 --- a/src/diff_tform.c +++ b/src/diff_tform.c @@ -473,7 +473,13 @@ static int similarity_calc( /* if lookup fails, just skip this item in similarity calc */ giterr_clear(); } else { - size_t sz = (size_t)(git__is_sizet(file->size) ? file->size : -1); + size_t sz; + + /* index size may not be actual blob size if filtered */ + if (file->size != git_blob_rawsize(info->blob)) + file->size = git_blob_rawsize(info->blob); + + sz = (size_t)(git__is_sizet(file->size) ? file->size : -1); error = opts->metric->buffer_signature( &cache[info->idx], info->file, |
