Skip to content

Commit e5f85df

Browse files
committed
diff --stat-count: finishing touches
Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 86e1ce9 commit e5f85df

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

diff.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,6 +1247,7 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
12471247
int width, name_width, count;
12481248
const char *reset, *add_c, *del_c;
12491249
const char *line_prefix = "";
1250+
int extra_shown = 0;
12501251
struct strbuf *msg = NULL;
12511252

12521253
if (data->nr == 0)
@@ -1376,8 +1377,6 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
13761377
show_graph(options->file, '-', del, del_c, reset);
13771378
fprintf(options->file, "\n");
13781379
}
1379-
if (count < data->nr)
1380-
fprintf(options->file, "%s ...\n", line_prefix);
13811380
for (i = count; i < data->nr; i++) {
13821381
uintmax_t added = data->files[i]->added;
13831382
uintmax_t deleted = data->files[i]->deleted;
@@ -1388,6 +1387,9 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
13881387
}
13891388
adds += added;
13901389
dels += deleted;
1390+
if (!extra_shown)
1391+
fprintf(options->file, "%s ...\n", line_prefix);
1392+
extra_shown = 1;
13911393
}
13921394
fprintf(options->file, "%s", line_prefix);
13931395
fprintf(options->file,

t/t4049-diff-stat-count.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

0 commit comments

Comments
 (0)