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

Re: Counter-intuitive result from diff -C --stat

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 1, 2017, 01:15 UTC
Message-ID
<xmqqd1g760n4.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20161228080916.72id4hzqxfbygtth@glandium.org>
Mike Hommey <mh@glandium.org> writes:
Show 14 quoted lines
> Hi,
>
> So I was checking out differences between two branches, accounting for
> file moves with -C, and was surprised by the number of insertions and
> deletions that it indicated, because it was telling me I had removed
> more than I added, which I really don't think is true.
>
> I took a closer look, and what happens is that I had a lot of stuff in
> a __init__.py file that I moved to another file, while keeping a now
> new, empty, __init__.py file.
>
> Which means while diff counts the deletions from __init__.py, it doesn't
> count the additions from the move because it is a move, leading to a
> counter-intuitive result.
Intuition is in the eyes of observer.  

A pairing of the original and the result you saw might be not very useful (which I have no opinion on), but in the context of the chosen pairing of the original and the result, in order to produce the final result, you started from a copy of the original and removed quite a lot while adding just a bit, so what you saw was an outcome that was deliberately designed.

Previous: Mike Hommey
Message 2 of 2 in “Counter-intuitive result from diff -C --stat”
  1. Mike HommeyDec 28, 2016
  2. Junio C HamanoJan 1, 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.