All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heikki Orsila <heikki.orsila@iki.fi>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>
Subject: [PATCH] Add --filedirstat diff option
Date: Mon, 1 Sep 2008 04:12:59 +0300	[thread overview]
Message-ID: <20080901011259.GA31696@zakalwe.fi> (raw)

--filedirstat is the same as --dirstat, but it counts "damaged files"
instead of "damaged lines" (lines that are added or removed).

Signed-off-by: Heikki Orsila <heikki.orsila@iki.fi>
---
Example of Linux v2.6.25..v2.6.26:

$ git diff --filedirstat v2.6.25..v2.6.26 
   3.3% arch/arm/
   6.0% arch/powerpc/
   3.8% arch/x86/
  12.1% arch/
   3.4% drivers/media/video/
   6.8% drivers/net/
  26.5% drivers/
   6.4% fs/
   4.5% include/linux/
  13.0% include/
   5.9% net/

$ git diff --dirstat v2.6.25..v2.6.26 
   4.9% arch/arm/
   9.0% arch/powerpc/configs/
  14.6% arch/
   5.0% drivers/media/video/
   4.2% drivers/media/
   5.5% drivers/net/sk98lin/
   6.6% drivers/net/wireless/
   5.7% drivers/net/
   4.8% drivers/s390/net/
  17.8% drivers/
   6.4% include/
   5.1% net/


 Documentation/diff-options.txt |    3 +++
 diff.c                         |   11 +++++++++--
 diff.h                         |    1 +
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
index 1759386..6e84f40 100644
--- a/Documentation/diff-options.txt
+++ b/Documentation/diff-options.txt
@@ -66,6 +66,9 @@ endif::git-format-patch[]
 	the "--cumulative" flag, which adds up percentages recursively
 	even when they have been already reported for a sub-directory.
 
+--filedirstat[=limit]::
+	Same as --dirstat, but count changed files instead of lines.
+
 --summary::
 	Output a condensed summary of extended header information
 	such as creations, renames and mode changes.
diff --git a/diff.c b/diff.c
index 135dec4..48f33d6 100644
--- a/diff.c
+++ b/diff.c
@@ -1110,9 +1110,13 @@ static void show_dirstat(struct diff_options *options)
 		/*
 		 * Original minus copied is the removed material,
 		 * added is the new material.  They are both damages
-		 * made to the preimage.
+		 * made to the preimage. In --filedirstat mode, count
+		 * damaged files, not damaged lines. This is done by
+		 * counting only a single damaged line per file.
 		 */
 		damage = (p->one->size - copied) + added;
+		if (options->filedirstat && damage > 0)
+			damage = 1;
 
 		ALLOC_GROW(dir.files, dir.nr + 1, dir.alloc);
 		dir.files[dir.nr].name = name;
@@ -2474,7 +2478,10 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
 		options->output_format |= DIFF_FORMAT_DIRSTAT;
 	else if (!strcmp(arg, "--cumulative"))
 		options->output_format |= DIFF_FORMAT_CUMULATIVE;
-	else if (!strcmp(arg, "--check"))
+	else if (opt_arg(arg, 'X', "filedirstat", &options->dirstat_percent)) {
+		options->output_format |= DIFF_FORMAT_DIRSTAT;
+		options->filedirstat = 1;
+	} else if (!strcmp(arg, "--check"))
 		options->output_format |= DIFF_FORMAT_CHECKDIFF;
 	else if (!strcmp(arg, "--summary"))
 		options->output_format |= DIFF_FORMAT_SUMMARY;
diff --git a/diff.h b/diff.h
index 50fb5dd..2832bb8 100644
--- a/diff.h
+++ b/diff.h
@@ -86,6 +86,7 @@ struct diff_options {
 	int rename_limit;
 	int warn_on_too_large_rename;
 	int dirstat_percent;
+	int filedirstat;
 	int setup;
 	int abbrev;
 	const char *prefix;
-- 
1.6.0.1

             reply	other threads:[~2008-09-01  1:14 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-01  1:12 Heikki Orsila [this message]
2008-09-02  6:57 ` [PATCH] Add --filedirstat diff option Junio C Hamano
2008-09-02 11:58   ` Heikki Orsila
2008-09-02 23:40     ` Junio C Hamano
2008-09-02 23:55       ` Junio C Hamano
2008-09-03  0:08         ` Heikki Orsila
2008-09-03  0:28           ` Re* " Junio C Hamano
2008-09-03  0:39             ` Heikki Orsila
2008-09-03  0:12         ` Jeff King
2008-09-03  0:18           ` Heikki Orsila
2008-09-03  0:44           ` Junio C Hamano
2008-09-03 12:47             ` Jeff King
  -- strict thread matches above, loose matches on Subject: below --
2008-09-02 23:51 Heikki Orsila

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080901011259.GA31696@zakalwe.fi \
    --to=heikki.orsila@iki.fi \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.