diff options
author | Heikki Orsila <heikki.orsila@iki.fi> | 2008-09-05 22:27:35 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-09-05 14:04:26 -0700 |
commit | fd33777b7871eefa440f89ccf7c432895af09c74 (patch) | |
tree | 4a09d41bc8c7515e027575a955ed6aaac9c52740 /diff.c | |
parent | 80d12c23de4fbddfaee2f9bf7fe809f57d02e171 (diff) | |
download | git-fd33777b7871eefa440f89ccf7c432895af09c74.tar.gz |
diff --dirstat-by-file: count changed files, not lines
This new option --dirstat-by-file is the same as --dirstat, but it
counts "impacted files" instead of "impacted lines" (lines that are
added or removed).
Signed-off-by: Heikki Orsila <heikki.orsila@iki.fi>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff.c')
-rw-r--r-- | diff.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -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 --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; @@ -2476,6 +2480,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; |