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

Re: "git diff --ignore-space-change --stat" lists files with only whitespace differences as "changed"

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 18, 2017, 20:57 UTC
Message-ID
<xmqqvatc3x3r.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20170118111705.6bqzkklluikda3r5@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
> So I dunno. A sensible rule to me is "iff -p would show a diff header,
> then --stat should mention it".
True but tricky (you need a better definition of "a diff header").

In addition to a new and deleted file, does a file whose executable bit was flipped need mention? If so, then "diff --git" is the diff header in the above. Otherwise "@@ ... @@", iow, "iff -p would show any hunk".

I think the patch implements the latter, which I think is sensible.
Show 17 quoted lines
> +		/*
> +		 * Omit diffstats where nothing changed. Even if
> +		 * !same_contents, this might be the case due to ignoring
> +		 * whitespace changes, etc.
> +		 *
> +		 * But note that we special-case additions and deletions,
> +		 * as adding an empty file, for example, is still of interest.
> +		 */
> +		if (DIFF_FILE_VALID(one) && DIFF_FILE_VALID(two)) {
> +			struct diffstat_file *file =
> +				diffstat->files[diffstat->nr - 1];
> +			if (!file->added && !file->deleted) {
> +				free_diffstat_file(file);
> +				diffstat->nr--;
> +			}
> +		}
>  	}
Previous: Jeff KingNext: Jeff King
Message 3 of 5 in “"git diff --ignore-space-change --stat" lists files with only whitespace differences as "changed"”
  1. Matt McCutchenJan 18, 2017
  2. Jeff KingJan 18, 2017
  3. Junio C HamanoJan 18, 2017
  4. Jeff KingJan 18, 2017
  5. Junio C HamanoJan 18, 2017

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.