Skip to content

Commit 3bac68f

Browse files
jorioEdward Thomson
andcommitted
diff_file: Apply suggestions from code review
Skip new_file_size non-zero test, custom error message if file changed in workdir Co-authored-by: Edward Thomson <ethomson@github.com>
1 parent 0a0cd67 commit 3bac68f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/diff_file.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,12 +335,12 @@ static int diff_file_content_load_workdir_file(
335335

336336
error = git_futils_filesize(&new_file_size, fd);
337337

338-
if (error < 0 || !new_file_size)
338+
if (error < 0)
339339
goto cleanup;
340340

341341
/* if file size doesn't match cached value, abort */
342-
if (fc->file->size && fc->file->size != new_file_size)
343-
{
342+
if (fc->file->size && fc->file->size != new_file_size) {
343+
git_error_set(GIT_ERROR_FILESYSTEM, "file changed before we could read it");
344344
error = -1;
345345
goto cleanup;
346346
}

0 commit comments

Comments
 (0)