Thread (2 messages) flat view 2 messages, 2 authors, 2016-06-15
  • (off-list ancestor, not in this archive)
  • Re: diff --stat · Junio C Hamano <hidden> · 2016-06-15
  • Re: diff --stat · Jeff King <hidden> · 2016-06-15

Re: diff --stat

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:53:04

Jeff King [off-list ref] writes:
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 ;-).
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help