Commit d2ce981f by Edward Thomson Committed by Edward Thomson

diff: fail generation if a file changes size

When we know that we know a file's size, and the file's size changes,
fail.
parent 359240b6
...@@ -338,15 +338,15 @@ static int diff_file_content_load_workdir_file( ...@@ -338,15 +338,15 @@ static int diff_file_content_load_workdir_file(
if (error < 0) if (error < 0)
goto cleanup; goto cleanup;
/* if file size doesn't match cached value, abort */ if (!(fc->file->flags & GIT_DIFF_FLAG_VALID_SIZE)) {
if (fc->file->size && fc->file->size != new_file_size) { fc->file->size = new_file_size;
fc->file->flags |= GIT_DIFF_FLAG_VALID_SIZE;
} else if (fc->file->size != new_file_size) {
git_error_set(GIT_ERROR_FILESYSTEM, "file changed before we could read it"); git_error_set(GIT_ERROR_FILESYSTEM, "file changed before we could read it");
error = -1; error = -1;
goto cleanup; goto cleanup;
} }
fc->file->size = new_file_size;
if ((diff_opts->flags & GIT_DIFF_SHOW_BINARY) == 0 && if ((diff_opts->flags & GIT_DIFF_SHOW_BINARY) == 0 &&
diff_file_content_binary_by_size(fc)) diff_file_content_binary_by_size(fc))
goto cleanup; goto cleanup;
......
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