On Sat, Jan 02, 2016 at 06:46:52PM +0000, Sandro Tosi wrote: > Adding Thomas, the upstream author of diffstat > > Hey Thomas, > what's your take on this report? > > On Sun, Aug 2, 2015 at 6:39 PM, Josh Triplett <[email protected]> wrote: > > On Sat, Aug 01, 2015 at 06:33:39PM -0700, Josh Triplett wrote: > >> If the diff contains files with very large diffs, diffstat's automatic > >> scaling can cause files with small diffs to display zero '-' or '+' > >> characters. This hides key information from the diffstat, namely > >> the direction of the diff. diffstat should always display at least one > >> '-' for a file with lines removed, and at least one '+' for a file with > >> lines added, regardless of scaling. > > > > Steps to reproduce: > > > > /tmp$ mkdir foo > > /tmp$ cd foo/ > > /tmp/foo$ mkdir 1 > > /tmp/foo$ mkdir 2 > > /tmp/foo$ echo one-line > 2/only-in-2 > > /tmp/foo$ echo one-line > 1/only-in-1 > > /tmp/foo$ seq 1 100000 > 2/big-file > > /tmp/foo$ diff -Naur 1 2 | diffstat
If it used
/tmp/foo$ diff -Naur 1 2 | diffstat -r2
> > big-file |100000
> > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> > only-in-1 | 1
> > only-in-2 | 1
> > 3 files changed, 100001 insertions(+), 1 deletion(-)
the output would be
big-file |100000
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
only-in-1 | 1 -
only-in-2 | 1 +
3 files changed, 100001 insertions(+), 1 deletion(-)
man diffstat:
-r code
provides optional rounding of the data shown in histogram,
rather than truncating with error adjustments.
0 is the default. No rounding is performed, but accumulated
errors are added to following columns.
1 rounds the data
2 rounds the data and adjusts the histogram to ensure that it
displays something if there are any differences even if those
would normally be rounded to zero.
I don't see a need to modify diffstat, since it does what was asked.
--
Thomas E. Dickey <[email protected]>
http://invisible-island.net
ftp://invisible-island.net
signature.asc
Description: Digital signature

