124
for (i = 0; i < params.nr; i++) {
125
const char *p = params.items[i].string;
126
if (!strcmp(p, "changes")) {
127
- options->flags.DIRSTAT_BY_LINE = 0;
128
- options->flags.DIRSTAT_BY_FILE = 0;
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
- options->flags.DIRSTAT_BY_FILE = 0;
130
+ options->flags.dirstat_by_line = 1;
131
+ options->flags.dirstat_by_file = 0;
132
} else if (!strcmp(p, "files")) {
133
- options->flags.DIRSTAT_BY_LINE = 0;
134
- options->flags.DIRSTAT_BY_FILE = 1;
133
+ options->flags.dirstat_by_line = 0;
134
+ options->flags.dirstat_by_file = 1;
135
} else if (!strcmp(p, "noncumulative")) {
136
- options->flags.DIRSTAT_CUMULATIVE = 0;
136
+ options->flags.dirstat_cumulative = 0;
137
} else if (!strcmp(p, "cumulative")) {
138
- options->flags.DIRSTAT_CUMULATIVE = 1;
138
+ options->flags.dirstat_cumulative = 1;
139
} else if (isdigit(*p)) {
140
char *end;
141
int permille = strtoul(p, &end, 10) * 10;
1481
struct emit_callback ecbdata;
1482
struct strbuf out = STRBUF_INIT;
1483
1484
- if (diff_mnemonic_prefix && o->flags.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
dir.alloc = 0;
2730
dir.nr = 0;
2731
dir.permille = options->dirstat_permille;
2732
- dir.cumulative = options->flags.DIRSTAT_CUMULATIVE;
2732
+ dir.cumulative = options->flags.dirstat_cumulative;
2733
2734
changed = 0;
2735
for (i = 0; i < q->nr; i++) {
2755
goto found_damage;
2756
}
2757
2758
- if (options->flags.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
dir.alloc = 0;
2831
dir.nr = 0;
2832
dir.permille = options->dirstat_permille;
2833
- dir.cumulative = options->flags.DIRSTAT_CUMULATIVE;
2833
+ dir.cumulative = options->flags.dirstat_cumulative;
2834
2835
changed = 0;
2836
for (i = 0; i < data->nr; i++) {
3117
const char *line_prefix = diff_line_prefix(o);
3118
3119
diff_set_mnemonic_prefix(o, "a/", "b/");
3120
- if (o->flags.REVERSE_DIFF) {
3120
+ if (o->flags.reverse_diff) {
3121
a_prefix = o->b_prefix;
3122
b_prefix = o->a_prefix;
3123
} else {
3141
return;
3142
}
3143
3144
- if (o->flags.ALLOW_TEXTCONV) {
3144
+ if (o->flags.allow_textconv) {
3145
textconv_one = get_textconv(one);
3146
textconv_two = get_textconv(two);
3147
}
3201
header.len, 0);
3202
strbuf_reset(&header);
3203
goto free_ab_and_return;
3204
- } else if (!o->flags.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
- !o->flags.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
}
3237
emit_diff_symbol(o, DIFF_SYMBOL_HEADER, header.buf, header.len, 0);
3238
strbuf_reset(&header);
3239
- if (o->flags.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
xecfg.ctxlen = o->context;
3283
xecfg.interhunkctxlen = o->interhunkcontext;
3284
xecfg.flags = XDL_EMIT_FUNCNAMES;
3285
- if (o->flags.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);
3447
diff_free_filespec_data(one);
3448
diff_free_filespec_data(two);
3449
if (data.status)
3450
- o->flags.CHECK_FAILED = 1;
3450
+ o->flags.check_failed = 1;
3451
}
3452
3453
struct diff_filespec *alloc_filespec(const char *path)
3941
*must_show_header = 0;
3942
}
3943
if (one && two && oidcmp(&one->oid, &two->oid)) {
3944
- int abbrev = o->flags.FULL_INDEX ? 40 : DEFAULT_ABBREV;
3944
+ int abbrev = o->flags.full_index ? 40 : DEFAULT_ABBREV;
3945
3946
- if (o->flags.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
int must_show_header = 0;
3974
3975
3976
- if (o->flags.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
if (o->prefix_length)
4054
strip_prefix(o->prefix_length, &name, &other);
4055
4056
- if (!o->flags.ALLOW_EXTERNAL)
4056
+ if (!o->flags.allow_external)
4057
pgm = NULL;
4058
4059
if (DIFF_PAIR_UNMERGED(p)) {
4152
options->context = diff_context_default;
4153
options->interhunkcontext = diff_interhunk_context_default;
4154
options->ws_error_highlight = ws_error_highlight_default;
4155
- options->flags.RENAME_EMPTY = 1;
4155
+ options->flags.rename_empty = 1;
4156
4157
/* pathchange left =NULL by default */
4158
options->change = diff_change;
4203
if (DIFF_XDL_TST(options, IGNORE_WHITESPACE) ||
4204
DIFF_XDL_TST(options, IGNORE_WHITESPACE_CHANGE) ||
4205
DIFF_XDL_TST(options, IGNORE_WHITESPACE_AT_EOL))
4206
- options->flags.DIFF_FROM_CONTENTS = 1;
4206
+ options->flags.diff_from_contents = 1;
4207
else
4208
- options->flags.DIFF_FROM_CONTENTS = 0;
4208
+ options->flags.diff_from_contents = 0;
4209
4210
- if (options->flags.FIND_COPIES_HARDER)
4210
+ if (options->flags.find_copies_harder)
4211
options->detect_rename = DIFF_DETECT_COPY;
4212
4213
- if (!options->flags.RELATIVE_NAME)
4213
+ if (!options->flags.relative_name)
4214
options->prefix = NULL;
4215
if (options->prefix)
4216
options->prefix_length = strlen(options->prefix);
4240
DIFF_FORMAT_DIRSTAT |
4241
DIFF_FORMAT_SUMMARY |
4242
DIFF_FORMAT_CHECKDIFF))
4243
- options->flags.RECURSIVE = 1;
4243
+ options->flags.recursive = 1;
4244
/*
4245
* Also pickaxe would not work very well if you do not say recursive
4246
*/
4247
if (options->pickaxe)
4248
- options->flags.RECURSIVE = 1;
4248
+ options->flags.recursive = 1;
4249
/*
4250
* When patches are generated, submodules diffed against the work tree
4251
* must be checked for dirtiness too so it can be shown in the output
4252
*/
4253
if (options->output_format & DIFF_FORMAT_PATCH)
4254
- options->flags.DIRTY_SUBMODULES = 1;
4254
+ options->flags.dirty_submodules = 1;
4255
4256
if (options->detect_rename && options->rename_limit < 0)
4257
options->rename_limit = diff_rename_limit_default;
4273
* to have found. It does not make sense not to return with
4274
* exit code in such a case either.
4275
*/
4276
- if (options->flags.QUICK) {
4276
+ if (options->flags.quick) {
4277
options->output_format = DIFF_FORMAT_NO_OUTPUT;
4278
- options->flags.EXIT_WITH_STATUS = 1;
4278
+ options->flags.exit_with_status = 1;
4279
}
4280
4281
options->diff_path_counter = 0;
4282
4283
- if (options->flags.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())
4630
else if (starts_with(arg, "-C") || starts_with(arg, "--find-copies=") ||
4631
!strcmp(arg, "--find-copies")) {
4632
if (options->detect_rename == DIFF_DETECT_COPY)
4633
- options->flags.FIND_COPIES_HARDER = 1;
4633
+ options->flags.find_copies_harder = 1;
4634
if ((options->rename_score = diff_scoreopt_parse(arg)) == -1)
4635
return error("invalid argument to -C: %s", arg+2);
4636
options->detect_rename = DIFF_DETECT_COPY;
4638
else if (!strcmp(arg, "--no-renames"))
4639
options->detect_rename = 0;
4640
else if (!strcmp(arg, "--rename-empty"))
4641
- options->flags.RENAME_EMPTY = 1;
4641
+ options->flags.rename_empty = 1;
4642
else if (!strcmp(arg, "--no-rename-empty"))
4643
- options->flags.RENAME_EMPTY = 0;
4643
+ options->flags.rename_empty = 0;
4644
else if (!strcmp(arg, "--relative"))
4645
- options->flags.RELATIVE_NAME = 1;
4645
+ options->flags.relative_name = 1;
4646
else if (skip_prefix(arg, "--relative=", &arg)) {
4647
- options->flags.RELATIVE_NAME = 1;
4647
+ options->flags.relative_name = 1;
4648
options->prefix = arg;
4649
}
4650
4684
/* flags options */
4685
else if (!strcmp(arg, "--binary")) {
4686
enable_patch_output(&options->output_format);
4687
- options->flags.BINARY = 1;
4687
+ options->flags.binary = 1;
4688
}
4689
else if (!strcmp(arg, "--full-index"))
4690
- options->flags.FULL_INDEX = 1;
4690
+ options->flags.full_index = 1;
4691
else if (!strcmp(arg, "-a") || !strcmp(arg, "--text"))
4692
- options->flags.TEXT = 1;
4692
+ options->flags.text = 1;
4693
else if (!strcmp(arg, "-R"))
4694
- options->flags.REVERSE_DIFF = 1;
4694
+ options->flags.reverse_diff = 1;
4695
else if (!strcmp(arg, "--find-copies-harder"))
4696
- options->flags.FIND_COPIES_HARDER = 1;
4696
+ options->flags.find_copies_harder = 1;
4697
else if (!strcmp(arg, "--follow"))
4698
- options->flags.FOLLOW_RENAMES = 1;
4698
+ options->flags.follow_renames = 1;
4699
else if (!strcmp(arg, "--no-follow")) {
4700
- options->flags.FOLLOW_RENAMES = 0;
4701
- options->flags.DEFAULT_FOLLOW_RENAMES = 0;
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)) {
4755
return argcount;
4756
}
4757
else if (!strcmp(arg, "--exit-code"))
4758
- options->flags.EXIT_WITH_STATUS = 1;
4758
+ options->flags.exit_with_status = 1;
4759
else if (!strcmp(arg, "--quiet"))
4760
- options->flags.QUICK = 1;
4760
+ options->flags.quick = 1;
4761
else if (!strcmp(arg, "--ext-diff"))
4762
- options->flags.ALLOW_EXTERNAL = 1;
4762
+ options->flags.allow_external = 1;
4763
else if (!strcmp(arg, "--no-ext-diff"))
4764
- options->flags.ALLOW_EXTERNAL = 0;
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;
4766
+ options->flags.allow_textconv = 1;
4767
+ options->flags.textconv_set_via_cmdline = 1;
4768
} else if (!strcmp(arg, "--no-textconv"))
4769
- options->flags.ALLOW_TEXTCONV = 0;
4769
+ options->flags.allow_textconv = 0;
4770
else if (!strcmp(arg, "--ignore-submodules")) {
4771
- options->flags.OVERRIDE_SUBMODULE_CONFIG = 1;
4771
+ options->flags.override_submodule_config = 1;
4772
handle_ignore_submodules_arg(options, "all");
4773
} else if (skip_prefix(arg, "--ignore-submodules=", &arg)) {
4774
- options->flags.OVERRIDE_SUBMODULE_CONFIG = 1;
4774
+ options->flags.override_submodule_config = 1;
4775
handle_ignore_submodules_arg(options, arg);
4776
} else if (!strcmp(arg, "--submodule"))
4777
options->submodule_format = DIFF_SUBMODULE_LOG;
4846
&options->interhunkcontext))
4847
;
4848
else if (!strcmp(arg, "-W"))
4849
- options->flags.FUNCCONTEXT = 1;
4849
+ options->flags.funccontext = 1;
4850
else if (!strcmp(arg, "--function-context"))
4851
- options->flags.FUNCCONTEXT = 1;
4851
+ options->flags.funccontext = 1;
4852
else if (!strcmp(arg, "--no-function-context"))
4853
- options->flags.FUNCCONTEXT = 0;
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");
5600
separator++;
5601
}
5602
5603
- if (output_format & DIFF_FORMAT_DIRSTAT && options->flags.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
}
5636
5637
if (output_format & DIFF_FORMAT_NO_OUTPUT &&
5638
- options->flags.EXIT_WITH_STATUS &&
5639
- options->flags.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
* diff_addremove/diff_change does not set the bit when
5685
* DIFF_FROM_CONTENTS is in effect (e.g. with -w).
5686
*/
5687
- if (options->flags.DIFF_FROM_CONTENTS) {
5687
+ if (options->flags.diff_from_contents) {
5688
if (options->found_changes)
5689
- options->flags.HAS_CHANGES = 1;
5689
+ options->flags.has_changes = 1;
5690
else
5691
- options->flags.HAS_CHANGES = 0;
5691
+ options->flags.has_changes = 0;
5692
}
5693
}
5694
5808
* to determine how many paths were dirty only
5809
* due to stat info mismatch.
5810
*/
5811
- if (!diffopt->flags.NO_INDEX)
5811
+ if (!diffopt->flags.no_index)
5812
diffopt->skip_stat_unmatch++;
5813
diff_free_filepair(p);
5814
}
5857
diff_resolve_rename_copy();
5858
diffcore_apply_filter(options);
5859
5860
- if (diff_queued_diff.nr && !options->flags.DIFF_FROM_CONTENTS)
5861
- options->flags.HAS_CHANGES = 1;
5860
+ if (diff_queued_diff.nr && !options->flags.diff_from_contents)
5861
+ options->flags.has_changes = 1;
5862
else
5863
- options->flags.HAS_CHANGES = 0;
5863
+ options->flags.has_changes = 0;
5864
5865
options->found_follow = 0;
5866
}
5872
diff_warn_rename_limit("diff.renameLimit",
5873
opt->needed_rename_limit,
5874
opt->degraded_cc_to_c);
5875
- if (!opt->flags.EXIT_WITH_STATUS &&
5875
+ if (!opt->flags.exit_with_status &&
5876
!(opt->output_format & DIFF_FORMAT_CHECKDIFF))
5877
return status;
5878
- if (opt->flags.EXIT_WITH_STATUS &&
5879
- opt->flags.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
- opt->flags.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 (opt->flags.QUICK &&
5889
+ return (opt->flags.quick &&
5890
!opt->filter &&
5891
- opt->flags.HAS_CHANGES);
5891
+ opt->flags.has_changes);
5892
}
5893
5894
/*
5901
{
5902
int ignored = 0;
5903
struct diff_flags orig_flags = options->flags;
5904
- if (!options->flags.OVERRIDE_SUBMODULE_CONFIG)
5904
+ if (!options->flags.override_submodule_config)
5905
set_diffopt_flags_from_submodule_config(options, path);
5906
- if (options->flags.IGNORE_SUBMODULES)
5906
+ if (options->flags.ignore_submodules)
5907
ignored = 1;
5908
options->flags = orig_flags;
5909
return ignored;
5932
* Before the final output happens, they are pruned after
5933
* merged into rename/copy pairs as appropriate.
5934
*/
5935
- if (options->flags.REVERSE_DIFF)
5935
+ if (options->flags.reverse_diff)
5936
addremove = (addremove == '+' ? '-' :
5937
addremove == '-' ? '+' : addremove);
5938
5951
}
5952
5953
diff_queue(&diff_queued_diff, one, two);
5954
- if (!options->flags.DIFF_FROM_CONTENTS)
5955
- options->flags.HAS_CHANGES = 1;
5954
+ if (!options->flags.diff_from_contents)
5955
+ options->flags.has_changes = 1;
5956
}
5957
5958
void diff_change(struct diff_options *options,
5970
is_submodule_ignored(concatpath, options))
5971
return;
5972
5973
- if (options->flags.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
two->dirty_submodule = new_dirty_submodule;
5990
p = diff_queue(&diff_queued_diff, one, two);
5991
5992
- if (options->flags.DIFF_FROM_CONTENTS)
5992
+ if (options->flags.diff_from_contents)
5993
return;
5994
5995
- if (options->flags.QUICK && options->skip_stat_unmatch &&
5995
+ if (options->flags.quick && options->skip_stat_unmatch &&
5996
!diff_filespec_check_stat_unmatch(p))
5997
return;
5998
5999
- options->flags.HAS_CHANGES = 1;
5999
+ options->flags.has_changes = 1;
6000
}
6001
6002
struct diff_filepair *diff_unmerge(struct diff_options *options, const char *path)
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 (!opt->flags.EXIT_WITH_STATUS &&
6137
+ if (!opt->flags.exit_with_status &&
6138
check_pager_config("diff") != 0)
6139
setup_pager();
6140
}