{"thread":{"id":"30664","subject":"[PATCH] diff: Only count lines in show_shortstats()","startedAt":"2012-05-30T21:58:43Z","lastAt":"2012-05-30T21:58:43Z","messageCount":1,"participants":["Alexander Strasser"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"192517","messageId":"20120530215843.GA29737@akuma","threadId":"30664","inReplyTo":null,"subject":"[PATCH] diff: Only count lines in show_shortstats()","fromName":"Alexander Strasser","fromEmail":"eclipse7@gmx.net","sentAt":"2012-05-30T21:58:43Z","receivedAt":"2012-05-30T21:58:43Z","isPatch":true,"sender":{"key":"eclipse7@gmx.net","avatar":"https://avatars.githubusercontent.com/u/4342576?v=4"},"body":"  Do not mix byte and line counts. Binary files have byte counts;\nskip them when accumulating line insertions/deletions.\n\n  The regression was introduced in e18872b.\n\nSigned-off-by: Alexander Strasser <eclipse7@gmx.net>\n---\n\n  I hope this does retain the original intent of e18872b while\nnot messing up the insertions/deletions output by --shortstat.\n\n  Output of --stat was never affected AFAICT.\n\n diff.c                 | 2 +-\n t/t4012-diff-binary.sh | 8 ++++++++\n 2 files changed, 9 insertions(+), 1 deletion(-)\n\ndiff --git a/diff.c b/diff.c\nindex 77edd50..1a594df 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -1700,7 +1700,7 @@ static void show_shortstats(struct diffstat_t *data, struct diff_options *option\n \t\t\tcontinue;\n \t\tif (!data->files[i]->is_renamed && (added + deleted == 0)) {\n \t\t\ttotal_files--;\n-\t\t} else {\n+\t\t} else if (!data->files[i]->is_binary) { /* don't count bytes */\n \t\t\tadds += added;\n \t\t\tdels += deleted;\n \t\t}\ndiff --git a/t/t4012-diff-binary.sh b/t/t4012-diff-binary.sh\nindex 8b4e80d..1a994f0 100755\n--- a/t/t4012-diff-binary.sh\n+++ b/t/t4012-diff-binary.sh\n@@ -36,6 +36,14 @@ test_expect_success '\"apply --stat\" output for binary file change' '\n \ttest_i18ncmp expected current\n '\n \n+cat > expected <<\\EOF\n+ 4 files changed, 2 insertions(+), 2 deletions(-)\n+EOF\n+test_expect_success 'diff with --shortstat' '\n+\tgit diff --shortstat >current &&\n+\ttest_cmp expected current\n+'\n+\n test_expect_success 'apply --numstat notices binary file change' '\n \tgit diff >diff &&\n \tgit apply --numstat <diff >current &&\n-- \n1.7.10.2.552.gaa3bb87\n"}]}