Remove the `DIFF_OPT_SET` macro and instead set the flags directly. This conversion is done using the following semantic patch: @@ expression E; identifier fld; @@ - DIFF_OPT_CLR(&E, fld) + E.flags.fld = 0 @@ type T; T *ptr; identifier fld; @@ - DIFF_OPT_CLR(ptr, fld) + ptr->flags.fld = 0 Signed-off-by: Brandon Williams <bmwill@xxxxxxxxxx> --- builtin/blame.c | 2 +- combine-diff.c | 2 +- diff.c | 28 ++++++++++++++-------------- diff.h | 2 -- merge-recursive.c | 2 +- revision.c | 4 ++-- submodule.c | 6 +++--- 7 files changed, 22 insertions(+), 24 deletions(-) diff --git a/builtin/blame.c b/builtin/blame.c index 76994aa64..79db9e849 100644 --- a/builtin/blame.c +++ b/builtin/blame.c @@ -736,7 +736,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix) parse_done: no_whole_file_rename = !revs.diffopt.flags.FOLLOW_RENAMES; xdl_opts |= revs.diffopt.xdl_opts & XDF_INDENT_HEURISTIC; - DIFF_OPT_CLR(&revs.diffopt, FOLLOW_RENAMES); + revs.diffopt.flags.FOLLOW_RENAMES = 0; argc = parse_options_end(&ctx); if (incremental || (output_option & OUTPUT_PORCELAIN)) { diff --git a/combine-diff.c b/combine-diff.c index 204b0dfce..5a3a8b49b 100644 --- a/combine-diff.c +++ b/combine-diff.c @@ -1414,7 +1414,7 @@ void diff_tree_combined(const struct object_id *oid, diffopts = *opt; copy_pathspec(&diffopts.pathspec, &opt->pathspec); diffopts.flags.RECURSIVE = 1; - DIFF_OPT_CLR(&diffopts, ALLOW_EXTERNAL); + diffopts.flags.ALLOW_EXTERNAL = 0; /* find set of paths that everybody touches * diff --git a/diff.c b/diff.c index 6dea186d8..e5f9d3078 100644 --- a/diff.c +++ b/diff.c @@ -124,16 +124,16 @@ static int parse_dirstat_params(struct diff_options *options, const char *params for (i = 0; i < params.nr; i++) { const char *p = params.items[i].string; if (!strcmp(p, "changes")) { - DIFF_OPT_CLR(options, DIRSTAT_BY_LINE); - DIFF_OPT_CLR(options, DIRSTAT_BY_FILE); + options->flags.DIRSTAT_BY_LINE = 0; + options->flags.DIRSTAT_BY_FILE = 0; } else if (!strcmp(p, "lines")) { options->flags.DIRSTAT_BY_LINE = 1; - DIFF_OPT_CLR(options, DIRSTAT_BY_FILE); + options->flags.DIRSTAT_BY_FILE = 0; } else if (!strcmp(p, "files")) { - DIFF_OPT_CLR(options, DIRSTAT_BY_LINE); + options->flags.DIRSTAT_BY_LINE = 0; options->flags.DIRSTAT_BY_FILE = 1; } else if (!strcmp(p, "noncumulative")) { - DIFF_OPT_CLR(options, DIRSTAT_CUMULATIVE); + options->flags.DIRSTAT_CUMULATIVE = 0; } else if (!strcmp(p, "cumulative")) { options->flags.DIRSTAT_CUMULATIVE = 1; } else if (isdigit(*p)) { @@ -4205,7 +4205,7 @@ void diff_setup_done(struct diff_options *options) DIFF_XDL_TST(options, IGNORE_WHITESPACE_AT_EOL)) options->flags.DIFF_FROM_CONTENTS = 1; else - DIFF_OPT_CLR(options, DIFF_FROM_CONTENTS); + options->flags.DIFF_FROM_CONTENTS = 0; if (options->flags.FIND_COPIES_HARDER) options->detect_rename = DIFF_DETECT_COPY; @@ -4640,7 +4640,7 @@ int diff_opt_parse(struct diff_options *options, else if (!strcmp(arg, "--rename-empty")) options->flags.RENAME_EMPTY = 1; else if (!strcmp(arg, "--no-rename-empty")) - DIFF_OPT_CLR(options, RENAME_EMPTY); + options->flags.RENAME_EMPTY = 0; else if (!strcmp(arg, "--relative")) options->flags.RELATIVE_NAME = 1; else if (skip_prefix(arg, "--relative=", &arg)) { @@ -4697,8 +4697,8 @@ int diff_opt_parse(struct diff_options *options, else if (!strcmp(arg, "--follow")) options->flags.FOLLOW_RENAMES = 1; else if (!strcmp(arg, "--no-follow")) { - DIFF_OPT_CLR(options, FOLLOW_RENAMES); - DIFF_OPT_CLR(options, DEFAULT_FOLLOW_RENAMES); + options->flags.FOLLOW_RENAMES = 0; + options->flags.DEFAULT_FOLLOW_RENAMES = 0; } else if (!strcmp(arg, "--color")) options->use_color = 1; else if (skip_prefix(arg, "--color=", &arg)) { @@ -4761,12 +4761,12 @@ int diff_opt_parse(struct diff_options *options, else if (!strcmp(arg, "--ext-diff")) options->flags.ALLOW_EXTERNAL = 1; else if (!strcmp(arg, "--no-ext-diff")) - DIFF_OPT_CLR(options, ALLOW_EXTERNAL); + options->flags.ALLOW_EXTERNAL = 0; else if (!strcmp(arg, "--textconv")) { options->flags.ALLOW_TEXTCONV = 1; options->flags.TEXTCONV_SET_VIA_CMDLINE = 1; } else if (!strcmp(arg, "--no-textconv")) - DIFF_OPT_CLR(options, ALLOW_TEXTCONV); + options->flags.ALLOW_TEXTCONV = 0; else if (!strcmp(arg, "--ignore-submodules")) { options->flags.OVERRIDE_SUBMODULE_CONFIG = 1; handle_ignore_submodules_arg(options, "all"); @@ -4850,7 +4850,7 @@ int diff_opt_parse(struct diff_options *options, else if (!strcmp(arg, "--function-context")) options->flags.FUNCCONTEXT = 1; else if (!strcmp(arg, "--no-function-context")) - DIFF_OPT_CLR(options, FUNCCONTEXT); + options->flags.FUNCCONTEXT = 0; else if ((argcount = parse_long_opt("output", av, &optarg))) { char *path = prefix_filename(prefix, optarg); options->file = xfopen(path, "w"); @@ -5688,7 +5688,7 @@ void diff_flush(struct diff_options *options) if (options->found_changes) options->flags.HAS_CHANGES = 1; else - DIFF_OPT_CLR(options, HAS_CHANGES); + options->flags.HAS_CHANGES = 0; } } @@ -5860,7 +5860,7 @@ void diffcore_std(struct diff_options *options) if (diff_queued_diff.nr && !options->flags.DIFF_FROM_CONTENTS) options->flags.HAS_CHANGES = 1; else - DIFF_OPT_CLR(options, HAS_CHANGES); + options->flags.HAS_CHANGES = 0; options->found_follow = 0; } diff --git a/diff.h b/diff.h index d53e5a2da..258d735c1 100644 --- a/diff.h +++ b/diff.h @@ -106,8 +106,6 @@ static inline void diff_flags_or(struct diff_flags *a, tmp_a[i] |= tmp_b[i]; } -#define DIFF_OPT_CLR(opts, flag) ((opts)->flags.flag = 0) - #define DIFF_XDL_TST(opts, flag) ((opts)->xdl_opts & XDF_##flag) #define DIFF_XDL_SET(opts, flag) ((opts)->xdl_opts |= XDF_##flag) #define DIFF_XDL_CLR(opts, flag) ((opts)->xdl_opts &= ~XDF_##flag) diff --git a/merge-recursive.c b/merge-recursive.c index e7b3df45c..9752aba4e 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -541,7 +541,7 @@ static struct string_list *get_renames(struct merge_options *o, diff_setup(&opts); opts.flags.RECURSIVE = 1; - DIFF_OPT_CLR(&opts, RENAME_EMPTY); + opts.flags.RENAME_EMPTY = 0; opts.detect_rename = DIFF_DETECT_RENAME; opts.rename_limit = o->merge_rename_limit >= 0 ? o->merge_rename_limit : o->diff_rename_limit >= 0 ? o->diff_rename_limit : diff --git a/revision.c b/revision.c index f019dd277..6bb873501 100644 --- a/revision.c +++ b/revision.c @@ -455,7 +455,7 @@ static int rev_compare_tree(struct rev_info *revs, } tree_difference = REV_TREE_SAME; - DIFF_OPT_CLR(&revs->pruning, HAS_CHANGES); + revs->pruning.flags.HAS_CHANGES = 0; if (diff_tree_oid(&t1->object.oid, &t2->object.oid, "", &revs->pruning) < 0) return REV_TREE_DIFFERENT; @@ -471,7 +471,7 @@ static int rev_same_tree_as_empty(struct rev_info *revs, struct commit *commit) return 0; tree_difference = REV_TREE_SAME; - DIFF_OPT_CLR(&revs->pruning, HAS_CHANGES); + revs->pruning.flags.HAS_CHANGES = 0; retval = diff_tree_oid(NULL, &t1->object.oid, "", &revs->pruning); return retval >= 0 && (tree_difference == REV_TREE_SAME); diff --git a/submodule.c b/submodule.c index 7e7998592..62a93bb88 100644 --- a/submodule.c +++ b/submodule.c @@ -402,9 +402,9 @@ const char *submodule_strategy_to_string(const struct submodule_update_strategy void handle_ignore_submodules_arg(struct diff_options *diffopt, const char *arg) { - DIFF_OPT_CLR(diffopt, IGNORE_SUBMODULES); - DIFF_OPT_CLR(diffopt, IGNORE_UNTRACKED_IN_SUBMODULES); - DIFF_OPT_CLR(diffopt, IGNORE_DIRTY_SUBMODULES); + diffopt->flags.IGNORE_SUBMODULES = 0; + diffopt->flags.IGNORE_UNTRACKED_IN_SUBMODULES = 0; + diffopt->flags.IGNORE_DIRTY_SUBMODULES = 0; if (!strcmp(arg, "all")) diffopt->flags.IGNORE_SUBMODULES = 1; -- 2.15.0.403.gc27cc4dac6-goog