Skip to content

Commit f88d225

Browse files
committed
diff --cumulative is a sub-option of --dirstat
The option used to be implemented as if it is a totally independent one, but "git diff --cumulative" would not mean anything without "--dirstat". This makes --cumulative imply --dirstat. Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent ff2549d commit f88d225

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

diff.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,7 @@ static void show_dirstat(struct diff_options *options)
10721072
dir.alloc = 0;
10731073
dir.nr = 0;
10741074
dir.percent = options->dirstat_percent;
1075-
dir.cumulative = options->output_format & DIFF_FORMAT_CUMULATIVE;
1075+
dir.cumulative = DIFF_OPT_TST(options, DIRSTAT_CUMULATIVE);
10761076

10771077
changed = 0;
10781078
for (i = 0; i < q->nr; i++) {
@@ -2298,6 +2298,7 @@ void diff_setup(struct diff_options *options)
22982298
options->break_opt = -1;
22992299
options->rename_limit = -1;
23002300
options->dirstat_percent = 3;
2301+
DIFF_OPT_CLR(options, DIRSTAT_CUMULATIVE);
23012302
options->context = 3;
23022303

23032304
options->change = diff_change;
@@ -2470,8 +2471,10 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
24702471
options->output_format |= DIFF_FORMAT_SHORTSTAT;
24712472
else if (opt_arg(arg, 'X', "dirstat", &options->dirstat_percent))
24722473
options->output_format |= DIFF_FORMAT_DIRSTAT;
2473-
else if (!strcmp(arg, "--cumulative"))
2474-
options->output_format |= DIFF_FORMAT_CUMULATIVE;
2474+
else if (!strcmp(arg, "--cumulative")) {
2475+
options->output_format |= DIFF_FORMAT_DIRSTAT;
2476+
DIFF_OPT_SET(options, DIRSTAT_CUMULATIVE);
2477+
}
24752478
else if (!strcmp(arg, "--check"))
24762479
options->output_format |= DIFF_FORMAT_CHECKDIFF;
24772480
else if (!strcmp(arg, "--summary"))

diff.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ typedef void (*diff_format_fn_t)(struct diff_queue_struct *q,
3131
#define DIFF_FORMAT_PATCH 0x0010
3232
#define DIFF_FORMAT_SHORTSTAT 0x0020
3333
#define DIFF_FORMAT_DIRSTAT 0x0040
34-
#define DIFF_FORMAT_CUMULATIVE 0x0080
3534

3635
/* These override all above */
3736
#define DIFF_FORMAT_NAME 0x0100
@@ -64,6 +63,7 @@ typedef void (*diff_format_fn_t)(struct diff_queue_struct *q,
6463
#define DIFF_OPT_CHECK_FAILED (1 << 16)
6564
#define DIFF_OPT_RELATIVE_NAME (1 << 17)
6665
#define DIFF_OPT_IGNORE_SUBMODULES (1 << 18)
66+
#define DIFF_OPT_DIRSTAT_CUMULATIVE (1 << 19)
6767
#define DIFF_OPT_TST(opts, flag) ((opts)->flags & DIFF_OPT_##flag)
6868
#define DIFF_OPT_SET(opts, flag) ((opts)->flags |= DIFF_OPT_##flag)
6969
#define DIFF_OPT_CLR(opts, flag) ((opts)->flags &= ~DIFF_OPT_##flag)

0 commit comments

Comments
 (0)