diff: remove DIFF_OPT_CLR macro
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>
Brandon Williams committed
Oct 31, 2017 at 11:19 UTC
b2100e529171f0bbd497366618436cf86c08a324
7 files changed
+22
-24
builtin/blame.c
+1
-1
@@ -736,7 +736,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
736
parse_done:
737
no_whole_file_rename = !revs.diffopt.flags.FOLLOW_RENAMES;
738
xdl_opts |= revs.diffopt.xdl_opts & XDF_INDENT_HEURISTIC;
739
- DIFF_OPT_CLR(&revs.diffopt, FOLLOW_RENAMES);
739
+ revs.diffopt.flags.FOLLOW_RENAMES = 0;
740
argc = parse_options_end(&ctx);
741
742
if (incremental || (output_option & OUTPUT_PORCELAIN)) {
combine-diff.c
+1
-1
@@ -1414,7 +1414,7 @@ void diff_tree_combined(const struct object_id *oid,
1414
diffopts = *opt;
1415
copy_pathspec(&diffopts.pathspec, &opt->pathspec);
1416
diffopts.flags.RECURSIVE = 1;
1417
- DIFF_OPT_CLR(&diffopts, ALLOW_EXTERNAL);
1417
+ diffopts.flags.ALLOW_EXTERNAL = 0;
1418
1419
/* find set of paths that everybody touches
1420
*
diff.c
+14
-14
@@ -124,16 +124,16 @@ static int parse_dirstat_params(struct diff_options *options, const char *params
124
for (i = 0; i < params.nr; i++) {
125
const char *p = params.items[i].string;
126
if (!strcmp(p, "changes")) {
127
- DIFF_OPT_CLR(options, DIRSTAT_BY_LINE);
128
- DIFF_OPT_CLR(options, DIRSTAT_BY_FILE);
127
+ options->flags.DIRSTAT_BY_LINE = 0;
128
+ options->flags.DIRSTAT_BY_FILE = 0;
129
} else if (!strcmp(p, "lines")) {
130
options->flags.DIRSTAT_BY_LINE = 1;
131
- DIFF_OPT_CLR(options, DIRSTAT_BY_FILE);
131
+ options->flags.DIRSTAT_BY_FILE = 0;
132
} else if (!strcmp(p, "files")) {
133
- DIFF_OPT_CLR(options, DIRSTAT_BY_LINE);
133
+ options->flags.DIRSTAT_BY_LINE = 0;
134
options->flags.DIRSTAT_BY_FILE = 1;
135
} else if (!strcmp(p, "noncumulative")) {
136
- DIFF_OPT_CLR(options, DIRSTAT_CUMULATIVE);
136
+ options->flags.DIRSTAT_CUMULATIVE = 0;
137
} else if (!strcmp(p, "cumulative")) {
138
options->flags.DIRSTAT_CUMULATIVE = 1;
139
} else if (isdigit(*p)) {
@@ -4205,7 +4205,7 @@ void diff_setup_done(struct diff_options *options)
4205
DIFF_XDL_TST(options, IGNORE_WHITESPACE_AT_EOL))
4206
options->flags.DIFF_FROM_CONTENTS = 1;
4207
else
4208
- DIFF_OPT_CLR(options, DIFF_FROM_CONTENTS);
4208
+ options->flags.DIFF_FROM_CONTENTS = 0;
4209
4210
if (options->flags.FIND_COPIES_HARDER)
4211
options->detect_rename = DIFF_DETECT_COPY;
@@ -4640,7 +4640,7 @@ int diff_opt_parse(struct diff_options *options,
4640
else if (!strcmp(arg, "--rename-empty"))
4641
options->flags.RENAME_EMPTY = 1;
4642
else if (!strcmp(arg, "--no-rename-empty"))
4643
- DIFF_OPT_CLR(options, RENAME_EMPTY);
4643
+ options->flags.RENAME_EMPTY = 0;
4644
else if (!strcmp(arg, "--relative"))
4645
options->flags.RELATIVE_NAME = 1;
4646
else if (skip_prefix(arg, "--relative=", &arg)) {
@@ -4697,8 +4697,8 @@ int diff_opt_parse(struct diff_options *options,
4697
else if (!strcmp(arg, "--follow"))
4698
options->flags.FOLLOW_RENAMES = 1;
4699
else if (!strcmp(arg, "--no-follow")) {
4700
- DIFF_OPT_CLR(options, FOLLOW_RENAMES);
4701
- DIFF_OPT_CLR(options, DEFAULT_FOLLOW_RENAMES);
4700
+ options->flags.FOLLOW_RENAMES = 0;
4701
+ options->flags.DEFAULT_FOLLOW_RENAMES = 0;
4702
} else if (!strcmp(arg, "--color"))
4703
options->use_color = 1;
4704
else if (skip_prefix(arg, "--color=", &arg)) {
@@ -4761,12 +4761,12 @@ int diff_opt_parse(struct diff_options *options,
4761
else if (!strcmp(arg, "--ext-diff"))
4762
options->flags.ALLOW_EXTERNAL = 1;
4763
else if (!strcmp(arg, "--no-ext-diff"))
4764
- DIFF_OPT_CLR(options, ALLOW_EXTERNAL);
4764
+ options->flags.ALLOW_EXTERNAL = 0;
4765
else if (!strcmp(arg, "--textconv")) {
4766
options->flags.ALLOW_TEXTCONV = 1;
4767
options->flags.TEXTCONV_SET_VIA_CMDLINE = 1;
4768
} else if (!strcmp(arg, "--no-textconv"))
4769
- DIFF_OPT_CLR(options, ALLOW_TEXTCONV);
4769
+ options->flags.ALLOW_TEXTCONV = 0;
4770
else if (!strcmp(arg, "--ignore-submodules")) {
4771
options->flags.OVERRIDE_SUBMODULE_CONFIG = 1;
4772
handle_ignore_submodules_arg(options, "all");
@@ -4850,7 +4850,7 @@ int diff_opt_parse(struct diff_options *options,
4850
else if (!strcmp(arg, "--function-context"))
4851
options->flags.FUNCCONTEXT = 1;
4852
else if (!strcmp(arg, "--no-function-context"))
4853
- DIFF_OPT_CLR(options, FUNCCONTEXT);
4853
+ options->flags.FUNCCONTEXT = 0;
4854
else if ((argcount = parse_long_opt("output", av, &optarg))) {
4855
char *path = prefix_filename(prefix, optarg);
4856
options->file = xfopen(path, "w");
@@ -5688,7 +5688,7 @@ free_queue:
5688
if (options->found_changes)
5689
options->flags.HAS_CHANGES = 1;
5690
else
5691
- DIFF_OPT_CLR(options, HAS_CHANGES);
5691
+ options->flags.HAS_CHANGES = 0;
5692
}
5693
}
5694
@@ -5860,7 +5860,7 @@ void diffcore_std(struct diff_options *options)
5860
if (diff_queued_diff.nr && !options->flags.DIFF_FROM_CONTENTS)
5861
options->flags.HAS_CHANGES = 1;
5862
else
5863
- DIFF_OPT_CLR(options, HAS_CHANGES);
5863
+ options->flags.HAS_CHANGES = 0;
5864
5865
options->found_follow = 0;
5866
}
diff.h
-2
@@ -106,8 +106,6 @@ static inline void diff_flags_or(struct diff_flags *a,
106
tmp_a[i] |= tmp_b[i];
107
}
108
109
-#define DIFF_OPT_CLR(opts, flag) ((opts)->flags.flag = 0)
110
-
109
#define DIFF_XDL_TST(opts, flag) ((opts)->xdl_opts & XDF_##flag)
110
#define DIFF_XDL_SET(opts, flag) ((opts)->xdl_opts |= XDF_##flag)
111
#define DIFF_XDL_CLR(opts, flag) ((opts)->xdl_opts &= ~XDF_##flag)
merge-recursive.c
+1
-1
@@ -541,7 +541,7 @@ static struct string_list *get_renames(struct merge_options *o,
541
542
diff_setup(&opts);
543
opts.flags.RECURSIVE = 1;
544
- DIFF_OPT_CLR(&opts, RENAME_EMPTY);
544
+ opts.flags.RENAME_EMPTY = 0;
545
opts.detect_rename = DIFF_DETECT_RENAME;
546
opts.rename_limit = o->merge_rename_limit >= 0 ? o->merge_rename_limit :
547
o->diff_rename_limit >= 0 ? o->diff_rename_limit :
revision.c
+2
-2
@@ -455,7 +455,7 @@ static int rev_compare_tree(struct rev_info *revs,
455
}
456
457
tree_difference = REV_TREE_SAME;
458
- DIFF_OPT_CLR(&revs->pruning, HAS_CHANGES);
458
+ revs->pruning.flags.HAS_CHANGES = 0;
459
if (diff_tree_oid(&t1->object.oid, &t2->object.oid, "",
460
&revs->pruning) < 0)
461
return REV_TREE_DIFFERENT;
@@ -471,7 +471,7 @@ static int rev_same_tree_as_empty(struct rev_info *revs, struct commit *commit)
471
return 0;
472
473
tree_difference = REV_TREE_SAME;
474
- DIFF_OPT_CLR(&revs->pruning, HAS_CHANGES);
474
+ revs->pruning.flags.HAS_CHANGES = 0;
475
retval = diff_tree_oid(NULL, &t1->object.oid, "", &revs->pruning);
476
477
return retval >= 0 && (tree_difference == REV_TREE_SAME);
submodule.c
+3
-3
@@ -402,9 +402,9 @@ const char *submodule_strategy_to_string(const struct submodule_update_strategy
402
void handle_ignore_submodules_arg(struct diff_options *diffopt,
403
const char *arg)
404
{
405
- DIFF_OPT_CLR(diffopt, IGNORE_SUBMODULES);
406
- DIFF_OPT_CLR(diffopt, IGNORE_UNTRACKED_IN_SUBMODULES);
407
- DIFF_OPT_CLR(diffopt, IGNORE_DIRTY_SUBMODULES);
405
+ diffopt->flags.IGNORE_SUBMODULES = 0;
406
+ diffopt->flags.IGNORE_UNTRACKED_IN_SUBMODULES = 0;
407
+ diffopt->flags.IGNORE_DIRTY_SUBMODULES = 0;
408
409
if (!strcmp(arg, "all"))
410
diffopt->flags.IGNORE_SUBMODULES = 1;