{"thread":{"id":"15341","subject":"[PATCH] Add --filedirstat diff option","startedAt":"2008-09-02T23:51:48Z","lastAt":"2008-09-02T23:51:48Z","messageCount":1,"participants":["Heikki Orsila"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"89574","messageId":"20080902235148.GA25312@zakalwe.fi","threadId":"15341","inReplyTo":null,"subject":"[PATCH] Add --filedirstat diff option","fromName":"Heikki Orsila","fromEmail":"heikki.orsila@iki.fi","sentAt":"2008-09-02T23:51:48Z","receivedAt":"2008-09-02T23:51:48Z","isPatch":true,"sender":{"key":"heikki.orsila@iki.fi","avatar":null},"body":"--filedirstat is the same as --dirstat, but it counts \"damaged files\"\ninstead of \"damaged lines\" (lines that are added or removed).\n\nSigned-off-by: Heikki Orsila <heikki.orsila@iki.fi>\n---\nThis is version 2 of the patch. It fixes --filedirstat option handling.\n\n Documentation/diff-options.txt |    3 +++\n diff.c                         |   11 +++++++++--\n diff.h                         |    1 +\n 3 files changed, 13 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt\nindex 1759386..6e84f40 100644\n--- a/Documentation/diff-options.txt\n+++ b/Documentation/diff-options.txt\n@@ -66,6 +66,9 @@ endif::git-format-patch[]\n \tthe \"--cumulative\" flag, which adds up percentages recursively\n \teven when they have been already reported for a sub-directory.\n \n+--filedirstat[=limit]::\n+\tSame as --dirstat, but count changed files instead of lines.\n+\n --summary::\n \tOutput a condensed summary of extended header information\n \tsuch as creations, renames and mode changes.\ndiff --git a/diff.c b/diff.c\nindex 135dec4..393dea7 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -1110,9 +1110,13 @@ static void show_dirstat(struct diff_options *options)\n \t\t/*\n \t\t * Original minus copied is the removed material,\n \t\t * added is the new material.  They are both damages\n-\t\t * made to the preimage.\n+\t\t * made to the preimage. In --filedirstat mode, count\n+\t\t * damaged files, not damaged lines. This is done by\n+\t\t * counting only a single damaged line per file.\n \t\t */\n \t\tdamage = (p->one->size - copied) + added;\n+\t\tif (options->filedirstat && damage > 0)\n+\t\t\tdamage = 1;\n \n \t\tALLOC_GROW(dir.files, dir.nr + 1, dir.alloc);\n \t\tdir.files[dir.nr].name = name;\n@@ -2474,7 +2478,10 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)\n \t\toptions->output_format |= DIFF_FORMAT_DIRSTAT;\n \telse if (!strcmp(arg, \"--cumulative\"))\n \t\toptions->output_format |= DIFF_FORMAT_CUMULATIVE;\n-\telse if (!strcmp(arg, \"--check\"))\n+\telse if (opt_arg(arg, 0, \"filedirstat\", &options->dirstat_percent)) {\n+\t\toptions->output_format |= DIFF_FORMAT_DIRSTAT;\n+\t\toptions->filedirstat = 1;\n+\t} else if (!strcmp(arg, \"--check\"))\n \t\toptions->output_format |= DIFF_FORMAT_CHECKDIFF;\n \telse if (!strcmp(arg, \"--summary\"))\n \t\toptions->output_format |= DIFF_FORMAT_SUMMARY;\ndiff --git a/diff.h b/diff.h\nindex 50fb5dd..2832bb8 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -86,6 +86,7 @@ struct diff_options {\n \tint rename_limit;\n \tint warn_on_too_large_rename;\n \tint dirstat_percent;\n+\tint filedirstat;\n \tint setup;\n \tint abbrev;\n \tconst char *prefix;\n-- \n1.6.0.1\n"}]}