Skip to content

Commit 0b6e913

Browse files
committed
Merge branch 'as/diff-shortstat-ignore-binary'
# By Alexander Strasser * as/diff-shortstat-ignore-binary: diff: Only count lines in show_shortstats
2 parents 1fd8f97 + de9658b commit 0b6e913

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

diff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1700,7 +1700,7 @@ static void show_shortstats(struct diffstat_t *data, struct diff_options *option
17001700
continue;
17011701
if (!data->files[i]->is_renamed && (added + deleted == 0)) {
17021702
total_files--;
1703-
} else {
1703+
} else if (!data->files[i]->is_binary) { /* don't count bytes */
17041704
adds += added;
17051705
dels += deleted;
17061706
}

t/t4012-diff-binary.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,18 @@ test_expect_success '"apply --stat" output for binary file change' '
3636
test_i18ncmp expected current
3737
'
3838

39+
test_expect_success 'diff --shortstat output for binary file change' '
40+
echo " 4 files changed, 2 insertions(+), 2 deletions(-)" >expected &&
41+
git diff --shortstat >current &&
42+
test_i18ncmp expected current
43+
'
44+
45+
test_expect_success 'diff --shortstat output for binary file change only' '
46+
echo " 1 file changed, 0 insertions(+), 0 deletions(-)" >expected &&
47+
git diff --shortstat -- b >current &&
48+
test_i18ncmp expected current
49+
'
50+
3951
test_expect_success 'apply --numstat notices binary file change' '
4052
git diff >diff &&
4153
git apply --numstat <diff >current &&

0 commit comments

Comments
 (0)