diff --stat-count: finishing touches

Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed May 27, 2011 at 21:50 UTC e5f85df87e8f1adb40288265ef54a16128691688
2 files changed +29 -2
diff.c
+4 -2
@@ -1247,6 +1247,7 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
1247 int width, name_width, count;
1248 const char *reset, *add_c, *del_c;
1249 const char *line_prefix = "";
1250 + int extra_shown = 0;
1251 struct strbuf *msg = NULL;
1252
1253 if (data->nr == 0)
@@ -1376,8 +1377,6 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
1377 show_graph(options->file, '-', del, del_c, reset);
1378 fprintf(options->file, "\n");
1379 }
1379 - if (count < data->nr)
1380 - fprintf(options->file, "%s ...\n", line_prefix);
1380 for (i = count; i < data->nr; i++) {
1381 uintmax_t added = data->files[i]->added;
1382 uintmax_t deleted = data->files[i]->deleted;
@@ -1388,6 +1387,9 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
1387 }
1388 adds += added;
1389 dels += deleted;
1390 + if (!extra_shown)
1391 + fprintf(options->file, "%s ...\n", line_prefix);
1392 + extra_shown = 1;
1393 }
1394 fprintf(options->file, "%s", line_prefix);
1395 fprintf(options->file,
t/t4049-diff-stat-count.sh new
+25
@@ -0,0 +1,25 @@
1 +#!/bin/sh
2 +# Copyright (c) 2011, Google Inc.
3 +
4 +test_description='diff --stat-count'
5 +. ./test-lib.sh
6 +
7 +test_expect_success setup '
8 + >a &&
9 + >b &&
10 + >c &&
11 + >d &&
12 + git add a b c d &&
13 + chmod +x c d &&
14 + echo a >a &&
15 + echo b >b &&
16 + cat >expect <<-\EOF
17 + a | 1 +
18 + b | 1 +
19 + 2 files changed, 2 insertions(+), 0 deletions(-)
20 + EOF
21 + git diff --stat --stat-count=2 >actual &&
22 + test_cmp expect actual
23 +'
24 +
25 +test_done