{"thread":{"id":"47047","subject":"[PATCH 0/3] convert diff flags to be stored in a struct","startedAt":"2017-10-27T22:29:03Z","lastAt":"2017-11-01T17:11:18Z","messageCount":47,"participants":["Brandon Williams","Junio C Hamano","Stefan Beller"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"331188","messageId":"20171027222853.180981-1-bmwill@google.com","threadId":"47047","inReplyTo":null,"subject":"[PATCH 0/3] convert diff flags to be stored in a struct","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-10-27T22:28:50Z","receivedAt":"2017-10-27T22:29:03Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"There has be some desire to add additional flags to the diff machineery\n(https://public-inbox.org/git/20171024000931.14814-1-sbeller@google.com/) but\ndue to the limits of the number of bits in an unsigned int on some systems we\ncan't add any additonal flags to the 'flags' variable.  This series converts\nthe flags to be stored in bitfields in a struct instead of in bit positions in\nan unsigned int.\n\nSome thoughts:\n * We may want to do a follow on patch to convert all the flags from being in\n   uppercase to lower case.\n * Maybe we can figure out how to remove the 'touched_flags' things (since its\n   only used in one place) and then we may even be able to stop needing to use\n   macros to set/clr/test the flags.\n\nBrandon Williams (3):\n  add: use DIFF_OPT_SET macro to set a diff flag\n  reset: use DIFF_OPT_SET macro to set a diff flag\n  diff: convert flags to be stored in bitfields\n\n builtin/add.c    |  2 +-\n builtin/commit.c |  7 +++--\n builtin/log.c    |  2 +-\n builtin/reset.c  |  2 +-\n diff-lib.c       |  6 ++--\n diff.c           |  3 +-\n diff.h           | 96 +++++++++++++++++++++++++++++++++-----------------------\n sequencer.c      |  5 +--\n 8 files changed, 72 insertions(+), 51 deletions(-)\n\n-- \n2.15.0.rc2.357.g7e34df9404-goog\n\n"},{"id":"331189","messageId":"20171027222853.180981-2-bmwill@google.com","threadId":"47047","inReplyTo":"20171027222853.180981-1-bmwill@google.com","subject":"[PATCH 1/3] add: use DIFF_OPT_SET macro to set a diff flag","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-10-27T22:28:51Z","receivedAt":"2017-10-27T22:29:06Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"Instead of explicitly setting the 'DIFF_OPT_OVERRIDE_SUBMODULE_CONFIG'\nflag, use the 'DIFF_OPT_SET' macro.\n\nSigned-off-by: Brandon Williams <bmwill@google.com>\n---\n builtin/add.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/add.c b/builtin/add.c\nindex a648cf4c5..b70e8a779 100644\n--- a/builtin/add.c\n+++ b/builtin/add.c\n@@ -116,7 +116,7 @@ int add_files_to_cache(const char *prefix,\n \trev.diffopt.output_format = DIFF_FORMAT_CALLBACK;\n \trev.diffopt.format_callback = update_callback;\n \trev.diffopt.format_callback_data = &data;\n-\trev.diffopt.flags |= DIFF_OPT_OVERRIDE_SUBMODULE_CONFIG;\n+\tDIFF_OPT_SET(&rev.diffopt, OVERRIDE_SUBMODULE_CONFIG);\n \trev.max_count = 0; /* do not compare unmerged paths with stage #2 */\n \trun_diff_files(&rev, DIFF_RACY_IS_MODIFIED);\n \tclear_pathspec(&rev.prune_data);\n-- \n2.15.0.rc2.357.g7e34df9404-goog\n\n"},{"id":"331190","messageId":"20171027222853.180981-3-bmwill@google.com","threadId":"47047","inReplyTo":"20171027222853.180981-1-bmwill@google.com","subject":"[PATCH 2/3] reset: use DIFF_OPT_SET macro to set a diff flag","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-10-27T22:28:52Z","receivedAt":"2017-10-27T22:29:09Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"Instead of explicitly setting the 'DIFF_OPT_OVERRIDE_SUBMODULE_CONFIG'\nflag, use the 'DIFF_OPT_SET' macro.\n\nSigned-off-by: Brandon Williams <bmwill@google.com>\n---\n builtin/reset.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/reset.c b/builtin/reset.c\nindex 9cd89b230..ea2fad5a0 100644\n--- a/builtin/reset.c\n+++ b/builtin/reset.c\n@@ -166,7 +166,7 @@ static int read_from_tree(const struct pathspec *pathspec,\n \topt.output_format = DIFF_FORMAT_CALLBACK;\n \topt.format_callback = update_index_from_diff;\n \topt.format_callback_data = &intent_to_add;\n-\topt.flags |= DIFF_OPT_OVERRIDE_SUBMODULE_CONFIG;\n+\tDIFF_OPT_SET(&opt, OVERRIDE_SUBMODULE_CONFIG);\n \n \tif (do_diff_cache(tree_oid, &opt))\n \t\treturn 1;\n-- \n2.15.0.rc2.357.g7e34df9404-goog\n\n"},{"id":"331191","messageId":"20171027222853.180981-4-bmwill@google.com","threadId":"47047","inReplyTo":"20171027222853.180981-1-bmwill@google.com","subject":"[PATCH 3/3] diff: convert flags to be stored in bitfields","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-10-27T22:28:53Z","receivedAt":"2017-10-27T22:29:11Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"We have have reached the limit of the number of flags that can be stored\nin a single unsigned int.  In order to allow for more flags to be added\nto the diff machinery in the future this patch converts the flags to be\nstored in bitfields in 'struct diff_flags'.\n\nSigned-off-by: Brandon Williams <bmwill@google.com>\n---\n builtin/commit.c |  7 +++--\n builtin/log.c    |  2 +-\n diff-lib.c       |  6 ++--\n diff.c           |  3 +-\n diff.h           | 96 +++++++++++++++++++++++++++++++++-----------------------\n sequencer.c      |  5 +--\n 6 files changed, 70 insertions(+), 49 deletions(-)\n\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex d75b3805e..de08c2594 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -912,11 +912,12 @@ static int prepare_to_commit(const char *index_file, const char *prefix,\n \t\t\t * submodules which were manually staged, which would\n \t\t\t * be really confusing.\n \t\t\t */\n-\t\t\tint diff_flags = DIFF_OPT_OVERRIDE_SUBMODULE_CONFIG;\n+\t\t\tstruct diff_flags flags = DIFF_FLAGS_INIT;\n+\t\t\tflags.OVERRIDE_SUBMODULE_CONFIG = 1;\n \t\t\tif (ignore_submodule_arg &&\n \t\t\t    !strcmp(ignore_submodule_arg, \"all\"))\n-\t\t\t\tdiff_flags |= DIFF_OPT_IGNORE_SUBMODULES;\n-\t\t\tcommitable = index_differs_from(parent, diff_flags, 1);\n+\t\t\t\tflags.IGNORE_SUBMODULES = 1;\n+\t\t\tcommitable = index_differs_from(parent, flags, 1);\n \t\t}\n \t}\n \tstrbuf_release(&committer_ident);\ndiff --git a/builtin/log.c b/builtin/log.c\nindex d81a09051..780975ed4 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -134,7 +134,7 @@ static void cmd_log_init_defaults(struct rev_info *rev)\n \n \tif (default_date_mode)\n \t\tparse_date_format(default_date_mode, &rev->date_mode);\n-\trev->diffopt.touched_flags = 0;\n+\trev->diffopt.touched_flags = diff_flags_cleared;\n }\n \n static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,\ndiff --git a/diff-lib.c b/diff-lib.c\nindex 4e0980caa..7375ef71d 100644\n--- a/diff-lib.c\n+++ b/diff-lib.c\n@@ -71,7 +71,7 @@ static int match_stat_with_submodule(struct diff_options *diffopt,\n {\n \tint changed = ce_match_stat(ce, st, ce_option);\n \tif (S_ISGITLINK(ce->ce_mode)) {\n-\t\tunsigned orig_flags = diffopt->flags;\n+\t\tstruct diff_flags orig_flags = diffopt->flags;\n \t\tif (!DIFF_OPT_TST(diffopt, OVERRIDE_SUBMODULE_CONFIG))\n \t\t\tset_diffopt_flags_from_submodule_config(diffopt, ce->name);\n \t\tif (DIFF_OPT_TST(diffopt, IGNORE_SUBMODULES))\n@@ -534,7 +534,7 @@ int do_diff_cache(const struct object_id *tree_oid, struct diff_options *opt)\n \treturn 0;\n }\n \n-int index_differs_from(const char *def, int diff_flags,\n+int index_differs_from(const char *def, struct diff_flags flags,\n \t\t       int ita_invisible_in_index)\n {\n \tstruct rev_info rev;\n@@ -546,7 +546,7 @@ int index_differs_from(const char *def, int diff_flags,\n \tsetup_revisions(0, NULL, &rev, &opt);\n \tDIFF_OPT_SET(&rev.diffopt, QUICK);\n \tDIFF_OPT_SET(&rev.diffopt, EXIT_WITH_STATUS);\n-\trev.diffopt.flags |= diff_flags;\n+\trev.diffopt.flags = diff_flags_or(rev.diffopt.flags, flags);\n \trev.diffopt.ita_invisible_in_index = ita_invisible_in_index;\n \trun_diff_index(&rev, 1);\n \tobject_array_clear(&rev.pending);\ndiff --git a/diff.c b/diff.c\nindex 6fd288420..6f1050d42 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -46,6 +46,7 @@ static int diff_no_prefix;\n static int diff_stat_graph_width;\n static int diff_dirstat_permille_default = 30;\n static struct diff_options default_diff_options;\n+const struct diff_flags diff_flags_cleared = DIFF_FLAGS_INIT;\n static long diff_algorithm;\n static unsigned ws_error_highlight_default = WSEH_NEW;\n \n@@ -5899,7 +5900,7 @@ int diff_can_quit_early(struct diff_options *opt)\n static int is_submodule_ignored(const char *path, struct diff_options *options)\n {\n \tint ignored = 0;\n-\tunsigned orig_flags = options->flags;\n+\tstruct diff_flags orig_flags = options->flags;\n \tif (!DIFF_OPT_TST(options, OVERRIDE_SUBMODULE_CONFIG))\n \t\tset_diffopt_flags_from_submodule_config(options, path);\n \tif (DIFF_OPT_TST(options, IGNORE_SUBMODULES))\ndiff --git a/diff.h b/diff.h\nindex aca150ba2..d58f06106 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -60,42 +60,59 @@ typedef struct strbuf *(*diff_prefix_fn_t)(struct diff_options *opt, void *data)\n \n #define DIFF_FORMAT_CALLBACK\t0x1000\n \n-#define DIFF_OPT_RECURSIVE           (1 <<  0)\n-#define DIFF_OPT_TREE_IN_RECURSIVE   (1 <<  1)\n-#define DIFF_OPT_BINARY              (1 <<  2)\n-#define DIFF_OPT_TEXT                (1 <<  3)\n-#define DIFF_OPT_FULL_INDEX          (1 <<  4)\n-#define DIFF_OPT_SILENT_ON_REMOVE    (1 <<  5)\n-#define DIFF_OPT_FIND_COPIES_HARDER  (1 <<  6)\n-#define DIFF_OPT_FOLLOW_RENAMES      (1 <<  7)\n-#define DIFF_OPT_RENAME_EMPTY        (1 <<  8)\n-/* (1 <<  9) unused */\n-#define DIFF_OPT_HAS_CHANGES         (1 << 10)\n-#define DIFF_OPT_QUICK               (1 << 11)\n-#define DIFF_OPT_NO_INDEX            (1 << 12)\n-#define DIFF_OPT_ALLOW_EXTERNAL      (1 << 13)\n-#define DIFF_OPT_EXIT_WITH_STATUS    (1 << 14)\n-#define DIFF_OPT_REVERSE_DIFF        (1 << 15)\n-#define DIFF_OPT_CHECK_FAILED        (1 << 16)\n-#define DIFF_OPT_RELATIVE_NAME       (1 << 17)\n-#define DIFF_OPT_IGNORE_SUBMODULES   (1 << 18)\n-#define DIFF_OPT_DIRSTAT_CUMULATIVE  (1 << 19)\n-#define DIFF_OPT_DIRSTAT_BY_FILE     (1 << 20)\n-#define DIFF_OPT_ALLOW_TEXTCONV      (1 << 21)\n-#define DIFF_OPT_DIFF_FROM_CONTENTS  (1 << 22)\n-#define DIFF_OPT_DIRTY_SUBMODULES    (1 << 24)\n-#define DIFF_OPT_IGNORE_UNTRACKED_IN_SUBMODULES (1 << 25)\n-#define DIFF_OPT_IGNORE_DIRTY_SUBMODULES (1 << 26)\n-#define DIFF_OPT_OVERRIDE_SUBMODULE_CONFIG (1 << 27)\n-#define DIFF_OPT_DIRSTAT_BY_LINE     (1 << 28)\n-#define DIFF_OPT_FUNCCONTEXT         (1 << 29)\n-#define DIFF_OPT_PICKAXE_IGNORE_CASE (1 << 30)\n-#define DIFF_OPT_DEFAULT_FOLLOW_RENAMES (1U << 31)\n-\n-#define DIFF_OPT_TST(opts, flag)    ((opts)->flags & DIFF_OPT_##flag)\n-#define DIFF_OPT_TOUCHED(opts, flag)    ((opts)->touched_flags & DIFF_OPT_##flag)\n-#define DIFF_OPT_SET(opts, flag)    (((opts)->flags |= DIFF_OPT_##flag),((opts)->touched_flags |= DIFF_OPT_##flag))\n-#define DIFF_OPT_CLR(opts, flag)    (((opts)->flags &= ~DIFF_OPT_##flag),((opts)->touched_flags |= DIFF_OPT_##flag))\n+#define DIFF_FLAGS_INIT { 0 }\n+extern const struct diff_flags diff_flags_cleared;\n+struct diff_flags {\n+\tunsigned RECURSIVE:1;\n+\tunsigned TREE_IN_RECURSIVE:1;\n+\tunsigned BINARY:1;\n+\tunsigned TEXT:1;\n+\tunsigned FULL_INDEX:1;\n+\tunsigned SILENT_ON_REMOVE:1;\n+\tunsigned FIND_COPIES_HARDER:1;\n+\tunsigned FOLLOW_RENAMES:1;\n+\tunsigned RENAME_EMPTY:1;\n+\tunsigned HAS_CHANGES:1;\n+\tunsigned QUICK:1;\n+\tunsigned NO_INDEX:1;\n+\tunsigned ALLOW_EXTERNAL:1;\n+\tunsigned EXIT_WITH_STATUS:1;\n+\tunsigned REVERSE_DIFF:1;\n+\tunsigned CHECK_FAILED:1;\n+\tunsigned RELATIVE_NAME:1;\n+\tunsigned IGNORE_SUBMODULES:1;\n+\tunsigned DIRSTAT_CUMULATIVE:1;\n+\tunsigned DIRSTAT_BY_FILE:1;\n+\tunsigned ALLOW_TEXTCONV:1;\n+\tunsigned DIFF_FROM_CONTENTS:1;\n+\tunsigned DIRTY_SUBMODULES:1;\n+\tunsigned IGNORE_UNTRACKED_IN_SUBMODULES:1;\n+\tunsigned IGNORE_DIRTY_SUBMODULES:1;\n+\tunsigned OVERRIDE_SUBMODULE_CONFIG:1;\n+\tunsigned DIRSTAT_BY_LINE:1;\n+\tunsigned FUNCCONTEXT:1;\n+\tunsigned PICKAXE_IGNORE_CASE:1;\n+\tunsigned DEFAULT_FOLLOW_RENAMES:1;\n+};\n+\n+static inline struct diff_flags diff_flags_or(struct diff_flags a,\n+\t\t\t\t\t      struct diff_flags b)\n+{\n+\tchar *tmp_a = (char *)&a;\n+\tchar *tmp_b = (char *)&b;\n+\tint i;\n+\n+\tfor (i = 0; i < sizeof(struct diff_flags); i++)\n+\t\ttmp_a[i] |= tmp_b[i];\n+\n+\treturn a;\n+}\n+\n+#define DIFF_OPT_TST(opts, flag)\t((opts)->flags.flag)\n+#define DIFF_OPT_TOUCHED(opts, flag)\t((opts)->touched_flags.flag)\n+#define DIFF_OPT_SET(opts, flag)\t(((opts)->flags.flag = 1),((opts)->touched_flags.flag = 1))\n+#define DIFF_OPT_CLR(opts, flag)\t(((opts)->flags.flag = 0),((opts)->touched_flags.flag = 1))\n+\n #define DIFF_XDL_TST(opts, flag)    ((opts)->xdl_opts & XDF_##flag)\n #define DIFF_XDL_SET(opts, flag)    ((opts)->xdl_opts |= XDF_##flag)\n #define DIFF_XDL_CLR(opts, flag)    ((opts)->xdl_opts &= ~XDF_##flag)\n@@ -122,8 +139,8 @@ struct diff_options {\n \tconst char *a_prefix, *b_prefix;\n \tconst char *line_prefix;\n \tsize_t line_prefix_length;\n-\tunsigned flags;\n-\tunsigned touched_flags;\n+\tstruct diff_flags flags;\n+\tstruct diff_flags touched_flags;\n \n \t/* diff-filter bits */\n \tunsigned int filter;\n@@ -388,7 +405,8 @@ extern int diff_result_code(struct diff_options *, int);\n \n extern void diff_no_index(struct rev_info *, int, const char **);\n \n-extern int index_differs_from(const char *def, int diff_flags, int ita_invisible_in_index);\n+extern int index_differs_from(const char *def, struct diff_flags flags,\n+\t\t\t      int ita_invisible_in_index);\n \n /*\n  * Fill the contents of the filespec \"df\", respecting any textconv defined by\ndiff --git a/sequencer.c b/sequencer.c\nindex f2a10cc4f..cf9bec716 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -959,7 +959,8 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,\n \t\tunborn = get_oid(\"HEAD\", &head);\n \t\tif (unborn)\n \t\t\toidcpy(&head, &empty_tree_oid);\n-\t\tif (index_differs_from(unborn ? EMPTY_TREE_SHA1_HEX : \"HEAD\", 0, 0))\n+\t\tif (index_differs_from(unborn ? EMPTY_TREE_SHA1_HEX : \"HEAD\",\n+\t\t\t\t       diff_flags_cleared, 0))\n \t\t\treturn error_dirty_index(opts);\n \t}\n \tdiscard_cache();\n@@ -2279,7 +2280,7 @@ int sequencer_continue(struct replay_opts *opts)\n \t\t\tif (res)\n \t\t\t\tgoto release_todo_list;\n \t\t}\n-\t\tif (index_differs_from(\"HEAD\", 0, 0)) {\n+\t\tif (index_differs_from(\"HEAD\", diff_flags_cleared, 0)) {\n \t\t\tres = error_dirty_index(opts);\n \t\t\tgoto release_todo_list;\n \t\t}\n-- \n2.15.0.rc2.357.g7e34df9404-goog\n\n"},{"id":"331251","messageId":"xmqq60aybvdp.fsf@gitster.mtv.corp.google.com","threadId":"47047","inReplyTo":"20171027222853.180981-1-bmwill@google.com","subject":"Re: [PATCH 0/3] convert diff flags to be stored in a struct","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-10-29T01:22:42Z","receivedAt":"2017-10-29T01:22:49Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Brandon Williams <bmwill@google.com> writes:\n\n> There has be some desire to add additional flags to the diff machineery\n> (https://public-inbox.org/git/20171024000931.14814-1-sbeller@google.com/) but\n> due to the limits of the number of bits in an unsigned int on some systems we\n> can't add any additonal flags to the 'flags' variable.  This series converts\n> the flags to be stored in bitfields in a struct instead of in bit positions in\n> an unsigned int.\n\nI haven't checked the patches yet, but its smallness look promising.\nOne reason why I didn't do this myself long time ago was because I\nsuspected that we may be passing an unsigned int that is a collection\nof flags as a parameter in many codepaths (to which I did not see a\ngood conversion once we start using discrete bitfields in a struct,\nwithout passing a \"flags\" struct instead, which felt somewhat ugly).\n\n> Some thoughts:\n>  * We may want to do a follow on patch to convert all the flags from being in\n>    uppercase to lower case.\n\nIf and only if we do not use macros to set/clr/test, this makes a\nlot of sense.  Otherwise, probably not.\n\n>  * Maybe we can figure out how to remove the 'touched_flags' things (since its\n>    only used in one place) and then we may even be able to stop needing to use\n>    macros to set/clr/test the flags.\n\nYup.  That is closely tied with the above one, but back then we\ndidn't think of a better implementation than the \"this was given\nfrom the command line\" vs \"this was initialized and kept\", so we\nneed some thought.\n\nThanks for starting this.\n\n> Brandon Williams (3):\n>   add: use DIFF_OPT_SET macro to set a diff flag\n>   reset: use DIFF_OPT_SET macro to set a diff flag\n>   diff: convert flags to be stored in bitfields\n>\n>  builtin/add.c    |  2 +-\n>  builtin/commit.c |  7 +++--\n>  builtin/log.c    |  2 +-\n>  builtin/reset.c  |  2 +-\n>  diff-lib.c       |  6 ++--\n>  diff.c           |  3 +-\n>  diff.h           | 96 +++++++++++++++++++++++++++++++++-----------------------\n>  sequencer.c      |  5 +--\n>  8 files changed, 72 insertions(+), 51 deletions(-)\n"},{"id":"331252","messageId":"xmqq1slmbv73.fsf@gitster.mtv.corp.google.com","threadId":"47047","inReplyTo":"20171027222853.180981-3-bmwill@google.com","subject":"Re: [PATCH 2/3] reset: use DIFF_OPT_SET macro to set a diff flag","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-10-29T01:26:40Z","receivedAt":"2017-10-29T01:26:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Brandon Williams <bmwill@google.com> writes:\n\n> Instead of explicitly setting the 'DIFF_OPT_OVERRIDE_SUBMODULE_CONFIG'\n> flag, use the 'DIFF_OPT_SET' macro.\n>\n> Signed-off-by: Brandon Williams <bmwill@google.com>\n> ---\n\nLooks good.  It's not like one of 1/3 and 2/3 could be a good idea\nwhile the other is not, so it would make a lot more sense to combine\nthem into a single preliminary clean-up patch, though.  \n\nIn any case, these two are very good clean-up patches, whose value\ndoes not diminish even we do not go ahead with 3/3 yet.  \n\nNicely spotted; thanks.\n\n\n>  builtin/reset.c | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git a/builtin/reset.c b/builtin/reset.c\n> index 9cd89b230..ea2fad5a0 100644\n> --- a/builtin/reset.c\n> +++ b/builtin/reset.c\n> @@ -166,7 +166,7 @@ static int read_from_tree(const struct pathspec *pathspec,\n>  \topt.output_format = DIFF_FORMAT_CALLBACK;\n>  \topt.format_callback = update_index_from_diff;\n>  \topt.format_callback_data = &intent_to_add;\n> -\topt.flags |= DIFF_OPT_OVERRIDE_SUBMODULE_CONFIG;\n> +\tDIFF_OPT_SET(&opt, OVERRIDE_SUBMODULE_CONFIG);\n>  \n>  \tif (do_diff_cache(tree_oid, &opt))\n>  \t\treturn 1;\n"},{"id":"331255","messageId":"xmqqk1zeafaq.fsf@gitster.mtv.corp.google.com","threadId":"47047","inReplyTo":"20171027222853.180981-4-bmwill@google.com","subject":"Re: [PATCH 3/3] diff: convert flags to be stored in bitfields","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-10-29T01:55:25Z","receivedAt":"2017-10-29T01:55:32Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Brandon Williams <bmwill@google.com> writes:\n\n> We have have reached the limit of the number of flags that can be stored\n\ns/have have/have/; but bit #9 is unused.  \n\n\"We cannot add many more flags even if we wanted to\" would be more\nflexible and does not take this change hostage to whatever topic\nthat tries to claim that bit, I would think.\n\n> in a single unsigned int.  In order to allow for more flags to be added\n> to the diff machinery in the future this patch converts the flags to be\n> stored in bitfields in 'struct diff_flags'.\n>\n> Signed-off-by: Brandon Williams <bmwill@google.com>\n> ---\n>  builtin/commit.c |  7 +++--\n>  builtin/log.c    |  2 +-\n>  diff-lib.c       |  6 ++--\n>  diff.c           |  3 +-\n>  diff.h           | 96 +++++++++++++++++++++++++++++++++-----------------------\n>  sequencer.c      |  5 +--\n>  6 files changed, 70 insertions(+), 49 deletions(-)\n>\n\n> diff --git a/diff.h b/diff.h\n> index aca150ba2..d58f06106 100644\n> --- a/diff.h\n> +++ b/diff.h\n> @@ -60,42 +60,59 @@ typedef struct strbuf *(*diff_prefix_fn_t)(struct diff_options *opt, void *data)\n>  \n>  #define DIFF_FORMAT_CALLBACK\t0x1000\n>  \n> -#define DIFF_OPT_RECURSIVE           (1 <<  0)\n> -#define DIFF_OPT_TREE_IN_RECURSIVE   (1 <<  1)\n> -#define DIFF_OPT_BINARY              (1 <<  2)\n> -...\n> -#define DIFF_OPT_FUNCCONTEXT         (1 << 29)\n> -#define DIFF_OPT_PICKAXE_IGNORE_CASE (1 << 30)\n> -#define DIFF_OPT_DEFAULT_FOLLOW_RENAMES (1U << 31)\n> -\n> -#define DIFF_OPT_TST(opts, flag)    ((opts)->flags & DIFF_OPT_##flag)\n> -#define DIFF_OPT_TOUCHED(opts, flag)    ((opts)->touched_flags & DIFF_OPT_##flag)\n> -#define DIFF_OPT_SET(opts, flag)    (((opts)->flags |= DIFF_OPT_##flag),((opts)->touched_flags |= DIFF_OPT_##flag))\n> -#define DIFF_OPT_CLR(opts, flag)    (((opts)->flags &= ~DIFF_OPT_##flag),((opts)->touched_flags |= DIFF_OPT_##flag))\n> +#define DIFF_FLAGS_INIT { 0 }\n> +extern const struct diff_flags diff_flags_cleared;\n\nThis thing is curious.  Seeing the scary diff_flags_or(), I would\nhave expected we'd have diff_flags_clear(&flags).\n\n> +struct diff_flags {\n> +\tunsigned RECURSIVE:1;\n> +\tunsigned TREE_IN_RECURSIVE:1;\n> +\tunsigned BINARY:1;\n> +...\n> +\tunsigned FUNCCONTEXT:1;\n> +\tunsigned PICKAXE_IGNORE_CASE:1;\n> +\tunsigned DEFAULT_FOLLOW_RENAMES:1;\n> +};\n> +\n> +static inline struct diff_flags diff_flags_or(struct diff_flags a,\n> +\t\t\t\t\t      struct diff_flags b)\n> +{\n> +\tchar *tmp_a = (char *)&a;\n> +\tchar *tmp_b = (char *)&b;\n> +\tint i;\n> +\n> +\tfor (i = 0; i < sizeof(struct diff_flags); i++)\n> +\t\ttmp_a[i] |= tmp_b[i];\n> +\n> +\treturn a;\n> +}\n\nThis is doubly scary, but let's see why we need it by looking at the\ncallers.\n\n> +#define DIFF_OPT_TST(opts, flag)\t((opts)->flags.flag)\n> +#define DIFF_OPT_TOUCHED(opts, flag)\t((opts)->touched_flags.flag)\n> +#define DIFF_OPT_SET(opts, flag)\t(((opts)->flags.flag = 1),((opts)->touched_flags.flag = 1))\n> +#define DIFF_OPT_CLR(opts, flag)\t(((opts)->flags.flag = 0),((opts)->touched_flags.flag = 1))\n\nThese are trivial and straight-forward.\n\n> +\n>  #define DIFF_XDL_TST(opts, flag)    ((opts)->xdl_opts & XDF_##flag)\n>  #define DIFF_XDL_SET(opts, flag)    ((opts)->xdl_opts |= XDF_##flag)\n>  #define DIFF_XDL_CLR(opts, flag)    ((opts)->xdl_opts &= ~XDF_##flag)\n> @@ -122,8 +139,8 @@ struct diff_options {\n>  \tconst char *a_prefix, *b_prefix;\n>  \tconst char *line_prefix;\n>  \tsize_t line_prefix_length;\n> -\tunsigned flags;\n> -\tunsigned touched_flags;\n> +\tstruct diff_flags flags;\n> +\tstruct diff_flags touched_flags;\n>  \n>  \t/* diff-filter bits */\n>  \tunsigned int filter;\n> @@ -388,7 +405,8 @@ extern int diff_result_code(struct diff_options *, int);\n>  \n>  extern void diff_no_index(struct rev_info *, int, const char **);\n>  \n> -extern int index_differs_from(const char *def, int diff_flags, int ita_invisible_in_index);\n> +extern int index_differs_from(const char *def, struct diff_flags flags,\n> +\t\t\t      int ita_invisible_in_index);\n\nOK.  I tend to think twice before passing any struct by value (even\nsomething that starts its life as a small/single-word struct), but\nlet's see how much simpler this allows callers to become.\n\n> diff --git a/builtin/commit.c b/builtin/commit.c\n> index d75b3805e..de08c2594 100644\n> --- a/builtin/commit.c\n> +++ b/builtin/commit.c\n> @@ -912,11 +912,12 @@ static int prepare_to_commit(const char *index_file, const char *prefix,\n>  \t\t\t * submodules which were manually staged, which would\n>  \t\t\t * be really confusing.\n>  \t\t\t */\n> -\t\t\tint diff_flags = DIFF_OPT_OVERRIDE_SUBMODULE_CONFIG;\n> +\t\t\tstruct diff_flags flags = DIFF_FLAGS_INIT;\n> +\t\t\tflags.OVERRIDE_SUBMODULE_CONFIG = 1;\n>  \t\t\tif (ignore_submodule_arg &&\n>  \t\t\t    !strcmp(ignore_submodule_arg, \"all\"))\n> -\t\t\t\tdiff_flags |= DIFF_OPT_IGNORE_SUBMODULES;\n\nThis couldn't have been done in patches 1+2/3 because DIFF_OPT_SET()\ndoes not take a bare 'flags' but diffopt itself, which was a bit\nunfortunate, but the end result after this step becomes a lot more\nsensible.\n\n> -\t\t\tcommitable = index_differs_from(parent, diff_flags, 1);\n> +\t\t\t\tflags.IGNORE_SUBMODULES = 1;\n> +\t\t\tcommitable = index_differs_from(parent, flags, 1);\n\nOK.\n\n> diff --git a/builtin/log.c b/builtin/log.c\n> index d81a09051..780975ed4 100644\n> --- a/builtin/log.c\n> +++ b/builtin/log.c\n> @@ -134,7 +134,7 @@ static void cmd_log_init_defaults(struct rev_info *rev)\n>  \n>  \tif (default_date_mode)\n>  \t\tparse_date_format(default_date_mode, &rev->date_mode);\n> -\trev->diffopt.touched_flags = 0;\n> +\trev->diffopt.touched_flags = diff_flags_cleared;\n\nSo this structure assignment is a more kosher way to clear\neverything than memset(&touched_flags, '\\0', sizeof(...));\nI'd still prefer\n\n\tdiff_flags_clear(&rev->diffopt.touched_flags);\n\ntough, as it is easy to forget diff_flags_cleared is a singleton\nconstant specifically created to be assigned for clearing another\nflags struct.\n\n> @@ -546,7 +546,7 @@ int index_differs_from(const char *def, int diff_flags,\n>  \tsetup_revisions(0, NULL, &rev, &opt);\n>  \tDIFF_OPT_SET(&rev.diffopt, QUICK);\n>  \tDIFF_OPT_SET(&rev.diffopt, EXIT_WITH_STATUS);\n> -\trev.diffopt.flags |= diff_flags;\n> +\trev.diffopt.flags = diff_flags_or(rev.diffopt.flags, flags);\n\nIn a more general case, we cannot know what flags setup_revisions()\ngave to rev.diffopt, and because of that we cannot do\n\n\trev.diffopt.flags = diff_flags;\n\tDIFF_OPT_SET(&rev.diffopt, QUICK);\n\tDIFF_OPT_SET(&rev.diffopt, EXIT_WITH_STATUS);\n\nwithout using the flags_or() thing.  In this codepath, that\ncurrently is not a problem (because we give ac/av = 0/NULL), but it\nprobably is a good idea to avoid depending on that.\n\nI still haven't brought myself to like the structure being passed by\nvalue and the singleton diff_flags_cleared thing, but I suspect that\nwe may get used to them once we start using these.  I dunno.\n\nThanks.\n"},{"id":"331263","messageId":"CAGZ79kb+NLT8fGc-QJEtzgt3V8rj4=ciROoYJVFtMOyG+0OLwQ@mail.gmail.com","threadId":"47047","inReplyTo":"xmqq60aybvdp.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH 0/3] convert diff flags to be stored in a struct","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-10-29T04:37:17Z","receivedAt":"2017-10-29T04:37:23Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Sat, Oct 28, 2017 at 6:22 PM, Junio C Hamano <gitster@pobox.com> wrote:\n\n>> Some thoughts:\n>>  * We may want to do a follow on patch to convert all the flags from being in\n>>    uppercase to lower case.\n>\n> If and only if we do not use macros to set/clr/test, this makes a\n> lot of sense.  Otherwise, probably not.\n\nThe .touched_flags is used just once in the code base for just one flag.\nI wonder if we could get rid of touched_flags and instead introduce a new\nflag (FORCE_TEXT_CONV instead of ALLOW_TEXT_CONV set by cmd_show\nspecifically) that will enable the special casing that is currently done via the\ntouched_flags.\n\nOnce we get rid of the special casing, we can get rid of the macros.\n"},{"id":"331299","messageId":"xmqqzi898olb.fsf@gitster.mtv.corp.google.com","threadId":"47047","inReplyTo":"xmqqk1zeafaq.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH 3/3] diff: convert flags to be stored in bitfields","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-10-30T00:29:52Z","receivedAt":"2017-10-30T00:30:02Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> I still haven't brought myself to like the structure being passed by\n> value and the singleton diff_flags_cleared thing, but I suspect that\n> we may get used to them once we start using these.  I dunno.\n\nJust bikeshedding, but I just had to prepare an evil merge to add a\nnew use of diff_flags_cleared to a codepath that evolved in a topic\nstill in flight, and realized that I really hate the name.  Perhaps\nI wouldn't have hated it so much if it were named diff_flags_none or\ndiff_flags_empty, I guess.\n"},{"id":"331396","messageId":"20171030174952.GA125460@google.com","threadId":"47047","inReplyTo":"xmqqk1zeafaq.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH 3/3] diff: convert flags to be stored in bitfields","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-10-30T17:49:52Z","receivedAt":"2017-10-30T17:50:04Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"On 10/29, Junio C Hamano wrote:\n> Brandon Williams <bmwill@google.com> writes:\n> \n> > We have have reached the limit of the number of flags that can be stored\n> \n> s/have have/have/; but bit #9 is unused.  \n> \n> \"We cannot add many more flags even if we wanted to\" would be more\n> flexible and does not take this change hostage to whatever topic\n> that tries to claim that bit, I would think.\n\nI'll tweak the wording a bit.\n\n> \n> > in a single unsigned int.  In order to allow for more flags to be added\n> > to the diff machinery in the future this patch converts the flags to be\n> > stored in bitfields in 'struct diff_flags'.\n> >\n> > Signed-off-by: Brandon Williams <bmwill@google.com>\n> > ---\n> >  builtin/commit.c |  7 +++--\n> >  builtin/log.c    |  2 +-\n> >  diff-lib.c       |  6 ++--\n> >  diff.c           |  3 +-\n> >  diff.h           | 96 +++++++++++++++++++++++++++++++++-----------------------\n> >  sequencer.c      |  5 +--\n> >  6 files changed, 70 insertions(+), 49 deletions(-)\n> >\n> \n> > diff --git a/diff.h b/diff.h\n> > index aca150ba2..d58f06106 100644\n> > --- a/diff.h\n> > +++ b/diff.h\n> > @@ -60,42 +60,59 @@ typedef struct strbuf *(*diff_prefix_fn_t)(struct diff_options *opt, void *data)\n> >  \n> >  #define DIFF_FORMAT_CALLBACK\t0x1000\n> >  \n> > -#define DIFF_OPT_RECURSIVE           (1 <<  0)\n> > -#define DIFF_OPT_TREE_IN_RECURSIVE   (1 <<  1)\n> > -#define DIFF_OPT_BINARY              (1 <<  2)\n> > -...\n> > -#define DIFF_OPT_FUNCCONTEXT         (1 << 29)\n> > -#define DIFF_OPT_PICKAXE_IGNORE_CASE (1 << 30)\n> > -#define DIFF_OPT_DEFAULT_FOLLOW_RENAMES (1U << 31)\n> > -\n> > -#define DIFF_OPT_TST(opts, flag)    ((opts)->flags & DIFF_OPT_##flag)\n> > -#define DIFF_OPT_TOUCHED(opts, flag)    ((opts)->touched_flags & DIFF_OPT_##flag)\n> > -#define DIFF_OPT_SET(opts, flag)    (((opts)->flags |= DIFF_OPT_##flag),((opts)->touched_flags |= DIFF_OPT_##flag))\n> > -#define DIFF_OPT_CLR(opts, flag)    (((opts)->flags &= ~DIFF_OPT_##flag),((opts)->touched_flags |= DIFF_OPT_##flag))\n> > +#define DIFF_FLAGS_INIT { 0 }\n> > +extern const struct diff_flags diff_flags_cleared;\n> \n> This thing is curious.  Seeing the scary diff_flags_or(), I would\n> have expected we'd have diff_flags_clear(&flags).\n\nThis seemed to make things easier in practice because I was passing some\nstructs by value, let me work with it a bit to see what it looks like\nwhen they are passed by reference instead.\n\n> \n> > +struct diff_flags {\n> > +\tunsigned RECURSIVE:1;\n> > +\tunsigned TREE_IN_RECURSIVE:1;\n> > +\tunsigned BINARY:1;\n> > +...\n> > +\tunsigned FUNCCONTEXT:1;\n> > +\tunsigned PICKAXE_IGNORE_CASE:1;\n> > +\tunsigned DEFAULT_FOLLOW_RENAMES:1;\n> > +};\n> > +\n> > +static inline struct diff_flags diff_flags_or(struct diff_flags a,\n> > +\t\t\t\t\t      struct diff_flags b)\n> > +{\n> > +\tchar *tmp_a = (char *)&a;\n> > +\tchar *tmp_b = (char *)&b;\n> > +\tint i;\n> > +\n> > +\tfor (i = 0; i < sizeof(struct diff_flags); i++)\n> > +\t\ttmp_a[i] |= tmp_b[i];\n> > +\n> > +\treturn a;\n> > +}\n> \n> This is doubly scary, but let's see why we need it by looking at the\n> callers.\n> \n> > +#define DIFF_OPT_TST(opts, flag)\t((opts)->flags.flag)\n> > +#define DIFF_OPT_TOUCHED(opts, flag)\t((opts)->touched_flags.flag)\n> > +#define DIFF_OPT_SET(opts, flag)\t(((opts)->flags.flag = 1),((opts)->touched_flags.flag = 1))\n> > +#define DIFF_OPT_CLR(opts, flag)\t(((opts)->flags.flag = 0),((opts)->touched_flags.flag = 1))\n> \n> These are trivial and straight-forward.\n> \n> > +\n> >  #define DIFF_XDL_TST(opts, flag)    ((opts)->xdl_opts & XDF_##flag)\n> >  #define DIFF_XDL_SET(opts, flag)    ((opts)->xdl_opts |= XDF_##flag)\n> >  #define DIFF_XDL_CLR(opts, flag)    ((opts)->xdl_opts &= ~XDF_##flag)\n> > @@ -122,8 +139,8 @@ struct diff_options {\n> >  \tconst char *a_prefix, *b_prefix;\n> >  \tconst char *line_prefix;\n> >  \tsize_t line_prefix_length;\n> > -\tunsigned flags;\n> > -\tunsigned touched_flags;\n> > +\tstruct diff_flags flags;\n> > +\tstruct diff_flags touched_flags;\n> >  \n> >  \t/* diff-filter bits */\n> >  \tunsigned int filter;\n> > @@ -388,7 +405,8 @@ extern int diff_result_code(struct diff_options *, int);\n> >  \n> >  extern void diff_no_index(struct rev_info *, int, const char **);\n> >  \n> > -extern int index_differs_from(const char *def, int diff_flags, int ita_invisible_in_index);\n> > +extern int index_differs_from(const char *def, struct diff_flags flags,\n> > +\t\t\t      int ita_invisible_in_index);\n> \n> OK.  I tend to think twice before passing any struct by value (even\n> something that starts its life as a small/single-word struct), but\n> let's see how much simpler this allows callers to become.\n> \n> > diff --git a/builtin/commit.c b/builtin/commit.c\n> > index d75b3805e..de08c2594 100644\n> > --- a/builtin/commit.c\n> > +++ b/builtin/commit.c\n> > @@ -912,11 +912,12 @@ static int prepare_to_commit(const char *index_file, const char *prefix,\n> >  \t\t\t * submodules which were manually staged, which would\n> >  \t\t\t * be really confusing.\n> >  \t\t\t */\n> > -\t\t\tint diff_flags = DIFF_OPT_OVERRIDE_SUBMODULE_CONFIG;\n> > +\t\t\tstruct diff_flags flags = DIFF_FLAGS_INIT;\n> > +\t\t\tflags.OVERRIDE_SUBMODULE_CONFIG = 1;\n> >  \t\t\tif (ignore_submodule_arg &&\n> >  \t\t\t    !strcmp(ignore_submodule_arg, \"all\"))\n> > -\t\t\t\tdiff_flags |= DIFF_OPT_IGNORE_SUBMODULES;\n> \n> This couldn't have been done in patches 1+2/3 because DIFF_OPT_SET()\n> does not take a bare 'flags' but diffopt itself, which was a bit\n> unfortunate, but the end result after this step becomes a lot more\n> sensible.\n> \n> > -\t\t\tcommitable = index_differs_from(parent, diff_flags, 1);\n> > +\t\t\t\tflags.IGNORE_SUBMODULES = 1;\n> > +\t\t\tcommitable = index_differs_from(parent, flags, 1);\n> \n> OK.\n> \n> > diff --git a/builtin/log.c b/builtin/log.c\n> > index d81a09051..780975ed4 100644\n> > --- a/builtin/log.c\n> > +++ b/builtin/log.c\n> > @@ -134,7 +134,7 @@ static void cmd_log_init_defaults(struct rev_info *rev)\n> >  \n> >  \tif (default_date_mode)\n> >  \t\tparse_date_format(default_date_mode, &rev->date_mode);\n> > -\trev->diffopt.touched_flags = 0;\n> > +\trev->diffopt.touched_flags = diff_flags_cleared;\n> \n> So this structure assignment is a more kosher way to clear\n> everything than memset(&touched_flags, '\\0', sizeof(...));\n> I'd still prefer\n> \n> \tdiff_flags_clear(&rev->diffopt.touched_flags);\n> \n> tough, as it is easy to forget diff_flags_cleared is a singleton\n> constant specifically created to be assigned for clearing another\n> flags struct.\n> \n> > @@ -546,7 +546,7 @@ int index_differs_from(const char *def, int diff_flags,\n> >  \tsetup_revisions(0, NULL, &rev, &opt);\n> >  \tDIFF_OPT_SET(&rev.diffopt, QUICK);\n> >  \tDIFF_OPT_SET(&rev.diffopt, EXIT_WITH_STATUS);\n> > -\trev.diffopt.flags |= diff_flags;\n> > +\trev.diffopt.flags = diff_flags_or(rev.diffopt.flags, flags);\n> \n> In a more general case, we cannot know what flags setup_revisions()\n> gave to rev.diffopt, and because of that we cannot do\n> \n> \trev.diffopt.flags = diff_flags;\n> \tDIFF_OPT_SET(&rev.diffopt, QUICK);\n> \tDIFF_OPT_SET(&rev.diffopt, EXIT_WITH_STATUS);\n> \n> without using the flags_or() thing.  In this codepath, that\n> currently is not a problem (because we give ac/av = 0/NULL), but it\n> probably is a good idea to avoid depending on that.\n> \n> I still haven't brought myself to like the structure being passed by\n> value and the singleton diff_flags_cleared thing, but I suspect that\n> we may get used to them once we start using these.  I dunno.\n> \n> Thanks.\n\n-- \nBrandon Williams\n"},{"id":"331399","messageId":"20171030180618.GB125460@google.com","threadId":"47047","inReplyTo":"xmqq1slmbv73.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH 2/3] reset: use DIFF_OPT_SET macro to set a diff flag","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-10-30T18:06:18Z","receivedAt":"2017-10-30T18:06:26Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"On 10/29, Junio C Hamano wrote:\n> Brandon Williams <bmwill@google.com> writes:\n> \n> > Instead of explicitly setting the 'DIFF_OPT_OVERRIDE_SUBMODULE_CONFIG'\n> > flag, use the 'DIFF_OPT_SET' macro.\n> >\n> > Signed-off-by: Brandon Williams <bmwill@google.com>\n> > ---\n> \n> Looks good.  It's not like one of 1/3 and 2/3 could be a good idea\n> while the other is not, so it would make a lot more sense to combine\n> them into a single preliminary clean-up patch, though.  \n> \n\nI'll squash them together in v2.\n\n> In any case, these two are very good clean-up patches, whose value\n> does not diminish even we do not go ahead with 3/3 yet.  \n> \n> Nicely spotted; thanks.\n> \n> \n> >  builtin/reset.c | 2 +-\n> >  1 file changed, 1 insertion(+), 1 deletion(-)\n> >\n> > diff --git a/builtin/reset.c b/builtin/reset.c\n> > index 9cd89b230..ea2fad5a0 100644\n> > --- a/builtin/reset.c\n> > +++ b/builtin/reset.c\n> > @@ -166,7 +166,7 @@ static int read_from_tree(const struct pathspec *pathspec,\n> >  \topt.output_format = DIFF_FORMAT_CALLBACK;\n> >  \topt.format_callback = update_index_from_diff;\n> >  \topt.format_callback_data = &intent_to_add;\n> > -\topt.flags |= DIFF_OPT_OVERRIDE_SUBMODULE_CONFIG;\n> > +\tDIFF_OPT_SET(&opt, OVERRIDE_SUBMODULE_CONFIG);\n> >  \n> >  \tif (do_diff_cache(tree_oid, &opt))\n> >  \t\treturn 1;\n\n-- \nBrandon Williams\n"},{"id":"331405","messageId":"20171030193924.GC125460@google.com","threadId":"47047","inReplyTo":"xmqqzi898olb.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH 3/3] diff: convert flags to be stored in bitfields","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-10-30T19:39:24Z","receivedAt":"2017-10-30T19:39:33Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"On 10/30, Junio C Hamano wrote:\n> Junio C Hamano <gitster@pobox.com> writes:\n> \n> > I still haven't brought myself to like the structure being passed by\n> > value and the singleton diff_flags_cleared thing, but I suspect that\n> > we may get used to them once we start using these.  I dunno.\n> \n> Just bikeshedding, but I just had to prepare an evil merge to add a\n> new use of diff_flags_cleared to a codepath that evolved in a topic\n> still in flight, and realized that I really hate the name.  Perhaps\n> I wouldn't have hated it so much if it were named diff_flags_none or\n> diff_flags_empty, I guess.\n\nI have a new version of the series I'll send out and i ended up dropping\nit entirely.  Didn't even need a clear function because I was able to\ndrop the touched stuff and it would have only been used inside of\nbuiltin/log.c to clear the touched flags.\n\n-- \nBrandon Williams\n"},{"id":"331406","messageId":"20171030194646.27473-1-bmwill@google.com","threadId":"47047","inReplyTo":"20171027222853.180981-1-bmwill@google.com","subject":"[PATCH v2 0/4] convert diff flags to be stored in a struct","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-10-30T19:46:42Z","receivedAt":"2017-10-30T19:46:58Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"Changes in v2:\n * removed the diff_flags_cleared singleton \n * eliminated the 'touched' parallel flags\n * pass structs by reference instead of by value\n\nNow that the 'touched' flags have been removed it may be valuable to go ahead\nand remove the macros all together (including making the flags lower case).  If\nthat's what we want to do, I can go ahead and send those patches out as a\nfollow on to these.\n\nBrandon Williams (4):\n  add, reset: use DIFF_OPT_SET macro to set a diff flag\n  diff: convert flags to be stored in bitfields\n  diff: add flag to indicate textconv was set via cmdline\n  diff: remove touched flags\n\n builtin/add.c    |  2 +-\n builtin/commit.c |  7 +++--\n builtin/log.c    |  3 +-\n builtin/reset.c  |  2 +-\n diff-lib.c       |  7 +++--\n diff.c           | 10 +++---\n diff.h           | 96 +++++++++++++++++++++++++++++++++-----------------------\n sequencer.c      |  5 +--\n 8 files changed, 77 insertions(+), 55 deletions(-)\n\n-- \n2.15.0.403.gc27cc4dac6-goog\n\n"},{"id":"331407","messageId":"20171030194646.27473-2-bmwill@google.com","threadId":"47047","inReplyTo":"20171030194646.27473-1-bmwill@google.com","subject":"[PATCH v2 1/4] add, reset: use DIFF_OPT_SET macro to set a diff flag","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-10-30T19:46:43Z","receivedAt":"2017-10-30T19:46:59Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"Instead of explicitly setting the 'DIFF_OPT_OVERRIDE_SUBMODULE_CONFIG'\nflag, use the 'DIFF_OPT_SET' macro.\n\nSigned-off-by: Brandon Williams <bmwill@google.com>\n---\n builtin/add.c   | 2 +-\n builtin/reset.c | 2 +-\n 2 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/add.c b/builtin/add.c\nindex a648cf4c5..b70e8a779 100644\n--- a/builtin/add.c\n+++ b/builtin/add.c\n@@ -116,7 +116,7 @@ int add_files_to_cache(const char *prefix,\n \trev.diffopt.output_format = DIFF_FORMAT_CALLBACK;\n \trev.diffopt.format_callback = update_callback;\n \trev.diffopt.format_callback_data = &data;\n-\trev.diffopt.flags |= DIFF_OPT_OVERRIDE_SUBMODULE_CONFIG;\n+\tDIFF_OPT_SET(&rev.diffopt, OVERRIDE_SUBMODULE_CONFIG);\n \trev.max_count = 0; /* do not compare unmerged paths with stage #2 */\n \trun_diff_files(&rev, DIFF_RACY_IS_MODIFIED);\n \tclear_pathspec(&rev.prune_data);\ndiff --git a/builtin/reset.c b/builtin/reset.c\nindex 9cd89b230..ea2fad5a0 100644\n--- a/builtin/reset.c\n+++ b/builtin/reset.c\n@@ -166,7 +166,7 @@ static int read_from_tree(const struct pathspec *pathspec,\n \topt.output_format = DIFF_FORMAT_CALLBACK;\n \topt.format_callback = update_index_from_diff;\n \topt.format_callback_data = &intent_to_add;\n-\topt.flags |= DIFF_OPT_OVERRIDE_SUBMODULE_CONFIG;\n+\tDIFF_OPT_SET(&opt, OVERRIDE_SUBMODULE_CONFIG);\n \n \tif (do_diff_cache(tree_oid, &opt))\n \t\treturn 1;\n-- \n2.15.0.403.gc27cc4dac6-goog\n\n"},{"id":"331408","messageId":"20171030194646.27473-3-bmwill@google.com","threadId":"47047","inReplyTo":"20171030194646.27473-1-bmwill@google.com","subject":"[PATCH v2 2/4] diff: convert flags to be stored in bitfields","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-10-30T19:46:44Z","receivedAt":"2017-10-30T19:47:04Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"We cannot add many more flags to the diff machinery due to the\nlimitations of the number of flags that can be stored in a single\nunsigned int.  In order to allow for more flags to be added to the diff\nmachinery in the future this patch converts the flags to be stored in\nbitfields in 'struct diff_flags'.\n\nSigned-off-by: Brandon Williams <bmwill@google.com>\n---\n builtin/commit.c |  7 ++--\n builtin/log.c    |  3 +-\n diff-lib.c       |  7 ++--\n diff.c           |  2 +-\n diff.h           | 97 +++++++++++++++++++++++++++++++++-----------------------\n sequencer.c      |  5 +--\n 6 files changed, 72 insertions(+), 49 deletions(-)\n\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex d75b3805e..960e7ac08 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -912,11 +912,12 @@ static int prepare_to_commit(const char *index_file, const char *prefix,\n \t\t\t * submodules which were manually staged, which would\n \t\t\t * be really confusing.\n \t\t\t */\n-\t\t\tint diff_flags = DIFF_OPT_OVERRIDE_SUBMODULE_CONFIG;\n+\t\t\tstruct diff_flags flags = DIFF_FLAGS_INIT;\n+\t\t\tflags.OVERRIDE_SUBMODULE_CONFIG = 1;\n \t\t\tif (ignore_submodule_arg &&\n \t\t\t    !strcmp(ignore_submodule_arg, \"all\"))\n-\t\t\t\tdiff_flags |= DIFF_OPT_IGNORE_SUBMODULES;\n-\t\t\tcommitable = index_differs_from(parent, diff_flags, 1);\n+\t\t\t\tflags.IGNORE_SUBMODULES = 1;\n+\t\t\tcommitable = index_differs_from(parent, &flags, 1);\n \t\t}\n \t}\n \tstrbuf_release(&committer_ident);\ndiff --git a/builtin/log.c b/builtin/log.c\nindex d81a09051..dc28d43eb 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -134,7 +134,8 @@ static void cmd_log_init_defaults(struct rev_info *rev)\n \n \tif (default_date_mode)\n \t\tparse_date_format(default_date_mode, &rev->date_mode);\n-\trev->diffopt.touched_flags = 0;\n+\n+\tmemset(&rev->diffopt.touched_flags, 0, sizeof(struct diff_flags));\n }\n \n static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,\ndiff --git a/diff-lib.c b/diff-lib.c\nindex 4e0980caa..6c1c05c5b 100644\n--- a/diff-lib.c\n+++ b/diff-lib.c\n@@ -71,7 +71,7 @@ static int match_stat_with_submodule(struct diff_options *diffopt,\n {\n \tint changed = ce_match_stat(ce, st, ce_option);\n \tif (S_ISGITLINK(ce->ce_mode)) {\n-\t\tunsigned orig_flags = diffopt->flags;\n+\t\tstruct diff_flags orig_flags = diffopt->flags;\n \t\tif (!DIFF_OPT_TST(diffopt, OVERRIDE_SUBMODULE_CONFIG))\n \t\t\tset_diffopt_flags_from_submodule_config(diffopt, ce->name);\n \t\tif (DIFF_OPT_TST(diffopt, IGNORE_SUBMODULES))\n@@ -534,7 +534,7 @@ int do_diff_cache(const struct object_id *tree_oid, struct diff_options *opt)\n \treturn 0;\n }\n \n-int index_differs_from(const char *def, int diff_flags,\n+int index_differs_from(const char *def, const struct diff_flags *flags,\n \t\t       int ita_invisible_in_index)\n {\n \tstruct rev_info rev;\n@@ -546,7 +546,8 @@ int index_differs_from(const char *def, int diff_flags,\n \tsetup_revisions(0, NULL, &rev, &opt);\n \tDIFF_OPT_SET(&rev.diffopt, QUICK);\n \tDIFF_OPT_SET(&rev.diffopt, EXIT_WITH_STATUS);\n-\trev.diffopt.flags |= diff_flags;\n+\tif (flags)\n+\t\trev.diffopt.flags = diff_flags_or(&rev.diffopt.flags, flags);\n \trev.diffopt.ita_invisible_in_index = ita_invisible_in_index;\n \trun_diff_index(&rev, 1);\n \tobject_array_clear(&rev.pending);\ndiff --git a/diff.c b/diff.c\nindex 6fd288420..3ad9c9b31 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -5899,7 +5899,7 @@ int diff_can_quit_early(struct diff_options *opt)\n static int is_submodule_ignored(const char *path, struct diff_options *options)\n {\n \tint ignored = 0;\n-\tunsigned orig_flags = options->flags;\n+\tstruct diff_flags orig_flags = options->flags;\n \tif (!DIFF_OPT_TST(options, OVERRIDE_SUBMODULE_CONFIG))\n \t\tset_diffopt_flags_from_submodule_config(options, path);\n \tif (DIFF_OPT_TST(options, IGNORE_SUBMODULES))\ndiff --git a/diff.h b/diff.h\nindex aca150ba2..47e6d43cb 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -60,42 +60,60 @@ typedef struct strbuf *(*diff_prefix_fn_t)(struct diff_options *opt, void *data)\n \n #define DIFF_FORMAT_CALLBACK\t0x1000\n \n-#define DIFF_OPT_RECURSIVE           (1 <<  0)\n-#define DIFF_OPT_TREE_IN_RECURSIVE   (1 <<  1)\n-#define DIFF_OPT_BINARY              (1 <<  2)\n-#define DIFF_OPT_TEXT                (1 <<  3)\n-#define DIFF_OPT_FULL_INDEX          (1 <<  4)\n-#define DIFF_OPT_SILENT_ON_REMOVE    (1 <<  5)\n-#define DIFF_OPT_FIND_COPIES_HARDER  (1 <<  6)\n-#define DIFF_OPT_FOLLOW_RENAMES      (1 <<  7)\n-#define DIFF_OPT_RENAME_EMPTY        (1 <<  8)\n-/* (1 <<  9) unused */\n-#define DIFF_OPT_HAS_CHANGES         (1 << 10)\n-#define DIFF_OPT_QUICK               (1 << 11)\n-#define DIFF_OPT_NO_INDEX            (1 << 12)\n-#define DIFF_OPT_ALLOW_EXTERNAL      (1 << 13)\n-#define DIFF_OPT_EXIT_WITH_STATUS    (1 << 14)\n-#define DIFF_OPT_REVERSE_DIFF        (1 << 15)\n-#define DIFF_OPT_CHECK_FAILED        (1 << 16)\n-#define DIFF_OPT_RELATIVE_NAME       (1 << 17)\n-#define DIFF_OPT_IGNORE_SUBMODULES   (1 << 18)\n-#define DIFF_OPT_DIRSTAT_CUMULATIVE  (1 << 19)\n-#define DIFF_OPT_DIRSTAT_BY_FILE     (1 << 20)\n-#define DIFF_OPT_ALLOW_TEXTCONV      (1 << 21)\n-#define DIFF_OPT_DIFF_FROM_CONTENTS  (1 << 22)\n-#define DIFF_OPT_DIRTY_SUBMODULES    (1 << 24)\n-#define DIFF_OPT_IGNORE_UNTRACKED_IN_SUBMODULES (1 << 25)\n-#define DIFF_OPT_IGNORE_DIRTY_SUBMODULES (1 << 26)\n-#define DIFF_OPT_OVERRIDE_SUBMODULE_CONFIG (1 << 27)\n-#define DIFF_OPT_DIRSTAT_BY_LINE     (1 << 28)\n-#define DIFF_OPT_FUNCCONTEXT         (1 << 29)\n-#define DIFF_OPT_PICKAXE_IGNORE_CASE (1 << 30)\n-#define DIFF_OPT_DEFAULT_FOLLOW_RENAMES (1U << 31)\n-\n-#define DIFF_OPT_TST(opts, flag)    ((opts)->flags & DIFF_OPT_##flag)\n-#define DIFF_OPT_TOUCHED(opts, flag)    ((opts)->touched_flags & DIFF_OPT_##flag)\n-#define DIFF_OPT_SET(opts, flag)    (((opts)->flags |= DIFF_OPT_##flag),((opts)->touched_flags |= DIFF_OPT_##flag))\n-#define DIFF_OPT_CLR(opts, flag)    (((opts)->flags &= ~DIFF_OPT_##flag),((opts)->touched_flags |= DIFF_OPT_##flag))\n+#define DIFF_FLAGS_INIT { 0 }\n+struct diff_flags {\n+\tunsigned RECURSIVE:1;\n+\tunsigned TREE_IN_RECURSIVE:1;\n+\tunsigned BINARY:1;\n+\tunsigned TEXT:1;\n+\tunsigned FULL_INDEX:1;\n+\tunsigned SILENT_ON_REMOVE:1;\n+\tunsigned FIND_COPIES_HARDER:1;\n+\tunsigned FOLLOW_RENAMES:1;\n+\tunsigned RENAME_EMPTY:1;\n+\tunsigned HAS_CHANGES:1;\n+\tunsigned QUICK:1;\n+\tunsigned NO_INDEX:1;\n+\tunsigned ALLOW_EXTERNAL:1;\n+\tunsigned EXIT_WITH_STATUS:1;\n+\tunsigned REVERSE_DIFF:1;\n+\tunsigned CHECK_FAILED:1;\n+\tunsigned RELATIVE_NAME:1;\n+\tunsigned IGNORE_SUBMODULES:1;\n+\tunsigned DIRSTAT_CUMULATIVE:1;\n+\tunsigned DIRSTAT_BY_FILE:1;\n+\tunsigned ALLOW_TEXTCONV:1;\n+\tunsigned DIFF_FROM_CONTENTS:1;\n+\tunsigned DIRTY_SUBMODULES:1;\n+\tunsigned IGNORE_UNTRACKED_IN_SUBMODULES:1;\n+\tunsigned IGNORE_DIRTY_SUBMODULES:1;\n+\tunsigned OVERRIDE_SUBMODULE_CONFIG:1;\n+\tunsigned DIRSTAT_BY_LINE:1;\n+\tunsigned FUNCCONTEXT:1;\n+\tunsigned PICKAXE_IGNORE_CASE:1;\n+\tunsigned DEFAULT_FOLLOW_RENAMES:1;\n+};\n+\n+static inline struct diff_flags diff_flags_or(const struct diff_flags *a,\n+\t\t\t\t\t      const struct diff_flags *b)\n+{\n+\tstruct diff_flags out;\n+\tchar *tmp_a = (char *)a;\n+\tchar *tmp_b = (char *)b;\n+\tchar *tmp_out = (char *)&out;\n+\tint i;\n+\n+\tfor (i = 0; i < sizeof(struct diff_flags); i++)\n+\t\ttmp_out[i] = tmp_a[i] | tmp_b[i];\n+\n+\treturn out;\n+}\n+\n+#define DIFF_OPT_TST(opts, flag)\t((opts)->flags.flag)\n+#define DIFF_OPT_TOUCHED(opts, flag)\t((opts)->touched_flags.flag)\n+#define DIFF_OPT_SET(opts, flag)\t(((opts)->flags.flag = 1),((opts)->touched_flags.flag = 1))\n+#define DIFF_OPT_CLR(opts, flag)\t(((opts)->flags.flag = 0),((opts)->touched_flags.flag = 1))\n+\n #define DIFF_XDL_TST(opts, flag)    ((opts)->xdl_opts & XDF_##flag)\n #define DIFF_XDL_SET(opts, flag)    ((opts)->xdl_opts |= XDF_##flag)\n #define DIFF_XDL_CLR(opts, flag)    ((opts)->xdl_opts &= ~XDF_##flag)\n@@ -122,8 +140,8 @@ struct diff_options {\n \tconst char *a_prefix, *b_prefix;\n \tconst char *line_prefix;\n \tsize_t line_prefix_length;\n-\tunsigned flags;\n-\tunsigned touched_flags;\n+\tstruct diff_flags flags;\n+\tstruct diff_flags touched_flags;\n \n \t/* diff-filter bits */\n \tunsigned int filter;\n@@ -388,7 +406,8 @@ extern int diff_result_code(struct diff_options *, int);\n \n extern void diff_no_index(struct rev_info *, int, const char **);\n \n-extern int index_differs_from(const char *def, int diff_flags, int ita_invisible_in_index);\n+extern int index_differs_from(const char *def, const struct diff_flags *flags,\n+\t\t\t      int ita_invisible_in_index);\n \n /*\n  * Fill the contents of the filespec \"df\", respecting any textconv defined by\ndiff --git a/sequencer.c b/sequencer.c\nindex f2a10cc4f..c0410e491 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -959,7 +959,8 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,\n \t\tunborn = get_oid(\"HEAD\", &head);\n \t\tif (unborn)\n \t\t\toidcpy(&head, &empty_tree_oid);\n-\t\tif (index_differs_from(unborn ? EMPTY_TREE_SHA1_HEX : \"HEAD\", 0, 0))\n+\t\tif (index_differs_from(unborn ? EMPTY_TREE_SHA1_HEX : \"HEAD\",\n+\t\t\t\t       NULL, 0))\n \t\t\treturn error_dirty_index(opts);\n \t}\n \tdiscard_cache();\n@@ -2279,7 +2280,7 @@ int sequencer_continue(struct replay_opts *opts)\n \t\t\tif (res)\n \t\t\t\tgoto release_todo_list;\n \t\t}\n-\t\tif (index_differs_from(\"HEAD\", 0, 0)) {\n+\t\tif (index_differs_from(\"HEAD\", NULL, 0)) {\n \t\t\tres = error_dirty_index(opts);\n \t\t\tgoto release_todo_list;\n \t\t}\n-- \n2.15.0.403.gc27cc4dac6-goog\n\n"},{"id":"331409","messageId":"20171030194646.27473-5-bmwill@google.com","threadId":"47047","inReplyTo":"20171030194646.27473-1-bmwill@google.com","subject":"[PATCH v2 4/4] diff: remove touched flags","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-10-30T19:46:46Z","receivedAt":"2017-10-30T19:47:06Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"Now that the set of parallel touched flags are no longer being used,\nremove them.\n\nSigned-off-by: Brandon Williams <bmwill@google.com>\n---\n builtin/log.c | 2 --\n diff.h        | 6 ++----\n 2 files changed, 2 insertions(+), 6 deletions(-)\n\ndiff --git a/builtin/log.c b/builtin/log.c\nindex 82131751d..9c0815270 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -134,8 +134,6 @@ static void cmd_log_init_defaults(struct rev_info *rev)\n \n \tif (default_date_mode)\n \t\tparse_date_format(default_date_mode, &rev->date_mode);\n-\n-\tmemset(&rev->diffopt.touched_flags, 0, sizeof(struct diff_flags));\n }\n \n static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,\ndiff --git a/diff.h b/diff.h\nindex 4eaf9b370..7e567108e 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -111,9 +111,8 @@ static inline struct diff_flags diff_flags_or(const struct diff_flags *a,\n }\n \n #define DIFF_OPT_TST(opts, flag)\t((opts)->flags.flag)\n-#define DIFF_OPT_TOUCHED(opts, flag)\t((opts)->touched_flags.flag)\n-#define DIFF_OPT_SET(opts, flag)\t(((opts)->flags.flag = 1),((opts)->touched_flags.flag = 1))\n-#define DIFF_OPT_CLR(opts, flag)\t(((opts)->flags.flag = 0),((opts)->touched_flags.flag = 1))\n+#define DIFF_OPT_SET(opts, flag)\t((opts)->flags.flag = 1)\n+#define DIFF_OPT_CLR(opts, flag)\t((opts)->flags.flag = 0)\n \n #define DIFF_XDL_TST(opts, flag)    ((opts)->xdl_opts & XDF_##flag)\n #define DIFF_XDL_SET(opts, flag)    ((opts)->xdl_opts |= XDF_##flag)\n@@ -142,7 +141,6 @@ struct diff_options {\n \tconst char *line_prefix;\n \tsize_t line_prefix_length;\n \tstruct diff_flags flags;\n-\tstruct diff_flags touched_flags;\n \n \t/* diff-filter bits */\n \tunsigned int filter;\n-- \n2.15.0.403.gc27cc4dac6-goog\n\n"},{"id":"331410","messageId":"20171030194646.27473-4-bmwill@google.com","threadId":"47047","inReplyTo":"20171030194646.27473-1-bmwill@google.com","subject":"[PATCH v2 3/4] diff: add flag to indicate textconv was set via cmdline","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-10-30T19:46:45Z","receivedAt":"2017-10-30T19:47:09Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"git-show is unique in that it wants to use textconv by default except\nfor when it is showing blobs.  When asked to show a blob, show doesn't\nwant to use textconv unless the user explicitly requested that it be\nused by providing the command line flag '--textconv'.\n\nCurrently this is done by using a parallel set of 'touched' flags which\nget set every time a particular flag is set or cleared.  In a future\npatch we want to eliminate this parallel set of flags so instead of\nrelying on if the textconv flag has been touched, add a new flag\n'TEXTCONV_SET_VIA_CMDLINE' which is only set if textconv is requested\nvia the command line.\n\nSigned-off-by: Brandon Williams <bmwill@google.com>\n---\n builtin/log.c | 2 +-\n diff.c        | 8 +++++---\n diff.h        | 1 +\n 3 files changed, 7 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin/log.c b/builtin/log.c\nindex dc28d43eb..82131751d 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -485,7 +485,7 @@ static int show_blob_object(const struct object_id *oid, struct rev_info *rev, c\n \tunsigned long size;\n \n \tfflush(rev->diffopt.file);\n-\tif (!DIFF_OPT_TOUCHED(&rev->diffopt, ALLOW_TEXTCONV) ||\n+\tif (!DIFF_OPT_TST(&rev->diffopt, TEXTCONV_SET_VIA_CMDLINE) ||\n \t    !DIFF_OPT_TST(&rev->diffopt, ALLOW_TEXTCONV))\n \t\treturn stream_blob_to_fd(1, oid, NULL, 0);\n \ndiff --git a/diff.c b/diff.c\nindex 3ad9c9b31..8b700b1bd 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4762,11 +4762,13 @@ int diff_opt_parse(struct diff_options *options,\n \t\tDIFF_OPT_SET(options, ALLOW_EXTERNAL);\n \telse if (!strcmp(arg, \"--no-ext-diff\"))\n \t\tDIFF_OPT_CLR(options, ALLOW_EXTERNAL);\n-\telse if (!strcmp(arg, \"--textconv\"))\n+\telse if (!strcmp(arg, \"--textconv\")) {\n \t\tDIFF_OPT_SET(options, ALLOW_TEXTCONV);\n-\telse if (!strcmp(arg, \"--no-textconv\"))\n+\t\tDIFF_OPT_SET(options, TEXTCONV_SET_VIA_CMDLINE);\n+\t} else if (!strcmp(arg, \"--no-textconv\")) {\n \t\tDIFF_OPT_CLR(options, ALLOW_TEXTCONV);\n-\telse if (!strcmp(arg, \"--ignore-submodules\")) {\n+\t\tDIFF_OPT_CLR(options, TEXTCONV_SET_VIA_CMDLINE);\n+\t} else if (!strcmp(arg, \"--ignore-submodules\")) {\n \t\tDIFF_OPT_SET(options, OVERRIDE_SUBMODULE_CONFIG);\n \t\thandle_ignore_submodules_arg(options, \"all\");\n \t} else if (skip_prefix(arg, \"--ignore-submodules=\", &arg)) {\ndiff --git a/diff.h b/diff.h\nindex 47e6d43cb..4eaf9b370 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -83,6 +83,7 @@ struct diff_flags {\n \tunsigned DIRSTAT_CUMULATIVE:1;\n \tunsigned DIRSTAT_BY_FILE:1;\n \tunsigned ALLOW_TEXTCONV:1;\n+\tunsigned TEXTCONV_SET_VIA_CMDLINE:1;\n \tunsigned DIFF_FROM_CONTENTS:1;\n \tunsigned DIRTY_SUBMODULES:1;\n \tunsigned IGNORE_UNTRACKED_IN_SUBMODULES:1;\n-- \n2.15.0.403.gc27cc4dac6-goog\n\n"},{"id":"331412","messageId":"CAGZ79kaLX881vi3MJaOCE6h=h_eRGjJ+gYCUEV-2rNSg0exFOw@mail.gmail.com","threadId":"47047","inReplyTo":"20171030194646.27473-4-bmwill@google.com","subject":"Re: [PATCH v2 3/4] diff: add flag to indicate textconv was set via cmdline","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-10-30T20:41:29Z","receivedAt":"2017-10-30T20:41:36Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Mon, Oct 30, 2017 at 12:46 PM, Brandon Williams <bmwill@google.com> wrote:\n> git-show is unique in that it wants to use textconv by default except\n> for when it is showing blobs.  When asked to show a blob, show doesn't\n> want to use textconv unless the user explicitly requested that it be\n> used by providing the command line flag '--textconv'.\n>\n> Currently this is done by using a parallel set of 'touched' flags which\n> get set every time a particular flag is set or cleared.  In a future\n> patch we want to eliminate this parallel set of flags so instead of\n> relying on if the textconv flag has been touched, add a new flag\n> 'TEXTCONV_SET_VIA_CMDLINE' which is only set if textconv is requested\n> via the command line.\n\nIs it worth mentioning 4197361e39 (Merge branch 'mg/more-textconv',\n2013-10-23), that introduced the touched_flags?\n(+cc Michael Gruber FYI)\n\n> Signed-off-by: Brandon Williams <bmwill@google.com>\n> ---\n>  builtin/log.c | 2 +-\n>  diff.c        | 8 +++++---\n>  diff.h        | 1 +\n>  3 files changed, 7 insertions(+), 4 deletions(-)\n>\n> diff --git a/builtin/log.c b/builtin/log.c\n> index dc28d43eb..82131751d 100644\n> --- a/builtin/log.c\n> +++ b/builtin/log.c\n> @@ -485,7 +485,7 @@ static int show_blob_object(const struct object_id *oid, struct rev_info *rev, c\n>         unsigned long size;\n>\n>         fflush(rev->diffopt.file);\n> -       if (!DIFF_OPT_TOUCHED(&rev->diffopt, ALLOW_TEXTCONV) ||\n> +       if (!DIFF_OPT_TST(&rev->diffopt, TEXTCONV_SET_VIA_CMDLINE) ||\n>             !DIFF_OPT_TST(&rev->diffopt, ALLOW_TEXTCONV))\n>                 return stream_blob_to_fd(1, oid, NULL, 0);\n>\n> diff --git a/diff.c b/diff.c\n> index 3ad9c9b31..8b700b1bd 100644\n> --- a/diff.c\n> +++ b/diff.c\n> @@ -4762,11 +4762,13 @@ int diff_opt_parse(struct diff_options *options,\n>                 DIFF_OPT_SET(options, ALLOW_EXTERNAL);\n>         else if (!strcmp(arg, \"--no-ext-diff\"))\n>                 DIFF_OPT_CLR(options, ALLOW_EXTERNAL);\n> -       else if (!strcmp(arg, \"--textconv\"))\n> +       else if (!strcmp(arg, \"--textconv\")) {\n>                 DIFF_OPT_SET(options, ALLOW_TEXTCONV);\n> -       else if (!strcmp(arg, \"--no-textconv\"))\n> +               DIFF_OPT_SET(options, TEXTCONV_SET_VIA_CMDLINE);\n> +       } else if (!strcmp(arg, \"--no-textconv\")) {\n>                 DIFF_OPT_CLR(options, ALLOW_TEXTCONV);\n\nAlso clear TEXTCONV_SET_VIA_CMDLINE here?\n(`git show --textconv --no-textconv` might act funny?)\n\n> -       else if (!strcmp(arg, \"--ignore-submodules\")) {\n> +               DIFF_OPT_CLR(options, TEXTCONV_SET_VIA_CMDLINE);\n> +       } else if (!strcmp(arg, \"--ignore-submodules\")) {\n>                 DIFF_OPT_SET(options, OVERRIDE_SUBMODULE_CONFIG);\n>                 handle_ignore_submodules_arg(options, \"all\");\n>         } else if (skip_prefix(arg, \"--ignore-submodules=\", &arg)) {\n> diff --git a/diff.h b/diff.h\n> index 47e6d43cb..4eaf9b370 100644\n> --- a/diff.h\n> +++ b/diff.h\n> @@ -83,6 +83,7 @@ struct diff_flags {\n>         unsigned DIRSTAT_CUMULATIVE:1;\n>         unsigned DIRSTAT_BY_FILE:1;\n>         unsigned ALLOW_TEXTCONV:1;\n> +       unsigned TEXTCONV_SET_VIA_CMDLINE:1;\n>         unsigned DIFF_FROM_CONTENTS:1;\n>         unsigned DIRTY_SUBMODULES:1;\n>         unsigned IGNORE_UNTRACKED_IN_SUBMODULES:1;\n> --\n> 2.15.0.403.gc27cc4dac6-goog\n>\n"},{"id":"331413","messageId":"20171030204447.GD125460@google.com","threadId":"47047","inReplyTo":"CAGZ79kaLX881vi3MJaOCE6h=h_eRGjJ+gYCUEV-2rNSg0exFOw@mail.gmail.com","subject":"Re: [PATCH v2 3/4] diff: add flag to indicate textconv was set via cmdline","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-10-30T20:44:47Z","receivedAt":"2017-10-30T20:44:55Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"On 10/30, Stefan Beller wrote:\n> On Mon, Oct 30, 2017 at 12:46 PM, Brandon Williams <bmwill@google.com> wrote:\n> > git-show is unique in that it wants to use textconv by default except\n> > for when it is showing blobs.  When asked to show a blob, show doesn't\n> > want to use textconv unless the user explicitly requested that it be\n> > used by providing the command line flag '--textconv'.\n> >\n> > Currently this is done by using a parallel set of 'touched' flags which\n> > get set every time a particular flag is set or cleared.  In a future\n> > patch we want to eliminate this parallel set of flags so instead of\n> > relying on if the textconv flag has been touched, add a new flag\n> > 'TEXTCONV_SET_VIA_CMDLINE' which is only set if textconv is requested\n> > via the command line.\n> \n> Is it worth mentioning 4197361e39 (Merge branch 'mg/more-textconv',\n> 2013-10-23), that introduced the touched_flags?\n> (+cc Michael Gruber FYI)\n> \n> > Signed-off-by: Brandon Williams <bmwill@google.com>\n> > ---\n> >  builtin/log.c | 2 +-\n> >  diff.c        | 8 +++++---\n> >  diff.h        | 1 +\n> >  3 files changed, 7 insertions(+), 4 deletions(-)\n> >\n> > diff --git a/builtin/log.c b/builtin/log.c\n> > index dc28d43eb..82131751d 100644\n> > --- a/builtin/log.c\n> > +++ b/builtin/log.c\n> > @@ -485,7 +485,7 @@ static int show_blob_object(const struct object_id *oid, struct rev_info *rev, c\n> >         unsigned long size;\n> >\n> >         fflush(rev->diffopt.file);\n> > -       if (!DIFF_OPT_TOUCHED(&rev->diffopt, ALLOW_TEXTCONV) ||\n> > +       if (!DIFF_OPT_TST(&rev->diffopt, TEXTCONV_SET_VIA_CMDLINE) ||\n> >             !DIFF_OPT_TST(&rev->diffopt, ALLOW_TEXTCONV))\n> >                 return stream_blob_to_fd(1, oid, NULL, 0);\n> >\n> > diff --git a/diff.c b/diff.c\n> > index 3ad9c9b31..8b700b1bd 100644\n> > --- a/diff.c\n> > +++ b/diff.c\n> > @@ -4762,11 +4762,13 @@ int diff_opt_parse(struct diff_options *options,\n> >                 DIFF_OPT_SET(options, ALLOW_EXTERNAL);\n> >         else if (!strcmp(arg, \"--no-ext-diff\"))\n> >                 DIFF_OPT_CLR(options, ALLOW_EXTERNAL);\n> > -       else if (!strcmp(arg, \"--textconv\"))\n> > +       else if (!strcmp(arg, \"--textconv\")) {\n> >                 DIFF_OPT_SET(options, ALLOW_TEXTCONV);\n> > -       else if (!strcmp(arg, \"--no-textconv\"))\n> > +               DIFF_OPT_SET(options, TEXTCONV_SET_VIA_CMDLINE);\n> > +       } else if (!strcmp(arg, \"--no-textconv\")) {\n> >                 DIFF_OPT_CLR(options, ALLOW_TEXTCONV);\n> \n> Also clear TEXTCONV_SET_VIA_CMDLINE here?\n> (`git show --textconv --no-textconv` might act funny?)\n\nOops, thanks for catching this, I added it in the wrong place! (as you\ncan see below.\n\n> \n> > -       else if (!strcmp(arg, \"--ignore-submodules\")) {\n> > +               DIFF_OPT_CLR(options, TEXTCONV_SET_VIA_CMDLINE);\n> > +       } else if (!strcmp(arg, \"--ignore-submodules\")) {\n> >                 DIFF_OPT_SET(options, OVERRIDE_SUBMODULE_CONFIG);\n> >                 handle_ignore_submodules_arg(options, \"all\");\n> >         } else if (skip_prefix(arg, \"--ignore-submodules=\", &arg)) {\n> > diff --git a/diff.h b/diff.h\n> > index 47e6d43cb..4eaf9b370 100644\n> > --- a/diff.h\n> > +++ b/diff.h\n> > @@ -83,6 +83,7 @@ struct diff_flags {\n> >         unsigned DIRSTAT_CUMULATIVE:1;\n> >         unsigned DIRSTAT_BY_FILE:1;\n> >         unsigned ALLOW_TEXTCONV:1;\n> > +       unsigned TEXTCONV_SET_VIA_CMDLINE:1;\n> >         unsigned DIFF_FROM_CONTENTS:1;\n> >         unsigned DIRTY_SUBMODULES:1;\n> >         unsigned IGNORE_UNTRACKED_IN_SUBMODULES:1;\n> > --\n> > 2.15.0.403.gc27cc4dac6-goog\n> >\n\n-- \nBrandon Williams\n"},{"id":"331414","messageId":"20171030204806.GE125460@google.com","threadId":"47047","inReplyTo":"20171030204447.GD125460@google.com","subject":"Re: [PATCH v2 3/4] diff: add flag to indicate textconv was set via cmdline","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-10-30T20:48:06Z","receivedAt":"2017-10-30T20:48:14Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"On 10/30, Brandon Williams wrote:\n> On 10/30, Stefan Beller wrote:\n> > On Mon, Oct 30, 2017 at 12:46 PM, Brandon Williams <bmwill@google.com> wrote:\n> > > git-show is unique in that it wants to use textconv by default except\n> > > for when it is showing blobs.  When asked to show a blob, show doesn't\n> > > want to use textconv unless the user explicitly requested that it be\n> > > used by providing the command line flag '--textconv'.\n> > >\n> > > Currently this is done by using a parallel set of 'touched' flags which\n> > > get set every time a particular flag is set or cleared.  In a future\n> > > patch we want to eliminate this parallel set of flags so instead of\n> > > relying on if the textconv flag has been touched, add a new flag\n> > > 'TEXTCONV_SET_VIA_CMDLINE' which is only set if textconv is requested\n> > > via the command line.\n> > \n> > Is it worth mentioning 4197361e39 (Merge branch 'mg/more-textconv',\n> > 2013-10-23), that introduced the touched_flags?\n> > (+cc Michael Gruber FYI)\n> > \n> > > Signed-off-by: Brandon Williams <bmwill@google.com>\n> > > ---\n> > >  builtin/log.c | 2 +-\n> > >  diff.c        | 8 +++++---\n> > >  diff.h        | 1 +\n> > >  3 files changed, 7 insertions(+), 4 deletions(-)\n> > >\n> > > diff --git a/builtin/log.c b/builtin/log.c\n> > > index dc28d43eb..82131751d 100644\n> > > --- a/builtin/log.c\n> > > +++ b/builtin/log.c\n> > > @@ -485,7 +485,7 @@ static int show_blob_object(const struct object_id *oid, struct rev_info *rev, c\n> > >         unsigned long size;\n> > >\n> > >         fflush(rev->diffopt.file);\n> > > -       if (!DIFF_OPT_TOUCHED(&rev->diffopt, ALLOW_TEXTCONV) ||\n> > > +       if (!DIFF_OPT_TST(&rev->diffopt, TEXTCONV_SET_VIA_CMDLINE) ||\n> > >             !DIFF_OPT_TST(&rev->diffopt, ALLOW_TEXTCONV))\n> > >                 return stream_blob_to_fd(1, oid, NULL, 0);\n> > >\n> > > diff --git a/diff.c b/diff.c\n> > > index 3ad9c9b31..8b700b1bd 100644\n> > > --- a/diff.c\n> > > +++ b/diff.c\n> > > @@ -4762,11 +4762,13 @@ int diff_opt_parse(struct diff_options *options,\n> > >                 DIFF_OPT_SET(options, ALLOW_EXTERNAL);\n> > >         else if (!strcmp(arg, \"--no-ext-diff\"))\n> > >                 DIFF_OPT_CLR(options, ALLOW_EXTERNAL);\n> > > -       else if (!strcmp(arg, \"--textconv\"))\n> > > +       else if (!strcmp(arg, \"--textconv\")) {\n> > >                 DIFF_OPT_SET(options, ALLOW_TEXTCONV);\n> > > -       else if (!strcmp(arg, \"--no-textconv\"))\n> > > +               DIFF_OPT_SET(options, TEXTCONV_SET_VIA_CMDLINE);\n> > > +       } else if (!strcmp(arg, \"--no-textconv\")) {\n> > >                 DIFF_OPT_CLR(options, ALLOW_TEXTCONV);\n> > \n> > Also clear TEXTCONV_SET_VIA_CMDLINE here?\n> > (`git show --textconv --no-textconv` might act funny?)\n> \n> Oops, thanks for catching this, I added it in the wrong place! (as you\n> can see below.\n\nwait nevermind, i overreacted.  And this patch does correctly clear\nTEXTCONV_SET_VIA_CMDLINE.\n\n> \n> > \n> > > -       else if (!strcmp(arg, \"--ignore-submodules\")) {\n> > > +               DIFF_OPT_CLR(options, TEXTCONV_SET_VIA_CMDLINE);\n> > > +       } else if (!strcmp(arg, \"--ignore-submodules\")) {\n> > >                 DIFF_OPT_SET(options, OVERRIDE_SUBMODULE_CONFIG);\n> > >                 handle_ignore_submodules_arg(options, \"all\");\n> > >         } else if (skip_prefix(arg, \"--ignore-submodules=\", &arg)) {\n> > > diff --git a/diff.h b/diff.h\n> > > index 47e6d43cb..4eaf9b370 100644\n> > > --- a/diff.h\n> > > +++ b/diff.h\n> > > @@ -83,6 +83,7 @@ struct diff_flags {\n> > >         unsigned DIRSTAT_CUMULATIVE:1;\n> > >         unsigned DIRSTAT_BY_FILE:1;\n> > >         unsigned ALLOW_TEXTCONV:1;\n> > > +       unsigned TEXTCONV_SET_VIA_CMDLINE:1;\n> > >         unsigned DIFF_FROM_CONTENTS:1;\n> > >         unsigned DIRTY_SUBMODULES:1;\n> > >         unsigned IGNORE_UNTRACKED_IN_SUBMODULES:1;\n> > > --\n> > > 2.15.0.403.gc27cc4dac6-goog\n> > >\n> \n> -- \n> Brandon Williams\n\n-- \nBrandon Williams\n"},{"id":"331416","messageId":"20171030221956.92466-1-bmwill@google.com","threadId":"47047","inReplyTo":"20171030194646.27473-1-bmwill@google.com","subject":"[PATCH v2 5/4] diff: remove DIFF_OPT_TST macro","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-10-30T22:19:53Z","receivedAt":"2017-10-30T22:20:21Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"Remove the `DIFF_OPT_TST` macro and instead access the flags directly.\nThis conversion is done using the following semantic patch:\n\n\t@@\n\texpression E;\n\tidentifier fld;\n\t@@\n\t- DIFF_OPT_TST(&E, fld)\n\t+ E.flags.fld\n\n\t@@\n\ttype T;\n\tT *ptr;\n\tidentifier fld;\n\t@@\n\t- DIFF_OPT_TST(ptr, fld)\n\t+ ptr->flags.fld\n\nSigned-off-by: Brandon Williams <bmwill@google.com>\n---\n blame.c            |  8 +++---\n builtin/am.c       |  2 +-\n builtin/blame.c    |  4 +--\n builtin/diff.c     |  2 +-\n builtin/log.c      | 12 ++++-----\n builtin/rev-list.c |  2 +-\n combine-diff.c     |  6 ++---\n diff-lib.c         | 19 +++++++-------\n diff-no-index.c    |  2 +-\n diff.c             | 76 +++++++++++++++++++++++++++---------------------------\n diff.h             |  1 -\n diffcore-pickaxe.c |  8 +++---\n diffcore-rename.c  |  6 ++---\n log-tree.c         |  2 +-\n revision.c         |  4 +--\n submodule.c        |  2 +-\n tree-diff.c        | 12 ++++-----\n 17 files changed, 84 insertions(+), 84 deletions(-)\n\ndiff --git a/blame.c b/blame.c\nindex f575e9cbf..7c019bc7c 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -209,7 +209,7 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,\n \n \t\tswitch (st.st_mode & S_IFMT) {\n \t\tcase S_IFREG:\n-\t\t\tif (DIFF_OPT_TST(opt, ALLOW_TEXTCONV) &&\n+\t\t\tif (opt->flags.ALLOW_TEXTCONV &&\n \t\t\t    textconv_object(read_from, mode, &null_oid, 0, &buf_ptr, &buf_len))\n \t\t\t\tstrbuf_attach(&buf, buf_ptr, buf_len, buf_len + 1);\n \t\t\telse if (strbuf_read_file(&buf, read_from, st.st_size) != st.st_size)\n@@ -293,7 +293,7 @@ static void fill_origin_blob(struct diff_options *opt,\n \t\tunsigned long file_size;\n \n \t\t(*num_read_blob)++;\n-\t\tif (DIFF_OPT_TST(opt, ALLOW_TEXTCONV) &&\n+\t\tif (opt->flags.ALLOW_TEXTCONV &&\n \t\t    textconv_object(o->path, o->mode, &o->blob_oid, 1, &file->ptr, &file_size))\n \t\t\t;\n \t\telse\n@@ -1262,7 +1262,7 @@ static void find_copy_in_parent(struct blame_scoreboard *sb,\n \t\t\t      &target->commit->tree->object.oid,\n \t\t\t      \"\", &diff_opts);\n \n-\tif (!DIFF_OPT_TST(&diff_opts, FIND_COPIES_HARDER))\n+\tif (!diff_opts.flags.FIND_COPIES_HARDER)\n \t\tdiffcore_std(&diff_opts);\n \n \tdo {\n@@ -1825,7 +1825,7 @@ void setup_scoreboard(struct blame_scoreboard *sb, const char *path, struct blam\n \t\tif (fill_blob_sha1_and_mode(o))\n \t\t\tdie(_(\"no such path %s in %s\"), path, final_commit_name);\n \n-\t\tif (DIFF_OPT_TST(&sb->revs->diffopt, ALLOW_TEXTCONV) &&\n+\t\tif (sb->revs->diffopt.flags.ALLOW_TEXTCONV &&\n \t\t    textconv_object(path, o->mode, &o->blob_oid, 1, (char **) &sb->final_buf,\n \t\t\t\t    &sb->final_buf_size))\n \t\t\t;\ndiff --git a/builtin/am.c b/builtin/am.c\nindex d7513f537..fc54724cc 100644\n--- a/builtin/am.c\n+++ b/builtin/am.c\n@@ -1168,7 +1168,7 @@ static int index_has_changes(struct strbuf *sb)\n \t\t\tstrbuf_addstr(sb, diff_queued_diff.queue[i]->two->path);\n \t\t}\n \t\tdiff_flush(&opt);\n-\t\treturn DIFF_OPT_TST(&opt, HAS_CHANGES) != 0;\n+\t\treturn opt.flags.HAS_CHANGES != 0;\n \t} else {\n \t\tfor (i = 0; sb && i < active_nr; i++) {\n \t\t\tif (i)\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex 67adaef4d..a29574984 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -734,7 +734,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)\n \t\tparse_revision_opt(&revs, &ctx, options, blame_opt_usage);\n \t}\n parse_done:\n-\tno_whole_file_rename = !DIFF_OPT_TST(&revs.diffopt, FOLLOW_RENAMES);\n+\tno_whole_file_rename = !revs.diffopt.flags.FOLLOW_RENAMES;\n \txdl_opts |= revs.diffopt.xdl_opts & XDF_INDENT_HEURISTIC;\n \tDIFF_OPT_CLR(&revs.diffopt, FOLLOW_RENAMES);\n \targc = parse_options_end(&ctx);\n@@ -803,7 +803,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)\n \t}\n \tblame_date_width -= 1; /* strip the null */\n \n-\tif (DIFF_OPT_TST(&revs.diffopt, FIND_COPIES_HARDER))\n+\tif (revs.diffopt.flags.FIND_COPIES_HARDER)\n \t\topt |= (PICKAXE_BLAME_COPY | PICKAXE_BLAME_MOVE |\n \t\t\tPICKAXE_BLAME_COPY_HARDER);\n \ndiff --git a/builtin/diff.c b/builtin/diff.c\nindex f5bbd4d75..8cbaf4538 100644\n--- a/builtin/diff.c\n+++ b/builtin/diff.c\n@@ -44,7 +44,7 @@ static void stuff_change(struct diff_options *opt,\n \t    !oidcmp(old_oid, new_oid) && (old_mode == new_mode))\n \t\treturn;\n \n-\tif (DIFF_OPT_TST(opt, REVERSE_DIFF)) {\n+\tif (opt->flags.REVERSE_DIFF) {\n \t\tSWAP(old_mode, new_mode);\n \t\tSWAP(old_oid, new_oid);\n \t\tSWAP(old_path, new_path);\ndiff --git a/builtin/log.c b/builtin/log.c\nindex 9c0815270..2b2d36678 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -181,7 +181,7 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,\n \t\tinit_display_notes(&rev->notes_opt);\n \n \tif (rev->diffopt.pickaxe || rev->diffopt.filter ||\n-\t    DIFF_OPT_TST(&rev->diffopt, FOLLOW_RENAMES))\n+\t    rev->diffopt.flags.FOLLOW_RENAMES)\n \t\trev->always_show_header = 0;\n \n \tif (source)\n@@ -391,7 +391,7 @@ static int cmd_log_walk(struct rev_info *rev)\n \t\tfclose(rev->diffopt.file);\n \n \tif (rev->diffopt.output_format & DIFF_FORMAT_CHECKDIFF &&\n-\t    DIFF_OPT_TST(&rev->diffopt, CHECK_FAILED)) {\n+\t    rev->diffopt.flags.CHECK_FAILED) {\n \t\treturn 02;\n \t}\n \treturn diff_result_code(&rev->diffopt, 0);\n@@ -483,8 +483,8 @@ static int show_blob_object(const struct object_id *oid, struct rev_info *rev, c\n \tunsigned long size;\n \n \tfflush(rev->diffopt.file);\n-\tif (!DIFF_OPT_TST(&rev->diffopt, TEXTCONV_SET_VIA_CMDLINE) ||\n-\t    !DIFF_OPT_TST(&rev->diffopt, ALLOW_TEXTCONV))\n+\tif (!rev->diffopt.flags.TEXTCONV_SET_VIA_CMDLINE ||\n+\t    !rev->diffopt.flags.ALLOW_TEXTCONV)\n \t\treturn stream_blob_to_fd(1, oid, NULL, 0);\n \n \tif (get_oid_with_context(obj_name, GET_OID_RECORD_PATH,\n@@ -666,7 +666,7 @@ int cmd_log_reflog(int argc, const char **argv, const char *prefix)\n static void log_setup_revisions_tweak(struct rev_info *rev,\n \t\t\t\t      struct setup_revision_opt *opt)\n {\n-\tif (DIFF_OPT_TST(&rev->diffopt, DEFAULT_FOLLOW_RENAMES) &&\n+\tif (rev->diffopt.flags.DEFAULT_FOLLOW_RENAMES &&\n \t    rev->prune_data.nr == 1)\n \t\tDIFF_OPT_SET(&rev->diffopt, FOLLOW_RENAMES);\n \n@@ -1612,7 +1612,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \n \trev.zero_commit = zero_commit;\n \n-\tif (!DIFF_OPT_TST(&rev.diffopt, TEXT) && !no_binary_diff)\n+\tif (!rev.diffopt.flags.TEXT && !no_binary_diff)\n \t\tDIFF_OPT_SET(&rev.diffopt, BINARY);\n \n \tif (rev.show_notes)\ndiff --git a/builtin/rev-list.c b/builtin/rev-list.c\nindex c1c74d4a7..c62382171 100644\n--- a/builtin/rev-list.c\n+++ b/builtin/rev-list.c\n@@ -294,7 +294,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)\n \tif (revs.bisect)\n \t\tbisect_list = 1;\n \n-\tif (DIFF_OPT_TST(&revs.diffopt, QUICK))\n+\tif (revs.diffopt.flags.QUICK)\n \t\tinfo.flags |= REV_LIST_QUIET;\n \tfor (i = 1 ; i < argc; i++) {\n \t\tconst char *arg = argv[i];\ndiff --git a/combine-diff.c b/combine-diff.c\nindex 9e163d5ad..40cb4dd1a 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -898,7 +898,7 @@ static void show_combined_header(struct combine_diff_path *elem,\n \t\t\t\t int show_file_header)\n {\n \tstruct diff_options *opt = &rev->diffopt;\n-\tint abbrev = DIFF_OPT_TST(opt, FULL_INDEX) ? GIT_SHA1_HEXSZ : DEFAULT_ABBREV;\n+\tint abbrev = opt->flags.FULL_INDEX ? GIT_SHA1_HEXSZ : DEFAULT_ABBREV;\n \tconst char *a_prefix = opt->a_prefix ? opt->a_prefix : \"a/\";\n \tconst char *b_prefix = opt->b_prefix ? opt->b_prefix : \"b/\";\n \tconst char *c_meta = diff_get_color_opt(opt, DIFF_METAINFO);\n@@ -987,7 +987,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,\n \tuserdiff = userdiff_find_by_path(elem->path);\n \tif (!userdiff)\n \t\tuserdiff = userdiff_find_by_name(\"default\");\n-\tif (DIFF_OPT_TST(opt, ALLOW_TEXTCONV))\n+\tif (opt->flags.ALLOW_TEXTCONV)\n \t\ttextconv = userdiff_get_textconv(userdiff);\n \n \t/* Read the result of merge first */\n@@ -1435,7 +1435,7 @@ void diff_tree_combined(const struct object_id *oid,\n \t * NOTE please keep this semantically in sync with diffcore_std()\n \t */\n \tneed_generic_pathscan = opt->skip_stat_unmatch\t||\n-\t\t\tDIFF_OPT_TST(opt, FOLLOW_RENAMES)\t||\n+\t\t\topt->flags.FOLLOW_RENAMES\t||\n \t\t\topt->break_opt != -1\t||\n \t\t\topt->detect_rename\t||\n \t\t\topt->pickaxe\t\t||\ndiff --git a/diff-lib.c b/diff-lib.c\nindex 6c1c05c5b..d6b711617 100644\n--- a/diff-lib.c\n+++ b/diff-lib.c\n@@ -72,13 +72,14 @@ static int match_stat_with_submodule(struct diff_options *diffopt,\n \tint changed = ce_match_stat(ce, st, ce_option);\n \tif (S_ISGITLINK(ce->ce_mode)) {\n \t\tstruct diff_flags orig_flags = diffopt->flags;\n-\t\tif (!DIFF_OPT_TST(diffopt, OVERRIDE_SUBMODULE_CONFIG))\n+\t\tif (!diffopt->flags.OVERRIDE_SUBMODULE_CONFIG)\n \t\t\tset_diffopt_flags_from_submodule_config(diffopt, ce->name);\n-\t\tif (DIFF_OPT_TST(diffopt, IGNORE_SUBMODULES))\n+\t\tif (diffopt->flags.IGNORE_SUBMODULES)\n \t\t\tchanged = 0;\n-\t\telse if (!DIFF_OPT_TST(diffopt, IGNORE_DIRTY_SUBMODULES)\n-\t\t    && (!changed || DIFF_OPT_TST(diffopt, DIRTY_SUBMODULES)))\n-\t\t\t*dirty_submodule = is_submodule_modified(ce->name, DIFF_OPT_TST(diffopt, IGNORE_UNTRACKED_IN_SUBMODULES));\n+\t\telse if (!diffopt->flags.IGNORE_DIRTY_SUBMODULES &&\n+\t\t\t (!changed || diffopt->flags.DIRTY_SUBMODULES))\n+\t\t\t*dirty_submodule = is_submodule_modified(ce->name,\n+\t\t\t\t\t\t\t\t diffopt->flags.IGNORE_UNTRACKED_IN_SUBMODULES);\n \t\tdiffopt->flags = orig_flags;\n \t}\n \treturn changed;\n@@ -228,7 +229,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)\n \n \t\tif (!changed && !dirty_submodule) {\n \t\t\tce_mark_uptodate(ce);\n-\t\t\tif (!DIFF_OPT_TST(&revs->diffopt, FIND_COPIES_HARDER))\n+\t\t\tif (!revs->diffopt.flags.FIND_COPIES_HARDER)\n \t\t\t\tcontinue;\n \t\t}\n \t\toldmode = ce->ce_mode;\n@@ -362,7 +363,7 @@ static int show_modified(struct rev_info *revs,\n \n \toldmode = old->ce_mode;\n \tif (mode == oldmode && !oidcmp(oid, &old->oid) && !dirty_submodule &&\n-\t    !DIFF_OPT_TST(&revs->diffopt, FIND_COPIES_HARDER))\n+\t    !revs->diffopt.flags.FIND_COPIES_HARDER)\n \t\treturn 0;\n \n \tdiff_change(&revs->diffopt, oldmode, mode,\n@@ -493,7 +494,7 @@ static int diff_cache(struct rev_info *revs,\n \topts.head_idx = 1;\n \topts.index_only = cached;\n \topts.diff_index_cached = (cached &&\n-\t\t\t\t  !DIFF_OPT_TST(&revs->diffopt, FIND_COPIES_HARDER));\n+\t\t\t\t  !revs->diffopt.flags.FIND_COPIES_HARDER);\n \topts.merge = 1;\n \topts.fn = oneway_diff;\n \topts.unpack_data = revs;\n@@ -551,5 +552,5 @@ int index_differs_from(const char *def, const struct diff_flags *flags,\n \trev.diffopt.ita_invisible_in_index = ita_invisible_in_index;\n \trun_diff_index(&rev, 1);\n \tobject_array_clear(&rev.pending);\n-\treturn (DIFF_OPT_TST(&rev.diffopt, HAS_CHANGES) != 0);\n+\treturn (rev.diffopt.flags.HAS_CHANGES != 0);\n }\ndiff --git a/diff-no-index.c b/diff-no-index.c\nindex 80ff17d46..40d17e42c 100644\n--- a/diff-no-index.c\n+++ b/diff-no-index.c\n@@ -184,7 +184,7 @@ static int queue_diff(struct diff_options *o,\n \t} else {\n \t\tstruct diff_filespec *d1, *d2;\n \n-\t\tif (DIFF_OPT_TST(o, REVERSE_DIFF)) {\n+\t\tif (o->flags.REVERSE_DIFF) {\n \t\t\tSWAP(mode1, mode2);\n \t\t\tSWAP(name1, name2);\n \t\t}\ndiff --git a/diff.c b/diff.c\nindex 8b700b1bd..924f876fc 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -1481,7 +1481,7 @@ static void emit_rewrite_diff(const char *name_a,\n \tstruct emit_callback ecbdata;\n \tstruct strbuf out = STRBUF_INIT;\n \n-\tif (diff_mnemonic_prefix && DIFF_OPT_TST(o, REVERSE_DIFF)) {\n+\tif (diff_mnemonic_prefix && o->flags.REVERSE_DIFF) {\n \t\ta_prefix = o->b_prefix;\n \t\tb_prefix = o->a_prefix;\n \t} else {\n@@ -2729,7 +2729,7 @@ static void show_dirstat(struct diff_options *options)\n \tdir.alloc = 0;\n \tdir.nr = 0;\n \tdir.permille = options->dirstat_permille;\n-\tdir.cumulative = DIFF_OPT_TST(options, DIRSTAT_CUMULATIVE);\n+\tdir.cumulative = options->flags.DIRSTAT_CUMULATIVE;\n \n \tchanged = 0;\n \tfor (i = 0; i < q->nr; i++) {\n@@ -2755,7 +2755,7 @@ static void show_dirstat(struct diff_options *options)\n \t\t\tgoto found_damage;\n \t\t}\n \n-\t\tif (DIFF_OPT_TST(options, DIRSTAT_BY_FILE)) {\n+\t\tif (options->flags.DIRSTAT_BY_FILE) {\n \t\t\t/*\n \t\t\t * In --dirstat-by-file mode, we don't really need to\n \t\t\t * look at the actual file contents at all.\n@@ -2830,7 +2830,7 @@ static void show_dirstat_by_line(struct diffstat_t *data, struct diff_options *o\n \tdir.alloc = 0;\n \tdir.nr = 0;\n \tdir.permille = options->dirstat_permille;\n-\tdir.cumulative = DIFF_OPT_TST(options, DIRSTAT_CUMULATIVE);\n+\tdir.cumulative = options->flags.DIRSTAT_CUMULATIVE;\n \n \tchanged = 0;\n \tfor (i = 0; i < data->nr; i++) {\n@@ -3117,7 +3117,7 @@ static void builtin_diff(const char *name_a,\n \tconst char *line_prefix = diff_line_prefix(o);\n \n \tdiff_set_mnemonic_prefix(o, \"a/\", \"b/\");\n-\tif (DIFF_OPT_TST(o, REVERSE_DIFF)) {\n+\tif (o->flags.REVERSE_DIFF) {\n \t\ta_prefix = o->b_prefix;\n \t\tb_prefix = o->a_prefix;\n \t} else {\n@@ -3141,7 +3141,7 @@ static void builtin_diff(const char *name_a,\n \t\treturn;\n \t}\n \n-\tif (DIFF_OPT_TST(o, ALLOW_TEXTCONV)) {\n+\tif (o->flags.ALLOW_TEXTCONV) {\n \t\ttextconv_one = get_textconv(one);\n \t\ttextconv_two = get_textconv(two);\n \t}\n@@ -3201,13 +3201,13 @@ static void builtin_diff(const char *name_a,\n \t\t\t\t header.len, 0);\n \t\tstrbuf_reset(&header);\n \t\tgoto free_ab_and_return;\n-\t} else if (!DIFF_OPT_TST(o, TEXT) &&\n+\t} else if (!o->flags.TEXT &&\n \t    ( (!textconv_one && diff_filespec_is_binary(one)) ||\n \t      (!textconv_two && diff_filespec_is_binary(two)) )) {\n \t\tstruct strbuf sb = STRBUF_INIT;\n \t\tif (!one->data && !two->data &&\n \t\t    S_ISREG(one->mode) && S_ISREG(two->mode) &&\n-\t\t    !DIFF_OPT_TST(o, BINARY)) {\n+\t\t    !o->flags.BINARY) {\n \t\t\tif (!oidcmp(&one->oid, &two->oid)) {\n \t\t\t\tif (must_show_header)\n \t\t\t\t\temit_diff_symbol(o, DIFF_SYMBOL_HEADER,\n@@ -3236,7 +3236,7 @@ static void builtin_diff(const char *name_a,\n \t\t}\n \t\temit_diff_symbol(o, DIFF_SYMBOL_HEADER, header.buf, header.len, 0);\n \t\tstrbuf_reset(&header);\n-\t\tif (DIFF_OPT_TST(o, BINARY))\n+\t\tif (o->flags.BINARY)\n \t\t\temit_binary_diff(o, &mf1, &mf2);\n \t\telse {\n \t\t\tstrbuf_addf(&sb, \"%sBinary files %s and %s differ\\n\",\n@@ -3282,7 +3282,7 @@ static void builtin_diff(const char *name_a,\n \t\txecfg.ctxlen = o->context;\n \t\txecfg.interhunkctxlen = o->interhunkcontext;\n \t\txecfg.flags = XDL_EMIT_FUNCNAMES;\n-\t\tif (DIFF_OPT_TST(o, FUNCCONTEXT))\n+\t\tif (o->flags.FUNCCONTEXT)\n \t\t\txecfg.flags |= XDL_EMIT_FUNCCONTEXT;\n \t\tif (pe)\n \t\t\txdiff_set_find_func(&xecfg, pe->pattern, pe->cflags);\n@@ -3941,9 +3941,9 @@ static void fill_metainfo(struct strbuf *msg,\n \t\t*must_show_header = 0;\n \t}\n \tif (one && two && oidcmp(&one->oid, &two->oid)) {\n-\t\tint abbrev = DIFF_OPT_TST(o, FULL_INDEX) ? 40 : DEFAULT_ABBREV;\n+\t\tint abbrev = o->flags.FULL_INDEX ? 40 : DEFAULT_ABBREV;\n \n-\t\tif (DIFF_OPT_TST(o, BINARY)) {\n+\t\tif (o->flags.BINARY) {\n \t\t\tmmfile_t mf;\n \t\t\tif ((!fill_mmfile(&mf, one) && diff_filespec_is_binary(one)) ||\n \t\t\t    (!fill_mmfile(&mf, two) && diff_filespec_is_binary(two)))\n@@ -3973,7 +3973,7 @@ static void run_diff_cmd(const char *pgm,\n \tint must_show_header = 0;\n \n \n-\tif (DIFF_OPT_TST(o, ALLOW_EXTERNAL)) {\n+\tif (o->flags.ALLOW_EXTERNAL) {\n \t\tstruct userdiff_driver *drv = userdiff_find_by_path(attr_path);\n \t\tif (drv && drv->external)\n \t\t\tpgm = drv->external;\n@@ -4053,7 +4053,7 @@ static void run_diff(struct diff_filepair *p, struct diff_options *o)\n \tif (o->prefix_length)\n \t\tstrip_prefix(o->prefix_length, &name, &other);\n \n-\tif (!DIFF_OPT_TST(o, ALLOW_EXTERNAL))\n+\tif (!o->flags.ALLOW_EXTERNAL)\n \t\tpgm = NULL;\n \n \tif (DIFF_PAIR_UNMERGED(p)) {\n@@ -4207,10 +4207,10 @@ void diff_setup_done(struct diff_options *options)\n \telse\n \t\tDIFF_OPT_CLR(options, DIFF_FROM_CONTENTS);\n \n-\tif (DIFF_OPT_TST(options, FIND_COPIES_HARDER))\n+\tif (options->flags.FIND_COPIES_HARDER)\n \t\toptions->detect_rename = DIFF_DETECT_COPY;\n \n-\tif (!DIFF_OPT_TST(options, RELATIVE_NAME))\n+\tif (!options->flags.RELATIVE_NAME)\n \t\toptions->prefix = NULL;\n \tif (options->prefix)\n \t\toptions->prefix_length = strlen(options->prefix);\n@@ -4273,14 +4273,14 @@ void diff_setup_done(struct diff_options *options)\n \t * to have found.  It does not make sense not to return with\n \t * exit code in such a case either.\n \t */\n-\tif (DIFF_OPT_TST(options, QUICK)) {\n+\tif (options->flags.QUICK) {\n \t\toptions->output_format = DIFF_FORMAT_NO_OUTPUT;\n \t\tDIFF_OPT_SET(options, EXIT_WITH_STATUS);\n \t}\n \n \toptions->diff_path_counter = 0;\n \n-\tif (DIFF_OPT_TST(options, FOLLOW_RENAMES) && options->pathspec.nr != 1)\n+\tif (options->flags.FOLLOW_RENAMES && options->pathspec.nr != 1)\n \t\tdie(_(\"--follow requires exactly one pathspec\"));\n \n \tif (!options->use_color || external_diff())\n@@ -5601,7 +5601,7 @@ void diff_flush(struct diff_options *options)\n \t\tseparator++;\n \t}\n \n-\tif (output_format & DIFF_FORMAT_DIRSTAT && DIFF_OPT_TST(options, DIRSTAT_BY_LINE))\n+\tif (output_format & DIFF_FORMAT_DIRSTAT && options->flags.DIRSTAT_BY_LINE)\n \t\tdirstat_by_line = 1;\n \n \tif (output_format & (DIFF_FORMAT_DIFFSTAT|DIFF_FORMAT_SHORTSTAT|DIFF_FORMAT_NUMSTAT) ||\n@@ -5636,8 +5636,8 @@ void diff_flush(struct diff_options *options)\n \t}\n \n \tif (output_format & DIFF_FORMAT_NO_OUTPUT &&\n-\t    DIFF_OPT_TST(options, EXIT_WITH_STATUS) &&\n-\t    DIFF_OPT_TST(options, DIFF_FROM_CONTENTS)) {\n+\t    options->flags.EXIT_WITH_STATUS &&\n+\t    options->flags.DIFF_FROM_CONTENTS) {\n \t\t/*\n \t\t * run diff_flush_patch for the exit status. setting\n \t\t * options->file to /dev/null should be safe, because we\n@@ -5685,7 +5685,7 @@ void diff_flush(struct diff_options *options)\n \t * diff_addremove/diff_change does not set the bit when\n \t * DIFF_FROM_CONTENTS is in effect (e.g. with -w).\n \t */\n-\tif (DIFF_OPT_TST(options, DIFF_FROM_CONTENTS)) {\n+\tif (options->flags.DIFF_FROM_CONTENTS) {\n \t\tif (options->found_changes)\n \t\t\tDIFF_OPT_SET(options, HAS_CHANGES);\n \t\telse\n@@ -5809,7 +5809,7 @@ static void diffcore_skip_stat_unmatch(struct diff_options *diffopt)\n \t\t\t * to determine how many paths were dirty only\n \t\t\t * due to stat info mismatch.\n \t\t\t */\n-\t\t\tif (!DIFF_OPT_TST(diffopt, NO_INDEX))\n+\t\t\tif (!diffopt->flags.NO_INDEX)\n \t\t\t\tdiffopt->skip_stat_unmatch++;\n \t\t\tdiff_free_filepair(p);\n \t\t}\n@@ -5858,7 +5858,7 @@ void diffcore_std(struct diff_options *options)\n \t\tdiff_resolve_rename_copy();\n \tdiffcore_apply_filter(options);\n \n-\tif (diff_queued_diff.nr && !DIFF_OPT_TST(options, DIFF_FROM_CONTENTS))\n+\tif (diff_queued_diff.nr && !options->flags.DIFF_FROM_CONTENTS)\n \t\tDIFF_OPT_SET(options, HAS_CHANGES);\n \telse\n \t\tDIFF_OPT_CLR(options, HAS_CHANGES);\n@@ -5873,23 +5873,23 @@ int diff_result_code(struct diff_options *opt, int status)\n \tdiff_warn_rename_limit(\"diff.renameLimit\",\n \t\t\t       opt->needed_rename_limit,\n \t\t\t       opt->degraded_cc_to_c);\n-\tif (!DIFF_OPT_TST(opt, EXIT_WITH_STATUS) &&\n+\tif (!opt->flags.EXIT_WITH_STATUS &&\n \t    !(opt->output_format & DIFF_FORMAT_CHECKDIFF))\n \t\treturn status;\n-\tif (DIFF_OPT_TST(opt, EXIT_WITH_STATUS) &&\n-\t    DIFF_OPT_TST(opt, HAS_CHANGES))\n+\tif (opt->flags.EXIT_WITH_STATUS &&\n+\t    opt->flags.HAS_CHANGES)\n \t\tresult |= 01;\n \tif ((opt->output_format & DIFF_FORMAT_CHECKDIFF) &&\n-\t    DIFF_OPT_TST(opt, CHECK_FAILED))\n+\t    opt->flags.CHECK_FAILED)\n \t\tresult |= 02;\n \treturn result;\n }\n \n int diff_can_quit_early(struct diff_options *opt)\n {\n-\treturn (DIFF_OPT_TST(opt, QUICK) &&\n+\treturn (opt->flags.QUICK &&\n \t\t!opt->filter &&\n-\t\tDIFF_OPT_TST(opt, HAS_CHANGES));\n+\t\topt->flags.HAS_CHANGES);\n }\n \n /*\n@@ -5902,9 +5902,9 @@ static int is_submodule_ignored(const char *path, struct diff_options *options)\n {\n \tint ignored = 0;\n \tstruct diff_flags orig_flags = options->flags;\n-\tif (!DIFF_OPT_TST(options, OVERRIDE_SUBMODULE_CONFIG))\n+\tif (!options->flags.OVERRIDE_SUBMODULE_CONFIG)\n \t\tset_diffopt_flags_from_submodule_config(options, path);\n-\tif (DIFF_OPT_TST(options, IGNORE_SUBMODULES))\n+\tif (options->flags.IGNORE_SUBMODULES)\n \t\tignored = 1;\n \toptions->flags = orig_flags;\n \treturn ignored;\n@@ -5933,7 +5933,7 @@ void diff_addremove(struct diff_options *options,\n \t * Before the final output happens, they are pruned after\n \t * merged into rename/copy pairs as appropriate.\n \t */\n-\tif (DIFF_OPT_TST(options, REVERSE_DIFF))\n+\tif (options->flags.REVERSE_DIFF)\n \t\taddremove = (addremove == '+' ? '-' :\n \t\t\t     addremove == '-' ? '+' : addremove);\n \n@@ -5952,7 +5952,7 @@ void diff_addremove(struct diff_options *options,\n \t}\n \n \tdiff_queue(&diff_queued_diff, one, two);\n-\tif (!DIFF_OPT_TST(options, DIFF_FROM_CONTENTS))\n+\tif (!options->flags.DIFF_FROM_CONTENTS)\n \t\tDIFF_OPT_SET(options, HAS_CHANGES);\n }\n \n@@ -5971,7 +5971,7 @@ void diff_change(struct diff_options *options,\n \t    is_submodule_ignored(concatpath, options))\n \t\treturn;\n \n-\tif (DIFF_OPT_TST(options, REVERSE_DIFF)) {\n+\tif (options->flags.REVERSE_DIFF) {\n \t\tSWAP(old_mode, new_mode);\n \t\tSWAP(old_oid, new_oid);\n \t\tSWAP(old_oid_valid, new_oid_valid);\n@@ -5990,10 +5990,10 @@ void diff_change(struct diff_options *options,\n \ttwo->dirty_submodule = new_dirty_submodule;\n \tp = diff_queue(&diff_queued_diff, one, two);\n \n-\tif (DIFF_OPT_TST(options, DIFF_FROM_CONTENTS))\n+\tif (options->flags.DIFF_FROM_CONTENTS)\n \t\treturn;\n \n-\tif (DIFF_OPT_TST(options, QUICK) && options->skip_stat_unmatch &&\n+\tif (options->flags.QUICK && options->skip_stat_unmatch &&\n \t    !diff_filespec_check_stat_unmatch(p))\n \t\treturn;\n \n@@ -6135,7 +6135,7 @@ void setup_diff_pager(struct diff_options *opt)\n \t * and because it is easy to find people oneline advising \"git diff\n \t * --exit-code\" in hooks and other scripts, we do not do so.\n \t */\n-\tif (!DIFF_OPT_TST(opt, EXIT_WITH_STATUS) &&\n+\tif (!opt->flags.EXIT_WITH_STATUS &&\n \t    check_pager_config(\"diff\") != 0)\n \t\tsetup_pager();\n }\ndiff --git a/diff.h b/diff.h\nindex 7e567108e..a3656ff5b 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -110,7 +110,6 @@ static inline struct diff_flags diff_flags_or(const struct diff_flags *a,\n \treturn out;\n }\n \n-#define DIFF_OPT_TST(opts, flag)\t((opts)->flags.flag)\n #define DIFF_OPT_SET(opts, flag)\t((opts)->flags.flag = 1)\n #define DIFF_OPT_CLR(opts, flag)\t((opts)->flags.flag = 0)\n \ndiff --git a/diffcore-pickaxe.c b/diffcore-pickaxe.c\nindex 341529b5a..6193c07f6 100644\n--- a/diffcore-pickaxe.c\n+++ b/diffcore-pickaxe.c\n@@ -131,7 +131,7 @@ static int pickaxe_match(struct diff_filepair *p, struct diff_options *o,\n \tif (!DIFF_FILE_VALID(p->one) && !DIFF_FILE_VALID(p->two))\n \t\treturn 0;\n \n-\tif (DIFF_OPT_TST(o, ALLOW_TEXTCONV)) {\n+\tif (o->flags.ALLOW_TEXTCONV) {\n \t\ttextconv_one = get_textconv(p->one);\n \t\ttextconv_two = get_textconv(p->two);\n \t}\n@@ -222,11 +222,11 @@ void diffcore_pickaxe(struct diff_options *o)\n \n \tif (opts & (DIFF_PICKAXE_REGEX | DIFF_PICKAXE_KIND_G)) {\n \t\tint cflags = REG_EXTENDED | REG_NEWLINE;\n-\t\tif (DIFF_OPT_TST(o, PICKAXE_IGNORE_CASE))\n+\t\tif (o->flags.PICKAXE_IGNORE_CASE)\n \t\t\tcflags |= REG_ICASE;\n \t\tregcomp_or_die(&regex, needle, cflags);\n \t\tregexp = &regex;\n-\t} else if (DIFF_OPT_TST(o, PICKAXE_IGNORE_CASE) &&\n+\t} else if (o->flags.PICKAXE_IGNORE_CASE &&\n \t\t   has_non_ascii(needle)) {\n \t\tstruct strbuf sb = STRBUF_INIT;\n \t\tint cflags = REG_NEWLINE | REG_ICASE;\n@@ -236,7 +236,7 @@ void diffcore_pickaxe(struct diff_options *o)\n \t\tstrbuf_release(&sb);\n \t\tregexp = &regex;\n \t} else {\n-\t\tkws = kwsalloc(DIFF_OPT_TST(o, PICKAXE_IGNORE_CASE)\n+\t\tkws = kwsalloc(o->flags.PICKAXE_IGNORE_CASE\n \t\t\t       ? tolower_trans_tbl : NULL);\n \t\tkwsincr(kws, needle, strlen(needle));\n \t\tkwsprep(kws);\ndiff --git a/diffcore-rename.c b/diffcore-rename.c\nindex 0d8c3d2ee..bd077ee11 100644\n--- a/diffcore-rename.c\n+++ b/diffcore-rename.c\n@@ -405,7 +405,7 @@ static int too_many_rename_candidates(int num_create,\n \t\tnum_src > num_create ? num_src : num_create;\n \n \t/* Are we running under -C -C? */\n-\tif (!DIFF_OPT_TST(options, FIND_COPIES_HARDER))\n+\tif (!options->flags.FIND_COPIES_HARDER)\n \t\treturn 1;\n \n \t/* Would we bust the limit if we were running under -C? */\n@@ -463,7 +463,7 @@ void diffcore_rename(struct diff_options *options)\n \t\t\telse if (options->single_follow &&\n \t\t\t\t strcmp(options->single_follow, p->two->path))\n \t\t\t\tcontinue; /* not interested */\n-\t\t\telse if (!DIFF_OPT_TST(options, RENAME_EMPTY) &&\n+\t\t\telse if (!options->flags.RENAME_EMPTY &&\n \t\t\t\t is_empty_blob_oid(&p->two->oid))\n \t\t\t\tcontinue;\n \t\t\telse if (add_rename_dst(p->two) < 0) {\n@@ -473,7 +473,7 @@ void diffcore_rename(struct diff_options *options)\n \t\t\t\tgoto cleanup;\n \t\t\t}\n \t\t}\n-\t\telse if (!DIFF_OPT_TST(options, RENAME_EMPTY) &&\n+\t\telse if (!options->flags.RENAME_EMPTY &&\n \t\t\t is_empty_blob_oid(&p->one->oid))\n \t\t\tcontinue;\n \t\telse if (!DIFF_PAIR_UNMERGED(p) && !DIFF_FILE_VALID(p->two)) {\ndiff --git a/log-tree.c b/log-tree.c\nindex cea056234..460bb5498 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -793,7 +793,7 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log\n \tstruct commit_list *parents;\n \tstruct object_id *oid;\n \n-\tif (!opt->diff && !DIFF_OPT_TST(&opt->diffopt, EXIT_WITH_STATUS))\n+\tif (!opt->diff && !opt->diffopt.flags.EXIT_WITH_STATUS)\n \t\treturn 0;\n \n \tparse_commit_or_die(commit);\ndiff --git a/revision.c b/revision.c\nindex d167223e6..c893d9166 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -2399,7 +2399,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s\n \t/* Pickaxe, diff-filter and rename following need diffs */\n \tif (revs->diffopt.pickaxe ||\n \t    revs->diffopt.filter ||\n-\t    DIFF_OPT_TST(&revs->diffopt, FOLLOW_RENAMES))\n+\t    revs->diffopt.flags.FOLLOW_RENAMES)\n \t\trevs->diff = 1;\n \n \tif (revs->topo_order)\n@@ -2408,7 +2408,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s\n \tif (revs->prune_data.nr) {\n \t\tcopy_pathspec(&revs->pruning.pathspec, &revs->prune_data);\n \t\t/* Can't prune commits with rename following: the paths change.. */\n-\t\tif (!DIFF_OPT_TST(&revs->diffopt, FOLLOW_RENAMES))\n+\t\tif (!revs->diffopt.flags.FOLLOW_RENAMES)\n \t\t\trevs->prune = 1;\n \t\tif (!revs->full_diff)\n \t\t\tcopy_pathspec(&revs->diffopt.pathspec,\ndiff --git a/submodule.c b/submodule.c\nindex 63e7094e1..58da9c668 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -616,7 +616,7 @@ void show_submodule_inline_diff(struct diff_options *o, const char *path,\n \targv_array_pushf(&cp.args, \"--color=%s\", want_color(o->use_color) ?\n \t\t\t \"always\" : \"never\");\n \n-\tif (DIFF_OPT_TST(o, REVERSE_DIFF)) {\n+\tif (o->flags.REVERSE_DIFF) {\n \t\targv_array_pushf(&cp.args, \"--src-prefix=%s%s/\",\n \t\t\t\t o->b_prefix, path);\n \t\targv_array_pushf(&cp.args, \"--dst-prefix=%s%s/\",\ndiff --git a/tree-diff.c b/tree-diff.c\nindex 4bb93155b..ed0aa6a62 100644\n--- a/tree-diff.c\n+++ b/tree-diff.c\n@@ -212,9 +212,9 @@ static struct combine_diff_path *emit_path(struct combine_diff_path *p,\n \t\tmode = 0;\n \t}\n \n-\tif (DIFF_OPT_TST(opt, RECURSIVE) && isdir) {\n+\tif (opt->flags.RECURSIVE && isdir) {\n \t\trecurse = 1;\n-\t\temitthis = DIFF_OPT_TST(opt, TREE_IN_RECURSIVE);\n+\t\temitthis = opt->flags.TREE_IN_RECURSIVE;\n \t}\n \n \tif (emitthis) {\n@@ -425,7 +425,7 @@ static struct combine_diff_path *ll_diff_tree_paths(\n \tttree = fill_tree_descriptor(&t, oid);\n \n \t/* Enable recursion indefinitely */\n-\topt->pathspec.recursive = DIFF_OPT_TST(opt, RECURSIVE);\n+\topt->pathspec.recursive = opt->flags.RECURSIVE;\n \n \tfor (;;) {\n \t\tint imin, cmp;\n@@ -484,7 +484,7 @@ static struct combine_diff_path *ll_diff_tree_paths(\n \t\t/* t = p[imin] */\n \t\tif (cmp == 0) {\n \t\t\t/* are either pi > p[imin] or diff(t,pi) != ø ? */\n-\t\t\tif (!DIFF_OPT_TST(opt, FIND_COPIES_HARDER)) {\n+\t\t\tif (!opt->flags.FIND_COPIES_HARDER) {\n \t\t\t\tfor (i = 0; i < nparent; ++i) {\n \t\t\t\t\t/* p[i] > p[imin] */\n \t\t\t\t\tif (tp[i].entry.mode & S_IFXMIN_NEQ)\n@@ -522,7 +522,7 @@ static struct combine_diff_path *ll_diff_tree_paths(\n \t\t/* t > p[imin] */\n \t\telse {\n \t\t\t/* ∀i pi=p[imin] -> D += \"-p[imin]\" */\n-\t\t\tif (!DIFF_OPT_TST(opt, FIND_COPIES_HARDER)) {\n+\t\t\tif (!opt->flags.FIND_COPIES_HARDER) {\n \t\t\t\tfor (i = 0; i < nparent; ++i)\n \t\t\t\t\tif (tp[i].entry.mode & S_IFXMIN_NEQ)\n \t\t\t\t\t\tgoto skip_emit_tp;\n@@ -706,7 +706,7 @@ int diff_tree_oid(const struct object_id *old_oid,\n \tstrbuf_addstr(&base, base_str);\n \n \tretval = ll_diff_tree_oid(old_oid, new_oid, &base, opt);\n-\tif (!*base_str && DIFF_OPT_TST(opt, FOLLOW_RENAMES) && diff_might_be_rename())\n+\tif (!*base_str && opt->flags.FOLLOW_RENAMES && diff_might_be_rename())\n \t\ttry_to_follow_renames(old_oid, new_oid, &base, opt);\n \n \tstrbuf_release(&base);\n-- \n2.15.0.403.gc27cc4dac6-goog\n\n"},{"id":"331417","messageId":"20171030221956.92466-3-bmwill@google.com","threadId":"47047","inReplyTo":"20171030221956.92466-1-bmwill@google.com","subject":"[PATCH v2 7/4] diff: remove DIFF_OPT_CLR macro","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-10-30T22:19:55Z","receivedAt":"2017-10-30T22:20:24Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"Remove the `DIFF_OPT_SET` macro and instead set the flags directly.\nThis conversion is done using the following semantic patch:\n\n\t@@\n\texpression E;\n\tidentifier fld;\n\t@@\n\t- DIFF_OPT_CLR(&E, fld)\n\t+ E.flags.fld = 0\n\n\t@@\n\ttype T;\n\tT *ptr;\n\tidentifier fld;\n\t@@\n\t- DIFF_OPT_CLR(ptr, fld)\n\t+ ptr->flags.fld = 0\n\nSigned-off-by: Brandon Williams <bmwill@google.com>\n---\n builtin/blame.c   |  2 +-\n combine-diff.c    |  2 +-\n diff.c            | 30 +++++++++++++++---------------\n diff.h            |  2 --\n merge-recursive.c |  2 +-\n revision.c        |  4 ++--\n submodule.c       |  6 +++---\n 7 files changed, 23 insertions(+), 25 deletions(-)\n\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex 76994aa64..79db9e849 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -736,7 +736,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)\n parse_done:\n \tno_whole_file_rename = !revs.diffopt.flags.FOLLOW_RENAMES;\n \txdl_opts |= revs.diffopt.xdl_opts & XDF_INDENT_HEURISTIC;\n-\tDIFF_OPT_CLR(&revs.diffopt, FOLLOW_RENAMES);\n+\trevs.diffopt.flags.FOLLOW_RENAMES = 0;\n \targc = parse_options_end(&ctx);\n \n \tif (incremental || (output_option & OUTPUT_PORCELAIN)) {\ndiff --git a/combine-diff.c b/combine-diff.c\nindex 204b0dfce..5a3a8b49b 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -1414,7 +1414,7 @@ void diff_tree_combined(const struct object_id *oid,\n \tdiffopts = *opt;\n \tcopy_pathspec(&diffopts.pathspec, &opt->pathspec);\n \tdiffopts.flags.RECURSIVE = 1;\n-\tDIFF_OPT_CLR(&diffopts, ALLOW_EXTERNAL);\n+\tdiffopts.flags.ALLOW_EXTERNAL = 0;\n \n \t/* find set of paths that everybody touches\n \t *\ndiff --git a/diff.c b/diff.c\nindex 16d33c319..0e5abb5ce 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -124,16 +124,16 @@ static int parse_dirstat_params(struct diff_options *options, const char *params\n \tfor (i = 0; i < params.nr; i++) {\n \t\tconst char *p = params.items[i].string;\n \t\tif (!strcmp(p, \"changes\")) {\n-\t\t\tDIFF_OPT_CLR(options, DIRSTAT_BY_LINE);\n-\t\t\tDIFF_OPT_CLR(options, DIRSTAT_BY_FILE);\n+\t\t\toptions->flags.DIRSTAT_BY_LINE = 0;\n+\t\t\toptions->flags.DIRSTAT_BY_FILE = 0;\n \t\t} else if (!strcmp(p, \"lines\")) {\n \t\t\toptions->flags.DIRSTAT_BY_LINE = 1;\n-\t\t\tDIFF_OPT_CLR(options, DIRSTAT_BY_FILE);\n+\t\t\toptions->flags.DIRSTAT_BY_FILE = 0;\n \t\t} else if (!strcmp(p, \"files\")) {\n-\t\t\tDIFF_OPT_CLR(options, DIRSTAT_BY_LINE);\n+\t\t\toptions->flags.DIRSTAT_BY_LINE = 0;\n \t\t\toptions->flags.DIRSTAT_BY_FILE = 1;\n \t\t} else if (!strcmp(p, \"noncumulative\")) {\n-\t\t\tDIFF_OPT_CLR(options, DIRSTAT_CUMULATIVE);\n+\t\t\toptions->flags.DIRSTAT_CUMULATIVE = 0;\n \t\t} else if (!strcmp(p, \"cumulative\")) {\n \t\t\toptions->flags.DIRSTAT_CUMULATIVE = 1;\n \t\t} else if (isdigit(*p)) {\n@@ -4205,7 +4205,7 @@ void diff_setup_done(struct diff_options *options)\n \t    DIFF_XDL_TST(options, IGNORE_WHITESPACE_AT_EOL))\n \t\toptions->flags.DIFF_FROM_CONTENTS = 1;\n \telse\n-\t\tDIFF_OPT_CLR(options, DIFF_FROM_CONTENTS);\n+\t\toptions->flags.DIFF_FROM_CONTENTS = 0;\n \n \tif (options->flags.FIND_COPIES_HARDER)\n \t\toptions->detect_rename = DIFF_DETECT_COPY;\n@@ -4640,7 +4640,7 @@ int diff_opt_parse(struct diff_options *options,\n \telse if (!strcmp(arg, \"--rename-empty\"))\n \t\toptions->flags.RENAME_EMPTY = 1;\n \telse if (!strcmp(arg, \"--no-rename-empty\"))\n-\t\tDIFF_OPT_CLR(options, RENAME_EMPTY);\n+\t\toptions->flags.RENAME_EMPTY = 0;\n \telse if (!strcmp(arg, \"--relative\"))\n \t\toptions->flags.RELATIVE_NAME = 1;\n \telse if (skip_prefix(arg, \"--relative=\", &arg)) {\n@@ -4697,8 +4697,8 @@ int diff_opt_parse(struct diff_options *options,\n \telse if (!strcmp(arg, \"--follow\"))\n \t\toptions->flags.FOLLOW_RENAMES = 1;\n \telse if (!strcmp(arg, \"--no-follow\")) {\n-\t\tDIFF_OPT_CLR(options, FOLLOW_RENAMES);\n-\t\tDIFF_OPT_CLR(options, DEFAULT_FOLLOW_RENAMES);\n+\t\toptions->flags.FOLLOW_RENAMES = 0;\n+\t\toptions->flags.DEFAULT_FOLLOW_RENAMES = 0;\n \t} else if (!strcmp(arg, \"--color\"))\n \t\toptions->use_color = 1;\n \telse if (skip_prefix(arg, \"--color=\", &arg)) {\n@@ -4761,13 +4761,13 @@ int diff_opt_parse(struct diff_options *options,\n \telse if (!strcmp(arg, \"--ext-diff\"))\n \t\toptions->flags.ALLOW_EXTERNAL = 1;\n \telse if (!strcmp(arg, \"--no-ext-diff\"))\n-\t\tDIFF_OPT_CLR(options, ALLOW_EXTERNAL);\n+\t\toptions->flags.ALLOW_EXTERNAL = 0;\n \telse if (!strcmp(arg, \"--textconv\")) {\n \t\toptions->flags.ALLOW_TEXTCONV = 1;\n \t\toptions->flags.TEXTCONV_SET_VIA_CMDLINE = 1;\n \t} else if (!strcmp(arg, \"--no-textconv\")) {\n-\t\tDIFF_OPT_CLR(options, ALLOW_TEXTCONV);\n-\t\tDIFF_OPT_CLR(options, TEXTCONV_SET_VIA_CMDLINE);\n+\t\toptions->flags.ALLOW_TEXTCONV = 0;\n+\t\toptions->flags.TEXTCONV_SET_VIA_CMDLINE = 0;\n \t} else if (!strcmp(arg, \"--ignore-submodules\")) {\n \t\toptions->flags.OVERRIDE_SUBMODULE_CONFIG = 1;\n \t\thandle_ignore_submodules_arg(options, \"all\");\n@@ -4851,7 +4851,7 @@ int diff_opt_parse(struct diff_options *options,\n \telse if (!strcmp(arg, \"--function-context\"))\n \t\toptions->flags.FUNCCONTEXT = 1;\n \telse if (!strcmp(arg, \"--no-function-context\"))\n-\t\tDIFF_OPT_CLR(options, FUNCCONTEXT);\n+\t\toptions->flags.FUNCCONTEXT = 0;\n \telse if ((argcount = parse_long_opt(\"output\", av, &optarg))) {\n \t\tchar *path = prefix_filename(prefix, optarg);\n \t\toptions->file = xfopen(path, \"w\");\n@@ -5689,7 +5689,7 @@ void diff_flush(struct diff_options *options)\n \t\tif (options->found_changes)\n \t\t\toptions->flags.HAS_CHANGES = 1;\n \t\telse\n-\t\t\tDIFF_OPT_CLR(options, HAS_CHANGES);\n+\t\t\toptions->flags.HAS_CHANGES = 0;\n \t}\n }\n \n@@ -5861,7 +5861,7 @@ void diffcore_std(struct diff_options *options)\n \tif (diff_queued_diff.nr && !options->flags.DIFF_FROM_CONTENTS)\n \t\toptions->flags.HAS_CHANGES = 1;\n \telse\n-\t\tDIFF_OPT_CLR(options, HAS_CHANGES);\n+\t\toptions->flags.HAS_CHANGES = 0;\n \n \toptions->found_follow = 0;\n }\ndiff --git a/diff.h b/diff.h\nindex 4c1af4be6..f68fcf737 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -110,8 +110,6 @@ static inline struct diff_flags diff_flags_or(const struct diff_flags *a,\n \treturn out;\n }\n \n-#define DIFF_OPT_CLR(opts, flag)\t((opts)->flags.flag = 0)\n-\n #define DIFF_XDL_TST(opts, flag)    ((opts)->xdl_opts & XDF_##flag)\n #define DIFF_XDL_SET(opts, flag)    ((opts)->xdl_opts |= XDF_##flag)\n #define DIFF_XDL_CLR(opts, flag)    ((opts)->xdl_opts &= ~XDF_##flag)\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex e7b3df45c..9752aba4e 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -541,7 +541,7 @@ static struct string_list *get_renames(struct merge_options *o,\n \n \tdiff_setup(&opts);\n \topts.flags.RECURSIVE = 1;\n-\tDIFF_OPT_CLR(&opts, RENAME_EMPTY);\n+\topts.flags.RENAME_EMPTY = 0;\n \topts.detect_rename = DIFF_DETECT_RENAME;\n \topts.rename_limit = o->merge_rename_limit >= 0 ? o->merge_rename_limit :\n \t\t\t    o->diff_rename_limit >= 0 ? o->diff_rename_limit :\ndiff --git a/revision.c b/revision.c\nindex f019dd277..6bb873501 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -455,7 +455,7 @@ static int rev_compare_tree(struct rev_info *revs,\n \t}\n \n \ttree_difference = REV_TREE_SAME;\n-\tDIFF_OPT_CLR(&revs->pruning, HAS_CHANGES);\n+\trevs->pruning.flags.HAS_CHANGES = 0;\n \tif (diff_tree_oid(&t1->object.oid, &t2->object.oid, \"\",\n \t\t\t   &revs->pruning) < 0)\n \t\treturn REV_TREE_DIFFERENT;\n@@ -471,7 +471,7 @@ static int rev_same_tree_as_empty(struct rev_info *revs, struct commit *commit)\n \t\treturn 0;\n \n \ttree_difference = REV_TREE_SAME;\n-\tDIFF_OPT_CLR(&revs->pruning, HAS_CHANGES);\n+\trevs->pruning.flags.HAS_CHANGES = 0;\n \tretval = diff_tree_oid(NULL, &t1->object.oid, \"\", &revs->pruning);\n \n \treturn retval >= 0 && (tree_difference == REV_TREE_SAME);\ndiff --git a/submodule.c b/submodule.c\nindex 7e7998592..62a93bb88 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -402,9 +402,9 @@ const char *submodule_strategy_to_string(const struct submodule_update_strategy\n void handle_ignore_submodules_arg(struct diff_options *diffopt,\n \t\t\t\t  const char *arg)\n {\n-\tDIFF_OPT_CLR(diffopt, IGNORE_SUBMODULES);\n-\tDIFF_OPT_CLR(diffopt, IGNORE_UNTRACKED_IN_SUBMODULES);\n-\tDIFF_OPT_CLR(diffopt, IGNORE_DIRTY_SUBMODULES);\n+\tdiffopt->flags.IGNORE_SUBMODULES = 0;\n+\tdiffopt->flags.IGNORE_UNTRACKED_IN_SUBMODULES = 0;\n+\tdiffopt->flags.IGNORE_DIRTY_SUBMODULES = 0;\n \n \tif (!strcmp(arg, \"all\"))\n \t\tdiffopt->flags.IGNORE_SUBMODULES = 1;\n-- \n2.15.0.403.gc27cc4dac6-goog\n\n"},{"id":"331418","messageId":"20171030221956.92466-2-bmwill@google.com","threadId":"47047","inReplyTo":"20171030221956.92466-1-bmwill@google.com","subject":"[PATCH v2 6/4] diff: remove DIFF_OPT_SET macro","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-10-30T22:19:54Z","receivedAt":"2017-10-30T22:20:26Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"Remove the `DIFF_OPT_SET` macro and instead set the flags directly.\nThis conversion is done using the following semantic patch:\n\n\t@@\n\texpression E;\n\tidentifier fld;\n\t@@\n\t- DIFF_OPT_SET(&E, fld)\n\t+ E.flags.fld = 1\n\n\t@@\n\ttype T;\n\tT *ptr;\n\tidentifier fld;\n\t@@\n\t- DIFF_OPT_SET(ptr, fld)\n\t+ ptr->flags.fld = 1\n\nSigned-off-by: Brandon Williams <bmwill@google.com>\n---\n blame.c               |  8 +++----\n builtin/add.c         |  4 ++--\n builtin/am.c          |  8 +++----\n builtin/blame.c       |  4 ++--\n builtin/diff.c        |  6 ++---\n builtin/fast-export.c |  2 +-\n builtin/log.c         | 14 +++++------\n builtin/reset.c       |  2 +-\n combine-diff.c        |  2 +-\n diff-lib.c            |  4 ++--\n diff-no-index.c       |  6 ++---\n diff.c                | 66 +++++++++++++++++++++++++--------------------------\n diff.h                |  1 -\n merge-recursive.c     |  2 +-\n notes-merge.c         |  4 ++--\n patch-ids.c           |  2 +-\n revision.c            | 16 ++++++-------\n submodule.c           |  8 +++----\n tree-diff.c           |  4 ++--\n wt-status.c           | 18 +++++++-------\n 20 files changed, 90 insertions(+), 91 deletions(-)\n\ndiff --git a/blame.c b/blame.c\nindex 7c019bc7c..dc9cc237b 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -541,7 +541,7 @@ static struct blame_origin *find_origin(struct commit *parent,\n \t * same and diff-tree is fairly efficient about this.\n \t */\n \tdiff_setup(&diff_opts);\n-\tDIFF_OPT_SET(&diff_opts, RECURSIVE);\n+\tdiff_opts.flags.RECURSIVE = 1;\n \tdiff_opts.detect_rename = 0;\n \tdiff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;\n \tpaths[0] = origin->path;\n@@ -615,7 +615,7 @@ static struct blame_origin *find_rename(struct commit *parent,\n \tint i;\n \n \tdiff_setup(&diff_opts);\n-\tDIFF_OPT_SET(&diff_opts, RECURSIVE);\n+\tdiff_opts.flags.RECURSIVE = 1;\n \tdiff_opts.detect_rename = DIFF_DETECT_RENAME;\n \tdiff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;\n \tdiff_opts.single_follow = origin->path;\n@@ -1238,7 +1238,7 @@ static void find_copy_in_parent(struct blame_scoreboard *sb,\n \t\treturn; /* nothing remains for this target */\n \n \tdiff_setup(&diff_opts);\n-\tDIFF_OPT_SET(&diff_opts, RECURSIVE);\n+\tdiff_opts.flags.RECURSIVE = 1;\n \tdiff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;\n \n \tdiff_setup_done(&diff_opts);\n@@ -1253,7 +1253,7 @@ static void find_copy_in_parent(struct blame_scoreboard *sb,\n \tif ((opt & PICKAXE_BLAME_COPY_HARDEST)\n \t    || ((opt & PICKAXE_BLAME_COPY_HARDER)\n \t\t&& (!porigin || strcmp(target->path, porigin->path))))\n-\t\tDIFF_OPT_SET(&diff_opts, FIND_COPIES_HARDER);\n+\t\tdiff_opts.flags.FIND_COPIES_HARDER = 1;\n \n \tif (is_null_oid(&target->commit->object.oid))\n \t\tdo_diff_cache(&parent->tree->object.oid, &diff_opts);\ndiff --git a/builtin/add.c b/builtin/add.c\nindex b70e8a779..e1d83b69a 100644\n--- a/builtin/add.c\n+++ b/builtin/add.c\n@@ -116,7 +116,7 @@ int add_files_to_cache(const char *prefix,\n \trev.diffopt.output_format = DIFF_FORMAT_CALLBACK;\n \trev.diffopt.format_callback = update_callback;\n \trev.diffopt.format_callback_data = &data;\n-\tDIFF_OPT_SET(&rev.diffopt, OVERRIDE_SUBMODULE_CONFIG);\n+\trev.diffopt.flags.OVERRIDE_SUBMODULE_CONFIG = 1;\n \trev.max_count = 0; /* do not compare unmerged paths with stage #2 */\n \trun_diff_files(&rev, DIFF_RACY_IS_MODIFIED);\n \tclear_pathspec(&rev.prune_data);\n@@ -218,7 +218,7 @@ static int edit_patch(int argc, const char **argv, const char *prefix)\n \targc = setup_revisions(argc, argv, &rev, NULL);\n \trev.diffopt.output_format = DIFF_FORMAT_PATCH;\n \trev.diffopt.use_color = 0;\n-\tDIFF_OPT_SET(&rev.diffopt, IGNORE_DIRTY_SUBMODULES);\n+\trev.diffopt.flags.IGNORE_DIRTY_SUBMODULES = 1;\n \tout = open(file, O_CREAT | O_WRONLY, 0666);\n \tif (out < 0)\n \t\tdie(_(\"Could not open '%s' for writing.\"), file);\ndiff --git a/builtin/am.c b/builtin/am.c\nindex fc54724cc..015425a0f 100644\n--- a/builtin/am.c\n+++ b/builtin/am.c\n@@ -1157,9 +1157,9 @@ static int index_has_changes(struct strbuf *sb)\n \t\tstruct diff_options opt;\n \n \t\tdiff_setup(&opt);\n-\t\tDIFF_OPT_SET(&opt, EXIT_WITH_STATUS);\n+\t\topt.flags.EXIT_WITH_STATUS = 1;\n \t\tif (!sb)\n-\t\t\tDIFF_OPT_SET(&opt, QUICK);\n+\t\t\topt.flags.QUICK = 1;\n \t\tdo_diff_cache(&head, &opt);\n \t\tdiffcore_std(&opt);\n \t\tfor (i = 0; sb && i < diff_queued_diff.nr; i++) {\n@@ -1409,8 +1409,8 @@ static void write_commit_patch(const struct am_state *state, struct commit *comm\n \trev_info.show_root_diff = 1;\n \trev_info.diffopt.output_format = DIFF_FORMAT_PATCH;\n \trev_info.no_commit_id = 1;\n-\tDIFF_OPT_SET(&rev_info.diffopt, BINARY);\n-\tDIFF_OPT_SET(&rev_info.diffopt, FULL_INDEX);\n+\trev_info.diffopt.flags.BINARY = 1;\n+\trev_info.diffopt.flags.FULL_INDEX = 1;\n \trev_info.diffopt.use_color = 0;\n \trev_info.diffopt.file = fp;\n \trev_info.diffopt.close_file = 1;\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex a29574984..76994aa64 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -708,8 +708,8 @@ int cmd_blame(int argc, const char **argv, const char *prefix)\n \tgit_config(git_blame_config, &output_option);\n \tinit_revisions(&revs, NULL);\n \trevs.date_mode = blame_date_mode;\n-\tDIFF_OPT_SET(&revs.diffopt, ALLOW_TEXTCONV);\n-\tDIFF_OPT_SET(&revs.diffopt, FOLLOW_RENAMES);\n+\trevs.diffopt.flags.ALLOW_TEXTCONV = 1;\n+\trevs.diffopt.flags.FOLLOW_RENAMES = 1;\n \n \tsave_commit_buffer = 0;\n \tdashdash_pos = 0;\ndiff --git a/builtin/diff.c b/builtin/diff.c\nindex 8cbaf4538..ed41eb5a5 100644\n--- a/builtin/diff.c\n+++ b/builtin/diff.c\n@@ -350,8 +350,8 @@ int cmd_diff(int argc, const char **argv, const char *prefix)\n \trev.diffopt.stat_graph_width = -1;\n \n \t/* Default to let external and textconv be used */\n-\tDIFF_OPT_SET(&rev.diffopt, ALLOW_EXTERNAL);\n-\tDIFF_OPT_SET(&rev.diffopt, ALLOW_TEXTCONV);\n+\trev.diffopt.flags.ALLOW_EXTERNAL = 1;\n+\trev.diffopt.flags.ALLOW_TEXTCONV = 1;\n \n \tif (nongit)\n \t\tdie(_(\"Not a git repository\"));\n@@ -361,7 +361,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)\n \t\tdiff_setup_done(&rev.diffopt);\n \t}\n \n-\tDIFF_OPT_SET(&rev.diffopt, RECURSIVE);\n+\trev.diffopt.flags.RECURSIVE = 1;\n \n \tsetup_diff_pager(&rev.diffopt);\n \ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex 2fb60d6d4..35c8fb65d 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -1066,7 +1066,7 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)\n \t\tdie(\"revision walk setup failed\");\n \trevs.diffopt.format_callback = show_filemodify;\n \trevs.diffopt.format_callback_data = &paths_of_changed_objects;\n-\tDIFF_OPT_SET(&revs.diffopt, RECURSIVE);\n+\trevs.diffopt.flags.RECURSIVE = 1;\n \twhile ((commit = get_revision(&revs))) {\n \t\tif (has_unshown_parent(commit)) {\n \t\t\tadd_object_array(&commit->object, NULL, &commits);\ndiff --git a/builtin/log.c b/builtin/log.c\nindex 2b2d36678..4a24d3e48 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -121,16 +121,16 @@ static void cmd_log_init_defaults(struct rev_info *rev)\n \tif (fmt_pretty)\n \t\tget_commit_format(fmt_pretty, rev);\n \tif (default_follow)\n-\t\tDIFF_OPT_SET(&rev->diffopt, DEFAULT_FOLLOW_RENAMES);\n+\t\trev->diffopt.flags.DEFAULT_FOLLOW_RENAMES = 1;\n \trev->verbose_header = 1;\n-\tDIFF_OPT_SET(&rev->diffopt, RECURSIVE);\n+\trev->diffopt.flags.RECURSIVE = 1;\n \trev->diffopt.stat_width = -1; /* use full terminal width */\n \trev->diffopt.stat_graph_width = -1; /* respect statGraphWidth config */\n \trev->abbrev_commit = default_abbrev_commit;\n \trev->show_root_diff = default_show_root;\n \trev->subject_prefix = fmt_patch_subject_prefix;\n \trev->show_signature = default_show_signature;\n-\tDIFF_OPT_SET(&rev->diffopt, ALLOW_TEXTCONV);\n+\trev->diffopt.flags.ALLOW_TEXTCONV = 1;\n \n \tif (default_date_mode)\n \t\tparse_date_format(default_date_mode, &rev->date_mode);\n@@ -668,7 +668,7 @@ static void log_setup_revisions_tweak(struct rev_info *rev,\n {\n \tif (rev->diffopt.flags.DEFAULT_FOLLOW_RENAMES &&\n \t    rev->prune_data.nr == 1)\n-\t\tDIFF_OPT_SET(&rev->diffopt, FOLLOW_RENAMES);\n+\t\trev->diffopt.flags.FOLLOW_RENAMES = 1;\n \n \t/* Turn --cc/-c into -p --cc/-c when -p was not given */\n \tif (!rev->diffopt.output_format && rev->combine_merges)\n@@ -1340,7 +1340,7 @@ static void prepare_bases(struct base_tree_info *bases,\n \t\treturn;\n \n \tdiff_setup(&diffopt);\n-\tDIFF_OPT_SET(&diffopt, RECURSIVE);\n+\tdiffopt.flags.RECURSIVE = 1;\n \tdiff_setup_done(&diffopt);\n \n \toidcpy(&bases->base_commit, &base->object.oid);\n@@ -1511,7 +1511,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \trev.verbose_header = 1;\n \trev.diff = 1;\n \trev.max_parents = 1;\n-\tDIFF_OPT_SET(&rev.diffopt, RECURSIVE);\n+\trev.diffopt.flags.RECURSIVE = 1;\n \trev.subject_prefix = fmt_patch_subject_prefix;\n \tmemset(&s_r_opt, 0, sizeof(s_r_opt));\n \ts_r_opt.def = \"HEAD\";\n@@ -1613,7 +1613,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \trev.zero_commit = zero_commit;\n \n \tif (!rev.diffopt.flags.TEXT && !no_binary_diff)\n-\t\tDIFF_OPT_SET(&rev.diffopt, BINARY);\n+\t\trev.diffopt.flags.BINARY = 1;\n \n \tif (rev.show_notes)\n \t\tinit_display_notes(&rev.notes_opt);\ndiff --git a/builtin/reset.c b/builtin/reset.c\nindex ea2fad5a0..206819ef1 100644\n--- a/builtin/reset.c\n+++ b/builtin/reset.c\n@@ -166,7 +166,7 @@ static int read_from_tree(const struct pathspec *pathspec,\n \topt.output_format = DIFF_FORMAT_CALLBACK;\n \topt.format_callback = update_index_from_diff;\n \topt.format_callback_data = &intent_to_add;\n-\tDIFF_OPT_SET(&opt, OVERRIDE_SUBMODULE_CONFIG);\n+\topt.flags.OVERRIDE_SUBMODULE_CONFIG = 1;\n \n \tif (do_diff_cache(tree_oid, &opt))\n \t\treturn 1;\ndiff --git a/combine-diff.c b/combine-diff.c\nindex 40cb4dd1a..204b0dfce 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -1413,7 +1413,7 @@ void diff_tree_combined(const struct object_id *oid,\n \n \tdiffopts = *opt;\n \tcopy_pathspec(&diffopts.pathspec, &opt->pathspec);\n-\tDIFF_OPT_SET(&diffopts, RECURSIVE);\n+\tdiffopts.flags.RECURSIVE = 1;\n \tDIFF_OPT_CLR(&diffopts, ALLOW_EXTERNAL);\n \n \t/* find set of paths that everybody touches\ndiff --git a/diff-lib.c b/diff-lib.c\nindex d6b711617..b1ec804fe 100644\n--- a/diff-lib.c\n+++ b/diff-lib.c\n@@ -545,8 +545,8 @@ int index_differs_from(const char *def, const struct diff_flags *flags,\n \tmemset(&opt, 0, sizeof(opt));\n \topt.def = def;\n \tsetup_revisions(0, NULL, &rev, &opt);\n-\tDIFF_OPT_SET(&rev.diffopt, QUICK);\n-\tDIFF_OPT_SET(&rev.diffopt, EXIT_WITH_STATUS);\n+\trev.diffopt.flags.QUICK = 1;\n+\trev.diffopt.flags.EXIT_WITH_STATUS = 1;\n \tif (flags)\n \t\trev.diffopt.flags = diff_flags_or(&rev.diffopt.flags, flags);\n \trev.diffopt.ita_invisible_in_index = ita_invisible_in_index;\ndiff --git a/diff-no-index.c b/diff-no-index.c\nindex 40d17e42c..a3e194340 100644\n--- a/diff-no-index.c\n+++ b/diff-no-index.c\n@@ -276,16 +276,16 @@ void diff_no_index(struct rev_info *revs,\n \tif (!revs->diffopt.output_format)\n \t\trevs->diffopt.output_format = DIFF_FORMAT_PATCH;\n \n-\tDIFF_OPT_SET(&revs->diffopt, NO_INDEX);\n+\trevs->diffopt.flags.NO_INDEX = 1;\n \n-\tDIFF_OPT_SET(&revs->diffopt, RELATIVE_NAME);\n+\trevs->diffopt.flags.RELATIVE_NAME = 1;\n \trevs->diffopt.prefix = prefix;\n \n \trevs->max_count = -2;\n \tdiff_setup_done(&revs->diffopt);\n \n \tsetup_diff_pager(&revs->diffopt);\n-\tDIFF_OPT_SET(&revs->diffopt, EXIT_WITH_STATUS);\n+\trevs->diffopt.flags.EXIT_WITH_STATUS = 1;\n \n \tif (queue_diff(&revs->diffopt, paths[0], paths[1]))\n \t\texit(1);\ndiff --git a/diff.c b/diff.c\nindex 924f876fc..16d33c319 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -127,15 +127,15 @@ static int parse_dirstat_params(struct diff_options *options, const char *params\n \t\t\tDIFF_OPT_CLR(options, DIRSTAT_BY_LINE);\n \t\t\tDIFF_OPT_CLR(options, DIRSTAT_BY_FILE);\n \t\t} else if (!strcmp(p, \"lines\")) {\n-\t\t\tDIFF_OPT_SET(options, DIRSTAT_BY_LINE);\n+\t\t\toptions->flags.DIRSTAT_BY_LINE = 1;\n \t\t\tDIFF_OPT_CLR(options, DIRSTAT_BY_FILE);\n \t\t} else if (!strcmp(p, \"files\")) {\n \t\t\tDIFF_OPT_CLR(options, DIRSTAT_BY_LINE);\n-\t\t\tDIFF_OPT_SET(options, DIRSTAT_BY_FILE);\n+\t\t\toptions->flags.DIRSTAT_BY_FILE = 1;\n \t\t} else if (!strcmp(p, \"noncumulative\")) {\n \t\t\tDIFF_OPT_CLR(options, DIRSTAT_CUMULATIVE);\n \t\t} else if (!strcmp(p, \"cumulative\")) {\n-\t\t\tDIFF_OPT_SET(options, DIRSTAT_CUMULATIVE);\n+\t\t\toptions->flags.DIRSTAT_CUMULATIVE = 1;\n \t\t} else if (isdigit(*p)) {\n \t\t\tchar *end;\n \t\t\tint permille = strtoul(p, &end, 10) * 10;\n@@ -3447,7 +3447,7 @@ static void builtin_checkdiff(const char *name_a, const char *name_b,\n \tdiff_free_filespec_data(one);\n \tdiff_free_filespec_data(two);\n \tif (data.status)\n-\t\tDIFF_OPT_SET(o, CHECK_FAILED);\n+\t\to->flags.CHECK_FAILED = 1;\n }\n \n struct diff_filespec *alloc_filespec(const char *path)\n@@ -4152,7 +4152,7 @@ void diff_setup(struct diff_options *options)\n \toptions->context = diff_context_default;\n \toptions->interhunkcontext = diff_interhunk_context_default;\n \toptions->ws_error_highlight = ws_error_highlight_default;\n-\tDIFF_OPT_SET(options, RENAME_EMPTY);\n+\toptions->flags.RENAME_EMPTY = 1;\n \n \t/* pathchange left =NULL by default */\n \toptions->change = diff_change;\n@@ -4203,7 +4203,7 @@ void diff_setup_done(struct diff_options *options)\n \tif (DIFF_XDL_TST(options, IGNORE_WHITESPACE) ||\n \t    DIFF_XDL_TST(options, IGNORE_WHITESPACE_CHANGE) ||\n \t    DIFF_XDL_TST(options, IGNORE_WHITESPACE_AT_EOL))\n-\t\tDIFF_OPT_SET(options, DIFF_FROM_CONTENTS);\n+\t\toptions->flags.DIFF_FROM_CONTENTS = 1;\n \telse\n \t\tDIFF_OPT_CLR(options, DIFF_FROM_CONTENTS);\n \n@@ -4240,18 +4240,18 @@ void diff_setup_done(struct diff_options *options)\n \t\t\t\t      DIFF_FORMAT_DIRSTAT |\n \t\t\t\t      DIFF_FORMAT_SUMMARY |\n \t\t\t\t      DIFF_FORMAT_CHECKDIFF))\n-\t\tDIFF_OPT_SET(options, RECURSIVE);\n+\t\toptions->flags.RECURSIVE = 1;\n \t/*\n \t * Also pickaxe would not work very well if you do not say recursive\n \t */\n \tif (options->pickaxe)\n-\t\tDIFF_OPT_SET(options, RECURSIVE);\n+\t\toptions->flags.RECURSIVE = 1;\n \t/*\n \t * When patches are generated, submodules diffed against the work tree\n \t * must be checked for dirtiness too so it can be shown in the output\n \t */\n \tif (options->output_format & DIFF_FORMAT_PATCH)\n-\t\tDIFF_OPT_SET(options, DIRTY_SUBMODULES);\n+\t\toptions->flags.DIRTY_SUBMODULES = 1;\n \n \tif (options->detect_rename && options->rename_limit < 0)\n \t\toptions->rename_limit = diff_rename_limit_default;\n@@ -4275,7 +4275,7 @@ void diff_setup_done(struct diff_options *options)\n \t */\n \tif (options->flags.QUICK) {\n \t\toptions->output_format = DIFF_FORMAT_NO_OUTPUT;\n-\t\tDIFF_OPT_SET(options, EXIT_WITH_STATUS);\n+\t\toptions->flags.EXIT_WITH_STATUS = 1;\n \t}\n \n \toptions->diff_path_counter = 0;\n@@ -4630,7 +4630,7 @@ int diff_opt_parse(struct diff_options *options,\n \telse if (starts_with(arg, \"-C\") || starts_with(arg, \"--find-copies=\") ||\n \t\t !strcmp(arg, \"--find-copies\")) {\n \t\tif (options->detect_rename == DIFF_DETECT_COPY)\n-\t\t\tDIFF_OPT_SET(options, FIND_COPIES_HARDER);\n+\t\t\toptions->flags.FIND_COPIES_HARDER = 1;\n \t\tif ((options->rename_score = diff_scoreopt_parse(arg)) == -1)\n \t\t\treturn error(\"invalid argument to -C: %s\", arg+2);\n \t\toptions->detect_rename = DIFF_DETECT_COPY;\n@@ -4638,13 +4638,13 @@ int diff_opt_parse(struct diff_options *options,\n \telse if (!strcmp(arg, \"--no-renames\"))\n \t\toptions->detect_rename = 0;\n \telse if (!strcmp(arg, \"--rename-empty\"))\n-\t\tDIFF_OPT_SET(options, RENAME_EMPTY);\n+\t\toptions->flags.RENAME_EMPTY = 1;\n \telse if (!strcmp(arg, \"--no-rename-empty\"))\n \t\tDIFF_OPT_CLR(options, RENAME_EMPTY);\n \telse if (!strcmp(arg, \"--relative\"))\n-\t\tDIFF_OPT_SET(options, RELATIVE_NAME);\n+\t\toptions->flags.RELATIVE_NAME = 1;\n \telse if (skip_prefix(arg, \"--relative=\", &arg)) {\n-\t\tDIFF_OPT_SET(options, RELATIVE_NAME);\n+\t\toptions->flags.RELATIVE_NAME = 1;\n \t\toptions->prefix = arg;\n \t}\n \n@@ -4684,18 +4684,18 @@ int diff_opt_parse(struct diff_options *options,\n \t/* flags options */\n \telse if (!strcmp(arg, \"--binary\")) {\n \t\tenable_patch_output(&options->output_format);\n-\t\tDIFF_OPT_SET(options, BINARY);\n+\t\toptions->flags.BINARY = 1;\n \t}\n \telse if (!strcmp(arg, \"--full-index\"))\n-\t\tDIFF_OPT_SET(options, FULL_INDEX);\n+\t\toptions->flags.FULL_INDEX = 1;\n \telse if (!strcmp(arg, \"-a\") || !strcmp(arg, \"--text\"))\n-\t\tDIFF_OPT_SET(options, TEXT);\n+\t\toptions->flags.TEXT = 1;\n \telse if (!strcmp(arg, \"-R\"))\n-\t\tDIFF_OPT_SET(options, REVERSE_DIFF);\n+\t\toptions->flags.REVERSE_DIFF = 1;\n \telse if (!strcmp(arg, \"--find-copies-harder\"))\n-\t\tDIFF_OPT_SET(options, FIND_COPIES_HARDER);\n+\t\toptions->flags.FIND_COPIES_HARDER = 1;\n \telse if (!strcmp(arg, \"--follow\"))\n-\t\tDIFF_OPT_SET(options, FOLLOW_RENAMES);\n+\t\toptions->flags.FOLLOW_RENAMES = 1;\n \telse if (!strcmp(arg, \"--no-follow\")) {\n \t\tDIFF_OPT_CLR(options, FOLLOW_RENAMES);\n \t\tDIFF_OPT_CLR(options, DEFAULT_FOLLOW_RENAMES);\n@@ -4755,24 +4755,24 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn argcount;\n \t}\n \telse if (!strcmp(arg, \"--exit-code\"))\n-\t\tDIFF_OPT_SET(options, EXIT_WITH_STATUS);\n+\t\toptions->flags.EXIT_WITH_STATUS = 1;\n \telse if (!strcmp(arg, \"--quiet\"))\n-\t\tDIFF_OPT_SET(options, QUICK);\n+\t\toptions->flags.QUICK = 1;\n \telse if (!strcmp(arg, \"--ext-diff\"))\n-\t\tDIFF_OPT_SET(options, ALLOW_EXTERNAL);\n+\t\toptions->flags.ALLOW_EXTERNAL = 1;\n \telse if (!strcmp(arg, \"--no-ext-diff\"))\n \t\tDIFF_OPT_CLR(options, ALLOW_EXTERNAL);\n \telse if (!strcmp(arg, \"--textconv\")) {\n-\t\tDIFF_OPT_SET(options, ALLOW_TEXTCONV);\n-\t\tDIFF_OPT_SET(options, TEXTCONV_SET_VIA_CMDLINE);\n+\t\toptions->flags.ALLOW_TEXTCONV = 1;\n+\t\toptions->flags.TEXTCONV_SET_VIA_CMDLINE = 1;\n \t} else if (!strcmp(arg, \"--no-textconv\")) {\n \t\tDIFF_OPT_CLR(options, ALLOW_TEXTCONV);\n \t\tDIFF_OPT_CLR(options, TEXTCONV_SET_VIA_CMDLINE);\n \t} else if (!strcmp(arg, \"--ignore-submodules\")) {\n-\t\tDIFF_OPT_SET(options, OVERRIDE_SUBMODULE_CONFIG);\n+\t\toptions->flags.OVERRIDE_SUBMODULE_CONFIG = 1;\n \t\thandle_ignore_submodules_arg(options, \"all\");\n \t} else if (skip_prefix(arg, \"--ignore-submodules=\", &arg)) {\n-\t\tDIFF_OPT_SET(options, OVERRIDE_SUBMODULE_CONFIG);\n+\t\toptions->flags.OVERRIDE_SUBMODULE_CONFIG = 1;\n \t\thandle_ignore_submodules_arg(options, arg);\n \t} else if (!strcmp(arg, \"--submodule\"))\n \t\toptions->submodule_format = DIFF_SUBMODULE_LOG;\n@@ -4847,9 +4847,9 @@ int diff_opt_parse(struct diff_options *options,\n \t\t\t &options->interhunkcontext))\n \t\t;\n \telse if (!strcmp(arg, \"-W\"))\n-\t\tDIFF_OPT_SET(options, FUNCCONTEXT);\n+\t\toptions->flags.FUNCCONTEXT = 1;\n \telse if (!strcmp(arg, \"--function-context\"))\n-\t\tDIFF_OPT_SET(options, FUNCCONTEXT);\n+\t\toptions->flags.FUNCCONTEXT = 1;\n \telse if (!strcmp(arg, \"--no-function-context\"))\n \t\tDIFF_OPT_CLR(options, FUNCCONTEXT);\n \telse if ((argcount = parse_long_opt(\"output\", av, &optarg))) {\n@@ -5687,7 +5687,7 @@ void diff_flush(struct diff_options *options)\n \t */\n \tif (options->flags.DIFF_FROM_CONTENTS) {\n \t\tif (options->found_changes)\n-\t\t\tDIFF_OPT_SET(options, HAS_CHANGES);\n+\t\t\toptions->flags.HAS_CHANGES = 1;\n \t\telse\n \t\t\tDIFF_OPT_CLR(options, HAS_CHANGES);\n \t}\n@@ -5859,7 +5859,7 @@ void diffcore_std(struct diff_options *options)\n \tdiffcore_apply_filter(options);\n \n \tif (diff_queued_diff.nr && !options->flags.DIFF_FROM_CONTENTS)\n-\t\tDIFF_OPT_SET(options, HAS_CHANGES);\n+\t\toptions->flags.HAS_CHANGES = 1;\n \telse\n \t\tDIFF_OPT_CLR(options, HAS_CHANGES);\n \n@@ -5953,7 +5953,7 @@ void diff_addremove(struct diff_options *options,\n \n \tdiff_queue(&diff_queued_diff, one, two);\n \tif (!options->flags.DIFF_FROM_CONTENTS)\n-\t\tDIFF_OPT_SET(options, HAS_CHANGES);\n+\t\toptions->flags.HAS_CHANGES = 1;\n }\n \n void diff_change(struct diff_options *options,\n@@ -5997,7 +5997,7 @@ void diff_change(struct diff_options *options,\n \t    !diff_filespec_check_stat_unmatch(p))\n \t\treturn;\n \n-\tDIFF_OPT_SET(options, HAS_CHANGES);\n+\toptions->flags.HAS_CHANGES = 1;\n }\n \n struct diff_filepair *diff_unmerge(struct diff_options *options, const char *path)\ndiff --git a/diff.h b/diff.h\nindex a3656ff5b..4c1af4be6 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -110,7 +110,6 @@ static inline struct diff_flags diff_flags_or(const struct diff_flags *a,\n \treturn out;\n }\n \n-#define DIFF_OPT_SET(opts, flag)\t((opts)->flags.flag = 1)\n #define DIFF_OPT_CLR(opts, flag)\t((opts)->flags.flag = 0)\n \n #define DIFF_XDL_TST(opts, flag)    ((opts)->xdl_opts & XDF_##flag)\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 1d3f8f0d2..e7b3df45c 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -540,7 +540,7 @@ static struct string_list *get_renames(struct merge_options *o,\n \t\treturn renames;\n \n \tdiff_setup(&opts);\n-\tDIFF_OPT_SET(&opts, RECURSIVE);\n+\topts.flags.RECURSIVE = 1;\n \tDIFF_OPT_CLR(&opts, RENAME_EMPTY);\n \topts.detect_rename = DIFF_DETECT_RENAME;\n \topts.rename_limit = o->merge_rename_limit >= 0 ? o->merge_rename_limit :\ndiff --git a/notes-merge.c b/notes-merge.c\nindex 4352c34a6..b50111cf2 100644\n--- a/notes-merge.c\n+++ b/notes-merge.c\n@@ -125,7 +125,7 @@ static struct notes_merge_pair *diff_tree_remote(struct notes_merge_options *o,\n \t       oid_to_hex(base), oid_to_hex(remote));\n \n \tdiff_setup(&opt);\n-\tDIFF_OPT_SET(&opt, RECURSIVE);\n+\topt.flags.RECURSIVE = 1;\n \topt.output_format = DIFF_FORMAT_NO_OUTPUT;\n \tdiff_setup_done(&opt);\n \tdiff_tree_oid(base, remote, \"\", &opt);\n@@ -188,7 +188,7 @@ static void diff_tree_local(struct notes_merge_options *o,\n \t       len, oid_to_hex(base), oid_to_hex(local));\n \n \tdiff_setup(&opt);\n-\tDIFF_OPT_SET(&opt, RECURSIVE);\n+\topt.flags.RECURSIVE = 1;\n \topt.output_format = DIFF_FORMAT_NO_OUTPUT;\n \tdiff_setup_done(&opt);\n \tdiff_tree_oid(base, local, \"\", &opt);\ndiff --git a/patch-ids.c b/patch-ids.c\nindex 7a583b301..189869e57 100644\n--- a/patch-ids.c\n+++ b/patch-ids.c\n@@ -61,7 +61,7 @@ int init_patch_ids(struct patch_ids *ids)\n \tmemset(ids, 0, sizeof(*ids));\n \tdiff_setup(&ids->diffopts);\n \tids->diffopts.detect_rename = 0;\n-\tDIFF_OPT_SET(&ids->diffopts, RECURSIVE);\n+\tids->diffopts.flags.RECURSIVE = 1;\n \tdiff_setup_done(&ids->diffopts);\n \thashmap_init(&ids->patches, patch_id_cmp, &ids->diffopts, 256);\n \treturn 0;\ndiff --git a/revision.c b/revision.c\nindex c893d9166..f019dd277 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -410,7 +410,7 @@ static void file_add_remove(struct diff_options *options,\n \n \ttree_difference |= diff;\n \tif (tree_difference == REV_TREE_DIFFERENT)\n-\t\tDIFF_OPT_SET(options, HAS_CHANGES);\n+\t\toptions->flags.HAS_CHANGES = 1;\n }\n \n static void file_change(struct diff_options *options,\n@@ -422,7 +422,7 @@ static void file_change(struct diff_options *options,\n \t\t unsigned old_dirty_submodule, unsigned new_dirty_submodule)\n {\n \ttree_difference = REV_TREE_DIFFERENT;\n-\tDIFF_OPT_SET(options, HAS_CHANGES);\n+\toptions->flags.HAS_CHANGES = 1;\n }\n \n static int rev_compare_tree(struct rev_info *revs,\n@@ -1403,8 +1403,8 @@ void init_revisions(struct rev_info *revs, const char *prefix)\n \trevs->abbrev = DEFAULT_ABBREV;\n \trevs->ignore_merges = 1;\n \trevs->simplify_history = 1;\n-\tDIFF_OPT_SET(&revs->pruning, RECURSIVE);\n-\tDIFF_OPT_SET(&revs->pruning, QUICK);\n+\trevs->pruning.flags.RECURSIVE = 1;\n+\trevs->pruning.flags.QUICK = 1;\n \trevs->pruning.add_remove = file_add_remove;\n \trevs->pruning.change = file_change;\n \trevs->sort_order = REV_SORT_IN_GRAPH_ORDER;\n@@ -1917,11 +1917,11 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg\n \t\tdie(\"--unpacked=<packfile> no longer supported.\");\n \t} else if (!strcmp(arg, \"-r\")) {\n \t\trevs->diff = 1;\n-\t\tDIFF_OPT_SET(&revs->diffopt, RECURSIVE);\n+\t\trevs->diffopt.flags.RECURSIVE = 1;\n \t} else if (!strcmp(arg, \"-t\")) {\n \t\trevs->diff = 1;\n-\t\tDIFF_OPT_SET(&revs->diffopt, RECURSIVE);\n-\t\tDIFF_OPT_SET(&revs->diffopt, TREE_IN_RECURSIVE);\n+\t\trevs->diffopt.flags.RECURSIVE = 1;\n+\t\trevs->diffopt.flags.TREE_IN_RECURSIVE = 1;\n \t} else if (!strcmp(arg, \"-m\")) {\n \t\trevs->ignore_merges = 0;\n \t} else if (!strcmp(arg, \"-c\")) {\n@@ -2066,7 +2066,7 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg\n \t\trevs->grep_filter.pattern_type_option = GREP_PATTERN_TYPE_ERE;\n \t} else if (!strcmp(arg, \"--regexp-ignore-case\") || !strcmp(arg, \"-i\")) {\n \t\trevs->grep_filter.ignore_case = 1;\n-\t\tDIFF_OPT_SET(&revs->diffopt, PICKAXE_IGNORE_CASE);\n+\t\trevs->diffopt.flags.PICKAXE_IGNORE_CASE = 1;\n \t} else if (!strcmp(arg, \"--fixed-strings\") || !strcmp(arg, \"-F\")) {\n \t\trevs->grep_filter.pattern_type_option = GREP_PATTERN_TYPE_FIXED;\n \t} else if (!strcmp(arg, \"--perl-regexp\") || !strcmp(arg, \"-P\")) {\ndiff --git a/submodule.c b/submodule.c\nindex 58da9c668..7e7998592 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -183,7 +183,7 @@ void set_diffopt_flags_from_submodule_config(struct diff_options *diffopt,\n \t\tif (ignore)\n \t\t\thandle_ignore_submodules_arg(diffopt, ignore);\n \t\telse if (is_gitmodules_unmerged(&the_index))\n-\t\t\tDIFF_OPT_SET(diffopt, IGNORE_SUBMODULES);\n+\t\t\tdiffopt->flags.IGNORE_SUBMODULES = 1;\n \t}\n }\n \n@@ -407,11 +407,11 @@ void handle_ignore_submodules_arg(struct diff_options *diffopt,\n \tDIFF_OPT_CLR(diffopt, IGNORE_DIRTY_SUBMODULES);\n \n \tif (!strcmp(arg, \"all\"))\n-\t\tDIFF_OPT_SET(diffopt, IGNORE_SUBMODULES);\n+\t\tdiffopt->flags.IGNORE_SUBMODULES = 1;\n \telse if (!strcmp(arg, \"untracked\"))\n-\t\tDIFF_OPT_SET(diffopt, IGNORE_UNTRACKED_IN_SUBMODULES);\n+\t\tdiffopt->flags.IGNORE_UNTRACKED_IN_SUBMODULES = 1;\n \telse if (!strcmp(arg, \"dirty\"))\n-\t\tDIFF_OPT_SET(diffopt, IGNORE_DIRTY_SUBMODULES);\n+\t\tdiffopt->flags.IGNORE_DIRTY_SUBMODULES = 1;\n \telse if (strcmp(arg, \"none\"))\n \t\tdie(\"bad --ignore-submodules argument: %s\", arg);\n }\ndiff --git a/tree-diff.c b/tree-diff.c\nindex ed0aa6a62..b996a23bb 100644\n--- a/tree-diff.c\n+++ b/tree-diff.c\n@@ -608,8 +608,8 @@ static void try_to_follow_renames(const struct object_id *old_oid,\n \tq->nr = 0;\n \n \tdiff_setup(&diff_opts);\n-\tDIFF_OPT_SET(&diff_opts, RECURSIVE);\n-\tDIFF_OPT_SET(&diff_opts, FIND_COPIES_HARDER);\n+\tdiff_opts.flags.RECURSIVE = 1;\n+\tdiff_opts.flags.FIND_COPIES_HARDER = 1;\n \tdiff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;\n \tdiff_opts.single_follow = opt->pathspec.items[0].match;\n \tdiff_opts.break_opt = opt->break_opt;\ndiff --git a/wt-status.c b/wt-status.c\nindex 29bc64cc0..59f9f3a0b 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -559,12 +559,12 @@ static void wt_status_collect_changes_worktree(struct wt_status *s)\n \tinit_revisions(&rev, NULL);\n \tsetup_revisions(0, NULL, &rev, NULL);\n \trev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;\n-\tDIFF_OPT_SET(&rev.diffopt, DIRTY_SUBMODULES);\n+\trev.diffopt.flags.DIRTY_SUBMODULES = 1;\n \trev.diffopt.ita_invisible_in_index = 1;\n \tif (!s->show_untracked_files)\n-\t\tDIFF_OPT_SET(&rev.diffopt, IGNORE_UNTRACKED_IN_SUBMODULES);\n+\t\trev.diffopt.flags.IGNORE_UNTRACKED_IN_SUBMODULES = 1;\n \tif (s->ignore_submodule_arg) {\n-\t\tDIFF_OPT_SET(&rev.diffopt, OVERRIDE_SUBMODULE_CONFIG);\n+\t\trev.diffopt.flags.OVERRIDE_SUBMODULE_CONFIG = 1;\n \t\thandle_ignore_submodules_arg(&rev.diffopt, s->ignore_submodule_arg);\n \t}\n \trev.diffopt.format_callback = wt_status_collect_changed_cb;\n@@ -583,7 +583,7 @@ static void wt_status_collect_changes_index(struct wt_status *s)\n \topt.def = s->is_initial ? EMPTY_TREE_SHA1_HEX : s->reference;\n \tsetup_revisions(0, NULL, &rev, &opt);\n \n-\tDIFF_OPT_SET(&rev.diffopt, OVERRIDE_SUBMODULE_CONFIG);\n+\trev.diffopt.flags.OVERRIDE_SUBMODULE_CONFIG = 1;\n \trev.diffopt.ita_invisible_in_index = 1;\n \tif (s->ignore_submodule_arg) {\n \t\thandle_ignore_submodules_arg(&rev.diffopt, s->ignore_submodule_arg);\n@@ -949,7 +949,7 @@ static void wt_longstatus_print_verbose(struct wt_status *s)\n \tconst char *c = color(WT_STATUS_HEADER, s);\n \n \tinit_revisions(&rev, NULL);\n-\tDIFF_OPT_SET(&rev.diffopt, ALLOW_TEXTCONV);\n+\trev.diffopt.flags.ALLOW_TEXTCONV = 1;\n \trev.diffopt.ita_invisible_in_index = 1;\n \n \tmemset(&opt, 0, sizeof(opt));\n@@ -2263,8 +2263,8 @@ int has_unstaged_changes(int ignore_submodules)\n \n \tinit_revisions(&rev_info, NULL);\n \tif (ignore_submodules)\n-\t\tDIFF_OPT_SET(&rev_info.diffopt, IGNORE_SUBMODULES);\n-\tDIFF_OPT_SET(&rev_info.diffopt, QUICK);\n+\t\trev_info.diffopt.flags.IGNORE_SUBMODULES = 1;\n+\trev_info.diffopt.flags.QUICK = 1;\n \tdiff_setup_done(&rev_info.diffopt);\n \tresult = run_diff_files(&rev_info, 0);\n \treturn diff_result_code(&rev_info.diffopt, result);\n@@ -2283,8 +2283,8 @@ int has_uncommitted_changes(int ignore_submodules)\n \n \tinit_revisions(&rev_info, NULL);\n \tif (ignore_submodules)\n-\t\tDIFF_OPT_SET(&rev_info.diffopt, IGNORE_SUBMODULES);\n-\tDIFF_OPT_SET(&rev_info.diffopt, QUICK);\n+\t\trev_info.diffopt.flags.IGNORE_SUBMODULES = 1;\n+\trev_info.diffopt.flags.QUICK = 1;\n \tadd_head_to_pending(&rev_info);\n \tdiff_setup_done(&rev_info.diffopt);\n \tresult = run_diff_index(&rev_info, 1);\n-- \n2.15.0.403.gc27cc4dac6-goog\n\n"},{"id":"331419","messageId":"20171030221956.92466-4-bmwill@google.com","threadId":"47047","inReplyTo":"20171030221956.92466-1-bmwill@google.com","subject":"[PATCH v2 8/4] diff: make struct diff_flags members lowercase","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-10-30T22:19:56Z","receivedAt":"2017-10-30T22:20:30Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"Now that the flags stored in struct diff_flags are being accessed\ndirectly and not through macros, change all struct members from being\nuppercase to lowercase.\nThis conversion is done using the following semantic patch:\n\n\t@@\n\texpression E;\n\t@@\n\t- E.RECURSIVE\n\t+ E.recursive\n\n\t@@\n\texpression E;\n\t@@\n\t- E.TREE_IN_RECURSIVE\n\t+ E.tree_in_recursive\n\n\t@@\n\texpression E;\n\t@@\n\t- E.BINARY\n\t+ E.binary\n\n\t@@\n\texpression E;\n\t@@\n\t- E.TEXT\n\t+ E.text\n\n\t@@\n\texpression E;\n\t@@\n\t- E.FULL_INDEX\n\t+ E.full_index\n\n\t@@\n\texpression E;\n\t@@\n\t- E.SILENT_ON_REMOVE\n\t+ E.silent_on_remove\n\n\t@@\n\texpression E;\n\t@@\n\t- E.FIND_COPIES_HARDER\n\t+ E.find_copies_harder\n\n\t@@\n\texpression E;\n\t@@\n\t- E.FOLLOW_RENAMES\n\t+ E.follow_renames\n\n\t@@\n\texpression E;\n\t@@\n\t- E.RENAME_EMPTY\n\t+ E.rename_empty\n\n\t@@\n\texpression E;\n\t@@\n\t- E.HAS_CHANGES\n\t+ E.has_changes\n\n\t@@\n\texpression E;\n\t@@\n\t- E.QUICK\n\t+ E.quick\n\n\t@@\n\texpression E;\n\t@@\n\t- E.NO_INDEX\n\t+ E.no_index\n\n\t@@\n\texpression E;\n\t@@\n\t- E.ALLOW_EXTERNAL\n\t+ E.allow_external\n\n\t@@\n\texpression E;\n\t@@\n\t- E.EXIT_WITH_STATUS\n\t+ E.exit_with_status\n\n\t@@\n\texpression E;\n\t@@\n\t- E.REVERSE_DIFF\n\t+ E.reverse_diff\n\n\t@@\n\texpression E;\n\t@@\n\t- E.CHECK_FAILED\n\t+ E.check_failed\n\n\t@@\n\texpression E;\n\t@@\n\t- E.RELATIVE_NAME\n\t+ E.relative_name\n\n\t@@\n\texpression E;\n\t@@\n\t- E.IGNORE_SUBMODULES\n\t+ E.ignore_submodules\n\n\t@@\n\texpression E;\n\t@@\n\t- E.DIRSTAT_CUMULATIVE\n\t+ E.dirstat_cumulative\n\n\t@@\n\texpression E;\n\t@@\n\t- E.DIRSTAT_BY_FILE\n\t+ E.dirstat_by_file\n\n\t@@\n\texpression E;\n\t@@\n\t- E.ALLOW_TEXTCONV\n\t+ E.allow_textconv\n\n\t@@\n\texpression E;\n\t@@\n\t- E.TEXTCONV_SET_VIA_CMDLINE\n\t+ E.textconv_set_via_cmdline\n\n\t@@\n\texpression E;\n\t@@\n\t- E.DIFF_FROM_CONTENTS\n\t+ E.diff_from_contents\n\n\t@@\n\texpression E;\n\t@@\n\t- E.DIRTY_SUBMODULES\n\t+ E.dirty_submodules\n\n\t@@\n\texpression E;\n\t@@\n\t- E.IGNORE_UNTRACKED_IN_SUBMODULES\n\t+ E.ignore_untracked_in_submodules\n\n\t@@\n\texpression E;\n\t@@\n\t- E.IGNORE_DIRTY_SUBMODULES\n\t+ E.ignore_dirty_submodules\n\n\t@@\n\texpression E;\n\t@@\n\t- E.OVERRIDE_SUBMODULE_CONFIG\n\t+ E.override_submodule_config\n\n\t@@\n\texpression E;\n\t@@\n\t- E.DIRSTAT_BY_LINE\n\t+ E.dirstat_by_line\n\n\t@@\n\texpression E;\n\t@@\n\t- E.FUNCCONTEXT\n\t+ E.funccontext\n\n\t@@\n\texpression E;\n\t@@\n\t- E.PICKAXE_IGNORE_CASE\n\t+ E.pickaxe_ignore_case\n\n\t@@\n\texpression E;\n\t@@\n\t- E.DEFAULT_FOLLOW_RENAMES\n\t+ E.default_follow_renames\n\nSigned-off-by: Brandon Williams <bmwill@google.com>\n---\n blame.c               |  16 ++---\n builtin/add.c         |   4 +-\n builtin/am.c          |  10 +--\n builtin/blame.c       |  10 +--\n builtin/commit.c      |   4 +-\n builtin/diff.c        |   8 +--\n builtin/fast-export.c |   2 +-\n builtin/log.c         |  26 ++++----\n builtin/reset.c       |   2 +-\n builtin/rev-list.c    |   2 +-\n combine-diff.c        |  10 +--\n diff-lib.c            |  22 +++----\n diff-no-index.c       |   8 +--\n diff.c                | 172 +++++++++++++++++++++++++-------------------------\n diff.h                |  62 +++++++++---------\n diffcore-pickaxe.c    |   8 +--\n diffcore-rename.c     |   6 +-\n log-tree.c            |   2 +-\n merge-recursive.c     |   4 +-\n notes-merge.c         |   4 +-\n patch-ids.c           |   2 +-\n revision.c            |  24 +++----\n submodule.c           |  16 ++---\n tree-diff.c           |  16 ++---\n wt-status.c           |  18 +++---\n 25 files changed, 229 insertions(+), 229 deletions(-)\n\ndiff --git a/blame.c b/blame.c\nindex dc9cc237b..28e03726f 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -209,7 +209,7 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,\n \n \t\tswitch (st.st_mode & S_IFMT) {\n \t\tcase S_IFREG:\n-\t\t\tif (opt->flags.ALLOW_TEXTCONV &&\n+\t\t\tif (opt->flags.allow_textconv &&\n \t\t\t    textconv_object(read_from, mode, &null_oid, 0, &buf_ptr, &buf_len))\n \t\t\t\tstrbuf_attach(&buf, buf_ptr, buf_len, buf_len + 1);\n \t\t\telse if (strbuf_read_file(&buf, read_from, st.st_size) != st.st_size)\n@@ -293,7 +293,7 @@ static void fill_origin_blob(struct diff_options *opt,\n \t\tunsigned long file_size;\n \n \t\t(*num_read_blob)++;\n-\t\tif (opt->flags.ALLOW_TEXTCONV &&\n+\t\tif (opt->flags.allow_textconv &&\n \t\t    textconv_object(o->path, o->mode, &o->blob_oid, 1, &file->ptr, &file_size))\n \t\t\t;\n \t\telse\n@@ -541,7 +541,7 @@ static struct blame_origin *find_origin(struct commit *parent,\n \t * same and diff-tree is fairly efficient about this.\n \t */\n \tdiff_setup(&diff_opts);\n-\tdiff_opts.flags.RECURSIVE = 1;\n+\tdiff_opts.flags.recursive = 1;\n \tdiff_opts.detect_rename = 0;\n \tdiff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;\n \tpaths[0] = origin->path;\n@@ -615,7 +615,7 @@ static struct blame_origin *find_rename(struct commit *parent,\n \tint i;\n \n \tdiff_setup(&diff_opts);\n-\tdiff_opts.flags.RECURSIVE = 1;\n+\tdiff_opts.flags.recursive = 1;\n \tdiff_opts.detect_rename = DIFF_DETECT_RENAME;\n \tdiff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;\n \tdiff_opts.single_follow = origin->path;\n@@ -1238,7 +1238,7 @@ static void find_copy_in_parent(struct blame_scoreboard *sb,\n \t\treturn; /* nothing remains for this target */\n \n \tdiff_setup(&diff_opts);\n-\tdiff_opts.flags.RECURSIVE = 1;\n+\tdiff_opts.flags.recursive = 1;\n \tdiff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;\n \n \tdiff_setup_done(&diff_opts);\n@@ -1253,7 +1253,7 @@ static void find_copy_in_parent(struct blame_scoreboard *sb,\n \tif ((opt & PICKAXE_BLAME_COPY_HARDEST)\n \t    || ((opt & PICKAXE_BLAME_COPY_HARDER)\n \t\t&& (!porigin || strcmp(target->path, porigin->path))))\n-\t\tdiff_opts.flags.FIND_COPIES_HARDER = 1;\n+\t\tdiff_opts.flags.find_copies_harder = 1;\n \n \tif (is_null_oid(&target->commit->object.oid))\n \t\tdo_diff_cache(&parent->tree->object.oid, &diff_opts);\n@@ -1262,7 +1262,7 @@ static void find_copy_in_parent(struct blame_scoreboard *sb,\n \t\t\t      &target->commit->tree->object.oid,\n \t\t\t      \"\", &diff_opts);\n \n-\tif (!diff_opts.flags.FIND_COPIES_HARDER)\n+\tif (!diff_opts.flags.find_copies_harder)\n \t\tdiffcore_std(&diff_opts);\n \n \tdo {\n@@ -1825,7 +1825,7 @@ void setup_scoreboard(struct blame_scoreboard *sb, const char *path, struct blam\n \t\tif (fill_blob_sha1_and_mode(o))\n \t\t\tdie(_(\"no such path %s in %s\"), path, final_commit_name);\n \n-\t\tif (sb->revs->diffopt.flags.ALLOW_TEXTCONV &&\n+\t\tif (sb->revs->diffopt.flags.allow_textconv &&\n \t\t    textconv_object(path, o->mode, &o->blob_oid, 1, (char **) &sb->final_buf,\n \t\t\t\t    &sb->final_buf_size))\n \t\t\t;\ndiff --git a/builtin/add.c b/builtin/add.c\nindex e1d83b69a..8d08e99e9 100644\n--- a/builtin/add.c\n+++ b/builtin/add.c\n@@ -116,7 +116,7 @@ int add_files_to_cache(const char *prefix,\n \trev.diffopt.output_format = DIFF_FORMAT_CALLBACK;\n \trev.diffopt.format_callback = update_callback;\n \trev.diffopt.format_callback_data = &data;\n-\trev.diffopt.flags.OVERRIDE_SUBMODULE_CONFIG = 1;\n+\trev.diffopt.flags.override_submodule_config = 1;\n \trev.max_count = 0; /* do not compare unmerged paths with stage #2 */\n \trun_diff_files(&rev, DIFF_RACY_IS_MODIFIED);\n \tclear_pathspec(&rev.prune_data);\n@@ -218,7 +218,7 @@ static int edit_patch(int argc, const char **argv, const char *prefix)\n \targc = setup_revisions(argc, argv, &rev, NULL);\n \trev.diffopt.output_format = DIFF_FORMAT_PATCH;\n \trev.diffopt.use_color = 0;\n-\trev.diffopt.flags.IGNORE_DIRTY_SUBMODULES = 1;\n+\trev.diffopt.flags.ignore_dirty_submodules = 1;\n \tout = open(file, O_CREAT | O_WRONLY, 0666);\n \tif (out < 0)\n \t\tdie(_(\"Could not open '%s' for writing.\"), file);\ndiff --git a/builtin/am.c b/builtin/am.c\nindex 015425a0f..b281d58f3 100644\n--- a/builtin/am.c\n+++ b/builtin/am.c\n@@ -1157,9 +1157,9 @@ static int index_has_changes(struct strbuf *sb)\n \t\tstruct diff_options opt;\n \n \t\tdiff_setup(&opt);\n-\t\topt.flags.EXIT_WITH_STATUS = 1;\n+\t\topt.flags.exit_with_status = 1;\n \t\tif (!sb)\n-\t\t\topt.flags.QUICK = 1;\n+\t\t\topt.flags.quick = 1;\n \t\tdo_diff_cache(&head, &opt);\n \t\tdiffcore_std(&opt);\n \t\tfor (i = 0; sb && i < diff_queued_diff.nr; i++) {\n@@ -1168,7 +1168,7 @@ static int index_has_changes(struct strbuf *sb)\n \t\t\tstrbuf_addstr(sb, diff_queued_diff.queue[i]->two->path);\n \t\t}\n \t\tdiff_flush(&opt);\n-\t\treturn opt.flags.HAS_CHANGES != 0;\n+\t\treturn opt.flags.has_changes != 0;\n \t} else {\n \t\tfor (i = 0; sb && i < active_nr; i++) {\n \t\t\tif (i)\n@@ -1409,8 +1409,8 @@ static void write_commit_patch(const struct am_state *state, struct commit *comm\n \trev_info.show_root_diff = 1;\n \trev_info.diffopt.output_format = DIFF_FORMAT_PATCH;\n \trev_info.no_commit_id = 1;\n-\trev_info.diffopt.flags.BINARY = 1;\n-\trev_info.diffopt.flags.FULL_INDEX = 1;\n+\trev_info.diffopt.flags.binary = 1;\n+\trev_info.diffopt.flags.full_index = 1;\n \trev_info.diffopt.use_color = 0;\n \trev_info.diffopt.file = fp;\n \trev_info.diffopt.close_file = 1;\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex 79db9e849..005f55aaa 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -708,8 +708,8 @@ int cmd_blame(int argc, const char **argv, const char *prefix)\n \tgit_config(git_blame_config, &output_option);\n \tinit_revisions(&revs, NULL);\n \trevs.date_mode = blame_date_mode;\n-\trevs.diffopt.flags.ALLOW_TEXTCONV = 1;\n-\trevs.diffopt.flags.FOLLOW_RENAMES = 1;\n+\trevs.diffopt.flags.allow_textconv = 1;\n+\trevs.diffopt.flags.follow_renames = 1;\n \n \tsave_commit_buffer = 0;\n \tdashdash_pos = 0;\n@@ -734,9 +734,9 @@ int cmd_blame(int argc, const char **argv, const char *prefix)\n \t\tparse_revision_opt(&revs, &ctx, options, blame_opt_usage);\n \t}\n parse_done:\n-\tno_whole_file_rename = !revs.diffopt.flags.FOLLOW_RENAMES;\n+\tno_whole_file_rename = !revs.diffopt.flags.follow_renames;\n \txdl_opts |= revs.diffopt.xdl_opts & XDF_INDENT_HEURISTIC;\n-\trevs.diffopt.flags.FOLLOW_RENAMES = 0;\n+\trevs.diffopt.flags.follow_renames = 0;\n \targc = parse_options_end(&ctx);\n \n \tif (incremental || (output_option & OUTPUT_PORCELAIN)) {\n@@ -803,7 +803,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)\n \t}\n \tblame_date_width -= 1; /* strip the null */\n \n-\tif (revs.diffopt.flags.FIND_COPIES_HARDER)\n+\tif (revs.diffopt.flags.find_copies_harder)\n \t\topt |= (PICKAXE_BLAME_COPY | PICKAXE_BLAME_MOVE |\n \t\t\tPICKAXE_BLAME_COPY_HARDER);\n \ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 960e7ac08..0f368ad81 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -913,10 +913,10 @@ static int prepare_to_commit(const char *index_file, const char *prefix,\n \t\t\t * be really confusing.\n \t\t\t */\n \t\t\tstruct diff_flags flags = DIFF_FLAGS_INIT;\n-\t\t\tflags.OVERRIDE_SUBMODULE_CONFIG = 1;\n+\t\t\tflags.override_submodule_config = 1;\n \t\t\tif (ignore_submodule_arg &&\n \t\t\t    !strcmp(ignore_submodule_arg, \"all\"))\n-\t\t\t\tflags.IGNORE_SUBMODULES = 1;\n+\t\t\t\tflags.ignore_submodules = 1;\n \t\t\tcommitable = index_differs_from(parent, &flags, 1);\n \t\t}\n \t}\ndiff --git a/builtin/diff.c b/builtin/diff.c\nindex ed41eb5a5..3476e95e1 100644\n--- a/builtin/diff.c\n+++ b/builtin/diff.c\n@@ -44,7 +44,7 @@ static void stuff_change(struct diff_options *opt,\n \t    !oidcmp(old_oid, new_oid) && (old_mode == new_mode))\n \t\treturn;\n \n-\tif (opt->flags.REVERSE_DIFF) {\n+\tif (opt->flags.reverse_diff) {\n \t\tSWAP(old_mode, new_mode);\n \t\tSWAP(old_oid, new_oid);\n \t\tSWAP(old_path, new_path);\n@@ -350,8 +350,8 @@ int cmd_diff(int argc, const char **argv, const char *prefix)\n \trev.diffopt.stat_graph_width = -1;\n \n \t/* Default to let external and textconv be used */\n-\trev.diffopt.flags.ALLOW_EXTERNAL = 1;\n-\trev.diffopt.flags.ALLOW_TEXTCONV = 1;\n+\trev.diffopt.flags.allow_external = 1;\n+\trev.diffopt.flags.allow_textconv = 1;\n \n \tif (nongit)\n \t\tdie(_(\"Not a git repository\"));\n@@ -361,7 +361,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)\n \t\tdiff_setup_done(&rev.diffopt);\n \t}\n \n-\trev.diffopt.flags.RECURSIVE = 1;\n+\trev.diffopt.flags.recursive = 1;\n \n \tsetup_diff_pager(&rev.diffopt);\n \ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex 35c8fb65d..72672665b 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -1066,7 +1066,7 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)\n \t\tdie(\"revision walk setup failed\");\n \trevs.diffopt.format_callback = show_filemodify;\n \trevs.diffopt.format_callback_data = &paths_of_changed_objects;\n-\trevs.diffopt.flags.RECURSIVE = 1;\n+\trevs.diffopt.flags.recursive = 1;\n \twhile ((commit = get_revision(&revs))) {\n \t\tif (has_unshown_parent(commit)) {\n \t\t\tadd_object_array(&commit->object, NULL, &commits);\ndiff --git a/builtin/log.c b/builtin/log.c\nindex 4a24d3e48..f3d5a02be 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -121,16 +121,16 @@ static void cmd_log_init_defaults(struct rev_info *rev)\n \tif (fmt_pretty)\n \t\tget_commit_format(fmt_pretty, rev);\n \tif (default_follow)\n-\t\trev->diffopt.flags.DEFAULT_FOLLOW_RENAMES = 1;\n+\t\trev->diffopt.flags.default_follow_renames = 1;\n \trev->verbose_header = 1;\n-\trev->diffopt.flags.RECURSIVE = 1;\n+\trev->diffopt.flags.recursive = 1;\n \trev->diffopt.stat_width = -1; /* use full terminal width */\n \trev->diffopt.stat_graph_width = -1; /* respect statGraphWidth config */\n \trev->abbrev_commit = default_abbrev_commit;\n \trev->show_root_diff = default_show_root;\n \trev->subject_prefix = fmt_patch_subject_prefix;\n \trev->show_signature = default_show_signature;\n-\trev->diffopt.flags.ALLOW_TEXTCONV = 1;\n+\trev->diffopt.flags.allow_textconv = 1;\n \n \tif (default_date_mode)\n \t\tparse_date_format(default_date_mode, &rev->date_mode);\n@@ -181,7 +181,7 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,\n \t\tinit_display_notes(&rev->notes_opt);\n \n \tif (rev->diffopt.pickaxe || rev->diffopt.filter ||\n-\t    rev->diffopt.flags.FOLLOW_RENAMES)\n+\t    rev->diffopt.flags.follow_renames)\n \t\trev->always_show_header = 0;\n \n \tif (source)\n@@ -391,7 +391,7 @@ static int cmd_log_walk(struct rev_info *rev)\n \t\tfclose(rev->diffopt.file);\n \n \tif (rev->diffopt.output_format & DIFF_FORMAT_CHECKDIFF &&\n-\t    rev->diffopt.flags.CHECK_FAILED) {\n+\t    rev->diffopt.flags.check_failed) {\n \t\treturn 02;\n \t}\n \treturn diff_result_code(&rev->diffopt, 0);\n@@ -483,8 +483,8 @@ static int show_blob_object(const struct object_id *oid, struct rev_info *rev, c\n \tunsigned long size;\n \n \tfflush(rev->diffopt.file);\n-\tif (!rev->diffopt.flags.TEXTCONV_SET_VIA_CMDLINE ||\n-\t    !rev->diffopt.flags.ALLOW_TEXTCONV)\n+\tif (!rev->diffopt.flags.textconv_set_via_cmdline ||\n+\t    !rev->diffopt.flags.allow_textconv)\n \t\treturn stream_blob_to_fd(1, oid, NULL, 0);\n \n \tif (get_oid_with_context(obj_name, GET_OID_RECORD_PATH,\n@@ -666,9 +666,9 @@ int cmd_log_reflog(int argc, const char **argv, const char *prefix)\n static void log_setup_revisions_tweak(struct rev_info *rev,\n \t\t\t\t      struct setup_revision_opt *opt)\n {\n-\tif (rev->diffopt.flags.DEFAULT_FOLLOW_RENAMES &&\n+\tif (rev->diffopt.flags.default_follow_renames &&\n \t    rev->prune_data.nr == 1)\n-\t\trev->diffopt.flags.FOLLOW_RENAMES = 1;\n+\t\trev->diffopt.flags.follow_renames = 1;\n \n \t/* Turn --cc/-c into -p --cc/-c when -p was not given */\n \tif (!rev->diffopt.output_format && rev->combine_merges)\n@@ -1340,7 +1340,7 @@ static void prepare_bases(struct base_tree_info *bases,\n \t\treturn;\n \n \tdiff_setup(&diffopt);\n-\tdiffopt.flags.RECURSIVE = 1;\n+\tdiffopt.flags.recursive = 1;\n \tdiff_setup_done(&diffopt);\n \n \toidcpy(&bases->base_commit, &base->object.oid);\n@@ -1511,7 +1511,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \trev.verbose_header = 1;\n \trev.diff = 1;\n \trev.max_parents = 1;\n-\trev.diffopt.flags.RECURSIVE = 1;\n+\trev.diffopt.flags.recursive = 1;\n \trev.subject_prefix = fmt_patch_subject_prefix;\n \tmemset(&s_r_opt, 0, sizeof(s_r_opt));\n \ts_r_opt.def = \"HEAD\";\n@@ -1612,8 +1612,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \n \trev.zero_commit = zero_commit;\n \n-\tif (!rev.diffopt.flags.TEXT && !no_binary_diff)\n-\t\trev.diffopt.flags.BINARY = 1;\n+\tif (!rev.diffopt.flags.text && !no_binary_diff)\n+\t\trev.diffopt.flags.binary = 1;\n \n \tif (rev.show_notes)\n \t\tinit_display_notes(&rev.notes_opt);\ndiff --git a/builtin/reset.c b/builtin/reset.c\nindex 206819ef1..4b313a018 100644\n--- a/builtin/reset.c\n+++ b/builtin/reset.c\n@@ -166,7 +166,7 @@ static int read_from_tree(const struct pathspec *pathspec,\n \topt.output_format = DIFF_FORMAT_CALLBACK;\n \topt.format_callback = update_index_from_diff;\n \topt.format_callback_data = &intent_to_add;\n-\topt.flags.OVERRIDE_SUBMODULE_CONFIG = 1;\n+\topt.flags.override_submodule_config = 1;\n \n \tif (do_diff_cache(tree_oid, &opt))\n \t\treturn 1;\ndiff --git a/builtin/rev-list.c b/builtin/rev-list.c\nindex c62382171..1d3b6b61b 100644\n--- a/builtin/rev-list.c\n+++ b/builtin/rev-list.c\n@@ -294,7 +294,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)\n \tif (revs.bisect)\n \t\tbisect_list = 1;\n \n-\tif (revs.diffopt.flags.QUICK)\n+\tif (revs.diffopt.flags.quick)\n \t\tinfo.flags |= REV_LIST_QUIET;\n \tfor (i = 1 ; i < argc; i++) {\n \t\tconst char *arg = argv[i];\ndiff --git a/combine-diff.c b/combine-diff.c\nindex 5a3a8b49b..23f3d25e2 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -898,7 +898,7 @@ static void show_combined_header(struct combine_diff_path *elem,\n \t\t\t\t int show_file_header)\n {\n \tstruct diff_options *opt = &rev->diffopt;\n-\tint abbrev = opt->flags.FULL_INDEX ? GIT_SHA1_HEXSZ : DEFAULT_ABBREV;\n+\tint abbrev = opt->flags.full_index ? GIT_SHA1_HEXSZ : DEFAULT_ABBREV;\n \tconst char *a_prefix = opt->a_prefix ? opt->a_prefix : \"a/\";\n \tconst char *b_prefix = opt->b_prefix ? opt->b_prefix : \"b/\";\n \tconst char *c_meta = diff_get_color_opt(opt, DIFF_METAINFO);\n@@ -987,7 +987,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,\n \tuserdiff = userdiff_find_by_path(elem->path);\n \tif (!userdiff)\n \t\tuserdiff = userdiff_find_by_name(\"default\");\n-\tif (opt->flags.ALLOW_TEXTCONV)\n+\tif (opt->flags.allow_textconv)\n \t\ttextconv = userdiff_get_textconv(userdiff);\n \n \t/* Read the result of merge first */\n@@ -1413,8 +1413,8 @@ void diff_tree_combined(const struct object_id *oid,\n \n \tdiffopts = *opt;\n \tcopy_pathspec(&diffopts.pathspec, &opt->pathspec);\n-\tdiffopts.flags.RECURSIVE = 1;\n-\tdiffopts.flags.ALLOW_EXTERNAL = 0;\n+\tdiffopts.flags.recursive = 1;\n+\tdiffopts.flags.allow_external = 0;\n \n \t/* find set of paths that everybody touches\n \t *\n@@ -1435,7 +1435,7 @@ void diff_tree_combined(const struct object_id *oid,\n \t * NOTE please keep this semantically in sync with diffcore_std()\n \t */\n \tneed_generic_pathscan = opt->skip_stat_unmatch\t||\n-\t\t\topt->flags.FOLLOW_RENAMES\t||\n+\t\t\topt->flags.follow_renames\t||\n \t\t\topt->break_opt != -1\t||\n \t\t\topt->detect_rename\t||\n \t\t\topt->pickaxe\t\t||\ndiff --git a/diff-lib.c b/diff-lib.c\nindex b1ec804fe..9d04972b9 100644\n--- a/diff-lib.c\n+++ b/diff-lib.c\n@@ -72,14 +72,14 @@ static int match_stat_with_submodule(struct diff_options *diffopt,\n \tint changed = ce_match_stat(ce, st, ce_option);\n \tif (S_ISGITLINK(ce->ce_mode)) {\n \t\tstruct diff_flags orig_flags = diffopt->flags;\n-\t\tif (!diffopt->flags.OVERRIDE_SUBMODULE_CONFIG)\n+\t\tif (!diffopt->flags.override_submodule_config)\n \t\t\tset_diffopt_flags_from_submodule_config(diffopt, ce->name);\n-\t\tif (diffopt->flags.IGNORE_SUBMODULES)\n+\t\tif (diffopt->flags.ignore_submodules)\n \t\t\tchanged = 0;\n-\t\telse if (!diffopt->flags.IGNORE_DIRTY_SUBMODULES &&\n-\t\t\t (!changed || diffopt->flags.DIRTY_SUBMODULES))\n+\t\telse if (!diffopt->flags.ignore_dirty_submodules &&\n+\t\t\t (!changed || diffopt->flags.dirty_submodules))\n \t\t\t*dirty_submodule = is_submodule_modified(ce->name,\n-\t\t\t\t\t\t\t\t diffopt->flags.IGNORE_UNTRACKED_IN_SUBMODULES);\n+\t\t\t\t\t\t\t\t diffopt->flags.ignore_untracked_in_submodules);\n \t\tdiffopt->flags = orig_flags;\n \t}\n \treturn changed;\n@@ -229,7 +229,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)\n \n \t\tif (!changed && !dirty_submodule) {\n \t\t\tce_mark_uptodate(ce);\n-\t\t\tif (!revs->diffopt.flags.FIND_COPIES_HARDER)\n+\t\t\tif (!revs->diffopt.flags.find_copies_harder)\n \t\t\t\tcontinue;\n \t\t}\n \t\toldmode = ce->ce_mode;\n@@ -363,7 +363,7 @@ static int show_modified(struct rev_info *revs,\n \n \toldmode = old->ce_mode;\n \tif (mode == oldmode && !oidcmp(oid, &old->oid) && !dirty_submodule &&\n-\t    !revs->diffopt.flags.FIND_COPIES_HARDER)\n+\t    !revs->diffopt.flags.find_copies_harder)\n \t\treturn 0;\n \n \tdiff_change(&revs->diffopt, oldmode, mode,\n@@ -494,7 +494,7 @@ static int diff_cache(struct rev_info *revs,\n \topts.head_idx = 1;\n \topts.index_only = cached;\n \topts.diff_index_cached = (cached &&\n-\t\t\t\t  !revs->diffopt.flags.FIND_COPIES_HARDER);\n+\t\t\t\t  !revs->diffopt.flags.find_copies_harder);\n \topts.merge = 1;\n \topts.fn = oneway_diff;\n \topts.unpack_data = revs;\n@@ -545,12 +545,12 @@ int index_differs_from(const char *def, const struct diff_flags *flags,\n \tmemset(&opt, 0, sizeof(opt));\n \topt.def = def;\n \tsetup_revisions(0, NULL, &rev, &opt);\n-\trev.diffopt.flags.QUICK = 1;\n-\trev.diffopt.flags.EXIT_WITH_STATUS = 1;\n+\trev.diffopt.flags.quick = 1;\n+\trev.diffopt.flags.exit_with_status = 1;\n \tif (flags)\n \t\trev.diffopt.flags = diff_flags_or(&rev.diffopt.flags, flags);\n \trev.diffopt.ita_invisible_in_index = ita_invisible_in_index;\n \trun_diff_index(&rev, 1);\n \tobject_array_clear(&rev.pending);\n-\treturn (rev.diffopt.flags.HAS_CHANGES != 0);\n+\treturn (rev.diffopt.flags.has_changes != 0);\n }\ndiff --git a/diff-no-index.c b/diff-no-index.c\nindex a3e194340..0ed5f0f49 100644\n--- a/diff-no-index.c\n+++ b/diff-no-index.c\n@@ -184,7 +184,7 @@ static int queue_diff(struct diff_options *o,\n \t} else {\n \t\tstruct diff_filespec *d1, *d2;\n \n-\t\tif (o->flags.REVERSE_DIFF) {\n+\t\tif (o->flags.reverse_diff) {\n \t\t\tSWAP(mode1, mode2);\n \t\t\tSWAP(name1, name2);\n \t\t}\n@@ -276,16 +276,16 @@ void diff_no_index(struct rev_info *revs,\n \tif (!revs->diffopt.output_format)\n \t\trevs->diffopt.output_format = DIFF_FORMAT_PATCH;\n \n-\trevs->diffopt.flags.NO_INDEX = 1;\n+\trevs->diffopt.flags.no_index = 1;\n \n-\trevs->diffopt.flags.RELATIVE_NAME = 1;\n+\trevs->diffopt.flags.relative_name = 1;\n \trevs->diffopt.prefix = prefix;\n \n \trevs->max_count = -2;\n \tdiff_setup_done(&revs->diffopt);\n \n \tsetup_diff_pager(&revs->diffopt);\n-\trevs->diffopt.flags.EXIT_WITH_STATUS = 1;\n+\trevs->diffopt.flags.exit_with_status = 1;\n \n \tif (queue_diff(&revs->diffopt, paths[0], paths[1]))\n \t\texit(1);\ndiff --git a/diff.c b/diff.c\nindex 0e5abb5ce..0459aa43e 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -124,18 +124,18 @@ static int parse_dirstat_params(struct diff_options *options, const char *params\n \tfor (i = 0; i < params.nr; i++) {\n \t\tconst char *p = params.items[i].string;\n \t\tif (!strcmp(p, \"changes\")) {\n-\t\t\toptions->flags.DIRSTAT_BY_LINE = 0;\n-\t\t\toptions->flags.DIRSTAT_BY_FILE = 0;\n+\t\t\toptions->flags.dirstat_by_line = 0;\n+\t\t\toptions->flags.dirstat_by_file = 0;\n \t\t} else if (!strcmp(p, \"lines\")) {\n-\t\t\toptions->flags.DIRSTAT_BY_LINE = 1;\n-\t\t\toptions->flags.DIRSTAT_BY_FILE = 0;\n+\t\t\toptions->flags.dirstat_by_line = 1;\n+\t\t\toptions->flags.dirstat_by_file = 0;\n \t\t} else if (!strcmp(p, \"files\")) {\n-\t\t\toptions->flags.DIRSTAT_BY_LINE = 0;\n-\t\t\toptions->flags.DIRSTAT_BY_FILE = 1;\n+\t\t\toptions->flags.dirstat_by_line = 0;\n+\t\t\toptions->flags.dirstat_by_file = 1;\n \t\t} else if (!strcmp(p, \"noncumulative\")) {\n-\t\t\toptions->flags.DIRSTAT_CUMULATIVE = 0;\n+\t\t\toptions->flags.dirstat_cumulative = 0;\n \t\t} else if (!strcmp(p, \"cumulative\")) {\n-\t\t\toptions->flags.DIRSTAT_CUMULATIVE = 1;\n+\t\t\toptions->flags.dirstat_cumulative = 1;\n \t\t} else if (isdigit(*p)) {\n \t\t\tchar *end;\n \t\t\tint permille = strtoul(p, &end, 10) * 10;\n@@ -1481,7 +1481,7 @@ static void emit_rewrite_diff(const char *name_a,\n \tstruct emit_callback ecbdata;\n \tstruct strbuf out = STRBUF_INIT;\n \n-\tif (diff_mnemonic_prefix && o->flags.REVERSE_DIFF) {\n+\tif (diff_mnemonic_prefix && o->flags.reverse_diff) {\n \t\ta_prefix = o->b_prefix;\n \t\tb_prefix = o->a_prefix;\n \t} else {\n@@ -2729,7 +2729,7 @@ static void show_dirstat(struct diff_options *options)\n \tdir.alloc = 0;\n \tdir.nr = 0;\n \tdir.permille = options->dirstat_permille;\n-\tdir.cumulative = options->flags.DIRSTAT_CUMULATIVE;\n+\tdir.cumulative = options->flags.dirstat_cumulative;\n \n \tchanged = 0;\n \tfor (i = 0; i < q->nr; i++) {\n@@ -2755,7 +2755,7 @@ static void show_dirstat(struct diff_options *options)\n \t\t\tgoto found_damage;\n \t\t}\n \n-\t\tif (options->flags.DIRSTAT_BY_FILE) {\n+\t\tif (options->flags.dirstat_by_file) {\n \t\t\t/*\n \t\t\t * In --dirstat-by-file mode, we don't really need to\n \t\t\t * look at the actual file contents at all.\n@@ -2830,7 +2830,7 @@ static void show_dirstat_by_line(struct diffstat_t *data, struct diff_options *o\n \tdir.alloc = 0;\n \tdir.nr = 0;\n \tdir.permille = options->dirstat_permille;\n-\tdir.cumulative = options->flags.DIRSTAT_CUMULATIVE;\n+\tdir.cumulative = options->flags.dirstat_cumulative;\n \n \tchanged = 0;\n \tfor (i = 0; i < data->nr; i++) {\n@@ -3117,7 +3117,7 @@ static void builtin_diff(const char *name_a,\n \tconst char *line_prefix = diff_line_prefix(o);\n \n \tdiff_set_mnemonic_prefix(o, \"a/\", \"b/\");\n-\tif (o->flags.REVERSE_DIFF) {\n+\tif (o->flags.reverse_diff) {\n \t\ta_prefix = o->b_prefix;\n \t\tb_prefix = o->a_prefix;\n \t} else {\n@@ -3141,7 +3141,7 @@ static void builtin_diff(const char *name_a,\n \t\treturn;\n \t}\n \n-\tif (o->flags.ALLOW_TEXTCONV) {\n+\tif (o->flags.allow_textconv) {\n \t\ttextconv_one = get_textconv(one);\n \t\ttextconv_two = get_textconv(two);\n \t}\n@@ -3201,13 +3201,13 @@ static void builtin_diff(const char *name_a,\n \t\t\t\t header.len, 0);\n \t\tstrbuf_reset(&header);\n \t\tgoto free_ab_and_return;\n-\t} else if (!o->flags.TEXT &&\n+\t} else if (!o->flags.text &&\n \t    ( (!textconv_one && diff_filespec_is_binary(one)) ||\n \t      (!textconv_two && diff_filespec_is_binary(two)) )) {\n \t\tstruct strbuf sb = STRBUF_INIT;\n \t\tif (!one->data && !two->data &&\n \t\t    S_ISREG(one->mode) && S_ISREG(two->mode) &&\n-\t\t    !o->flags.BINARY) {\n+\t\t    !o->flags.binary) {\n \t\t\tif (!oidcmp(&one->oid, &two->oid)) {\n \t\t\t\tif (must_show_header)\n \t\t\t\t\temit_diff_symbol(o, DIFF_SYMBOL_HEADER,\n@@ -3236,7 +3236,7 @@ static void builtin_diff(const char *name_a,\n \t\t}\n \t\temit_diff_symbol(o, DIFF_SYMBOL_HEADER, header.buf, header.len, 0);\n \t\tstrbuf_reset(&header);\n-\t\tif (o->flags.BINARY)\n+\t\tif (o->flags.binary)\n \t\t\temit_binary_diff(o, &mf1, &mf2);\n \t\telse {\n \t\t\tstrbuf_addf(&sb, \"%sBinary files %s and %s differ\\n\",\n@@ -3282,7 +3282,7 @@ static void builtin_diff(const char *name_a,\n \t\txecfg.ctxlen = o->context;\n \t\txecfg.interhunkctxlen = o->interhunkcontext;\n \t\txecfg.flags = XDL_EMIT_FUNCNAMES;\n-\t\tif (o->flags.FUNCCONTEXT)\n+\t\tif (o->flags.funccontext)\n \t\t\txecfg.flags |= XDL_EMIT_FUNCCONTEXT;\n \t\tif (pe)\n \t\t\txdiff_set_find_func(&xecfg, pe->pattern, pe->cflags);\n@@ -3447,7 +3447,7 @@ static void builtin_checkdiff(const char *name_a, const char *name_b,\n \tdiff_free_filespec_data(one);\n \tdiff_free_filespec_data(two);\n \tif (data.status)\n-\t\to->flags.CHECK_FAILED = 1;\n+\t\to->flags.check_failed = 1;\n }\n \n struct diff_filespec *alloc_filespec(const char *path)\n@@ -3941,9 +3941,9 @@ static void fill_metainfo(struct strbuf *msg,\n \t\t*must_show_header = 0;\n \t}\n \tif (one && two && oidcmp(&one->oid, &two->oid)) {\n-\t\tint abbrev = o->flags.FULL_INDEX ? 40 : DEFAULT_ABBREV;\n+\t\tint abbrev = o->flags.full_index ? 40 : DEFAULT_ABBREV;\n \n-\t\tif (o->flags.BINARY) {\n+\t\tif (o->flags.binary) {\n \t\t\tmmfile_t mf;\n \t\t\tif ((!fill_mmfile(&mf, one) && diff_filespec_is_binary(one)) ||\n \t\t\t    (!fill_mmfile(&mf, two) && diff_filespec_is_binary(two)))\n@@ -3973,7 +3973,7 @@ static void run_diff_cmd(const char *pgm,\n \tint must_show_header = 0;\n \n \n-\tif (o->flags.ALLOW_EXTERNAL) {\n+\tif (o->flags.allow_external) {\n \t\tstruct userdiff_driver *drv = userdiff_find_by_path(attr_path);\n \t\tif (drv && drv->external)\n \t\t\tpgm = drv->external;\n@@ -4053,7 +4053,7 @@ static void run_diff(struct diff_filepair *p, struct diff_options *o)\n \tif (o->prefix_length)\n \t\tstrip_prefix(o->prefix_length, &name, &other);\n \n-\tif (!o->flags.ALLOW_EXTERNAL)\n+\tif (!o->flags.allow_external)\n \t\tpgm = NULL;\n \n \tif (DIFF_PAIR_UNMERGED(p)) {\n@@ -4152,7 +4152,7 @@ void diff_setup(struct diff_options *options)\n \toptions->context = diff_context_default;\n \toptions->interhunkcontext = diff_interhunk_context_default;\n \toptions->ws_error_highlight = ws_error_highlight_default;\n-\toptions->flags.RENAME_EMPTY = 1;\n+\toptions->flags.rename_empty = 1;\n \n \t/* pathchange left =NULL by default */\n \toptions->change = diff_change;\n@@ -4203,14 +4203,14 @@ void diff_setup_done(struct diff_options *options)\n \tif (DIFF_XDL_TST(options, IGNORE_WHITESPACE) ||\n \t    DIFF_XDL_TST(options, IGNORE_WHITESPACE_CHANGE) ||\n \t    DIFF_XDL_TST(options, IGNORE_WHITESPACE_AT_EOL))\n-\t\toptions->flags.DIFF_FROM_CONTENTS = 1;\n+\t\toptions->flags.diff_from_contents = 1;\n \telse\n-\t\toptions->flags.DIFF_FROM_CONTENTS = 0;\n+\t\toptions->flags.diff_from_contents = 0;\n \n-\tif (options->flags.FIND_COPIES_HARDER)\n+\tif (options->flags.find_copies_harder)\n \t\toptions->detect_rename = DIFF_DETECT_COPY;\n \n-\tif (!options->flags.RELATIVE_NAME)\n+\tif (!options->flags.relative_name)\n \t\toptions->prefix = NULL;\n \tif (options->prefix)\n \t\toptions->prefix_length = strlen(options->prefix);\n@@ -4240,18 +4240,18 @@ void diff_setup_done(struct diff_options *options)\n \t\t\t\t      DIFF_FORMAT_DIRSTAT |\n \t\t\t\t      DIFF_FORMAT_SUMMARY |\n \t\t\t\t      DIFF_FORMAT_CHECKDIFF))\n-\t\toptions->flags.RECURSIVE = 1;\n+\t\toptions->flags.recursive = 1;\n \t/*\n \t * Also pickaxe would not work very well if you do not say recursive\n \t */\n \tif (options->pickaxe)\n-\t\toptions->flags.RECURSIVE = 1;\n+\t\toptions->flags.recursive = 1;\n \t/*\n \t * When patches are generated, submodules diffed against the work tree\n \t * must be checked for dirtiness too so it can be shown in the output\n \t */\n \tif (options->output_format & DIFF_FORMAT_PATCH)\n-\t\toptions->flags.DIRTY_SUBMODULES = 1;\n+\t\toptions->flags.dirty_submodules = 1;\n \n \tif (options->detect_rename && options->rename_limit < 0)\n \t\toptions->rename_limit = diff_rename_limit_default;\n@@ -4273,14 +4273,14 @@ void diff_setup_done(struct diff_options *options)\n \t * to have found.  It does not make sense not to return with\n \t * exit code in such a case either.\n \t */\n-\tif (options->flags.QUICK) {\n+\tif (options->flags.quick) {\n \t\toptions->output_format = DIFF_FORMAT_NO_OUTPUT;\n-\t\toptions->flags.EXIT_WITH_STATUS = 1;\n+\t\toptions->flags.exit_with_status = 1;\n \t}\n \n \toptions->diff_path_counter = 0;\n \n-\tif (options->flags.FOLLOW_RENAMES && options->pathspec.nr != 1)\n+\tif (options->flags.follow_renames && options->pathspec.nr != 1)\n \t\tdie(_(\"--follow requires exactly one pathspec\"));\n \n \tif (!options->use_color || external_diff())\n@@ -4630,7 +4630,7 @@ int diff_opt_parse(struct diff_options *options,\n \telse if (starts_with(arg, \"-C\") || starts_with(arg, \"--find-copies=\") ||\n \t\t !strcmp(arg, \"--find-copies\")) {\n \t\tif (options->detect_rename == DIFF_DETECT_COPY)\n-\t\t\toptions->flags.FIND_COPIES_HARDER = 1;\n+\t\t\toptions->flags.find_copies_harder = 1;\n \t\tif ((options->rename_score = diff_scoreopt_parse(arg)) == -1)\n \t\t\treturn error(\"invalid argument to -C: %s\", arg+2);\n \t\toptions->detect_rename = DIFF_DETECT_COPY;\n@@ -4638,13 +4638,13 @@ int diff_opt_parse(struct diff_options *options,\n \telse if (!strcmp(arg, \"--no-renames\"))\n \t\toptions->detect_rename = 0;\n \telse if (!strcmp(arg, \"--rename-empty\"))\n-\t\toptions->flags.RENAME_EMPTY = 1;\n+\t\toptions->flags.rename_empty = 1;\n \telse if (!strcmp(arg, \"--no-rename-empty\"))\n-\t\toptions->flags.RENAME_EMPTY = 0;\n+\t\toptions->flags.rename_empty = 0;\n \telse if (!strcmp(arg, \"--relative\"))\n-\t\toptions->flags.RELATIVE_NAME = 1;\n+\t\toptions->flags.relative_name = 1;\n \telse if (skip_prefix(arg, \"--relative=\", &arg)) {\n-\t\toptions->flags.RELATIVE_NAME = 1;\n+\t\toptions->flags.relative_name = 1;\n \t\toptions->prefix = arg;\n \t}\n \n@@ -4684,21 +4684,21 @@ int diff_opt_parse(struct diff_options *options,\n \t/* flags options */\n \telse if (!strcmp(arg, \"--binary\")) {\n \t\tenable_patch_output(&options->output_format);\n-\t\toptions->flags.BINARY = 1;\n+\t\toptions->flags.binary = 1;\n \t}\n \telse if (!strcmp(arg, \"--full-index\"))\n-\t\toptions->flags.FULL_INDEX = 1;\n+\t\toptions->flags.full_index = 1;\n \telse if (!strcmp(arg, \"-a\") || !strcmp(arg, \"--text\"))\n-\t\toptions->flags.TEXT = 1;\n+\t\toptions->flags.text = 1;\n \telse if (!strcmp(arg, \"-R\"))\n-\t\toptions->flags.REVERSE_DIFF = 1;\n+\t\toptions->flags.reverse_diff = 1;\n \telse if (!strcmp(arg, \"--find-copies-harder\"))\n-\t\toptions->flags.FIND_COPIES_HARDER = 1;\n+\t\toptions->flags.find_copies_harder = 1;\n \telse if (!strcmp(arg, \"--follow\"))\n-\t\toptions->flags.FOLLOW_RENAMES = 1;\n+\t\toptions->flags.follow_renames = 1;\n \telse if (!strcmp(arg, \"--no-follow\")) {\n-\t\toptions->flags.FOLLOW_RENAMES = 0;\n-\t\toptions->flags.DEFAULT_FOLLOW_RENAMES = 0;\n+\t\toptions->flags.follow_renames = 0;\n+\t\toptions->flags.default_follow_renames = 0;\n \t} else if (!strcmp(arg, \"--color\"))\n \t\toptions->use_color = 1;\n \telse if (skip_prefix(arg, \"--color=\", &arg)) {\n@@ -4755,24 +4755,24 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn argcount;\n \t}\n \telse if (!strcmp(arg, \"--exit-code\"))\n-\t\toptions->flags.EXIT_WITH_STATUS = 1;\n+\t\toptions->flags.exit_with_status = 1;\n \telse if (!strcmp(arg, \"--quiet\"))\n-\t\toptions->flags.QUICK = 1;\n+\t\toptions->flags.quick = 1;\n \telse if (!strcmp(arg, \"--ext-diff\"))\n-\t\toptions->flags.ALLOW_EXTERNAL = 1;\n+\t\toptions->flags.allow_external = 1;\n \telse if (!strcmp(arg, \"--no-ext-diff\"))\n-\t\toptions->flags.ALLOW_EXTERNAL = 0;\n+\t\toptions->flags.allow_external = 0;\n \telse if (!strcmp(arg, \"--textconv\")) {\n-\t\toptions->flags.ALLOW_TEXTCONV = 1;\n-\t\toptions->flags.TEXTCONV_SET_VIA_CMDLINE = 1;\n+\t\toptions->flags.allow_textconv = 1;\n+\t\toptions->flags.textconv_set_via_cmdline = 1;\n \t} else if (!strcmp(arg, \"--no-textconv\")) {\n-\t\toptions->flags.ALLOW_TEXTCONV = 0;\n-\t\toptions->flags.TEXTCONV_SET_VIA_CMDLINE = 0;\n+\t\toptions->flags.allow_textconv = 0;\n+\t\toptions->flags.textconv_set_via_cmdline = 0;\n \t} else if (!strcmp(arg, \"--ignore-submodules\")) {\n-\t\toptions->flags.OVERRIDE_SUBMODULE_CONFIG = 1;\n+\t\toptions->flags.override_submodule_config = 1;\n \t\thandle_ignore_submodules_arg(options, \"all\");\n \t} else if (skip_prefix(arg, \"--ignore-submodules=\", &arg)) {\n-\t\toptions->flags.OVERRIDE_SUBMODULE_CONFIG = 1;\n+\t\toptions->flags.override_submodule_config = 1;\n \t\thandle_ignore_submodules_arg(options, arg);\n \t} else if (!strcmp(arg, \"--submodule\"))\n \t\toptions->submodule_format = DIFF_SUBMODULE_LOG;\n@@ -4847,11 +4847,11 @@ int diff_opt_parse(struct diff_options *options,\n \t\t\t &options->interhunkcontext))\n \t\t;\n \telse if (!strcmp(arg, \"-W\"))\n-\t\toptions->flags.FUNCCONTEXT = 1;\n+\t\toptions->flags.funccontext = 1;\n \telse if (!strcmp(arg, \"--function-context\"))\n-\t\toptions->flags.FUNCCONTEXT = 1;\n+\t\toptions->flags.funccontext = 1;\n \telse if (!strcmp(arg, \"--no-function-context\"))\n-\t\toptions->flags.FUNCCONTEXT = 0;\n+\t\toptions->flags.funccontext = 0;\n \telse if ((argcount = parse_long_opt(\"output\", av, &optarg))) {\n \t\tchar *path = prefix_filename(prefix, optarg);\n \t\toptions->file = xfopen(path, \"w\");\n@@ -5601,7 +5601,7 @@ void diff_flush(struct diff_options *options)\n \t\tseparator++;\n \t}\n \n-\tif (output_format & DIFF_FORMAT_DIRSTAT && options->flags.DIRSTAT_BY_LINE)\n+\tif (output_format & DIFF_FORMAT_DIRSTAT && options->flags.dirstat_by_line)\n \t\tdirstat_by_line = 1;\n \n \tif (output_format & (DIFF_FORMAT_DIFFSTAT|DIFF_FORMAT_SHORTSTAT|DIFF_FORMAT_NUMSTAT) ||\n@@ -5636,8 +5636,8 @@ void diff_flush(struct diff_options *options)\n \t}\n \n \tif (output_format & DIFF_FORMAT_NO_OUTPUT &&\n-\t    options->flags.EXIT_WITH_STATUS &&\n-\t    options->flags.DIFF_FROM_CONTENTS) {\n+\t    options->flags.exit_with_status &&\n+\t    options->flags.diff_from_contents) {\n \t\t/*\n \t\t * run diff_flush_patch for the exit status. setting\n \t\t * options->file to /dev/null should be safe, because we\n@@ -5685,11 +5685,11 @@ void diff_flush(struct diff_options *options)\n \t * diff_addremove/diff_change does not set the bit when\n \t * DIFF_FROM_CONTENTS is in effect (e.g. with -w).\n \t */\n-\tif (options->flags.DIFF_FROM_CONTENTS) {\n+\tif (options->flags.diff_from_contents) {\n \t\tif (options->found_changes)\n-\t\t\toptions->flags.HAS_CHANGES = 1;\n+\t\t\toptions->flags.has_changes = 1;\n \t\telse\n-\t\t\toptions->flags.HAS_CHANGES = 0;\n+\t\t\toptions->flags.has_changes = 0;\n \t}\n }\n \n@@ -5809,7 +5809,7 @@ static void diffcore_skip_stat_unmatch(struct diff_options *diffopt)\n \t\t\t * to determine how many paths were dirty only\n \t\t\t * due to stat info mismatch.\n \t\t\t */\n-\t\t\tif (!diffopt->flags.NO_INDEX)\n+\t\t\tif (!diffopt->flags.no_index)\n \t\t\t\tdiffopt->skip_stat_unmatch++;\n \t\t\tdiff_free_filepair(p);\n \t\t}\n@@ -5858,10 +5858,10 @@ void diffcore_std(struct diff_options *options)\n \t\tdiff_resolve_rename_copy();\n \tdiffcore_apply_filter(options);\n \n-\tif (diff_queued_diff.nr && !options->flags.DIFF_FROM_CONTENTS)\n-\t\toptions->flags.HAS_CHANGES = 1;\n+\tif (diff_queued_diff.nr && !options->flags.diff_from_contents)\n+\t\toptions->flags.has_changes = 1;\n \telse\n-\t\toptions->flags.HAS_CHANGES = 0;\n+\t\toptions->flags.has_changes = 0;\n \n \toptions->found_follow = 0;\n }\n@@ -5873,23 +5873,23 @@ int diff_result_code(struct diff_options *opt, int status)\n \tdiff_warn_rename_limit(\"diff.renameLimit\",\n \t\t\t       opt->needed_rename_limit,\n \t\t\t       opt->degraded_cc_to_c);\n-\tif (!opt->flags.EXIT_WITH_STATUS &&\n+\tif (!opt->flags.exit_with_status &&\n \t    !(opt->output_format & DIFF_FORMAT_CHECKDIFF))\n \t\treturn status;\n-\tif (opt->flags.EXIT_WITH_STATUS &&\n-\t    opt->flags.HAS_CHANGES)\n+\tif (opt->flags.exit_with_status &&\n+\t    opt->flags.has_changes)\n \t\tresult |= 01;\n \tif ((opt->output_format & DIFF_FORMAT_CHECKDIFF) &&\n-\t    opt->flags.CHECK_FAILED)\n+\t    opt->flags.check_failed)\n \t\tresult |= 02;\n \treturn result;\n }\n \n int diff_can_quit_early(struct diff_options *opt)\n {\n-\treturn (opt->flags.QUICK &&\n+\treturn (opt->flags.quick &&\n \t\t!opt->filter &&\n-\t\topt->flags.HAS_CHANGES);\n+\t\topt->flags.has_changes);\n }\n \n /*\n@@ -5902,9 +5902,9 @@ static int is_submodule_ignored(const char *path, struct diff_options *options)\n {\n \tint ignored = 0;\n \tstruct diff_flags orig_flags = options->flags;\n-\tif (!options->flags.OVERRIDE_SUBMODULE_CONFIG)\n+\tif (!options->flags.override_submodule_config)\n \t\tset_diffopt_flags_from_submodule_config(options, path);\n-\tif (options->flags.IGNORE_SUBMODULES)\n+\tif (options->flags.ignore_submodules)\n \t\tignored = 1;\n \toptions->flags = orig_flags;\n \treturn ignored;\n@@ -5933,7 +5933,7 @@ void diff_addremove(struct diff_options *options,\n \t * Before the final output happens, they are pruned after\n \t * merged into rename/copy pairs as appropriate.\n \t */\n-\tif (options->flags.REVERSE_DIFF)\n+\tif (options->flags.reverse_diff)\n \t\taddremove = (addremove == '+' ? '-' :\n \t\t\t     addremove == '-' ? '+' : addremove);\n \n@@ -5952,8 +5952,8 @@ void diff_addremove(struct diff_options *options,\n \t}\n \n \tdiff_queue(&diff_queued_diff, one, two);\n-\tif (!options->flags.DIFF_FROM_CONTENTS)\n-\t\toptions->flags.HAS_CHANGES = 1;\n+\tif (!options->flags.diff_from_contents)\n+\t\toptions->flags.has_changes = 1;\n }\n \n void diff_change(struct diff_options *options,\n@@ -5971,7 +5971,7 @@ void diff_change(struct diff_options *options,\n \t    is_submodule_ignored(concatpath, options))\n \t\treturn;\n \n-\tif (options->flags.REVERSE_DIFF) {\n+\tif (options->flags.reverse_diff) {\n \t\tSWAP(old_mode, new_mode);\n \t\tSWAP(old_oid, new_oid);\n \t\tSWAP(old_oid_valid, new_oid_valid);\n@@ -5990,14 +5990,14 @@ void diff_change(struct diff_options *options,\n \ttwo->dirty_submodule = new_dirty_submodule;\n \tp = diff_queue(&diff_queued_diff, one, two);\n \n-\tif (options->flags.DIFF_FROM_CONTENTS)\n+\tif (options->flags.diff_from_contents)\n \t\treturn;\n \n-\tif (options->flags.QUICK && options->skip_stat_unmatch &&\n+\tif (options->flags.quick && options->skip_stat_unmatch &&\n \t    !diff_filespec_check_stat_unmatch(p))\n \t\treturn;\n \n-\toptions->flags.HAS_CHANGES = 1;\n+\toptions->flags.has_changes = 1;\n }\n \n struct diff_filepair *diff_unmerge(struct diff_options *options, const char *path)\n@@ -6135,7 +6135,7 @@ void setup_diff_pager(struct diff_options *opt)\n \t * and because it is easy to find people oneline advising \"git diff\n \t * --exit-code\" in hooks and other scripts, we do not do so.\n \t */\n-\tif (!opt->flags.EXIT_WITH_STATUS &&\n+\tif (!opt->flags.exit_with_status &&\n \t    check_pager_config(\"diff\") != 0)\n \t\tsetup_pager();\n }\ndiff --git a/diff.h b/diff.h\nindex f68fcf737..0ba645711 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -62,37 +62,37 @@ typedef struct strbuf *(*diff_prefix_fn_t)(struct diff_options *opt, void *data)\n \n #define DIFF_FLAGS_INIT { 0 }\n struct diff_flags {\n-\tunsigned RECURSIVE:1;\n-\tunsigned TREE_IN_RECURSIVE:1;\n-\tunsigned BINARY:1;\n-\tunsigned TEXT:1;\n-\tunsigned FULL_INDEX:1;\n-\tunsigned SILENT_ON_REMOVE:1;\n-\tunsigned FIND_COPIES_HARDER:1;\n-\tunsigned FOLLOW_RENAMES:1;\n-\tunsigned RENAME_EMPTY:1;\n-\tunsigned HAS_CHANGES:1;\n-\tunsigned QUICK:1;\n-\tunsigned NO_INDEX:1;\n-\tunsigned ALLOW_EXTERNAL:1;\n-\tunsigned EXIT_WITH_STATUS:1;\n-\tunsigned REVERSE_DIFF:1;\n-\tunsigned CHECK_FAILED:1;\n-\tunsigned RELATIVE_NAME:1;\n-\tunsigned IGNORE_SUBMODULES:1;\n-\tunsigned DIRSTAT_CUMULATIVE:1;\n-\tunsigned DIRSTAT_BY_FILE:1;\n-\tunsigned ALLOW_TEXTCONV:1;\n-\tunsigned TEXTCONV_SET_VIA_CMDLINE:1;\n-\tunsigned DIFF_FROM_CONTENTS:1;\n-\tunsigned DIRTY_SUBMODULES:1;\n-\tunsigned IGNORE_UNTRACKED_IN_SUBMODULES:1;\n-\tunsigned IGNORE_DIRTY_SUBMODULES:1;\n-\tunsigned OVERRIDE_SUBMODULE_CONFIG:1;\n-\tunsigned DIRSTAT_BY_LINE:1;\n-\tunsigned FUNCCONTEXT:1;\n-\tunsigned PICKAXE_IGNORE_CASE:1;\n-\tunsigned DEFAULT_FOLLOW_RENAMES:1;\n+\tunsigned recursive:1;\n+\tunsigned tree_in_recursive:1;\n+\tunsigned binary:1;\n+\tunsigned text:1;\n+\tunsigned full_index:1;\n+\tunsigned silent_on_remove:1;\n+\tunsigned find_copies_harder:1;\n+\tunsigned follow_renames:1;\n+\tunsigned rename_empty:1;\n+\tunsigned has_changes:1;\n+\tunsigned quick:1;\n+\tunsigned no_index:1;\n+\tunsigned allow_external:1;\n+\tunsigned exit_with_status:1;\n+\tunsigned reverse_diff:1;\n+\tunsigned check_failed:1;\n+\tunsigned relative_name:1;\n+\tunsigned ignore_submodules:1;\n+\tunsigned dirstat_cumulative:1;\n+\tunsigned dirstat_by_file:1;\n+\tunsigned allow_textconv:1;\n+\tunsigned textconv_set_via_cmdline:1;\n+\tunsigned diff_from_contents:1;\n+\tunsigned dirty_submodules:1;\n+\tunsigned ignore_untracked_in_submodules:1;\n+\tunsigned ignore_dirty_submodules:1;\n+\tunsigned override_submodule_config:1;\n+\tunsigned dirstat_by_line:1;\n+\tunsigned funccontext:1;\n+\tunsigned pickaxe_ignore_case:1;\n+\tunsigned default_follow_renames:1;\n };\n \n static inline struct diff_flags diff_flags_or(const struct diff_flags *a,\ndiff --git a/diffcore-pickaxe.c b/diffcore-pickaxe.c\nindex 6193c07f6..9476bd210 100644\n--- a/diffcore-pickaxe.c\n+++ b/diffcore-pickaxe.c\n@@ -131,7 +131,7 @@ static int pickaxe_match(struct diff_filepair *p, struct diff_options *o,\n \tif (!DIFF_FILE_VALID(p->one) && !DIFF_FILE_VALID(p->two))\n \t\treturn 0;\n \n-\tif (o->flags.ALLOW_TEXTCONV) {\n+\tif (o->flags.allow_textconv) {\n \t\ttextconv_one = get_textconv(p->one);\n \t\ttextconv_two = get_textconv(p->two);\n \t}\n@@ -222,11 +222,11 @@ void diffcore_pickaxe(struct diff_options *o)\n \n \tif (opts & (DIFF_PICKAXE_REGEX | DIFF_PICKAXE_KIND_G)) {\n \t\tint cflags = REG_EXTENDED | REG_NEWLINE;\n-\t\tif (o->flags.PICKAXE_IGNORE_CASE)\n+\t\tif (o->flags.pickaxe_ignore_case)\n \t\t\tcflags |= REG_ICASE;\n \t\tregcomp_or_die(&regex, needle, cflags);\n \t\tregexp = &regex;\n-\t} else if (o->flags.PICKAXE_IGNORE_CASE &&\n+\t} else if (o->flags.pickaxe_ignore_case &&\n \t\t   has_non_ascii(needle)) {\n \t\tstruct strbuf sb = STRBUF_INIT;\n \t\tint cflags = REG_NEWLINE | REG_ICASE;\n@@ -236,7 +236,7 @@ void diffcore_pickaxe(struct diff_options *o)\n \t\tstrbuf_release(&sb);\n \t\tregexp = &regex;\n \t} else {\n-\t\tkws = kwsalloc(o->flags.PICKAXE_IGNORE_CASE\n+\t\tkws = kwsalloc(o->flags.pickaxe_ignore_case\n \t\t\t       ? tolower_trans_tbl : NULL);\n \t\tkwsincr(kws, needle, strlen(needle));\n \t\tkwsprep(kws);\ndiff --git a/diffcore-rename.c b/diffcore-rename.c\nindex bd077ee11..12dc2a056 100644\n--- a/diffcore-rename.c\n+++ b/diffcore-rename.c\n@@ -405,7 +405,7 @@ static int too_many_rename_candidates(int num_create,\n \t\tnum_src > num_create ? num_src : num_create;\n \n \t/* Are we running under -C -C? */\n-\tif (!options->flags.FIND_COPIES_HARDER)\n+\tif (!options->flags.find_copies_harder)\n \t\treturn 1;\n \n \t/* Would we bust the limit if we were running under -C? */\n@@ -463,7 +463,7 @@ void diffcore_rename(struct diff_options *options)\n \t\t\telse if (options->single_follow &&\n \t\t\t\t strcmp(options->single_follow, p->two->path))\n \t\t\t\tcontinue; /* not interested */\n-\t\t\telse if (!options->flags.RENAME_EMPTY &&\n+\t\t\telse if (!options->flags.rename_empty &&\n \t\t\t\t is_empty_blob_oid(&p->two->oid))\n \t\t\t\tcontinue;\n \t\t\telse if (add_rename_dst(p->two) < 0) {\n@@ -473,7 +473,7 @@ void diffcore_rename(struct diff_options *options)\n \t\t\t\tgoto cleanup;\n \t\t\t}\n \t\t}\n-\t\telse if (!options->flags.RENAME_EMPTY &&\n+\t\telse if (!options->flags.rename_empty &&\n \t\t\t is_empty_blob_oid(&p->one->oid))\n \t\t\tcontinue;\n \t\telse if (!DIFF_PAIR_UNMERGED(p) && !DIFF_FILE_VALID(p->two)) {\ndiff --git a/log-tree.c b/log-tree.c\nindex 460bb5498..8dacccc0c 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -793,7 +793,7 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log\n \tstruct commit_list *parents;\n \tstruct object_id *oid;\n \n-\tif (!opt->diff && !opt->diffopt.flags.EXIT_WITH_STATUS)\n+\tif (!opt->diff && !opt->diffopt.flags.exit_with_status)\n \t\treturn 0;\n \n \tparse_commit_or_die(commit);\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 9752aba4e..f6c03770b 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -540,8 +540,8 @@ static struct string_list *get_renames(struct merge_options *o,\n \t\treturn renames;\n \n \tdiff_setup(&opts);\n-\topts.flags.RECURSIVE = 1;\n-\topts.flags.RENAME_EMPTY = 0;\n+\topts.flags.recursive = 1;\n+\topts.flags.rename_empty = 0;\n \topts.detect_rename = DIFF_DETECT_RENAME;\n \topts.rename_limit = o->merge_rename_limit >= 0 ? o->merge_rename_limit :\n \t\t\t    o->diff_rename_limit >= 0 ? o->diff_rename_limit :\ndiff --git a/notes-merge.c b/notes-merge.c\nindex b50111cf2..b3d4d44fc 100644\n--- a/notes-merge.c\n+++ b/notes-merge.c\n@@ -125,7 +125,7 @@ static struct notes_merge_pair *diff_tree_remote(struct notes_merge_options *o,\n \t       oid_to_hex(base), oid_to_hex(remote));\n \n \tdiff_setup(&opt);\n-\topt.flags.RECURSIVE = 1;\n+\topt.flags.recursive = 1;\n \topt.output_format = DIFF_FORMAT_NO_OUTPUT;\n \tdiff_setup_done(&opt);\n \tdiff_tree_oid(base, remote, \"\", &opt);\n@@ -188,7 +188,7 @@ static void diff_tree_local(struct notes_merge_options *o,\n \t       len, oid_to_hex(base), oid_to_hex(local));\n \n \tdiff_setup(&opt);\n-\topt.flags.RECURSIVE = 1;\n+\topt.flags.recursive = 1;\n \topt.output_format = DIFF_FORMAT_NO_OUTPUT;\n \tdiff_setup_done(&opt);\n \tdiff_tree_oid(base, local, \"\", &opt);\ndiff --git a/patch-ids.c b/patch-ids.c\nindex 189869e57..8f7c25d5d 100644\n--- a/patch-ids.c\n+++ b/patch-ids.c\n@@ -61,7 +61,7 @@ int init_patch_ids(struct patch_ids *ids)\n \tmemset(ids, 0, sizeof(*ids));\n \tdiff_setup(&ids->diffopts);\n \tids->diffopts.detect_rename = 0;\n-\tids->diffopts.flags.RECURSIVE = 1;\n+\tids->diffopts.flags.recursive = 1;\n \tdiff_setup_done(&ids->diffopts);\n \thashmap_init(&ids->patches, patch_id_cmp, &ids->diffopts, 256);\n \treturn 0;\ndiff --git a/revision.c b/revision.c\nindex 6bb873501..bfde5b0cd 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -410,7 +410,7 @@ static void file_add_remove(struct diff_options *options,\n \n \ttree_difference |= diff;\n \tif (tree_difference == REV_TREE_DIFFERENT)\n-\t\toptions->flags.HAS_CHANGES = 1;\n+\t\toptions->flags.has_changes = 1;\n }\n \n static void file_change(struct diff_options *options,\n@@ -422,7 +422,7 @@ static void file_change(struct diff_options *options,\n \t\t unsigned old_dirty_submodule, unsigned new_dirty_submodule)\n {\n \ttree_difference = REV_TREE_DIFFERENT;\n-\toptions->flags.HAS_CHANGES = 1;\n+\toptions->flags.has_changes = 1;\n }\n \n static int rev_compare_tree(struct rev_info *revs,\n@@ -455,7 +455,7 @@ static int rev_compare_tree(struct rev_info *revs,\n \t}\n \n \ttree_difference = REV_TREE_SAME;\n-\trevs->pruning.flags.HAS_CHANGES = 0;\n+\trevs->pruning.flags.has_changes = 0;\n \tif (diff_tree_oid(&t1->object.oid, &t2->object.oid, \"\",\n \t\t\t   &revs->pruning) < 0)\n \t\treturn REV_TREE_DIFFERENT;\n@@ -471,7 +471,7 @@ static int rev_same_tree_as_empty(struct rev_info *revs, struct commit *commit)\n \t\treturn 0;\n \n \ttree_difference = REV_TREE_SAME;\n-\trevs->pruning.flags.HAS_CHANGES = 0;\n+\trevs->pruning.flags.has_changes = 0;\n \tretval = diff_tree_oid(NULL, &t1->object.oid, \"\", &revs->pruning);\n \n \treturn retval >= 0 && (tree_difference == REV_TREE_SAME);\n@@ -1403,8 +1403,8 @@ void init_revisions(struct rev_info *revs, const char *prefix)\n \trevs->abbrev = DEFAULT_ABBREV;\n \trevs->ignore_merges = 1;\n \trevs->simplify_history = 1;\n-\trevs->pruning.flags.RECURSIVE = 1;\n-\trevs->pruning.flags.QUICK = 1;\n+\trevs->pruning.flags.recursive = 1;\n+\trevs->pruning.flags.quick = 1;\n \trevs->pruning.add_remove = file_add_remove;\n \trevs->pruning.change = file_change;\n \trevs->sort_order = REV_SORT_IN_GRAPH_ORDER;\n@@ -1917,11 +1917,11 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg\n \t\tdie(\"--unpacked=<packfile> no longer supported.\");\n \t} else if (!strcmp(arg, \"-r\")) {\n \t\trevs->diff = 1;\n-\t\trevs->diffopt.flags.RECURSIVE = 1;\n+\t\trevs->diffopt.flags.recursive = 1;\n \t} else if (!strcmp(arg, \"-t\")) {\n \t\trevs->diff = 1;\n-\t\trevs->diffopt.flags.RECURSIVE = 1;\n-\t\trevs->diffopt.flags.TREE_IN_RECURSIVE = 1;\n+\t\trevs->diffopt.flags.recursive = 1;\n+\t\trevs->diffopt.flags.tree_in_recursive = 1;\n \t} else if (!strcmp(arg, \"-m\")) {\n \t\trevs->ignore_merges = 0;\n \t} else if (!strcmp(arg, \"-c\")) {\n@@ -2066,7 +2066,7 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg\n \t\trevs->grep_filter.pattern_type_option = GREP_PATTERN_TYPE_ERE;\n \t} else if (!strcmp(arg, \"--regexp-ignore-case\") || !strcmp(arg, \"-i\")) {\n \t\trevs->grep_filter.ignore_case = 1;\n-\t\trevs->diffopt.flags.PICKAXE_IGNORE_CASE = 1;\n+\t\trevs->diffopt.flags.pickaxe_ignore_case = 1;\n \t} else if (!strcmp(arg, \"--fixed-strings\") || !strcmp(arg, \"-F\")) {\n \t\trevs->grep_filter.pattern_type_option = GREP_PATTERN_TYPE_FIXED;\n \t} else if (!strcmp(arg, \"--perl-regexp\") || !strcmp(arg, \"-P\")) {\n@@ -2399,7 +2399,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s\n \t/* Pickaxe, diff-filter and rename following need diffs */\n \tif (revs->diffopt.pickaxe ||\n \t    revs->diffopt.filter ||\n-\t    revs->diffopt.flags.FOLLOW_RENAMES)\n+\t    revs->diffopt.flags.follow_renames)\n \t\trevs->diff = 1;\n \n \tif (revs->topo_order)\n@@ -2408,7 +2408,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s\n \tif (revs->prune_data.nr) {\n \t\tcopy_pathspec(&revs->pruning.pathspec, &revs->prune_data);\n \t\t/* Can't prune commits with rename following: the paths change.. */\n-\t\tif (!revs->diffopt.flags.FOLLOW_RENAMES)\n+\t\tif (!revs->diffopt.flags.follow_renames)\n \t\t\trevs->prune = 1;\n \t\tif (!revs->full_diff)\n \t\t\tcopy_pathspec(&revs->diffopt.pathspec,\ndiff --git a/submodule.c b/submodule.c\nindex 62a93bb88..9b16adc96 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -183,7 +183,7 @@ void set_diffopt_flags_from_submodule_config(struct diff_options *diffopt,\n \t\tif (ignore)\n \t\t\thandle_ignore_submodules_arg(diffopt, ignore);\n \t\telse if (is_gitmodules_unmerged(&the_index))\n-\t\t\tdiffopt->flags.IGNORE_SUBMODULES = 1;\n+\t\t\tdiffopt->flags.ignore_submodules = 1;\n \t}\n }\n \n@@ -402,16 +402,16 @@ const char *submodule_strategy_to_string(const struct submodule_update_strategy\n void handle_ignore_submodules_arg(struct diff_options *diffopt,\n \t\t\t\t  const char *arg)\n {\n-\tdiffopt->flags.IGNORE_SUBMODULES = 0;\n-\tdiffopt->flags.IGNORE_UNTRACKED_IN_SUBMODULES = 0;\n-\tdiffopt->flags.IGNORE_DIRTY_SUBMODULES = 0;\n+\tdiffopt->flags.ignore_submodules = 0;\n+\tdiffopt->flags.ignore_untracked_in_submodules = 0;\n+\tdiffopt->flags.ignore_dirty_submodules = 0;\n \n \tif (!strcmp(arg, \"all\"))\n-\t\tdiffopt->flags.IGNORE_SUBMODULES = 1;\n+\t\tdiffopt->flags.ignore_submodules = 1;\n \telse if (!strcmp(arg, \"untracked\"))\n-\t\tdiffopt->flags.IGNORE_UNTRACKED_IN_SUBMODULES = 1;\n+\t\tdiffopt->flags.ignore_untracked_in_submodules = 1;\n \telse if (!strcmp(arg, \"dirty\"))\n-\t\tdiffopt->flags.IGNORE_DIRTY_SUBMODULES = 1;\n+\t\tdiffopt->flags.ignore_dirty_submodules = 1;\n \telse if (strcmp(arg, \"none\"))\n \t\tdie(\"bad --ignore-submodules argument: %s\", arg);\n }\n@@ -616,7 +616,7 @@ void show_submodule_inline_diff(struct diff_options *o, const char *path,\n \targv_array_pushf(&cp.args, \"--color=%s\", want_color(o->use_color) ?\n \t\t\t \"always\" : \"never\");\n \n-\tif (o->flags.REVERSE_DIFF) {\n+\tif (o->flags.reverse_diff) {\n \t\targv_array_pushf(&cp.args, \"--src-prefix=%s%s/\",\n \t\t\t\t o->b_prefix, path);\n \t\targv_array_pushf(&cp.args, \"--dst-prefix=%s%s/\",\ndiff --git a/tree-diff.c b/tree-diff.c\nindex b996a23bb..fe2e466ac 100644\n--- a/tree-diff.c\n+++ b/tree-diff.c\n@@ -212,9 +212,9 @@ static struct combine_diff_path *emit_path(struct combine_diff_path *p,\n \t\tmode = 0;\n \t}\n \n-\tif (opt->flags.RECURSIVE && isdir) {\n+\tif (opt->flags.recursive && isdir) {\n \t\trecurse = 1;\n-\t\temitthis = opt->flags.TREE_IN_RECURSIVE;\n+\t\temitthis = opt->flags.tree_in_recursive;\n \t}\n \n \tif (emitthis) {\n@@ -425,7 +425,7 @@ static struct combine_diff_path *ll_diff_tree_paths(\n \tttree = fill_tree_descriptor(&t, oid);\n \n \t/* Enable recursion indefinitely */\n-\topt->pathspec.recursive = opt->flags.RECURSIVE;\n+\topt->pathspec.recursive = opt->flags.recursive;\n \n \tfor (;;) {\n \t\tint imin, cmp;\n@@ -484,7 +484,7 @@ static struct combine_diff_path *ll_diff_tree_paths(\n \t\t/* t = p[imin] */\n \t\tif (cmp == 0) {\n \t\t\t/* are either pi > p[imin] or diff(t,pi) != ø ? */\n-\t\t\tif (!opt->flags.FIND_COPIES_HARDER) {\n+\t\t\tif (!opt->flags.find_copies_harder) {\n \t\t\t\tfor (i = 0; i < nparent; ++i) {\n \t\t\t\t\t/* p[i] > p[imin] */\n \t\t\t\t\tif (tp[i].entry.mode & S_IFXMIN_NEQ)\n@@ -522,7 +522,7 @@ static struct combine_diff_path *ll_diff_tree_paths(\n \t\t/* t > p[imin] */\n \t\telse {\n \t\t\t/* ∀i pi=p[imin] -> D += \"-p[imin]\" */\n-\t\t\tif (!opt->flags.FIND_COPIES_HARDER) {\n+\t\t\tif (!opt->flags.find_copies_harder) {\n \t\t\t\tfor (i = 0; i < nparent; ++i)\n \t\t\t\t\tif (tp[i].entry.mode & S_IFXMIN_NEQ)\n \t\t\t\t\t\tgoto skip_emit_tp;\n@@ -608,8 +608,8 @@ static void try_to_follow_renames(const struct object_id *old_oid,\n \tq->nr = 0;\n \n \tdiff_setup(&diff_opts);\n-\tdiff_opts.flags.RECURSIVE = 1;\n-\tdiff_opts.flags.FIND_COPIES_HARDER = 1;\n+\tdiff_opts.flags.recursive = 1;\n+\tdiff_opts.flags.find_copies_harder = 1;\n \tdiff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;\n \tdiff_opts.single_follow = opt->pathspec.items[0].match;\n \tdiff_opts.break_opt = opt->break_opt;\n@@ -706,7 +706,7 @@ int diff_tree_oid(const struct object_id *old_oid,\n \tstrbuf_addstr(&base, base_str);\n \n \tretval = ll_diff_tree_oid(old_oid, new_oid, &base, opt);\n-\tif (!*base_str && opt->flags.FOLLOW_RENAMES && diff_might_be_rename())\n+\tif (!*base_str && opt->flags.follow_renames && diff_might_be_rename())\n \t\ttry_to_follow_renames(old_oid, new_oid, &base, opt);\n \n \tstrbuf_release(&base);\ndiff --git a/wt-status.c b/wt-status.c\nindex 59f9f3a0b..4f76e19d3 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -559,12 +559,12 @@ static void wt_status_collect_changes_worktree(struct wt_status *s)\n \tinit_revisions(&rev, NULL);\n \tsetup_revisions(0, NULL, &rev, NULL);\n \trev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;\n-\trev.diffopt.flags.DIRTY_SUBMODULES = 1;\n+\trev.diffopt.flags.dirty_submodules = 1;\n \trev.diffopt.ita_invisible_in_index = 1;\n \tif (!s->show_untracked_files)\n-\t\trev.diffopt.flags.IGNORE_UNTRACKED_IN_SUBMODULES = 1;\n+\t\trev.diffopt.flags.ignore_untracked_in_submodules = 1;\n \tif (s->ignore_submodule_arg) {\n-\t\trev.diffopt.flags.OVERRIDE_SUBMODULE_CONFIG = 1;\n+\t\trev.diffopt.flags.override_submodule_config = 1;\n \t\thandle_ignore_submodules_arg(&rev.diffopt, s->ignore_submodule_arg);\n \t}\n \trev.diffopt.format_callback = wt_status_collect_changed_cb;\n@@ -583,7 +583,7 @@ static void wt_status_collect_changes_index(struct wt_status *s)\n \topt.def = s->is_initial ? EMPTY_TREE_SHA1_HEX : s->reference;\n \tsetup_revisions(0, NULL, &rev, &opt);\n \n-\trev.diffopt.flags.OVERRIDE_SUBMODULE_CONFIG = 1;\n+\trev.diffopt.flags.override_submodule_config = 1;\n \trev.diffopt.ita_invisible_in_index = 1;\n \tif (s->ignore_submodule_arg) {\n \t\thandle_ignore_submodules_arg(&rev.diffopt, s->ignore_submodule_arg);\n@@ -949,7 +949,7 @@ static void wt_longstatus_print_verbose(struct wt_status *s)\n \tconst char *c = color(WT_STATUS_HEADER, s);\n \n \tinit_revisions(&rev, NULL);\n-\trev.diffopt.flags.ALLOW_TEXTCONV = 1;\n+\trev.diffopt.flags.allow_textconv = 1;\n \trev.diffopt.ita_invisible_in_index = 1;\n \n \tmemset(&opt, 0, sizeof(opt));\n@@ -2263,8 +2263,8 @@ int has_unstaged_changes(int ignore_submodules)\n \n \tinit_revisions(&rev_info, NULL);\n \tif (ignore_submodules)\n-\t\trev_info.diffopt.flags.IGNORE_SUBMODULES = 1;\n-\trev_info.diffopt.flags.QUICK = 1;\n+\t\trev_info.diffopt.flags.ignore_submodules = 1;\n+\trev_info.diffopt.flags.quick = 1;\n \tdiff_setup_done(&rev_info.diffopt);\n \tresult = run_diff_files(&rev_info, 0);\n \treturn diff_result_code(&rev_info.diffopt, result);\n@@ -2283,8 +2283,8 @@ int has_uncommitted_changes(int ignore_submodules)\n \n \tinit_revisions(&rev_info, NULL);\n \tif (ignore_submodules)\n-\t\trev_info.diffopt.flags.IGNORE_SUBMODULES = 1;\n-\trev_info.diffopt.flags.QUICK = 1;\n+\t\trev_info.diffopt.flags.ignore_submodules = 1;\n+\trev_info.diffopt.flags.quick = 1;\n \tadd_head_to_pending(&rev_info);\n \tdiff_setup_done(&rev_info.diffopt);\n \tresult = run_diff_index(&rev_info, 1);\n-- \n2.15.0.403.gc27cc4dac6-goog\n\n"},{"id":"331444","messageId":"xmqqlgjs2fqp.fsf@gitster.mtv.corp.google.com","threadId":"47047","inReplyTo":"xmqqzi898olb.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH 3/3] diff: convert flags to be stored in bitfields","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-10-31T02:49:50Z","receivedAt":"2017-10-31T02:49:57Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Junio C Hamano <gitster@pobox.com> writes:\n>\n>> I still haven't brought myself to like the structure being passed by\n>> value and the singleton diff_flags_cleared thing, but I suspect that\n>> we may get used to them once we start using these.  I dunno.\n>\n> Just bikeshedding, but I just had to prepare an evil merge to add a\n> new use of diff_flags_cleared to a codepath that evolved in a topic\n> still in flight, and realized that I really hate the name.  Perhaps\n> I wouldn't have hated it so much if it were named diff_flags_none or\n> diff_flags_empty, I guess.\n\nAs to the \"passing by value\" thing, as long as we have the _or()\nhelper function, no sensible person will add anything but a bitfield\ninto the structure, so I am fine with it.\n"},{"id":"331448","messageId":"xmqq8tfs2al4.fsf@gitster.mtv.corp.google.com","threadId":"47047","inReplyTo":"20171030194646.27473-3-bmwill@google.com","subject":"Re: [PATCH v2 2/4] diff: convert flags to be stored in bitfields","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-10-31T04:41:11Z","receivedAt":"2017-10-31T04:41:17Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Brandon Williams <bmwill@google.com> writes:\n\n> +\tif (flags)\n> +\t\trev.diffopt.flags = diff_flags_or(&rev.diffopt.flags, flags);\n\nIf we are avoiding from passing a struct (even if it is a small one)\nby value, then returning a struct as value defeats the point of the\nexercise, I would think.  If that will be the calling cconvention,\nmaking diff_flags_or(&a, &b) to update &a by or'ing bits in &b would\nbe more natural.\n\nHaving said that, as I said in a separate message, as long as we\nhave this _or() thing, no sane person would add anything but\nbitfields to the structure which will guarantee that it will stay to\nbe small set of flags and nothing else---so I personally am fine\nwith pass by value (which in turn makes it OK to return as a value,\ntoo).\n\nOther than that, this step looked reasonable to me.\n\nThanks.\n"},{"id":"331449","messageId":"xmqq4lqf3o5q.fsf@gitster.mtv.corp.google.com","threadId":"47047","inReplyTo":"20171030194646.27473-4-bmwill@google.com","subject":"Re: [PATCH v2 3/4] diff: add flag to indicate textconv was set via cmdline","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-10-31T05:02:41Z","receivedAt":"2017-10-31T05:02:48Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Brandon Williams <bmwill@google.com> writes:\n\n> diff --git a/builtin/log.c b/builtin/log.c\n> index dc28d43eb..82131751d 100644\n> --- a/builtin/log.c\n> +++ b/builtin/log.c\n> @@ -485,7 +485,7 @@ static int show_blob_object(const struct object_id *oid, struct rev_info *rev, c\n>  \tunsigned long size;\n>  \n>  \tfflush(rev->diffopt.file);\n> -\tif (!DIFF_OPT_TOUCHED(&rev->diffopt, ALLOW_TEXTCONV) ||\n> +\tif (!DIFF_OPT_TST(&rev->diffopt, TEXTCONV_SET_VIA_CMDLINE) ||\n>  \t    !DIFF_OPT_TST(&rev->diffopt, ALLOW_TEXTCONV))\n>  \t\treturn stream_blob_to_fd(1, oid, NULL, 0);\n\nThe original is equivalent to \n\n\tif (! (DIFF_OPT_TOUCHED() && DIFF_OPT_TST()))\n\t\treturn stream_blob_to_fd();\n\nwhich means that we must have used DIFF_OPT_SET() or DIFF_OPT_CLR()\nto touch the ALLOW_TEXTCONV bit, and ALLOW_TEXTCONV bit is currently\nset, in order for the flow to skip this \"just stream it out\".\n\nAnd the way it implemented it was:\n\n#define DIFF_OPT_TOUCHED(opts, flag)    ((opts)->touched_flags & DIFF_OPT_##flag)\n#define DIFF_OPT_SET(opts, flag)    (((opts)->flags |= DIFF_OPT_##flag),((opts)->touched_flags |= DIFF_OPT_##flag))\n#define DIFF_OPT_CLR(opts, flag)    (((opts)->flags &= ~DIFF_OPT_##flag),((opts)->touched_flags |= DIFF_OPT_##flag))\n\nNotice that touched_flags is SET in both OPT_SET() and OPT_CLR(),\nbecause the point of _TOUCHED() was \"did the user made an explicit\nrequest to affect the value of the bit from the command line?\".\n\n> diff --git a/diff.c b/diff.c\n> index 3ad9c9b31..8b700b1bd 100644\n> --- a/diff.c\n> +++ b/diff.c\n> @@ -4762,11 +4762,13 @@ int diff_opt_parse(struct diff_options *options,\n>  \t\tDIFF_OPT_SET(options, ALLOW_EXTERNAL);\n>  \telse if (!strcmp(arg, \"--no-ext-diff\"))\n>  \t\tDIFF_OPT_CLR(options, ALLOW_EXTERNAL);\n> -\telse if (!strcmp(arg, \"--textconv\"))\n> +\telse if (!strcmp(arg, \"--textconv\")) {\n>  \t\tDIFF_OPT_SET(options, ALLOW_TEXTCONV);\n> -\telse if (!strcmp(arg, \"--no-textconv\"))\n> +\t\tDIFF_OPT_SET(options, TEXTCONV_SET_VIA_CMDLINE);\n> +\t} else if (!strcmp(arg, \"--no-textconv\")) {\n>  \t\tDIFF_OPT_CLR(options, ALLOW_TEXTCONV);\n> -\telse if (!strcmp(arg, \"--ignore-submodules\")) {\n> +\t\tDIFF_OPT_CLR(options, TEXTCONV_SET_VIA_CMDLINE);\n> +\t} else if (!strcmp(arg, \"--ignore-submodules\")) {\n\nIf we were aiming for faithful conversion, the above must be\nDIFF_OPT_SET(options, TEXTCONV_SET_VIA_CMDLINE), not CLR.\n\nHOWEVER, I think it is fine to define TEXTCONV_SET_VIA_CMDLINE bit\ndifferently from what DIFF_OPT_TOUCHED(ALLOW_TEXTCONV) meant in the\nold code (i.e. \"did the user made an explicit request to affect the\nvalue?\").  That is, we can define the new one as \"did the user\nexplicitly SET the bit from the command line?\", the conditional in\nshow_blob_object() is prepared to take either interpretation.  \"User\nexplicitly set the bit to true, and the bit is true\" and \"User\nexplicitly set the bit to something, and the bit is true\" are pretty\nmuch the same thing.\n\nAnd that leads me to suggest dropping the last change here, to touch\nVIA_CMDLINE in response to \"--no-textconv\".\n\nOther than that, looks good to me.\n\nThanks.\n"},{"id":"331450","messageId":"xmqqvaiv28n2.fsf_-_@gitster.mtv.corp.google.com","threadId":"47047","inReplyTo":"20171030194646.27473-4-bmwill@google.com","subject":"[PATCH 3.5/4] diff: set TEXTCONV_VIA_CMDLINE only when it is set to true","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-10-31T05:23:13Z","receivedAt":"2017-10-31T05:23:56Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Change the meaning of the bit to \"the user explicitly set the\nallow-textconv bit to true from the command line\".\n\nThe \"touched\" mechanism in the old code meant to express \"the user\nexplicitly set the allow-textconv bit to something from the command\nline\" and recorded that fact upon \"--no-textconv\", too, by setting\nthe corresponding touched bit.  The code in the previous step to\nclear the bit did not make much sense.\n\nAgain, this may want be squashed into the previous step, but its log\nmessage needs to be adjusted somewhat (e.g. \"s/is requested via/is\nset to true via/\").\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n diff.c | 5 ++---\n 1 file changed, 2 insertions(+), 3 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 8b700b1bd2..11fccbd107 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4765,10 +4765,9 @@ int diff_opt_parse(struct diff_options *options,\n \telse if (!strcmp(arg, \"--textconv\")) {\n \t\tDIFF_OPT_SET(options, ALLOW_TEXTCONV);\n \t\tDIFF_OPT_SET(options, TEXTCONV_SET_VIA_CMDLINE);\n-\t} else if (!strcmp(arg, \"--no-textconv\")) {\n+\t} else if (!strcmp(arg, \"--no-textconv\"))\n \t\tDIFF_OPT_CLR(options, ALLOW_TEXTCONV);\n-\t\tDIFF_OPT_CLR(options, TEXTCONV_SET_VIA_CMDLINE);\n-\t} else if (!strcmp(arg, \"--ignore-submodules\")) {\n+\telse if (!strcmp(arg, \"--ignore-submodules\")) {\n \t\tDIFF_OPT_SET(options, OVERRIDE_SUBMODULE_CONFIG);\n \t\thandle_ignore_submodules_arg(options, \"all\");\n \t} else if (skip_prefix(arg, \"--ignore-submodules=\", &arg)) {\n-- \n2.15.0-224-g5109123e6a\n\n"},{"id":"331451","messageId":"xmqqo9on28mf.fsf@gitster.mtv.corp.google.com","threadId":"47047","inReplyTo":"20171030194646.27473-3-bmwill@google.com","subject":"[PATCH 2.5/4] diff: avoid returning a struct by value from diff_flags_or()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-10-31T05:23:36Z","receivedAt":"2017-10-31T05:23:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"That is more in line with the design decision made in the previous\nstep to pass struct by reference.\n\nWe may want to squash this into the previous patch eventually.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n\n * I am OK either way as long as things are consistent; as you took\n   time to change the code to pass the struct by reference, let's\n   unify the API in that direction.\n\n diff-lib.c |  2 +-\n diff.h     | 12 ++++--------\n 2 files changed, 5 insertions(+), 9 deletions(-)\n\ndiff --git a/diff-lib.c b/diff-lib.c\nindex 6c1c05c5b0..ed37f24c68 100644\n--- a/diff-lib.c\n+++ b/diff-lib.c\n@@ -547,7 +547,7 @@ int index_differs_from(const char *def, const struct diff_flags *flags,\n \tDIFF_OPT_SET(&rev.diffopt, QUICK);\n \tDIFF_OPT_SET(&rev.diffopt, EXIT_WITH_STATUS);\n \tif (flags)\n-\t\trev.diffopt.flags = diff_flags_or(&rev.diffopt.flags, flags);\n+\t\tdiff_flags_or(&rev.diffopt.flags, flags);\n \trev.diffopt.ita_invisible_in_index = ita_invisible_in_index;\n \trun_diff_index(&rev, 1);\n \tobject_array_clear(&rev.pending);\ndiff --git a/diff.h b/diff.h\nindex 47e6d43cbc..e512cf44d0 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -94,19 +94,15 @@ struct diff_flags {\n \tunsigned DEFAULT_FOLLOW_RENAMES:1;\n };\n \n-static inline struct diff_flags diff_flags_or(const struct diff_flags *a,\n-\t\t\t\t\t      const struct diff_flags *b)\n+static inline void diff_flags_or(struct diff_flags *a,\n+\t\t\t\t const struct diff_flags *b)\n {\n-\tstruct diff_flags out;\n \tchar *tmp_a = (char *)a;\n-\tchar *tmp_b = (char *)b;\n-\tchar *tmp_out = (char *)&out;\n+\tconst char *tmp_b = (const char *)b;\n \tint i;\n \n \tfor (i = 0; i < sizeof(struct diff_flags); i++)\n-\t\ttmp_out[i] = tmp_a[i] | tmp_b[i];\n-\n-\treturn out;\n+\t\ttmp_a[i] |= tmp_b[i];\n }\n \n #define DIFF_OPT_TST(opts, flag)\t((opts)->flags.flag)\n-- \n2.15.0-224-g5109123e6a\n\n"},{"id":"331491","messageId":"20171031175119.GB94048@google.com","threadId":"47047","inReplyTo":"xmqqo9on28mf.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH 2.5/4] diff: avoid returning a struct by value from diff_flags_or()","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-10-31T17:51:19Z","receivedAt":"2017-10-31T17:51:27Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"On 10/31, Junio C Hamano wrote:\n> That is more in line with the design decision made in the previous\n> step to pass struct by reference.\n> \n> We may want to squash this into the previous patch eventually.\n\nLooks good to me.  I was on the fence with what to do since I was\nalready moving to pass by reference.  This is probably the better move\nso I can squash this one into the previous.\n\n> \n> Signed-off-by: Junio C Hamano <gitster@pobox.com>\n> ---\n> \n>  * I am OK either way as long as things are consistent; as you took\n>    time to change the code to pass the struct by reference, let's\n>    unify the API in that direction.\n> \n>  diff-lib.c |  2 +-\n>  diff.h     | 12 ++++--------\n>  2 files changed, 5 insertions(+), 9 deletions(-)\n> \n> diff --git a/diff-lib.c b/diff-lib.c\n> index 6c1c05c5b0..ed37f24c68 100644\n> --- a/diff-lib.c\n> +++ b/diff-lib.c\n> @@ -547,7 +547,7 @@ int index_differs_from(const char *def, const struct diff_flags *flags,\n>  \tDIFF_OPT_SET(&rev.diffopt, QUICK);\n>  \tDIFF_OPT_SET(&rev.diffopt, EXIT_WITH_STATUS);\n>  \tif (flags)\n> -\t\trev.diffopt.flags = diff_flags_or(&rev.diffopt.flags, flags);\n> +\t\tdiff_flags_or(&rev.diffopt.flags, flags);\n>  \trev.diffopt.ita_invisible_in_index = ita_invisible_in_index;\n>  \trun_diff_index(&rev, 1);\n>  \tobject_array_clear(&rev.pending);\n> diff --git a/diff.h b/diff.h\n> index 47e6d43cbc..e512cf44d0 100644\n> --- a/diff.h\n> +++ b/diff.h\n> @@ -94,19 +94,15 @@ struct diff_flags {\n>  \tunsigned DEFAULT_FOLLOW_RENAMES:1;\n>  };\n>  \n> -static inline struct diff_flags diff_flags_or(const struct diff_flags *a,\n> -\t\t\t\t\t      const struct diff_flags *b)\n> +static inline void diff_flags_or(struct diff_flags *a,\n> +\t\t\t\t const struct diff_flags *b)\n>  {\n> -\tstruct diff_flags out;\n>  \tchar *tmp_a = (char *)a;\n> -\tchar *tmp_b = (char *)b;\n> -\tchar *tmp_out = (char *)&out;\n> +\tconst char *tmp_b = (const char *)b;\n>  \tint i;\n>  \n>  \tfor (i = 0; i < sizeof(struct diff_flags); i++)\n> -\t\ttmp_out[i] = tmp_a[i] | tmp_b[i];\n> -\n> -\treturn out;\n> +\t\ttmp_a[i] |= tmp_b[i];\n>  }\n>  \n>  #define DIFF_OPT_TST(opts, flag)\t((opts)->flags.flag)\n> -- \n> 2.15.0-224-g5109123e6a\n> \n\n-- \nBrandon Williams\n"},{"id":"331492","messageId":"20171031175522.GC94048@google.com","threadId":"47047","inReplyTo":"xmqqvaiv28n2.fsf_-_@gitster.mtv.corp.google.com","subject":"Re: [PATCH 3.5/4] diff: set TEXTCONV_VIA_CMDLINE only when it is set to true","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-10-31T17:55:22Z","receivedAt":"2017-10-31T17:55:29Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"On 10/31, Junio C Hamano wrote:\n> Change the meaning of the bit to \"the user explicitly set the\n> allow-textconv bit to true from the command line\".\n> \n> The \"touched\" mechanism in the old code meant to express \"the user\n> explicitly set the allow-textconv bit to something from the command\n> line\" and recorded that fact upon \"--no-textconv\", too, by setting\n> the corresponding touched bit.  The code in the previous step to\n> clear the bit did not make much sense.\n> \n> Again, this may want be squashed into the previous step, but its log\n> message needs to be adjusted somewhat (e.g. \"s/is requested via/is\n> set to true via/\").\n\nI don't have any opinions on this, but I agree that if we want a more\ntrue conversion then we would wanted to squash this in, which I'll do\nand update the log message.\n\n> \n> Signed-off-by: Junio C Hamano <gitster@pobox.com>\n> ---\n>  diff.c | 5 ++---\n>  1 file changed, 2 insertions(+), 3 deletions(-)\n> \n> diff --git a/diff.c b/diff.c\n> index 8b700b1bd2..11fccbd107 100644\n> --- a/diff.c\n> +++ b/diff.c\n> @@ -4765,10 +4765,9 @@ int diff_opt_parse(struct diff_options *options,\n>  \telse if (!strcmp(arg, \"--textconv\")) {\n>  \t\tDIFF_OPT_SET(options, ALLOW_TEXTCONV);\n>  \t\tDIFF_OPT_SET(options, TEXTCONV_SET_VIA_CMDLINE);\n> -\t} else if (!strcmp(arg, \"--no-textconv\")) {\n> +\t} else if (!strcmp(arg, \"--no-textconv\"))\n>  \t\tDIFF_OPT_CLR(options, ALLOW_TEXTCONV);\n> -\t\tDIFF_OPT_CLR(options, TEXTCONV_SET_VIA_CMDLINE);\n> -\t} else if (!strcmp(arg, \"--ignore-submodules\")) {\n> +\telse if (!strcmp(arg, \"--ignore-submodules\")) {\n>  \t\tDIFF_OPT_SET(options, OVERRIDE_SUBMODULE_CONFIG);\n>  \t\thandle_ignore_submodules_arg(options, \"all\");\n>  \t} else if (skip_prefix(arg, \"--ignore-submodules=\", &arg)) {\n> -- \n> 2.15.0-224-g5109123e6a\n> \n\n-- \nBrandon Williams\n"},{"id":"331497","messageId":"20171031181911.42687-1-bmwill@google.com","threadId":"47047","inReplyTo":"20171030194646.27473-1-bmwill@google.com","subject":"[PATCH v3 0/8] convert diff flags to be stored in a struct","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-10-31T18:19:03Z","receivedAt":"2017-10-31T18:19:23Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"Changes in v3:\n * Now always pass struct diff_flags by reference and don't return the struct\n   but rather modify the passed in struct.\n * Don't clear TEXTCONV_SET_VIA_CMDLINE when --no-textconv is passed\n * added additional patches (set out separately before) to remove the macros\n   and change the struct members to lowercase\n\nBrandon Williams (8):\n  add, reset: use DIFF_OPT_SET macro to set a diff flag\n  diff: convert flags to be stored in bitfields\n  diff: add flag to indicate textconv was set via cmdline\n  diff: remove touched flags\n  diff: remove DIFF_OPT_TST macro\n  diff: remove DIFF_OPT_SET macro\n  diff: remove DIFF_OPT_CLR macro\n  diff: make struct diff_flags members lowercase\n\n blame.c               |  16 ++---\n builtin/add.c         |   4 +-\n builtin/am.c          |  10 +--\n builtin/blame.c       |  10 +--\n builtin/commit.c      |   7 +-\n builtin/diff.c        |   8 +--\n builtin/fast-export.c |   2 +-\n builtin/log.c         |  27 ++++----\n builtin/reset.c       |   2 +-\n builtin/rev-list.c    |   2 +-\n combine-diff.c        |  10 +--\n diff-lib.c            |  30 +++++----\n diff-no-index.c       |   8 +--\n diff.c                | 175 +++++++++++++++++++++++++-------------------------\n diff.h                |  88 ++++++++++++++-----------\n diffcore-pickaxe.c    |   8 +--\n diffcore-rename.c     |   6 +-\n log-tree.c            |   2 +-\n merge-recursive.c     |   4 +-\n notes-merge.c         |   4 +-\n patch-ids.c           |   2 +-\n revision.c            |  24 +++----\n sequencer.c           |   5 +-\n submodule.c           |  16 ++---\n tree-diff.c           |  16 ++---\n wt-status.c           |  18 +++---\n 26 files changed, 259 insertions(+), 245 deletions(-)\n\n-- \n2.15.0.403.gc27cc4dac6-goog\n\n"},{"id":"331498","messageId":"20171031181911.42687-2-bmwill@google.com","threadId":"47047","inReplyTo":"20171031181911.42687-1-bmwill@google.com","subject":"[PATCH v3 1/8] add, reset: use DIFF_OPT_SET macro to set a diff flag","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-10-31T18:19:04Z","receivedAt":"2017-10-31T18:19:25Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"Instead of explicitly setting the 'DIFF_OPT_OVERRIDE_SUBMODULE_CONFIG'\nflag, use the 'DIFF_OPT_SET' macro.\n\nSigned-off-by: Brandon Williams <bmwill@google.com>\n---\n builtin/add.c   | 2 +-\n builtin/reset.c | 2 +-\n 2 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/add.c b/builtin/add.c\nindex a648cf4c5..b70e8a779 100644\n--- a/builtin/add.c\n+++ b/builtin/add.c\n@@ -116,7 +116,7 @@ int add_files_to_cache(const char *prefix,\n \trev.diffopt.output_format = DIFF_FORMAT_CALLBACK;\n \trev.diffopt.format_callback = update_callback;\n \trev.diffopt.format_callback_data = &data;\n-\trev.diffopt.flags |= DIFF_OPT_OVERRIDE_SUBMODULE_CONFIG;\n+\tDIFF_OPT_SET(&rev.diffopt, OVERRIDE_SUBMODULE_CONFIG);\n \trev.max_count = 0; /* do not compare unmerged paths with stage #2 */\n \trun_diff_files(&rev, DIFF_RACY_IS_MODIFIED);\n \tclear_pathspec(&rev.prune_data);\ndiff --git a/builtin/reset.c b/builtin/reset.c\nindex 9cd89b230..ea2fad5a0 100644\n--- a/builtin/reset.c\n+++ b/builtin/reset.c\n@@ -166,7 +166,7 @@ static int read_from_tree(const struct pathspec *pathspec,\n \topt.output_format = DIFF_FORMAT_CALLBACK;\n \topt.format_callback = update_index_from_diff;\n \topt.format_callback_data = &intent_to_add;\n-\topt.flags |= DIFF_OPT_OVERRIDE_SUBMODULE_CONFIG;\n+\tDIFF_OPT_SET(&opt, OVERRIDE_SUBMODULE_CONFIG);\n \n \tif (do_diff_cache(tree_oid, &opt))\n \t\treturn 1;\n-- \n2.15.0.403.gc27cc4dac6-goog\n\n"},{"id":"331499","messageId":"20171031181911.42687-3-bmwill@google.com","threadId":"47047","inReplyTo":"20171031181911.42687-1-bmwill@google.com","subject":"[PATCH v3 2/8] diff: convert flags to be stored in bitfields","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-10-31T18:19:05Z","receivedAt":"2017-10-31T18:19:27Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"We cannot add many more flags to the diff machinery due to the\nlimitations of the number of flags that can be stored in a single\nunsigned int.  In order to allow for more flags to be added to the diff\nmachinery in the future this patch converts the flags to be stored in\nbitfields in 'struct diff_flags'.\n\nSigned-off-by: Brandon Williams <bmwill@google.com>\n---\n builtin/commit.c |  7 +++--\n builtin/log.c    |  3 +-\n diff-lib.c       |  7 +++--\n diff.c           |  2 +-\n diff.h           | 93 ++++++++++++++++++++++++++++++++------------------------\n sequencer.c      |  5 +--\n 6 files changed, 68 insertions(+), 49 deletions(-)\n\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex d75b3805e..960e7ac08 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -912,11 +912,12 @@ static int prepare_to_commit(const char *index_file, const char *prefix,\n \t\t\t * submodules which were manually staged, which would\n \t\t\t * be really confusing.\n \t\t\t */\n-\t\t\tint diff_flags = DIFF_OPT_OVERRIDE_SUBMODULE_CONFIG;\n+\t\t\tstruct diff_flags flags = DIFF_FLAGS_INIT;\n+\t\t\tflags.OVERRIDE_SUBMODULE_CONFIG = 1;\n \t\t\tif (ignore_submodule_arg &&\n \t\t\t    !strcmp(ignore_submodule_arg, \"all\"))\n-\t\t\t\tdiff_flags |= DIFF_OPT_IGNORE_SUBMODULES;\n-\t\t\tcommitable = index_differs_from(parent, diff_flags, 1);\n+\t\t\t\tflags.IGNORE_SUBMODULES = 1;\n+\t\t\tcommitable = index_differs_from(parent, &flags, 1);\n \t\t}\n \t}\n \tstrbuf_release(&committer_ident);\ndiff --git a/builtin/log.c b/builtin/log.c\nindex d81a09051..dc28d43eb 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -134,7 +134,8 @@ static void cmd_log_init_defaults(struct rev_info *rev)\n \n \tif (default_date_mode)\n \t\tparse_date_format(default_date_mode, &rev->date_mode);\n-\trev->diffopt.touched_flags = 0;\n+\n+\tmemset(&rev->diffopt.touched_flags, 0, sizeof(struct diff_flags));\n }\n \n static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,\ndiff --git a/diff-lib.c b/diff-lib.c\nindex 4e0980caa..ed37f24c6 100644\n--- a/diff-lib.c\n+++ b/diff-lib.c\n@@ -71,7 +71,7 @@ static int match_stat_with_submodule(struct diff_options *diffopt,\n {\n \tint changed = ce_match_stat(ce, st, ce_option);\n \tif (S_ISGITLINK(ce->ce_mode)) {\n-\t\tunsigned orig_flags = diffopt->flags;\n+\t\tstruct diff_flags orig_flags = diffopt->flags;\n \t\tif (!DIFF_OPT_TST(diffopt, OVERRIDE_SUBMODULE_CONFIG))\n \t\t\tset_diffopt_flags_from_submodule_config(diffopt, ce->name);\n \t\tif (DIFF_OPT_TST(diffopt, IGNORE_SUBMODULES))\n@@ -534,7 +534,7 @@ int do_diff_cache(const struct object_id *tree_oid, struct diff_options *opt)\n \treturn 0;\n }\n \n-int index_differs_from(const char *def, int diff_flags,\n+int index_differs_from(const char *def, const struct diff_flags *flags,\n \t\t       int ita_invisible_in_index)\n {\n \tstruct rev_info rev;\n@@ -546,7 +546,8 @@ int index_differs_from(const char *def, int diff_flags,\n \tsetup_revisions(0, NULL, &rev, &opt);\n \tDIFF_OPT_SET(&rev.diffopt, QUICK);\n \tDIFF_OPT_SET(&rev.diffopt, EXIT_WITH_STATUS);\n-\trev.diffopt.flags |= diff_flags;\n+\tif (flags)\n+\t\tdiff_flags_or(&rev.diffopt.flags, flags);\n \trev.diffopt.ita_invisible_in_index = ita_invisible_in_index;\n \trun_diff_index(&rev, 1);\n \tobject_array_clear(&rev.pending);\ndiff --git a/diff.c b/diff.c\nindex 6fd288420..3ad9c9b31 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -5899,7 +5899,7 @@ int diff_can_quit_early(struct diff_options *opt)\n static int is_submodule_ignored(const char *path, struct diff_options *options)\n {\n \tint ignored = 0;\n-\tunsigned orig_flags = options->flags;\n+\tstruct diff_flags orig_flags = options->flags;\n \tif (!DIFF_OPT_TST(options, OVERRIDE_SUBMODULE_CONFIG))\n \t\tset_diffopt_flags_from_submodule_config(options, path);\n \tif (DIFF_OPT_TST(options, IGNORE_SUBMODULES))\ndiff --git a/diff.h b/diff.h\nindex aca150ba2..e512cf44d 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -60,42 +60,56 @@ typedef struct strbuf *(*diff_prefix_fn_t)(struct diff_options *opt, void *data)\n \n #define DIFF_FORMAT_CALLBACK\t0x1000\n \n-#define DIFF_OPT_RECURSIVE           (1 <<  0)\n-#define DIFF_OPT_TREE_IN_RECURSIVE   (1 <<  1)\n-#define DIFF_OPT_BINARY              (1 <<  2)\n-#define DIFF_OPT_TEXT                (1 <<  3)\n-#define DIFF_OPT_FULL_INDEX          (1 <<  4)\n-#define DIFF_OPT_SILENT_ON_REMOVE    (1 <<  5)\n-#define DIFF_OPT_FIND_COPIES_HARDER  (1 <<  6)\n-#define DIFF_OPT_FOLLOW_RENAMES      (1 <<  7)\n-#define DIFF_OPT_RENAME_EMPTY        (1 <<  8)\n-/* (1 <<  9) unused */\n-#define DIFF_OPT_HAS_CHANGES         (1 << 10)\n-#define DIFF_OPT_QUICK               (1 << 11)\n-#define DIFF_OPT_NO_INDEX            (1 << 12)\n-#define DIFF_OPT_ALLOW_EXTERNAL      (1 << 13)\n-#define DIFF_OPT_EXIT_WITH_STATUS    (1 << 14)\n-#define DIFF_OPT_REVERSE_DIFF        (1 << 15)\n-#define DIFF_OPT_CHECK_FAILED        (1 << 16)\n-#define DIFF_OPT_RELATIVE_NAME       (1 << 17)\n-#define DIFF_OPT_IGNORE_SUBMODULES   (1 << 18)\n-#define DIFF_OPT_DIRSTAT_CUMULATIVE  (1 << 19)\n-#define DIFF_OPT_DIRSTAT_BY_FILE     (1 << 20)\n-#define DIFF_OPT_ALLOW_TEXTCONV      (1 << 21)\n-#define DIFF_OPT_DIFF_FROM_CONTENTS  (1 << 22)\n-#define DIFF_OPT_DIRTY_SUBMODULES    (1 << 24)\n-#define DIFF_OPT_IGNORE_UNTRACKED_IN_SUBMODULES (1 << 25)\n-#define DIFF_OPT_IGNORE_DIRTY_SUBMODULES (1 << 26)\n-#define DIFF_OPT_OVERRIDE_SUBMODULE_CONFIG (1 << 27)\n-#define DIFF_OPT_DIRSTAT_BY_LINE     (1 << 28)\n-#define DIFF_OPT_FUNCCONTEXT         (1 << 29)\n-#define DIFF_OPT_PICKAXE_IGNORE_CASE (1 << 30)\n-#define DIFF_OPT_DEFAULT_FOLLOW_RENAMES (1U << 31)\n-\n-#define DIFF_OPT_TST(opts, flag)    ((opts)->flags & DIFF_OPT_##flag)\n-#define DIFF_OPT_TOUCHED(opts, flag)    ((opts)->touched_flags & DIFF_OPT_##flag)\n-#define DIFF_OPT_SET(opts, flag)    (((opts)->flags |= DIFF_OPT_##flag),((opts)->touched_flags |= DIFF_OPT_##flag))\n-#define DIFF_OPT_CLR(opts, flag)    (((opts)->flags &= ~DIFF_OPT_##flag),((opts)->touched_flags |= DIFF_OPT_##flag))\n+#define DIFF_FLAGS_INIT { 0 }\n+struct diff_flags {\n+\tunsigned RECURSIVE:1;\n+\tunsigned TREE_IN_RECURSIVE:1;\n+\tunsigned BINARY:1;\n+\tunsigned TEXT:1;\n+\tunsigned FULL_INDEX:1;\n+\tunsigned SILENT_ON_REMOVE:1;\n+\tunsigned FIND_COPIES_HARDER:1;\n+\tunsigned FOLLOW_RENAMES:1;\n+\tunsigned RENAME_EMPTY:1;\n+\tunsigned HAS_CHANGES:1;\n+\tunsigned QUICK:1;\n+\tunsigned NO_INDEX:1;\n+\tunsigned ALLOW_EXTERNAL:1;\n+\tunsigned EXIT_WITH_STATUS:1;\n+\tunsigned REVERSE_DIFF:1;\n+\tunsigned CHECK_FAILED:1;\n+\tunsigned RELATIVE_NAME:1;\n+\tunsigned IGNORE_SUBMODULES:1;\n+\tunsigned DIRSTAT_CUMULATIVE:1;\n+\tunsigned DIRSTAT_BY_FILE:1;\n+\tunsigned ALLOW_TEXTCONV:1;\n+\tunsigned DIFF_FROM_CONTENTS:1;\n+\tunsigned DIRTY_SUBMODULES:1;\n+\tunsigned IGNORE_UNTRACKED_IN_SUBMODULES:1;\n+\tunsigned IGNORE_DIRTY_SUBMODULES:1;\n+\tunsigned OVERRIDE_SUBMODULE_CONFIG:1;\n+\tunsigned DIRSTAT_BY_LINE:1;\n+\tunsigned FUNCCONTEXT:1;\n+\tunsigned PICKAXE_IGNORE_CASE:1;\n+\tunsigned DEFAULT_FOLLOW_RENAMES:1;\n+};\n+\n+static inline void diff_flags_or(struct diff_flags *a,\n+\t\t\t\t const struct diff_flags *b)\n+{\n+\tchar *tmp_a = (char *)a;\n+\tconst char *tmp_b = (const char *)b;\n+\tint i;\n+\n+\tfor (i = 0; i < sizeof(struct diff_flags); i++)\n+\t\ttmp_a[i] |= tmp_b[i];\n+}\n+\n+#define DIFF_OPT_TST(opts, flag)\t((opts)->flags.flag)\n+#define DIFF_OPT_TOUCHED(opts, flag)\t((opts)->touched_flags.flag)\n+#define DIFF_OPT_SET(opts, flag)\t(((opts)->flags.flag = 1),((opts)->touched_flags.flag = 1))\n+#define DIFF_OPT_CLR(opts, flag)\t(((opts)->flags.flag = 0),((opts)->touched_flags.flag = 1))\n+\n #define DIFF_XDL_TST(opts, flag)    ((opts)->xdl_opts & XDF_##flag)\n #define DIFF_XDL_SET(opts, flag)    ((opts)->xdl_opts |= XDF_##flag)\n #define DIFF_XDL_CLR(opts, flag)    ((opts)->xdl_opts &= ~XDF_##flag)\n@@ -122,8 +136,8 @@ struct diff_options {\n \tconst char *a_prefix, *b_prefix;\n \tconst char *line_prefix;\n \tsize_t line_prefix_length;\n-\tunsigned flags;\n-\tunsigned touched_flags;\n+\tstruct diff_flags flags;\n+\tstruct diff_flags touched_flags;\n \n \t/* diff-filter bits */\n \tunsigned int filter;\n@@ -388,7 +402,8 @@ extern int diff_result_code(struct diff_options *, int);\n \n extern void diff_no_index(struct rev_info *, int, const char **);\n \n-extern int index_differs_from(const char *def, int diff_flags, int ita_invisible_in_index);\n+extern int index_differs_from(const char *def, const struct diff_flags *flags,\n+\t\t\t      int ita_invisible_in_index);\n \n /*\n  * Fill the contents of the filespec \"df\", respecting any textconv defined by\ndiff --git a/sequencer.c b/sequencer.c\nindex f2a10cc4f..c0410e491 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -959,7 +959,8 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,\n \t\tunborn = get_oid(\"HEAD\", &head);\n \t\tif (unborn)\n \t\t\toidcpy(&head, &empty_tree_oid);\n-\t\tif (index_differs_from(unborn ? EMPTY_TREE_SHA1_HEX : \"HEAD\", 0, 0))\n+\t\tif (index_differs_from(unborn ? EMPTY_TREE_SHA1_HEX : \"HEAD\",\n+\t\t\t\t       NULL, 0))\n \t\t\treturn error_dirty_index(opts);\n \t}\n \tdiscard_cache();\n@@ -2279,7 +2280,7 @@ int sequencer_continue(struct replay_opts *opts)\n \t\t\tif (res)\n \t\t\t\tgoto release_todo_list;\n \t\t}\n-\t\tif (index_differs_from(\"HEAD\", 0, 0)) {\n+\t\tif (index_differs_from(\"HEAD\", NULL, 0)) {\n \t\t\tres = error_dirty_index(opts);\n \t\t\tgoto release_todo_list;\n \t\t}\n-- \n2.15.0.403.gc27cc4dac6-goog\n\n"},{"id":"331500","messageId":"20171031181911.42687-5-bmwill@google.com","threadId":"47047","inReplyTo":"20171031181911.42687-1-bmwill@google.com","subject":"[PATCH v3 4/8] diff: remove touched flags","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-10-31T18:19:07Z","receivedAt":"2017-10-31T18:19:29Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"Now that the set of parallel touched flags are no longer being used,\nremove them.\n\nSigned-off-by: Brandon Williams <bmwill@google.com>\n---\n builtin/log.c | 2 --\n diff.h        | 6 ++----\n 2 files changed, 2 insertions(+), 6 deletions(-)\n\ndiff --git a/builtin/log.c b/builtin/log.c\nindex 82131751d..9c0815270 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -134,8 +134,6 @@ static void cmd_log_init_defaults(struct rev_info *rev)\n \n \tif (default_date_mode)\n \t\tparse_date_format(default_date_mode, &rev->date_mode);\n-\n-\tmemset(&rev->diffopt.touched_flags, 0, sizeof(struct diff_flags));\n }\n \n static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,\ndiff --git a/diff.h b/diff.h\nindex d077d3c10..26a1cab87 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -107,9 +107,8 @@ static inline void diff_flags_or(struct diff_flags *a,\n }\n \n #define DIFF_OPT_TST(opts, flag)\t((opts)->flags.flag)\n-#define DIFF_OPT_TOUCHED(opts, flag)\t((opts)->touched_flags.flag)\n-#define DIFF_OPT_SET(opts, flag)\t(((opts)->flags.flag = 1),((opts)->touched_flags.flag = 1))\n-#define DIFF_OPT_CLR(opts, flag)\t(((opts)->flags.flag = 0),((opts)->touched_flags.flag = 1))\n+#define DIFF_OPT_SET(opts, flag)\t((opts)->flags.flag = 1)\n+#define DIFF_OPT_CLR(opts, flag)\t((opts)->flags.flag = 0)\n \n #define DIFF_XDL_TST(opts, flag)    ((opts)->xdl_opts & XDF_##flag)\n #define DIFF_XDL_SET(opts, flag)    ((opts)->xdl_opts |= XDF_##flag)\n@@ -138,7 +137,6 @@ struct diff_options {\n \tconst char *line_prefix;\n \tsize_t line_prefix_length;\n \tstruct diff_flags flags;\n-\tstruct diff_flags touched_flags;\n \n \t/* diff-filter bits */\n \tunsigned int filter;\n-- \n2.15.0.403.gc27cc4dac6-goog\n\n"},{"id":"331501","messageId":"20171031181911.42687-6-bmwill@google.com","threadId":"47047","inReplyTo":"20171031181911.42687-1-bmwill@google.com","subject":"[PATCH v3 5/8] diff: remove DIFF_OPT_TST macro","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-10-31T18:19:08Z","receivedAt":"2017-10-31T18:19:34Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"Remove the `DIFF_OPT_TST` macro and instead access the flags directly.\nThis conversion is done using the following semantic patch:\n\n\t@@\n\texpression E;\n\tidentifier fld;\n\t@@\n\t- DIFF_OPT_TST(&E, fld)\n\t+ E.flags.fld\n\n\t@@\n\ttype T;\n\tT *ptr;\n\tidentifier fld;\n\t@@\n\t- DIFF_OPT_TST(ptr, fld)\n\t+ ptr->flags.fld\n\nSigned-off-by: Brandon Williams <bmwill@google.com>\n---\n blame.c            |  8 +++---\n builtin/am.c       |  2 +-\n builtin/blame.c    |  4 +--\n builtin/diff.c     |  2 +-\n builtin/log.c      | 12 ++++-----\n builtin/rev-list.c |  2 +-\n combine-diff.c     |  6 ++---\n diff-lib.c         | 19 +++++++-------\n diff-no-index.c    |  2 +-\n diff.c             | 76 +++++++++++++++++++++++++++---------------------------\n diff.h             |  1 -\n diffcore-pickaxe.c |  8 +++---\n diffcore-rename.c  |  6 ++---\n log-tree.c         |  2 +-\n revision.c         |  4 +--\n submodule.c        |  2 +-\n tree-diff.c        | 12 ++++-----\n 17 files changed, 84 insertions(+), 84 deletions(-)\n\ndiff --git a/blame.c b/blame.c\nindex f575e9cbf..7c019bc7c 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -209,7 +209,7 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,\n \n \t\tswitch (st.st_mode & S_IFMT) {\n \t\tcase S_IFREG:\n-\t\t\tif (DIFF_OPT_TST(opt, ALLOW_TEXTCONV) &&\n+\t\t\tif (opt->flags.ALLOW_TEXTCONV &&\n \t\t\t    textconv_object(read_from, mode, &null_oid, 0, &buf_ptr, &buf_len))\n \t\t\t\tstrbuf_attach(&buf, buf_ptr, buf_len, buf_len + 1);\n \t\t\telse if (strbuf_read_file(&buf, read_from, st.st_size) != st.st_size)\n@@ -293,7 +293,7 @@ static void fill_origin_blob(struct diff_options *opt,\n \t\tunsigned long file_size;\n \n \t\t(*num_read_blob)++;\n-\t\tif (DIFF_OPT_TST(opt, ALLOW_TEXTCONV) &&\n+\t\tif (opt->flags.ALLOW_TEXTCONV &&\n \t\t    textconv_object(o->path, o->mode, &o->blob_oid, 1, &file->ptr, &file_size))\n \t\t\t;\n \t\telse\n@@ -1262,7 +1262,7 @@ static void find_copy_in_parent(struct blame_scoreboard *sb,\n \t\t\t      &target->commit->tree->object.oid,\n \t\t\t      \"\", &diff_opts);\n \n-\tif (!DIFF_OPT_TST(&diff_opts, FIND_COPIES_HARDER))\n+\tif (!diff_opts.flags.FIND_COPIES_HARDER)\n \t\tdiffcore_std(&diff_opts);\n \n \tdo {\n@@ -1825,7 +1825,7 @@ void setup_scoreboard(struct blame_scoreboard *sb, const char *path, struct blam\n \t\tif (fill_blob_sha1_and_mode(o))\n \t\t\tdie(_(\"no such path %s in %s\"), path, final_commit_name);\n \n-\t\tif (DIFF_OPT_TST(&sb->revs->diffopt, ALLOW_TEXTCONV) &&\n+\t\tif (sb->revs->diffopt.flags.ALLOW_TEXTCONV &&\n \t\t    textconv_object(path, o->mode, &o->blob_oid, 1, (char **) &sb->final_buf,\n \t\t\t\t    &sb->final_buf_size))\n \t\t\t;\ndiff --git a/builtin/am.c b/builtin/am.c\nindex d7513f537..fc54724cc 100644\n--- a/builtin/am.c\n+++ b/builtin/am.c\n@@ -1168,7 +1168,7 @@ static int index_has_changes(struct strbuf *sb)\n \t\t\tstrbuf_addstr(sb, diff_queued_diff.queue[i]->two->path);\n \t\t}\n \t\tdiff_flush(&opt);\n-\t\treturn DIFF_OPT_TST(&opt, HAS_CHANGES) != 0;\n+\t\treturn opt.flags.HAS_CHANGES != 0;\n \t} else {\n \t\tfor (i = 0; sb && i < active_nr; i++) {\n \t\t\tif (i)\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex 67adaef4d..a29574984 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -734,7 +734,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)\n \t\tparse_revision_opt(&revs, &ctx, options, blame_opt_usage);\n \t}\n parse_done:\n-\tno_whole_file_rename = !DIFF_OPT_TST(&revs.diffopt, FOLLOW_RENAMES);\n+\tno_whole_file_rename = !revs.diffopt.flags.FOLLOW_RENAMES;\n \txdl_opts |= revs.diffopt.xdl_opts & XDF_INDENT_HEURISTIC;\n \tDIFF_OPT_CLR(&revs.diffopt, FOLLOW_RENAMES);\n \targc = parse_options_end(&ctx);\n@@ -803,7 +803,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)\n \t}\n \tblame_date_width -= 1; /* strip the null */\n \n-\tif (DIFF_OPT_TST(&revs.diffopt, FIND_COPIES_HARDER))\n+\tif (revs.diffopt.flags.FIND_COPIES_HARDER)\n \t\topt |= (PICKAXE_BLAME_COPY | PICKAXE_BLAME_MOVE |\n \t\t\tPICKAXE_BLAME_COPY_HARDER);\n \ndiff --git a/builtin/diff.c b/builtin/diff.c\nindex f5bbd4d75..8cbaf4538 100644\n--- a/builtin/diff.c\n+++ b/builtin/diff.c\n@@ -44,7 +44,7 @@ static void stuff_change(struct diff_options *opt,\n \t    !oidcmp(old_oid, new_oid) && (old_mode == new_mode))\n \t\treturn;\n \n-\tif (DIFF_OPT_TST(opt, REVERSE_DIFF)) {\n+\tif (opt->flags.REVERSE_DIFF) {\n \t\tSWAP(old_mode, new_mode);\n \t\tSWAP(old_oid, new_oid);\n \t\tSWAP(old_path, new_path);\ndiff --git a/builtin/log.c b/builtin/log.c\nindex 9c0815270..2b2d36678 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -181,7 +181,7 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,\n \t\tinit_display_notes(&rev->notes_opt);\n \n \tif (rev->diffopt.pickaxe || rev->diffopt.filter ||\n-\t    DIFF_OPT_TST(&rev->diffopt, FOLLOW_RENAMES))\n+\t    rev->diffopt.flags.FOLLOW_RENAMES)\n \t\trev->always_show_header = 0;\n \n \tif (source)\n@@ -391,7 +391,7 @@ static int cmd_log_walk(struct rev_info *rev)\n \t\tfclose(rev->diffopt.file);\n \n \tif (rev->diffopt.output_format & DIFF_FORMAT_CHECKDIFF &&\n-\t    DIFF_OPT_TST(&rev->diffopt, CHECK_FAILED)) {\n+\t    rev->diffopt.flags.CHECK_FAILED) {\n \t\treturn 02;\n \t}\n \treturn diff_result_code(&rev->diffopt, 0);\n@@ -483,8 +483,8 @@ static int show_blob_object(const struct object_id *oid, struct rev_info *rev, c\n \tunsigned long size;\n \n \tfflush(rev->diffopt.file);\n-\tif (!DIFF_OPT_TST(&rev->diffopt, TEXTCONV_SET_VIA_CMDLINE) ||\n-\t    !DIFF_OPT_TST(&rev->diffopt, ALLOW_TEXTCONV))\n+\tif (!rev->diffopt.flags.TEXTCONV_SET_VIA_CMDLINE ||\n+\t    !rev->diffopt.flags.ALLOW_TEXTCONV)\n \t\treturn stream_blob_to_fd(1, oid, NULL, 0);\n \n \tif (get_oid_with_context(obj_name, GET_OID_RECORD_PATH,\n@@ -666,7 +666,7 @@ int cmd_log_reflog(int argc, const char **argv, const char *prefix)\n static void log_setup_revisions_tweak(struct rev_info *rev,\n \t\t\t\t      struct setup_revision_opt *opt)\n {\n-\tif (DIFF_OPT_TST(&rev->diffopt, DEFAULT_FOLLOW_RENAMES) &&\n+\tif (rev->diffopt.flags.DEFAULT_FOLLOW_RENAMES &&\n \t    rev->prune_data.nr == 1)\n \t\tDIFF_OPT_SET(&rev->diffopt, FOLLOW_RENAMES);\n \n@@ -1612,7 +1612,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \n \trev.zero_commit = zero_commit;\n \n-\tif (!DIFF_OPT_TST(&rev.diffopt, TEXT) && !no_binary_diff)\n+\tif (!rev.diffopt.flags.TEXT && !no_binary_diff)\n \t\tDIFF_OPT_SET(&rev.diffopt, BINARY);\n \n \tif (rev.show_notes)\ndiff --git a/builtin/rev-list.c b/builtin/rev-list.c\nindex c1c74d4a7..c62382171 100644\n--- a/builtin/rev-list.c\n+++ b/builtin/rev-list.c\n@@ -294,7 +294,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)\n \tif (revs.bisect)\n \t\tbisect_list = 1;\n \n-\tif (DIFF_OPT_TST(&revs.diffopt, QUICK))\n+\tif (revs.diffopt.flags.QUICK)\n \t\tinfo.flags |= REV_LIST_QUIET;\n \tfor (i = 1 ; i < argc; i++) {\n \t\tconst char *arg = argv[i];\ndiff --git a/combine-diff.c b/combine-diff.c\nindex 9e163d5ad..40cb4dd1a 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -898,7 +898,7 @@ static void show_combined_header(struct combine_diff_path *elem,\n \t\t\t\t int show_file_header)\n {\n \tstruct diff_options *opt = &rev->diffopt;\n-\tint abbrev = DIFF_OPT_TST(opt, FULL_INDEX) ? GIT_SHA1_HEXSZ : DEFAULT_ABBREV;\n+\tint abbrev = opt->flags.FULL_INDEX ? GIT_SHA1_HEXSZ : DEFAULT_ABBREV;\n \tconst char *a_prefix = opt->a_prefix ? opt->a_prefix : \"a/\";\n \tconst char *b_prefix = opt->b_prefix ? opt->b_prefix : \"b/\";\n \tconst char *c_meta = diff_get_color_opt(opt, DIFF_METAINFO);\n@@ -987,7 +987,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,\n \tuserdiff = userdiff_find_by_path(elem->path);\n \tif (!userdiff)\n \t\tuserdiff = userdiff_find_by_name(\"default\");\n-\tif (DIFF_OPT_TST(opt, ALLOW_TEXTCONV))\n+\tif (opt->flags.ALLOW_TEXTCONV)\n \t\ttextconv = userdiff_get_textconv(userdiff);\n \n \t/* Read the result of merge first */\n@@ -1435,7 +1435,7 @@ void diff_tree_combined(const struct object_id *oid,\n \t * NOTE please keep this semantically in sync with diffcore_std()\n \t */\n \tneed_generic_pathscan = opt->skip_stat_unmatch\t||\n-\t\t\tDIFF_OPT_TST(opt, FOLLOW_RENAMES)\t||\n+\t\t\topt->flags.FOLLOW_RENAMES\t||\n \t\t\topt->break_opt != -1\t||\n \t\t\topt->detect_rename\t||\n \t\t\topt->pickaxe\t\t||\ndiff --git a/diff-lib.c b/diff-lib.c\nindex ed37f24c6..456971b2c 100644\n--- a/diff-lib.c\n+++ b/diff-lib.c\n@@ -72,13 +72,14 @@ static int match_stat_with_submodule(struct diff_options *diffopt,\n \tint changed = ce_match_stat(ce, st, ce_option);\n \tif (S_ISGITLINK(ce->ce_mode)) {\n \t\tstruct diff_flags orig_flags = diffopt->flags;\n-\t\tif (!DIFF_OPT_TST(diffopt, OVERRIDE_SUBMODULE_CONFIG))\n+\t\tif (!diffopt->flags.OVERRIDE_SUBMODULE_CONFIG)\n \t\t\tset_diffopt_flags_from_submodule_config(diffopt, ce->name);\n-\t\tif (DIFF_OPT_TST(diffopt, IGNORE_SUBMODULES))\n+\t\tif (diffopt->flags.IGNORE_SUBMODULES)\n \t\t\tchanged = 0;\n-\t\telse if (!DIFF_OPT_TST(diffopt, IGNORE_DIRTY_SUBMODULES)\n-\t\t    && (!changed || DIFF_OPT_TST(diffopt, DIRTY_SUBMODULES)))\n-\t\t\t*dirty_submodule = is_submodule_modified(ce->name, DIFF_OPT_TST(diffopt, IGNORE_UNTRACKED_IN_SUBMODULES));\n+\t\telse if (!diffopt->flags.IGNORE_DIRTY_SUBMODULES &&\n+\t\t\t (!changed || diffopt->flags.DIRTY_SUBMODULES))\n+\t\t\t*dirty_submodule = is_submodule_modified(ce->name,\n+\t\t\t\t\t\t\t\t diffopt->flags.IGNORE_UNTRACKED_IN_SUBMODULES);\n \t\tdiffopt->flags = orig_flags;\n \t}\n \treturn changed;\n@@ -228,7 +229,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)\n \n \t\tif (!changed && !dirty_submodule) {\n \t\t\tce_mark_uptodate(ce);\n-\t\t\tif (!DIFF_OPT_TST(&revs->diffopt, FIND_COPIES_HARDER))\n+\t\t\tif (!revs->diffopt.flags.FIND_COPIES_HARDER)\n \t\t\t\tcontinue;\n \t\t}\n \t\toldmode = ce->ce_mode;\n@@ -362,7 +363,7 @@ static int show_modified(struct rev_info *revs,\n \n \toldmode = old->ce_mode;\n \tif (mode == oldmode && !oidcmp(oid, &old->oid) && !dirty_submodule &&\n-\t    !DIFF_OPT_TST(&revs->diffopt, FIND_COPIES_HARDER))\n+\t    !revs->diffopt.flags.FIND_COPIES_HARDER)\n \t\treturn 0;\n \n \tdiff_change(&revs->diffopt, oldmode, mode,\n@@ -493,7 +494,7 @@ static int diff_cache(struct rev_info *revs,\n \topts.head_idx = 1;\n \topts.index_only = cached;\n \topts.diff_index_cached = (cached &&\n-\t\t\t\t  !DIFF_OPT_TST(&revs->diffopt, FIND_COPIES_HARDER));\n+\t\t\t\t  !revs->diffopt.flags.FIND_COPIES_HARDER);\n \topts.merge = 1;\n \topts.fn = oneway_diff;\n \topts.unpack_data = revs;\n@@ -551,5 +552,5 @@ int index_differs_from(const char *def, const struct diff_flags *flags,\n \trev.diffopt.ita_invisible_in_index = ita_invisible_in_index;\n \trun_diff_index(&rev, 1);\n \tobject_array_clear(&rev.pending);\n-\treturn (DIFF_OPT_TST(&rev.diffopt, HAS_CHANGES) != 0);\n+\treturn (rev.diffopt.flags.HAS_CHANGES != 0);\n }\ndiff --git a/diff-no-index.c b/diff-no-index.c\nindex 80ff17d46..40d17e42c 100644\n--- a/diff-no-index.c\n+++ b/diff-no-index.c\n@@ -184,7 +184,7 @@ static int queue_diff(struct diff_options *o,\n \t} else {\n \t\tstruct diff_filespec *d1, *d2;\n \n-\t\tif (DIFF_OPT_TST(o, REVERSE_DIFF)) {\n+\t\tif (o->flags.REVERSE_DIFF) {\n \t\t\tSWAP(mode1, mode2);\n \t\t\tSWAP(name1, name2);\n \t\t}\ndiff --git a/diff.c b/diff.c\nindex 11fccbd10..8bfa57cc3 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -1481,7 +1481,7 @@ static void emit_rewrite_diff(const char *name_a,\n \tstruct emit_callback ecbdata;\n \tstruct strbuf out = STRBUF_INIT;\n \n-\tif (diff_mnemonic_prefix && DIFF_OPT_TST(o, REVERSE_DIFF)) {\n+\tif (diff_mnemonic_prefix && o->flags.REVERSE_DIFF) {\n \t\ta_prefix = o->b_prefix;\n \t\tb_prefix = o->a_prefix;\n \t} else {\n@@ -2729,7 +2729,7 @@ static void show_dirstat(struct diff_options *options)\n \tdir.alloc = 0;\n \tdir.nr = 0;\n \tdir.permille = options->dirstat_permille;\n-\tdir.cumulative = DIFF_OPT_TST(options, DIRSTAT_CUMULATIVE);\n+\tdir.cumulative = options->flags.DIRSTAT_CUMULATIVE;\n \n \tchanged = 0;\n \tfor (i = 0; i < q->nr; i++) {\n@@ -2755,7 +2755,7 @@ static void show_dirstat(struct diff_options *options)\n \t\t\tgoto found_damage;\n \t\t}\n \n-\t\tif (DIFF_OPT_TST(options, DIRSTAT_BY_FILE)) {\n+\t\tif (options->flags.DIRSTAT_BY_FILE) {\n \t\t\t/*\n \t\t\t * In --dirstat-by-file mode, we don't really need to\n \t\t\t * look at the actual file contents at all.\n@@ -2830,7 +2830,7 @@ static void show_dirstat_by_line(struct diffstat_t *data, struct diff_options *o\n \tdir.alloc = 0;\n \tdir.nr = 0;\n \tdir.permille = options->dirstat_permille;\n-\tdir.cumulative = DIFF_OPT_TST(options, DIRSTAT_CUMULATIVE);\n+\tdir.cumulative = options->flags.DIRSTAT_CUMULATIVE;\n \n \tchanged = 0;\n \tfor (i = 0; i < data->nr; i++) {\n@@ -3117,7 +3117,7 @@ static void builtin_diff(const char *name_a,\n \tconst char *line_prefix = diff_line_prefix(o);\n \n \tdiff_set_mnemonic_prefix(o, \"a/\", \"b/\");\n-\tif (DIFF_OPT_TST(o, REVERSE_DIFF)) {\n+\tif (o->flags.REVERSE_DIFF) {\n \t\ta_prefix = o->b_prefix;\n \t\tb_prefix = o->a_prefix;\n \t} else {\n@@ -3141,7 +3141,7 @@ static void builtin_diff(const char *name_a,\n \t\treturn;\n \t}\n \n-\tif (DIFF_OPT_TST(o, ALLOW_TEXTCONV)) {\n+\tif (o->flags.ALLOW_TEXTCONV) {\n \t\ttextconv_one = get_textconv(one);\n \t\ttextconv_two = get_textconv(two);\n \t}\n@@ -3201,13 +3201,13 @@ static void builtin_diff(const char *name_a,\n \t\t\t\t header.len, 0);\n \t\tstrbuf_reset(&header);\n \t\tgoto free_ab_and_return;\n-\t} else if (!DIFF_OPT_TST(o, TEXT) &&\n+\t} else if (!o->flags.TEXT &&\n \t    ( (!textconv_one && diff_filespec_is_binary(one)) ||\n \t      (!textconv_two && diff_filespec_is_binary(two)) )) {\n \t\tstruct strbuf sb = STRBUF_INIT;\n \t\tif (!one->data && !two->data &&\n \t\t    S_ISREG(one->mode) && S_ISREG(two->mode) &&\n-\t\t    !DIFF_OPT_TST(o, BINARY)) {\n+\t\t    !o->flags.BINARY) {\n \t\t\tif (!oidcmp(&one->oid, &two->oid)) {\n \t\t\t\tif (must_show_header)\n \t\t\t\t\temit_diff_symbol(o, DIFF_SYMBOL_HEADER,\n@@ -3236,7 +3236,7 @@ static void builtin_diff(const char *name_a,\n \t\t}\n \t\temit_diff_symbol(o, DIFF_SYMBOL_HEADER, header.buf, header.len, 0);\n \t\tstrbuf_reset(&header);\n-\t\tif (DIFF_OPT_TST(o, BINARY))\n+\t\tif (o->flags.BINARY)\n \t\t\temit_binary_diff(o, &mf1, &mf2);\n \t\telse {\n \t\t\tstrbuf_addf(&sb, \"%sBinary files %s and %s differ\\n\",\n@@ -3282,7 +3282,7 @@ static void builtin_diff(const char *name_a,\n \t\txecfg.ctxlen = o->context;\n \t\txecfg.interhunkctxlen = o->interhunkcontext;\n \t\txecfg.flags = XDL_EMIT_FUNCNAMES;\n-\t\tif (DIFF_OPT_TST(o, FUNCCONTEXT))\n+\t\tif (o->flags.FUNCCONTEXT)\n \t\t\txecfg.flags |= XDL_EMIT_FUNCCONTEXT;\n \t\tif (pe)\n \t\t\txdiff_set_find_func(&xecfg, pe->pattern, pe->cflags);\n@@ -3941,9 +3941,9 @@ static void fill_metainfo(struct strbuf *msg,\n \t\t*must_show_header = 0;\n \t}\n \tif (one && two && oidcmp(&one->oid, &two->oid)) {\n-\t\tint abbrev = DIFF_OPT_TST(o, FULL_INDEX) ? 40 : DEFAULT_ABBREV;\n+\t\tint abbrev = o->flags.FULL_INDEX ? 40 : DEFAULT_ABBREV;\n \n-\t\tif (DIFF_OPT_TST(o, BINARY)) {\n+\t\tif (o->flags.BINARY) {\n \t\t\tmmfile_t mf;\n \t\t\tif ((!fill_mmfile(&mf, one) && diff_filespec_is_binary(one)) ||\n \t\t\t    (!fill_mmfile(&mf, two) && diff_filespec_is_binary(two)))\n@@ -3973,7 +3973,7 @@ static void run_diff_cmd(const char *pgm,\n \tint must_show_header = 0;\n \n \n-\tif (DIFF_OPT_TST(o, ALLOW_EXTERNAL)) {\n+\tif (o->flags.ALLOW_EXTERNAL) {\n \t\tstruct userdiff_driver *drv = userdiff_find_by_path(attr_path);\n \t\tif (drv && drv->external)\n \t\t\tpgm = drv->external;\n@@ -4053,7 +4053,7 @@ static void run_diff(struct diff_filepair *p, struct diff_options *o)\n \tif (o->prefix_length)\n \t\tstrip_prefix(o->prefix_length, &name, &other);\n \n-\tif (!DIFF_OPT_TST(o, ALLOW_EXTERNAL))\n+\tif (!o->flags.ALLOW_EXTERNAL)\n \t\tpgm = NULL;\n \n \tif (DIFF_PAIR_UNMERGED(p)) {\n@@ -4207,10 +4207,10 @@ void diff_setup_done(struct diff_options *options)\n \telse\n \t\tDIFF_OPT_CLR(options, DIFF_FROM_CONTENTS);\n \n-\tif (DIFF_OPT_TST(options, FIND_COPIES_HARDER))\n+\tif (options->flags.FIND_COPIES_HARDER)\n \t\toptions->detect_rename = DIFF_DETECT_COPY;\n \n-\tif (!DIFF_OPT_TST(options, RELATIVE_NAME))\n+\tif (!options->flags.RELATIVE_NAME)\n \t\toptions->prefix = NULL;\n \tif (options->prefix)\n \t\toptions->prefix_length = strlen(options->prefix);\n@@ -4273,14 +4273,14 @@ void diff_setup_done(struct diff_options *options)\n \t * to have found.  It does not make sense not to return with\n \t * exit code in such a case either.\n \t */\n-\tif (DIFF_OPT_TST(options, QUICK)) {\n+\tif (options->flags.QUICK) {\n \t\toptions->output_format = DIFF_FORMAT_NO_OUTPUT;\n \t\tDIFF_OPT_SET(options, EXIT_WITH_STATUS);\n \t}\n \n \toptions->diff_path_counter = 0;\n \n-\tif (DIFF_OPT_TST(options, FOLLOW_RENAMES) && options->pathspec.nr != 1)\n+\tif (options->flags.FOLLOW_RENAMES && options->pathspec.nr != 1)\n \t\tdie(_(\"--follow requires exactly one pathspec\"));\n \n \tif (!options->use_color || external_diff())\n@@ -5600,7 +5600,7 @@ void diff_flush(struct diff_options *options)\n \t\tseparator++;\n \t}\n \n-\tif (output_format & DIFF_FORMAT_DIRSTAT && DIFF_OPT_TST(options, DIRSTAT_BY_LINE))\n+\tif (output_format & DIFF_FORMAT_DIRSTAT && options->flags.DIRSTAT_BY_LINE)\n \t\tdirstat_by_line = 1;\n \n \tif (output_format & (DIFF_FORMAT_DIFFSTAT|DIFF_FORMAT_SHORTSTAT|DIFF_FORMAT_NUMSTAT) ||\n@@ -5635,8 +5635,8 @@ void diff_flush(struct diff_options *options)\n \t}\n \n \tif (output_format & DIFF_FORMAT_NO_OUTPUT &&\n-\t    DIFF_OPT_TST(options, EXIT_WITH_STATUS) &&\n-\t    DIFF_OPT_TST(options, DIFF_FROM_CONTENTS)) {\n+\t    options->flags.EXIT_WITH_STATUS &&\n+\t    options->flags.DIFF_FROM_CONTENTS) {\n \t\t/*\n \t\t * run diff_flush_patch for the exit status. setting\n \t\t * options->file to /dev/null should be safe, because we\n@@ -5684,7 +5684,7 @@ void diff_flush(struct diff_options *options)\n \t * diff_addremove/diff_change does not set the bit when\n \t * DIFF_FROM_CONTENTS is in effect (e.g. with -w).\n \t */\n-\tif (DIFF_OPT_TST(options, DIFF_FROM_CONTENTS)) {\n+\tif (options->flags.DIFF_FROM_CONTENTS) {\n \t\tif (options->found_changes)\n \t\t\tDIFF_OPT_SET(options, HAS_CHANGES);\n \t\telse\n@@ -5808,7 +5808,7 @@ static void diffcore_skip_stat_unmatch(struct diff_options *diffopt)\n \t\t\t * to determine how many paths were dirty only\n \t\t\t * due to stat info mismatch.\n \t\t\t */\n-\t\t\tif (!DIFF_OPT_TST(diffopt, NO_INDEX))\n+\t\t\tif (!diffopt->flags.NO_INDEX)\n \t\t\t\tdiffopt->skip_stat_unmatch++;\n \t\t\tdiff_free_filepair(p);\n \t\t}\n@@ -5857,7 +5857,7 @@ void diffcore_std(struct diff_options *options)\n \t\tdiff_resolve_rename_copy();\n \tdiffcore_apply_filter(options);\n \n-\tif (diff_queued_diff.nr && !DIFF_OPT_TST(options, DIFF_FROM_CONTENTS))\n+\tif (diff_queued_diff.nr && !options->flags.DIFF_FROM_CONTENTS)\n \t\tDIFF_OPT_SET(options, HAS_CHANGES);\n \telse\n \t\tDIFF_OPT_CLR(options, HAS_CHANGES);\n@@ -5872,23 +5872,23 @@ int diff_result_code(struct diff_options *opt, int status)\n \tdiff_warn_rename_limit(\"diff.renameLimit\",\n \t\t\t       opt->needed_rename_limit,\n \t\t\t       opt->degraded_cc_to_c);\n-\tif (!DIFF_OPT_TST(opt, EXIT_WITH_STATUS) &&\n+\tif (!opt->flags.EXIT_WITH_STATUS &&\n \t    !(opt->output_format & DIFF_FORMAT_CHECKDIFF))\n \t\treturn status;\n-\tif (DIFF_OPT_TST(opt, EXIT_WITH_STATUS) &&\n-\t    DIFF_OPT_TST(opt, HAS_CHANGES))\n+\tif (opt->flags.EXIT_WITH_STATUS &&\n+\t    opt->flags.HAS_CHANGES)\n \t\tresult |= 01;\n \tif ((opt->output_format & DIFF_FORMAT_CHECKDIFF) &&\n-\t    DIFF_OPT_TST(opt, CHECK_FAILED))\n+\t    opt->flags.CHECK_FAILED)\n \t\tresult |= 02;\n \treturn result;\n }\n \n int diff_can_quit_early(struct diff_options *opt)\n {\n-\treturn (DIFF_OPT_TST(opt, QUICK) &&\n+\treturn (opt->flags.QUICK &&\n \t\t!opt->filter &&\n-\t\tDIFF_OPT_TST(opt, HAS_CHANGES));\n+\t\topt->flags.HAS_CHANGES);\n }\n \n /*\n@@ -5901,9 +5901,9 @@ static int is_submodule_ignored(const char *path, struct diff_options *options)\n {\n \tint ignored = 0;\n \tstruct diff_flags orig_flags = options->flags;\n-\tif (!DIFF_OPT_TST(options, OVERRIDE_SUBMODULE_CONFIG))\n+\tif (!options->flags.OVERRIDE_SUBMODULE_CONFIG)\n \t\tset_diffopt_flags_from_submodule_config(options, path);\n-\tif (DIFF_OPT_TST(options, IGNORE_SUBMODULES))\n+\tif (options->flags.IGNORE_SUBMODULES)\n \t\tignored = 1;\n \toptions->flags = orig_flags;\n \treturn ignored;\n@@ -5932,7 +5932,7 @@ void diff_addremove(struct diff_options *options,\n \t * Before the final output happens, they are pruned after\n \t * merged into rename/copy pairs as appropriate.\n \t */\n-\tif (DIFF_OPT_TST(options, REVERSE_DIFF))\n+\tif (options->flags.REVERSE_DIFF)\n \t\taddremove = (addremove == '+' ? '-' :\n \t\t\t     addremove == '-' ? '+' : addremove);\n \n@@ -5951,7 +5951,7 @@ void diff_addremove(struct diff_options *options,\n \t}\n \n \tdiff_queue(&diff_queued_diff, one, two);\n-\tif (!DIFF_OPT_TST(options, DIFF_FROM_CONTENTS))\n+\tif (!options->flags.DIFF_FROM_CONTENTS)\n \t\tDIFF_OPT_SET(options, HAS_CHANGES);\n }\n \n@@ -5970,7 +5970,7 @@ void diff_change(struct diff_options *options,\n \t    is_submodule_ignored(concatpath, options))\n \t\treturn;\n \n-\tif (DIFF_OPT_TST(options, REVERSE_DIFF)) {\n+\tif (options->flags.REVERSE_DIFF) {\n \t\tSWAP(old_mode, new_mode);\n \t\tSWAP(old_oid, new_oid);\n \t\tSWAP(old_oid_valid, new_oid_valid);\n@@ -5989,10 +5989,10 @@ void diff_change(struct diff_options *options,\n \ttwo->dirty_submodule = new_dirty_submodule;\n \tp = diff_queue(&diff_queued_diff, one, two);\n \n-\tif (DIFF_OPT_TST(options, DIFF_FROM_CONTENTS))\n+\tif (options->flags.DIFF_FROM_CONTENTS)\n \t\treturn;\n \n-\tif (DIFF_OPT_TST(options, QUICK) && options->skip_stat_unmatch &&\n+\tif (options->flags.QUICK && options->skip_stat_unmatch &&\n \t    !diff_filespec_check_stat_unmatch(p))\n \t\treturn;\n \n@@ -6134,7 +6134,7 @@ void setup_diff_pager(struct diff_options *opt)\n \t * and because it is easy to find people oneline advising \"git diff\n \t * --exit-code\" in hooks and other scripts, we do not do so.\n \t */\n-\tif (!DIFF_OPT_TST(opt, EXIT_WITH_STATUS) &&\n+\tif (!opt->flags.EXIT_WITH_STATUS &&\n \t    check_pager_config(\"diff\") != 0)\n \t\tsetup_pager();\n }\ndiff --git a/diff.h b/diff.h\nindex 26a1cab87..c3798a104 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -106,7 +106,6 @@ static inline void diff_flags_or(struct diff_flags *a,\n \t\ttmp_a[i] |= tmp_b[i];\n }\n \n-#define DIFF_OPT_TST(opts, flag)\t((opts)->flags.flag)\n #define DIFF_OPT_SET(opts, flag)\t((opts)->flags.flag = 1)\n #define DIFF_OPT_CLR(opts, flag)\t((opts)->flags.flag = 0)\n \ndiff --git a/diffcore-pickaxe.c b/diffcore-pickaxe.c\nindex 341529b5a..6193c07f6 100644\n--- a/diffcore-pickaxe.c\n+++ b/diffcore-pickaxe.c\n@@ -131,7 +131,7 @@ static int pickaxe_match(struct diff_filepair *p, struct diff_options *o,\n \tif (!DIFF_FILE_VALID(p->one) && !DIFF_FILE_VALID(p->two))\n \t\treturn 0;\n \n-\tif (DIFF_OPT_TST(o, ALLOW_TEXTCONV)) {\n+\tif (o->flags.ALLOW_TEXTCONV) {\n \t\ttextconv_one = get_textconv(p->one);\n \t\ttextconv_two = get_textconv(p->two);\n \t}\n@@ -222,11 +222,11 @@ void diffcore_pickaxe(struct diff_options *o)\n \n \tif (opts & (DIFF_PICKAXE_REGEX | DIFF_PICKAXE_KIND_G)) {\n \t\tint cflags = REG_EXTENDED | REG_NEWLINE;\n-\t\tif (DIFF_OPT_TST(o, PICKAXE_IGNORE_CASE))\n+\t\tif (o->flags.PICKAXE_IGNORE_CASE)\n \t\t\tcflags |= REG_ICASE;\n \t\tregcomp_or_die(&regex, needle, cflags);\n \t\tregexp = &regex;\n-\t} else if (DIFF_OPT_TST(o, PICKAXE_IGNORE_CASE) &&\n+\t} else if (o->flags.PICKAXE_IGNORE_CASE &&\n \t\t   has_non_ascii(needle)) {\n \t\tstruct strbuf sb = STRBUF_INIT;\n \t\tint cflags = REG_NEWLINE | REG_ICASE;\n@@ -236,7 +236,7 @@ void diffcore_pickaxe(struct diff_options *o)\n \t\tstrbuf_release(&sb);\n \t\tregexp = &regex;\n \t} else {\n-\t\tkws = kwsalloc(DIFF_OPT_TST(o, PICKAXE_IGNORE_CASE)\n+\t\tkws = kwsalloc(o->flags.PICKAXE_IGNORE_CASE\n \t\t\t       ? tolower_trans_tbl : NULL);\n \t\tkwsincr(kws, needle, strlen(needle));\n \t\tkwsprep(kws);\ndiff --git a/diffcore-rename.c b/diffcore-rename.c\nindex 0d8c3d2ee..bd077ee11 100644\n--- a/diffcore-rename.c\n+++ b/diffcore-rename.c\n@@ -405,7 +405,7 @@ static int too_many_rename_candidates(int num_create,\n \t\tnum_src > num_create ? num_src : num_create;\n \n \t/* Are we running under -C -C? */\n-\tif (!DIFF_OPT_TST(options, FIND_COPIES_HARDER))\n+\tif (!options->flags.FIND_COPIES_HARDER)\n \t\treturn 1;\n \n \t/* Would we bust the limit if we were running under -C? */\n@@ -463,7 +463,7 @@ void diffcore_rename(struct diff_options *options)\n \t\t\telse if (options->single_follow &&\n \t\t\t\t strcmp(options->single_follow, p->two->path))\n \t\t\t\tcontinue; /* not interested */\n-\t\t\telse if (!DIFF_OPT_TST(options, RENAME_EMPTY) &&\n+\t\t\telse if (!options->flags.RENAME_EMPTY &&\n \t\t\t\t is_empty_blob_oid(&p->two->oid))\n \t\t\t\tcontinue;\n \t\t\telse if (add_rename_dst(p->two) < 0) {\n@@ -473,7 +473,7 @@ void diffcore_rename(struct diff_options *options)\n \t\t\t\tgoto cleanup;\n \t\t\t}\n \t\t}\n-\t\telse if (!DIFF_OPT_TST(options, RENAME_EMPTY) &&\n+\t\telse if (!options->flags.RENAME_EMPTY &&\n \t\t\t is_empty_blob_oid(&p->one->oid))\n \t\t\tcontinue;\n \t\telse if (!DIFF_PAIR_UNMERGED(p) && !DIFF_FILE_VALID(p->two)) {\ndiff --git a/log-tree.c b/log-tree.c\nindex cea056234..460bb5498 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -793,7 +793,7 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log\n \tstruct commit_list *parents;\n \tstruct object_id *oid;\n \n-\tif (!opt->diff && !DIFF_OPT_TST(&opt->diffopt, EXIT_WITH_STATUS))\n+\tif (!opt->diff && !opt->diffopt.flags.EXIT_WITH_STATUS)\n \t\treturn 0;\n \n \tparse_commit_or_die(commit);\ndiff --git a/revision.c b/revision.c\nindex d167223e6..c893d9166 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -2399,7 +2399,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s\n \t/* Pickaxe, diff-filter and rename following need diffs */\n \tif (revs->diffopt.pickaxe ||\n \t    revs->diffopt.filter ||\n-\t    DIFF_OPT_TST(&revs->diffopt, FOLLOW_RENAMES))\n+\t    revs->diffopt.flags.FOLLOW_RENAMES)\n \t\trevs->diff = 1;\n \n \tif (revs->topo_order)\n@@ -2408,7 +2408,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s\n \tif (revs->prune_data.nr) {\n \t\tcopy_pathspec(&revs->pruning.pathspec, &revs->prune_data);\n \t\t/* Can't prune commits with rename following: the paths change.. */\n-\t\tif (!DIFF_OPT_TST(&revs->diffopt, FOLLOW_RENAMES))\n+\t\tif (!revs->diffopt.flags.FOLLOW_RENAMES)\n \t\t\trevs->prune = 1;\n \t\tif (!revs->full_diff)\n \t\t\tcopy_pathspec(&revs->diffopt.pathspec,\ndiff --git a/submodule.c b/submodule.c\nindex 63e7094e1..58da9c668 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -616,7 +616,7 @@ void show_submodule_inline_diff(struct diff_options *o, const char *path,\n \targv_array_pushf(&cp.args, \"--color=%s\", want_color(o->use_color) ?\n \t\t\t \"always\" : \"never\");\n \n-\tif (DIFF_OPT_TST(o, REVERSE_DIFF)) {\n+\tif (o->flags.REVERSE_DIFF) {\n \t\targv_array_pushf(&cp.args, \"--src-prefix=%s%s/\",\n \t\t\t\t o->b_prefix, path);\n \t\targv_array_pushf(&cp.args, \"--dst-prefix=%s%s/\",\ndiff --git a/tree-diff.c b/tree-diff.c\nindex 4bb93155b..ed0aa6a62 100644\n--- a/tree-diff.c\n+++ b/tree-diff.c\n@@ -212,9 +212,9 @@ static struct combine_diff_path *emit_path(struct combine_diff_path *p,\n \t\tmode = 0;\n \t}\n \n-\tif (DIFF_OPT_TST(opt, RECURSIVE) && isdir) {\n+\tif (opt->flags.RECURSIVE && isdir) {\n \t\trecurse = 1;\n-\t\temitthis = DIFF_OPT_TST(opt, TREE_IN_RECURSIVE);\n+\t\temitthis = opt->flags.TREE_IN_RECURSIVE;\n \t}\n \n \tif (emitthis) {\n@@ -425,7 +425,7 @@ static struct combine_diff_path *ll_diff_tree_paths(\n \tttree = fill_tree_descriptor(&t, oid);\n \n \t/* Enable recursion indefinitely */\n-\topt->pathspec.recursive = DIFF_OPT_TST(opt, RECURSIVE);\n+\topt->pathspec.recursive = opt->flags.RECURSIVE;\n \n \tfor (;;) {\n \t\tint imin, cmp;\n@@ -484,7 +484,7 @@ static struct combine_diff_path *ll_diff_tree_paths(\n \t\t/* t = p[imin] */\n \t\tif (cmp == 0) {\n \t\t\t/* are either pi > p[imin] or diff(t,pi) != ø ? */\n-\t\t\tif (!DIFF_OPT_TST(opt, FIND_COPIES_HARDER)) {\n+\t\t\tif (!opt->flags.FIND_COPIES_HARDER) {\n \t\t\t\tfor (i = 0; i < nparent; ++i) {\n \t\t\t\t\t/* p[i] > p[imin] */\n \t\t\t\t\tif (tp[i].entry.mode & S_IFXMIN_NEQ)\n@@ -522,7 +522,7 @@ static struct combine_diff_path *ll_diff_tree_paths(\n \t\t/* t > p[imin] */\n \t\telse {\n \t\t\t/* ∀i pi=p[imin] -> D += \"-p[imin]\" */\n-\t\t\tif (!DIFF_OPT_TST(opt, FIND_COPIES_HARDER)) {\n+\t\t\tif (!opt->flags.FIND_COPIES_HARDER) {\n \t\t\t\tfor (i = 0; i < nparent; ++i)\n \t\t\t\t\tif (tp[i].entry.mode & S_IFXMIN_NEQ)\n \t\t\t\t\t\tgoto skip_emit_tp;\n@@ -706,7 +706,7 @@ int diff_tree_oid(const struct object_id *old_oid,\n \tstrbuf_addstr(&base, base_str);\n \n \tretval = ll_diff_tree_oid(old_oid, new_oid, &base, opt);\n-\tif (!*base_str && DIFF_OPT_TST(opt, FOLLOW_RENAMES) && diff_might_be_rename())\n+\tif (!*base_str && opt->flags.FOLLOW_RENAMES && diff_might_be_rename())\n \t\ttry_to_follow_renames(old_oid, new_oid, &base, opt);\n \n \tstrbuf_release(&base);\n-- \n2.15.0.403.gc27cc4dac6-goog\n\n"},{"id":"331502","messageId":"20171031181911.42687-4-bmwill@google.com","threadId":"47047","inReplyTo":"20171031181911.42687-1-bmwill@google.com","subject":"[PATCH v3 3/8] diff: add flag to indicate textconv was set via cmdline","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-10-31T18:19:06Z","receivedAt":"2017-10-31T18:19:40Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"git-show is unique in that it wants to use textconv by default except\nfor when it is showing blobs.  When asked to show a blob, show doesn't\nwant to use textconv unless the user explicitly requested that it be\nused by providing the command line flag '--textconv'.\n\nCurrently this is done by using a parallel set of 'touched' flags which\nget set every time a particular flag is set or cleared.  In a future\npatch we want to eliminate this parallel set of flags so instead of\nrelying on if the textconv flag has been touched, add a new flag\n'TEXTCONV_SET_VIA_CMDLINE' which is only set if textconv is set to true\nvia the command line.\n\nSigned-off-by: Brandon Williams <bmwill@google.com>\n---\n builtin/log.c | 2 +-\n diff.c        | 5 +++--\n diff.h        | 1 +\n 3 files changed, 5 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/log.c b/builtin/log.c\nindex dc28d43eb..82131751d 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -485,7 +485,7 @@ static int show_blob_object(const struct object_id *oid, struct rev_info *rev, c\n \tunsigned long size;\n \n \tfflush(rev->diffopt.file);\n-\tif (!DIFF_OPT_TOUCHED(&rev->diffopt, ALLOW_TEXTCONV) ||\n+\tif (!DIFF_OPT_TST(&rev->diffopt, TEXTCONV_SET_VIA_CMDLINE) ||\n \t    !DIFF_OPT_TST(&rev->diffopt, ALLOW_TEXTCONV))\n \t\treturn stream_blob_to_fd(1, oid, NULL, 0);\n \ndiff --git a/diff.c b/diff.c\nindex 3ad9c9b31..11fccbd10 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4762,9 +4762,10 @@ int diff_opt_parse(struct diff_options *options,\n \t\tDIFF_OPT_SET(options, ALLOW_EXTERNAL);\n \telse if (!strcmp(arg, \"--no-ext-diff\"))\n \t\tDIFF_OPT_CLR(options, ALLOW_EXTERNAL);\n-\telse if (!strcmp(arg, \"--textconv\"))\n+\telse if (!strcmp(arg, \"--textconv\")) {\n \t\tDIFF_OPT_SET(options, ALLOW_TEXTCONV);\n-\telse if (!strcmp(arg, \"--no-textconv\"))\n+\t\tDIFF_OPT_SET(options, TEXTCONV_SET_VIA_CMDLINE);\n+\t} else if (!strcmp(arg, \"--no-textconv\"))\n \t\tDIFF_OPT_CLR(options, ALLOW_TEXTCONV);\n \telse if (!strcmp(arg, \"--ignore-submodules\")) {\n \t\tDIFF_OPT_SET(options, OVERRIDE_SUBMODULE_CONFIG);\ndiff --git a/diff.h b/diff.h\nindex e512cf44d..d077d3c10 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -83,6 +83,7 @@ struct diff_flags {\n \tunsigned DIRSTAT_CUMULATIVE:1;\n \tunsigned DIRSTAT_BY_FILE:1;\n \tunsigned ALLOW_TEXTCONV:1;\n+\tunsigned TEXTCONV_SET_VIA_CMDLINE:1;\n \tunsigned DIFF_FROM_CONTENTS:1;\n \tunsigned DIRTY_SUBMODULES:1;\n \tunsigned IGNORE_UNTRACKED_IN_SUBMODULES:1;\n-- \n2.15.0.403.gc27cc4dac6-goog\n\n"},{"id":"331503","messageId":"20171031181911.42687-7-bmwill@google.com","threadId":"47047","inReplyTo":"20171031181911.42687-1-bmwill@google.com","subject":"[PATCH v3 6/8] diff: remove DIFF_OPT_SET macro","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-10-31T18:19:09Z","receivedAt":"2017-10-31T18:19:42Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"Remove the `DIFF_OPT_SET` macro and instead set the flags directly.\nThis conversion is done using the following semantic patch:\n\n\t@@\n\texpression E;\n\tidentifier fld;\n\t@@\n\t- DIFF_OPT_SET(&E, fld)\n\t+ E.flags.fld = 1\n\n\t@@\n\ttype T;\n\tT *ptr;\n\tidentifier fld;\n\t@@\n\t- DIFF_OPT_SET(ptr, fld)\n\t+ ptr->flags.fld = 1\n\nSigned-off-by: Brandon Williams <bmwill@google.com>\n---\n blame.c               |  8 +++----\n builtin/add.c         |  4 ++--\n builtin/am.c          |  8 +++----\n builtin/blame.c       |  4 ++--\n builtin/diff.c        |  6 ++---\n builtin/fast-export.c |  2 +-\n builtin/log.c         | 14 +++++------\n builtin/reset.c       |  2 +-\n combine-diff.c        |  2 +-\n diff-lib.c            |  4 ++--\n diff-no-index.c       |  6 ++---\n diff.c                | 66 +++++++++++++++++++++++++--------------------------\n diff.h                |  1 -\n merge-recursive.c     |  2 +-\n notes-merge.c         |  4 ++--\n patch-ids.c           |  2 +-\n revision.c            | 16 ++++++-------\n submodule.c           |  8 +++----\n tree-diff.c           |  4 ++--\n wt-status.c           | 18 +++++++-------\n 20 files changed, 90 insertions(+), 91 deletions(-)\n\ndiff --git a/blame.c b/blame.c\nindex 7c019bc7c..dc9cc237b 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -541,7 +541,7 @@ static struct blame_origin *find_origin(struct commit *parent,\n \t * same and diff-tree is fairly efficient about this.\n \t */\n \tdiff_setup(&diff_opts);\n-\tDIFF_OPT_SET(&diff_opts, RECURSIVE);\n+\tdiff_opts.flags.RECURSIVE = 1;\n \tdiff_opts.detect_rename = 0;\n \tdiff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;\n \tpaths[0] = origin->path;\n@@ -615,7 +615,7 @@ static struct blame_origin *find_rename(struct commit *parent,\n \tint i;\n \n \tdiff_setup(&diff_opts);\n-\tDIFF_OPT_SET(&diff_opts, RECURSIVE);\n+\tdiff_opts.flags.RECURSIVE = 1;\n \tdiff_opts.detect_rename = DIFF_DETECT_RENAME;\n \tdiff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;\n \tdiff_opts.single_follow = origin->path;\n@@ -1238,7 +1238,7 @@ static void find_copy_in_parent(struct blame_scoreboard *sb,\n \t\treturn; /* nothing remains for this target */\n \n \tdiff_setup(&diff_opts);\n-\tDIFF_OPT_SET(&diff_opts, RECURSIVE);\n+\tdiff_opts.flags.RECURSIVE = 1;\n \tdiff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;\n \n \tdiff_setup_done(&diff_opts);\n@@ -1253,7 +1253,7 @@ static void find_copy_in_parent(struct blame_scoreboard *sb,\n \tif ((opt & PICKAXE_BLAME_COPY_HARDEST)\n \t    || ((opt & PICKAXE_BLAME_COPY_HARDER)\n \t\t&& (!porigin || strcmp(target->path, porigin->path))))\n-\t\tDIFF_OPT_SET(&diff_opts, FIND_COPIES_HARDER);\n+\t\tdiff_opts.flags.FIND_COPIES_HARDER = 1;\n \n \tif (is_null_oid(&target->commit->object.oid))\n \t\tdo_diff_cache(&parent->tree->object.oid, &diff_opts);\ndiff --git a/builtin/add.c b/builtin/add.c\nindex b70e8a779..e1d83b69a 100644\n--- a/builtin/add.c\n+++ b/builtin/add.c\n@@ -116,7 +116,7 @@ int add_files_to_cache(const char *prefix,\n \trev.diffopt.output_format = DIFF_FORMAT_CALLBACK;\n \trev.diffopt.format_callback = update_callback;\n \trev.diffopt.format_callback_data = &data;\n-\tDIFF_OPT_SET(&rev.diffopt, OVERRIDE_SUBMODULE_CONFIG);\n+\trev.diffopt.flags.OVERRIDE_SUBMODULE_CONFIG = 1;\n \trev.max_count = 0; /* do not compare unmerged paths with stage #2 */\n \trun_diff_files(&rev, DIFF_RACY_IS_MODIFIED);\n \tclear_pathspec(&rev.prune_data);\n@@ -218,7 +218,7 @@ static int edit_patch(int argc, const char **argv, const char *prefix)\n \targc = setup_revisions(argc, argv, &rev, NULL);\n \trev.diffopt.output_format = DIFF_FORMAT_PATCH;\n \trev.diffopt.use_color = 0;\n-\tDIFF_OPT_SET(&rev.diffopt, IGNORE_DIRTY_SUBMODULES);\n+\trev.diffopt.flags.IGNORE_DIRTY_SUBMODULES = 1;\n \tout = open(file, O_CREAT | O_WRONLY, 0666);\n \tif (out < 0)\n \t\tdie(_(\"Could not open '%s' for writing.\"), file);\ndiff --git a/builtin/am.c b/builtin/am.c\nindex fc54724cc..015425a0f 100644\n--- a/builtin/am.c\n+++ b/builtin/am.c\n@@ -1157,9 +1157,9 @@ static int index_has_changes(struct strbuf *sb)\n \t\tstruct diff_options opt;\n \n \t\tdiff_setup(&opt);\n-\t\tDIFF_OPT_SET(&opt, EXIT_WITH_STATUS);\n+\t\topt.flags.EXIT_WITH_STATUS = 1;\n \t\tif (!sb)\n-\t\t\tDIFF_OPT_SET(&opt, QUICK);\n+\t\t\topt.flags.QUICK = 1;\n \t\tdo_diff_cache(&head, &opt);\n \t\tdiffcore_std(&opt);\n \t\tfor (i = 0; sb && i < diff_queued_diff.nr; i++) {\n@@ -1409,8 +1409,8 @@ static void write_commit_patch(const struct am_state *state, struct commit *comm\n \trev_info.show_root_diff = 1;\n \trev_info.diffopt.output_format = DIFF_FORMAT_PATCH;\n \trev_info.no_commit_id = 1;\n-\tDIFF_OPT_SET(&rev_info.diffopt, BINARY);\n-\tDIFF_OPT_SET(&rev_info.diffopt, FULL_INDEX);\n+\trev_info.diffopt.flags.BINARY = 1;\n+\trev_info.diffopt.flags.FULL_INDEX = 1;\n \trev_info.diffopt.use_color = 0;\n \trev_info.diffopt.file = fp;\n \trev_info.diffopt.close_file = 1;\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex a29574984..76994aa64 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -708,8 +708,8 @@ int cmd_blame(int argc, const char **argv, const char *prefix)\n \tgit_config(git_blame_config, &output_option);\n \tinit_revisions(&revs, NULL);\n \trevs.date_mode = blame_date_mode;\n-\tDIFF_OPT_SET(&revs.diffopt, ALLOW_TEXTCONV);\n-\tDIFF_OPT_SET(&revs.diffopt, FOLLOW_RENAMES);\n+\trevs.diffopt.flags.ALLOW_TEXTCONV = 1;\n+\trevs.diffopt.flags.FOLLOW_RENAMES = 1;\n \n \tsave_commit_buffer = 0;\n \tdashdash_pos = 0;\ndiff --git a/builtin/diff.c b/builtin/diff.c\nindex 8cbaf4538..ed41eb5a5 100644\n--- a/builtin/diff.c\n+++ b/builtin/diff.c\n@@ -350,8 +350,8 @@ int cmd_diff(int argc, const char **argv, const char *prefix)\n \trev.diffopt.stat_graph_width = -1;\n \n \t/* Default to let external and textconv be used */\n-\tDIFF_OPT_SET(&rev.diffopt, ALLOW_EXTERNAL);\n-\tDIFF_OPT_SET(&rev.diffopt, ALLOW_TEXTCONV);\n+\trev.diffopt.flags.ALLOW_EXTERNAL = 1;\n+\trev.diffopt.flags.ALLOW_TEXTCONV = 1;\n \n \tif (nongit)\n \t\tdie(_(\"Not a git repository\"));\n@@ -361,7 +361,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)\n \t\tdiff_setup_done(&rev.diffopt);\n \t}\n \n-\tDIFF_OPT_SET(&rev.diffopt, RECURSIVE);\n+\trev.diffopt.flags.RECURSIVE = 1;\n \n \tsetup_diff_pager(&rev.diffopt);\n \ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex 2fb60d6d4..35c8fb65d 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -1066,7 +1066,7 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)\n \t\tdie(\"revision walk setup failed\");\n \trevs.diffopt.format_callback = show_filemodify;\n \trevs.diffopt.format_callback_data = &paths_of_changed_objects;\n-\tDIFF_OPT_SET(&revs.diffopt, RECURSIVE);\n+\trevs.diffopt.flags.RECURSIVE = 1;\n \twhile ((commit = get_revision(&revs))) {\n \t\tif (has_unshown_parent(commit)) {\n \t\t\tadd_object_array(&commit->object, NULL, &commits);\ndiff --git a/builtin/log.c b/builtin/log.c\nindex 2b2d36678..4a24d3e48 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -121,16 +121,16 @@ static void cmd_log_init_defaults(struct rev_info *rev)\n \tif (fmt_pretty)\n \t\tget_commit_format(fmt_pretty, rev);\n \tif (default_follow)\n-\t\tDIFF_OPT_SET(&rev->diffopt, DEFAULT_FOLLOW_RENAMES);\n+\t\trev->diffopt.flags.DEFAULT_FOLLOW_RENAMES = 1;\n \trev->verbose_header = 1;\n-\tDIFF_OPT_SET(&rev->diffopt, RECURSIVE);\n+\trev->diffopt.flags.RECURSIVE = 1;\n \trev->diffopt.stat_width = -1; /* use full terminal width */\n \trev->diffopt.stat_graph_width = -1; /* respect statGraphWidth config */\n \trev->abbrev_commit = default_abbrev_commit;\n \trev->show_root_diff = default_show_root;\n \trev->subject_prefix = fmt_patch_subject_prefix;\n \trev->show_signature = default_show_signature;\n-\tDIFF_OPT_SET(&rev->diffopt, ALLOW_TEXTCONV);\n+\trev->diffopt.flags.ALLOW_TEXTCONV = 1;\n \n \tif (default_date_mode)\n \t\tparse_date_format(default_date_mode, &rev->date_mode);\n@@ -668,7 +668,7 @@ static void log_setup_revisions_tweak(struct rev_info *rev,\n {\n \tif (rev->diffopt.flags.DEFAULT_FOLLOW_RENAMES &&\n \t    rev->prune_data.nr == 1)\n-\t\tDIFF_OPT_SET(&rev->diffopt, FOLLOW_RENAMES);\n+\t\trev->diffopt.flags.FOLLOW_RENAMES = 1;\n \n \t/* Turn --cc/-c into -p --cc/-c when -p was not given */\n \tif (!rev->diffopt.output_format && rev->combine_merges)\n@@ -1340,7 +1340,7 @@ static void prepare_bases(struct base_tree_info *bases,\n \t\treturn;\n \n \tdiff_setup(&diffopt);\n-\tDIFF_OPT_SET(&diffopt, RECURSIVE);\n+\tdiffopt.flags.RECURSIVE = 1;\n \tdiff_setup_done(&diffopt);\n \n \toidcpy(&bases->base_commit, &base->object.oid);\n@@ -1511,7 +1511,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \trev.verbose_header = 1;\n \trev.diff = 1;\n \trev.max_parents = 1;\n-\tDIFF_OPT_SET(&rev.diffopt, RECURSIVE);\n+\trev.diffopt.flags.RECURSIVE = 1;\n \trev.subject_prefix = fmt_patch_subject_prefix;\n \tmemset(&s_r_opt, 0, sizeof(s_r_opt));\n \ts_r_opt.def = \"HEAD\";\n@@ -1613,7 +1613,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \trev.zero_commit = zero_commit;\n \n \tif (!rev.diffopt.flags.TEXT && !no_binary_diff)\n-\t\tDIFF_OPT_SET(&rev.diffopt, BINARY);\n+\t\trev.diffopt.flags.BINARY = 1;\n \n \tif (rev.show_notes)\n \t\tinit_display_notes(&rev.notes_opt);\ndiff --git a/builtin/reset.c b/builtin/reset.c\nindex ea2fad5a0..206819ef1 100644\n--- a/builtin/reset.c\n+++ b/builtin/reset.c\n@@ -166,7 +166,7 @@ static int read_from_tree(const struct pathspec *pathspec,\n \topt.output_format = DIFF_FORMAT_CALLBACK;\n \topt.format_callback = update_index_from_diff;\n \topt.format_callback_data = &intent_to_add;\n-\tDIFF_OPT_SET(&opt, OVERRIDE_SUBMODULE_CONFIG);\n+\topt.flags.OVERRIDE_SUBMODULE_CONFIG = 1;\n \n \tif (do_diff_cache(tree_oid, &opt))\n \t\treturn 1;\ndiff --git a/combine-diff.c b/combine-diff.c\nindex 40cb4dd1a..204b0dfce 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -1413,7 +1413,7 @@ void diff_tree_combined(const struct object_id *oid,\n \n \tdiffopts = *opt;\n \tcopy_pathspec(&diffopts.pathspec, &opt->pathspec);\n-\tDIFF_OPT_SET(&diffopts, RECURSIVE);\n+\tdiffopts.flags.RECURSIVE = 1;\n \tDIFF_OPT_CLR(&diffopts, ALLOW_EXTERNAL);\n \n \t/* find set of paths that everybody touches\ndiff --git a/diff-lib.c b/diff-lib.c\nindex 456971b2c..f1cc3fd51 100644\n--- a/diff-lib.c\n+++ b/diff-lib.c\n@@ -545,8 +545,8 @@ int index_differs_from(const char *def, const struct diff_flags *flags,\n \tmemset(&opt, 0, sizeof(opt));\n \topt.def = def;\n \tsetup_revisions(0, NULL, &rev, &opt);\n-\tDIFF_OPT_SET(&rev.diffopt, QUICK);\n-\tDIFF_OPT_SET(&rev.diffopt, EXIT_WITH_STATUS);\n+\trev.diffopt.flags.QUICK = 1;\n+\trev.diffopt.flags.EXIT_WITH_STATUS = 1;\n \tif (flags)\n \t\tdiff_flags_or(&rev.diffopt.flags, flags);\n \trev.diffopt.ita_invisible_in_index = ita_invisible_in_index;\ndiff --git a/diff-no-index.c b/diff-no-index.c\nindex 40d17e42c..a3e194340 100644\n--- a/diff-no-index.c\n+++ b/diff-no-index.c\n@@ -276,16 +276,16 @@ void diff_no_index(struct rev_info *revs,\n \tif (!revs->diffopt.output_format)\n \t\trevs->diffopt.output_format = DIFF_FORMAT_PATCH;\n \n-\tDIFF_OPT_SET(&revs->diffopt, NO_INDEX);\n+\trevs->diffopt.flags.NO_INDEX = 1;\n \n-\tDIFF_OPT_SET(&revs->diffopt, RELATIVE_NAME);\n+\trevs->diffopt.flags.RELATIVE_NAME = 1;\n \trevs->diffopt.prefix = prefix;\n \n \trevs->max_count = -2;\n \tdiff_setup_done(&revs->diffopt);\n \n \tsetup_diff_pager(&revs->diffopt);\n-\tDIFF_OPT_SET(&revs->diffopt, EXIT_WITH_STATUS);\n+\trevs->diffopt.flags.EXIT_WITH_STATUS = 1;\n \n \tif (queue_diff(&revs->diffopt, paths[0], paths[1]))\n \t\texit(1);\ndiff --git a/diff.c b/diff.c\nindex 8bfa57cc3..6dea186d8 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -127,15 +127,15 @@ static int parse_dirstat_params(struct diff_options *options, const char *params\n \t\t\tDIFF_OPT_CLR(options, DIRSTAT_BY_LINE);\n \t\t\tDIFF_OPT_CLR(options, DIRSTAT_BY_FILE);\n \t\t} else if (!strcmp(p, \"lines\")) {\n-\t\t\tDIFF_OPT_SET(options, DIRSTAT_BY_LINE);\n+\t\t\toptions->flags.DIRSTAT_BY_LINE = 1;\n \t\t\tDIFF_OPT_CLR(options, DIRSTAT_BY_FILE);\n \t\t} else if (!strcmp(p, \"files\")) {\n \t\t\tDIFF_OPT_CLR(options, DIRSTAT_BY_LINE);\n-\t\t\tDIFF_OPT_SET(options, DIRSTAT_BY_FILE);\n+\t\t\toptions->flags.DIRSTAT_BY_FILE = 1;\n \t\t} else if (!strcmp(p, \"noncumulative\")) {\n \t\t\tDIFF_OPT_CLR(options, DIRSTAT_CUMULATIVE);\n \t\t} else if (!strcmp(p, \"cumulative\")) {\n-\t\t\tDIFF_OPT_SET(options, DIRSTAT_CUMULATIVE);\n+\t\t\toptions->flags.DIRSTAT_CUMULATIVE = 1;\n \t\t} else if (isdigit(*p)) {\n \t\t\tchar *end;\n \t\t\tint permille = strtoul(p, &end, 10) * 10;\n@@ -3447,7 +3447,7 @@ static void builtin_checkdiff(const char *name_a, const char *name_b,\n \tdiff_free_filespec_data(one);\n \tdiff_free_filespec_data(two);\n \tif (data.status)\n-\t\tDIFF_OPT_SET(o, CHECK_FAILED);\n+\t\to->flags.CHECK_FAILED = 1;\n }\n \n struct diff_filespec *alloc_filespec(const char *path)\n@@ -4152,7 +4152,7 @@ void diff_setup(struct diff_options *options)\n \toptions->context = diff_context_default;\n \toptions->interhunkcontext = diff_interhunk_context_default;\n \toptions->ws_error_highlight = ws_error_highlight_default;\n-\tDIFF_OPT_SET(options, RENAME_EMPTY);\n+\toptions->flags.RENAME_EMPTY = 1;\n \n \t/* pathchange left =NULL by default */\n \toptions->change = diff_change;\n@@ -4203,7 +4203,7 @@ void diff_setup_done(struct diff_options *options)\n \tif (DIFF_XDL_TST(options, IGNORE_WHITESPACE) ||\n \t    DIFF_XDL_TST(options, IGNORE_WHITESPACE_CHANGE) ||\n \t    DIFF_XDL_TST(options, IGNORE_WHITESPACE_AT_EOL))\n-\t\tDIFF_OPT_SET(options, DIFF_FROM_CONTENTS);\n+\t\toptions->flags.DIFF_FROM_CONTENTS = 1;\n \telse\n \t\tDIFF_OPT_CLR(options, DIFF_FROM_CONTENTS);\n \n@@ -4240,18 +4240,18 @@ void diff_setup_done(struct diff_options *options)\n \t\t\t\t      DIFF_FORMAT_DIRSTAT |\n \t\t\t\t      DIFF_FORMAT_SUMMARY |\n \t\t\t\t      DIFF_FORMAT_CHECKDIFF))\n-\t\tDIFF_OPT_SET(options, RECURSIVE);\n+\t\toptions->flags.RECURSIVE = 1;\n \t/*\n \t * Also pickaxe would not work very well if you do not say recursive\n \t */\n \tif (options->pickaxe)\n-\t\tDIFF_OPT_SET(options, RECURSIVE);\n+\t\toptions->flags.RECURSIVE = 1;\n \t/*\n \t * When patches are generated, submodules diffed against the work tree\n \t * must be checked for dirtiness too so it can be shown in the output\n \t */\n \tif (options->output_format & DIFF_FORMAT_PATCH)\n-\t\tDIFF_OPT_SET(options, DIRTY_SUBMODULES);\n+\t\toptions->flags.DIRTY_SUBMODULES = 1;\n \n \tif (options->detect_rename && options->rename_limit < 0)\n \t\toptions->rename_limit = diff_rename_limit_default;\n@@ -4275,7 +4275,7 @@ void diff_setup_done(struct diff_options *options)\n \t */\n \tif (options->flags.QUICK) {\n \t\toptions->output_format = DIFF_FORMAT_NO_OUTPUT;\n-\t\tDIFF_OPT_SET(options, EXIT_WITH_STATUS);\n+\t\toptions->flags.EXIT_WITH_STATUS = 1;\n \t}\n \n \toptions->diff_path_counter = 0;\n@@ -4630,7 +4630,7 @@ int diff_opt_parse(struct diff_options *options,\n \telse if (starts_with(arg, \"-C\") || starts_with(arg, \"--find-copies=\") ||\n \t\t !strcmp(arg, \"--find-copies\")) {\n \t\tif (options->detect_rename == DIFF_DETECT_COPY)\n-\t\t\tDIFF_OPT_SET(options, FIND_COPIES_HARDER);\n+\t\t\toptions->flags.FIND_COPIES_HARDER = 1;\n \t\tif ((options->rename_score = diff_scoreopt_parse(arg)) == -1)\n \t\t\treturn error(\"invalid argument to -C: %s\", arg+2);\n \t\toptions->detect_rename = DIFF_DETECT_COPY;\n@@ -4638,13 +4638,13 @@ int diff_opt_parse(struct diff_options *options,\n \telse if (!strcmp(arg, \"--no-renames\"))\n \t\toptions->detect_rename = 0;\n \telse if (!strcmp(arg, \"--rename-empty\"))\n-\t\tDIFF_OPT_SET(options, RENAME_EMPTY);\n+\t\toptions->flags.RENAME_EMPTY = 1;\n \telse if (!strcmp(arg, \"--no-rename-empty\"))\n \t\tDIFF_OPT_CLR(options, RENAME_EMPTY);\n \telse if (!strcmp(arg, \"--relative\"))\n-\t\tDIFF_OPT_SET(options, RELATIVE_NAME);\n+\t\toptions->flags.RELATIVE_NAME = 1;\n \telse if (skip_prefix(arg, \"--relative=\", &arg)) {\n-\t\tDIFF_OPT_SET(options, RELATIVE_NAME);\n+\t\toptions->flags.RELATIVE_NAME = 1;\n \t\toptions->prefix = arg;\n \t}\n \n@@ -4684,18 +4684,18 @@ int diff_opt_parse(struct diff_options *options,\n \t/* flags options */\n \telse if (!strcmp(arg, \"--binary\")) {\n \t\tenable_patch_output(&options->output_format);\n-\t\tDIFF_OPT_SET(options, BINARY);\n+\t\toptions->flags.BINARY = 1;\n \t}\n \telse if (!strcmp(arg, \"--full-index\"))\n-\t\tDIFF_OPT_SET(options, FULL_INDEX);\n+\t\toptions->flags.FULL_INDEX = 1;\n \telse if (!strcmp(arg, \"-a\") || !strcmp(arg, \"--text\"))\n-\t\tDIFF_OPT_SET(options, TEXT);\n+\t\toptions->flags.TEXT = 1;\n \telse if (!strcmp(arg, \"-R\"))\n-\t\tDIFF_OPT_SET(options, REVERSE_DIFF);\n+\t\toptions->flags.REVERSE_DIFF = 1;\n \telse if (!strcmp(arg, \"--find-copies-harder\"))\n-\t\tDIFF_OPT_SET(options, FIND_COPIES_HARDER);\n+\t\toptions->flags.FIND_COPIES_HARDER = 1;\n \telse if (!strcmp(arg, \"--follow\"))\n-\t\tDIFF_OPT_SET(options, FOLLOW_RENAMES);\n+\t\toptions->flags.FOLLOW_RENAMES = 1;\n \telse if (!strcmp(arg, \"--no-follow\")) {\n \t\tDIFF_OPT_CLR(options, FOLLOW_RENAMES);\n \t\tDIFF_OPT_CLR(options, DEFAULT_FOLLOW_RENAMES);\n@@ -4755,23 +4755,23 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn argcount;\n \t}\n \telse if (!strcmp(arg, \"--exit-code\"))\n-\t\tDIFF_OPT_SET(options, EXIT_WITH_STATUS);\n+\t\toptions->flags.EXIT_WITH_STATUS = 1;\n \telse if (!strcmp(arg, \"--quiet\"))\n-\t\tDIFF_OPT_SET(options, QUICK);\n+\t\toptions->flags.QUICK = 1;\n \telse if (!strcmp(arg, \"--ext-diff\"))\n-\t\tDIFF_OPT_SET(options, ALLOW_EXTERNAL);\n+\t\toptions->flags.ALLOW_EXTERNAL = 1;\n \telse if (!strcmp(arg, \"--no-ext-diff\"))\n \t\tDIFF_OPT_CLR(options, ALLOW_EXTERNAL);\n \telse if (!strcmp(arg, \"--textconv\")) {\n-\t\tDIFF_OPT_SET(options, ALLOW_TEXTCONV);\n-\t\tDIFF_OPT_SET(options, TEXTCONV_SET_VIA_CMDLINE);\n+\t\toptions->flags.ALLOW_TEXTCONV = 1;\n+\t\toptions->flags.TEXTCONV_SET_VIA_CMDLINE = 1;\n \t} else if (!strcmp(arg, \"--no-textconv\"))\n \t\tDIFF_OPT_CLR(options, ALLOW_TEXTCONV);\n \telse if (!strcmp(arg, \"--ignore-submodules\")) {\n-\t\tDIFF_OPT_SET(options, OVERRIDE_SUBMODULE_CONFIG);\n+\t\toptions->flags.OVERRIDE_SUBMODULE_CONFIG = 1;\n \t\thandle_ignore_submodules_arg(options, \"all\");\n \t} else if (skip_prefix(arg, \"--ignore-submodules=\", &arg)) {\n-\t\tDIFF_OPT_SET(options, OVERRIDE_SUBMODULE_CONFIG);\n+\t\toptions->flags.OVERRIDE_SUBMODULE_CONFIG = 1;\n \t\thandle_ignore_submodules_arg(options, arg);\n \t} else if (!strcmp(arg, \"--submodule\"))\n \t\toptions->submodule_format = DIFF_SUBMODULE_LOG;\n@@ -4846,9 +4846,9 @@ int diff_opt_parse(struct diff_options *options,\n \t\t\t &options->interhunkcontext))\n \t\t;\n \telse if (!strcmp(arg, \"-W\"))\n-\t\tDIFF_OPT_SET(options, FUNCCONTEXT);\n+\t\toptions->flags.FUNCCONTEXT = 1;\n \telse if (!strcmp(arg, \"--function-context\"))\n-\t\tDIFF_OPT_SET(options, FUNCCONTEXT);\n+\t\toptions->flags.FUNCCONTEXT = 1;\n \telse if (!strcmp(arg, \"--no-function-context\"))\n \t\tDIFF_OPT_CLR(options, FUNCCONTEXT);\n \telse if ((argcount = parse_long_opt(\"output\", av, &optarg))) {\n@@ -5686,7 +5686,7 @@ void diff_flush(struct diff_options *options)\n \t */\n \tif (options->flags.DIFF_FROM_CONTENTS) {\n \t\tif (options->found_changes)\n-\t\t\tDIFF_OPT_SET(options, HAS_CHANGES);\n+\t\t\toptions->flags.HAS_CHANGES = 1;\n \t\telse\n \t\t\tDIFF_OPT_CLR(options, HAS_CHANGES);\n \t}\n@@ -5858,7 +5858,7 @@ void diffcore_std(struct diff_options *options)\n \tdiffcore_apply_filter(options);\n \n \tif (diff_queued_diff.nr && !options->flags.DIFF_FROM_CONTENTS)\n-\t\tDIFF_OPT_SET(options, HAS_CHANGES);\n+\t\toptions->flags.HAS_CHANGES = 1;\n \telse\n \t\tDIFF_OPT_CLR(options, HAS_CHANGES);\n \n@@ -5952,7 +5952,7 @@ void diff_addremove(struct diff_options *options,\n \n \tdiff_queue(&diff_queued_diff, one, two);\n \tif (!options->flags.DIFF_FROM_CONTENTS)\n-\t\tDIFF_OPT_SET(options, HAS_CHANGES);\n+\t\toptions->flags.HAS_CHANGES = 1;\n }\n \n void diff_change(struct diff_options *options,\n@@ -5996,7 +5996,7 @@ void diff_change(struct diff_options *options,\n \t    !diff_filespec_check_stat_unmatch(p))\n \t\treturn;\n \n-\tDIFF_OPT_SET(options, HAS_CHANGES);\n+\toptions->flags.HAS_CHANGES = 1;\n }\n \n struct diff_filepair *diff_unmerge(struct diff_options *options, const char *path)\ndiff --git a/diff.h b/diff.h\nindex c3798a104..d53e5a2da 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -106,7 +106,6 @@ static inline void diff_flags_or(struct diff_flags *a,\n \t\ttmp_a[i] |= tmp_b[i];\n }\n \n-#define DIFF_OPT_SET(opts, flag)\t((opts)->flags.flag = 1)\n #define DIFF_OPT_CLR(opts, flag)\t((opts)->flags.flag = 0)\n \n #define DIFF_XDL_TST(opts, flag)    ((opts)->xdl_opts & XDF_##flag)\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 1d3f8f0d2..e7b3df45c 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -540,7 +540,7 @@ static struct string_list *get_renames(struct merge_options *o,\n \t\treturn renames;\n \n \tdiff_setup(&opts);\n-\tDIFF_OPT_SET(&opts, RECURSIVE);\n+\topts.flags.RECURSIVE = 1;\n \tDIFF_OPT_CLR(&opts, RENAME_EMPTY);\n \topts.detect_rename = DIFF_DETECT_RENAME;\n \topts.rename_limit = o->merge_rename_limit >= 0 ? o->merge_rename_limit :\ndiff --git a/notes-merge.c b/notes-merge.c\nindex 4352c34a6..b50111cf2 100644\n--- a/notes-merge.c\n+++ b/notes-merge.c\n@@ -125,7 +125,7 @@ static struct notes_merge_pair *diff_tree_remote(struct notes_merge_options *o,\n \t       oid_to_hex(base), oid_to_hex(remote));\n \n \tdiff_setup(&opt);\n-\tDIFF_OPT_SET(&opt, RECURSIVE);\n+\topt.flags.RECURSIVE = 1;\n \topt.output_format = DIFF_FORMAT_NO_OUTPUT;\n \tdiff_setup_done(&opt);\n \tdiff_tree_oid(base, remote, \"\", &opt);\n@@ -188,7 +188,7 @@ static void diff_tree_local(struct notes_merge_options *o,\n \t       len, oid_to_hex(base), oid_to_hex(local));\n \n \tdiff_setup(&opt);\n-\tDIFF_OPT_SET(&opt, RECURSIVE);\n+\topt.flags.RECURSIVE = 1;\n \topt.output_format = DIFF_FORMAT_NO_OUTPUT;\n \tdiff_setup_done(&opt);\n \tdiff_tree_oid(base, local, \"\", &opt);\ndiff --git a/patch-ids.c b/patch-ids.c\nindex 7a583b301..189869e57 100644\n--- a/patch-ids.c\n+++ b/patch-ids.c\n@@ -61,7 +61,7 @@ int init_patch_ids(struct patch_ids *ids)\n \tmemset(ids, 0, sizeof(*ids));\n \tdiff_setup(&ids->diffopts);\n \tids->diffopts.detect_rename = 0;\n-\tDIFF_OPT_SET(&ids->diffopts, RECURSIVE);\n+\tids->diffopts.flags.RECURSIVE = 1;\n \tdiff_setup_done(&ids->diffopts);\n \thashmap_init(&ids->patches, patch_id_cmp, &ids->diffopts, 256);\n \treturn 0;\ndiff --git a/revision.c b/revision.c\nindex c893d9166..f019dd277 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -410,7 +410,7 @@ static void file_add_remove(struct diff_options *options,\n \n \ttree_difference |= diff;\n \tif (tree_difference == REV_TREE_DIFFERENT)\n-\t\tDIFF_OPT_SET(options, HAS_CHANGES);\n+\t\toptions->flags.HAS_CHANGES = 1;\n }\n \n static void file_change(struct diff_options *options,\n@@ -422,7 +422,7 @@ static void file_change(struct diff_options *options,\n \t\t unsigned old_dirty_submodule, unsigned new_dirty_submodule)\n {\n \ttree_difference = REV_TREE_DIFFERENT;\n-\tDIFF_OPT_SET(options, HAS_CHANGES);\n+\toptions->flags.HAS_CHANGES = 1;\n }\n \n static int rev_compare_tree(struct rev_info *revs,\n@@ -1403,8 +1403,8 @@ void init_revisions(struct rev_info *revs, const char *prefix)\n \trevs->abbrev = DEFAULT_ABBREV;\n \trevs->ignore_merges = 1;\n \trevs->simplify_history = 1;\n-\tDIFF_OPT_SET(&revs->pruning, RECURSIVE);\n-\tDIFF_OPT_SET(&revs->pruning, QUICK);\n+\trevs->pruning.flags.RECURSIVE = 1;\n+\trevs->pruning.flags.QUICK = 1;\n \trevs->pruning.add_remove = file_add_remove;\n \trevs->pruning.change = file_change;\n \trevs->sort_order = REV_SORT_IN_GRAPH_ORDER;\n@@ -1917,11 +1917,11 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg\n \t\tdie(\"--unpacked=<packfile> no longer supported.\");\n \t} else if (!strcmp(arg, \"-r\")) {\n \t\trevs->diff = 1;\n-\t\tDIFF_OPT_SET(&revs->diffopt, RECURSIVE);\n+\t\trevs->diffopt.flags.RECURSIVE = 1;\n \t} else if (!strcmp(arg, \"-t\")) {\n \t\trevs->diff = 1;\n-\t\tDIFF_OPT_SET(&revs->diffopt, RECURSIVE);\n-\t\tDIFF_OPT_SET(&revs->diffopt, TREE_IN_RECURSIVE);\n+\t\trevs->diffopt.flags.RECURSIVE = 1;\n+\t\trevs->diffopt.flags.TREE_IN_RECURSIVE = 1;\n \t} else if (!strcmp(arg, \"-m\")) {\n \t\trevs->ignore_merges = 0;\n \t} else if (!strcmp(arg, \"-c\")) {\n@@ -2066,7 +2066,7 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg\n \t\trevs->grep_filter.pattern_type_option = GREP_PATTERN_TYPE_ERE;\n \t} else if (!strcmp(arg, \"--regexp-ignore-case\") || !strcmp(arg, \"-i\")) {\n \t\trevs->grep_filter.ignore_case = 1;\n-\t\tDIFF_OPT_SET(&revs->diffopt, PICKAXE_IGNORE_CASE);\n+\t\trevs->diffopt.flags.PICKAXE_IGNORE_CASE = 1;\n \t} else if (!strcmp(arg, \"--fixed-strings\") || !strcmp(arg, \"-F\")) {\n \t\trevs->grep_filter.pattern_type_option = GREP_PATTERN_TYPE_FIXED;\n \t} else if (!strcmp(arg, \"--perl-regexp\") || !strcmp(arg, \"-P\")) {\ndiff --git a/submodule.c b/submodule.c\nindex 58da9c668..7e7998592 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -183,7 +183,7 @@ void set_diffopt_flags_from_submodule_config(struct diff_options *diffopt,\n \t\tif (ignore)\n \t\t\thandle_ignore_submodules_arg(diffopt, ignore);\n \t\telse if (is_gitmodules_unmerged(&the_index))\n-\t\t\tDIFF_OPT_SET(diffopt, IGNORE_SUBMODULES);\n+\t\t\tdiffopt->flags.IGNORE_SUBMODULES = 1;\n \t}\n }\n \n@@ -407,11 +407,11 @@ void handle_ignore_submodules_arg(struct diff_options *diffopt,\n \tDIFF_OPT_CLR(diffopt, IGNORE_DIRTY_SUBMODULES);\n \n \tif (!strcmp(arg, \"all\"))\n-\t\tDIFF_OPT_SET(diffopt, IGNORE_SUBMODULES);\n+\t\tdiffopt->flags.IGNORE_SUBMODULES = 1;\n \telse if (!strcmp(arg, \"untracked\"))\n-\t\tDIFF_OPT_SET(diffopt, IGNORE_UNTRACKED_IN_SUBMODULES);\n+\t\tdiffopt->flags.IGNORE_UNTRACKED_IN_SUBMODULES = 1;\n \telse if (!strcmp(arg, \"dirty\"))\n-\t\tDIFF_OPT_SET(diffopt, IGNORE_DIRTY_SUBMODULES);\n+\t\tdiffopt->flags.IGNORE_DIRTY_SUBMODULES = 1;\n \telse if (strcmp(arg, \"none\"))\n \t\tdie(\"bad --ignore-submodules argument: %s\", arg);\n }\ndiff --git a/tree-diff.c b/tree-diff.c\nindex ed0aa6a62..b996a23bb 100644\n--- a/tree-diff.c\n+++ b/tree-diff.c\n@@ -608,8 +608,8 @@ static void try_to_follow_renames(const struct object_id *old_oid,\n \tq->nr = 0;\n \n \tdiff_setup(&diff_opts);\n-\tDIFF_OPT_SET(&diff_opts, RECURSIVE);\n-\tDIFF_OPT_SET(&diff_opts, FIND_COPIES_HARDER);\n+\tdiff_opts.flags.RECURSIVE = 1;\n+\tdiff_opts.flags.FIND_COPIES_HARDER = 1;\n \tdiff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;\n \tdiff_opts.single_follow = opt->pathspec.items[0].match;\n \tdiff_opts.break_opt = opt->break_opt;\ndiff --git a/wt-status.c b/wt-status.c\nindex 29bc64cc0..59f9f3a0b 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -559,12 +559,12 @@ static void wt_status_collect_changes_worktree(struct wt_status *s)\n \tinit_revisions(&rev, NULL);\n \tsetup_revisions(0, NULL, &rev, NULL);\n \trev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;\n-\tDIFF_OPT_SET(&rev.diffopt, DIRTY_SUBMODULES);\n+\trev.diffopt.flags.DIRTY_SUBMODULES = 1;\n \trev.diffopt.ita_invisible_in_index = 1;\n \tif (!s->show_untracked_files)\n-\t\tDIFF_OPT_SET(&rev.diffopt, IGNORE_UNTRACKED_IN_SUBMODULES);\n+\t\trev.diffopt.flags.IGNORE_UNTRACKED_IN_SUBMODULES = 1;\n \tif (s->ignore_submodule_arg) {\n-\t\tDIFF_OPT_SET(&rev.diffopt, OVERRIDE_SUBMODULE_CONFIG);\n+\t\trev.diffopt.flags.OVERRIDE_SUBMODULE_CONFIG = 1;\n \t\thandle_ignore_submodules_arg(&rev.diffopt, s->ignore_submodule_arg);\n \t}\n \trev.diffopt.format_callback = wt_status_collect_changed_cb;\n@@ -583,7 +583,7 @@ static void wt_status_collect_changes_index(struct wt_status *s)\n \topt.def = s->is_initial ? EMPTY_TREE_SHA1_HEX : s->reference;\n \tsetup_revisions(0, NULL, &rev, &opt);\n \n-\tDIFF_OPT_SET(&rev.diffopt, OVERRIDE_SUBMODULE_CONFIG);\n+\trev.diffopt.flags.OVERRIDE_SUBMODULE_CONFIG = 1;\n \trev.diffopt.ita_invisible_in_index = 1;\n \tif (s->ignore_submodule_arg) {\n \t\thandle_ignore_submodules_arg(&rev.diffopt, s->ignore_submodule_arg);\n@@ -949,7 +949,7 @@ static void wt_longstatus_print_verbose(struct wt_status *s)\n \tconst char *c = color(WT_STATUS_HEADER, s);\n \n \tinit_revisions(&rev, NULL);\n-\tDIFF_OPT_SET(&rev.diffopt, ALLOW_TEXTCONV);\n+\trev.diffopt.flags.ALLOW_TEXTCONV = 1;\n \trev.diffopt.ita_invisible_in_index = 1;\n \n \tmemset(&opt, 0, sizeof(opt));\n@@ -2263,8 +2263,8 @@ int has_unstaged_changes(int ignore_submodules)\n \n \tinit_revisions(&rev_info, NULL);\n \tif (ignore_submodules)\n-\t\tDIFF_OPT_SET(&rev_info.diffopt, IGNORE_SUBMODULES);\n-\tDIFF_OPT_SET(&rev_info.diffopt, QUICK);\n+\t\trev_info.diffopt.flags.IGNORE_SUBMODULES = 1;\n+\trev_info.diffopt.flags.QUICK = 1;\n \tdiff_setup_done(&rev_info.diffopt);\n \tresult = run_diff_files(&rev_info, 0);\n \treturn diff_result_code(&rev_info.diffopt, result);\n@@ -2283,8 +2283,8 @@ int has_uncommitted_changes(int ignore_submodules)\n \n \tinit_revisions(&rev_info, NULL);\n \tif (ignore_submodules)\n-\t\tDIFF_OPT_SET(&rev_info.diffopt, IGNORE_SUBMODULES);\n-\tDIFF_OPT_SET(&rev_info.diffopt, QUICK);\n+\t\trev_info.diffopt.flags.IGNORE_SUBMODULES = 1;\n+\trev_info.diffopt.flags.QUICK = 1;\n \tadd_head_to_pending(&rev_info);\n \tdiff_setup_done(&rev_info.diffopt);\n \tresult = run_diff_index(&rev_info, 1);\n-- \n2.15.0.403.gc27cc4dac6-goog\n\n"},{"id":"331504","messageId":"20171031181911.42687-8-bmwill@google.com","threadId":"47047","inReplyTo":"20171031181911.42687-1-bmwill@google.com","subject":"[PATCH v3 7/8] diff: remove DIFF_OPT_CLR macro","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-10-31T18:19:10Z","receivedAt":"2017-10-31T18:19:44Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"Remove the `DIFF_OPT_SET` macro and instead set the flags directly.\nThis conversion is done using the following semantic patch:\n\n\t@@\n\texpression E;\n\tidentifier fld;\n\t@@\n\t- DIFF_OPT_CLR(&E, fld)\n\t+ E.flags.fld = 0\n\n\t@@\n\ttype T;\n\tT *ptr;\n\tidentifier fld;\n\t@@\n\t- DIFF_OPT_CLR(ptr, fld)\n\t+ ptr->flags.fld = 0\n\nSigned-off-by: Brandon Williams <bmwill@google.com>\n---\n builtin/blame.c   |  2 +-\n combine-diff.c    |  2 +-\n diff.c            | 28 ++++++++++++++--------------\n diff.h            |  2 --\n merge-recursive.c |  2 +-\n revision.c        |  4 ++--\n submodule.c       |  6 +++---\n 7 files changed, 22 insertions(+), 24 deletions(-)\n\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex 76994aa64..79db9e849 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -736,7 +736,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)\n parse_done:\n \tno_whole_file_rename = !revs.diffopt.flags.FOLLOW_RENAMES;\n \txdl_opts |= revs.diffopt.xdl_opts & XDF_INDENT_HEURISTIC;\n-\tDIFF_OPT_CLR(&revs.diffopt, FOLLOW_RENAMES);\n+\trevs.diffopt.flags.FOLLOW_RENAMES = 0;\n \targc = parse_options_end(&ctx);\n \n \tif (incremental || (output_option & OUTPUT_PORCELAIN)) {\ndiff --git a/combine-diff.c b/combine-diff.c\nindex 204b0dfce..5a3a8b49b 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -1414,7 +1414,7 @@ void diff_tree_combined(const struct object_id *oid,\n \tdiffopts = *opt;\n \tcopy_pathspec(&diffopts.pathspec, &opt->pathspec);\n \tdiffopts.flags.RECURSIVE = 1;\n-\tDIFF_OPT_CLR(&diffopts, ALLOW_EXTERNAL);\n+\tdiffopts.flags.ALLOW_EXTERNAL = 0;\n \n \t/* find set of paths that everybody touches\n \t *\ndiff --git a/diff.c b/diff.c\nindex 6dea186d8..e5f9d3078 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -124,16 +124,16 @@ static int parse_dirstat_params(struct diff_options *options, const char *params\n \tfor (i = 0; i < params.nr; i++) {\n \t\tconst char *p = params.items[i].string;\n \t\tif (!strcmp(p, \"changes\")) {\n-\t\t\tDIFF_OPT_CLR(options, DIRSTAT_BY_LINE);\n-\t\t\tDIFF_OPT_CLR(options, DIRSTAT_BY_FILE);\n+\t\t\toptions->flags.DIRSTAT_BY_LINE = 0;\n+\t\t\toptions->flags.DIRSTAT_BY_FILE = 0;\n \t\t} else if (!strcmp(p, \"lines\")) {\n \t\t\toptions->flags.DIRSTAT_BY_LINE = 1;\n-\t\t\tDIFF_OPT_CLR(options, DIRSTAT_BY_FILE);\n+\t\t\toptions->flags.DIRSTAT_BY_FILE = 0;\n \t\t} else if (!strcmp(p, \"files\")) {\n-\t\t\tDIFF_OPT_CLR(options, DIRSTAT_BY_LINE);\n+\t\t\toptions->flags.DIRSTAT_BY_LINE = 0;\n \t\t\toptions->flags.DIRSTAT_BY_FILE = 1;\n \t\t} else if (!strcmp(p, \"noncumulative\")) {\n-\t\t\tDIFF_OPT_CLR(options, DIRSTAT_CUMULATIVE);\n+\t\t\toptions->flags.DIRSTAT_CUMULATIVE = 0;\n \t\t} else if (!strcmp(p, \"cumulative\")) {\n \t\t\toptions->flags.DIRSTAT_CUMULATIVE = 1;\n \t\t} else if (isdigit(*p)) {\n@@ -4205,7 +4205,7 @@ void diff_setup_done(struct diff_options *options)\n \t    DIFF_XDL_TST(options, IGNORE_WHITESPACE_AT_EOL))\n \t\toptions->flags.DIFF_FROM_CONTENTS = 1;\n \telse\n-\t\tDIFF_OPT_CLR(options, DIFF_FROM_CONTENTS);\n+\t\toptions->flags.DIFF_FROM_CONTENTS = 0;\n \n \tif (options->flags.FIND_COPIES_HARDER)\n \t\toptions->detect_rename = DIFF_DETECT_COPY;\n@@ -4640,7 +4640,7 @@ int diff_opt_parse(struct diff_options *options,\n \telse if (!strcmp(arg, \"--rename-empty\"))\n \t\toptions->flags.RENAME_EMPTY = 1;\n \telse if (!strcmp(arg, \"--no-rename-empty\"))\n-\t\tDIFF_OPT_CLR(options, RENAME_EMPTY);\n+\t\toptions->flags.RENAME_EMPTY = 0;\n \telse if (!strcmp(arg, \"--relative\"))\n \t\toptions->flags.RELATIVE_NAME = 1;\n \telse if (skip_prefix(arg, \"--relative=\", &arg)) {\n@@ -4697,8 +4697,8 @@ int diff_opt_parse(struct diff_options *options,\n \telse if (!strcmp(arg, \"--follow\"))\n \t\toptions->flags.FOLLOW_RENAMES = 1;\n \telse if (!strcmp(arg, \"--no-follow\")) {\n-\t\tDIFF_OPT_CLR(options, FOLLOW_RENAMES);\n-\t\tDIFF_OPT_CLR(options, DEFAULT_FOLLOW_RENAMES);\n+\t\toptions->flags.FOLLOW_RENAMES = 0;\n+\t\toptions->flags.DEFAULT_FOLLOW_RENAMES = 0;\n \t} else if (!strcmp(arg, \"--color\"))\n \t\toptions->use_color = 1;\n \telse if (skip_prefix(arg, \"--color=\", &arg)) {\n@@ -4761,12 +4761,12 @@ int diff_opt_parse(struct diff_options *options,\n \telse if (!strcmp(arg, \"--ext-diff\"))\n \t\toptions->flags.ALLOW_EXTERNAL = 1;\n \telse if (!strcmp(arg, \"--no-ext-diff\"))\n-\t\tDIFF_OPT_CLR(options, ALLOW_EXTERNAL);\n+\t\toptions->flags.ALLOW_EXTERNAL = 0;\n \telse if (!strcmp(arg, \"--textconv\")) {\n \t\toptions->flags.ALLOW_TEXTCONV = 1;\n \t\toptions->flags.TEXTCONV_SET_VIA_CMDLINE = 1;\n \t} else if (!strcmp(arg, \"--no-textconv\"))\n-\t\tDIFF_OPT_CLR(options, ALLOW_TEXTCONV);\n+\t\toptions->flags.ALLOW_TEXTCONV = 0;\n \telse if (!strcmp(arg, \"--ignore-submodules\")) {\n \t\toptions->flags.OVERRIDE_SUBMODULE_CONFIG = 1;\n \t\thandle_ignore_submodules_arg(options, \"all\");\n@@ -4850,7 +4850,7 @@ int diff_opt_parse(struct diff_options *options,\n \telse if (!strcmp(arg, \"--function-context\"))\n \t\toptions->flags.FUNCCONTEXT = 1;\n \telse if (!strcmp(arg, \"--no-function-context\"))\n-\t\tDIFF_OPT_CLR(options, FUNCCONTEXT);\n+\t\toptions->flags.FUNCCONTEXT = 0;\n \telse if ((argcount = parse_long_opt(\"output\", av, &optarg))) {\n \t\tchar *path = prefix_filename(prefix, optarg);\n \t\toptions->file = xfopen(path, \"w\");\n@@ -5688,7 +5688,7 @@ void diff_flush(struct diff_options *options)\n \t\tif (options->found_changes)\n \t\t\toptions->flags.HAS_CHANGES = 1;\n \t\telse\n-\t\t\tDIFF_OPT_CLR(options, HAS_CHANGES);\n+\t\t\toptions->flags.HAS_CHANGES = 0;\n \t}\n }\n \n@@ -5860,7 +5860,7 @@ void diffcore_std(struct diff_options *options)\n \tif (diff_queued_diff.nr && !options->flags.DIFF_FROM_CONTENTS)\n \t\toptions->flags.HAS_CHANGES = 1;\n \telse\n-\t\tDIFF_OPT_CLR(options, HAS_CHANGES);\n+\t\toptions->flags.HAS_CHANGES = 0;\n \n \toptions->found_follow = 0;\n }\ndiff --git a/diff.h b/diff.h\nindex d53e5a2da..258d735c1 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -106,8 +106,6 @@ static inline void diff_flags_or(struct diff_flags *a,\n \t\ttmp_a[i] |= tmp_b[i];\n }\n \n-#define DIFF_OPT_CLR(opts, flag)\t((opts)->flags.flag = 0)\n-\n #define DIFF_XDL_TST(opts, flag)    ((opts)->xdl_opts & XDF_##flag)\n #define DIFF_XDL_SET(opts, flag)    ((opts)->xdl_opts |= XDF_##flag)\n #define DIFF_XDL_CLR(opts, flag)    ((opts)->xdl_opts &= ~XDF_##flag)\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex e7b3df45c..9752aba4e 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -541,7 +541,7 @@ static struct string_list *get_renames(struct merge_options *o,\n \n \tdiff_setup(&opts);\n \topts.flags.RECURSIVE = 1;\n-\tDIFF_OPT_CLR(&opts, RENAME_EMPTY);\n+\topts.flags.RENAME_EMPTY = 0;\n \topts.detect_rename = DIFF_DETECT_RENAME;\n \topts.rename_limit = o->merge_rename_limit >= 0 ? o->merge_rename_limit :\n \t\t\t    o->diff_rename_limit >= 0 ? o->diff_rename_limit :\ndiff --git a/revision.c b/revision.c\nindex f019dd277..6bb873501 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -455,7 +455,7 @@ static int rev_compare_tree(struct rev_info *revs,\n \t}\n \n \ttree_difference = REV_TREE_SAME;\n-\tDIFF_OPT_CLR(&revs->pruning, HAS_CHANGES);\n+\trevs->pruning.flags.HAS_CHANGES = 0;\n \tif (diff_tree_oid(&t1->object.oid, &t2->object.oid, \"\",\n \t\t\t   &revs->pruning) < 0)\n \t\treturn REV_TREE_DIFFERENT;\n@@ -471,7 +471,7 @@ static int rev_same_tree_as_empty(struct rev_info *revs, struct commit *commit)\n \t\treturn 0;\n \n \ttree_difference = REV_TREE_SAME;\n-\tDIFF_OPT_CLR(&revs->pruning, HAS_CHANGES);\n+\trevs->pruning.flags.HAS_CHANGES = 0;\n \tretval = diff_tree_oid(NULL, &t1->object.oid, \"\", &revs->pruning);\n \n \treturn retval >= 0 && (tree_difference == REV_TREE_SAME);\ndiff --git a/submodule.c b/submodule.c\nindex 7e7998592..62a93bb88 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -402,9 +402,9 @@ const char *submodule_strategy_to_string(const struct submodule_update_strategy\n void handle_ignore_submodules_arg(struct diff_options *diffopt,\n \t\t\t\t  const char *arg)\n {\n-\tDIFF_OPT_CLR(diffopt, IGNORE_SUBMODULES);\n-\tDIFF_OPT_CLR(diffopt, IGNORE_UNTRACKED_IN_SUBMODULES);\n-\tDIFF_OPT_CLR(diffopt, IGNORE_DIRTY_SUBMODULES);\n+\tdiffopt->flags.IGNORE_SUBMODULES = 0;\n+\tdiffopt->flags.IGNORE_UNTRACKED_IN_SUBMODULES = 0;\n+\tdiffopt->flags.IGNORE_DIRTY_SUBMODULES = 0;\n \n \tif (!strcmp(arg, \"all\"))\n \t\tdiffopt->flags.IGNORE_SUBMODULES = 1;\n-- \n2.15.0.403.gc27cc4dac6-goog\n\n"},{"id":"331505","messageId":"20171031181911.42687-9-bmwill@google.com","threadId":"47047","inReplyTo":"20171031181911.42687-1-bmwill@google.com","subject":"[PATCH v3 8/8] diff: make struct diff_flags members lowercase","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-10-31T18:19:11Z","receivedAt":"2017-10-31T18:19:51Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"Now that the flags stored in struct diff_flags are being accessed\ndirectly and not through macros, change all struct members from being\nuppercase to lowercase.\nThis conversion is done using the following semantic patch:\n\n\t@@\n\texpression E;\n\t@@\n\t- E.RECURSIVE\n\t+ E.recursive\n\n\t@@\n\texpression E;\n\t@@\n\t- E.TREE_IN_RECURSIVE\n\t+ E.tree_in_recursive\n\n\t@@\n\texpression E;\n\t@@\n\t- E.BINARY\n\t+ E.binary\n\n\t@@\n\texpression E;\n\t@@\n\t- E.TEXT\n\t+ E.text\n\n\t@@\n\texpression E;\n\t@@\n\t- E.FULL_INDEX\n\t+ E.full_index\n\n\t@@\n\texpression E;\n\t@@\n\t- E.SILENT_ON_REMOVE\n\t+ E.silent_on_remove\n\n\t@@\n\texpression E;\n\t@@\n\t- E.FIND_COPIES_HARDER\n\t+ E.find_copies_harder\n\n\t@@\n\texpression E;\n\t@@\n\t- E.FOLLOW_RENAMES\n\t+ E.follow_renames\n\n\t@@\n\texpression E;\n\t@@\n\t- E.RENAME_EMPTY\n\t+ E.rename_empty\n\n\t@@\n\texpression E;\n\t@@\n\t- E.HAS_CHANGES\n\t+ E.has_changes\n\n\t@@\n\texpression E;\n\t@@\n\t- E.QUICK\n\t+ E.quick\n\n\t@@\n\texpression E;\n\t@@\n\t- E.NO_INDEX\n\t+ E.no_index\n\n\t@@\n\texpression E;\n\t@@\n\t- E.ALLOW_EXTERNAL\n\t+ E.allow_external\n\n\t@@\n\texpression E;\n\t@@\n\t- E.EXIT_WITH_STATUS\n\t+ E.exit_with_status\n\n\t@@\n\texpression E;\n\t@@\n\t- E.REVERSE_DIFF\n\t+ E.reverse_diff\n\n\t@@\n\texpression E;\n\t@@\n\t- E.CHECK_FAILED\n\t+ E.check_failed\n\n\t@@\n\texpression E;\n\t@@\n\t- E.RELATIVE_NAME\n\t+ E.relative_name\n\n\t@@\n\texpression E;\n\t@@\n\t- E.IGNORE_SUBMODULES\n\t+ E.ignore_submodules\n\n\t@@\n\texpression E;\n\t@@\n\t- E.DIRSTAT_CUMULATIVE\n\t+ E.dirstat_cumulative\n\n\t@@\n\texpression E;\n\t@@\n\t- E.DIRSTAT_BY_FILE\n\t+ E.dirstat_by_file\n\n\t@@\n\texpression E;\n\t@@\n\t- E.ALLOW_TEXTCONV\n\t+ E.allow_textconv\n\n\t@@\n\texpression E;\n\t@@\n\t- E.TEXTCONV_SET_VIA_CMDLINE\n\t+ E.textconv_set_via_cmdline\n\n\t@@\n\texpression E;\n\t@@\n\t- E.DIFF_FROM_CONTENTS\n\t+ E.diff_from_contents\n\n\t@@\n\texpression E;\n\t@@\n\t- E.DIRTY_SUBMODULES\n\t+ E.dirty_submodules\n\n\t@@\n\texpression E;\n\t@@\n\t- E.IGNORE_UNTRACKED_IN_SUBMODULES\n\t+ E.ignore_untracked_in_submodules\n\n\t@@\n\texpression E;\n\t@@\n\t- E.IGNORE_DIRTY_SUBMODULES\n\t+ E.ignore_dirty_submodules\n\n\t@@\n\texpression E;\n\t@@\n\t- E.OVERRIDE_SUBMODULE_CONFIG\n\t+ E.override_submodule_config\n\n\t@@\n\texpression E;\n\t@@\n\t- E.DIRSTAT_BY_LINE\n\t+ E.dirstat_by_line\n\n\t@@\n\texpression E;\n\t@@\n\t- E.FUNCCONTEXT\n\t+ E.funccontext\n\n\t@@\n\texpression E;\n\t@@\n\t- E.PICKAXE_IGNORE_CASE\n\t+ E.pickaxe_ignore_case\n\n\t@@\n\texpression E;\n\t@@\n\t- E.DEFAULT_FOLLOW_RENAMES\n\t+ E.default_follow_renames\n\nSigned-off-by: Brandon Williams <bmwill@google.com>\n---\n blame.c               |  16 ++---\n builtin/add.c         |   4 +-\n builtin/am.c          |  10 +--\n builtin/blame.c       |  10 +--\n builtin/commit.c      |   4 +-\n builtin/diff.c        |   8 +--\n builtin/fast-export.c |   2 +-\n builtin/log.c         |  26 ++++----\n builtin/reset.c       |   2 +-\n builtin/rev-list.c    |   2 +-\n combine-diff.c        |  10 +--\n diff-lib.c            |  22 +++----\n diff-no-index.c       |   8 +--\n diff.c                | 170 +++++++++++++++++++++++++-------------------------\n diff.h                |  62 +++++++++---------\n diffcore-pickaxe.c    |   8 +--\n diffcore-rename.c     |   6 +-\n log-tree.c            |   2 +-\n merge-recursive.c     |   4 +-\n notes-merge.c         |   4 +-\n patch-ids.c           |   2 +-\n revision.c            |  24 +++----\n submodule.c           |  16 ++---\n tree-diff.c           |  16 ++---\n wt-status.c           |  18 +++---\n 25 files changed, 228 insertions(+), 228 deletions(-)\n\ndiff --git a/blame.c b/blame.c\nindex dc9cc237b..28e03726f 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -209,7 +209,7 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,\n \n \t\tswitch (st.st_mode & S_IFMT) {\n \t\tcase S_IFREG:\n-\t\t\tif (opt->flags.ALLOW_TEXTCONV &&\n+\t\t\tif (opt->flags.allow_textconv &&\n \t\t\t    textconv_object(read_from, mode, &null_oid, 0, &buf_ptr, &buf_len))\n \t\t\t\tstrbuf_attach(&buf, buf_ptr, buf_len, buf_len + 1);\n \t\t\telse if (strbuf_read_file(&buf, read_from, st.st_size) != st.st_size)\n@@ -293,7 +293,7 @@ static void fill_origin_blob(struct diff_options *opt,\n \t\tunsigned long file_size;\n \n \t\t(*num_read_blob)++;\n-\t\tif (opt->flags.ALLOW_TEXTCONV &&\n+\t\tif (opt->flags.allow_textconv &&\n \t\t    textconv_object(o->path, o->mode, &o->blob_oid, 1, &file->ptr, &file_size))\n \t\t\t;\n \t\telse\n@@ -541,7 +541,7 @@ static struct blame_origin *find_origin(struct commit *parent,\n \t * same and diff-tree is fairly efficient about this.\n \t */\n \tdiff_setup(&diff_opts);\n-\tdiff_opts.flags.RECURSIVE = 1;\n+\tdiff_opts.flags.recursive = 1;\n \tdiff_opts.detect_rename = 0;\n \tdiff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;\n \tpaths[0] = origin->path;\n@@ -615,7 +615,7 @@ static struct blame_origin *find_rename(struct commit *parent,\n \tint i;\n \n \tdiff_setup(&diff_opts);\n-\tdiff_opts.flags.RECURSIVE = 1;\n+\tdiff_opts.flags.recursive = 1;\n \tdiff_opts.detect_rename = DIFF_DETECT_RENAME;\n \tdiff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;\n \tdiff_opts.single_follow = origin->path;\n@@ -1238,7 +1238,7 @@ static void find_copy_in_parent(struct blame_scoreboard *sb,\n \t\treturn; /* nothing remains for this target */\n \n \tdiff_setup(&diff_opts);\n-\tdiff_opts.flags.RECURSIVE = 1;\n+\tdiff_opts.flags.recursive = 1;\n \tdiff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;\n \n \tdiff_setup_done(&diff_opts);\n@@ -1253,7 +1253,7 @@ static void find_copy_in_parent(struct blame_scoreboard *sb,\n \tif ((opt & PICKAXE_BLAME_COPY_HARDEST)\n \t    || ((opt & PICKAXE_BLAME_COPY_HARDER)\n \t\t&& (!porigin || strcmp(target->path, porigin->path))))\n-\t\tdiff_opts.flags.FIND_COPIES_HARDER = 1;\n+\t\tdiff_opts.flags.find_copies_harder = 1;\n \n \tif (is_null_oid(&target->commit->object.oid))\n \t\tdo_diff_cache(&parent->tree->object.oid, &diff_opts);\n@@ -1262,7 +1262,7 @@ static void find_copy_in_parent(struct blame_scoreboard *sb,\n \t\t\t      &target->commit->tree->object.oid,\n \t\t\t      \"\", &diff_opts);\n \n-\tif (!diff_opts.flags.FIND_COPIES_HARDER)\n+\tif (!diff_opts.flags.find_copies_harder)\n \t\tdiffcore_std(&diff_opts);\n \n \tdo {\n@@ -1825,7 +1825,7 @@ void setup_scoreboard(struct blame_scoreboard *sb, const char *path, struct blam\n \t\tif (fill_blob_sha1_and_mode(o))\n \t\t\tdie(_(\"no such path %s in %s\"), path, final_commit_name);\n \n-\t\tif (sb->revs->diffopt.flags.ALLOW_TEXTCONV &&\n+\t\tif (sb->revs->diffopt.flags.allow_textconv &&\n \t\t    textconv_object(path, o->mode, &o->blob_oid, 1, (char **) &sb->final_buf,\n \t\t\t\t    &sb->final_buf_size))\n \t\t\t;\ndiff --git a/builtin/add.c b/builtin/add.c\nindex e1d83b69a..8d08e99e9 100644\n--- a/builtin/add.c\n+++ b/builtin/add.c\n@@ -116,7 +116,7 @@ int add_files_to_cache(const char *prefix,\n \trev.diffopt.output_format = DIFF_FORMAT_CALLBACK;\n \trev.diffopt.format_callback = update_callback;\n \trev.diffopt.format_callback_data = &data;\n-\trev.diffopt.flags.OVERRIDE_SUBMODULE_CONFIG = 1;\n+\trev.diffopt.flags.override_submodule_config = 1;\n \trev.max_count = 0; /* do not compare unmerged paths with stage #2 */\n \trun_diff_files(&rev, DIFF_RACY_IS_MODIFIED);\n \tclear_pathspec(&rev.prune_data);\n@@ -218,7 +218,7 @@ static int edit_patch(int argc, const char **argv, const char *prefix)\n \targc = setup_revisions(argc, argv, &rev, NULL);\n \trev.diffopt.output_format = DIFF_FORMAT_PATCH;\n \trev.diffopt.use_color = 0;\n-\trev.diffopt.flags.IGNORE_DIRTY_SUBMODULES = 1;\n+\trev.diffopt.flags.ignore_dirty_submodules = 1;\n \tout = open(file, O_CREAT | O_WRONLY, 0666);\n \tif (out < 0)\n \t\tdie(_(\"Could not open '%s' for writing.\"), file);\ndiff --git a/builtin/am.c b/builtin/am.c\nindex 015425a0f..b281d58f3 100644\n--- a/builtin/am.c\n+++ b/builtin/am.c\n@@ -1157,9 +1157,9 @@ static int index_has_changes(struct strbuf *sb)\n \t\tstruct diff_options opt;\n \n \t\tdiff_setup(&opt);\n-\t\topt.flags.EXIT_WITH_STATUS = 1;\n+\t\topt.flags.exit_with_status = 1;\n \t\tif (!sb)\n-\t\t\topt.flags.QUICK = 1;\n+\t\t\topt.flags.quick = 1;\n \t\tdo_diff_cache(&head, &opt);\n \t\tdiffcore_std(&opt);\n \t\tfor (i = 0; sb && i < diff_queued_diff.nr; i++) {\n@@ -1168,7 +1168,7 @@ static int index_has_changes(struct strbuf *sb)\n \t\t\tstrbuf_addstr(sb, diff_queued_diff.queue[i]->two->path);\n \t\t}\n \t\tdiff_flush(&opt);\n-\t\treturn opt.flags.HAS_CHANGES != 0;\n+\t\treturn opt.flags.has_changes != 0;\n \t} else {\n \t\tfor (i = 0; sb && i < active_nr; i++) {\n \t\t\tif (i)\n@@ -1409,8 +1409,8 @@ static void write_commit_patch(const struct am_state *state, struct commit *comm\n \trev_info.show_root_diff = 1;\n \trev_info.diffopt.output_format = DIFF_FORMAT_PATCH;\n \trev_info.no_commit_id = 1;\n-\trev_info.diffopt.flags.BINARY = 1;\n-\trev_info.diffopt.flags.FULL_INDEX = 1;\n+\trev_info.diffopt.flags.binary = 1;\n+\trev_info.diffopt.flags.full_index = 1;\n \trev_info.diffopt.use_color = 0;\n \trev_info.diffopt.file = fp;\n \trev_info.diffopt.close_file = 1;\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex 79db9e849..005f55aaa 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -708,8 +708,8 @@ int cmd_blame(int argc, const char **argv, const char *prefix)\n \tgit_config(git_blame_config, &output_option);\n \tinit_revisions(&revs, NULL);\n \trevs.date_mode = blame_date_mode;\n-\trevs.diffopt.flags.ALLOW_TEXTCONV = 1;\n-\trevs.diffopt.flags.FOLLOW_RENAMES = 1;\n+\trevs.diffopt.flags.allow_textconv = 1;\n+\trevs.diffopt.flags.follow_renames = 1;\n \n \tsave_commit_buffer = 0;\n \tdashdash_pos = 0;\n@@ -734,9 +734,9 @@ int cmd_blame(int argc, const char **argv, const char *prefix)\n \t\tparse_revision_opt(&revs, &ctx, options, blame_opt_usage);\n \t}\n parse_done:\n-\tno_whole_file_rename = !revs.diffopt.flags.FOLLOW_RENAMES;\n+\tno_whole_file_rename = !revs.diffopt.flags.follow_renames;\n \txdl_opts |= revs.diffopt.xdl_opts & XDF_INDENT_HEURISTIC;\n-\trevs.diffopt.flags.FOLLOW_RENAMES = 0;\n+\trevs.diffopt.flags.follow_renames = 0;\n \targc = parse_options_end(&ctx);\n \n \tif (incremental || (output_option & OUTPUT_PORCELAIN)) {\n@@ -803,7 +803,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)\n \t}\n \tblame_date_width -= 1; /* strip the null */\n \n-\tif (revs.diffopt.flags.FIND_COPIES_HARDER)\n+\tif (revs.diffopt.flags.find_copies_harder)\n \t\topt |= (PICKAXE_BLAME_COPY | PICKAXE_BLAME_MOVE |\n \t\t\tPICKAXE_BLAME_COPY_HARDER);\n \ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 960e7ac08..0f368ad81 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -913,10 +913,10 @@ static int prepare_to_commit(const char *index_file, const char *prefix,\n \t\t\t * be really confusing.\n \t\t\t */\n \t\t\tstruct diff_flags flags = DIFF_FLAGS_INIT;\n-\t\t\tflags.OVERRIDE_SUBMODULE_CONFIG = 1;\n+\t\t\tflags.override_submodule_config = 1;\n \t\t\tif (ignore_submodule_arg &&\n \t\t\t    !strcmp(ignore_submodule_arg, \"all\"))\n-\t\t\t\tflags.IGNORE_SUBMODULES = 1;\n+\t\t\t\tflags.ignore_submodules = 1;\n \t\t\tcommitable = index_differs_from(parent, &flags, 1);\n \t\t}\n \t}\ndiff --git a/builtin/diff.c b/builtin/diff.c\nindex ed41eb5a5..3476e95e1 100644\n--- a/builtin/diff.c\n+++ b/builtin/diff.c\n@@ -44,7 +44,7 @@ static void stuff_change(struct diff_options *opt,\n \t    !oidcmp(old_oid, new_oid) && (old_mode == new_mode))\n \t\treturn;\n \n-\tif (opt->flags.REVERSE_DIFF) {\n+\tif (opt->flags.reverse_diff) {\n \t\tSWAP(old_mode, new_mode);\n \t\tSWAP(old_oid, new_oid);\n \t\tSWAP(old_path, new_path);\n@@ -350,8 +350,8 @@ int cmd_diff(int argc, const char **argv, const char *prefix)\n \trev.diffopt.stat_graph_width = -1;\n \n \t/* Default to let external and textconv be used */\n-\trev.diffopt.flags.ALLOW_EXTERNAL = 1;\n-\trev.diffopt.flags.ALLOW_TEXTCONV = 1;\n+\trev.diffopt.flags.allow_external = 1;\n+\trev.diffopt.flags.allow_textconv = 1;\n \n \tif (nongit)\n \t\tdie(_(\"Not a git repository\"));\n@@ -361,7 +361,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)\n \t\tdiff_setup_done(&rev.diffopt);\n \t}\n \n-\trev.diffopt.flags.RECURSIVE = 1;\n+\trev.diffopt.flags.recursive = 1;\n \n \tsetup_diff_pager(&rev.diffopt);\n \ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex 35c8fb65d..72672665b 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -1066,7 +1066,7 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)\n \t\tdie(\"revision walk setup failed\");\n \trevs.diffopt.format_callback = show_filemodify;\n \trevs.diffopt.format_callback_data = &paths_of_changed_objects;\n-\trevs.diffopt.flags.RECURSIVE = 1;\n+\trevs.diffopt.flags.recursive = 1;\n \twhile ((commit = get_revision(&revs))) {\n \t\tif (has_unshown_parent(commit)) {\n \t\t\tadd_object_array(&commit->object, NULL, &commits);\ndiff --git a/builtin/log.c b/builtin/log.c\nindex 4a24d3e48..f3d5a02be 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -121,16 +121,16 @@ static void cmd_log_init_defaults(struct rev_info *rev)\n \tif (fmt_pretty)\n \t\tget_commit_format(fmt_pretty, rev);\n \tif (default_follow)\n-\t\trev->diffopt.flags.DEFAULT_FOLLOW_RENAMES = 1;\n+\t\trev->diffopt.flags.default_follow_renames = 1;\n \trev->verbose_header = 1;\n-\trev->diffopt.flags.RECURSIVE = 1;\n+\trev->diffopt.flags.recursive = 1;\n \trev->diffopt.stat_width = -1; /* use full terminal width */\n \trev->diffopt.stat_graph_width = -1; /* respect statGraphWidth config */\n \trev->abbrev_commit = default_abbrev_commit;\n \trev->show_root_diff = default_show_root;\n \trev->subject_prefix = fmt_patch_subject_prefix;\n \trev->show_signature = default_show_signature;\n-\trev->diffopt.flags.ALLOW_TEXTCONV = 1;\n+\trev->diffopt.flags.allow_textconv = 1;\n \n \tif (default_date_mode)\n \t\tparse_date_format(default_date_mode, &rev->date_mode);\n@@ -181,7 +181,7 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,\n \t\tinit_display_notes(&rev->notes_opt);\n \n \tif (rev->diffopt.pickaxe || rev->diffopt.filter ||\n-\t    rev->diffopt.flags.FOLLOW_RENAMES)\n+\t    rev->diffopt.flags.follow_renames)\n \t\trev->always_show_header = 0;\n \n \tif (source)\n@@ -391,7 +391,7 @@ static int cmd_log_walk(struct rev_info *rev)\n \t\tfclose(rev->diffopt.file);\n \n \tif (rev->diffopt.output_format & DIFF_FORMAT_CHECKDIFF &&\n-\t    rev->diffopt.flags.CHECK_FAILED) {\n+\t    rev->diffopt.flags.check_failed) {\n \t\treturn 02;\n \t}\n \treturn diff_result_code(&rev->diffopt, 0);\n@@ -483,8 +483,8 @@ static int show_blob_object(const struct object_id *oid, struct rev_info *rev, c\n \tunsigned long size;\n \n \tfflush(rev->diffopt.file);\n-\tif (!rev->diffopt.flags.TEXTCONV_SET_VIA_CMDLINE ||\n-\t    !rev->diffopt.flags.ALLOW_TEXTCONV)\n+\tif (!rev->diffopt.flags.textconv_set_via_cmdline ||\n+\t    !rev->diffopt.flags.allow_textconv)\n \t\treturn stream_blob_to_fd(1, oid, NULL, 0);\n \n \tif (get_oid_with_context(obj_name, GET_OID_RECORD_PATH,\n@@ -666,9 +666,9 @@ int cmd_log_reflog(int argc, const char **argv, const char *prefix)\n static void log_setup_revisions_tweak(struct rev_info *rev,\n \t\t\t\t      struct setup_revision_opt *opt)\n {\n-\tif (rev->diffopt.flags.DEFAULT_FOLLOW_RENAMES &&\n+\tif (rev->diffopt.flags.default_follow_renames &&\n \t    rev->prune_data.nr == 1)\n-\t\trev->diffopt.flags.FOLLOW_RENAMES = 1;\n+\t\trev->diffopt.flags.follow_renames = 1;\n \n \t/* Turn --cc/-c into -p --cc/-c when -p was not given */\n \tif (!rev->diffopt.output_format && rev->combine_merges)\n@@ -1340,7 +1340,7 @@ static void prepare_bases(struct base_tree_info *bases,\n \t\treturn;\n \n \tdiff_setup(&diffopt);\n-\tdiffopt.flags.RECURSIVE = 1;\n+\tdiffopt.flags.recursive = 1;\n \tdiff_setup_done(&diffopt);\n \n \toidcpy(&bases->base_commit, &base->object.oid);\n@@ -1511,7 +1511,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \trev.verbose_header = 1;\n \trev.diff = 1;\n \trev.max_parents = 1;\n-\trev.diffopt.flags.RECURSIVE = 1;\n+\trev.diffopt.flags.recursive = 1;\n \trev.subject_prefix = fmt_patch_subject_prefix;\n \tmemset(&s_r_opt, 0, sizeof(s_r_opt));\n \ts_r_opt.def = \"HEAD\";\n@@ -1612,8 +1612,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \n \trev.zero_commit = zero_commit;\n \n-\tif (!rev.diffopt.flags.TEXT && !no_binary_diff)\n-\t\trev.diffopt.flags.BINARY = 1;\n+\tif (!rev.diffopt.flags.text && !no_binary_diff)\n+\t\trev.diffopt.flags.binary = 1;\n \n \tif (rev.show_notes)\n \t\tinit_display_notes(&rev.notes_opt);\ndiff --git a/builtin/reset.c b/builtin/reset.c\nindex 206819ef1..4b313a018 100644\n--- a/builtin/reset.c\n+++ b/builtin/reset.c\n@@ -166,7 +166,7 @@ static int read_from_tree(const struct pathspec *pathspec,\n \topt.output_format = DIFF_FORMAT_CALLBACK;\n \topt.format_callback = update_index_from_diff;\n \topt.format_callback_data = &intent_to_add;\n-\topt.flags.OVERRIDE_SUBMODULE_CONFIG = 1;\n+\topt.flags.override_submodule_config = 1;\n \n \tif (do_diff_cache(tree_oid, &opt))\n \t\treturn 1;\ndiff --git a/builtin/rev-list.c b/builtin/rev-list.c\nindex c62382171..1d3b6b61b 100644\n--- a/builtin/rev-list.c\n+++ b/builtin/rev-list.c\n@@ -294,7 +294,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)\n \tif (revs.bisect)\n \t\tbisect_list = 1;\n \n-\tif (revs.diffopt.flags.QUICK)\n+\tif (revs.diffopt.flags.quick)\n \t\tinfo.flags |= REV_LIST_QUIET;\n \tfor (i = 1 ; i < argc; i++) {\n \t\tconst char *arg = argv[i];\ndiff --git a/combine-diff.c b/combine-diff.c\nindex 5a3a8b49b..23f3d25e2 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -898,7 +898,7 @@ static void show_combined_header(struct combine_diff_path *elem,\n \t\t\t\t int show_file_header)\n {\n \tstruct diff_options *opt = &rev->diffopt;\n-\tint abbrev = opt->flags.FULL_INDEX ? GIT_SHA1_HEXSZ : DEFAULT_ABBREV;\n+\tint abbrev = opt->flags.full_index ? GIT_SHA1_HEXSZ : DEFAULT_ABBREV;\n \tconst char *a_prefix = opt->a_prefix ? opt->a_prefix : \"a/\";\n \tconst char *b_prefix = opt->b_prefix ? opt->b_prefix : \"b/\";\n \tconst char *c_meta = diff_get_color_opt(opt, DIFF_METAINFO);\n@@ -987,7 +987,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,\n \tuserdiff = userdiff_find_by_path(elem->path);\n \tif (!userdiff)\n \t\tuserdiff = userdiff_find_by_name(\"default\");\n-\tif (opt->flags.ALLOW_TEXTCONV)\n+\tif (opt->flags.allow_textconv)\n \t\ttextconv = userdiff_get_textconv(userdiff);\n \n \t/* Read the result of merge first */\n@@ -1413,8 +1413,8 @@ void diff_tree_combined(const struct object_id *oid,\n \n \tdiffopts = *opt;\n \tcopy_pathspec(&diffopts.pathspec, &opt->pathspec);\n-\tdiffopts.flags.RECURSIVE = 1;\n-\tdiffopts.flags.ALLOW_EXTERNAL = 0;\n+\tdiffopts.flags.recursive = 1;\n+\tdiffopts.flags.allow_external = 0;\n \n \t/* find set of paths that everybody touches\n \t *\n@@ -1435,7 +1435,7 @@ void diff_tree_combined(const struct object_id *oid,\n \t * NOTE please keep this semantically in sync with diffcore_std()\n \t */\n \tneed_generic_pathscan = opt->skip_stat_unmatch\t||\n-\t\t\topt->flags.FOLLOW_RENAMES\t||\n+\t\t\topt->flags.follow_renames\t||\n \t\t\topt->break_opt != -1\t||\n \t\t\topt->detect_rename\t||\n \t\t\topt->pickaxe\t\t||\ndiff --git a/diff-lib.c b/diff-lib.c\nindex f1cc3fd51..d373358a5 100644\n--- a/diff-lib.c\n+++ b/diff-lib.c\n@@ -72,14 +72,14 @@ static int match_stat_with_submodule(struct diff_options *diffopt,\n \tint changed = ce_match_stat(ce, st, ce_option);\n \tif (S_ISGITLINK(ce->ce_mode)) {\n \t\tstruct diff_flags orig_flags = diffopt->flags;\n-\t\tif (!diffopt->flags.OVERRIDE_SUBMODULE_CONFIG)\n+\t\tif (!diffopt->flags.override_submodule_config)\n \t\t\tset_diffopt_flags_from_submodule_config(diffopt, ce->name);\n-\t\tif (diffopt->flags.IGNORE_SUBMODULES)\n+\t\tif (diffopt->flags.ignore_submodules)\n \t\t\tchanged = 0;\n-\t\telse if (!diffopt->flags.IGNORE_DIRTY_SUBMODULES &&\n-\t\t\t (!changed || diffopt->flags.DIRTY_SUBMODULES))\n+\t\telse if (!diffopt->flags.ignore_dirty_submodules &&\n+\t\t\t (!changed || diffopt->flags.dirty_submodules))\n \t\t\t*dirty_submodule = is_submodule_modified(ce->name,\n-\t\t\t\t\t\t\t\t diffopt->flags.IGNORE_UNTRACKED_IN_SUBMODULES);\n+\t\t\t\t\t\t\t\t diffopt->flags.ignore_untracked_in_submodules);\n \t\tdiffopt->flags = orig_flags;\n \t}\n \treturn changed;\n@@ -229,7 +229,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)\n \n \t\tif (!changed && !dirty_submodule) {\n \t\t\tce_mark_uptodate(ce);\n-\t\t\tif (!revs->diffopt.flags.FIND_COPIES_HARDER)\n+\t\t\tif (!revs->diffopt.flags.find_copies_harder)\n \t\t\t\tcontinue;\n \t\t}\n \t\toldmode = ce->ce_mode;\n@@ -363,7 +363,7 @@ static int show_modified(struct rev_info *revs,\n \n \toldmode = old->ce_mode;\n \tif (mode == oldmode && !oidcmp(oid, &old->oid) && !dirty_submodule &&\n-\t    !revs->diffopt.flags.FIND_COPIES_HARDER)\n+\t    !revs->diffopt.flags.find_copies_harder)\n \t\treturn 0;\n \n \tdiff_change(&revs->diffopt, oldmode, mode,\n@@ -494,7 +494,7 @@ static int diff_cache(struct rev_info *revs,\n \topts.head_idx = 1;\n \topts.index_only = cached;\n \topts.diff_index_cached = (cached &&\n-\t\t\t\t  !revs->diffopt.flags.FIND_COPIES_HARDER);\n+\t\t\t\t  !revs->diffopt.flags.find_copies_harder);\n \topts.merge = 1;\n \topts.fn = oneway_diff;\n \topts.unpack_data = revs;\n@@ -545,12 +545,12 @@ int index_differs_from(const char *def, const struct diff_flags *flags,\n \tmemset(&opt, 0, sizeof(opt));\n \topt.def = def;\n \tsetup_revisions(0, NULL, &rev, &opt);\n-\trev.diffopt.flags.QUICK = 1;\n-\trev.diffopt.flags.EXIT_WITH_STATUS = 1;\n+\trev.diffopt.flags.quick = 1;\n+\trev.diffopt.flags.exit_with_status = 1;\n \tif (flags)\n \t\tdiff_flags_or(&rev.diffopt.flags, flags);\n \trev.diffopt.ita_invisible_in_index = ita_invisible_in_index;\n \trun_diff_index(&rev, 1);\n \tobject_array_clear(&rev.pending);\n-\treturn (rev.diffopt.flags.HAS_CHANGES != 0);\n+\treturn (rev.diffopt.flags.has_changes != 0);\n }\ndiff --git a/diff-no-index.c b/diff-no-index.c\nindex a3e194340..0ed5f0f49 100644\n--- a/diff-no-index.c\n+++ b/diff-no-index.c\n@@ -184,7 +184,7 @@ static int queue_diff(struct diff_options *o,\n \t} else {\n \t\tstruct diff_filespec *d1, *d2;\n \n-\t\tif (o->flags.REVERSE_DIFF) {\n+\t\tif (o->flags.reverse_diff) {\n \t\t\tSWAP(mode1, mode2);\n \t\t\tSWAP(name1, name2);\n \t\t}\n@@ -276,16 +276,16 @@ void diff_no_index(struct rev_info *revs,\n \tif (!revs->diffopt.output_format)\n \t\trevs->diffopt.output_format = DIFF_FORMAT_PATCH;\n \n-\trevs->diffopt.flags.NO_INDEX = 1;\n+\trevs->diffopt.flags.no_index = 1;\n \n-\trevs->diffopt.flags.RELATIVE_NAME = 1;\n+\trevs->diffopt.flags.relative_name = 1;\n \trevs->diffopt.prefix = prefix;\n \n \trevs->max_count = -2;\n \tdiff_setup_done(&revs->diffopt);\n \n \tsetup_diff_pager(&revs->diffopt);\n-\trevs->diffopt.flags.EXIT_WITH_STATUS = 1;\n+\trevs->diffopt.flags.exit_with_status = 1;\n \n \tif (queue_diff(&revs->diffopt, paths[0], paths[1]))\n \t\texit(1);\ndiff --git a/diff.c b/diff.c\nindex e5f9d3078..5714382d3 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -124,18 +124,18 @@ static int parse_dirstat_params(struct diff_options *options, const char *params\n \tfor (i = 0; i < params.nr; i++) {\n \t\tconst char *p = params.items[i].string;\n \t\tif (!strcmp(p, \"changes\")) {\n-\t\t\toptions->flags.DIRSTAT_BY_LINE = 0;\n-\t\t\toptions->flags.DIRSTAT_BY_FILE = 0;\n+\t\t\toptions->flags.dirstat_by_line = 0;\n+\t\t\toptions->flags.dirstat_by_file = 0;\n \t\t} else if (!strcmp(p, \"lines\")) {\n-\t\t\toptions->flags.DIRSTAT_BY_LINE = 1;\n-\t\t\toptions->flags.DIRSTAT_BY_FILE = 0;\n+\t\t\toptions->flags.dirstat_by_line = 1;\n+\t\t\toptions->flags.dirstat_by_file = 0;\n \t\t} else if (!strcmp(p, \"files\")) {\n-\t\t\toptions->flags.DIRSTAT_BY_LINE = 0;\n-\t\t\toptions->flags.DIRSTAT_BY_FILE = 1;\n+\t\t\toptions->flags.dirstat_by_line = 0;\n+\t\t\toptions->flags.dirstat_by_file = 1;\n \t\t} else if (!strcmp(p, \"noncumulative\")) {\n-\t\t\toptions->flags.DIRSTAT_CUMULATIVE = 0;\n+\t\t\toptions->flags.dirstat_cumulative = 0;\n \t\t} else if (!strcmp(p, \"cumulative\")) {\n-\t\t\toptions->flags.DIRSTAT_CUMULATIVE = 1;\n+\t\t\toptions->flags.dirstat_cumulative = 1;\n \t\t} else if (isdigit(*p)) {\n \t\t\tchar *end;\n \t\t\tint permille = strtoul(p, &end, 10) * 10;\n@@ -1481,7 +1481,7 @@ static void emit_rewrite_diff(const char *name_a,\n \tstruct emit_callback ecbdata;\n \tstruct strbuf out = STRBUF_INIT;\n \n-\tif (diff_mnemonic_prefix && o->flags.REVERSE_DIFF) {\n+\tif (diff_mnemonic_prefix && o->flags.reverse_diff) {\n \t\ta_prefix = o->b_prefix;\n \t\tb_prefix = o->a_prefix;\n \t} else {\n@@ -2729,7 +2729,7 @@ static void show_dirstat(struct diff_options *options)\n \tdir.alloc = 0;\n \tdir.nr = 0;\n \tdir.permille = options->dirstat_permille;\n-\tdir.cumulative = options->flags.DIRSTAT_CUMULATIVE;\n+\tdir.cumulative = options->flags.dirstat_cumulative;\n \n \tchanged = 0;\n \tfor (i = 0; i < q->nr; i++) {\n@@ -2755,7 +2755,7 @@ static void show_dirstat(struct diff_options *options)\n \t\t\tgoto found_damage;\n \t\t}\n \n-\t\tif (options->flags.DIRSTAT_BY_FILE) {\n+\t\tif (options->flags.dirstat_by_file) {\n \t\t\t/*\n \t\t\t * In --dirstat-by-file mode, we don't really need to\n \t\t\t * look at the actual file contents at all.\n@@ -2830,7 +2830,7 @@ static void show_dirstat_by_line(struct diffstat_t *data, struct diff_options *o\n \tdir.alloc = 0;\n \tdir.nr = 0;\n \tdir.permille = options->dirstat_permille;\n-\tdir.cumulative = options->flags.DIRSTAT_CUMULATIVE;\n+\tdir.cumulative = options->flags.dirstat_cumulative;\n \n \tchanged = 0;\n \tfor (i = 0; i < data->nr; i++) {\n@@ -3117,7 +3117,7 @@ static void builtin_diff(const char *name_a,\n \tconst char *line_prefix = diff_line_prefix(o);\n \n \tdiff_set_mnemonic_prefix(o, \"a/\", \"b/\");\n-\tif (o->flags.REVERSE_DIFF) {\n+\tif (o->flags.reverse_diff) {\n \t\ta_prefix = o->b_prefix;\n \t\tb_prefix = o->a_prefix;\n \t} else {\n@@ -3141,7 +3141,7 @@ static void builtin_diff(const char *name_a,\n \t\treturn;\n \t}\n \n-\tif (o->flags.ALLOW_TEXTCONV) {\n+\tif (o->flags.allow_textconv) {\n \t\ttextconv_one = get_textconv(one);\n \t\ttextconv_two = get_textconv(two);\n \t}\n@@ -3201,13 +3201,13 @@ static void builtin_diff(const char *name_a,\n \t\t\t\t header.len, 0);\n \t\tstrbuf_reset(&header);\n \t\tgoto free_ab_and_return;\n-\t} else if (!o->flags.TEXT &&\n+\t} else if (!o->flags.text &&\n \t    ( (!textconv_one && diff_filespec_is_binary(one)) ||\n \t      (!textconv_two && diff_filespec_is_binary(two)) )) {\n \t\tstruct strbuf sb = STRBUF_INIT;\n \t\tif (!one->data && !two->data &&\n \t\t    S_ISREG(one->mode) && S_ISREG(two->mode) &&\n-\t\t    !o->flags.BINARY) {\n+\t\t    !o->flags.binary) {\n \t\t\tif (!oidcmp(&one->oid, &two->oid)) {\n \t\t\t\tif (must_show_header)\n \t\t\t\t\temit_diff_symbol(o, DIFF_SYMBOL_HEADER,\n@@ -3236,7 +3236,7 @@ static void builtin_diff(const char *name_a,\n \t\t}\n \t\temit_diff_symbol(o, DIFF_SYMBOL_HEADER, header.buf, header.len, 0);\n \t\tstrbuf_reset(&header);\n-\t\tif (o->flags.BINARY)\n+\t\tif (o->flags.binary)\n \t\t\temit_binary_diff(o, &mf1, &mf2);\n \t\telse {\n \t\t\tstrbuf_addf(&sb, \"%sBinary files %s and %s differ\\n\",\n@@ -3282,7 +3282,7 @@ static void builtin_diff(const char *name_a,\n \t\txecfg.ctxlen = o->context;\n \t\txecfg.interhunkctxlen = o->interhunkcontext;\n \t\txecfg.flags = XDL_EMIT_FUNCNAMES;\n-\t\tif (o->flags.FUNCCONTEXT)\n+\t\tif (o->flags.funccontext)\n \t\t\txecfg.flags |= XDL_EMIT_FUNCCONTEXT;\n \t\tif (pe)\n \t\t\txdiff_set_find_func(&xecfg, pe->pattern, pe->cflags);\n@@ -3447,7 +3447,7 @@ static void builtin_checkdiff(const char *name_a, const char *name_b,\n \tdiff_free_filespec_data(one);\n \tdiff_free_filespec_data(two);\n \tif (data.status)\n-\t\to->flags.CHECK_FAILED = 1;\n+\t\to->flags.check_failed = 1;\n }\n \n struct diff_filespec *alloc_filespec(const char *path)\n@@ -3941,9 +3941,9 @@ static void fill_metainfo(struct strbuf *msg,\n \t\t*must_show_header = 0;\n \t}\n \tif (one && two && oidcmp(&one->oid, &two->oid)) {\n-\t\tint abbrev = o->flags.FULL_INDEX ? 40 : DEFAULT_ABBREV;\n+\t\tint abbrev = o->flags.full_index ? 40 : DEFAULT_ABBREV;\n \n-\t\tif (o->flags.BINARY) {\n+\t\tif (o->flags.binary) {\n \t\t\tmmfile_t mf;\n \t\t\tif ((!fill_mmfile(&mf, one) && diff_filespec_is_binary(one)) ||\n \t\t\t    (!fill_mmfile(&mf, two) && diff_filespec_is_binary(two)))\n@@ -3973,7 +3973,7 @@ static void run_diff_cmd(const char *pgm,\n \tint must_show_header = 0;\n \n \n-\tif (o->flags.ALLOW_EXTERNAL) {\n+\tif (o->flags.allow_external) {\n \t\tstruct userdiff_driver *drv = userdiff_find_by_path(attr_path);\n \t\tif (drv && drv->external)\n \t\t\tpgm = drv->external;\n@@ -4053,7 +4053,7 @@ static void run_diff(struct diff_filepair *p, struct diff_options *o)\n \tif (o->prefix_length)\n \t\tstrip_prefix(o->prefix_length, &name, &other);\n \n-\tif (!o->flags.ALLOW_EXTERNAL)\n+\tif (!o->flags.allow_external)\n \t\tpgm = NULL;\n \n \tif (DIFF_PAIR_UNMERGED(p)) {\n@@ -4152,7 +4152,7 @@ void diff_setup(struct diff_options *options)\n \toptions->context = diff_context_default;\n \toptions->interhunkcontext = diff_interhunk_context_default;\n \toptions->ws_error_highlight = ws_error_highlight_default;\n-\toptions->flags.RENAME_EMPTY = 1;\n+\toptions->flags.rename_empty = 1;\n \n \t/* pathchange left =NULL by default */\n \toptions->change = diff_change;\n@@ -4203,14 +4203,14 @@ void diff_setup_done(struct diff_options *options)\n \tif (DIFF_XDL_TST(options, IGNORE_WHITESPACE) ||\n \t    DIFF_XDL_TST(options, IGNORE_WHITESPACE_CHANGE) ||\n \t    DIFF_XDL_TST(options, IGNORE_WHITESPACE_AT_EOL))\n-\t\toptions->flags.DIFF_FROM_CONTENTS = 1;\n+\t\toptions->flags.diff_from_contents = 1;\n \telse\n-\t\toptions->flags.DIFF_FROM_CONTENTS = 0;\n+\t\toptions->flags.diff_from_contents = 0;\n \n-\tif (options->flags.FIND_COPIES_HARDER)\n+\tif (options->flags.find_copies_harder)\n \t\toptions->detect_rename = DIFF_DETECT_COPY;\n \n-\tif (!options->flags.RELATIVE_NAME)\n+\tif (!options->flags.relative_name)\n \t\toptions->prefix = NULL;\n \tif (options->prefix)\n \t\toptions->prefix_length = strlen(options->prefix);\n@@ -4240,18 +4240,18 @@ void diff_setup_done(struct diff_options *options)\n \t\t\t\t      DIFF_FORMAT_DIRSTAT |\n \t\t\t\t      DIFF_FORMAT_SUMMARY |\n \t\t\t\t      DIFF_FORMAT_CHECKDIFF))\n-\t\toptions->flags.RECURSIVE = 1;\n+\t\toptions->flags.recursive = 1;\n \t/*\n \t * Also pickaxe would not work very well if you do not say recursive\n \t */\n \tif (options->pickaxe)\n-\t\toptions->flags.RECURSIVE = 1;\n+\t\toptions->flags.recursive = 1;\n \t/*\n \t * When patches are generated, submodules diffed against the work tree\n \t * must be checked for dirtiness too so it can be shown in the output\n \t */\n \tif (options->output_format & DIFF_FORMAT_PATCH)\n-\t\toptions->flags.DIRTY_SUBMODULES = 1;\n+\t\toptions->flags.dirty_submodules = 1;\n \n \tif (options->detect_rename && options->rename_limit < 0)\n \t\toptions->rename_limit = diff_rename_limit_default;\n@@ -4273,14 +4273,14 @@ void diff_setup_done(struct diff_options *options)\n \t * to have found.  It does not make sense not to return with\n \t * exit code in such a case either.\n \t */\n-\tif (options->flags.QUICK) {\n+\tif (options->flags.quick) {\n \t\toptions->output_format = DIFF_FORMAT_NO_OUTPUT;\n-\t\toptions->flags.EXIT_WITH_STATUS = 1;\n+\t\toptions->flags.exit_with_status = 1;\n \t}\n \n \toptions->diff_path_counter = 0;\n \n-\tif (options->flags.FOLLOW_RENAMES && options->pathspec.nr != 1)\n+\tif (options->flags.follow_renames && options->pathspec.nr != 1)\n \t\tdie(_(\"--follow requires exactly one pathspec\"));\n \n \tif (!options->use_color || external_diff())\n@@ -4630,7 +4630,7 @@ int diff_opt_parse(struct diff_options *options,\n \telse if (starts_with(arg, \"-C\") || starts_with(arg, \"--find-copies=\") ||\n \t\t !strcmp(arg, \"--find-copies\")) {\n \t\tif (options->detect_rename == DIFF_DETECT_COPY)\n-\t\t\toptions->flags.FIND_COPIES_HARDER = 1;\n+\t\t\toptions->flags.find_copies_harder = 1;\n \t\tif ((options->rename_score = diff_scoreopt_parse(arg)) == -1)\n \t\t\treturn error(\"invalid argument to -C: %s\", arg+2);\n \t\toptions->detect_rename = DIFF_DETECT_COPY;\n@@ -4638,13 +4638,13 @@ int diff_opt_parse(struct diff_options *options,\n \telse if (!strcmp(arg, \"--no-renames\"))\n \t\toptions->detect_rename = 0;\n \telse if (!strcmp(arg, \"--rename-empty\"))\n-\t\toptions->flags.RENAME_EMPTY = 1;\n+\t\toptions->flags.rename_empty = 1;\n \telse if (!strcmp(arg, \"--no-rename-empty\"))\n-\t\toptions->flags.RENAME_EMPTY = 0;\n+\t\toptions->flags.rename_empty = 0;\n \telse if (!strcmp(arg, \"--relative\"))\n-\t\toptions->flags.RELATIVE_NAME = 1;\n+\t\toptions->flags.relative_name = 1;\n \telse if (skip_prefix(arg, \"--relative=\", &arg)) {\n-\t\toptions->flags.RELATIVE_NAME = 1;\n+\t\toptions->flags.relative_name = 1;\n \t\toptions->prefix = arg;\n \t}\n \n@@ -4684,21 +4684,21 @@ int diff_opt_parse(struct diff_options *options,\n \t/* flags options */\n \telse if (!strcmp(arg, \"--binary\")) {\n \t\tenable_patch_output(&options->output_format);\n-\t\toptions->flags.BINARY = 1;\n+\t\toptions->flags.binary = 1;\n \t}\n \telse if (!strcmp(arg, \"--full-index\"))\n-\t\toptions->flags.FULL_INDEX = 1;\n+\t\toptions->flags.full_index = 1;\n \telse if (!strcmp(arg, \"-a\") || !strcmp(arg, \"--text\"))\n-\t\toptions->flags.TEXT = 1;\n+\t\toptions->flags.text = 1;\n \telse if (!strcmp(arg, \"-R\"))\n-\t\toptions->flags.REVERSE_DIFF = 1;\n+\t\toptions->flags.reverse_diff = 1;\n \telse if (!strcmp(arg, \"--find-copies-harder\"))\n-\t\toptions->flags.FIND_COPIES_HARDER = 1;\n+\t\toptions->flags.find_copies_harder = 1;\n \telse if (!strcmp(arg, \"--follow\"))\n-\t\toptions->flags.FOLLOW_RENAMES = 1;\n+\t\toptions->flags.follow_renames = 1;\n \telse if (!strcmp(arg, \"--no-follow\")) {\n-\t\toptions->flags.FOLLOW_RENAMES = 0;\n-\t\toptions->flags.DEFAULT_FOLLOW_RENAMES = 0;\n+\t\toptions->flags.follow_renames = 0;\n+\t\toptions->flags.default_follow_renames = 0;\n \t} else if (!strcmp(arg, \"--color\"))\n \t\toptions->use_color = 1;\n \telse if (skip_prefix(arg, \"--color=\", &arg)) {\n@@ -4755,23 +4755,23 @@ int diff_opt_parse(struct diff_options *options,\n \t\treturn argcount;\n \t}\n \telse if (!strcmp(arg, \"--exit-code\"))\n-\t\toptions->flags.EXIT_WITH_STATUS = 1;\n+\t\toptions->flags.exit_with_status = 1;\n \telse if (!strcmp(arg, \"--quiet\"))\n-\t\toptions->flags.QUICK = 1;\n+\t\toptions->flags.quick = 1;\n \telse if (!strcmp(arg, \"--ext-diff\"))\n-\t\toptions->flags.ALLOW_EXTERNAL = 1;\n+\t\toptions->flags.allow_external = 1;\n \telse if (!strcmp(arg, \"--no-ext-diff\"))\n-\t\toptions->flags.ALLOW_EXTERNAL = 0;\n+\t\toptions->flags.allow_external = 0;\n \telse if (!strcmp(arg, \"--textconv\")) {\n-\t\toptions->flags.ALLOW_TEXTCONV = 1;\n-\t\toptions->flags.TEXTCONV_SET_VIA_CMDLINE = 1;\n+\t\toptions->flags.allow_textconv = 1;\n+\t\toptions->flags.textconv_set_via_cmdline = 1;\n \t} else if (!strcmp(arg, \"--no-textconv\"))\n-\t\toptions->flags.ALLOW_TEXTCONV = 0;\n+\t\toptions->flags.allow_textconv = 0;\n \telse if (!strcmp(arg, \"--ignore-submodules\")) {\n-\t\toptions->flags.OVERRIDE_SUBMODULE_CONFIG = 1;\n+\t\toptions->flags.override_submodule_config = 1;\n \t\thandle_ignore_submodules_arg(options, \"all\");\n \t} else if (skip_prefix(arg, \"--ignore-submodules=\", &arg)) {\n-\t\toptions->flags.OVERRIDE_SUBMODULE_CONFIG = 1;\n+\t\toptions->flags.override_submodule_config = 1;\n \t\thandle_ignore_submodules_arg(options, arg);\n \t} else if (!strcmp(arg, \"--submodule\"))\n \t\toptions->submodule_format = DIFF_SUBMODULE_LOG;\n@@ -4846,11 +4846,11 @@ int diff_opt_parse(struct diff_options *options,\n \t\t\t &options->interhunkcontext))\n \t\t;\n \telse if (!strcmp(arg, \"-W\"))\n-\t\toptions->flags.FUNCCONTEXT = 1;\n+\t\toptions->flags.funccontext = 1;\n \telse if (!strcmp(arg, \"--function-context\"))\n-\t\toptions->flags.FUNCCONTEXT = 1;\n+\t\toptions->flags.funccontext = 1;\n \telse if (!strcmp(arg, \"--no-function-context\"))\n-\t\toptions->flags.FUNCCONTEXT = 0;\n+\t\toptions->flags.funccontext = 0;\n \telse if ((argcount = parse_long_opt(\"output\", av, &optarg))) {\n \t\tchar *path = prefix_filename(prefix, optarg);\n \t\toptions->file = xfopen(path, \"w\");\n@@ -5600,7 +5600,7 @@ void diff_flush(struct diff_options *options)\n \t\tseparator++;\n \t}\n \n-\tif (output_format & DIFF_FORMAT_DIRSTAT && options->flags.DIRSTAT_BY_LINE)\n+\tif (output_format & DIFF_FORMAT_DIRSTAT && options->flags.dirstat_by_line)\n \t\tdirstat_by_line = 1;\n \n \tif (output_format & (DIFF_FORMAT_DIFFSTAT|DIFF_FORMAT_SHORTSTAT|DIFF_FORMAT_NUMSTAT) ||\n@@ -5635,8 +5635,8 @@ void diff_flush(struct diff_options *options)\n \t}\n \n \tif (output_format & DIFF_FORMAT_NO_OUTPUT &&\n-\t    options->flags.EXIT_WITH_STATUS &&\n-\t    options->flags.DIFF_FROM_CONTENTS) {\n+\t    options->flags.exit_with_status &&\n+\t    options->flags.diff_from_contents) {\n \t\t/*\n \t\t * run diff_flush_patch for the exit status. setting\n \t\t * options->file to /dev/null should be safe, because we\n@@ -5684,11 +5684,11 @@ void diff_flush(struct diff_options *options)\n \t * diff_addremove/diff_change does not set the bit when\n \t * DIFF_FROM_CONTENTS is in effect (e.g. with -w).\n \t */\n-\tif (options->flags.DIFF_FROM_CONTENTS) {\n+\tif (options->flags.diff_from_contents) {\n \t\tif (options->found_changes)\n-\t\t\toptions->flags.HAS_CHANGES = 1;\n+\t\t\toptions->flags.has_changes = 1;\n \t\telse\n-\t\t\toptions->flags.HAS_CHANGES = 0;\n+\t\t\toptions->flags.has_changes = 0;\n \t}\n }\n \n@@ -5808,7 +5808,7 @@ static void diffcore_skip_stat_unmatch(struct diff_options *diffopt)\n \t\t\t * to determine how many paths were dirty only\n \t\t\t * due to stat info mismatch.\n \t\t\t */\n-\t\t\tif (!diffopt->flags.NO_INDEX)\n+\t\t\tif (!diffopt->flags.no_index)\n \t\t\t\tdiffopt->skip_stat_unmatch++;\n \t\t\tdiff_free_filepair(p);\n \t\t}\n@@ -5857,10 +5857,10 @@ void diffcore_std(struct diff_options *options)\n \t\tdiff_resolve_rename_copy();\n \tdiffcore_apply_filter(options);\n \n-\tif (diff_queued_diff.nr && !options->flags.DIFF_FROM_CONTENTS)\n-\t\toptions->flags.HAS_CHANGES = 1;\n+\tif (diff_queued_diff.nr && !options->flags.diff_from_contents)\n+\t\toptions->flags.has_changes = 1;\n \telse\n-\t\toptions->flags.HAS_CHANGES = 0;\n+\t\toptions->flags.has_changes = 0;\n \n \toptions->found_follow = 0;\n }\n@@ -5872,23 +5872,23 @@ int diff_result_code(struct diff_options *opt, int status)\n \tdiff_warn_rename_limit(\"diff.renameLimit\",\n \t\t\t       opt->needed_rename_limit,\n \t\t\t       opt->degraded_cc_to_c);\n-\tif (!opt->flags.EXIT_WITH_STATUS &&\n+\tif (!opt->flags.exit_with_status &&\n \t    !(opt->output_format & DIFF_FORMAT_CHECKDIFF))\n \t\treturn status;\n-\tif (opt->flags.EXIT_WITH_STATUS &&\n-\t    opt->flags.HAS_CHANGES)\n+\tif (opt->flags.exit_with_status &&\n+\t    opt->flags.has_changes)\n \t\tresult |= 01;\n \tif ((opt->output_format & DIFF_FORMAT_CHECKDIFF) &&\n-\t    opt->flags.CHECK_FAILED)\n+\t    opt->flags.check_failed)\n \t\tresult |= 02;\n \treturn result;\n }\n \n int diff_can_quit_early(struct diff_options *opt)\n {\n-\treturn (opt->flags.QUICK &&\n+\treturn (opt->flags.quick &&\n \t\t!opt->filter &&\n-\t\topt->flags.HAS_CHANGES);\n+\t\topt->flags.has_changes);\n }\n \n /*\n@@ -5901,9 +5901,9 @@ static int is_submodule_ignored(const char *path, struct diff_options *options)\n {\n \tint ignored = 0;\n \tstruct diff_flags orig_flags = options->flags;\n-\tif (!options->flags.OVERRIDE_SUBMODULE_CONFIG)\n+\tif (!options->flags.override_submodule_config)\n \t\tset_diffopt_flags_from_submodule_config(options, path);\n-\tif (options->flags.IGNORE_SUBMODULES)\n+\tif (options->flags.ignore_submodules)\n \t\tignored = 1;\n \toptions->flags = orig_flags;\n \treturn ignored;\n@@ -5932,7 +5932,7 @@ void diff_addremove(struct diff_options *options,\n \t * Before the final output happens, they are pruned after\n \t * merged into rename/copy pairs as appropriate.\n \t */\n-\tif (options->flags.REVERSE_DIFF)\n+\tif (options->flags.reverse_diff)\n \t\taddremove = (addremove == '+' ? '-' :\n \t\t\t     addremove == '-' ? '+' : addremove);\n \n@@ -5951,8 +5951,8 @@ void diff_addremove(struct diff_options *options,\n \t}\n \n \tdiff_queue(&diff_queued_diff, one, two);\n-\tif (!options->flags.DIFF_FROM_CONTENTS)\n-\t\toptions->flags.HAS_CHANGES = 1;\n+\tif (!options->flags.diff_from_contents)\n+\t\toptions->flags.has_changes = 1;\n }\n \n void diff_change(struct diff_options *options,\n@@ -5970,7 +5970,7 @@ void diff_change(struct diff_options *options,\n \t    is_submodule_ignored(concatpath, options))\n \t\treturn;\n \n-\tif (options->flags.REVERSE_DIFF) {\n+\tif (options->flags.reverse_diff) {\n \t\tSWAP(old_mode, new_mode);\n \t\tSWAP(old_oid, new_oid);\n \t\tSWAP(old_oid_valid, new_oid_valid);\n@@ -5989,14 +5989,14 @@ void diff_change(struct diff_options *options,\n \ttwo->dirty_submodule = new_dirty_submodule;\n \tp = diff_queue(&diff_queued_diff, one, two);\n \n-\tif (options->flags.DIFF_FROM_CONTENTS)\n+\tif (options->flags.diff_from_contents)\n \t\treturn;\n \n-\tif (options->flags.QUICK && options->skip_stat_unmatch &&\n+\tif (options->flags.quick && options->skip_stat_unmatch &&\n \t    !diff_filespec_check_stat_unmatch(p))\n \t\treturn;\n \n-\toptions->flags.HAS_CHANGES = 1;\n+\toptions->flags.has_changes = 1;\n }\n \n struct diff_filepair *diff_unmerge(struct diff_options *options, const char *path)\n@@ -6134,7 +6134,7 @@ void setup_diff_pager(struct diff_options *opt)\n \t * and because it is easy to find people oneline advising \"git diff\n \t * --exit-code\" in hooks and other scripts, we do not do so.\n \t */\n-\tif (!opt->flags.EXIT_WITH_STATUS &&\n+\tif (!opt->flags.exit_with_status &&\n \t    check_pager_config(\"diff\") != 0)\n \t\tsetup_pager();\n }\ndiff --git a/diff.h b/diff.h\nindex 258d735c1..ed2832d7a 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -62,37 +62,37 @@ typedef struct strbuf *(*diff_prefix_fn_t)(struct diff_options *opt, void *data)\n \n #define DIFF_FLAGS_INIT { 0 }\n struct diff_flags {\n-\tunsigned RECURSIVE:1;\n-\tunsigned TREE_IN_RECURSIVE:1;\n-\tunsigned BINARY:1;\n-\tunsigned TEXT:1;\n-\tunsigned FULL_INDEX:1;\n-\tunsigned SILENT_ON_REMOVE:1;\n-\tunsigned FIND_COPIES_HARDER:1;\n-\tunsigned FOLLOW_RENAMES:1;\n-\tunsigned RENAME_EMPTY:1;\n-\tunsigned HAS_CHANGES:1;\n-\tunsigned QUICK:1;\n-\tunsigned NO_INDEX:1;\n-\tunsigned ALLOW_EXTERNAL:1;\n-\tunsigned EXIT_WITH_STATUS:1;\n-\tunsigned REVERSE_DIFF:1;\n-\tunsigned CHECK_FAILED:1;\n-\tunsigned RELATIVE_NAME:1;\n-\tunsigned IGNORE_SUBMODULES:1;\n-\tunsigned DIRSTAT_CUMULATIVE:1;\n-\tunsigned DIRSTAT_BY_FILE:1;\n-\tunsigned ALLOW_TEXTCONV:1;\n-\tunsigned TEXTCONV_SET_VIA_CMDLINE:1;\n-\tunsigned DIFF_FROM_CONTENTS:1;\n-\tunsigned DIRTY_SUBMODULES:1;\n-\tunsigned IGNORE_UNTRACKED_IN_SUBMODULES:1;\n-\tunsigned IGNORE_DIRTY_SUBMODULES:1;\n-\tunsigned OVERRIDE_SUBMODULE_CONFIG:1;\n-\tunsigned DIRSTAT_BY_LINE:1;\n-\tunsigned FUNCCONTEXT:1;\n-\tunsigned PICKAXE_IGNORE_CASE:1;\n-\tunsigned DEFAULT_FOLLOW_RENAMES:1;\n+\tunsigned recursive:1;\n+\tunsigned tree_in_recursive:1;\n+\tunsigned binary:1;\n+\tunsigned text:1;\n+\tunsigned full_index:1;\n+\tunsigned silent_on_remove:1;\n+\tunsigned find_copies_harder:1;\n+\tunsigned follow_renames:1;\n+\tunsigned rename_empty:1;\n+\tunsigned has_changes:1;\n+\tunsigned quick:1;\n+\tunsigned no_index:1;\n+\tunsigned allow_external:1;\n+\tunsigned exit_with_status:1;\n+\tunsigned reverse_diff:1;\n+\tunsigned check_failed:1;\n+\tunsigned relative_name:1;\n+\tunsigned ignore_submodules:1;\n+\tunsigned dirstat_cumulative:1;\n+\tunsigned dirstat_by_file:1;\n+\tunsigned allow_textconv:1;\n+\tunsigned textconv_set_via_cmdline:1;\n+\tunsigned diff_from_contents:1;\n+\tunsigned dirty_submodules:1;\n+\tunsigned ignore_untracked_in_submodules:1;\n+\tunsigned ignore_dirty_submodules:1;\n+\tunsigned override_submodule_config:1;\n+\tunsigned dirstat_by_line:1;\n+\tunsigned funccontext:1;\n+\tunsigned pickaxe_ignore_case:1;\n+\tunsigned default_follow_renames:1;\n };\n \n static inline void diff_flags_or(struct diff_flags *a,\ndiff --git a/diffcore-pickaxe.c b/diffcore-pickaxe.c\nindex 6193c07f6..9476bd210 100644\n--- a/diffcore-pickaxe.c\n+++ b/diffcore-pickaxe.c\n@@ -131,7 +131,7 @@ static int pickaxe_match(struct diff_filepair *p, struct diff_options *o,\n \tif (!DIFF_FILE_VALID(p->one) && !DIFF_FILE_VALID(p->two))\n \t\treturn 0;\n \n-\tif (o->flags.ALLOW_TEXTCONV) {\n+\tif (o->flags.allow_textconv) {\n \t\ttextconv_one = get_textconv(p->one);\n \t\ttextconv_two = get_textconv(p->two);\n \t}\n@@ -222,11 +222,11 @@ void diffcore_pickaxe(struct diff_options *o)\n \n \tif (opts & (DIFF_PICKAXE_REGEX | DIFF_PICKAXE_KIND_G)) {\n \t\tint cflags = REG_EXTENDED | REG_NEWLINE;\n-\t\tif (o->flags.PICKAXE_IGNORE_CASE)\n+\t\tif (o->flags.pickaxe_ignore_case)\n \t\t\tcflags |= REG_ICASE;\n \t\tregcomp_or_die(&regex, needle, cflags);\n \t\tregexp = &regex;\n-\t} else if (o->flags.PICKAXE_IGNORE_CASE &&\n+\t} else if (o->flags.pickaxe_ignore_case &&\n \t\t   has_non_ascii(needle)) {\n \t\tstruct strbuf sb = STRBUF_INIT;\n \t\tint cflags = REG_NEWLINE | REG_ICASE;\n@@ -236,7 +236,7 @@ void diffcore_pickaxe(struct diff_options *o)\n \t\tstrbuf_release(&sb);\n \t\tregexp = &regex;\n \t} else {\n-\t\tkws = kwsalloc(o->flags.PICKAXE_IGNORE_CASE\n+\t\tkws = kwsalloc(o->flags.pickaxe_ignore_case\n \t\t\t       ? tolower_trans_tbl : NULL);\n \t\tkwsincr(kws, needle, strlen(needle));\n \t\tkwsprep(kws);\ndiff --git a/diffcore-rename.c b/diffcore-rename.c\nindex bd077ee11..12dc2a056 100644\n--- a/diffcore-rename.c\n+++ b/diffcore-rename.c\n@@ -405,7 +405,7 @@ static int too_many_rename_candidates(int num_create,\n \t\tnum_src > num_create ? num_src : num_create;\n \n \t/* Are we running under -C -C? */\n-\tif (!options->flags.FIND_COPIES_HARDER)\n+\tif (!options->flags.find_copies_harder)\n \t\treturn 1;\n \n \t/* Would we bust the limit if we were running under -C? */\n@@ -463,7 +463,7 @@ void diffcore_rename(struct diff_options *options)\n \t\t\telse if (options->single_follow &&\n \t\t\t\t strcmp(options->single_follow, p->two->path))\n \t\t\t\tcontinue; /* not interested */\n-\t\t\telse if (!options->flags.RENAME_EMPTY &&\n+\t\t\telse if (!options->flags.rename_empty &&\n \t\t\t\t is_empty_blob_oid(&p->two->oid))\n \t\t\t\tcontinue;\n \t\t\telse if (add_rename_dst(p->two) < 0) {\n@@ -473,7 +473,7 @@ void diffcore_rename(struct diff_options *options)\n \t\t\t\tgoto cleanup;\n \t\t\t}\n \t\t}\n-\t\telse if (!options->flags.RENAME_EMPTY &&\n+\t\telse if (!options->flags.rename_empty &&\n \t\t\t is_empty_blob_oid(&p->one->oid))\n \t\t\tcontinue;\n \t\telse if (!DIFF_PAIR_UNMERGED(p) && !DIFF_FILE_VALID(p->two)) {\ndiff --git a/log-tree.c b/log-tree.c\nindex 460bb5498..8dacccc0c 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -793,7 +793,7 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log\n \tstruct commit_list *parents;\n \tstruct object_id *oid;\n \n-\tif (!opt->diff && !opt->diffopt.flags.EXIT_WITH_STATUS)\n+\tif (!opt->diff && !opt->diffopt.flags.exit_with_status)\n \t\treturn 0;\n \n \tparse_commit_or_die(commit);\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 9752aba4e..f6c03770b 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -540,8 +540,8 @@ static struct string_list *get_renames(struct merge_options *o,\n \t\treturn renames;\n \n \tdiff_setup(&opts);\n-\topts.flags.RECURSIVE = 1;\n-\topts.flags.RENAME_EMPTY = 0;\n+\topts.flags.recursive = 1;\n+\topts.flags.rename_empty = 0;\n \topts.detect_rename = DIFF_DETECT_RENAME;\n \topts.rename_limit = o->merge_rename_limit >= 0 ? o->merge_rename_limit :\n \t\t\t    o->diff_rename_limit >= 0 ? o->diff_rename_limit :\ndiff --git a/notes-merge.c b/notes-merge.c\nindex b50111cf2..b3d4d44fc 100644\n--- a/notes-merge.c\n+++ b/notes-merge.c\n@@ -125,7 +125,7 @@ static struct notes_merge_pair *diff_tree_remote(struct notes_merge_options *o,\n \t       oid_to_hex(base), oid_to_hex(remote));\n \n \tdiff_setup(&opt);\n-\topt.flags.RECURSIVE = 1;\n+\topt.flags.recursive = 1;\n \topt.output_format = DIFF_FORMAT_NO_OUTPUT;\n \tdiff_setup_done(&opt);\n \tdiff_tree_oid(base, remote, \"\", &opt);\n@@ -188,7 +188,7 @@ static void diff_tree_local(struct notes_merge_options *o,\n \t       len, oid_to_hex(base), oid_to_hex(local));\n \n \tdiff_setup(&opt);\n-\topt.flags.RECURSIVE = 1;\n+\topt.flags.recursive = 1;\n \topt.output_format = DIFF_FORMAT_NO_OUTPUT;\n \tdiff_setup_done(&opt);\n \tdiff_tree_oid(base, local, \"\", &opt);\ndiff --git a/patch-ids.c b/patch-ids.c\nindex 189869e57..8f7c25d5d 100644\n--- a/patch-ids.c\n+++ b/patch-ids.c\n@@ -61,7 +61,7 @@ int init_patch_ids(struct patch_ids *ids)\n \tmemset(ids, 0, sizeof(*ids));\n \tdiff_setup(&ids->diffopts);\n \tids->diffopts.detect_rename = 0;\n-\tids->diffopts.flags.RECURSIVE = 1;\n+\tids->diffopts.flags.recursive = 1;\n \tdiff_setup_done(&ids->diffopts);\n \thashmap_init(&ids->patches, patch_id_cmp, &ids->diffopts, 256);\n \treturn 0;\ndiff --git a/revision.c b/revision.c\nindex 6bb873501..bfde5b0cd 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -410,7 +410,7 @@ static void file_add_remove(struct diff_options *options,\n \n \ttree_difference |= diff;\n \tif (tree_difference == REV_TREE_DIFFERENT)\n-\t\toptions->flags.HAS_CHANGES = 1;\n+\t\toptions->flags.has_changes = 1;\n }\n \n static void file_change(struct diff_options *options,\n@@ -422,7 +422,7 @@ static void file_change(struct diff_options *options,\n \t\t unsigned old_dirty_submodule, unsigned new_dirty_submodule)\n {\n \ttree_difference = REV_TREE_DIFFERENT;\n-\toptions->flags.HAS_CHANGES = 1;\n+\toptions->flags.has_changes = 1;\n }\n \n static int rev_compare_tree(struct rev_info *revs,\n@@ -455,7 +455,7 @@ static int rev_compare_tree(struct rev_info *revs,\n \t}\n \n \ttree_difference = REV_TREE_SAME;\n-\trevs->pruning.flags.HAS_CHANGES = 0;\n+\trevs->pruning.flags.has_changes = 0;\n \tif (diff_tree_oid(&t1->object.oid, &t2->object.oid, \"\",\n \t\t\t   &revs->pruning) < 0)\n \t\treturn REV_TREE_DIFFERENT;\n@@ -471,7 +471,7 @@ static int rev_same_tree_as_empty(struct rev_info *revs, struct commit *commit)\n \t\treturn 0;\n \n \ttree_difference = REV_TREE_SAME;\n-\trevs->pruning.flags.HAS_CHANGES = 0;\n+\trevs->pruning.flags.has_changes = 0;\n \tretval = diff_tree_oid(NULL, &t1->object.oid, \"\", &revs->pruning);\n \n \treturn retval >= 0 && (tree_difference == REV_TREE_SAME);\n@@ -1403,8 +1403,8 @@ void init_revisions(struct rev_info *revs, const char *prefix)\n \trevs->abbrev = DEFAULT_ABBREV;\n \trevs->ignore_merges = 1;\n \trevs->simplify_history = 1;\n-\trevs->pruning.flags.RECURSIVE = 1;\n-\trevs->pruning.flags.QUICK = 1;\n+\trevs->pruning.flags.recursive = 1;\n+\trevs->pruning.flags.quick = 1;\n \trevs->pruning.add_remove = file_add_remove;\n \trevs->pruning.change = file_change;\n \trevs->sort_order = REV_SORT_IN_GRAPH_ORDER;\n@@ -1917,11 +1917,11 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg\n \t\tdie(\"--unpacked=<packfile> no longer supported.\");\n \t} else if (!strcmp(arg, \"-r\")) {\n \t\trevs->diff = 1;\n-\t\trevs->diffopt.flags.RECURSIVE = 1;\n+\t\trevs->diffopt.flags.recursive = 1;\n \t} else if (!strcmp(arg, \"-t\")) {\n \t\trevs->diff = 1;\n-\t\trevs->diffopt.flags.RECURSIVE = 1;\n-\t\trevs->diffopt.flags.TREE_IN_RECURSIVE = 1;\n+\t\trevs->diffopt.flags.recursive = 1;\n+\t\trevs->diffopt.flags.tree_in_recursive = 1;\n \t} else if (!strcmp(arg, \"-m\")) {\n \t\trevs->ignore_merges = 0;\n \t} else if (!strcmp(arg, \"-c\")) {\n@@ -2066,7 +2066,7 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg\n \t\trevs->grep_filter.pattern_type_option = GREP_PATTERN_TYPE_ERE;\n \t} else if (!strcmp(arg, \"--regexp-ignore-case\") || !strcmp(arg, \"-i\")) {\n \t\trevs->grep_filter.ignore_case = 1;\n-\t\trevs->diffopt.flags.PICKAXE_IGNORE_CASE = 1;\n+\t\trevs->diffopt.flags.pickaxe_ignore_case = 1;\n \t} else if (!strcmp(arg, \"--fixed-strings\") || !strcmp(arg, \"-F\")) {\n \t\trevs->grep_filter.pattern_type_option = GREP_PATTERN_TYPE_FIXED;\n \t} else if (!strcmp(arg, \"--perl-regexp\") || !strcmp(arg, \"-P\")) {\n@@ -2399,7 +2399,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s\n \t/* Pickaxe, diff-filter and rename following need diffs */\n \tif (revs->diffopt.pickaxe ||\n \t    revs->diffopt.filter ||\n-\t    revs->diffopt.flags.FOLLOW_RENAMES)\n+\t    revs->diffopt.flags.follow_renames)\n \t\trevs->diff = 1;\n \n \tif (revs->topo_order)\n@@ -2408,7 +2408,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s\n \tif (revs->prune_data.nr) {\n \t\tcopy_pathspec(&revs->pruning.pathspec, &revs->prune_data);\n \t\t/* Can't prune commits with rename following: the paths change.. */\n-\t\tif (!revs->diffopt.flags.FOLLOW_RENAMES)\n+\t\tif (!revs->diffopt.flags.follow_renames)\n \t\t\trevs->prune = 1;\n \t\tif (!revs->full_diff)\n \t\t\tcopy_pathspec(&revs->diffopt.pathspec,\ndiff --git a/submodule.c b/submodule.c\nindex 62a93bb88..9b16adc96 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -183,7 +183,7 @@ void set_diffopt_flags_from_submodule_config(struct diff_options *diffopt,\n \t\tif (ignore)\n \t\t\thandle_ignore_submodules_arg(diffopt, ignore);\n \t\telse if (is_gitmodules_unmerged(&the_index))\n-\t\t\tdiffopt->flags.IGNORE_SUBMODULES = 1;\n+\t\t\tdiffopt->flags.ignore_submodules = 1;\n \t}\n }\n \n@@ -402,16 +402,16 @@ const char *submodule_strategy_to_string(const struct submodule_update_strategy\n void handle_ignore_submodules_arg(struct diff_options *diffopt,\n \t\t\t\t  const char *arg)\n {\n-\tdiffopt->flags.IGNORE_SUBMODULES = 0;\n-\tdiffopt->flags.IGNORE_UNTRACKED_IN_SUBMODULES = 0;\n-\tdiffopt->flags.IGNORE_DIRTY_SUBMODULES = 0;\n+\tdiffopt->flags.ignore_submodules = 0;\n+\tdiffopt->flags.ignore_untracked_in_submodules = 0;\n+\tdiffopt->flags.ignore_dirty_submodules = 0;\n \n \tif (!strcmp(arg, \"all\"))\n-\t\tdiffopt->flags.IGNORE_SUBMODULES = 1;\n+\t\tdiffopt->flags.ignore_submodules = 1;\n \telse if (!strcmp(arg, \"untracked\"))\n-\t\tdiffopt->flags.IGNORE_UNTRACKED_IN_SUBMODULES = 1;\n+\t\tdiffopt->flags.ignore_untracked_in_submodules = 1;\n \telse if (!strcmp(arg, \"dirty\"))\n-\t\tdiffopt->flags.IGNORE_DIRTY_SUBMODULES = 1;\n+\t\tdiffopt->flags.ignore_dirty_submodules = 1;\n \telse if (strcmp(arg, \"none\"))\n \t\tdie(\"bad --ignore-submodules argument: %s\", arg);\n }\n@@ -616,7 +616,7 @@ void show_submodule_inline_diff(struct diff_options *o, const char *path,\n \targv_array_pushf(&cp.args, \"--color=%s\", want_color(o->use_color) ?\n \t\t\t \"always\" : \"never\");\n \n-\tif (o->flags.REVERSE_DIFF) {\n+\tif (o->flags.reverse_diff) {\n \t\targv_array_pushf(&cp.args, \"--src-prefix=%s%s/\",\n \t\t\t\t o->b_prefix, path);\n \t\targv_array_pushf(&cp.args, \"--dst-prefix=%s%s/\",\ndiff --git a/tree-diff.c b/tree-diff.c\nindex b996a23bb..fe2e466ac 100644\n--- a/tree-diff.c\n+++ b/tree-diff.c\n@@ -212,9 +212,9 @@ static struct combine_diff_path *emit_path(struct combine_diff_path *p,\n \t\tmode = 0;\n \t}\n \n-\tif (opt->flags.RECURSIVE && isdir) {\n+\tif (opt->flags.recursive && isdir) {\n \t\trecurse = 1;\n-\t\temitthis = opt->flags.TREE_IN_RECURSIVE;\n+\t\temitthis = opt->flags.tree_in_recursive;\n \t}\n \n \tif (emitthis) {\n@@ -425,7 +425,7 @@ static struct combine_diff_path *ll_diff_tree_paths(\n \tttree = fill_tree_descriptor(&t, oid);\n \n \t/* Enable recursion indefinitely */\n-\topt->pathspec.recursive = opt->flags.RECURSIVE;\n+\topt->pathspec.recursive = opt->flags.recursive;\n \n \tfor (;;) {\n \t\tint imin, cmp;\n@@ -484,7 +484,7 @@ static struct combine_diff_path *ll_diff_tree_paths(\n \t\t/* t = p[imin] */\n \t\tif (cmp == 0) {\n \t\t\t/* are either pi > p[imin] or diff(t,pi) != ø ? */\n-\t\t\tif (!opt->flags.FIND_COPIES_HARDER) {\n+\t\t\tif (!opt->flags.find_copies_harder) {\n \t\t\t\tfor (i = 0; i < nparent; ++i) {\n \t\t\t\t\t/* p[i] > p[imin] */\n \t\t\t\t\tif (tp[i].entry.mode & S_IFXMIN_NEQ)\n@@ -522,7 +522,7 @@ static struct combine_diff_path *ll_diff_tree_paths(\n \t\t/* t > p[imin] */\n \t\telse {\n \t\t\t/* ∀i pi=p[imin] -> D += \"-p[imin]\" */\n-\t\t\tif (!opt->flags.FIND_COPIES_HARDER) {\n+\t\t\tif (!opt->flags.find_copies_harder) {\n \t\t\t\tfor (i = 0; i < nparent; ++i)\n \t\t\t\t\tif (tp[i].entry.mode & S_IFXMIN_NEQ)\n \t\t\t\t\t\tgoto skip_emit_tp;\n@@ -608,8 +608,8 @@ static void try_to_follow_renames(const struct object_id *old_oid,\n \tq->nr = 0;\n \n \tdiff_setup(&diff_opts);\n-\tdiff_opts.flags.RECURSIVE = 1;\n-\tdiff_opts.flags.FIND_COPIES_HARDER = 1;\n+\tdiff_opts.flags.recursive = 1;\n+\tdiff_opts.flags.find_copies_harder = 1;\n \tdiff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;\n \tdiff_opts.single_follow = opt->pathspec.items[0].match;\n \tdiff_opts.break_opt = opt->break_opt;\n@@ -706,7 +706,7 @@ int diff_tree_oid(const struct object_id *old_oid,\n \tstrbuf_addstr(&base, base_str);\n \n \tretval = ll_diff_tree_oid(old_oid, new_oid, &base, opt);\n-\tif (!*base_str && opt->flags.FOLLOW_RENAMES && diff_might_be_rename())\n+\tif (!*base_str && opt->flags.follow_renames && diff_might_be_rename())\n \t\ttry_to_follow_renames(old_oid, new_oid, &base, opt);\n \n \tstrbuf_release(&base);\ndiff --git a/wt-status.c b/wt-status.c\nindex 59f9f3a0b..4f76e19d3 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -559,12 +559,12 @@ static void wt_status_collect_changes_worktree(struct wt_status *s)\n \tinit_revisions(&rev, NULL);\n \tsetup_revisions(0, NULL, &rev, NULL);\n \trev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;\n-\trev.diffopt.flags.DIRTY_SUBMODULES = 1;\n+\trev.diffopt.flags.dirty_submodules = 1;\n \trev.diffopt.ita_invisible_in_index = 1;\n \tif (!s->show_untracked_files)\n-\t\trev.diffopt.flags.IGNORE_UNTRACKED_IN_SUBMODULES = 1;\n+\t\trev.diffopt.flags.ignore_untracked_in_submodules = 1;\n \tif (s->ignore_submodule_arg) {\n-\t\trev.diffopt.flags.OVERRIDE_SUBMODULE_CONFIG = 1;\n+\t\trev.diffopt.flags.override_submodule_config = 1;\n \t\thandle_ignore_submodules_arg(&rev.diffopt, s->ignore_submodule_arg);\n \t}\n \trev.diffopt.format_callback = wt_status_collect_changed_cb;\n@@ -583,7 +583,7 @@ static void wt_status_collect_changes_index(struct wt_status *s)\n \topt.def = s->is_initial ? EMPTY_TREE_SHA1_HEX : s->reference;\n \tsetup_revisions(0, NULL, &rev, &opt);\n \n-\trev.diffopt.flags.OVERRIDE_SUBMODULE_CONFIG = 1;\n+\trev.diffopt.flags.override_submodule_config = 1;\n \trev.diffopt.ita_invisible_in_index = 1;\n \tif (s->ignore_submodule_arg) {\n \t\thandle_ignore_submodules_arg(&rev.diffopt, s->ignore_submodule_arg);\n@@ -949,7 +949,7 @@ static void wt_longstatus_print_verbose(struct wt_status *s)\n \tconst char *c = color(WT_STATUS_HEADER, s);\n \n \tinit_revisions(&rev, NULL);\n-\trev.diffopt.flags.ALLOW_TEXTCONV = 1;\n+\trev.diffopt.flags.allow_textconv = 1;\n \trev.diffopt.ita_invisible_in_index = 1;\n \n \tmemset(&opt, 0, sizeof(opt));\n@@ -2263,8 +2263,8 @@ int has_unstaged_changes(int ignore_submodules)\n \n \tinit_revisions(&rev_info, NULL);\n \tif (ignore_submodules)\n-\t\trev_info.diffopt.flags.IGNORE_SUBMODULES = 1;\n-\trev_info.diffopt.flags.QUICK = 1;\n+\t\trev_info.diffopt.flags.ignore_submodules = 1;\n+\trev_info.diffopt.flags.quick = 1;\n \tdiff_setup_done(&rev_info.diffopt);\n \tresult = run_diff_files(&rev_info, 0);\n \treturn diff_result_code(&rev_info.diffopt, result);\n@@ -2283,8 +2283,8 @@ int has_uncommitted_changes(int ignore_submodules)\n \n \tinit_revisions(&rev_info, NULL);\n \tif (ignore_submodules)\n-\t\trev_info.diffopt.flags.IGNORE_SUBMODULES = 1;\n-\trev_info.diffopt.flags.QUICK = 1;\n+\t\trev_info.diffopt.flags.ignore_submodules = 1;\n+\trev_info.diffopt.flags.quick = 1;\n \tadd_head_to_pending(&rev_info);\n \tdiff_setup_done(&rev_info.diffopt);\n \tresult = run_diff_index(&rev_info, 1);\n-- \n2.15.0.403.gc27cc4dac6-goog\n\n"},{"id":"331520","messageId":"CAGZ79kajX=FmGacDSv_dDzppE6WBHGqgyCpaG1zDyENcsDbwZg@mail.gmail.com","threadId":"47047","inReplyTo":"20171031181911.42687-3-bmwill@google.com","subject":"Re: [PATCH v3 2/8] diff: convert flags to be stored in bitfields","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-10-31T21:32:20Z","receivedAt":"2017-10-31T21:32:26Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Tue, Oct 31, 2017 at 11:19 AM, Brandon Williams <bmwill@google.com> wrote:\n> We cannot add many more flags to the diff machinery due to the\n> limitations of the number of flags that can be stored in a single\n> unsigned int.  In order to allow for more flags to be added to the diff\n> machinery in the future this patch converts the flags to be stored in\n> bitfields in 'struct diff_flags'.\n>\n> Signed-off-by: Brandon Williams <bmwill@google.com>\n\nThanks for this cleanup series!\nStefan\n\n> +struct diff_flags {\n> +       unsigned RECURSIVE:1;\n\nAfter some quick research our coding style on bit fields is twofold:\nMost older code is this way and more recent code seems to prefer\n\n    unsigned <FLAGNAME> SP : SP ;\n\nIf this turns out to be the only nit, I would ignore it for the sake of\nfaster settlement of the series.\n\n\n> +static inline void diff_flags_or(struct diff_flags *a,\n> +                                const struct diff_flags *b)\n> +{\n> +       char *tmp_a = (char *)a;\n> +       const char *tmp_b = (const char *)b;\n> +       int i;\n> +\n> +       for (i = 0; i < sizeof(struct diff_flags); i++)\n\nI think most of the code prefers to put the variable into the sizeof\nargument i.e. 'sizeof(*a)', as that is presumably more maintainable.\n(If the type of 'a' changes, then we don't forget to adapt this place,\nbut the compiler can take care of it.\n"},{"id":"331521","messageId":"CAGZ79kbgeVhi46vU9YzSyuvgFLFCZddFatUaopJDG=o=cU6dcw@mail.gmail.com","threadId":"47047","inReplyTo":"20171031181911.42687-8-bmwill@google.com","subject":"Re: [PATCH v3 7/8] diff: remove DIFF_OPT_CLR macro","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-10-31T21:44:00Z","receivedAt":"2017-10-31T21:44:06Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Tue, Oct 31, 2017 at 11:19 AM, Brandon Williams <bmwill@google.com> wrote:\n> Remove the `DIFF_OPT_SET` macro and instead set the flags directly.\n\n _CLR here\n"},{"id":"331522","messageId":"CAGZ79kZytrzDRsEU8Od3rZBPbWYqJQiQ5w0PE6hxVR-SbE2MqA@mail.gmail.com","threadId":"47047","inReplyTo":"20171031181911.42687-1-bmwill@google.com","subject":"Re: [PATCH v3 0/8] convert diff flags to be stored in a struct","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-10-31T21:46:00Z","receivedAt":"2017-10-31T21:46:06Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Tue, Oct 31, 2017 at 11:19 AM, Brandon Williams <bmwill@google.com> wrote:\n> Changes in v3:\n>  * Now always pass struct diff_flags by reference and don't return the struct\n>    but rather modify the passed in struct.\n>  * Don't clear TEXTCONV_SET_VIA_CMDLINE when --no-textconv is passed\n>  * added additional patches (set out separately before) to remove the macros\n>    and change the struct members to lowercase\n\nI have reviewed this version and the functionality introduced\nlooks good to me. My only nits were regarding style and typos.\n\nThanks,\nStefan\n"},{"id":"331530","messageId":"xmqq8tfqyejq.fsf@gitster.mtv.corp.google.com","threadId":"47047","inReplyTo":"CAGZ79kajX=FmGacDSv_dDzppE6WBHGqgyCpaG1zDyENcsDbwZg@mail.gmail.com","subject":"Re: [PATCH v3 2/8] diff: convert flags to be stored in bitfields","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-11-01T01:26:49Z","receivedAt":"2017-11-01T01:26:55Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stefan Beller <sbeller@google.com> writes:\n\n> After some quick research our coding style on bit fields is twofold:\n> Most older code is this way and more recent code seems to prefer\n>\n>     unsigned <FLAGNAME> SP : SP ;\n\nYes, we are very inconsistent.  What does the clang format rules\nBrandon came up with have to say on this?  FWIW, checkpatch.pl is\nunhappy without spaces on both side.\n\n>> +static inline void diff_flags_or(struct diff_flags *a,\n>> +                                const struct diff_flags *b)\n>> +{\n>> +       char *tmp_a = (char *)a;\n>> +       const char *tmp_b = (const char *)b;\n>> +       int i;\n>> +\n>> +       for (i = 0; i < sizeof(struct diff_flags); i++)\n>\n> I think most of the code prefers to put the variable into the sizeof\n> argument i.e. 'sizeof(*a)', as that is presumably more maintainable.\n> (If the type of 'a' changes, then we don't forget to adapt this place,\n> but the compiler can take care of it.\n\nYup, but in this case we won't change the type, no?\n"},{"id":"331535","messageId":"xmqqbmkmww17.fsf@gitster.mtv.corp.google.com","threadId":"47047","inReplyTo":"CAGZ79kbgeVhi46vU9YzSyuvgFLFCZddFatUaopJDG=o=cU6dcw@mail.gmail.com","subject":"Re: [PATCH v3 7/8] diff: remove DIFF_OPT_CLR macro","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-11-01T02:52:04Z","receivedAt":"2017-11-01T02:52:11Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stefan Beller <sbeller@google.com> writes:\n\n> On Tue, Oct 31, 2017 at 11:19 AM, Brandon Williams <bmwill@google.com> wrote:\n>> Remove the `DIFF_OPT_SET` macro and instead set the flags directly.\n>\n>  _CLR here\n\nWill squash in. Thanks.\n"},{"id":"331547","messageId":"xmqqfu9ytt3z.fsf@gitster.mtv.corp.google.com","threadId":"47047","inReplyTo":"20171031181911.42687-1-bmwill@google.com","subject":"Re: [PATCH v3 0/8] convert diff flags to be stored in a struct","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-11-01T06:23:28Z","receivedAt":"2017-11-01T06:23:35Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Brandon Williams <bmwill@google.com> writes:\n\n> Changes in v3:\n>  * Now always pass struct diff_flags by reference and don't return the struct\n>    but rather modify the passed in struct.\n>  * Don't clear TEXTCONV_SET_VIA_CMDLINE when --no-textconv is passed\n>  * added additional patches (set out separately before) to remove the macros\n>    and change the struct members to lowercase\n\nThe result looks pleasant overall, although I suspect I'd need some\ntime to get used to them being all explicit bitfields.\n\nQueued.\n"},{"id":"331583","messageId":"CAGZ79ka+WK2rtR0_LtWPWM7k-_Bs0aJLvVJ9CJx-u6eenp4FwA@mail.gmail.com","threadId":"47047","inReplyTo":"xmqq8tfqyejq.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v3 2/8] diff: convert flags to be stored in bitfields","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-11-01T17:11:12Z","receivedAt":"2017-11-01T17:11:18Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Tue, Oct 31, 2017 at 6:26 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Stefan Beller <sbeller@google.com> writes:\n>\n>> After some quick research our coding style on bit fields is twofold:\n>> Most older code is this way and more recent code seems to prefer\n>>\n>>     unsigned <FLAGNAME> SP : SP ;\n>\n> Yes, we are very inconsistent.  What does the clang format rules\n> Brandon came up with have to say on this?  FWIW, checkpatch.pl is\n> unhappy without spaces on both side.\n\nclang-format --style file diff.h\n\n...\n#define DIFF_FLAGS_INIT \\\n{               \\\n                0       \\\n}\nstruct diff_flags {\n        unsigned recursive : 1;\n        unsigned tree_in_recursive : 1;\n        unsigned binary : 1;\n        unsigned text : 1;\n...\n\n\n>>> +       for (i = 0; i < sizeof(struct diff_flags); i++)\n>>\n>> I think most of the code prefers to put the variable into the sizeof\n>> argument i.e. 'sizeof(*a)', as that is presumably more maintainable.\n>> (If the type of 'a' changes, then we don't forget to adapt this place,\n>> but the compiler can take care of it.\n>\n> Yup, but in this case we won't change the type, no?\n\nMost likely. If we were to change the type we'd have to rename the function\nand probably rewrite the body, too. I just mentioned it from a consistency\npoint of view. (exceptions are both a mental burden to humans as well\nas to machines using .clang-format et al. The fewer \"this time is different\"\ncalls we have, the better)\n"}]}