From: Junio C Hamano Date: Wed, 04 May 2011 04:37:04 GMT Subject: Re: [PATCHv2 1/2] diff: introduce --stat-lines to limit the stat lines Message-ID: <7vvcxrf5e7.fsf@alter.siamese.dyndns.org> In-Reply-To: <102e117f7a9f7fd6e652f23d5630db973e8e52b8.1304419588.git.git@drmicha.warpmail.net> Michael J Gruber writes: > @@ -1302,7 +1304,7 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options) > else > width = max_change; > > - for (i = 0; i < data->nr; i++) { > + for (i = 0; i < count; i++) { > const char *prefix = ""; > char *name = data->files[i]->print_name; > uintmax_t added = data->files[i]->added; This first loop can omit a "struct diffstat_file" that is not a rename and does not add nor delete any lines (look for "total_files--"), but you do not seem to compensate for it. If you have such a record in the earlier part of the result for whatever reason, you would end up showing fewer entries than what "count" indicates in this loop.