зеркало из https://github.com/microsoft/git.git
Merge branch 'ho/dirstat-by-file'
* ho/dirstat-by-file: diff --dirstat-by-file: count changed files, not lines
This commit is contained in:
Коммит
de81343562
|
@ -65,6 +65,9 @@ endif::git-format-patch[]
|
||||||
can be set with "--dirstat=limit". Changes in a child directory is not
|
can be set with "--dirstat=limit". Changes in a child directory is not
|
||||||
counted for the parent directory, unless "--cumulative" is used.
|
counted for the parent directory, unless "--cumulative" is used.
|
||||||
|
|
||||||
|
--dirstat-by-file[=limit]::
|
||||||
|
Same as --dirstat, but counts changed files instead of lines.
|
||||||
|
|
||||||
--summary::
|
--summary::
|
||||||
Output a condensed summary of extended header information
|
Output a condensed summary of extended header information
|
||||||
such as creations, renames and mode changes.
|
such as creations, renames and mode changes.
|
||||||
|
|
10
diff.c
10
diff.c
|
@ -1131,9 +1131,13 @@ static void show_dirstat(struct diff_options *options)
|
||||||
/*
|
/*
|
||||||
* Original minus copied is the removed material,
|
* Original minus copied is the removed material,
|
||||||
* added is the new material. They are both damages
|
* 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;
|
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);
|
ALLOC_GROW(dir.files, dir.nr + 1, dir.alloc);
|
||||||
dir.files[dir.nr].name = name;
|
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")) {
|
else if (!strcmp(arg, "--cumulative")) {
|
||||||
options->output_format |= DIFF_FORMAT_DIRSTAT;
|
options->output_format |= DIFF_FORMAT_DIRSTAT;
|
||||||
DIFF_OPT_SET(options, DIRSTAT_CUMULATIVE);
|
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"))
|
else if (!strcmp(arg, "--check"))
|
||||||
options->output_format |= DIFF_FORMAT_CHECKDIFF;
|
options->output_format |= DIFF_FORMAT_CHECKDIFF;
|
||||||
|
|
1
diff.h
1
diff.h
|
@ -64,6 +64,7 @@ typedef void (*diff_format_fn_t)(struct diff_queue_struct *q,
|
||||||
#define DIFF_OPT_RELATIVE_NAME (1 << 17)
|
#define DIFF_OPT_RELATIVE_NAME (1 << 17)
|
||||||
#define DIFF_OPT_IGNORE_SUBMODULES (1 << 18)
|
#define DIFF_OPT_IGNORE_SUBMODULES (1 << 18)
|
||||||
#define DIFF_OPT_DIRSTAT_CUMULATIVE (1 << 19)
|
#define DIFF_OPT_DIRSTAT_CUMULATIVE (1 << 19)
|
||||||
|
#define DIFF_OPT_DIRSTAT_BY_FILE (1 << 20)
|
||||||
#define DIFF_OPT_TST(opts, flag) ((opts)->flags & DIFF_OPT_##flag)
|
#define DIFF_OPT_TST(opts, flag) ((opts)->flags & DIFF_OPT_##flag)
|
||||||
#define DIFF_OPT_SET(opts, flag) ((opts)->flags |= DIFF_OPT_##flag)
|
#define DIFF_OPT_SET(opts, flag) ((opts)->flags |= DIFF_OPT_##flag)
|
||||||
#define DIFF_OPT_CLR(opts, flag) ((opts)->flags &= ~DIFF_OPT_##flag)
|
#define DIFF_OPT_CLR(opts, flag) ((opts)->flags &= ~DIFF_OPT_##flag)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче