From 02f2f56bc377c287c411947d0e1482aac888f8db Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Tue, 31 Oct 2017 11:19:05 -0700 Subject: diff: convert flags to be stored in bitfields We cannot add many more flags to the diff machinery due to the limitations of the number of flags that can be stored in a single unsigned int. In order to allow for more flags to be added to the diff machinery in the future this patch converts the flags to be stored in bitfields in 'struct diff_flags'. Signed-off-by: Brandon Williams Signed-off-by: Junio C Hamano --- diff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'diff.c') diff --git a/diff.c b/diff.c index 6fd288420b..3ad9c9b31c 100644 --- a/diff.c +++ b/diff.c @@ -5899,7 +5899,7 @@ int diff_can_quit_early(struct diff_options *opt) static int is_submodule_ignored(const char *path, struct diff_options *options) { int ignored = 0; - unsigned orig_flags = options->flags; + struct diff_flags orig_flags = options->flags; if (!DIFF_OPT_TST(options, OVERRIDE_SUBMODULE_CONFIG)) set_diffopt_flags_from_submodule_config(options, path); if (DIFF_OPT_TST(options, IGNORE_SUBMODULES)) -- cgit v1.2.1 From afa73c5384de1d01386e57bd575257d1420aeb21 Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Tue, 31 Oct 2017 11:19:06 -0700 Subject: diff: add flag to indicate textconv was set via cmdline git-show is unique in that it wants to use textconv by default except for when it is showing blobs. When asked to show a blob, show doesn't want to use textconv unless the user explicitly requested that it be used by providing the command line flag '--textconv'. Currently this is done by using a parallel set of 'touched' flags which get set every time a particular flag is set or cleared. In a future patch we want to eliminate this parallel set of flags so instead of relying on if the textconv flag has been touched, add a new flag 'TEXTCONV_SET_VIA_CMDLINE' which is only set if textconv is set to true via the command line. Signed-off-by: Brandon Williams Signed-off-by: Junio C Hamano --- diff.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'diff.c') diff --git a/diff.c b/diff.c index 3ad9c9b31c..11fccbd107 100644 --- a/diff.c +++ b/diff.c @@ -4762,9 +4762,10 @@ int diff_opt_parse(struct diff_options *options, DIFF_OPT_SET(options, ALLOW_EXTERNAL); else if (!strcmp(arg, "--no-ext-diff")) DIFF_OPT_CLR(options, ALLOW_EXTERNAL); - else if (!strcmp(arg, "--textconv")) + else if (!strcmp(arg, "--textconv")) { DIFF_OPT_SET(options, ALLOW_TEXTCONV); - else if (!strcmp(arg, "--no-textconv")) + DIFF_OPT_SET(options, TEXTCONV_SET_VIA_CMDLINE); + } else if (!strcmp(arg, "--no-textconv")) DIFF_OPT_CLR(options, ALLOW_TEXTCONV); else if (!strcmp(arg, "--ignore-submodules")) { DIFF_OPT_SET(options, OVERRIDE_SUBMODULE_CONFIG); -- cgit v1.2.1 From 3b69daed861daec1923c369d59c97e46eb3c3d7b Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Tue, 31 Oct 2017 11:19:08 -0700 Subject: 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 Signed-off-by: Junio C Hamano --- diff.c | 76 +++++++++++++++++++++++++++++++++--------------------------------- 1 file changed, 38 insertions(+), 38 deletions(-) (limited to 'diff.c') diff --git a/diff.c b/diff.c index 11fccbd107..8bfa57cc3c 100644 --- a/diff.c +++ b/diff.c @@ -1481,7 +1481,7 @@ static void emit_rewrite_diff(const char *name_a, struct emit_callback ecbdata; struct strbuf out = STRBUF_INIT; - if (diff_mnemonic_prefix && DIFF_OPT_TST(o, REVERSE_DIFF)) { + if (diff_mnemonic_prefix && o->flags.REVERSE_DIFF) { a_prefix = o->b_prefix; b_prefix = o->a_prefix; } else { @@ -2729,7 +2729,7 @@ static void show_dirstat(struct diff_options *options) dir.alloc = 0; dir.nr = 0; dir.permille = options->dirstat_permille; - dir.cumulative = DIFF_OPT_TST(options, DIRSTAT_CUMULATIVE); + dir.cumulative = options->flags.DIRSTAT_CUMULATIVE; changed = 0; for (i = 0; i < q->nr; i++) { @@ -2755,7 +2755,7 @@ static void show_dirstat(struct diff_options *options) goto found_damage; } - if (DIFF_OPT_TST(options, DIRSTAT_BY_FILE)) { + if (options->flags.DIRSTAT_BY_FILE) { /* * In --dirstat-by-file mode, we don't really need to * 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 dir.alloc = 0; dir.nr = 0; dir.permille = options->dirstat_permille; - dir.cumulative = DIFF_OPT_TST(options, DIRSTAT_CUMULATIVE); + dir.cumulative = options->flags.DIRSTAT_CUMULATIVE; changed = 0; for (i = 0; i < data->nr; i++) { @@ -3117,7 +3117,7 @@ static void builtin_diff(const char *name_a, const char *line_prefix = diff_line_prefix(o); diff_set_mnemonic_prefix(o, "a/", "b/"); - if (DIFF_OPT_TST(o, REVERSE_DIFF)) { + if (o->flags.REVERSE_DIFF) { a_prefix = o->b_prefix; b_prefix = o->a_prefix; } else { @@ -3141,7 +3141,7 @@ static void builtin_diff(const char *name_a, return; } - if (DIFF_OPT_TST(o, ALLOW_TEXTCONV)) { + if (o->flags.ALLOW_TEXTCONV) { textconv_one = get_textconv(one); textconv_two = get_textconv(two); } @@ -3201,13 +3201,13 @@ static void builtin_diff(const char *name_a, header.len, 0); strbuf_reset(&header); goto free_ab_and_return; - } else if (!DIFF_OPT_TST(o, TEXT) && + } else if (!o->flags.TEXT && ( (!textconv_one && diff_filespec_is_binary(one)) || (!textconv_two && diff_filespec_is_binary(two)) )) { struct strbuf sb = STRBUF_INIT; if (!one->data && !two->data && S_ISREG(one->mode) && S_ISREG(two->mode) && - !DIFF_OPT_TST(o, BINARY)) { + !o->flags.BINARY) { if (!oidcmp(&one->oid, &two->oid)) { if (must_show_header) emit_diff_symbol(o, DIFF_SYMBOL_HEADER, @@ -3236,7 +3236,7 @@ static void builtin_diff(const char *name_a, } emit_diff_symbol(o, DIFF_SYMBOL_HEADER, header.buf, header.len, 0); strbuf_reset(&header); - if (DIFF_OPT_TST(o, BINARY)) + if (o->flags.BINARY) emit_binary_diff(o, &mf1, &mf2); else { strbuf_addf(&sb, "%sBinary files %s and %s differ\n", @@ -3282,7 +3282,7 @@ static void builtin_diff(const char *name_a, xecfg.ctxlen = o->context; xecfg.interhunkctxlen = o->interhunkcontext; xecfg.flags = XDL_EMIT_FUNCNAMES; - if (DIFF_OPT_TST(o, FUNCCONTEXT)) + if (o->flags.FUNCCONTEXT) xecfg.flags |= XDL_EMIT_FUNCCONTEXT; if (pe) xdiff_set_find_func(&xecfg, pe->pattern, pe->cflags); @@ -3941,9 +3941,9 @@ static void fill_metainfo(struct strbuf *msg, *must_show_header = 0; } if (one && two && oidcmp(&one->oid, &two->oid)) { - int abbrev = DIFF_OPT_TST(o, FULL_INDEX) ? 40 : DEFAULT_ABBREV; + int abbrev = o->flags.FULL_INDEX ? 40 : DEFAULT_ABBREV; - if (DIFF_OPT_TST(o, BINARY)) { + if (o->flags.BINARY) { mmfile_t mf; if ((!fill_mmfile(&mf, one) && diff_filespec_is_binary(one)) || (!fill_mmfile(&mf, two) && diff_filespec_is_binary(two))) @@ -3973,7 +3973,7 @@ static void run_diff_cmd(const char *pgm, int must_show_header = 0; - if (DIFF_OPT_TST(o, ALLOW_EXTERNAL)) { + if (o->flags.ALLOW_EXTERNAL) { struct userdiff_driver *drv = userdiff_find_by_path(attr_path); if (drv && drv->external) pgm = drv->external; @@ -4053,7 +4053,7 @@ static void run_diff(struct diff_filepair *p, struct diff_options *o) if (o->prefix_length) strip_prefix(o->prefix_length, &name, &other); - if (!DIFF_OPT_TST(o, ALLOW_EXTERNAL)) + if (!o->flags.ALLOW_EXTERNAL) pgm = NULL; if (DIFF_PAIR_UNMERGED(p)) { @@ -4207,10 +4207,10 @@ void diff_setup_done(struct diff_options *options) else DIFF_OPT_CLR(options, DIFF_FROM_CONTENTS); - if (DIFF_OPT_TST(options, FIND_COPIES_HARDER)) + if (options->flags.FIND_COPIES_HARDER) options->detect_rename = DIFF_DETECT_COPY; - if (!DIFF_OPT_TST(options, RELATIVE_NAME)) + if (!options->flags.RELATIVE_NAME) options->prefix = NULL; if (options->prefix) options->prefix_length = strlen(options->prefix); @@ -4273,14 +4273,14 @@ void diff_setup_done(struct diff_options *options) * to have found. It does not make sense not to return with * exit code in such a case either. */ - if (DIFF_OPT_TST(options, QUICK)) { + if (options->flags.QUICK) { options->output_format = DIFF_FORMAT_NO_OUTPUT; DIFF_OPT_SET(options, EXIT_WITH_STATUS); } options->diff_path_counter = 0; - if (DIFF_OPT_TST(options, FOLLOW_RENAMES) && options->pathspec.nr != 1) + if (options->flags.FOLLOW_RENAMES && options->pathspec.nr != 1) die(_("--follow requires exactly one pathspec")); if (!options->use_color || external_diff()) @@ -5600,7 +5600,7 @@ void diff_flush(struct diff_options *options) separator++; } - if (output_format & DIFF_FORMAT_DIRSTAT && DIFF_OPT_TST(options, DIRSTAT_BY_LINE)) + if (output_format & DIFF_FORMAT_DIRSTAT && options->flags.DIRSTAT_BY_LINE) dirstat_by_line = 1; if (output_format & (DIFF_FORMAT_DIFFSTAT|DIFF_FORMAT_SHORTSTAT|DIFF_FORMAT_NUMSTAT) || @@ -5635,8 +5635,8 @@ void diff_flush(struct diff_options *options) } if (output_format & DIFF_FORMAT_NO_OUTPUT && - DIFF_OPT_TST(options, EXIT_WITH_STATUS) && - DIFF_OPT_TST(options, DIFF_FROM_CONTENTS)) { + options->flags.EXIT_WITH_STATUS && + options->flags.DIFF_FROM_CONTENTS) { /* * run diff_flush_patch for the exit status. setting * options->file to /dev/null should be safe, because we @@ -5684,7 +5684,7 @@ free_queue: * diff_addremove/diff_change does not set the bit when * DIFF_FROM_CONTENTS is in effect (e.g. with -w). */ - if (DIFF_OPT_TST(options, DIFF_FROM_CONTENTS)) { + if (options->flags.DIFF_FROM_CONTENTS) { if (options->found_changes) DIFF_OPT_SET(options, HAS_CHANGES); else @@ -5808,7 +5808,7 @@ static void diffcore_skip_stat_unmatch(struct diff_options *diffopt) * to determine how many paths were dirty only * due to stat info mismatch. */ - if (!DIFF_OPT_TST(diffopt, NO_INDEX)) + if (!diffopt->flags.NO_INDEX) diffopt->skip_stat_unmatch++; diff_free_filepair(p); } @@ -5857,7 +5857,7 @@ void diffcore_std(struct diff_options *options) diff_resolve_rename_copy(); diffcore_apply_filter(options); - if (diff_queued_diff.nr && !DIFF_OPT_TST(options, DIFF_FROM_CONTENTS)) + if (diff_queued_diff.nr && !options->flags.DIFF_FROM_CONTENTS) DIFF_OPT_SET(options, HAS_CHANGES); else DIFF_OPT_CLR(options, HAS_CHANGES); @@ -5872,23 +5872,23 @@ int diff_result_code(struct diff_options *opt, int status) diff_warn_rename_limit("diff.renameLimit", opt->needed_rename_limit, opt->degraded_cc_to_c); - if (!DIFF_OPT_TST(opt, EXIT_WITH_STATUS) && + if (!opt->flags.EXIT_WITH_STATUS && !(opt->output_format & DIFF_FORMAT_CHECKDIFF)) return status; - if (DIFF_OPT_TST(opt, EXIT_WITH_STATUS) && - DIFF_OPT_TST(opt, HAS_CHANGES)) + if (opt->flags.EXIT_WITH_STATUS && + opt->flags.HAS_CHANGES) result |= 01; if ((opt->output_format & DIFF_FORMAT_CHECKDIFF) && - DIFF_OPT_TST(opt, CHECK_FAILED)) + opt->flags.CHECK_FAILED) result |= 02; return result; } int diff_can_quit_early(struct diff_options *opt) { - return (DIFF_OPT_TST(opt, QUICK) && + return (opt->flags.QUICK && !opt->filter && - DIFF_OPT_TST(opt, HAS_CHANGES)); + opt->flags.HAS_CHANGES); } /* @@ -5901,9 +5901,9 @@ static int is_submodule_ignored(const char *path, struct diff_options *options) { int ignored = 0; struct diff_flags orig_flags = options->flags; - if (!DIFF_OPT_TST(options, OVERRIDE_SUBMODULE_CONFIG)) + if (!options->flags.OVERRIDE_SUBMODULE_CONFIG) set_diffopt_flags_from_submodule_config(options, path); - if (DIFF_OPT_TST(options, IGNORE_SUBMODULES)) + if (options->flags.IGNORE_SUBMODULES) ignored = 1; options->flags = orig_flags; return ignored; @@ -5932,7 +5932,7 @@ void diff_addremove(struct diff_options *options, * Before the final output happens, they are pruned after * merged into rename/copy pairs as appropriate. */ - if (DIFF_OPT_TST(options, REVERSE_DIFF)) + if (options->flags.REVERSE_DIFF) addremove = (addremove == '+' ? '-' : addremove == '-' ? '+' : addremove); @@ -5951,7 +5951,7 @@ void diff_addremove(struct diff_options *options, } diff_queue(&diff_queued_diff, one, two); - if (!DIFF_OPT_TST(options, DIFF_FROM_CONTENTS)) + if (!options->flags.DIFF_FROM_CONTENTS) DIFF_OPT_SET(options, HAS_CHANGES); } @@ -5970,7 +5970,7 @@ void diff_change(struct diff_options *options, is_submodule_ignored(concatpath, options)) return; - if (DIFF_OPT_TST(options, REVERSE_DIFF)) { + if (options->flags.REVERSE_DIFF) { SWAP(old_mode, new_mode); SWAP(old_oid, new_oid); SWAP(old_oid_valid, new_oid_valid); @@ -5989,10 +5989,10 @@ void diff_change(struct diff_options *options, two->dirty_submodule = new_dirty_submodule; p = diff_queue(&diff_queued_diff, one, two); - if (DIFF_OPT_TST(options, DIFF_FROM_CONTENTS)) + if (options->flags.DIFF_FROM_CONTENTS) return; - if (DIFF_OPT_TST(options, QUICK) && options->skip_stat_unmatch && + if (options->flags.QUICK && options->skip_stat_unmatch && !diff_filespec_check_stat_unmatch(p)) return; @@ -6134,7 +6134,7 @@ void setup_diff_pager(struct diff_options *opt) * and because it is easy to find people oneline advising "git diff * --exit-code" in hooks and other scripts, we do not do so. */ - if (!DIFF_OPT_TST(opt, EXIT_WITH_STATUS) && + if (!opt->flags.EXIT_WITH_STATUS && check_pager_config("diff") != 0) setup_pager(); } -- cgit v1.2.1 From 23dcf77f48feb49c54bad09210f093a799816334 Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Tue, 31 Oct 2017 11:19:09 -0700 Subject: diff: remove DIFF_OPT_SET macro 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_SET(&E, fld) + E.flags.fld = 1 @@ type T; T *ptr; identifier fld; @@ - DIFF_OPT_SET(ptr, fld) + ptr->flags.fld = 1 Signed-off-by: Brandon Williams Signed-off-by: Junio C Hamano --- diff.c | 66 +++++++++++++++++++++++++++++++++--------------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) (limited to 'diff.c') diff --git a/diff.c b/diff.c index 8bfa57cc3c..6dea186d8d 100644 --- a/diff.c +++ b/diff.c @@ -127,15 +127,15 @@ static int parse_dirstat_params(struct diff_options *options, const char *params DIFF_OPT_CLR(options, DIRSTAT_BY_LINE); DIFF_OPT_CLR(options, DIRSTAT_BY_FILE); } else if (!strcmp(p, "lines")) { - DIFF_OPT_SET(options, DIRSTAT_BY_LINE); + options->flags.DIRSTAT_BY_LINE = 1; DIFF_OPT_CLR(options, DIRSTAT_BY_FILE); } else if (!strcmp(p, "files")) { DIFF_OPT_CLR(options, DIRSTAT_BY_LINE); - DIFF_OPT_SET(options, DIRSTAT_BY_FILE); + options->flags.DIRSTAT_BY_FILE = 1; } else if (!strcmp(p, "noncumulative")) { DIFF_OPT_CLR(options, DIRSTAT_CUMULATIVE); } else if (!strcmp(p, "cumulative")) { - DIFF_OPT_SET(options, DIRSTAT_CUMULATIVE); + options->flags.DIRSTAT_CUMULATIVE = 1; } else if (isdigit(*p)) { char *end; int permille = strtoul(p, &end, 10) * 10; @@ -3447,7 +3447,7 @@ static void builtin_checkdiff(const char *name_a, const char *name_b, diff_free_filespec_data(one); diff_free_filespec_data(two); if (data.status) - DIFF_OPT_SET(o, CHECK_FAILED); + o->flags.CHECK_FAILED = 1; } struct diff_filespec *alloc_filespec(const char *path) @@ -4152,7 +4152,7 @@ void diff_setup(struct diff_options *options) options->context = diff_context_default; options->interhunkcontext = diff_interhunk_context_default; options->ws_error_highlight = ws_error_highlight_default; - DIFF_OPT_SET(options, RENAME_EMPTY); + options->flags.RENAME_EMPTY = 1; /* pathchange left =NULL by default */ options->change = diff_change; @@ -4203,7 +4203,7 @@ void diff_setup_done(struct diff_options *options) if (DIFF_XDL_TST(options, IGNORE_WHITESPACE) || DIFF_XDL_TST(options, IGNORE_WHITESPACE_CHANGE) || DIFF_XDL_TST(options, IGNORE_WHITESPACE_AT_EOL)) - DIFF_OPT_SET(options, DIFF_FROM_CONTENTS); + options->flags.DIFF_FROM_CONTENTS = 1; else DIFF_OPT_CLR(options, DIFF_FROM_CONTENTS); @@ -4240,18 +4240,18 @@ void diff_setup_done(struct diff_options *options) DIFF_FORMAT_DIRSTAT | DIFF_FORMAT_SUMMARY | DIFF_FORMAT_CHECKDIFF)) - DIFF_OPT_SET(options, RECURSIVE); + options->flags.RECURSIVE = 1; /* * Also pickaxe would not work very well if you do not say recursive */ if (options->pickaxe) - DIFF_OPT_SET(options, RECURSIVE); + options->flags.RECURSIVE = 1; /* * When patches are generated, submodules diffed against the work tree * must be checked for dirtiness too so it can be shown in the output */ if (options->output_format & DIFF_FORMAT_PATCH) - DIFF_OPT_SET(options, DIRTY_SUBMODULES); + options->flags.DIRTY_SUBMODULES = 1; if (options->detect_rename && options->rename_limit < 0) options->rename_limit = diff_rename_limit_default; @@ -4275,7 +4275,7 @@ void diff_setup_done(struct diff_options *options) */ if (options->flags.QUICK) { options->output_format = DIFF_FORMAT_NO_OUTPUT; - DIFF_OPT_SET(options, EXIT_WITH_STATUS); + options->flags.EXIT_WITH_STATUS = 1; } options->diff_path_counter = 0; @@ -4630,7 +4630,7 @@ int diff_opt_parse(struct diff_options *options, else if (starts_with(arg, "-C") || starts_with(arg, "--find-copies=") || !strcmp(arg, "--find-copies")) { if (options->detect_rename == DIFF_DETECT_COPY) - DIFF_OPT_SET(options, FIND_COPIES_HARDER); + options->flags.FIND_COPIES_HARDER = 1; if ((options->rename_score = diff_scoreopt_parse(arg)) == -1) return error("invalid argument to -C: %s", arg+2); options->detect_rename = DIFF_DETECT_COPY; @@ -4638,13 +4638,13 @@ int diff_opt_parse(struct diff_options *options, else if (!strcmp(arg, "--no-renames")) options->detect_rename = 0; else if (!strcmp(arg, "--rename-empty")) - DIFF_OPT_SET(options, RENAME_EMPTY); + options->flags.RENAME_EMPTY = 1; else if (!strcmp(arg, "--no-rename-empty")) DIFF_OPT_CLR(options, RENAME_EMPTY); else if (!strcmp(arg, "--relative")) - DIFF_OPT_SET(options, RELATIVE_NAME); + options->flags.RELATIVE_NAME = 1; else if (skip_prefix(arg, "--relative=", &arg)) { - DIFF_OPT_SET(options, RELATIVE_NAME); + options->flags.RELATIVE_NAME = 1; options->prefix = arg; } @@ -4684,18 +4684,18 @@ int diff_opt_parse(struct diff_options *options, /* flags options */ else if (!strcmp(arg, "--binary")) { enable_patch_output(&options->output_format); - DIFF_OPT_SET(options, BINARY); + options->flags.BINARY = 1; } else if (!strcmp(arg, "--full-index")) - DIFF_OPT_SET(options, FULL_INDEX); + options->flags.FULL_INDEX = 1; else if (!strcmp(arg, "-a") || !strcmp(arg, "--text")) - DIFF_OPT_SET(options, TEXT); + options->flags.TEXT = 1; else if (!strcmp(arg, "-R")) - DIFF_OPT_SET(options, REVERSE_DIFF); + options->flags.REVERSE_DIFF = 1; else if (!strcmp(arg, "--find-copies-harder")) - DIFF_OPT_SET(options, FIND_COPIES_HARDER); + options->flags.FIND_COPIES_HARDER = 1; else if (!strcmp(arg, "--follow")) - DIFF_OPT_SET(options, FOLLOW_RENAMES); + options->flags.FOLLOW_RENAMES = 1; else if (!strcmp(arg, "--no-follow")) { DIFF_OPT_CLR(options, FOLLOW_RENAMES); DIFF_OPT_CLR(options, DEFAULT_FOLLOW_RENAMES); @@ -4755,23 +4755,23 @@ int diff_opt_parse(struct diff_options *options, return argcount; } else if (!strcmp(arg, "--exit-code")) - DIFF_OPT_SET(options, EXIT_WITH_STATUS); + options->flags.EXIT_WITH_STATUS = 1; else if (!strcmp(arg, "--quiet")) - DIFF_OPT_SET(options, QUICK); + options->flags.QUICK = 1; else if (!strcmp(arg, "--ext-diff")) - DIFF_OPT_SET(options, ALLOW_EXTERNAL); + options->flags.ALLOW_EXTERNAL = 1; else if (!strcmp(arg, "--no-ext-diff")) DIFF_OPT_CLR(options, ALLOW_EXTERNAL); else if (!strcmp(arg, "--textconv")) { - DIFF_OPT_SET(options, ALLOW_TEXTCONV); - DIFF_OPT_SET(options, TEXTCONV_SET_VIA_CMDLINE); + options->flags.ALLOW_TEXTCONV = 1; + options->flags.TEXTCONV_SET_VIA_CMDLINE = 1; } else if (!strcmp(arg, "--no-textconv")) DIFF_OPT_CLR(options, ALLOW_TEXTCONV); else if (!strcmp(arg, "--ignore-submodules")) { - DIFF_OPT_SET(options, OVERRIDE_SUBMODULE_CONFIG); + options->flags.OVERRIDE_SUBMODULE_CONFIG = 1; handle_ignore_submodules_arg(options, "all"); } else if (skip_prefix(arg, "--ignore-submodules=", &arg)) { - DIFF_OPT_SET(options, OVERRIDE_SUBMODULE_CONFIG); + options->flags.OVERRIDE_SUBMODULE_CONFIG = 1; handle_ignore_submodules_arg(options, arg); } else if (!strcmp(arg, "--submodule")) options->submodule_format = DIFF_SUBMODULE_LOG; @@ -4846,9 +4846,9 @@ int diff_opt_parse(struct diff_options *options, &options->interhunkcontext)) ; else if (!strcmp(arg, "-W")) - DIFF_OPT_SET(options, FUNCCONTEXT); + options->flags.FUNCCONTEXT = 1; else if (!strcmp(arg, "--function-context")) - DIFF_OPT_SET(options, FUNCCONTEXT); + options->flags.FUNCCONTEXT = 1; else if (!strcmp(arg, "--no-function-context")) DIFF_OPT_CLR(options, FUNCCONTEXT); else if ((argcount = parse_long_opt("output", av, &optarg))) { @@ -5686,7 +5686,7 @@ free_queue: */ if (options->flags.DIFF_FROM_CONTENTS) { if (options->found_changes) - DIFF_OPT_SET(options, HAS_CHANGES); + options->flags.HAS_CHANGES = 1; else DIFF_OPT_CLR(options, HAS_CHANGES); } @@ -5858,7 +5858,7 @@ void diffcore_std(struct diff_options *options) diffcore_apply_filter(options); if (diff_queued_diff.nr && !options->flags.DIFF_FROM_CONTENTS) - DIFF_OPT_SET(options, HAS_CHANGES); + options->flags.HAS_CHANGES = 1; else DIFF_OPT_CLR(options, HAS_CHANGES); @@ -5952,7 +5952,7 @@ void diff_addremove(struct diff_options *options, diff_queue(&diff_queued_diff, one, two); if (!options->flags.DIFF_FROM_CONTENTS) - DIFF_OPT_SET(options, HAS_CHANGES); + options->flags.HAS_CHANGES = 1; } void diff_change(struct diff_options *options, @@ -5996,7 +5996,7 @@ void diff_change(struct diff_options *options, !diff_filespec_check_stat_unmatch(p)) return; - DIFF_OPT_SET(options, HAS_CHANGES); + options->flags.HAS_CHANGES = 1; } struct diff_filepair *diff_unmerge(struct diff_options *options, const char *path) -- cgit v1.2.1 From b2100e529171f0bbd497366618436cf86c08a324 Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Tue, 31 Oct 2017 11:19:10 -0700 Subject: 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 Signed-off-by: Junio C Hamano --- diff.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'diff.c') diff --git a/diff.c b/diff.c index 6dea186d8d..e5f9d3078a 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 @@ 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; } -- cgit v1.2.1 From 0d1e0e7801bb2ae22036ad09f9f5cec17e08c48b Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Tue, 31 Oct 2017 11:19:11 -0700 Subject: diff: make struct diff_flags members lowercase Now that the flags stored in struct diff_flags are being accessed directly and not through macros, change all struct members from being uppercase to lowercase. This conversion is done using the following semantic patch: @@ expression E; @@ - E.RECURSIVE + E.recursive @@ expression E; @@ - E.TREE_IN_RECURSIVE + E.tree_in_recursive @@ expression E; @@ - E.BINARY + E.binary @@ expression E; @@ - E.TEXT + E.text @@ expression E; @@ - E.FULL_INDEX + E.full_index @@ expression E; @@ - E.SILENT_ON_REMOVE + E.silent_on_remove @@ expression E; @@ - E.FIND_COPIES_HARDER + E.find_copies_harder @@ expression E; @@ - E.FOLLOW_RENAMES + E.follow_renames @@ expression E; @@ - E.RENAME_EMPTY + E.rename_empty @@ expression E; @@ - E.HAS_CHANGES + E.has_changes @@ expression E; @@ - E.QUICK + E.quick @@ expression E; @@ - E.NO_INDEX + E.no_index @@ expression E; @@ - E.ALLOW_EXTERNAL + E.allow_external @@ expression E; @@ - E.EXIT_WITH_STATUS + E.exit_with_status @@ expression E; @@ - E.REVERSE_DIFF + E.reverse_diff @@ expression E; @@ - E.CHECK_FAILED + E.check_failed @@ expression E; @@ - E.RELATIVE_NAME + E.relative_name @@ expression E; @@ - E.IGNORE_SUBMODULES + E.ignore_submodules @@ expression E; @@ - E.DIRSTAT_CUMULATIVE + E.dirstat_cumulative @@ expression E; @@ - E.DIRSTAT_BY_FILE + E.dirstat_by_file @@ expression E; @@ - E.ALLOW_TEXTCONV + E.allow_textconv @@ expression E; @@ - E.TEXTCONV_SET_VIA_CMDLINE + E.textconv_set_via_cmdline @@ expression E; @@ - E.DIFF_FROM_CONTENTS + E.diff_from_contents @@ expression E; @@ - E.DIRTY_SUBMODULES + E.dirty_submodules @@ expression E; @@ - E.IGNORE_UNTRACKED_IN_SUBMODULES + E.ignore_untracked_in_submodules @@ expression E; @@ - E.IGNORE_DIRTY_SUBMODULES + E.ignore_dirty_submodules @@ expression E; @@ - E.OVERRIDE_SUBMODULE_CONFIG + E.override_submodule_config @@ expression E; @@ - E.DIRSTAT_BY_LINE + E.dirstat_by_line @@ expression E; @@ - E.FUNCCONTEXT + E.funccontext @@ expression E; @@ - E.PICKAXE_IGNORE_CASE + E.pickaxe_ignore_case @@ expression E; @@ - E.DEFAULT_FOLLOW_RENAMES + E.default_follow_renames Signed-off-by: Brandon Williams Signed-off-by: Junio C Hamano --- diff.c | 170 ++++++++++++++++++++++++++++++++--------------------------------- 1 file changed, 85 insertions(+), 85 deletions(-) (limited to 'diff.c') diff --git a/diff.c b/diff.c index e5f9d3078a..5714382d3f 100644 --- a/diff.c +++ b/diff.c @@ -124,18 +124,18 @@ 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")) { - options->flags.DIRSTAT_BY_LINE = 0; - options->flags.DIRSTAT_BY_FILE = 0; + options->flags.dirstat_by_line = 0; + options->flags.dirstat_by_file = 0; } else if (!strcmp(p, "lines")) { - options->flags.DIRSTAT_BY_LINE = 1; - options->flags.DIRSTAT_BY_FILE = 0; + options->flags.dirstat_by_line = 1; + options->flags.dirstat_by_file = 0; } else if (!strcmp(p, "files")) { - options->flags.DIRSTAT_BY_LINE = 0; - options->flags.DIRSTAT_BY_FILE = 1; + options->flags.dirstat_by_line = 0; + options->flags.dirstat_by_file = 1; } else if (!strcmp(p, "noncumulative")) { - options->flags.DIRSTAT_CUMULATIVE = 0; + options->flags.dirstat_cumulative = 0; } else if (!strcmp(p, "cumulative")) { - options->flags.DIRSTAT_CUMULATIVE = 1; + options->flags.dirstat_cumulative = 1; } else if (isdigit(*p)) { char *end; int permille = strtoul(p, &end, 10) * 10; @@ -1481,7 +1481,7 @@ static void emit_rewrite_diff(const char *name_a, struct emit_callback ecbdata; struct strbuf out = STRBUF_INIT; - if (diff_mnemonic_prefix && o->flags.REVERSE_DIFF) { + if (diff_mnemonic_prefix && o->flags.reverse_diff) { a_prefix = o->b_prefix; b_prefix = o->a_prefix; } else { @@ -2729,7 +2729,7 @@ static void show_dirstat(struct diff_options *options) dir.alloc = 0; dir.nr = 0; dir.permille = options->dirstat_permille; - dir.cumulative = options->flags.DIRSTAT_CUMULATIVE; + dir.cumulative = options->flags.dirstat_cumulative; changed = 0; for (i = 0; i < q->nr; i++) { @@ -2755,7 +2755,7 @@ static void show_dirstat(struct diff_options *options) goto found_damage; } - if (options->flags.DIRSTAT_BY_FILE) { + if (options->flags.dirstat_by_file) { /* * In --dirstat-by-file mode, we don't really need to * 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 dir.alloc = 0; dir.nr = 0; dir.permille = options->dirstat_permille; - dir.cumulative = options->flags.DIRSTAT_CUMULATIVE; + dir.cumulative = options->flags.dirstat_cumulative; changed = 0; for (i = 0; i < data->nr; i++) { @@ -3117,7 +3117,7 @@ static void builtin_diff(const char *name_a, const char *line_prefix = diff_line_prefix(o); diff_set_mnemonic_prefix(o, "a/", "b/"); - if (o->flags.REVERSE_DIFF) { + if (o->flags.reverse_diff) { a_prefix = o->b_prefix; b_prefix = o->a_prefix; } else { @@ -3141,7 +3141,7 @@ static void builtin_diff(const char *name_a, return; } - if (o->flags.ALLOW_TEXTCONV) { + if (o->flags.allow_textconv) { textconv_one = get_textconv(one); textconv_two = get_textconv(two); } @@ -3201,13 +3201,13 @@ static void builtin_diff(const char *name_a, header.len, 0); strbuf_reset(&header); goto free_ab_and_return; - } else if (!o->flags.TEXT && + } else if (!o->flags.text && ( (!textconv_one && diff_filespec_is_binary(one)) || (!textconv_two && diff_filespec_is_binary(two)) )) { struct strbuf sb = STRBUF_INIT; if (!one->data && !two->data && S_ISREG(one->mode) && S_ISREG(two->mode) && - !o->flags.BINARY) { + !o->flags.binary) { if (!oidcmp(&one->oid, &two->oid)) { if (must_show_header) emit_diff_symbol(o, DIFF_SYMBOL_HEADER, @@ -3236,7 +3236,7 @@ static void builtin_diff(const char *name_a, } emit_diff_symbol(o, DIFF_SYMBOL_HEADER, header.buf, header.len, 0); strbuf_reset(&header); - if (o->flags.BINARY) + if (o->flags.binary) emit_binary_diff(o, &mf1, &mf2); else { strbuf_addf(&sb, "%sBinary files %s and %s differ\n", @@ -3282,7 +3282,7 @@ static void builtin_diff(const char *name_a, xecfg.ctxlen = o->context; xecfg.interhunkctxlen = o->interhunkcontext; xecfg.flags = XDL_EMIT_FUNCNAMES; - if (o->flags.FUNCCONTEXT) + if (o->flags.funccontext) xecfg.flags |= XDL_EMIT_FUNCCONTEXT; if (pe) xdiff_set_find_func(&xecfg, pe->pattern, pe->cflags); @@ -3447,7 +3447,7 @@ static void builtin_checkdiff(const char *name_a, const char *name_b, diff_free_filespec_data(one); diff_free_filespec_data(two); if (data.status) - o->flags.CHECK_FAILED = 1; + o->flags.check_failed = 1; } struct diff_filespec *alloc_filespec(const char *path) @@ -3941,9 +3941,9 @@ static void fill_metainfo(struct strbuf *msg, *must_show_header = 0; } if (one && two && oidcmp(&one->oid, &two->oid)) { - int abbrev = o->flags.FULL_INDEX ? 40 : DEFAULT_ABBREV; + int abbrev = o->flags.full_index ? 40 : DEFAULT_ABBREV; - if (o->flags.BINARY) { + if (o->flags.binary) { mmfile_t mf; if ((!fill_mmfile(&mf, one) && diff_filespec_is_binary(one)) || (!fill_mmfile(&mf, two) && diff_filespec_is_binary(two))) @@ -3973,7 +3973,7 @@ static void run_diff_cmd(const char *pgm, int must_show_header = 0; - if (o->flags.ALLOW_EXTERNAL) { + if (o->flags.allow_external) { struct userdiff_driver *drv = userdiff_find_by_path(attr_path); if (drv && drv->external) pgm = drv->external; @@ -4053,7 +4053,7 @@ static void run_diff(struct diff_filepair *p, struct diff_options *o) if (o->prefix_length) strip_prefix(o->prefix_length, &name, &other); - if (!o->flags.ALLOW_EXTERNAL) + if (!o->flags.allow_external) pgm = NULL; if (DIFF_PAIR_UNMERGED(p)) { @@ -4152,7 +4152,7 @@ void diff_setup(struct diff_options *options) options->context = diff_context_default; options->interhunkcontext = diff_interhunk_context_default; options->ws_error_highlight = ws_error_highlight_default; - options->flags.RENAME_EMPTY = 1; + options->flags.rename_empty = 1; /* pathchange left =NULL by default */ options->change = diff_change; @@ -4203,14 +4203,14 @@ void diff_setup_done(struct diff_options *options) if (DIFF_XDL_TST(options, IGNORE_WHITESPACE) || DIFF_XDL_TST(options, IGNORE_WHITESPACE_CHANGE) || DIFF_XDL_TST(options, IGNORE_WHITESPACE_AT_EOL)) - options->flags.DIFF_FROM_CONTENTS = 1; + options->flags.diff_from_contents = 1; else - options->flags.DIFF_FROM_CONTENTS = 0; + options->flags.diff_from_contents = 0; - if (options->flags.FIND_COPIES_HARDER) + if (options->flags.find_copies_harder) options->detect_rename = DIFF_DETECT_COPY; - if (!options->flags.RELATIVE_NAME) + if (!options->flags.relative_name) options->prefix = NULL; if (options->prefix) options->prefix_length = strlen(options->prefix); @@ -4240,18 +4240,18 @@ void diff_setup_done(struct diff_options *options) DIFF_FORMAT_DIRSTAT | DIFF_FORMAT_SUMMARY | DIFF_FORMAT_CHECKDIFF)) - options->flags.RECURSIVE = 1; + options->flags.recursive = 1; /* * Also pickaxe would not work very well if you do not say recursive */ if (options->pickaxe) - options->flags.RECURSIVE = 1; + options->flags.recursive = 1; /* * When patches are generated, submodules diffed against the work tree * must be checked for dirtiness too so it can be shown in the output */ if (options->output_format & DIFF_FORMAT_PATCH) - options->flags.DIRTY_SUBMODULES = 1; + options->flags.dirty_submodules = 1; if (options->detect_rename && options->rename_limit < 0) options->rename_limit = diff_rename_limit_default; @@ -4273,14 +4273,14 @@ void diff_setup_done(struct diff_options *options) * to have found. It does not make sense not to return with * exit code in such a case either. */ - if (options->flags.QUICK) { + if (options->flags.quick) { options->output_format = DIFF_FORMAT_NO_OUTPUT; - options->flags.EXIT_WITH_STATUS = 1; + options->flags.exit_with_status = 1; } options->diff_path_counter = 0; - if (options->flags.FOLLOW_RENAMES && options->pathspec.nr != 1) + if (options->flags.follow_renames && options->pathspec.nr != 1) die(_("--follow requires exactly one pathspec")); if (!options->use_color || external_diff()) @@ -4630,7 +4630,7 @@ int diff_opt_parse(struct diff_options *options, else if (starts_with(arg, "-C") || starts_with(arg, "--find-copies=") || !strcmp(arg, "--find-copies")) { if (options->detect_rename == DIFF_DETECT_COPY) - options->flags.FIND_COPIES_HARDER = 1; + options->flags.find_copies_harder = 1; if ((options->rename_score = diff_scoreopt_parse(arg)) == -1) return error("invalid argument to -C: %s", arg+2); options->detect_rename = DIFF_DETECT_COPY; @@ -4638,13 +4638,13 @@ int diff_opt_parse(struct diff_options *options, else if (!strcmp(arg, "--no-renames")) options->detect_rename = 0; else if (!strcmp(arg, "--rename-empty")) - options->flags.RENAME_EMPTY = 1; + options->flags.rename_empty = 1; else if (!strcmp(arg, "--no-rename-empty")) - options->flags.RENAME_EMPTY = 0; + options->flags.rename_empty = 0; else if (!strcmp(arg, "--relative")) - options->flags.RELATIVE_NAME = 1; + options->flags.relative_name = 1; else if (skip_prefix(arg, "--relative=", &arg)) { - options->flags.RELATIVE_NAME = 1; + options->flags.relative_name = 1; options->prefix = arg; } @@ -4684,21 +4684,21 @@ int diff_opt_parse(struct diff_options *options, /* flags options */ else if (!strcmp(arg, "--binary")) { enable_patch_output(&options->output_format); - options->flags.BINARY = 1; + options->flags.binary = 1; } else if (!strcmp(arg, "--full-index")) - options->flags.FULL_INDEX = 1; + options->flags.full_index = 1; else if (!strcmp(arg, "-a") || !strcmp(arg, "--text")) - options->flags.TEXT = 1; + options->flags.text = 1; else if (!strcmp(arg, "-R")) - options->flags.REVERSE_DIFF = 1; + options->flags.reverse_diff = 1; else if (!strcmp(arg, "--find-copies-harder")) - options->flags.FIND_COPIES_HARDER = 1; + options->flags.find_copies_harder = 1; else if (!strcmp(arg, "--follow")) - options->flags.FOLLOW_RENAMES = 1; + options->flags.follow_renames = 1; else if (!strcmp(arg, "--no-follow")) { - options->flags.FOLLOW_RENAMES = 0; - options->flags.DEFAULT_FOLLOW_RENAMES = 0; + 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)) { @@ -4755,23 +4755,23 @@ int diff_opt_parse(struct diff_options *options, return argcount; } else if (!strcmp(arg, "--exit-code")) - options->flags.EXIT_WITH_STATUS = 1; + options->flags.exit_with_status = 1; else if (!strcmp(arg, "--quiet")) - options->flags.QUICK = 1; + options->flags.quick = 1; else if (!strcmp(arg, "--ext-diff")) - options->flags.ALLOW_EXTERNAL = 1; + options->flags.allow_external = 1; else if (!strcmp(arg, "--no-ext-diff")) - options->flags.ALLOW_EXTERNAL = 0; + options->flags.allow_external = 0; else if (!strcmp(arg, "--textconv")) { - options->flags.ALLOW_TEXTCONV = 1; - options->flags.TEXTCONV_SET_VIA_CMDLINE = 1; + options->flags.allow_textconv = 1; + options->flags.textconv_set_via_cmdline = 1; } else if (!strcmp(arg, "--no-textconv")) - options->flags.ALLOW_TEXTCONV = 0; + options->flags.allow_textconv = 0; else if (!strcmp(arg, "--ignore-submodules")) { - options->flags.OVERRIDE_SUBMODULE_CONFIG = 1; + options->flags.override_submodule_config = 1; handle_ignore_submodules_arg(options, "all"); } else if (skip_prefix(arg, "--ignore-submodules=", &arg)) { - options->flags.OVERRIDE_SUBMODULE_CONFIG = 1; + options->flags.override_submodule_config = 1; handle_ignore_submodules_arg(options, arg); } else if (!strcmp(arg, "--submodule")) options->submodule_format = DIFF_SUBMODULE_LOG; @@ -4846,11 +4846,11 @@ int diff_opt_parse(struct diff_options *options, &options->interhunkcontext)) ; else if (!strcmp(arg, "-W")) - options->flags.FUNCCONTEXT = 1; + options->flags.funccontext = 1; else if (!strcmp(arg, "--function-context")) - options->flags.FUNCCONTEXT = 1; + options->flags.funccontext = 1; else if (!strcmp(arg, "--no-function-context")) - options->flags.FUNCCONTEXT = 0; + options->flags.funccontext = 0; else if ((argcount = parse_long_opt("output", av, &optarg))) { char *path = prefix_filename(prefix, optarg); options->file = xfopen(path, "w"); @@ -5600,7 +5600,7 @@ void diff_flush(struct diff_options *options) separator++; } - if (output_format & DIFF_FORMAT_DIRSTAT && options->flags.DIRSTAT_BY_LINE) + if (output_format & DIFF_FORMAT_DIRSTAT && options->flags.dirstat_by_line) dirstat_by_line = 1; if (output_format & (DIFF_FORMAT_DIFFSTAT|DIFF_FORMAT_SHORTSTAT|DIFF_FORMAT_NUMSTAT) || @@ -5635,8 +5635,8 @@ void diff_flush(struct diff_options *options) } if (output_format & DIFF_FORMAT_NO_OUTPUT && - options->flags.EXIT_WITH_STATUS && - options->flags.DIFF_FROM_CONTENTS) { + options->flags.exit_with_status && + options->flags.diff_from_contents) { /* * run diff_flush_patch for the exit status. setting * options->file to /dev/null should be safe, because we @@ -5684,11 +5684,11 @@ free_queue: * diff_addremove/diff_change does not set the bit when * DIFF_FROM_CONTENTS is in effect (e.g. with -w). */ - if (options->flags.DIFF_FROM_CONTENTS) { + if (options->flags.diff_from_contents) { if (options->found_changes) - options->flags.HAS_CHANGES = 1; + options->flags.has_changes = 1; else - options->flags.HAS_CHANGES = 0; + options->flags.has_changes = 0; } } @@ -5808,7 +5808,7 @@ static void diffcore_skip_stat_unmatch(struct diff_options *diffopt) * to determine how many paths were dirty only * due to stat info mismatch. */ - if (!diffopt->flags.NO_INDEX) + if (!diffopt->flags.no_index) diffopt->skip_stat_unmatch++; diff_free_filepair(p); } @@ -5857,10 +5857,10 @@ void diffcore_std(struct diff_options *options) diff_resolve_rename_copy(); diffcore_apply_filter(options); - if (diff_queued_diff.nr && !options->flags.DIFF_FROM_CONTENTS) - options->flags.HAS_CHANGES = 1; + if (diff_queued_diff.nr && !options->flags.diff_from_contents) + options->flags.has_changes = 1; else - options->flags.HAS_CHANGES = 0; + options->flags.has_changes = 0; options->found_follow = 0; } @@ -5872,23 +5872,23 @@ int diff_result_code(struct diff_options *opt, int status) diff_warn_rename_limit("diff.renameLimit", opt->needed_rename_limit, opt->degraded_cc_to_c); - if (!opt->flags.EXIT_WITH_STATUS && + if (!opt->flags.exit_with_status && !(opt->output_format & DIFF_FORMAT_CHECKDIFF)) return status; - if (opt->flags.EXIT_WITH_STATUS && - opt->flags.HAS_CHANGES) + if (opt->flags.exit_with_status && + opt->flags.has_changes) result |= 01; if ((opt->output_format & DIFF_FORMAT_CHECKDIFF) && - opt->flags.CHECK_FAILED) + opt->flags.check_failed) result |= 02; return result; } int diff_can_quit_early(struct diff_options *opt) { - return (opt->flags.QUICK && + return (opt->flags.quick && !opt->filter && - opt->flags.HAS_CHANGES); + opt->flags.has_changes); } /* @@ -5901,9 +5901,9 @@ static int is_submodule_ignored(const char *path, struct diff_options *options) { int ignored = 0; struct diff_flags orig_flags = options->flags; - if (!options->flags.OVERRIDE_SUBMODULE_CONFIG) + if (!options->flags.override_submodule_config) set_diffopt_flags_from_submodule_config(options, path); - if (options->flags.IGNORE_SUBMODULES) + if (options->flags.ignore_submodules) ignored = 1; options->flags = orig_flags; return ignored; @@ -5932,7 +5932,7 @@ void diff_addremove(struct diff_options *options, * Before the final output happens, they are pruned after * merged into rename/copy pairs as appropriate. */ - if (options->flags.REVERSE_DIFF) + if (options->flags.reverse_diff) addremove = (addremove == '+' ? '-' : addremove == '-' ? '+' : addremove); @@ -5951,8 +5951,8 @@ void diff_addremove(struct diff_options *options, } diff_queue(&diff_queued_diff, one, two); - if (!options->flags.DIFF_FROM_CONTENTS) - options->flags.HAS_CHANGES = 1; + if (!options->flags.diff_from_contents) + options->flags.has_changes = 1; } void diff_change(struct diff_options *options, @@ -5970,7 +5970,7 @@ void diff_change(struct diff_options *options, is_submodule_ignored(concatpath, options)) return; - if (options->flags.REVERSE_DIFF) { + if (options->flags.reverse_diff) { SWAP(old_mode, new_mode); SWAP(old_oid, new_oid); SWAP(old_oid_valid, new_oid_valid); @@ -5989,14 +5989,14 @@ void diff_change(struct diff_options *options, two->dirty_submodule = new_dirty_submodule; p = diff_queue(&diff_queued_diff, one, two); - if (options->flags.DIFF_FROM_CONTENTS) + if (options->flags.diff_from_contents) return; - if (options->flags.QUICK && options->skip_stat_unmatch && + if (options->flags.quick && options->skip_stat_unmatch && !diff_filespec_check_stat_unmatch(p)) return; - options->flags.HAS_CHANGES = 1; + options->flags.has_changes = 1; } struct diff_filepair *diff_unmerge(struct diff_options *options, const char *path) @@ -6134,7 +6134,7 @@ void setup_diff_pager(struct diff_options *opt) * and because it is easy to find people oneline advising "git diff * --exit-code" in hooks and other scripts, we do not do so. */ - if (!opt->flags.EXIT_WITH_STATUS && + if (!opt->flags.exit_with_status && check_pager_config("diff") != 0) setup_pager(); } -- cgit v1.2.1