git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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!
Previous: Michael J GruberNext: Michael J Gruber
Message 14 of 21 in “diff: introduce --stat-lines to limit the stat lines”
  1. 1/2 diff: introduce --stat-lines to limit the stat linesMichael J Gruber, Apr 29, 2011
  2. 2/2 diff-options.txt: describe --stat-{width,name-width,lines}Michael J Gruber, Apr 29, 2011
  3. Michael J GruberApr 29, 2011
  4. Junio C HamanoApr 29, 2011
  5. Michael J GruberMay 1, 2011
  6. Junio C HamanoMay 1, 2011
  7. 1/2 diff: introduce --stat-lines to limit the stat linesMichael J Gruber, May 3, 2011
  8. Junio C HamanoMay 3, 2011
  9. Michael J GruberMay 4, 2011
  10. 0/3 diff.c: --stat-count=<n>Michael J Gruber, May 27, 2011
  11. 1/3 diff.c: omit hidden entries from namelen calculation with --statMichael J Gruber, May 27, 2011
  12. Junio C HamanoMay 27, 2011
  13. Michael J GruberMay 27, 2011
  14. Junio C HamanoMay 27, 2011
  15. 2/3 diff: introduce --stat-lines to limit the stat linesMichael J Gruber, May 27, 2011
  16. Junio C HamanoMay 28, 2011
  17. Michael J GruberMay 30, 2011
  18. Junio C HamanoMay 30, 2011
  19. 3/3 diff-options.txt: describe --stat-{width,name-width,count}Michael J Gruber, May 27, 2011
  20. Junio C HamanoMay 4, 2011
  21. 2/2 diff-options.txt: describe --stat-{width,name-width,count}Michael J Gruber, May 3, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.