Skip to content

Commit 358e460

Browse files
Michael J Grubergitster
authored andcommitted
diff.c: omit hidden entries from namelen calculation with --stat
Currently, --stat calculates the longest name from all items but then drops some (mode changes) from the output later on. Instead, drop them from the namelen generation and calculation. Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 0b9deec commit 358e460

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

diff.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,6 +1278,10 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
12781278
for (i = 0; i < data->nr; i++) {
12791279
struct diffstat_file *file = data->files[i];
12801280
uintmax_t change = file->added + file->deleted;
1281+
if (!data->files[i]->is_renamed &&
1282+
(change == 0)) {
1283+
continue;
1284+
}
12811285
fill_print_name(file);
12821286
len = strlen(file->print_name);
12831287
if (max_len < len)
@@ -1309,6 +1313,11 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
13091313
uintmax_t deleted = data->files[i]->deleted;
13101314
int name_len;
13111315

1316+
if (!data->files[i]->is_renamed &&
1317+
(added + deleted == 0)) {
1318+
total_files--;
1319+
continue;
1320+
}
13121321
/*
13131322
* "scale" the filename
13141323
*/
@@ -1343,11 +1352,6 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
13431352
fprintf(options->file, " Unmerged\n");
13441353
continue;
13451354
}
1346-
else if (!data->files[i]->is_renamed &&
1347-
(added + deleted == 0)) {
1348-
total_files--;
1349-
continue;
1350-
}
13511355

13521356
/*
13531357
* scale the add/delete

0 commit comments

Comments
 (0)