aboutsummaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2008-09-25 08:41:42 -0700
committerShawn O. Pearce <spearce@spearce.org>2008-09-25 08:41:42 -0700
commitde813435621b914f2b3e148c6cc94ab0066300c3 (patch)
treedf8dc1ffcdb555e334d310cbb26d34ef12f28aed /diff.c
parent1500f7bc1366e71edb7e8a31f3cf5614e9591cc2 (diff)
parentfd33777b7871eefa440f89ccf7c432895af09c74 (diff)
downloadgit-de813435621b914f2b3e148c6cc94ab0066300c3.tar.gz
git-de813435621b914f2b3e148c6cc94ab0066300c3.tar.xz
Merge branch 'ho/dirstat-by-file'
* ho/dirstat-by-file: diff --dirstat-by-file: count changed files, not lines
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/diff.c b/diff.c
index 9053d4d1f..a2f4850d4 100644
--- a/diff.c
+++ b/diff.c
@@ -1131,9 +1131,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 --dirstat-by-file 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 (DIFF_OPT_TST(options, DIRSTAT_BY_FILE) && damage > 0)
+ damage = 1;
ALLOC_GROW(dir.files, dir.nr + 1, dir.alloc);
dir.files[dir.nr].name = name;
@@ -2511,6 +2515,10 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
else if (!strcmp(arg, "--cumulative")) {
options->output_format |= DIFF_FORMAT_DIRSTAT;
DIFF_OPT_SET(options, DIRSTAT_CUMULATIVE);
+ } else if (opt_arg(arg, 0, "dirstat-by-file",
+ &options->dirstat_percent)) {
+ options->output_format |= DIFF_FORMAT_DIRSTAT;
+ DIFF_OPT_SET(options, DIRSTAT_BY_FILE);
}
else if (!strcmp(arg, "--check"))
options->output_format |= DIFF_FORMAT_CHECKDIFF;