diff: remove DIFF_OPT_TST macro
Remove the `DIFF_OPT_TST` macro and instead access the flags directly. This conversion is done using the following semantic patch: @@ expression E; identifier fld; @@ - DIFF_OPT_TST(&E, fld) + E.flags.fld @@ type T; T *ptr; identifier fld; @@ - DIFF_OPT_TST(ptr, fld) + ptr->flags.fld 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
3b69daed861daec1923c369d59c97e46eb3c3d7b
17 files changed
+84
-84
blame.c
+4
-4
@@ -209,7 +209,7 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,
209
210
switch (st.st_mode & S_IFMT) {
211
case S_IFREG:
212
- if (DIFF_OPT_TST(opt, ALLOW_TEXTCONV) &&
212
+ if (opt->flags.ALLOW_TEXTCONV &&
213
textconv_object(read_from, mode, &null_oid, 0, &buf_ptr, &buf_len))
214
strbuf_attach(&buf, buf_ptr, buf_len, buf_len + 1);
215
else if (strbuf_read_file(&buf, read_from, st.st_size) != st.st_size)
@@ -293,7 +293,7 @@ static void fill_origin_blob(struct diff_options *opt,
293
unsigned long file_size;
294
295
(*num_read_blob)++;
296
- if (DIFF_OPT_TST(opt, ALLOW_TEXTCONV) &&
296
+ if (opt->flags.ALLOW_TEXTCONV &&
297
textconv_object(o->path, o->mode, &o->blob_oid, 1, &file->ptr, &file_size))
298
;
299
else
@@ -1262,7 +1262,7 @@ static void find_copy_in_parent(struct blame_scoreboard *sb,
1262
&target->commit->tree->object.oid,
1263
"", &diff_opts);
1264
1265
- if (!DIFF_OPT_TST(&diff_opts, FIND_COPIES_HARDER))
1265
+ if (!diff_opts.flags.FIND_COPIES_HARDER)
1266
diffcore_std(&diff_opts);
1267
1268
do {
@@ -1825,7 +1825,7 @@ void setup_scoreboard(struct blame_scoreboard *sb, const char *path, struct blam
1825
if (fill_blob_sha1_and_mode(o))
1826
die(_("no such path %s in %s"), path, final_commit_name);
1827
1828
- if (DIFF_OPT_TST(&sb->revs->diffopt, ALLOW_TEXTCONV) &&
1828
+ if (sb->revs->diffopt.flags.ALLOW_TEXTCONV &&
1829
textconv_object(path, o->mode, &o->blob_oid, 1, (char **) &sb->final_buf,
1830
&sb->final_buf_size))
1831
;
builtin/am.c
+1
-1
@@ -1168,7 +1168,7 @@ static int index_has_changes(struct strbuf *sb)
1168
strbuf_addstr(sb, diff_queued_diff.queue[i]->two->path);
1169
}
1170
diff_flush(&opt);
1171
- return DIFF_OPT_TST(&opt, HAS_CHANGES) != 0;
1171
+ return opt.flags.HAS_CHANGES != 0;
1172
} else {
1173
for (i = 0; sb && i < active_nr; i++) {
1174
if (i)
builtin/blame.c
+2
-2
@@ -734,7 +734,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
734
parse_revision_opt(&revs, &ctx, options, blame_opt_usage);
735
}
736
parse_done:
737
- no_whole_file_rename = !DIFF_OPT_TST(&revs.diffopt, FOLLOW_RENAMES);
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);
740
argc = parse_options_end(&ctx);
@@ -803,7 +803,7 @@ parse_done:
803
}
804
blame_date_width -= 1; /* strip the null */
805
806
- if (DIFF_OPT_TST(&revs.diffopt, FIND_COPIES_HARDER))
806
+ if (revs.diffopt.flags.FIND_COPIES_HARDER)
807
opt |= (PICKAXE_BLAME_COPY | PICKAXE_BLAME_MOVE |
808
PICKAXE_BLAME_COPY_HARDER);
809
builtin/diff.c
+1
-1
@@ -44,7 +44,7 @@ static void stuff_change(struct diff_options *opt,
44
!oidcmp(old_oid, new_oid) && (old_mode == new_mode))
45
return;
46
47
- if (DIFF_OPT_TST(opt, REVERSE_DIFF)) {
47
+ if (opt->flags.REVERSE_DIFF) {
48
SWAP(old_mode, new_mode);
49
SWAP(old_oid, new_oid);
50
SWAP(old_path, new_path);
builtin/log.c
+6
-6
@@ -181,7 +181,7 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
181
init_display_notes(&rev->notes_opt);
182
183
if (rev->diffopt.pickaxe || rev->diffopt.filter ||
184
- DIFF_OPT_TST(&rev->diffopt, FOLLOW_RENAMES))
184
+ rev->diffopt.flags.FOLLOW_RENAMES)
185
rev->always_show_header = 0;
186
187
if (source)
@@ -391,7 +391,7 @@ static int cmd_log_walk(struct rev_info *rev)
391
fclose(rev->diffopt.file);
392
393
if (rev->diffopt.output_format & DIFF_FORMAT_CHECKDIFF &&
394
- DIFF_OPT_TST(&rev->diffopt, CHECK_FAILED)) {
394
+ rev->diffopt.flags.CHECK_FAILED) {
395
return 02;
396
}
397
return diff_result_code(&rev->diffopt, 0);
@@ -483,8 +483,8 @@ static int show_blob_object(const struct object_id *oid, struct rev_info *rev, c
483
unsigned long size;
484
485
fflush(rev->diffopt.file);
486
- if (!DIFF_OPT_TST(&rev->diffopt, TEXTCONV_SET_VIA_CMDLINE) ||
487
- !DIFF_OPT_TST(&rev->diffopt, ALLOW_TEXTCONV))
486
+ if (!rev->diffopt.flags.TEXTCONV_SET_VIA_CMDLINE ||
487
+ !rev->diffopt.flags.ALLOW_TEXTCONV)
488
return stream_blob_to_fd(1, oid, NULL, 0);
489
490
if (get_oid_with_context(obj_name, GET_OID_RECORD_PATH,
@@ -666,7 +666,7 @@ int cmd_log_reflog(int argc, const char **argv, const char *prefix)
666
static void log_setup_revisions_tweak(struct rev_info *rev,
667
struct setup_revision_opt *opt)
668
{
669
- if (DIFF_OPT_TST(&rev->diffopt, DEFAULT_FOLLOW_RENAMES) &&
669
+ if (rev->diffopt.flags.DEFAULT_FOLLOW_RENAMES &&
670
rev->prune_data.nr == 1)
671
DIFF_OPT_SET(&rev->diffopt, FOLLOW_RENAMES);
672
@@ -1612,7 +1612,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
1612
1613
rev.zero_commit = zero_commit;
1614
1615
- if (!DIFF_OPT_TST(&rev.diffopt, TEXT) && !no_binary_diff)
1615
+ if (!rev.diffopt.flags.TEXT && !no_binary_diff)
1616
DIFF_OPT_SET(&rev.diffopt, BINARY);
1617
1618
if (rev.show_notes)
builtin/rev-list.c
+1
-1
@@ -294,7 +294,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
294
if (revs.bisect)
295
bisect_list = 1;
296
297
- if (DIFF_OPT_TST(&revs.diffopt, QUICK))
297
+ if (revs.diffopt.flags.QUICK)
298
info.flags |= REV_LIST_QUIET;
299
for (i = 1 ; i < argc; i++) {
300
const char *arg = argv[i];
combine-diff.c
+3
-3
@@ -898,7 +898,7 @@ static void show_combined_header(struct combine_diff_path *elem,
898
int show_file_header)
899
{
900
struct diff_options *opt = &rev->diffopt;
901
- int abbrev = DIFF_OPT_TST(opt, FULL_INDEX) ? GIT_SHA1_HEXSZ : DEFAULT_ABBREV;
901
+ int abbrev = opt->flags.FULL_INDEX ? GIT_SHA1_HEXSZ : DEFAULT_ABBREV;
902
const char *a_prefix = opt->a_prefix ? opt->a_prefix : "a/";
903
const char *b_prefix = opt->b_prefix ? opt->b_prefix : "b/";
904
const char *c_meta = diff_get_color_opt(opt, DIFF_METAINFO);
@@ -987,7 +987,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
987
userdiff = userdiff_find_by_path(elem->path);
988
if (!userdiff)
989
userdiff = userdiff_find_by_name("default");
990
- if (DIFF_OPT_TST(opt, ALLOW_TEXTCONV))
990
+ if (opt->flags.ALLOW_TEXTCONV)
991
textconv = userdiff_get_textconv(userdiff);
992
993
/* Read the result of merge first */
@@ -1435,7 +1435,7 @@ void diff_tree_combined(const struct object_id *oid,
1435
* NOTE please keep this semantically in sync with diffcore_std()
1436
*/
1437
need_generic_pathscan = opt->skip_stat_unmatch ||
1438
- DIFF_OPT_TST(opt, FOLLOW_RENAMES) ||
1438
+ opt->flags.FOLLOW_RENAMES ||
1439
opt->break_opt != -1 ||
1440
opt->detect_rename ||
1441
opt->pickaxe ||
diff-lib.c
+10
-9
@@ -72,13 +72,14 @@ static int match_stat_with_submodule(struct diff_options *diffopt,
72
int changed = ce_match_stat(ce, st, ce_option);
73
if (S_ISGITLINK(ce->ce_mode)) {
74
struct diff_flags orig_flags = diffopt->flags;
75
- if (!DIFF_OPT_TST(diffopt, OVERRIDE_SUBMODULE_CONFIG))
75
+ if (!diffopt->flags.OVERRIDE_SUBMODULE_CONFIG)
76
set_diffopt_flags_from_submodule_config(diffopt, ce->name);
77
- if (DIFF_OPT_TST(diffopt, IGNORE_SUBMODULES))
77
+ if (diffopt->flags.IGNORE_SUBMODULES)
78
changed = 0;
79
- else if (!DIFF_OPT_TST(diffopt, IGNORE_DIRTY_SUBMODULES)
80
- && (!changed || DIFF_OPT_TST(diffopt, DIRTY_SUBMODULES)))
81
- *dirty_submodule = is_submodule_modified(ce->name, DIFF_OPT_TST(diffopt, IGNORE_UNTRACKED_IN_SUBMODULES));
79
+ else if (!diffopt->flags.IGNORE_DIRTY_SUBMODULES &&
80
+ (!changed || diffopt->flags.DIRTY_SUBMODULES))
81
+ *dirty_submodule = is_submodule_modified(ce->name,
82
+ diffopt->flags.IGNORE_UNTRACKED_IN_SUBMODULES);
83
diffopt->flags = orig_flags;
84
}
85
return changed;
@@ -228,7 +229,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
229
230
if (!changed && !dirty_submodule) {
231
ce_mark_uptodate(ce);
231
- if (!DIFF_OPT_TST(&revs->diffopt, FIND_COPIES_HARDER))
232
+ if (!revs->diffopt.flags.FIND_COPIES_HARDER)
233
continue;
234
}
235
oldmode = ce->ce_mode;
@@ -362,7 +363,7 @@ static int show_modified(struct rev_info *revs,
363
364
oldmode = old->ce_mode;
365
if (mode == oldmode && !oidcmp(oid, &old->oid) && !dirty_submodule &&
365
- !DIFF_OPT_TST(&revs->diffopt, FIND_COPIES_HARDER))
366
+ !revs->diffopt.flags.FIND_COPIES_HARDER)
367
return 0;
368
369
diff_change(&revs->diffopt, oldmode, mode,
@@ -493,7 +494,7 @@ static int diff_cache(struct rev_info *revs,
494
opts.head_idx = 1;
495
opts.index_only = cached;
496
opts.diff_index_cached = (cached &&
496
- !DIFF_OPT_TST(&revs->diffopt, FIND_COPIES_HARDER));
497
+ !revs->diffopt.flags.FIND_COPIES_HARDER);
498
opts.merge = 1;
499
opts.fn = oneway_diff;
500
opts.unpack_data = revs;
@@ -551,5 +552,5 @@ int index_differs_from(const char *def, const struct diff_flags *flags,
552
rev.diffopt.ita_invisible_in_index = ita_invisible_in_index;
553
run_diff_index(&rev, 1);
554
object_array_clear(&rev.pending);
554
- return (DIFF_OPT_TST(&rev.diffopt, HAS_CHANGES) != 0);
555
+ return (rev.diffopt.flags.HAS_CHANGES != 0);
556
}
diff-no-index.c
+1
-1
@@ -184,7 +184,7 @@ static int queue_diff(struct diff_options *o,
184
} else {
185
struct diff_filespec *d1, *d2;
186
187
- if (DIFF_OPT_TST(o, REVERSE_DIFF)) {
187
+ if (o->flags.REVERSE_DIFF) {
188
SWAP(mode1, mode2);
189
SWAP(name1, name2);
190
}
diff.c
+38
-38
@@ -1481,7 +1481,7 @@ static void emit_rewrite_diff(const char *name_a,
1481
struct emit_callback ecbdata;
1482
struct strbuf out = STRBUF_INIT;
1483
1484
- if (diff_mnemonic_prefix && DIFF_OPT_TST(o, REVERSE_DIFF)) {
1484
+ if (diff_mnemonic_prefix && o->flags.REVERSE_DIFF) {
1485
a_prefix = o->b_prefix;
1486
b_prefix = o->a_prefix;
1487
} else {
@@ -2729,7 +2729,7 @@ static void show_dirstat(struct diff_options *options)
2729
dir.alloc = 0;
2730
dir.nr = 0;
2731
dir.permille = options->dirstat_permille;
2732
- dir.cumulative = DIFF_OPT_TST(options, DIRSTAT_CUMULATIVE);
2732
+ dir.cumulative = options->flags.DIRSTAT_CUMULATIVE;
2733
2734
changed = 0;
2735
for (i = 0; i < q->nr; i++) {
@@ -2755,7 +2755,7 @@ static void show_dirstat(struct diff_options *options)
2755
goto found_damage;
2756
}
2757
2758
- if (DIFF_OPT_TST(options, DIRSTAT_BY_FILE)) {
2758
+ if (options->flags.DIRSTAT_BY_FILE) {
2759
/*
2760
* In --dirstat-by-file mode, we don't really need to
2761
* look at the actual file contents at all.
@@ -2830,7 +2830,7 @@ static void show_dirstat_by_line(struct diffstat_t *data, struct diff_options *o
2830
dir.alloc = 0;
2831
dir.nr = 0;
2832
dir.permille = options->dirstat_permille;
2833
- dir.cumulative = DIFF_OPT_TST(options, DIRSTAT_CUMULATIVE);
2833
+ dir.cumulative = options->flags.DIRSTAT_CUMULATIVE;
2834
2835
changed = 0;
2836
for (i = 0; i < data->nr; i++) {
@@ -3117,7 +3117,7 @@ static void builtin_diff(const char *name_a,
3117
const char *line_prefix = diff_line_prefix(o);
3118
3119
diff_set_mnemonic_prefix(o, "a/", "b/");
3120
- if (DIFF_OPT_TST(o, REVERSE_DIFF)) {
3120
+ if (o->flags.REVERSE_DIFF) {
3121
a_prefix = o->b_prefix;
3122
b_prefix = o->a_prefix;
3123
} else {
@@ -3141,7 +3141,7 @@ static void builtin_diff(const char *name_a,
3141
return;
3142
}
3143
3144
- if (DIFF_OPT_TST(o, ALLOW_TEXTCONV)) {
3144
+ if (o->flags.ALLOW_TEXTCONV) {
3145
textconv_one = get_textconv(one);
3146
textconv_two = get_textconv(two);
3147
}
@@ -3201,13 +3201,13 @@ static void builtin_diff(const char *name_a,
3201
header.len, 0);
3202
strbuf_reset(&header);
3203
goto free_ab_and_return;
3204
- } else if (!DIFF_OPT_TST(o, TEXT) &&
3204
+ } else if (!o->flags.TEXT &&
3205
( (!textconv_one && diff_filespec_is_binary(one)) ||
3206
(!textconv_two && diff_filespec_is_binary(two)) )) {
3207
struct strbuf sb = STRBUF_INIT;
3208
if (!one->data && !two->data &&
3209
S_ISREG(one->mode) && S_ISREG(two->mode) &&
3210
- !DIFF_OPT_TST(o, BINARY)) {
3210
+ !o->flags.BINARY) {
3211
if (!oidcmp(&one->oid, &two->oid)) {
3212
if (must_show_header)
3213
emit_diff_symbol(o, DIFF_SYMBOL_HEADER,
@@ -3236,7 +3236,7 @@ static void builtin_diff(const char *name_a,
3236
}
3237
emit_diff_symbol(o, DIFF_SYMBOL_HEADER, header.buf, header.len, 0);
3238
strbuf_reset(&header);
3239
- if (DIFF_OPT_TST(o, BINARY))
3239
+ if (o->flags.BINARY)
3240
emit_binary_diff(o, &mf1, &mf2);
3241
else {
3242
strbuf_addf(&sb, "%sBinary files %s and %s differ\n",
@@ -3282,7 +3282,7 @@ static void builtin_diff(const char *name_a,
3282
xecfg.ctxlen = o->context;
3283
xecfg.interhunkctxlen = o->interhunkcontext;
3284
xecfg.flags = XDL_EMIT_FUNCNAMES;
3285
- if (DIFF_OPT_TST(o, FUNCCONTEXT))
3285
+ if (o->flags.FUNCCONTEXT)
3286
xecfg.flags |= XDL_EMIT_FUNCCONTEXT;
3287
if (pe)
3288
xdiff_set_find_func(&xecfg, pe->pattern, pe->cflags);
@@ -3941,9 +3941,9 @@ static void fill_metainfo(struct strbuf *msg,
3941
*must_show_header = 0;
3942
}
3943
if (one && two && oidcmp(&one->oid, &two->oid)) {
3944
- int abbrev = DIFF_OPT_TST(o, FULL_INDEX) ? 40 : DEFAULT_ABBREV;
3944
+ int abbrev = o->flags.FULL_INDEX ? 40 : DEFAULT_ABBREV;
3945
3946
- if (DIFF_OPT_TST(o, BINARY)) {
3946
+ if (o->flags.BINARY) {
3947
mmfile_t mf;
3948
if ((!fill_mmfile(&mf, one) && diff_filespec_is_binary(one)) ||
3949
(!fill_mmfile(&mf, two) && diff_filespec_is_binary(two)))
@@ -3973,7 +3973,7 @@ static void run_diff_cmd(const char *pgm,
3973
int must_show_header = 0;
3974
3975
3976
- if (DIFF_OPT_TST(o, ALLOW_EXTERNAL)) {
3976
+ if (o->flags.ALLOW_EXTERNAL) {
3977
struct userdiff_driver *drv = userdiff_find_by_path(attr_path);
3978
if (drv && drv->external)
3979
pgm = drv->external;
@@ -4053,7 +4053,7 @@ static void run_diff(struct diff_filepair *p, struct diff_options *o)
4053
if (o->prefix_length)
4054
strip_prefix(o->prefix_length, &name, &other);
4055
4056
- if (!DIFF_OPT_TST(o, ALLOW_EXTERNAL))
4056
+ if (!o->flags.ALLOW_EXTERNAL)
4057
pgm = NULL;
4058
4059
if (DIFF_PAIR_UNMERGED(p)) {
@@ -4207,10 +4207,10 @@ void diff_setup_done(struct diff_options *options)
4207
else
4208
DIFF_OPT_CLR(options, DIFF_FROM_CONTENTS);
4209
4210
- if (DIFF_OPT_TST(options, FIND_COPIES_HARDER))
4210
+ if (options->flags.FIND_COPIES_HARDER)
4211
options->detect_rename = DIFF_DETECT_COPY;
4212
4213
- if (!DIFF_OPT_TST(options, RELATIVE_NAME))
4213
+ if (!options->flags.RELATIVE_NAME)
4214
options->prefix = NULL;
4215
if (options->prefix)
4216
options->prefix_length = strlen(options->prefix);
@@ -4273,14 +4273,14 @@ void diff_setup_done(struct diff_options *options)
4273
* to have found. It does not make sense not to return with
4274
* exit code in such a case either.
4275
*/
4276
- if (DIFF_OPT_TST(options, QUICK)) {
4276
+ if (options->flags.QUICK) {
4277
options->output_format = DIFF_FORMAT_NO_OUTPUT;
4278
DIFF_OPT_SET(options, EXIT_WITH_STATUS);
4279
}
4280
4281
options->diff_path_counter = 0;
4282
4283
- if (DIFF_OPT_TST(options, FOLLOW_RENAMES) && options->pathspec.nr != 1)
4283
+ if (options->flags.FOLLOW_RENAMES && options->pathspec.nr != 1)
4284
die(_("--follow requires exactly one pathspec"));
4285
4286
if (!options->use_color || external_diff())
@@ -5600,7 +5600,7 @@ void diff_flush(struct diff_options *options)
5600
separator++;
5601
}
5602
5603
- if (output_format & DIFF_FORMAT_DIRSTAT && DIFF_OPT_TST(options, DIRSTAT_BY_LINE))
5603
+ if (output_format & DIFF_FORMAT_DIRSTAT && options->flags.DIRSTAT_BY_LINE)
5604
dirstat_by_line = 1;
5605
5606
if (output_format & (DIFF_FORMAT_DIFFSTAT|DIFF_FORMAT_SHORTSTAT|DIFF_FORMAT_NUMSTAT) ||
@@ -5635,8 +5635,8 @@ void diff_flush(struct diff_options *options)
5635
}
5636
5637
if (output_format & DIFF_FORMAT_NO_OUTPUT &&
5638
- DIFF_OPT_TST(options, EXIT_WITH_STATUS) &&
5639
- DIFF_OPT_TST(options, DIFF_FROM_CONTENTS)) {
5638
+ options->flags.EXIT_WITH_STATUS &&
5639
+ options->flags.DIFF_FROM_CONTENTS) {
5640
/*
5641
* run diff_flush_patch for the exit status. setting
5642
* options->file to /dev/null should be safe, because we
@@ -5684,7 +5684,7 @@ free_queue:
5684
* diff_addremove/diff_change does not set the bit when
5685
* DIFF_FROM_CONTENTS is in effect (e.g. with -w).
5686
*/
5687
- if (DIFF_OPT_TST(options, DIFF_FROM_CONTENTS)) {
5687
+ if (options->flags.DIFF_FROM_CONTENTS) {
5688
if (options->found_changes)
5689
DIFF_OPT_SET(options, HAS_CHANGES);
5690
else
@@ -5808,7 +5808,7 @@ static void diffcore_skip_stat_unmatch(struct diff_options *diffopt)
5808
* to determine how many paths were dirty only
5809
* due to stat info mismatch.
5810
*/
5811
- if (!DIFF_OPT_TST(diffopt, NO_INDEX))
5811
+ if (!diffopt->flags.NO_INDEX)
5812
diffopt->skip_stat_unmatch++;
5813
diff_free_filepair(p);
5814
}
@@ -5857,7 +5857,7 @@ void diffcore_std(struct diff_options *options)
5857
diff_resolve_rename_copy();
5858
diffcore_apply_filter(options);
5859
5860
- if (diff_queued_diff.nr && !DIFF_OPT_TST(options, DIFF_FROM_CONTENTS))
5860
+ if (diff_queued_diff.nr && !options->flags.DIFF_FROM_CONTENTS)
5861
DIFF_OPT_SET(options, HAS_CHANGES);
5862
else
5863
DIFF_OPT_CLR(options, HAS_CHANGES);
@@ -5872,23 +5872,23 @@ int diff_result_code(struct diff_options *opt, int status)
5872
diff_warn_rename_limit("diff.renameLimit",
5873
opt->needed_rename_limit,
5874
opt->degraded_cc_to_c);
5875
- if (!DIFF_OPT_TST(opt, EXIT_WITH_STATUS) &&
5875
+ if (!opt->flags.EXIT_WITH_STATUS &&
5876
!(opt->output_format & DIFF_FORMAT_CHECKDIFF))
5877
return status;
5878
- if (DIFF_OPT_TST(opt, EXIT_WITH_STATUS) &&
5879
- DIFF_OPT_TST(opt, HAS_CHANGES))
5878
+ if (opt->flags.EXIT_WITH_STATUS &&
5879
+ opt->flags.HAS_CHANGES)
5880
result |= 01;
5881
if ((opt->output_format & DIFF_FORMAT_CHECKDIFF) &&
5882
- DIFF_OPT_TST(opt, CHECK_FAILED))
5882
+ opt->flags.CHECK_FAILED)
5883
result |= 02;
5884
return result;
5885
}
5886
5887
int diff_can_quit_early(struct diff_options *opt)
5888
{
5889
- return (DIFF_OPT_TST(opt, QUICK) &&
5889
+ return (opt->flags.QUICK &&
5890
!opt->filter &&
5891
- DIFF_OPT_TST(opt, HAS_CHANGES));
5891
+ opt->flags.HAS_CHANGES);
5892
}
5893
5894
/*
@@ -5901,9 +5901,9 @@ static int is_submodule_ignored(const char *path, struct diff_options *options)
5901
{
5902
int ignored = 0;
5903
struct diff_flags orig_flags = options->flags;
5904
- if (!DIFF_OPT_TST(options, OVERRIDE_SUBMODULE_CONFIG))
5904
+ if (!options->flags.OVERRIDE_SUBMODULE_CONFIG)
5905
set_diffopt_flags_from_submodule_config(options, path);
5906
- if (DIFF_OPT_TST(options, IGNORE_SUBMODULES))
5906
+ if (options->flags.IGNORE_SUBMODULES)
5907
ignored = 1;
5908
options->flags = orig_flags;
5909
return ignored;
@@ -5932,7 +5932,7 @@ void diff_addremove(struct diff_options *options,
5932
* Before the final output happens, they are pruned after
5933
* merged into rename/copy pairs as appropriate.
5934
*/
5935
- if (DIFF_OPT_TST(options, REVERSE_DIFF))
5935
+ if (options->flags.REVERSE_DIFF)
5936
addremove = (addremove == '+' ? '-' :
5937
addremove == '-' ? '+' : addremove);
5938
@@ -5951,7 +5951,7 @@ void diff_addremove(struct diff_options *options,
5951
}
5952
5953
diff_queue(&diff_queued_diff, one, two);
5954
- if (!DIFF_OPT_TST(options, DIFF_FROM_CONTENTS))
5954
+ if (!options->flags.DIFF_FROM_CONTENTS)
5955
DIFF_OPT_SET(options, HAS_CHANGES);
5956
}
5957
@@ -5970,7 +5970,7 @@ void diff_change(struct diff_options *options,
5970
is_submodule_ignored(concatpath, options))
5971
return;
5972
5973
- if (DIFF_OPT_TST(options, REVERSE_DIFF)) {
5973
+ if (options->flags.REVERSE_DIFF) {
5974
SWAP(old_mode, new_mode);
5975
SWAP(old_oid, new_oid);
5976
SWAP(old_oid_valid, new_oid_valid);
@@ -5989,10 +5989,10 @@ void diff_change(struct diff_options *options,
5989
two->dirty_submodule = new_dirty_submodule;
5990
p = diff_queue(&diff_queued_diff, one, two);
5991
5992
- if (DIFF_OPT_TST(options, DIFF_FROM_CONTENTS))
5992
+ if (options->flags.DIFF_FROM_CONTENTS)
5993
return;
5994
5995
- if (DIFF_OPT_TST(options, QUICK) && options->skip_stat_unmatch &&
5995
+ if (options->flags.QUICK && options->skip_stat_unmatch &&
5996
!diff_filespec_check_stat_unmatch(p))
5997
return;
5998
@@ -6134,7 +6134,7 @@ void setup_diff_pager(struct diff_options *opt)
6134
* and because it is easy to find people oneline advising "git diff
6135
* --exit-code" in hooks and other scripts, we do not do so.
6136
*/
6137
- if (!DIFF_OPT_TST(opt, EXIT_WITH_STATUS) &&
6137
+ if (!opt->flags.EXIT_WITH_STATUS &&
6138
check_pager_config("diff") != 0)
6139
setup_pager();
6140
}
diff.h
-1
@@ -106,7 +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_TST(opts, flag) ((opts)->flags.flag)
109
#define DIFF_OPT_SET(opts, flag) ((opts)->flags.flag = 1)
110
#define DIFF_OPT_CLR(opts, flag) ((opts)->flags.flag = 0)
111
diffcore-pickaxe.c
+4
-4
@@ -131,7 +131,7 @@ static int pickaxe_match(struct diff_filepair *p, struct diff_options *o,
131
if (!DIFF_FILE_VALID(p->one) && !DIFF_FILE_VALID(p->two))
132
return 0;
133
134
- if (DIFF_OPT_TST(o, ALLOW_TEXTCONV)) {
134
+ if (o->flags.ALLOW_TEXTCONV) {
135
textconv_one = get_textconv(p->one);
136
textconv_two = get_textconv(p->two);
137
}
@@ -222,11 +222,11 @@ void diffcore_pickaxe(struct diff_options *o)
222
223
if (opts & (DIFF_PICKAXE_REGEX | DIFF_PICKAXE_KIND_G)) {
224
int cflags = REG_EXTENDED | REG_NEWLINE;
225
- if (DIFF_OPT_TST(o, PICKAXE_IGNORE_CASE))
225
+ if (o->flags.PICKAXE_IGNORE_CASE)
226
cflags |= REG_ICASE;
227
regcomp_or_die(®ex, needle, cflags);
228
regexp = ®ex;
229
- } else if (DIFF_OPT_TST(o, PICKAXE_IGNORE_CASE) &&
229
+ } else if (o->flags.PICKAXE_IGNORE_CASE &&
230
has_non_ascii(needle)) {
231
struct strbuf sb = STRBUF_INIT;
232
int cflags = REG_NEWLINE | REG_ICASE;
@@ -236,7 +236,7 @@ void diffcore_pickaxe(struct diff_options *o)
236
strbuf_release(&sb);
237
regexp = ®ex;
238
} else {
239
- kws = kwsalloc(DIFF_OPT_TST(o, PICKAXE_IGNORE_CASE)
239
+ kws = kwsalloc(o->flags.PICKAXE_IGNORE_CASE
240
? tolower_trans_tbl : NULL);
241
kwsincr(kws, needle, strlen(needle));
242
kwsprep(kws);
diffcore-rename.c
+3
-3
@@ -405,7 +405,7 @@ static int too_many_rename_candidates(int num_create,
405
num_src > num_create ? num_src : num_create;
406
407
/* Are we running under -C -C? */
408
- if (!DIFF_OPT_TST(options, FIND_COPIES_HARDER))
408
+ if (!options->flags.FIND_COPIES_HARDER)
409
return 1;
410
411
/* Would we bust the limit if we were running under -C? */
@@ -463,7 +463,7 @@ void diffcore_rename(struct diff_options *options)
463
else if (options->single_follow &&
464
strcmp(options->single_follow, p->two->path))
465
continue; /* not interested */
466
- else if (!DIFF_OPT_TST(options, RENAME_EMPTY) &&
466
+ else if (!options->flags.RENAME_EMPTY &&
467
is_empty_blob_oid(&p->two->oid))
468
continue;
469
else if (add_rename_dst(p->two) < 0) {
@@ -473,7 +473,7 @@ void diffcore_rename(struct diff_options *options)
473
goto cleanup;
474
}
475
}
476
- else if (!DIFF_OPT_TST(options, RENAME_EMPTY) &&
476
+ else if (!options->flags.RENAME_EMPTY &&
477
is_empty_blob_oid(&p->one->oid))
478
continue;
479
else if (!DIFF_PAIR_UNMERGED(p) && !DIFF_FILE_VALID(p->two)) {
log-tree.c
+1
-1
@@ -793,7 +793,7 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log
793
struct commit_list *parents;
794
struct object_id *oid;
795
796
- if (!opt->diff && !DIFF_OPT_TST(&opt->diffopt, EXIT_WITH_STATUS))
796
+ if (!opt->diff && !opt->diffopt.flags.EXIT_WITH_STATUS)
797
return 0;
798
799
parse_commit_or_die(commit);
revision.c
+2
-2
@@ -2399,7 +2399,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
2399
/* Pickaxe, diff-filter and rename following need diffs */
2400
if (revs->diffopt.pickaxe ||
2401
revs->diffopt.filter ||
2402
- DIFF_OPT_TST(&revs->diffopt, FOLLOW_RENAMES))
2402
+ revs->diffopt.flags.FOLLOW_RENAMES)
2403
revs->diff = 1;
2404
2405
if (revs->topo_order)
@@ -2408,7 +2408,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
2408
if (revs->prune_data.nr) {
2409
copy_pathspec(&revs->pruning.pathspec, &revs->prune_data);
2410
/* Can't prune commits with rename following: the paths change.. */
2411
- if (!DIFF_OPT_TST(&revs->diffopt, FOLLOW_RENAMES))
2411
+ if (!revs->diffopt.flags.FOLLOW_RENAMES)
2412
revs->prune = 1;
2413
if (!revs->full_diff)
2414
copy_pathspec(&revs->diffopt.pathspec,
submodule.c
+1
-1
@@ -616,7 +616,7 @@ void show_submodule_inline_diff(struct diff_options *o, const char *path,
616
argv_array_pushf(&cp.args, "--color=%s", want_color(o->use_color) ?
617
"always" : "never");
618
619
- if (DIFF_OPT_TST(o, REVERSE_DIFF)) {
619
+ if (o->flags.REVERSE_DIFF) {
620
argv_array_pushf(&cp.args, "--src-prefix=%s%s/",
621
o->b_prefix, path);
622
argv_array_pushf(&cp.args, "--dst-prefix=%s%s/",
tree-diff.c
+6
-6
@@ -212,9 +212,9 @@ static struct combine_diff_path *emit_path(struct combine_diff_path *p,
212
mode = 0;
213
}
214
215
- if (DIFF_OPT_TST(opt, RECURSIVE) && isdir) {
215
+ if (opt->flags.RECURSIVE && isdir) {
216
recurse = 1;
217
- emitthis = DIFF_OPT_TST(opt, TREE_IN_RECURSIVE);
217
+ emitthis = opt->flags.TREE_IN_RECURSIVE;
218
}
219
220
if (emitthis) {
@@ -425,7 +425,7 @@ static struct combine_diff_path *ll_diff_tree_paths(
425
ttree = fill_tree_descriptor(&t, oid);
426
427
/* Enable recursion indefinitely */
428
- opt->pathspec.recursive = DIFF_OPT_TST(opt, RECURSIVE);
428
+ opt->pathspec.recursive = opt->flags.RECURSIVE;
429
430
for (;;) {
431
int imin, cmp;
@@ -484,7 +484,7 @@ static struct combine_diff_path *ll_diff_tree_paths(
484
/* t = p[imin] */
485
if (cmp == 0) {
486
/* are either pi > p[imin] or diff(t,pi) != ø ? */
487
- if (!DIFF_OPT_TST(opt, FIND_COPIES_HARDER)) {
487
+ if (!opt->flags.FIND_COPIES_HARDER) {
488
for (i = 0; i < nparent; ++i) {
489
/* p[i] > p[imin] */
490
if (tp[i].entry.mode & S_IFXMIN_NEQ)
@@ -522,7 +522,7 @@ static struct combine_diff_path *ll_diff_tree_paths(
522
/* t > p[imin] */
523
else {
524
/* ∀i pi=p[imin] -> D += "-p[imin]" */
525
- if (!DIFF_OPT_TST(opt, FIND_COPIES_HARDER)) {
525
+ if (!opt->flags.FIND_COPIES_HARDER) {
526
for (i = 0; i < nparent; ++i)
527
if (tp[i].entry.mode & S_IFXMIN_NEQ)
528
goto skip_emit_tp;
@@ -706,7 +706,7 @@ int diff_tree_oid(const struct object_id *old_oid,
706
strbuf_addstr(&base, base_str);
707
708
retval = ll_diff_tree_oid(old_oid, new_oid, &base, opt);
709
- if (!*base_str && DIFF_OPT_TST(opt, FOLLOW_RENAMES) && diff_might_be_rename())
709
+ if (!*base_str && opt->flags.FOLLOW_RENAMES && diff_might_be_rename())
710
try_to_follow_renames(old_oid, new_oid, &base, opt);
711
712
strbuf_release(&base);