Skip to content

Commit f92c61a

Browse files
committed
Merge branch 'rs/diff-exit-code-binary'
"git diff --exit-code" ignored modified binary files, which has been corrected. * rs/diff-exit-code-binary: diff: report modified binary files as changes in builtin_diff()
2 parents cd845c0 + 9a41735 commit f92c61a

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

diff.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3675,6 +3675,7 @@ static void builtin_diff(const char *name_a,
36753675
emit_diff_symbol(o, DIFF_SYMBOL_BINARY_FILES,
36763676
sb.buf, sb.len, 0);
36773677
strbuf_release(&sb);
3678+
o->found_changes = 1;
36783679
goto free_ab_and_return;
36793680
}
36803681
if (fill_mmfile(o->repo, &mf1, one) < 0 ||

t/t4017-diff-retval.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,14 @@ test_expect_success 'option errors are not confused by --exit-code' '
145145

146146
for option in --exit-code --quiet
147147
do
148+
test_expect_success "git diff $option returns 1 for changed binary file" "
149+
test_when_finished 'rm -f .gitattributes' &&
150+
git reset --hard &&
151+
echo a binary >.gitattributes &&
152+
echo 2 >>a &&
153+
test_expect_code 1 git diff $option
154+
"
155+
148156
test_expect_success "git diff $option returns 1 for copied file" "
149157
git reset --hard &&
150158
cp a copy &&

0 commit comments

Comments
 (0)