]> git.ipfire.org Git - thirdparty/git.git/commitdiff
diff: remove DIFF_OPT_CLR macro
authorBrandon Williams <bmwill@google.com>
Tue, 31 Oct 2017 18:19:10 +0000 (11:19 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 1 Nov 2017 02:51:30 +0000 (11:51 +0900)
Remove the `DIFF_OPT_CLR` 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@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/blame.c
combine-diff.c
diff.c
diff.h
merge-recursive.c
revision.c
submodule.c

index 76994aa64d34ea0894894893186e16a58d553fda..79db9e849cc605bdb7f3272be982334c28db77bb 100644 (file)
@@ -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)) {
index 204b0dfce43b3e070279d242e054bc32c76c2fa1..5a3a8b49be8ddf3a858bfcadcc0143c5ff45f5d6 100644 (file)
@@ -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 6dea186d8d418ea45ec652a6ce96f62a560c3d04..e5f9d3078a435d59b9939d7046ec67cc12a1da22 100644 (file)
--- 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 @@ free_queue:
                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 d53e5a2da4b164d308cda1c813754094dd98c079..258d735c1860f5330f432fe47ee01b75edc43af1 100644 (file)
--- 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)
index e7b3df45c0901cac42c7319505dcd9a8f67cd1ed..9752aba4ed195e6c93e83b6ba05d020e580e6854 100644 (file)
@@ -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 :
index f019dd277097210edc63e101d75685900540c80e..6bb873501419b8f0afccbb39d4f5e985fdfd7c1a 100644 (file)
@@ -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);
index 7e79985928aaf3e7efac83a87e0cf7786da7cf20..62a93bb888ab0045bcd264e23573674152d53456 100644 (file)
@@ -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;