@matheusbsbs / matheus-bagliano / commits / f88d225feb
Fork 0

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>

Junio C Hamano committed Sep 2, 2008 at 17:28 UTC f88d225feb117f0429540da90b2552e198fa2e82
2 files changed +7 -4
diff.c
+6 -3
@@ -1072,7 +1072,7 @@ static void show_dirstat(struct diff_options *options)
1072 dir.alloc = 0;
1073 dir.nr = 0;
1074 dir.percent = options->dirstat_percent;
1075 - dir.cumulative = options->output_format & DIFF_FORMAT_CUMULATIVE;
1075 + dir.cumulative = DIFF_OPT_TST(options, DIRSTAT_CUMULATIVE);
1076
1077 changed = 0;
1078 for (i = 0; i < q->nr; i++) {
@@ -2298,6 +2298,7 @@ void diff_setup(struct diff_options *options)
2298 options->break_opt = -1;
2299 options->rename_limit = -1;
2300 options->dirstat_percent = 3;
2301 + DIFF_OPT_CLR(options, DIRSTAT_CUMULATIVE);
2302 options->context = 3;
2303
2304 options->change = diff_change;
@@ -2470,8 +2471,10 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
2471 options->output_format |= DIFF_FORMAT_SHORTSTAT;
2472 else if (opt_arg(arg, 'X', "dirstat", &options->dirstat_percent))
2473 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 + }
2478 else if (!strcmp(arg, "--check"))
2479 options->output_format |= DIFF_FORMAT_CHECKDIFF;
2480 else if (!strcmp(arg, "--summary"))
diff.h
+1 -1
@@ -31,7 +31,6 @@ typedef void (*diff_format_fn_t)(struct diff_queue_struct *q,
31 #define DIFF_FORMAT_PATCH 0x0010
32 #define DIFF_FORMAT_SHORTSTAT 0x0020
33 #define DIFF_FORMAT_DIRSTAT 0x0040
34 -#define DIFF_FORMAT_CUMULATIVE 0x0080
34
35 /* These override all above */
36 #define DIFF_FORMAT_NAME 0x0100
@@ -64,6 +63,7 @@ typedef void (*diff_format_fn_t)(struct diff_queue_struct *q,
63 #define DIFF_OPT_CHECK_FAILED (1 << 16)
64 #define DIFF_OPT_RELATIVE_NAME (1 << 17)
65 #define DIFF_OPT_IGNORE_SUBMODULES (1 << 18)
66 +#define DIFF_OPT_DIRSTAT_CUMULATIVE (1 << 19)
67 #define DIFF_OPT_TST(opts, flag) ((opts)->flags & DIFF_OPT_##flag)
68 #define DIFF_OPT_SET(opts, flag) ((opts)->flags |= DIFF_OPT_##flag)
69 #define DIFF_OPT_CLR(opts, flag) ((opts)->flags &= ~DIFF_OPT_##flag)