summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--diff.c1
-rwxr-xr-xt/t4017-diff-retval.sh8
2 files changed, 9 insertions, 0 deletions
diff --git a/diff.c b/diff.c
index a83409944b..6da7bfd0c6 100644
--- a/diff.c
+++ b/diff.c
@@ -3673,6 +3673,7 @@ static void builtin_diff(const char *name_a,
emit_diff_symbol(o, DIFF_SYMBOL_BINARY_FILES,
sb.buf, sb.len, 0);
strbuf_release(&sb);
+ o->found_changes = 1;
goto free_ab_and_return;
}
if (fill_mmfile(o->repo, &mf1, one) < 0 ||
diff --git a/t/t4017-diff-retval.sh b/t/t4017-diff-retval.sh
index d644310e22..1cea73ef5a 100755
--- a/t/t4017-diff-retval.sh
+++ b/t/t4017-diff-retval.sh
@@ -145,6 +145,14 @@ test_expect_success 'option errors are not confused by --exit-code' '
for option in --exit-code --quiet
do
+ test_expect_success "git diff $option returns 1 for changed binary file" "
+ test_when_finished 'rm -f .gitattributes' &&
+ git reset --hard &&
+ echo a binary >.gitattributes &&
+ echo 2 >>a &&
+ test_expect_code 1 git diff $option
+ "
+
test_expect_success "git diff $option returns 1 for copied file" "
git reset --hard &&
cp a copy &&