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

Re: [PATCH 3/3] diff --stat: sometimes use non-linear scaling.

From
Andreas Ericsson <ae@op5.se>
Date
Sep 29, 2006, 10:56 UTC
Message-ID
<451CFBC5.3020006@op5.se>
In-Reply-To
<7v64f8xs7p.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano wrote:
Show 37 quoted lines
> Martin Waitz <tali@admingilde.org> writes:
> 
>>> It should at least never be superlinear, I believe.
>> So if we want to keep the logarithmic scale we can do some maths:
>> ...
>> But only I have not succeeded in solving these equations, I always stop
>> at the last invariant :-(
> 
> There is another constraint you did not mention.  Here is the
> output from my another failed experiment:
> 
>  .gitignore                       |    1 -
>  Documentation/git-tar-tree.txt   |    3 +++
>  Documentation/git-upload-tar.txt |   39 -----------------------------
>  Documentation/git.txt            |    4 ----
>  Makefile                         |    1 -
>  builtin-tar-tree.c               |  130 +++++++++++++++-----------------------
>  builtin-upload-tar.c             |   74 ----------------------------------
>  git.c                            |    1 -
>  8 files changed, 53 insertions(+), 200 deletions(-)
> 
> The deletion from Documentation/git-upload-tar.txt looks much
> larger than addition to builtin-tar-tree.c in the above, but
> there are 50 lines added to builtin-tar-tree.c (which is why
> this experiment is a failure).
> 
> Because we are dealing with non-linear scaling, the total of
> scaled adds and scaled deletes does not equal to scaled total.
> We can deal with this in two ways.  Scale the total and
> distribute it, or scale adds and deletes individually and make
> sure the sum of scaled adds and deletes never exceed the width.
> Obviously the former is easier to implement but it was _wrong_.
> 
> The fitting algorithm in the posted patch scales the total to
> fit the alloted width and then distributes the result to adds
> and deletes.
> 
Why not just take the stupid and simple solution and make it:

file1 | +31,-19 +++ file2 | +19,-106 --- file3 | +10,-10 ###

That is, show the number of lines that actually changed, and print a fixed number of plusses or minuses after the numbers to make it easy to, at a glance, check if more lines were added than deleted or vice versa.

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231
Previous: Junio C HamanoNext: Johannes Schindelin
Message 16 of 18 in “diff --stat: sometimes use non-linear scaling.”
  1. 3/3 diff --stat: sometimes use non-linear scaling.Junio C Hamano, Sep 27, 2006
  2. David RientjesSep 27, 2006
  3. Junio C HamanoSep 27, 2006
  4. David RientjesSep 27, 2006
  5. Junio C HamanoSep 27, 2006
  6. David RientjesSep 27, 2006
  7. Junio C HamanoSep 27, 2006
  8. David RientjesSep 27, 2006
  9. Johannes SchindelinSep 27, 2006
  10. Petr BaudisOct 6, 2006
  11. Johannes SchindelinSep 27, 2006
  12. Martin WaitzSep 27, 2006
  13. Linus TorvaldsSep 27, 2006
  14. Martin WaitzSep 28, 2006
  15. Junio C HamanoSep 28, 2006
  16. Andreas EricssonSep 29, 2006
  17. Johannes SchindelinSep 27, 2006
  18. SeanSep 27, 2006

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.