* [PATCH] Add --filedirstat diff option
@ 2008-09-02 23:51 Heikki Orsila
0 siblings, 0 replies; 11+ messages in thread
From: Heikki Orsila @ 2008-09-02 23:51 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano
--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>
---
This is version 2 of the patch. It fixes --filedirstat option handling.
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..393dea7 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, 0, "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
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH] Add --filedirstat diff option
@ 2008-09-01 1:12 Heikki Orsila
2008-09-02 6:57 ` Junio C Hamano
0 siblings, 1 reply; 11+ messages in thread
From: Heikki Orsila @ 2008-09-01 1:12 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano
--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
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH] Add --filedirstat diff option
2008-09-01 1:12 Heikki Orsila
@ 2008-09-02 6:57 ` Junio C Hamano
2008-09-02 11:58 ` Heikki Orsila
0 siblings, 1 reply; 11+ messages in thread
From: Junio C Hamano @ 2008-09-02 6:57 UTC (permalink / raw)
To: Heikki Orsila; +Cc: git
Heikki Orsila <heikki.orsila@iki.fi> writes:
> @@ -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;
Why 'X'? It would never match, confusing to the reader, and risks a
sudden change in behaviour when these statements are reordered or somebody
mechanically attempts to convert this to parse_options().
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] Add --filedirstat diff option
2008-09-02 6:57 ` Junio C Hamano
@ 2008-09-02 11:58 ` Heikki Orsila
2008-09-02 23:40 ` Junio C Hamano
0 siblings, 1 reply; 11+ messages in thread
From: Heikki Orsila @ 2008-09-02 11:58 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
On Mon, Sep 01, 2008 at 11:57:46PM -0700, Junio C Hamano wrote:
> Heikki Orsila <heikki.orsila@iki.fi> writes:
>
> > @@ -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;
>
> Why 'X'? It would never match, confusing to the reader, and risks a
> sudden change in behaviour when these statements are reordered or somebody
> mechanically attempts to convert this to parse_options().
This is embarrassing.. I just copied the previous "dirstat" line..
*grin*
Anyway, what about the concept of filedirstat? Is it agreeable?
--
Heikki Orsila
heikki.orsila@iki.fi
http://www.iki.fi/shd
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] Add --filedirstat diff option
2008-09-02 11:58 ` Heikki Orsila
@ 2008-09-02 23:40 ` Junio C Hamano
2008-09-02 23:55 ` Junio C Hamano
0 siblings, 1 reply; 11+ messages in thread
From: Junio C Hamano @ 2008-09-02 23:40 UTC (permalink / raw)
To: Heikki Orsila; +Cc: git
Heikki Orsila <shd@modeemi.fi> writes:
> On Mon, Sep 01, 2008 at 11:57:46PM -0700, Junio C Hamano wrote:
>> Heikki Orsila <heikki.orsila@iki.fi> writes:
>>
>> > @@ -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;
>>
>> Why 'X'? It would never match, confusing to the reader, and risks a
>> sudden change in behaviour when these statements are reordered or somebody
>> mechanically attempts to convert this to parse_options().
>
> This is embarrassing.. I just copied the previous "dirstat" line..
> *grin*
>
> Anyway, what about the concept of filedirstat? Is it agreeable?
I am neutral.
I do not think the additional code hurts anybody, so I wouldn't say I do
not want to have the patch anywhere near my tree, but on the other hand,
personally I do not find the feature as interesting or useful as dirstat.
Maybe there are many others who do find this option useful. I dunno.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] Add --filedirstat diff option
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:12 ` Jeff King
0 siblings, 2 replies; 11+ messages in thread
From: Junio C Hamano @ 2008-09-02 23:55 UTC (permalink / raw)
To: Heikki Orsila; +Cc: git
Junio C Hamano <gitster@pobox.com> writes:
> Heikki Orsila <shd@modeemi.fi> writes:
>
>> On Mon, Sep 01, 2008 at 11:57:46PM -0700, Junio C Hamano wrote:
>>> Heikki Orsila <heikki.orsila@iki.fi> writes:
>>>
>>> > @@ -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;
>>>
>>> Why 'X'? It would never match, confusing to the reader, and risks a
>>> sudden change in behaviour when these statements are reordered or somebody
>>> mechanically attempts to convert this to parse_options().
>>
>> This is embarrassing.. I just copied the previous "dirstat" line..
>> *grin*
>>
>> Anyway, what about the concept of filedirstat? Is it agreeable?
>
> I am neutral.
>
> I do not think the additional code hurts anybody, so I wouldn't say I do
> not want to have the patch anywhere near my tree, but on the other hand,
> personally I do not find the feature as interesting or useful as dirstat.
>
> Maybe there are many others who do find this option useful. I dunno.
While I was thinking about potential issues before queuing this, I
realized that I forgot to mention one thing.
The name.
"filedirstat" is simply too long to type, and it has a certain "Huh?"
factor --- is it about file, or is it about directory?
This option essentially is just the dirstat but with different logic to
compute how big the damage is. Conceptually, the original one gives one
"damage point" to each added or deleted line.
$ git show --dirstat=<one-point-per-line>
and yours awards one point to each file, whatever the size of the damage
is.
$ git show --dirstat=<one-point-per-file>
I cannot come up with a short-and-sweet name for one-point-per-X offhand,
but expressing this variant as an option to --dirstat will leave the door
open for other people to come up with different system to award damage
points. Perhaps
$ git show --dirstat=exclude-typofixes
might even be not just interesting but useful ;-)
Again, I mention this not because I want to reject the patch, but because
I hope other people with better UI taste may come up with an alternative
before I finish handling other patches.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] Add --filedirstat diff option
2008-09-02 23:55 ` Junio C Hamano
@ 2008-09-03 0:08 ` Heikki Orsila
2008-09-03 0:12 ` Jeff King
1 sibling, 0 replies; 11+ messages in thread
From: Heikki Orsila @ 2008-09-03 0:08 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
On Tue, Sep 02, 2008 at 04:55:39PM -0700, Junio C Hamano wrote:
> realized that I forgot to mention one thing.
>
> The name.
>
> "filedirstat" is simply too long to type, and it has a certain "Huh?"
> factor --- is it about file, or is it about directory?
>
> This option essentially is just the dirstat but with different logic to
> compute how big the damage is. Conceptually, the original one gives one
> "damage point" to each added or deleted line.
>
> $ git show --dirstat=<one-point-per-line>
>
> and yours awards one point to each file, whatever the size of the damage
> is.
>
> $ git show --dirstat=<one-point-per-file>
>
> I cannot come up with a short-and-sweet name for one-point-per-X offhand,
> but expressing this variant as an option to --dirstat will leave the door
> open for other people to come up with different system to award damage
> points. Perhaps
>
> $ git show --dirstat=exclude-typofixes
>
> might even be not just interesting but useful ;-)
I wouldn't add new semantics for --dirstat=x since it's easy to add
new options. We already have --cumulative, so adding options is not
new. How about "--dirstat --filemode"? It's long, but it is obvious. I
don't think length is relevant here. A shorter but obscure syntax would
be "--dirstat2" :-)
--
Heikki Orsila
heikki.orsila@iki.fi
http://www.iki.fi/shd
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] Add --filedirstat diff option
2008-09-02 23:55 ` Junio C Hamano
2008-09-03 0:08 ` Heikki Orsila
@ 2008-09-03 0:12 ` Jeff King
2008-09-03 0:18 ` Heikki Orsila
2008-09-03 0:44 ` Junio C Hamano
1 sibling, 2 replies; 11+ messages in thread
From: Jeff King @ 2008-09-03 0:12 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Heikki Orsila, git
On Tue, Sep 02, 2008 at 04:55:39PM -0700, Junio C Hamano wrote:
> "filedirstat" is simply too long to type, and it has a certain "Huh?"
> factor --- is it about file, or is it about directory?
I had the same thought when I saw the original patch...
> This option essentially is just the dirstat but with different logic to
> compute how big the damage is. Conceptually, the original one gives one
> "damage point" to each added or deleted line.
>
> $ git show --dirstat=<one-point-per-line>
...and I thought of --dirstat-byfile. So maybe:
--dirstat=byfile
and
--dirstat=byline
defaulting to byline (or by-line if preferred).
-Peff
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] Add --filedirstat diff option
2008-09-03 0:12 ` Jeff King
@ 2008-09-03 0:18 ` Heikki Orsila
2008-09-03 0:44 ` Junio C Hamano
1 sibling, 0 replies; 11+ messages in thread
From: Heikki Orsila @ 2008-09-03 0:18 UTC (permalink / raw)
To: Jeff King; +Cc: Junio C Hamano, git
On Tue, Sep 02, 2008 at 08:12:54PM -0400, Jeff King wrote:
> ...and I thought of --dirstat-byfile. So maybe:
I like --dirstat-byfile more than --dirstat=byfile as dirstat already
takes a cut-off percent parameter.
--
Heikki Orsila
heikki.orsila@iki.fi
http://www.iki.fi/shd
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] Add --filedirstat diff option
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
1 sibling, 1 reply; 11+ messages in thread
From: Junio C Hamano @ 2008-09-03 0:44 UTC (permalink / raw)
To: Jeff King; +Cc: Heikki Orsila, git
Jeff King <peff@peff.net> writes:
> On Tue, Sep 02, 2008 at 04:55:39PM -0700, Junio C Hamano wrote:
>
>> "filedirstat" is simply too long to type, and it has a certain "Huh?"
>> factor --- is it about file, or is it about directory?
>
> I had the same thought when I saw the original patch...
>
>> This option essentially is just the dirstat but with different logic to
>> compute how big the damage is. Conceptually, the original one gives one
>> "damage point" to each added or deleted line.
>>
>> $ git show --dirstat=<one-point-per-line>
>
> ...and I thought of --dirstat-byfile. So maybe:
>
> --dirstat=byfile
>
> and
>
> --dirstat=byline
>
> defaulting to byline (or by-line if preferred).
As Heikki points out (and I missed this initially myself), --dirstat[=x]
already exists and it gives the cut-off-point.
Perhaps "--dirstat-by-file" that implies "--dirstat" (with the
understanding (and documentation) that "--dirstat" is a shorthand for
"--dirstat-by-line" that does not exist)?
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2008-09-03 12:49 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-02 23:51 [PATCH] Add --filedirstat diff option Heikki Orsila
-- strict thread matches above, loose matches on Subject: below --
2008-09-01 1:12 Heikki Orsila
2008-09-02 6:57 ` 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: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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).