Re: Add "--dirstat" for some directory statistics

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Mon, 11 Feb 2008, Johannes Schindelin wrote:
> 
> I mean, sometimes even 0.01% is worth showing.

I tried this, and no. It's not. Not even 0.1%. If you care at that level,  
you're better off just looking at the diffstat itself. The noise factor 
with the summary makes it useless with even 0.1%.

That said, the *reporting* sometimes looks better with tenths of percents. 
This is an example of "report in tenths of percent, limit to 1%":

   4.8% arch/um/include/
   6.1% arch/um/os-Linux/drivers/
   5.7% arch/um/os-Linux/include/
   2.6% arch/um/os-Linux/skas/
   1.7% arch/um/os-Linux/sys-i386/
   9.2% arch/um/os-Linux/sys-x86_64/
  69.6% arch/um/os-Linux/

and maybe that format would be nicer (and more "future proof" in case 
people want to make the limiting go down to fractional percentages too).

If people want to play around with it, here's a trial patch (and yes, if 
you want it down to 0.1%, you can use "--dirstat=0", and it will only 
remove the ones that really round down to 0.0%, but it really isn't any 
good for summaries any more).

For summaries, I'd suggest testing with something like

	git diff --dirstat=? v2.6.23..v2.6.24

and comparing the 0% cutoff (pretty damn useless) to 1 (already *much* 
better and perhaps appropriate as a "deep summary") to 2 (probably the 
best if you actually want a short summary) to 3 (fairly similar, but 
dropped a few "2.x%" cases that were relevant).

The 1% cutoff case is already big enough that I don't think it's good as a 
summary, and while it contains "more information", it's actually likely 
much more informative in that case to do the default 3% case, and then 
noticing that "drivers" and "include" are pretty high, and at that point 
it makes sense to say "ok, let's re-do it but limiting it to that 
subdirectory", and do a

	git diff --dirstat=3 v2.6.23..v2.6.24 drivers/

where now you'll actually see *more* information than for the 1% case, but 
only as it pertains for that drivers subdirectory.

So I seriously doubt that you often want to have small percentages, and 
that it's much more productive to give people the overview and then they 
can "drill down" into that overview.

Anyway, here's the patch to try out..

		Linus

---
 diff.c |   11 ++++++++-----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/diff.c b/diff.c
--- a/diff.c
+++ b/diff.c
@@ -1012,10 +1012,13 @@ static long gather_dirstat(struct diffstat_dir *dir, unsigned long changed, cons
 	}
 
 	if (baselen) {
-		int percent = this_dir * 100 / changed;
-		if (percent >= dir->percent) {
-			printf("%4d%% %.*s\n", percent, baselen, base);
-			return 0;
+		int permille = this_dir * 1000 / changed;
+		if (permille) {
+			int percent = permille / 10;
+			if (percent >= dir->percent) {
+				printf("%4d.%01d%% %.*s\n", percent, permille % 10, baselen, base);
+				return 0;
+			}
 		}
 	}
 	return this_dir;
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux