Skip to content

Commit e72ade8

Browse files
author
Kevin Swinton
committed
Fix binary diff showing /dev/null
Fixes issue where a changed binary file's content in the working tree isn't displayed correctly, instead showing an oid of zero, and with its path being reported incorrectly as "/dev/null".
1 parent 918a7d1 commit e72ade8

File tree

3 files changed

+3
-7
lines changed

3 files changed

+3
-7
lines changed

src/patch_generate.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,7 @@ static int patch_generated_load(git_patch_generated *patch, git_patch_generated_
209209

210210
if ((error = git_diff_file_content__load(
211211
&patch->ofile, &patch->base.diff_opts)) < 0 ||
212-
should_skip_binary(patch, patch->ofile.file))
213-
goto cleanup;
214-
if ((error = git_diff_file_content__load(
212+
(error = git_diff_file_content__load(
215213
&patch->nfile, &patch->base.diff_opts)) < 0 ||
216214
should_skip_binary(patch, patch->nfile.file))
217215
goto cleanup;

tests/diff/format_email.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ void test_diff_format_email__binary(void)
487487
"Subject: [PATCH] Modified binary file\n" \
488488
"\n" \
489489
"---\n" \
490-
" binary.bin | Bin 3 -> 0 bytes\n" \
490+
" binary.bin | Bin 3 -> 5 bytes\n" \
491491
" 1 file changed, 0 insertions(+), 0 deletions(-)\n" \
492492
"\n" \
493493
"diff --git a/binary.bin b/binary.bin\n" \
@@ -496,7 +496,6 @@ void test_diff_format_email__binary(void)
496496
"--\n" \
497497
"libgit2 " LIBGIT2_VERSION "\n" \
498498
"\n";
499-
/* TODO: Actually 0 bytes here should be 5!. Seems like we don't load the new content for binary files? */
500499

501500
opts.summary = "Modified binary file";
502501

tests/diff/stats.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,8 @@ void test_diff_stats__binary(void)
298298
{
299299
git_buf buf = GIT_BUF_INIT;
300300
const char *stat =
301-
" binary.bin | Bin 3 -> 0 bytes\n"
301+
" binary.bin | Bin 3 -> 5 bytes\n"
302302
" 1 file changed, 0 insertions(+), 0 deletions(-)\n";
303-
/* TODO: Actually 0 bytes here should be 5!. Seems like we don't load the new content for binary files? */
304303

305304
diff_stats_from_commit_oid(
306305
&_stats, "8d7523f6fcb2404257889abe0d96f093d9f524f9", false);

0 commit comments

Comments
 (0)