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

Re: diff --stat

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 14, 2012, 20:07 UTC
Message-ID
<7vfwed6uws.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20120214195036.GD12072@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 7 quoted lines
> Hmm. Looking at scale_linear, the formula is:
>
>    return ((it - 1) * (width - 1) + max_change - 1) / (max_change - 1);
>
> I don't see how that can be accurate, since the magnitude of the "-1"
> tweak will vary based on the value of "it". This code is due to
> 3ed74e6, but I don't quite follow the logic in the commit message.
Doesn't it need +1 at the end, I wonder?  We want to map:
 - zero to zero
 - any number to at least 1

so scaling a non-zero "it" so that maximum maps to (width-1) and then adding 1 would be the right way for the latter case.

Of course, an easy way out without worrying about the correct math is to scale the total and the smaller one and then declare that the scaled larger one is the difference between the two. That way, both of these two files have 109 in total so the length of the entire graph would be the same ;-).

Previous: Jeff KingNext: Jeff King
Message 3 of 7 in “diff --stat”
  1. Junio C HamanoFeb 14, 2012
  2. Jeff KingFeb 14, 2012
  3. Junio C HamanoFeb 14, 2012
  4. Jeff KingFeb 14, 2012
  5. Junio C HamanoFeb 14, 2012
  6. Jeff KingFeb 14, 2012
  7. Junio C HamanoFeb 14, 2012

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.