Re: [PATCHv3 1/3] diff.c: omit hidden entries from namelen calculation with --stat
- From
Junio C Hamano <gitster@pobox.com>
- Date
- May 27, 2011, 22:45 UTC
- Message-ID
- <7v39jzsqxt.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <4DE00755.1020404@drmicha.warpmail.net>
Michael J Gruber <git@drmicha.warpmail.net> writes:
> Again, I'm sorry I'm not seeing through the call chain here.
diff_flush() notices it needs to produce textual patch and count added or deleted lines here:
if (output_format & (DIFF_FORMAT_DIFFSTAT|DIFF_FORMAT... struct diffstat_t diffstat;
memset(&diffstat, 0, sizeof(struct diffstat_t));
for (i = 0; i < q->nr; i++) {
struct diff_filepair *p = q->queue[i];
if (check_pair_status(p))
diff_flush_stat(p, options, &diffstat);
}
if (output_format & DIFF_FORMAT_NUMSTAT)
show_numstat(&diffstat, options);
if (output_format & DIFF_FORMAT_DIFFSTAT)
show_stats(&diffstat, options);
if (output_format & DIFF_FORMAT_SHORTSTAT)
show_shortstats(&diffstat, options);
free_diffstat_info(&diffstat);
separator++;
}In the loop, it calls diff_flush_stat() for each and every filepair in the queue. The result is collected in &diffstat, and that is what your patch works on in show_stats() function. Before you look at it in show_stats(), the same &diffstat may be examined by show_numstat(), and after you look at it, the same &diffstat may be examined by show_shortstats().
diff_flush_stat() calls run_diffstat() to get textual patch for one filepair. It ends up calling builtin_diffstat().
builtin_diffstat() looks at the preimage and postimage, and feeds the low level xdiff machinery with it, and uses diffstat_consume() callbac to count the +/- lines in the patch between the two.
Even though three show_*stat* function look at the same &diffstat, two have duplicated logic to ignore (and uncount) a path whose executable bit was changed without any other change, with:
if (!it->is_renamed && (added + deleted) == 0)
ignore it!