{"thread":{"id":"10700","subject":"[PATCH MISC 1/1] Make gcc warning about empty if body go away.","startedAt":"2007-11-07T10:20:25Z","lastAt":"2007-11-10T19:05:14Z","messageCount":19,"participants":["Pierre Habouzit","Junio C Hamano","Andreas Ericsson","Jon Loeliger"],"isPatch":true,"patchVersion":1,"patchTotal":1},"messages":[{"id":"58661","messageId":"1194430832-6224-1-git-send-email-madcoder@debian.org","threadId":"10700","inReplyTo":null,"subject":"Preliminary patches to the diff.[hc] parseoptification","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-07T10:20:25Z","receivedAt":"2007-11-07T10:20:25Z","isPatch":false,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"I'm currently working on the very involved task of migrating diff\noptions to parseopts. It's quite involved because for many reasons I\nwon't detail here, it needs to migrate those _and_ revisions options at\nthe same time (most of the diff options users _also_ use the revisions\nones).\n\nSo I'm trying to see some preliminary patches that I need to make this\nthe less disruptive possible: my goal is that people can use those\npreliminary series bit by bit, and not a whole 10 to 20 patches (I\nbelieve it will really take this amount in the end) at once with\nbreakages hard to find in the mess.\n\nSo in the coming days I'll probably send my work bit by bit when I feel\nit won't change anymore.\n\n\nSummary:\n~~~~~~~\n\nThe 3 series are completely independent.\n\n  + this is a patch to fix an issue that begin to irritate me and\n    prevents me to build with -Werror.\n\n    [1/1] Make gcc warning about empty if body go away.\n\n  + this series add new features that are needed for the diff options.\n    commit 1 implements them (see commit log,\n    commits 2 to 4 use them in some commands that benefit from those.\n\n    [1/4] parse-options new features.\n    [2/4] Use OPT_SET_INT and OPT_BIT in builtin-branch\n    [3/4] Use OPT_BIT in builtin-for-each-ref\n    [4/4] Use OPT_BIT in builtin-pack-refs\n\n  + this series does some modifications on the diff_options structure\n    and the diff_opt_parse functions. Those are not fundamentally needed\n    without parseopt, but parseopt will need them.\n\n    Basically, diff_options had bitfields (the C :1 kind). parseopt cannot\n    grok that portably, so I've converted these into a single\n    `unsigned flags` with explicit masks to use (and helper macros to\n    avoid overlong lines).\n\n    The obvious goal is that I can use the OPTION_BIT feature from the\n    previous series to fill them from parse_options.\n\n    [1/2] Make the diff_options bitfields be an unsigned with explicit masks.\n    [2/2] Reorder diff_opt_parse options more logically per topics.\n\nThose patches are available on my public repository in the\nph/parseopt-stable branch.\n\nph/parseopt is my WIP and has many many horrible commits right now, that\nI rebase -i to cleanse them once the big picture pleases me enough,\nthough people may want to look at diff.h in that branch to see where it\ngoes. I'm pleased to say that it seems I'll only need 3 diff-specific\ncallbacks, which is not a lot:\n\n    http://git.madism.org/?p=git.git;a=blobdiff;f=diff.h;h=0e44e5;hp=6ff2b0;hb=def4eb;hpb=bdc1ab\n\nI suppose that the split of this big macro is explanatory enough for the\nreason behind commit 2/2 of the third series...\n\n\nDiff stats:\n~~~~~~~~~~\n\n  + gcc issue:\n     builtin-diff.c |    2 +-\n     1 file changed, 1 insertion(+), 1 deletion(-)\n\n  + parseopt features:\n     builtin-branch.c       |   44 ++++++++++++-----------------------\n     builtin-for-each-ref.c |   19 ++++++++-------\n     builtin-pack-refs.c    |   12 ++-------\n     git-compat-util.h      |    1 \n     parse-options.c        |   61 +++++++++++++++++++++++++++++++++++--------------\n     parse-options.h        |   15 +++++++++++-\n     6 files changed, 88 insertions(+), 64 deletions(-)\n\n  + diff-cleanup:\n     builtin-blame.c      |   10 +-\n     builtin-diff-files.c |    4 +-\n     builtin-diff-index.c |    4 +-\n     builtin-diff-tree.c  |    9 +-\n     builtin-diff.c       |   12 ++--\n     builtin-log.c        |   24 +++---\n     combine-diff.c       |   10 +-\n     diff-lib.c           |   23 +++---\n     diff.c               |  221 ++++++++++++++++++++++++++------------------------\n     diff.h               |   40 ++++++----\n     log-tree.c           |    6 +-\n     merge-recursive.c    |    2 +-\n     patch-ids.c          |    2 +-\n     revision.c           |   22 +++---\n     tree-diff.c          |   14 ++--\n     15 files changed, 209 insertions(+), 194 deletions(-)\n\n-- \nÂ·OÂ·  Pierre Habouzit\nÂ·Â·O                                                madcoder@debian.org\nOOO                                                http://www.madism.org\n"},{"id":"58657","messageId":"1194430832-6224-2-git-send-email-madcoder@debian.org","threadId":"10700","inReplyTo":"1194430832-6224-1-git-send-email-madcoder@debian.org","subject":"[PATCH MISC 1/1] Make gcc warning about empty if body go away.","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-07T10:20:26Z","receivedAt":"2007-11-07T10:20:26Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"Signed-off-by: Pierre Habouzit <madcoder@debian.org>\n---\n builtin-diff.c |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-diff.c b/builtin-diff.c\nindex f77352b..80392a8 100644\n--- a/builtin-diff.c\n+++ b/builtin-diff.c\n@@ -204,7 +204,7 @@ static void refresh_index_quietly(void)\n \t\tif (write_cache(fd, active_cache, active_nr) ||\n \t\t    close(fd) ||\n \t\t    commit_locked_index(lock_file))\n-\t\t\t; /*\n+\t\t\t(void)0; /*\n \t\t\t   * silently ignore it -- we haven't mucked\n \t\t\t   * with the real index.\n \t\t\t   */\n-- \n1.5.3.5.1598.gdef4e\n"},{"id":"58658","messageId":"1194430832-6224-3-git-send-email-madcoder@debian.org","threadId":"10700","inReplyTo":"1194430832-6224-2-git-send-email-madcoder@debian.org","subject":"[PATCH PARSEOPT 1/4] parse-options new features.","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-07T10:20:27Z","receivedAt":"2007-11-07T10:20:27Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"options flags:\n~~~~~~~~~~~~~\n  PARSE_OPT_NONEG allow the caller to disallow the negated option to exists.\n\noption types:\n~~~~~~~~~~~~\n  OPTION_BIT: ORs (or NANDs) a mask.\n  OPTION_SET_INT: force the value to be set to this integer.\n  OPTION_SET_PTR: force the value to be set to this pointer.\n\nhelper:\n~~~~~~\n  HAS_MULTI_BITS (in git-compat-util.h) is a bit-hack to check if an\n  unsigned integer has more than one bit set, useful to check if conflicting\n  options have been used.\n\nSigned-off-by: Pierre Habouzit <madcoder@debian.org>\n---\n git-compat-util.h |    1 +\n parse-options.c   |   61 ++++++++++++++++++++++++++++++++++++++--------------\n parse-options.h   |   15 ++++++++++++-\n 3 files changed, 59 insertions(+), 18 deletions(-)\n\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex 7b29d1b..f86b19f 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -20,6 +20,7 @@\n #endif\n \n #define MSB(x, bits) ((x) & TYPEOF(x)(~0ULL << (sizeof(x) * 8 - (bits))))\n+#define HAS_MULTI_BITS(i)  ((i) & ((i) - 1))  /* checks if an integer has more than 1 bit set */\n \n /* Approximation of the length of the decimal representation of this type. */\n #define decimal_length(x)\t((int)(sizeof(x) * 2.56 + 0.5) + 1)\ndiff --git a/parse-options.c b/parse-options.c\nindex 15b32f7..d3e608a 100644\n--- a/parse-options.c\n+++ b/parse-options.c\n@@ -40,24 +40,53 @@ static int get_value(struct optparse_t *p,\n                      const struct option *opt, int flags)\n {\n \tconst char *s, *arg;\n-\targ = p->opt ? p->opt : (p->argc > 1 ? p->argv[1] : NULL);\n+\tconst int unset = flags & OPT_UNSET;\n \n-\tif (p->opt && (flags & OPT_UNSET))\n+\tif (unset && p->opt)\n \t\treturn opterror(opt, \"takes no value\", flags);\n+\tif (unset && (opt->flags & PARSE_OPT_NONEG))\n+\t\treturn opterror(opt, \"isn't available\", flags);\n \n-\tswitch (opt->type) {\n-\tcase OPTION_BOOLEAN:\n-\t\tif (!(flags & OPT_SHORT) && p->opt)\n+\tif (!(flags & OPT_SHORT) && p->opt) {\n+\t\tswitch (opt->type) {\n+\t\tcase OPTION_CALLBACK:\n+\t\t\tif (!(opt->flags & PARSE_OPT_NOARG))\n+\t\t\t\tbreak;\n+\t\t\t/* FALLTHROUGH */\n+\t\tcase OPTION_BOOLEAN:\n+\t\tcase OPTION_BIT:\n+\t\tcase OPTION_SET_INT:\n+\t\tcase OPTION_SET_PTR:\n \t\t\treturn opterror(opt, \"takes no value\", flags);\n-\t\tif (flags & OPT_UNSET)\n-\t\t\t*(int *)opt->value = 0;\n+\t\tdefault:\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+\n+\targ = p->opt ? p->opt : (p->argc > 1 ? p->argv[1] : NULL);\n+\tswitch (opt->type) {\n+\tcase OPTION_BIT:\n+\t\tif (unset)\n+\t\t\t*(int *)opt->value &= ~opt->defval;\n \t\telse\n-\t\t\t(*(int *)opt->value)++;\n+\t\t\t*(int *)opt->value |= opt->defval;\n+\t\treturn 0;\n+\n+\tcase OPTION_BOOLEAN:\n+\t\t*(int *)opt->value = unset ? 0 : *(int *)opt->value + 1;\n+\t\treturn 0;\n+\n+\tcase OPTION_SET_INT:\n+\t\t*(int *)opt->value = unset ? 0 : opt->defval;\n+\t\treturn 0;\n+\n+\tcase OPTION_SET_PTR:\n+\t\t*(void **)opt->value = unset ? NULL : (void *)opt->defval;\n \t\treturn 0;\n \n \tcase OPTION_STRING:\n-\t\tif (flags & OPT_UNSET) {\n-\t\t\t*(const char **)opt->value = (const char *)NULL;\n+\t\tif (unset) {\n+\t\t\t*(const char **)opt->value = NULL;\n \t\t\treturn 0;\n \t\t}\n \t\tif (opt->flags & PARSE_OPT_OPTARG && (!arg || *arg == '-')) {\n@@ -70,13 +99,10 @@ static int get_value(struct optparse_t *p,\n \t\treturn 0;\n \n \tcase OPTION_CALLBACK:\n-\t\tif (flags & OPT_UNSET)\n+\t\tif (unset)\n \t\t\treturn (*opt->callback)(opt, NULL, 1);\n-\t\tif (opt->flags & PARSE_OPT_NOARG) {\n-\t\t\tif (p->opt && !(flags & OPT_SHORT))\n-\t\t\t\treturn opterror(opt, \"takes no value\", flags);\n+\t\tif (opt->flags & PARSE_OPT_NOARG)\n \t\t\treturn (*opt->callback)(opt, NULL, 0);\n-\t\t}\n \t\tif (opt->flags & PARSE_OPT_OPTARG && (!arg || *arg == '-'))\n \t\t\treturn (*opt->callback)(opt, NULL, 0);\n \t\tif (!arg)\n@@ -84,7 +110,7 @@ static int get_value(struct optparse_t *p,\n \t\treturn (*opt->callback)(opt, get_arg(p), 0);\n \n \tcase OPTION_INTEGER:\n-\t\tif (flags & OPT_UNSET) {\n+\t\tif (unset) {\n \t\t\t*(int *)opt->value = 0;\n \t\t\treturn 0;\n \t\t}\n@@ -292,7 +318,7 @@ void usage_with_options(const char * const *usagestr,\n \t\t\t\t\tpos += fprintf(stderr, \" ...\");\n \t\t\t}\n \t\t\tbreak;\n-\t\tdefault:\n+\t\tdefault: /* OPTION_{BIT,BOOLEAN,SET_INT,SET_PTR} */\n \t\t\tbreak;\n \t\t}\n \n@@ -311,6 +337,7 @@ void usage_with_options(const char * const *usagestr,\n \n /*----- some often used options -----*/\n #include \"cache.h\"\n+\n int parse_opt_abbrev_cb(const struct option *opt, const char *arg, int unset)\n {\n \tint v;\ndiff --git a/parse-options.h b/parse-options.h\nindex 65bce6e..a8760ac 100644\n--- a/parse-options.h\n+++ b/parse-options.h\n@@ -2,9 +2,15 @@\n #define PARSE_OPTIONS_H\n \n enum parse_opt_type {\n+\t/* special types */\n \tOPTION_END,\n \tOPTION_GROUP,\n-\tOPTION_BOOLEAN,\n+\t/* options with no arguments */\n+\tOPTION_BIT,\n+\tOPTION_BOOLEAN, /* _INCR would have been a better name */\n+\tOPTION_SET_INT,\n+\tOPTION_SET_PTR,\n+\t/* options with arguments (usually) */\n \tOPTION_STRING,\n \tOPTION_INTEGER,\n \tOPTION_CALLBACK,\n@@ -17,6 +23,7 @@ enum parse_opt_flags {\n enum parse_opt_option_flags {\n \tPARSE_OPT_OPTARG  = 1,\n \tPARSE_OPT_NOARG   = 2,\n+\tPARSE_OPT_NONEG   = 4,\n };\n \n struct option;\n@@ -49,12 +56,15 @@ typedef int parse_opt_cb(const struct option *, const char *arg, int unset);\n  *   mask of parse_opt_option_flags.\n  *   PARSE_OPT_OPTARG: says that the argument is optionnal (not for BOOLEANs)\n  *   PARSE_OPT_NOARG: says that this option takes no argument, for CALLBACKs\n+ *   PARSE_OPT_NONEG: says that this option cannot be negated\n  *\n  * `callback`::\n  *   pointer to the callback to use for OPTION_CALLBACK.\n  *\n  * `defval`::\n  *   default value to fill (*->value) with for PARSE_OPT_OPTARG.\n+ *   OPTION_{BIT,SET_INT,SET_PTR} store the {mask,integer,pointer} to put in\n+ *   the value when met.\n  *   CALLBACKS can use it like they want.\n  */\n struct option {\n@@ -72,7 +82,10 @@ struct option {\n \n #define OPT_END()                   { OPTION_END }\n #define OPT_GROUP(h)                { OPTION_GROUP, 0, NULL, NULL, NULL, (h) }\n+#define OPT_BIT(s, l, v, h, b)      { OPTION_BIT, (s), (l), (v), NULL, (h), 0, NULL, (b) }\n #define OPT_BOOLEAN(s, l, v, h)     { OPTION_BOOLEAN, (s), (l), (v), NULL, (h) }\n+#define OPT_SET_INT(s, l, v, h, i)  { OPTION_SET_INT, (s), (l), (v), NULL, (h), 0, NULL, (i) }\n+#define OPT_SET_PTR(s, l, v, h, p)  { OPTION_SET_PTR, (s), (l), (v), NULL, (h), 0, NULL, (p) }\n #define OPT_INTEGER(s, l, v, h)     { OPTION_INTEGER, (s), (l), (v), NULL, (h) }\n #define OPT_STRING(s, l, v, a, h)   { OPTION_STRING,  (s), (l), (v), (a), (h) }\n #define OPT_CALLBACK(s, l, v, a, h, f) \\\n-- \n1.5.3.5.1598.gdef4e\n"},{"id":"58660","messageId":"1194430832-6224-4-git-send-email-madcoder@debian.org","threadId":"10700","inReplyTo":"1194430832-6224-3-git-send-email-madcoder@debian.org","subject":"[PATCH PARSEOPT 2/4] Use OPT_SET_INT and OPT_BIT in builtin-branch","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-07T10:20:28Z","receivedAt":"2007-11-07T10:20:28Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"Also remove a spurious after-check on --abbrev (OPT__ABBREV already takes\ncare of that)\n---\n builtin-branch.c |   44 ++++++++++++++++----------------------------\n 1 files changed, 16 insertions(+), 28 deletions(-)\n\ndiff --git a/builtin-branch.c b/builtin-branch.c\nindex 3bf40f1..2694c9c 100644\n--- a/builtin-branch.c\n+++ b/builtin-branch.c\n@@ -507,48 +507,36 @@ static void rename_branch(const char *oldname, const char *newname, int force)\n \n int cmd_branch(int argc, const char **argv, const char *prefix)\n {\n-\tint delete = 0, force_delete = 0, force_create = 0;\n-\tint rename = 0, force_rename = 0;\n+\tint delete = 0, rename = 0, force_create = 0;\n \tint verbose = 0, abbrev = DEFAULT_ABBREV, detached = 0;\n \tint reflog = 0, track;\n-\tint kinds = REF_LOCAL_BRANCH, kind_remote = 0, kind_any = 0;\n+\tint kinds = REF_LOCAL_BRANCH;\n \n \tstruct option options[] = {\n \t\tOPT_GROUP(\"Generic options\"),\n \t\tOPT__VERBOSE(&verbose),\n \t\tOPT_BOOLEAN( 0 , \"track\",  &track, \"set up tracking mode (see git-pull(1))\"),\n \t\tOPT_BOOLEAN( 0 , \"color\",  &branch_use_color, \"use colored output\"),\n-\t\tOPT_BOOLEAN('r', NULL,     &kind_remote, \"act on remote-tracking branches\"),\n+\t\tOPT_SET_INT('r', NULL,     &kinds, \"act on remote-tracking branches\",\n+\t\t\tREF_REMOTE_BRANCH),\n \t\tOPT__ABBREV(&abbrev),\n \n \t\tOPT_GROUP(\"Specific git-branch actions:\"),\n-\t\tOPT_BOOLEAN('a', NULL,     &kind_any, \"list both remote-tracking and local branches\"),\n-\t\tOPT_BOOLEAN('d', NULL,     &delete, \"delete fully merged branch\"),\n-\t\tOPT_BOOLEAN('D', NULL,     &force_delete, \"delete branch (even if not merged)\"),\n-\t\tOPT_BOOLEAN('l', NULL,     &reflog, \"create the branch's reflog\"),\n-\t\tOPT_BOOLEAN('f', NULL,     &force_create, \"force creation (when already exists)\"),\n-\t\tOPT_BOOLEAN('m', NULL,     &rename, \"move/rename a branch and its reflog\"),\n-\t\tOPT_BOOLEAN('M', NULL,     &force_rename, \"move/rename a branch, even if target exists\"),\n+\t\tOPT_SET_INT('a', NULL, &kinds, \"list both remote-tracking and local branches\",\n+\t\t\tREF_REMOTE_BRANCH | REF_LOCAL_BRANCH),\n+\t\tOPT_BIT('d', NULL, &delete, \"delete fully merged branch\", 1),\n+\t\tOPT_BIT('D', NULL, &delete, \"delete branch (even if not merged)\", 2),\n+\t\tOPT_BIT('m', NULL, &rename, \"move/rename a branch and its reflog\", 1),\n+\t\tOPT_BIT('M', NULL, &rename, \"move/rename a branch, even if target exists\", 2),\n+\t\tOPT_BOOLEAN('l', NULL, &reflog, \"create the branch's reflog\"),\n+\t\tOPT_BOOLEAN('f', NULL, &force_create, \"force creation (when already exists)\"),\n \t\tOPT_END(),\n \t};\n \n \tgit_config(git_branch_config);\n \ttrack = branch_track;\n \targc = parse_options(argc, argv, options, builtin_branch_usage, 0);\n-\n-\tdelete |= force_delete;\n-\trename |= force_rename;\n-\tif (kind_remote)\n-\t\tkinds = REF_REMOTE_BRANCH;\n-\tif (kind_any)\n-\t\tkinds = REF_REMOTE_BRANCH | REF_LOCAL_BRANCH;\n-\tif (abbrev && abbrev < MINIMUM_ABBREV)\n-\t\tabbrev = MINIMUM_ABBREV;\n-\telse if (abbrev > 40)\n-\t\tabbrev = 40;\n-\n-\tif ((delete && rename) || (delete && force_create) ||\n-\t    (rename && force_create))\n+\tif (!!delete + !!rename + !!force_create > 1)\n \t\tusage_with_options(builtin_branch_usage, options);\n \n \thead = resolve_ref(\"HEAD\", head_sha1, 0, NULL);\n@@ -564,13 +552,13 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n \t}\n \n \tif (delete)\n-\t\treturn delete_branches(argc, argv, force_delete, kinds);\n+\t\treturn delete_branches(argc, argv, delete > 1, kinds);\n \telse if (argc == 0)\n \t\tprint_ref_list(kinds, detached, verbose, abbrev);\n \telse if (rename && (argc == 1))\n-\t\trename_branch(head, argv[0], force_rename);\n+\t\trename_branch(head, argv[0], rename > 1);\n \telse if (rename && (argc == 2))\n-\t\trename_branch(argv[0], argv[1], force_rename);\n+\t\trename_branch(argv[0], argv[1], rename > 1);\n \telse if (argc <= 2)\n \t\tcreate_branch(argv[0], (argc == 2) ? argv[1] : head,\n \t\t\t      force_create, reflog, track);\n-- \n1.5.3.5.1598.gdef4e\n"},{"id":"58659","messageId":"1194430832-6224-5-git-send-email-madcoder@debian.org","threadId":"10700","inReplyTo":"1194430832-6224-4-git-send-email-madcoder@debian.org","subject":"[PATCH PARSEOPT 3/4] Use OPT_BIT in builtin-for-each-ref","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-07T10:20:29Z","receivedAt":"2007-11-07T10:20:29Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"---\n builtin-for-each-ref.c |   19 ++++++++++---------\n 1 files changed, 10 insertions(+), 9 deletions(-)\n\ndiff --git a/builtin-for-each-ref.c b/builtin-for-each-ref.c\nindex da8c794..1a23ea6 100644\n--- a/builtin-for-each-ref.c\n+++ b/builtin-for-each-ref.c\n@@ -833,16 +833,19 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix)\n \tint i, num_refs;\n \tconst char *format = \"%(objectname) %(objecttype)\\t%(refname)\";\n \tstruct ref_sort *sort = NULL, **sort_tail = &sort;\n-\tint maxcount = 0, quote_style;\n-\tint quote_shell = 0, quote_perl = 0, quote_python = 0, quote_tcl = 0;\n+\tint maxcount = 0, quote_style = 0;\n \tstruct refinfo **refs;\n \tstruct grab_ref_cbdata cbdata;\n \n \tstruct option opts[] = {\n-\t\tOPT_BOOLEAN('s', \"shell\", &quote_shell, \"quote placeholders suitably for shells\"),\n-\t\tOPT_BOOLEAN('p', \"perl\",  &quote_perl, \"quote placeholders suitably for perl\"),\n-\t\tOPT_BOOLEAN( 0 , \"python\", &quote_python, \"quote placeholders suitably for python\"),\n-\t\tOPT_BOOLEAN( 0 , \"tcl\",  &quote_tcl, \"quote placeholders suitably for tcl\"),\n+\t\tOPT_BIT('s', \"shell\", &quote_style,\n+\t\t        \"quote placeholders suitably for shells\", QUOTE_SHELL),\n+\t\tOPT_BIT('p', \"perl\",  &quote_style,\n+\t\t        \"quote placeholders suitably for perl\", QUOTE_PERL),\n+\t\tOPT_BIT(0 , \"python\", &quote_style,\n+\t\t        \"quote placeholders suitably for python\", QUOTE_PYTHON),\n+\t\tOPT_BIT(0 , \"tcl\",  &quote_style,\n+\t\t        \"quote placeholders suitably for tcl\", QUOTE_TCL),\n \n \t\tOPT_GROUP(\"\"),\n \t\tOPT_INTEGER( 0 , \"count\", &maxcount, \"show only <n> matched refs\"),\n@@ -857,15 +860,13 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix)\n \t\terror(\"invalid --count argument: `%d'\", maxcount);\n \t\tusage_with_options(for_each_ref_usage, opts);\n \t}\n-\tif (quote_shell + quote_perl + quote_python + quote_tcl > 1) {\n+\tif (HAS_MULTI_BITS(quote_style)) {\n \t\terror(\"more than one quoting style ?\");\n \t\tusage_with_options(for_each_ref_usage, opts);\n \t}\n \tif (verify_format(format))\n \t\tusage_with_options(for_each_ref_usage, opts);\n \n-\tquote_style = QUOTE_SHELL * quote_shell + QUOTE_PERL * quote_perl +\n-\t\tQUOTE_PYTHON * quote_python + QUOTE_TCL * quote_tcl;\n \tif (!sort)\n \t\tsort = default_sort();\n \tsort_atom_limit = used_atom_cnt;\n-- \n1.5.3.5.1598.gdef4e\n"},{"id":"58662","messageId":"1194430832-6224-6-git-send-email-madcoder@debian.org","threadId":"10700","inReplyTo":"1194430832-6224-5-git-send-email-madcoder@debian.org","subject":"[PATCH PARSEOPT 4/4] Use OPT_BIT in builtin-pack-refs","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-07T10:20:30Z","receivedAt":"2007-11-07T10:20:30Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"---\n builtin-pack-refs.c |   12 +++---------\n 1 files changed, 3 insertions(+), 9 deletions(-)\n\ndiff --git a/builtin-pack-refs.c b/builtin-pack-refs.c\nindex a62f06b..1923fb1 100644\n--- a/builtin-pack-refs.c\n+++ b/builtin-pack-refs.c\n@@ -122,19 +122,13 @@ static char const * const pack_refs_usage[] = {\n \n int cmd_pack_refs(int argc, const char **argv, const char *prefix)\n {\n-\tint all = 0, prune = 1;\n-\tunsigned int flags = 0;\n+\tunsigned int flags = PACK_REFS_PRUNE;\n \tstruct option opts[] = {\n-\t\tOPT_BOOLEAN(0, \"all\", &all, \"pack everything\"),\n-\t\tOPT_BOOLEAN(0, \"prune\", &prune, \"prune loose refs (default)\"),\n+\t\tOPT_BIT(0, \"all\",   &flags, \"pack everything\", PACK_REFS_ALL),\n+\t\tOPT_BIT(0, \"prune\", &flags, \"prune loose refs (default)\", PACK_REFS_PRUNE),\n \t\tOPT_END(),\n \t};\n-\n \tif (parse_options(argc, argv, opts, pack_refs_usage, 0))\n \t\tusage_with_options(pack_refs_usage, opts);\n-\tif (prune)\n-\t\tflags |= PACK_REFS_PRUNE;\n-\tif (all)\n-\t\tflags |= PACK_REFS_ALL;\n \treturn pack_refs(flags);\n }\n-- \n1.5.3.5.1598.gdef4e\n"},{"id":"58664","messageId":"1194430832-6224-7-git-send-email-madcoder@debian.org","threadId":"10700","inReplyTo":"1194430832-6224-6-git-send-email-madcoder@debian.org","subject":"[PATCH DIFF-CLEANUP 1/2] Make the diff_options bitfields be an unsigned with explicit masks.","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-07T10:20:31Z","receivedAt":"2007-11-07T10:20:31Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"reverse_diff was a bit-value in disguise, it's merged in the flags now.\n\nSigned-off-by: Pierre Habouzit <madcoder@debian.org>\n---\n builtin-blame.c      |   10 ++--\n builtin-diff-files.c |    4 +-\n builtin-diff-index.c |    4 +-\n builtin-diff-tree.c  |    9 ++--\n builtin-diff.c       |   12 +++---\n builtin-log.c        |   24 ++++------\n combine-diff.c       |   10 ++--\n diff-lib.c           |   23 +++++-----\n diff.c               |  123 ++++++++++++++++++++++++-------------------------\n diff.h               |   40 ++++++++++-------\n log-tree.c           |    6 +--\n merge-recursive.c    |    2 +-\n patch-ids.c          |    2 +-\n revision.c           |   22 +++++-----\n tree-diff.c          |   14 +++---\n 15 files changed, 155 insertions(+), 150 deletions(-)\n\ndiff --git a/builtin-blame.c b/builtin-blame.c\nindex 55a3c0b..eaf9c15 100644\n--- a/builtin-blame.c\n+++ b/builtin-blame.c\n@@ -335,7 +335,7 @@ static struct origin *find_origin(struct scoreboard *sb,\n \t * same and diff-tree is fairly efficient about this.\n \t */\n \tdiff_setup(&diff_opts);\n-\tdiff_opts.recursive = 1;\n+\tDIFF_OPT_SET(&diff_opts, RECURSIVE);\n \tdiff_opts.detect_rename = 0;\n \tdiff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;\n \tpaths[0] = origin->path;\n@@ -409,7 +409,7 @@ static struct origin *find_rename(struct scoreboard *sb,\n \tconst char *paths[2];\n \n \tdiff_setup(&diff_opts);\n-\tdiff_opts.recursive = 1;\n+\tDIFF_OPT_SET(&diff_opts, RECURSIVE);\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@@ -1075,7 +1075,7 @@ static int find_copy_in_parent(struct scoreboard *sb,\n \t\treturn 1; /* nothing remains for this target */\n \n \tdiff_setup(&diff_opts);\n-\tdiff_opts.recursive = 1;\n+\tDIFF_OPT_SET(&diff_opts, RECURSIVE);\n \tdiff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;\n \n \tpaths[0] = NULL;\n@@ -1093,7 +1093,7 @@ static int find_copy_in_parent(struct 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.find_copies_harder = 1;\n+\t\tDIFF_OPT_SET(&diff_opts, FIND_COPIES_HARDER);\n \n \tif (is_null_sha1(target->commit->object.sha1))\n \t\tdo_diff_cache(parent->tree->object.sha1, &diff_opts);\n@@ -1102,7 +1102,7 @@ static int find_copy_in_parent(struct scoreboard *sb,\n \t\t\t       target->commit->tree->object.sha1,\n \t\t\t       \"\", &diff_opts);\n \n-\tif (!diff_opts.find_copies_harder)\n+\tif (!DIFF_OPT_TST(&diff_opts, FIND_COPIES_HARDER))\n \t\tdiffcore_std(&diff_opts);\n \n \tretval = 0;\ndiff --git a/builtin-diff-files.c b/builtin-diff-files.c\nindex 6cb30c8..046b7e3 100644\n--- a/builtin-diff-files.c\n+++ b/builtin-diff-files.c\n@@ -31,5 +31,7 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix)\n \tif (!rev.diffopt.output_format)\n \t\trev.diffopt.output_format = DIFF_FORMAT_RAW;\n \tresult = run_diff_files_cmd(&rev, argc, argv);\n-\treturn rev.diffopt.exit_with_status ? rev.diffopt.has_changes: result;\n+\tif (DIFF_OPT_TST(&rev.diffopt, EXIT_WITH_STATUS))\n+\t\treturn DIFF_OPT_TST(&rev.diffopt, HAS_CHANGES) != 0;\n+\treturn result;\n }\ndiff --git a/builtin-diff-index.c b/builtin-diff-index.c\nindex 81e7167..556c506 100644\n--- a/builtin-diff-index.c\n+++ b/builtin-diff-index.c\n@@ -44,5 +44,7 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix)\n \t\treturn -1;\n \t}\n \tresult = run_diff_index(&rev, cached);\n-\treturn rev.diffopt.exit_with_status ? rev.diffopt.has_changes: result;\n+\tif (DIFF_OPT_TST(&rev.diffopt, EXIT_WITH_STATUS))\n+\t\treturn DIFF_OPT_TST(&rev.diffopt, HAS_CHANGES) != 0;\n+\treturn result;\n }\ndiff --git a/builtin-diff-tree.c b/builtin-diff-tree.c\nindex 0b591c8..e71841a 100644\n--- a/builtin-diff-tree.c\n+++ b/builtin-diff-tree.c\n@@ -118,12 +118,12 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)\n \t}\n \n \tif (!read_stdin)\n-\t\treturn opt->diffopt.exit_with_status ?\n-\t\t    opt->diffopt.has_changes: 0;\n+\t\treturn DIFF_OPT_TST(&opt->diffopt, EXIT_WITH_STATUS)\n+\t\t\t&& DIFF_OPT_TST(&opt->diffopt, HAS_CHANGES);\n \n \tif (opt->diffopt.detect_rename)\n \t\topt->diffopt.setup |= (DIFF_SETUP_USE_SIZE_CACHE |\n-\t\t\t\t       DIFF_SETUP_USE_CACHE);\n+\t\t\t\t\t\t\t   DIFF_SETUP_USE_CACHE);\n \twhile (fgets(line, sizeof(line), stdin)) {\n \t\tunsigned char sha1[20];\n \n@@ -134,5 +134,6 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)\n \t\telse\n \t\t\tdiff_tree_stdin(line);\n \t}\n-\treturn opt->diffopt.exit_with_status ? opt->diffopt.has_changes: 0;\n+\treturn DIFF_OPT_TST(&opt->diffopt, EXIT_WITH_STATUS)\n+\t\t&& DIFF_OPT_TST(&opt->diffopt, HAS_CHANGES);\n }\ndiff --git a/builtin-diff.c b/builtin-diff.c\nindex 80392a8..59b9c6e 100644\n--- a/builtin-diff.c\n+++ b/builtin-diff.c\n@@ -35,7 +35,7 @@ static void stuff_change(struct diff_options *opt,\n \t    !hashcmp(old_sha1, new_sha1) && (old_mode == new_mode))\n \t\treturn;\n \n-\tif (opt->reverse_diff) {\n+\tif (DIFF_OPT_TST(opt, REVERSE_DIFF)) {\n \t\tunsigned tmp;\n \t\tconst unsigned char *tmp_u;\n \t\tconst char *tmp_c;\n@@ -257,13 +257,13 @@ int cmd_diff(int argc, const char **argv, const char *prefix)\n \t\tif (diff_setup_done(&rev.diffopt) < 0)\n \t\t\tdie(\"diff_setup_done failed\");\n \t}\n-\trev.diffopt.allow_external = 1;\n-\trev.diffopt.recursive = 1;\n+\tDIFF_OPT_SET(&rev.diffopt, ALLOW_EXTERNAL);\n+\tDIFF_OPT_SET(&rev.diffopt, RECURSIVE);\n \n \t/* If the user asked for our exit code then don't start a\n \t * pager or we would end up reporting its exit code instead.\n \t */\n-\tif (!rev.diffopt.exit_with_status)\n+\tif (!DIFF_OPT_TST(&rev.diffopt, EXIT_WITH_STATUS))\n \t\tsetup_pager();\n \n \t/* Do we have --cached and not have a pending object, then\n@@ -367,8 +367,8 @@ int cmd_diff(int argc, const char **argv, const char *prefix)\n \telse\n \t\tresult = builtin_diff_combined(&rev, argc, argv,\n \t\t\t\t\t     ent, ents);\n-\tif (rev.diffopt.exit_with_status)\n-\t\tresult = rev.diffopt.has_changes;\n+\tif (DIFF_OPT_TST(&rev.diffopt, EXIT_WITH_STATUS))\n+\t\tresult = DIFF_OPT_TST(&rev.diffopt, HAS_CHANGES) != 0;\n \n \tif (1 < rev.diffopt.skip_stat_unmatch)\n \t\trefresh_index_quietly();\ndiff --git a/builtin-log.c b/builtin-log.c\nindex b6ca04a..72745cd 100644\n--- a/builtin-log.c\n+++ b/builtin-log.c\n@@ -55,13 +55,13 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,\n \trev->abbrev = DEFAULT_ABBREV;\n \trev->commit_format = CMIT_FMT_DEFAULT;\n \trev->verbose_header = 1;\n-\trev->diffopt.recursive = 1;\n+\tDIFF_OPT_SET(&rev->diffopt, RECURSIVE);\n \trev->show_root_diff = default_show_root;\n \trev->subject_prefix = fmt_patch_subject_prefix;\n \targc = setup_revisions(argc, argv, rev, \"HEAD\");\n \tif (rev->diffopt.pickaxe || rev->diffopt.filter)\n \t\trev->always_show_header = 0;\n-\tif (rev->diffopt.follow_renames) {\n+\tif (DIFF_OPT_TST(&rev->diffopt, FOLLOW_RENAMES)) {\n \t\trev->always_show_header = 0;\n \t\tif (rev->diffopt.nr_paths != 1)\n \t\t\tusage(\"git logs can only follow renames on one pathname at a time\");\n@@ -308,11 +308,9 @@ int cmd_show(int argc, const char **argv, const char *prefix)\n \t\t\tstruct tag *t = (struct tag *)o;\n \n \t\t\tprintf(\"%stag %s%s\\n\\n\",\n-\t\t\t\t\tdiff_get_color(rev.diffopt.color_diff,\n-\t\t\t\t\t\tDIFF_COMMIT),\n+\t\t\t\t\tdiff_get_color_opt(&rev.diffopt, DIFF_COMMIT),\n \t\t\t\t\tt->tag,\n-\t\t\t\t\tdiff_get_color(rev.diffopt.color_diff,\n-\t\t\t\t\t\tDIFF_RESET));\n+\t\t\t\t\tdiff_get_color_opt(&rev.diffopt, DIFF_RESET));\n \t\t\tret = show_object(o->sha1, 1);\n \t\t\tobjects[i].item = (struct object *)t->tagged;\n \t\t\ti--;\n@@ -320,11 +318,9 @@ int cmd_show(int argc, const char **argv, const char *prefix)\n \t\t}\n \t\tcase OBJ_TREE:\n \t\t\tprintf(\"%stree %s%s\\n\\n\",\n-\t\t\t\t\tdiff_get_color(rev.diffopt.color_diff,\n-\t\t\t\t\t\tDIFF_COMMIT),\n+\t\t\t\t\tdiff_get_color_opt(&rev.diffopt, DIFF_COMMIT),\n \t\t\t\t\tname,\n-\t\t\t\t\tdiff_get_color(rev.diffopt.color_diff,\n-\t\t\t\t\t\tDIFF_RESET));\n+\t\t\t\t\tdiff_get_color_opt(&rev.diffopt, DIFF_RESET));\n \t\t\tread_tree_recursive((struct tree *)o, \"\", 0, 0, NULL,\n \t\t\t\t\tshow_tree_object);\n \t\t\tbreak;\n@@ -620,7 +616,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \trev.combine_merges = 0;\n \trev.ignore_merges = 1;\n \trev.diffopt.msg_sep = \"\";\n-\trev.diffopt.recursive = 1;\n+\tDIFF_OPT_SET(&rev.diffopt, RECURSIVE);\n \n \trev.subject_prefix = fmt_patch_subject_prefix;\n \trev.extra_headers = extra_headers;\n@@ -728,8 +724,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \tif (!rev.diffopt.output_format)\n \t\trev.diffopt.output_format = DIFF_FORMAT_DIFFSTAT | DIFF_FORMAT_SUMMARY | DIFF_FORMAT_PATCH;\n \n-\tif (!rev.diffopt.text)\n-\t\trev.diffopt.binary = 1;\n+\tif (!DIFF_OPT_TST(&rev.diffopt, TEXT))\n+\t\tDIFF_OPT_SET(&rev.diffopt, BINARY);\n \n \tif (!output_directory && !use_stdout)\n \t\toutput_directory = prefix;\n@@ -887,7 +883,7 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)\n \trevs.diff = 1;\n \trevs.combine_merges = 0;\n \trevs.ignore_merges = 1;\n-\trevs.diffopt.recursive = 1;\n+\tDIFF_OPT_SET(&revs.diffopt, RECURSIVE);\n \n \tif (add_pending_commit(head, &revs, 0))\n \t\tdie(\"Unknown commit %s\", head);\ndiff --git a/combine-diff.c b/combine-diff.c\nindex fe5a2a1..3cab04b 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -664,7 +664,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,\n \tint mode_differs = 0;\n \tint i, show_hunks;\n \tint working_tree_file = is_null_sha1(elem->sha1);\n-\tint abbrev = opt->full_index ? 40 : DEFAULT_ABBREV;\n+        int abbrev = DIFF_OPT_TST(opt, FULL_INDEX) ? 40 : DEFAULT_ABBREV;\n \tmmfile_t result_file;\n \n \tcontext = opt->context;\n@@ -784,7 +784,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,\n \n \tif (show_hunks || mode_differs || working_tree_file) {\n \t\tconst char *abb;\n-\t\tint use_color = opt->color_diff;\n+\t\tint use_color = DIFF_OPT_TST(opt, COLOR_DIFF);\n \t\tconst char *c_meta = diff_get_color(use_color, DIFF_METAINFO);\n \t\tconst char *c_reset = diff_get_color(use_color, DIFF_RESET);\n \t\tint added = 0;\n@@ -836,7 +836,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,\n \t\t\tdump_quoted_path(\"+++ /dev/\", \"null\", c_meta, c_reset);\n \t\telse\n \t\t\tdump_quoted_path(\"+++ b/\", elem->path, c_meta, c_reset);\n-\t\tdump_sline(sline, cnt, num_parent, opt->color_diff);\n+\t\tdump_sline(sline, cnt, num_parent, DIFF_OPT_TST(opt, COLOR_DIFF));\n \t}\n \tfree(result);\n \n@@ -929,8 +929,8 @@ void diff_tree_combined(const unsigned char *sha1,\n \n \tdiffopts = *opt;\n \tdiffopts.output_format = DIFF_FORMAT_NO_OUTPUT;\n-\tdiffopts.recursive = 1;\n-\tdiffopts.allow_external = 0;\n+\tDIFF_OPT_SET(&diffopts, RECURSIVE);\n+\tDIFF_OPT_CLR(&diffopts, ALLOW_EXTERNAL);\n \n \tshow_log_first = !!rev->loginfo && !rev->no_commit_id;\n \tneedsep = 0;\ndiff --git a/diff-lib.c b/diff-lib.c\nindex da55713..69b5dc9 100644\n--- a/diff-lib.c\n+++ b/diff-lib.c\n@@ -121,7 +121,7 @@ static int queue_diff(struct diff_options *o,\n \t} else {\n \t\tstruct diff_filespec *d1, *d2;\n \n-\t\tif (o->reverse_diff) {\n+\t\tif (DIFF_OPT_TST(o, REVERSE_DIFF)) {\n \t\t\tunsigned tmp;\n \t\t\tconst char *tmp_c;\n \t\t\ttmp = mode1; mode1 = mode2; mode2 = tmp;\n@@ -188,8 +188,7 @@ static int handle_diff_files_args(struct rev_info *revs,\n \t\telse if (!strcmp(argv[1], \"-n\") ||\n \t\t\t\t!strcmp(argv[1], \"--no-index\")) {\n \t\t\trevs->max_count = -2;\n-\t\t\trevs->diffopt.exit_with_status = 1;\n-\t\t\trevs->diffopt.no_index = 1;\n+\t\t\trevs->diffopt.flags |= DIFF_OPT_EXIT_WITH_STATUS | DIFF_OPT_NO_INDEX;\n \t\t}\n \t\telse if (!strcmp(argv[1], \"-q\"))\n \t\t\t*silent = 1;\n@@ -207,7 +206,7 @@ static int handle_diff_files_args(struct rev_info *revs,\n \t\tif (!is_in_index(revs->diffopt.paths[0]) ||\n \t\t\t\t\t!is_in_index(revs->diffopt.paths[1])) {\n \t\t\trevs->max_count = -2;\n-\t\t\trevs->diffopt.no_index = 1;\n+\t\t\tDIFF_OPT_SET(&revs->diffopt, NO_INDEX);\n \t\t}\n \t}\n \n@@ -258,7 +257,7 @@ int setup_diff_no_index(struct rev_info *revs,\n \t\t\tbreak;\n \t\t} else if (i < argc - 3 && !strcmp(argv[i], \"--no-index\")) {\n \t\t\ti = argc - 3;\n-\t\t\trevs->diffopt.exit_with_status = 1;\n+\t\t\tDIFF_OPT_SET(&revs->diffopt, EXIT_WITH_STATUS);\n \t\t\tbreak;\n \t\t}\n \tif (argc != i + 2 || (!is_outside_repo(argv[i + 1], nongit, prefix) &&\n@@ -296,7 +295,7 @@ int setup_diff_no_index(struct rev_info *revs,\n \telse\n \t\trevs->diffopt.paths = argv + argc - 2;\n \trevs->diffopt.nr_paths = 2;\n-\trevs->diffopt.no_index = 1;\n+\tDIFF_OPT_SET(&revs->diffopt, NO_INDEX);\n \trevs->max_count = -2;\n \tif (diff_setup_done(&revs->diffopt) < 0)\n \t\tdie(\"diff_setup_done failed\");\n@@ -310,7 +309,7 @@ int run_diff_files_cmd(struct rev_info *revs, int argc, const char **argv)\n \tif (handle_diff_files_args(revs, argc, argv, &silent_on_removed))\n \t\treturn -1;\n \n-\tif (revs->diffopt.no_index) {\n+\tif (DIFF_OPT_TST(&revs->diffopt, NO_INDEX)) {\n \t\tif (revs->diffopt.nr_paths != 2)\n \t\t\treturn error(\"need two files/directories with --no-index\");\n \t\tif (queue_diff(&revs->diffopt, revs->diffopt.paths[0],\n@@ -346,7 +345,8 @@ int run_diff_files(struct rev_info *revs, int silent_on_removed)\n \t\tstruct cache_entry *ce = active_cache[i];\n \t\tint changed;\n \n-\t\tif (revs->diffopt.quiet && revs->diffopt.has_changes)\n+\t\tif (DIFF_OPT_TST(&revs->diffopt, QUIET) &&\n+\t\t\tDIFF_OPT_TST(&revs->diffopt, HAS_CHANGES))\n \t\t\tbreak;\n \n \t\tif (!ce_path_match(ce, revs->prune_data))\n@@ -442,7 +442,7 @@ int run_diff_files(struct rev_info *revs, int silent_on_removed)\n \t\t\tcontinue;\n \t\t}\n \t\tchanged = ce_match_stat(ce, &st, 0);\n-\t\tif (!changed && !revs->diffopt.find_copies_harder)\n+\t\tif (!changed && !DIFF_OPT_TST(&revs->diffopt, FIND_COPIES_HARDER))\n \t\t\tcontinue;\n \t\toldmode = ntohl(ce->ce_mode);\n \t\tnewmode = ntohl(ce_mode_from_stat(ce, st.st_mode));\n@@ -561,7 +561,7 @@ static int show_modified(struct rev_info *revs,\n \n \toldmode = old->ce_mode;\n \tif (mode == oldmode && !hashcmp(sha1, old->sha1) &&\n-\t    !revs->diffopt.find_copies_harder)\n+\t    !DIFF_OPT_TST(&revs->diffopt, FIND_COPIES_HARDER))\n \t\treturn 0;\n \n \tmode = ntohl(mode);\n@@ -581,7 +581,8 @@ static int diff_cache(struct rev_info *revs,\n \t\tstruct cache_entry *ce = *ac;\n \t\tint same = (entries > 1) && ce_same_name(ce, ac[1]);\n \n-\t\tif (revs->diffopt.quiet && revs->diffopt.has_changes)\n+\t\tif (DIFF_OPT_TST(&revs->diffopt, QUIET) &&\n+\t\t\tDIFF_OPT_TST(&revs->diffopt, HAS_CHANGES))\n \t\t\tbreak;\n \n \t\tif (!ce_path_match(ce, pathspec))\ndiff --git a/diff.c b/diff.c\nindex 6bb902f..97c9a59 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -827,10 +827,10 @@ static void show_stats(struct diffstat_t* data, struct diff_options *options)\n \t}\n \n \t/* Find the longest filename and max number of changes */\n-\treset = diff_get_color(options->color_diff, DIFF_RESET);\n-\tset = diff_get_color(options->color_diff, DIFF_PLAIN);\n-\tadd_c = diff_get_color(options->color_diff, DIFF_FILE_NEW);\n-\tdel_c = diff_get_color(options->color_diff, DIFF_FILE_OLD);\n+\treset = diff_get_color_opt(options, DIFF_RESET);\n+\tset   = diff_get_color_opt(options, DIFF_PLAIN);\n+\tadd_c = diff_get_color_opt(options, DIFF_FILE_NEW);\n+\tdel_c = diff_get_color_opt(options, DIFF_FILE_OLD);\n \n \tfor (i = 0; i < data->nr; i++) {\n \t\tstruct diffstat_file *file = data->files[i];\n@@ -1256,8 +1256,8 @@ static void builtin_diff(const char *name_a,\n \tmmfile_t mf1, mf2;\n \tconst char *lbl[2];\n \tchar *a_one, *b_two;\n-\tconst char *set = diff_get_color(o->color_diff, DIFF_METAINFO);\n-\tconst char *reset = diff_get_color(o->color_diff, DIFF_RESET);\n+\tconst char *set = diff_get_color_opt(o, DIFF_METAINFO);\n+\tconst char *reset = diff_get_color_opt(o, DIFF_RESET);\n \n \ta_one = quote_two(\"a/\", name_a + (*name_a == '/'));\n \tb_two = quote_two(\"b/\", name_b + (*name_b == '/'));\n@@ -1290,7 +1290,7 @@ static void builtin_diff(const char *name_a,\n \t\t\tgoto free_ab_and_return;\n \t\tif (complete_rewrite) {\n \t\t\temit_rewrite_diff(name_a, name_b, one, two,\n-\t\t\t\t\to->color_diff);\n+\t\t\t\t\tDIFF_OPT_TST(o, COLOR_DIFF));\n \t\t\to->found_changes = 1;\n \t\t\tgoto free_ab_and_return;\n \t\t}\n@@ -1299,13 +1299,13 @@ static void builtin_diff(const char *name_a,\n \tif (fill_mmfile(&mf1, one) < 0 || fill_mmfile(&mf2, two) < 0)\n \t\tdie(\"unable to read files to diff\");\n \n-\tif (!o->text &&\n+\tif (!DIFF_OPT_TST(o, TEXT) &&\n \t    (diff_filespec_is_binary(one) || diff_filespec_is_binary(two))) {\n \t\t/* Quite common confusing case */\n \t\tif (mf1.size == mf2.size &&\n \t\t    !memcmp(mf1.ptr, mf2.ptr, mf1.size))\n \t\t\tgoto free_ab_and_return;\n-\t\tif (o->binary)\n+\t\tif (DIFF_OPT_TST(o, BINARY))\n \t\t\temit_binary_diff(&mf1, &mf2);\n \t\telse\n \t\t\tprintf(\"Binary files %s and %s differ\\n\",\n@@ -1328,7 +1328,7 @@ static void builtin_diff(const char *name_a,\n \t\tmemset(&xecfg, 0, sizeof(xecfg));\n \t\tmemset(&ecbdata, 0, sizeof(ecbdata));\n \t\tecbdata.label_path = lbl;\n-\t\tecbdata.color_diff = o->color_diff;\n+\t\tecbdata.color_diff = DIFF_OPT_TST(o, COLOR_DIFF);\n \t\tecbdata.found_changesp = &o->found_changes;\n \t\txpp.flags = XDF_NEED_MINIMAL | o->xdl_opts;\n \t\txecfg.ctxlen = o->context;\n@@ -1344,11 +1344,11 @@ static void builtin_diff(const char *name_a,\n \t\tecb.outf = xdiff_outf;\n \t\tecb.priv = &ecbdata;\n \t\tecbdata.xm.consume = fn_out_consume;\n-\t\tif (o->color_diff_words)\n+\t\tif (DIFF_OPT_TST(o, COLOR_DIFF_WORDS))\n \t\t\tecbdata.diff_words =\n \t\t\t\txcalloc(1, sizeof(struct diff_words_data));\n \t\txdl_diff(&mf1, &mf2, &xpp, &xecfg, &ecb);\n-\t\tif (o->color_diff_words)\n+\t\tif (DIFF_OPT_TST(o, COLOR_DIFF_WORDS))\n \t\t\tfree_diff_words_data(&ecbdata);\n \t}\n \n@@ -1422,7 +1422,7 @@ static void builtin_checkdiff(const char *name_a, const char *name_b,\n \tdata.xm.consume = checkdiff_consume;\n \tdata.filename = name_b ? name_b : name_a;\n \tdata.lineno = 0;\n-\tdata.color_diff = o->color_diff;\n+\tdata.color_diff = DIFF_OPT_TST(o, COLOR_DIFF);\n \n \tif (fill_mmfile(&mf1, one) < 0 || fill_mmfile(&mf2, two) < 0)\n \t\tdie(\"unable to read files to diff\");\n@@ -1866,7 +1866,7 @@ static void run_diff_cmd(const char *pgm,\n \t\t\t struct diff_options *o,\n \t\t\t int complete_rewrite)\n {\n-\tif (!o->allow_external)\n+\tif (!DIFF_OPT_TST(o, ALLOW_EXTERNAL))\n \t\tpgm = NULL;\n \telse {\n \t\tconst char *cmd = external_diff_attr(name);\n@@ -1964,9 +1964,9 @@ static void run_diff(struct diff_filepair *p, struct diff_options *o)\n \t}\n \n \tif (hashcmp(one->sha1, two->sha1)) {\n-\t\tint abbrev = o->full_index ? 40 : DEFAULT_ABBREV;\n+\t\tint abbrev = DIFF_OPT_TST(o, FULL_INDEX) ? 40 : DEFAULT_ABBREV;\n \n-\t\tif (o->binary) {\n+\t\tif (DIFF_OPT_TST(o, 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@@ -2058,7 +2058,10 @@ void diff_setup(struct diff_options *options)\n \n \toptions->change = diff_change;\n \toptions->add_remove = diff_addremove;\n-\toptions->color_diff = diff_use_color_default;\n+\tif (diff_use_color_default)\n+\t\tDIFF_OPT_SET(options, COLOR_DIFF);\n+\telse\n+\t\tDIFF_OPT_CLR(options, COLOR_DIFF);\n \toptions->detect_rename = diff_detect_rename_default;\n }\n \n@@ -2077,7 +2080,7 @@ int diff_setup_done(struct diff_options *options)\n \tif (count > 1)\n \t\tdie(\"--name-only, --name-status, --check and -s are mutually exclusive\");\n \n-\tif (options->find_copies_harder)\n+\tif (DIFF_OPT_TST(options, FIND_COPIES_HARDER))\n \t\toptions->detect_rename = DIFF_DETECT_COPY;\n \n \tif (options->output_format & (DIFF_FORMAT_NAME |\n@@ -2101,12 +2104,12 @@ int diff_setup_done(struct diff_options *options)\n \t\t\t\t      DIFF_FORMAT_SHORTSTAT |\n \t\t\t\t      DIFF_FORMAT_SUMMARY |\n \t\t\t\t      DIFF_FORMAT_CHECKDIFF))\n-\t\toptions->recursive = 1;\n+\t\tDIFF_OPT_SET(options, RECURSIVE);\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->recursive = 1;\n+\t\tDIFF_OPT_SET(options, RECURSIVE);\n \n \tif (options->detect_rename && options->rename_limit < 0)\n \t\toptions->rename_limit = diff_rename_limit_default;\n@@ -2128,9 +2131,9 @@ int 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->quiet) {\n+\tif (DIFF_OPT_TST(options, QUIET)) {\n \t\toptions->output_format = DIFF_FORMAT_NO_OUTPUT;\n-\t\toptions->exit_with_status = 1;\n+\t\tDIFF_OPT_SET(options, EXIT_WITH_STATUS);\n \t}\n \n \t/*\n@@ -2138,7 +2141,7 @@ int diff_setup_done(struct diff_options *options)\n \t * upon the first hit.  We need to run diff as usual.\n \t */\n \tif (options->pickaxe || options->filter)\n-\t\toptions->quiet = 0;\n+\t\tDIFF_OPT_CLR(options, QUIET);\n \n \treturn 0;\n }\n@@ -2201,15 +2204,12 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)\n \t\toptions->output_format |= DIFF_FORMAT_PATCH;\n \telse if (!strcmp(arg, \"--raw\"))\n \t\toptions->output_format |= DIFF_FORMAT_RAW;\n-\telse if (!strcmp(arg, \"--patch-with-raw\")) {\n+\telse if (!strcmp(arg, \"--patch-with-raw\"))\n \t\toptions->output_format |= DIFF_FORMAT_PATCH | DIFF_FORMAT_RAW;\n-\t}\n-\telse if (!strcmp(arg, \"--numstat\")) {\n+\telse if (!strcmp(arg, \"--numstat\"))\n \t\toptions->output_format |= DIFF_FORMAT_NUMSTAT;\n-\t}\n-\telse if (!strcmp(arg, \"--shortstat\")) {\n+\telse if (!strcmp(arg, \"--shortstat\"))\n \t\toptions->output_format |= DIFF_FORMAT_SHORTSTAT;\n-\t}\n \telse if (!prefixcmp(arg, \"--stat\")) {\n \t\tchar *end;\n \t\tint width = options->stat_width;\n@@ -2241,33 +2241,30 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)\n \t\toptions->output_format |= DIFF_FORMAT_CHECKDIFF;\n \telse if (!strcmp(arg, \"--summary\"))\n \t\toptions->output_format |= DIFF_FORMAT_SUMMARY;\n-\telse if (!strcmp(arg, \"--patch-with-stat\")) {\n+\telse if (!strcmp(arg, \"--patch-with-stat\"))\n \t\toptions->output_format |= DIFF_FORMAT_PATCH | DIFF_FORMAT_DIFFSTAT;\n-\t}\n \telse if (!strcmp(arg, \"-z\"))\n \t\toptions->line_termination = 0;\n \telse if (!prefixcmp(arg, \"-l\"))\n \t\toptions->rename_limit = strtoul(arg+2, NULL, 10);\n \telse if (!strcmp(arg, \"--full-index\"))\n-\t\toptions->full_index = 1;\n+\t\tDIFF_OPT_SET(options, FULL_INDEX);\n \telse if (!strcmp(arg, \"--binary\")) {\n \t\toptions->output_format |= DIFF_FORMAT_PATCH;\n-\t\toptions->binary = 1;\n-\t}\n-\telse if (!strcmp(arg, \"-a\") || !strcmp(arg, \"--text\")) {\n-\t\toptions->text = 1;\n+\t\tDIFF_OPT_SET(options, BINARY);\n \t}\n+\telse if (!strcmp(arg, \"-a\") || !strcmp(arg, \"--text\"))\n+\t\tDIFF_OPT_SET(options, TEXT);\n \telse if (!strcmp(arg, \"--name-only\"))\n \t\toptions->output_format |= DIFF_FORMAT_NAME;\n \telse if (!strcmp(arg, \"--name-status\"))\n \t\toptions->output_format |= DIFF_FORMAT_NAME_STATUS;\n \telse if (!strcmp(arg, \"-R\"))\n-\t\toptions->reverse_diff = 1;\n+\t\tDIFF_OPT_SET(options, REVERSE_DIFF);\n \telse if (!prefixcmp(arg, \"-S\"))\n \t\toptions->pickaxe = arg + 2;\n-\telse if (!strcmp(arg, \"-s\")) {\n+\telse if (!strcmp(arg, \"-s\"))\n \t\toptions->output_format |= DIFF_FORMAT_NO_OUTPUT;\n-\t}\n \telse if (!prefixcmp(arg, \"-O\"))\n \t\toptions->orderfile = arg + 2;\n \telse if (!prefixcmp(arg, \"--diff-filter=\"))\n@@ -2277,28 +2274,25 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)\n \telse if (!strcmp(arg, \"--pickaxe-regex\"))\n \t\toptions->pickaxe_opts = DIFF_PICKAXE_REGEX;\n \telse if (!prefixcmp(arg, \"-B\")) {\n-\t\tif ((options->break_opt =\n-\t\t     diff_scoreopt_parse(arg)) == -1)\n+\t\tif ((options->break_opt = diff_scoreopt_parse(arg)) == -1)\n \t\t\treturn -1;\n \t}\n \telse if (!prefixcmp(arg, \"-M\")) {\n-\t\tif ((options->rename_score =\n-\t\t     diff_scoreopt_parse(arg)) == -1)\n+\t\tif ((options->rename_score = diff_scoreopt_parse(arg)) == -1)\n \t\t\treturn -1;\n \t\toptions->detect_rename = DIFF_DETECT_RENAME;\n \t}\n \telse if (!prefixcmp(arg, \"-C\")) {\n \t\tif (options->detect_rename == DIFF_DETECT_COPY)\n-\t\t\toptions->find_copies_harder = 1;\n-\t\tif ((options->rename_score =\n-\t\t     diff_scoreopt_parse(arg)) == -1)\n+\t\t\tDIFF_OPT_SET(options, FIND_COPIES_HARDER);\n+\t\tif ((options->rename_score = diff_scoreopt_parse(arg)) == -1)\n \t\t\treturn -1;\n \t\toptions->detect_rename = DIFF_DETECT_COPY;\n \t}\n \telse if (!strcmp(arg, \"--find-copies-harder\"))\n-\t\toptions->find_copies_harder = 1;\n+\t\tDIFF_OPT_SET(options, FIND_COPIES_HARDER);\n \telse if (!strcmp(arg, \"--follow\"))\n-\t\toptions->follow_renames = 1;\n+\t\tDIFF_OPT_SET(options, FOLLOW_RENAMES);\n \telse if (!strcmp(arg, \"--abbrev\"))\n \t\toptions->abbrev = DEFAULT_ABBREV;\n \telse if (!prefixcmp(arg, \"--abbrev=\")) {\n@@ -2309,9 +2303,9 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)\n \t\t\toptions->abbrev = 40;\n \t}\n \telse if (!strcmp(arg, \"--color\"))\n-\t\toptions->color_diff = 1;\n+\t\tDIFF_OPT_SET(options, COLOR_DIFF);\n \telse if (!strcmp(arg, \"--no-color\"))\n-\t\toptions->color_diff = 0;\n+\t\tDIFF_OPT_CLR(options, COLOR_DIFF);\n \telse if (!strcmp(arg, \"-w\") || !strcmp(arg, \"--ignore-all-space\"))\n \t\toptions->xdl_opts |= XDF_IGNORE_WHITESPACE;\n \telse if (!strcmp(arg, \"-b\") || !strcmp(arg, \"--ignore-space-change\"))\n@@ -2319,17 +2313,17 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)\n \telse if (!strcmp(arg, \"--ignore-space-at-eol\"))\n \t\toptions->xdl_opts |= XDF_IGNORE_WHITESPACE_AT_EOL;\n \telse if (!strcmp(arg, \"--color-words\"))\n-\t\toptions->color_diff = options->color_diff_words = 1;\n+\t\toptions->flags |= DIFF_OPT_COLOR_DIFF | DIFF_OPT_COLOR_DIFF_WORDS;\n \telse if (!strcmp(arg, \"--no-renames\"))\n \t\toptions->detect_rename = 0;\n \telse if (!strcmp(arg, \"--exit-code\"))\n-\t\toptions->exit_with_status = 1;\n+\t\tDIFF_OPT_SET(options, EXIT_WITH_STATUS);\n \telse if (!strcmp(arg, \"--quiet\"))\n-\t\toptions->quiet = 1;\n+\t\tDIFF_OPT_SET(options, QUIET);\n \telse if (!strcmp(arg, \"--ext-diff\"))\n-\t\toptions->allow_external = 1;\n+\t\tDIFF_OPT_SET(options, ALLOW_EXTERNAL);\n \telse if (!strcmp(arg, \"--no-ext-diff\"))\n-\t\toptions->allow_external = 0;\n+\t\tDIFF_OPT_CLR(options, ALLOW_EXTERNAL);\n \telse\n \t\treturn 0;\n \treturn 1;\n@@ -3084,7 +3078,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->no_index)\n+\t\t\tif (!DIFF_OPT_TST(diffopt, NO_INDEX))\n \t\t\t\tdiffopt->skip_stat_unmatch++;\n \t\t\tdiff_free_filepair(p);\n \t\t}\n@@ -3095,10 +3089,10 @@ static void diffcore_skip_stat_unmatch(struct diff_options *diffopt)\n \n void diffcore_std(struct diff_options *options)\n {\n-\tif (options->quiet)\n+\tif (DIFF_OPT_TST(options, QUIET))\n \t\treturn;\n \n-\tif (options->skip_stat_unmatch && !options->find_copies_harder)\n+\tif (options->skip_stat_unmatch && !DIFF_OPT_TST(options, FIND_COPIES_HARDER))\n \t\tdiffcore_skip_stat_unmatch(options);\n \tif (options->break_opt != -1)\n \t\tdiffcore_break(options->break_opt);\n@@ -3113,7 +3107,10 @@ void diffcore_std(struct diff_options *options)\n \tdiff_resolve_rename_copy();\n \tdiffcore_apply_filter(options->filter);\n \n-\toptions->has_changes = !!diff_queued_diff.nr;\n+\tif (diff_queued_diff.nr)\n+\t\tDIFF_OPT_SET(options, HAS_CHANGES);\n+\telse\n+\t\tDIFF_OPT_CLR(options, HAS_CHANGES);\n }\n \n \n@@ -3137,7 +3134,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->reverse_diff)\n+\tif (DIFF_OPT_TST(options, REVERSE_DIFF))\n \t\taddremove = (addremove == '+' ? '-' :\n \t\t\t     addremove == '-' ? '+' : addremove);\n \n@@ -3152,7 +3149,7 @@ void diff_addremove(struct diff_options *options,\n \t\tfill_filespec(two, sha1, mode);\n \n \tdiff_queue(&diff_queued_diff, one, two);\n-\toptions->has_changes = 1;\n+\tDIFF_OPT_SET(options, HAS_CHANGES);\n }\n \n void diff_change(struct diff_options *options,\n@@ -3164,7 +3161,7 @@ void diff_change(struct diff_options *options,\n \tchar concatpath[PATH_MAX];\n \tstruct diff_filespec *one, *two;\n \n-\tif (options->reverse_diff) {\n+\tif (DIFF_OPT_TST(options, REVERSE_DIFF)) {\n \t\tunsigned tmp;\n \t\tconst unsigned char *tmp_c;\n \t\ttmp = old_mode; old_mode = new_mode; new_mode = tmp;\n@@ -3178,7 +3175,7 @@ void diff_change(struct diff_options *options,\n \tfill_filespec(two, new_sha1, new_mode);\n \n \tdiff_queue(&diff_queued_diff, one, two);\n-\toptions->has_changes = 1;\n+\tDIFF_OPT_SET(options, HAS_CHANGES);\n }\n \n void diff_unmerge(struct diff_options *options,\ndiff --git a/diff.h b/diff.h\nindex 4546aad..6ff2b0e 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -43,26 +43,32 @@ typedef void (*diff_format_fn_t)(struct diff_queue_struct *q,\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_COLOR_DIFF          (1 <<  8)\n+#define DIFF_OPT_COLOR_DIFF_WORDS    (1 <<  9)\n+#define DIFF_OPT_HAS_CHANGES         (1 << 10)\n+#define DIFF_OPT_QUIET               (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_TST(opts, flag)    ((opts)->flags & DIFF_OPT_##flag)\n+#define DIFF_OPT_SET(opts, flag)    ((opts)->flags |= DIFF_OPT_##flag)\n+#define DIFF_OPT_CLR(opts, flag)    ((opts)->flags &= ~DIFF_OPT_##flag)\n+\n struct diff_options {\n \tconst char *filter;\n \tconst char *orderfile;\n \tconst char *pickaxe;\n \tconst char *single_follow;\n-\tunsigned recursive:1,\n-\t\t tree_in_recursive:1,\n-\t\t binary:1,\n-\t\t text:1,\n-\t\t full_index:1,\n-\t\t silent_on_remove:1,\n-\t\t find_copies_harder:1,\n-\t\t follow_renames:1,\n-\t\t color_diff:1,\n-\t\t color_diff_words:1,\n-\t\t has_changes:1,\n-\t\t quiet:1,\n-\t\t no_index:1,\n-\t\t allow_external:1,\n-\t\t exit_with_status:1;\n+\tunsigned flags;\n \tint context;\n \tint break_opt;\n \tint detect_rename;\n@@ -71,7 +77,6 @@ struct diff_options {\n \tint output_format;\n \tint pickaxe_opts;\n \tint rename_score;\n-\tint reverse_diff;\n \tint rename_limit;\n \tint setup;\n \tint abbrev;\n@@ -105,6 +110,9 @@ enum color_diff {\n \tDIFF_WHITESPACE = 7,\n };\n const char *diff_get_color(int diff_use_color, enum color_diff ix);\n+#define diff_get_color_opt(o, ix) \\\n+\tdiff_get_color(DIFF_OPT_TST((o), COLOR_DIFF), ix)\n+\n \n extern const char mime_boundary_leader[];\n \ndiff --git a/log-tree.c b/log-tree.c\nindex a34beb0..1f3fcf1 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -245,8 +245,7 @@ void show_log(struct rev_info *opt, const char *sep)\n \t\t\topt->diffopt.stat_sep = buffer;\n \t\t}\n \t} else if (opt->commit_format != CMIT_FMT_USERFORMAT) {\n-\t\tfputs(diff_get_color(opt->diffopt.color_diff, DIFF_COMMIT),\n-\t\t      stdout);\n+\t\tfputs(diff_get_color_opt(&opt->diffopt, DIFF_COMMIT), stdout);\n \t\tif (opt->commit_format != CMIT_FMT_ONELINE)\n \t\t\tfputs(\"commit \", stdout);\n \t\tif (commit->object.flags & BOUNDARY)\n@@ -266,8 +265,7 @@ void show_log(struct rev_info *opt, const char *sep)\n \t\t\t       diff_unique_abbrev(parent->object.sha1,\n \t\t\t\t\t\t  abbrev_commit));\n \t\tshow_decorations(commit);\n-\t\tprintf(\"%s\",\n-\t\t       diff_get_color(opt->diffopt.color_diff, DIFF_RESET));\n+\t\tprintf(\"%s\", diff_get_color_opt(&opt->diffopt, DIFF_RESET));\n \t\tputchar(opt->commit_format == CMIT_FMT_ONELINE ? ' ' : '\\n');\n \t\tif (opt->reflog_info) {\n \t\t\tshow_reflog_message(opt->reflog_info,\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 6c6f595..9a1e2f2 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -366,7 +366,7 @@ static struct path_list *get_renames(struct tree *tree,\n \n \trenames = xcalloc(1, sizeof(struct path_list));\n \tdiff_setup(&opts);\n-\topts.recursive = 1;\n+\tDIFF_OPT_SET(&opts, RECURSIVE);\n \topts.detect_rename = DIFF_DETECT_RENAME;\n \topts.rename_limit = rename_limit;\n \topts.output_format = DIFF_FORMAT_NO_OUTPUT;\ndiff --git a/patch-ids.c b/patch-ids.c\nindex a288fac..3be5d31 100644\n--- a/patch-ids.c\n+++ b/patch-ids.c\n@@ -121,7 +121,7 @@ int init_patch_ids(struct patch_ids *ids)\n {\n \tmemset(ids, 0, sizeof(*ids));\n \tdiff_setup(&ids->diffopts);\n-\tids->diffopts.recursive = 1;\n+\tDIFF_OPT_SET(&ids->diffopts, RECURSIVE);\n \tif (diff_setup_done(&ids->diffopts) < 0)\n \t\treturn error(\"diff_setup_done failed\");\n \treturn 0;\ndiff --git a/revision.c b/revision.c\nindex 931f978..040214f 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -252,7 +252,7 @@ static void file_add_remove(struct diff_options *options,\n \t}\n \ttree_difference = diff;\n \tif (tree_difference == REV_TREE_DIFFERENT)\n-\t\toptions->has_changes = 1;\n+\t\tDIFF_OPT_SET(options, HAS_CHANGES);\n }\n \n static void file_change(struct diff_options *options,\n@@ -262,7 +262,7 @@ static void file_change(struct diff_options *options,\n \t\t const char *base, const char *path)\n {\n \ttree_difference = REV_TREE_DIFFERENT;\n-\toptions->has_changes = 1;\n+\tDIFF_OPT_SET(options, HAS_CHANGES);\n }\n \n static int rev_compare_tree(struct rev_info *revs, struct tree *t1, struct tree *t2)\n@@ -272,7 +272,7 @@ static int rev_compare_tree(struct rev_info *revs, struct tree *t1, struct tree\n \tif (!t2)\n \t\treturn REV_TREE_DIFFERENT;\n \ttree_difference = REV_TREE_SAME;\n-\trevs->pruning.has_changes = 0;\n+\tDIFF_OPT_CLR(&revs->pruning, HAS_CHANGES);\n \tif (diff_tree_sha1(t1->object.sha1, t2->object.sha1, \"\",\n \t\t\t   &revs->pruning) < 0)\n \t\treturn REV_TREE_DIFFERENT;\n@@ -296,7 +296,7 @@ static int rev_same_tree_as_empty(struct rev_info *revs, struct tree *t1)\n \tinit_tree_desc(&empty, \"\", 0);\n \n \ttree_difference = REV_TREE_SAME;\n-\trevs->pruning.has_changes = 0;\n+\tDIFF_OPT_CLR(&revs->pruning, HAS_CHANGES);\n \tretval = diff_tree(&empty, &real, \"\", &revs->pruning);\n \tfree(tree);\n \n@@ -688,8 +688,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.recursive = 1;\n-\trevs->pruning.quiet = 1;\n+\tDIFF_OPT_SET(&revs->pruning, RECURSIVE);\n+\tDIFF_OPT_SET(&revs->pruning, QUIET);\n \trevs->pruning.add_remove = file_add_remove;\n \trevs->pruning.change = file_change;\n \trevs->lifo = 1;\n@@ -1086,13 +1086,13 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch\n \t\t\t}\n \t\t\tif (!strcmp(arg, \"-r\")) {\n \t\t\t\trevs->diff = 1;\n-\t\t\t\trevs->diffopt.recursive = 1;\n+\t\t\t\tDIFF_OPT_SET(&revs->diffopt, RECURSIVE);\n \t\t\t\tcontinue;\n \t\t\t}\n \t\t\tif (!strcmp(arg, \"-t\")) {\n \t\t\t\trevs->diff = 1;\n-\t\t\t\trevs->diffopt.recursive = 1;\n-\t\t\t\trevs->diffopt.tree_in_recursive = 1;\n+\t\t\t\tDIFF_OPT_SET(&revs->diffopt, RECURSIVE);\n+\t\t\t\tDIFF_OPT_SET(&revs->diffopt, TREE_IN_RECURSIVE);\n \t\t\t\tcontinue;\n \t\t\t}\n \t\t\tif (!strcmp(arg, \"-m\")) {\n@@ -1274,7 +1274,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch\n \t\trevs->diff = 1;\n \n \t/* Pickaxe and rename following needs diffs */\n-\tif (revs->diffopt.pickaxe || revs->diffopt.follow_renames)\n+\tif (revs->diffopt.pickaxe || DIFF_OPT_TST(&revs->diffopt, FOLLOW_RENAMES))\n \t\trevs->diff = 1;\n \n \tif (revs->topo_order)\n@@ -1283,7 +1283,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch\n \tif (revs->prune_data) {\n \t\tdiff_tree_setup_paths(revs->prune_data, &revs->pruning);\n \t\t/* Can't prune commits with rename following: the paths change.. */\n-\t\tif (!revs->diffopt.follow_renames)\n+\t\tif (!DIFF_OPT_TST(&revs->diffopt, FOLLOW_RENAMES))\n \t\t\trevs->prune = 1;\n \t\tif (!revs->full_diff)\n \t\t\tdiff_tree_setup_paths(revs->prune_data, &revs->diffopt);\ndiff --git a/tree-diff.c b/tree-diff.c\nindex 7c261fd..aa0a100 100644\n--- a/tree-diff.c\n+++ b/tree-diff.c\n@@ -39,7 +39,7 @@ static int compare_tree_entry(struct tree_desc *t1, struct tree_desc *t2, const\n \t\tshow_entry(opt, \"+\", t2, base, baselen);\n \t\treturn 1;\n \t}\n-\tif (!opt->find_copies_harder && !hashcmp(sha1, sha2) && mode1 == mode2)\n+\tif (!DIFF_OPT_TST(opt, FIND_COPIES_HARDER) && !hashcmp(sha1, sha2) && mode1 == mode2)\n \t\treturn 0;\n \n \t/*\n@@ -52,10 +52,10 @@ static int compare_tree_entry(struct tree_desc *t1, struct tree_desc *t2, const\n \t\treturn 0;\n \t}\n \n-\tif (opt->recursive && S_ISDIR(mode1)) {\n+\tif (DIFF_OPT_TST(opt, RECURSIVE) && S_ISDIR(mode1)) {\n \t\tint retval;\n \t\tchar *newbase = malloc_base(base, baselen, path1, pathlen1);\n-\t\tif (opt->tree_in_recursive)\n+\t\tif (DIFF_OPT_TST(opt, TREE_IN_RECURSIVE))\n \t\t\topt->change(opt, mode1, mode2,\n \t\t\t\t    sha1, sha2, base, path1);\n \t\tretval = diff_tree_sha1(sha1, sha2, newbase, opt);\n@@ -206,7 +206,7 @@ static void show_entry(struct diff_options *opt, const char *prefix, struct tree\n \tconst char *path;\n \tconst unsigned char *sha1 = tree_entry_extract(desc, &path, &mode);\n \n-\tif (opt->recursive && S_ISDIR(mode)) {\n+\tif (DIFF_OPT_TST(opt, RECURSIVE) && S_ISDIR(mode)) {\n \t\tenum object_type type;\n \t\tint pathlen = tree_entry_len(path, sha1);\n \t\tchar *newbase = malloc_base(base, baselen, path, pathlen);\n@@ -257,7 +257,7 @@ int diff_tree(struct tree_desc *t1, struct tree_desc *t2, const char *base, stru\n \tint baselen = strlen(base);\n \n \tfor (;;) {\n-\t\tif (opt->quiet && opt->has_changes)\n+\t\tif (DIFF_OPT_TST(opt, QUIET) && DIFF_OPT_TST(opt, HAS_CHANGES))\n \t\t\tbreak;\n \t\tif (opt->nr_paths) {\n \t\t\tskip_uninteresting(t1, base, baselen, opt);\n@@ -315,7 +315,7 @@ static void try_to_follow_renames(struct tree_desc *t1, struct tree_desc *t2, co\n \tq->nr = 0;\n \n \tdiff_setup(&diff_opts);\n-\tdiff_opts.recursive = 1;\n+\tDIFF_OPT_SET(&diff_opts, RECURSIVE);\n \tdiff_opts.detect_rename = DIFF_DETECT_RENAME;\n \tdiff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;\n \tdiff_opts.single_follow = opt->paths[0];\n@@ -380,7 +380,7 @@ int diff_tree_sha1(const unsigned char *old, const unsigned char *new, const cha\n \tinit_tree_desc(&t1, tree1, size1);\n \tinit_tree_desc(&t2, tree2, size2);\n \tretval = diff_tree(&t1, &t2, base, opt);\n-\tif (opt->follow_renames && diff_might_be_rename()) {\n+\tif (DIFF_OPT_TST(opt, FOLLOW_RENAMES) && diff_might_be_rename()) {\n \t\tinit_tree_desc(&t1, tree1, size1);\n \t\tinit_tree_desc(&t2, tree2, size2);\n \t\ttry_to_follow_renames(&t1, &t2, base, opt);\n-- \n1.5.3.5.1598.gdef4e\n"},{"id":"58663","messageId":"1194430832-6224-8-git-send-email-madcoder@debian.org","threadId":"10700","inReplyTo":"1194430832-6224-7-git-send-email-madcoder@debian.org","subject":"[PATCH DIFF-CLEANUP 2/2] Reorder diff_opt_parse options more logically per topics.","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-07T10:20:32Z","receivedAt":"2007-11-07T10:20:32Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"This is a line reordering patch _only_.\n\nSigned-off-by: Pierre Habouzit <madcoder@debian.org>\n---\n    the 10 added lines are five times a blank line and a header for the each\n    of the 5 options groups.\n\n    This patch is very useful as it will help checking that I didn't missed\n    any option while converting to parseopt, it's not coquetry.\n\n diff.c |  116 ++++++++++++++++++++++++++++++++++-----------------------------\n 1 files changed, 63 insertions(+), 53 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 97c9a59..7a89959 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -2198,6 +2198,8 @@ static int diff_scoreopt_parse(const char *opt);\n int diff_opt_parse(struct diff_options *options, const char **av, int ac)\n {\n \tconst char *arg = av[0];\n+\n+\t/* Output format options */\n \tif (!strcmp(arg, \"-p\") || !strcmp(arg, \"-u\"))\n \t\toptions->output_format |= DIFF_FORMAT_PATCH;\n \telse if (opt_arg(arg, 'U', \"unified\", &options->context))\n@@ -2210,6 +2212,18 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)\n \t\toptions->output_format |= DIFF_FORMAT_NUMSTAT;\n \telse if (!strcmp(arg, \"--shortstat\"))\n \t\toptions->output_format |= DIFF_FORMAT_SHORTSTAT;\n+\telse if (!strcmp(arg, \"--check\"))\n+\t\toptions->output_format |= DIFF_FORMAT_CHECKDIFF;\n+\telse if (!strcmp(arg, \"--summary\"))\n+\t\toptions->output_format |= DIFF_FORMAT_SUMMARY;\n+\telse if (!strcmp(arg, \"--patch-with-stat\"))\n+\t\toptions->output_format |= DIFF_FORMAT_PATCH | DIFF_FORMAT_DIFFSTAT;\n+\telse if (!strcmp(arg, \"--name-only\"))\n+\t\toptions->output_format |= DIFF_FORMAT_NAME;\n+\telse if (!strcmp(arg, \"--name-status\"))\n+\t\toptions->output_format |= DIFF_FORMAT_NAME_STATUS;\n+\telse if (!strcmp(arg, \"-s\"))\n+\t\toptions->output_format |= DIFF_FORMAT_NO_OUTPUT;\n \telse if (!prefixcmp(arg, \"--stat\")) {\n \t\tchar *end;\n \t\tint width = options->stat_width;\n@@ -2237,42 +2251,8 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)\n \t\toptions->stat_name_width = name_width;\n \t\toptions->stat_width = width;\n \t}\n-\telse if (!strcmp(arg, \"--check\"))\n-\t\toptions->output_format |= DIFF_FORMAT_CHECKDIFF;\n-\telse if (!strcmp(arg, \"--summary\"))\n-\t\toptions->output_format |= DIFF_FORMAT_SUMMARY;\n-\telse if (!strcmp(arg, \"--patch-with-stat\"))\n-\t\toptions->output_format |= DIFF_FORMAT_PATCH | DIFF_FORMAT_DIFFSTAT;\n-\telse if (!strcmp(arg, \"-z\"))\n-\t\toptions->line_termination = 0;\n-\telse if (!prefixcmp(arg, \"-l\"))\n-\t\toptions->rename_limit = strtoul(arg+2, NULL, 10);\n-\telse if (!strcmp(arg, \"--full-index\"))\n-\t\tDIFF_OPT_SET(options, FULL_INDEX);\n-\telse if (!strcmp(arg, \"--binary\")) {\n-\t\toptions->output_format |= DIFF_FORMAT_PATCH;\n-\t\tDIFF_OPT_SET(options, BINARY);\n-\t}\n-\telse if (!strcmp(arg, \"-a\") || !strcmp(arg, \"--text\"))\n-\t\tDIFF_OPT_SET(options, TEXT);\n-\telse if (!strcmp(arg, \"--name-only\"))\n-\t\toptions->output_format |= DIFF_FORMAT_NAME;\n-\telse if (!strcmp(arg, \"--name-status\"))\n-\t\toptions->output_format |= DIFF_FORMAT_NAME_STATUS;\n-\telse if (!strcmp(arg, \"-R\"))\n-\t\tDIFF_OPT_SET(options, REVERSE_DIFF);\n-\telse if (!prefixcmp(arg, \"-S\"))\n-\t\toptions->pickaxe = arg + 2;\n-\telse if (!strcmp(arg, \"-s\"))\n-\t\toptions->output_format |= DIFF_FORMAT_NO_OUTPUT;\n-\telse if (!prefixcmp(arg, \"-O\"))\n-\t\toptions->orderfile = arg + 2;\n-\telse if (!prefixcmp(arg, \"--diff-filter=\"))\n-\t\toptions->filter = arg + 14;\n-\telse if (!strcmp(arg, \"--pickaxe-all\"))\n-\t\toptions->pickaxe_opts = DIFF_PICKAXE_ALL;\n-\telse if (!strcmp(arg, \"--pickaxe-regex\"))\n-\t\toptions->pickaxe_opts = DIFF_PICKAXE_REGEX;\n+\n+\t/* renames options */\n \telse if (!prefixcmp(arg, \"-B\")) {\n \t\tif ((options->break_opt = diff_scoreopt_parse(arg)) == -1)\n \t\t\treturn -1;\n@@ -2289,33 +2269,38 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)\n \t\t\treturn -1;\n \t\toptions->detect_rename = DIFF_DETECT_COPY;\n \t}\n+\telse if (!strcmp(arg, \"--no-renames\"))\n+\t\toptions->detect_rename = 0;\n+\n+\t/* xdiff options */\n+\telse if (!strcmp(arg, \"-w\") || !strcmp(arg, \"--ignore-all-space\"))\n+\t\toptions->xdl_opts |= XDF_IGNORE_WHITESPACE;\n+\telse if (!strcmp(arg, \"-b\") || !strcmp(arg, \"--ignore-space-change\"))\n+\t\toptions->xdl_opts |= XDF_IGNORE_WHITESPACE_CHANGE;\n+\telse if (!strcmp(arg, \"--ignore-space-at-eol\"))\n+\t\toptions->xdl_opts |= XDF_IGNORE_WHITESPACE_AT_EOL;\n+\n+\t/* flags options */\n+\telse if (!strcmp(arg, \"--binary\")) {\n+\t\toptions->output_format |= DIFF_FORMAT_PATCH;\n+\t\tDIFF_OPT_SET(options, BINARY);\n+\t}\n+\telse if (!strcmp(arg, \"--full-index\"))\n+\t\tDIFF_OPT_SET(options, FULL_INDEX);\n+\telse if (!strcmp(arg, \"-a\") || !strcmp(arg, \"--text\"))\n+\t\tDIFF_OPT_SET(options, TEXT);\n+\telse if (!strcmp(arg, \"-R\"))\n+\t\tDIFF_OPT_SET(options, REVERSE_DIFF);\n \telse if (!strcmp(arg, \"--find-copies-harder\"))\n \t\tDIFF_OPT_SET(options, FIND_COPIES_HARDER);\n \telse if (!strcmp(arg, \"--follow\"))\n \t\tDIFF_OPT_SET(options, FOLLOW_RENAMES);\n-\telse if (!strcmp(arg, \"--abbrev\"))\n-\t\toptions->abbrev = DEFAULT_ABBREV;\n-\telse if (!prefixcmp(arg, \"--abbrev=\")) {\n-\t\toptions->abbrev = strtoul(arg + 9, NULL, 10);\n-\t\tif (options->abbrev < MINIMUM_ABBREV)\n-\t\t\toptions->abbrev = MINIMUM_ABBREV;\n-\t\telse if (40 < options->abbrev)\n-\t\t\toptions->abbrev = 40;\n-\t}\n \telse if (!strcmp(arg, \"--color\"))\n \t\tDIFF_OPT_SET(options, COLOR_DIFF);\n \telse if (!strcmp(arg, \"--no-color\"))\n \t\tDIFF_OPT_CLR(options, COLOR_DIFF);\n-\telse if (!strcmp(arg, \"-w\") || !strcmp(arg, \"--ignore-all-space\"))\n-\t\toptions->xdl_opts |= XDF_IGNORE_WHITESPACE;\n-\telse if (!strcmp(arg, \"-b\") || !strcmp(arg, \"--ignore-space-change\"))\n-\t\toptions->xdl_opts |= XDF_IGNORE_WHITESPACE_CHANGE;\n-\telse if (!strcmp(arg, \"--ignore-space-at-eol\"))\n-\t\toptions->xdl_opts |= XDF_IGNORE_WHITESPACE_AT_EOL;\n \telse if (!strcmp(arg, \"--color-words\"))\n \t\toptions->flags |= DIFF_OPT_COLOR_DIFF | DIFF_OPT_COLOR_DIFF_WORDS;\n-\telse if (!strcmp(arg, \"--no-renames\"))\n-\t\toptions->detect_rename = 0;\n \telse if (!strcmp(arg, \"--exit-code\"))\n \t\tDIFF_OPT_SET(options, EXIT_WITH_STATUS);\n \telse if (!strcmp(arg, \"--quiet\"))\n@@ -2324,6 +2309,31 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)\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+\n+\t/* misc options */\n+\telse if (!strcmp(arg, \"-z\"))\n+\t\toptions->line_termination = 0;\n+\telse if (!prefixcmp(arg, \"-l\"))\n+\t\toptions->rename_limit = strtoul(arg+2, NULL, 10);\n+\telse if (!prefixcmp(arg, \"-S\"))\n+\t\toptions->pickaxe = arg + 2;\n+\telse if (!strcmp(arg, \"--pickaxe-all\"))\n+\t\toptions->pickaxe_opts = DIFF_PICKAXE_ALL;\n+\telse if (!strcmp(arg, \"--pickaxe-regex\"))\n+\t\toptions->pickaxe_opts = DIFF_PICKAXE_REGEX;\n+\telse if (!prefixcmp(arg, \"-O\"))\n+\t\toptions->orderfile = arg + 2;\n+\telse if (!prefixcmp(arg, \"--diff-filter=\"))\n+\t\toptions->filter = arg + 14;\n+\telse if (!strcmp(arg, \"--abbrev\"))\n+\t\toptions->abbrev = DEFAULT_ABBREV;\n+\telse if (!prefixcmp(arg, \"--abbrev=\")) {\n+\t\toptions->abbrev = strtoul(arg + 9, NULL, 10);\n+\t\tif (options->abbrev < MINIMUM_ABBREV)\n+\t\t\toptions->abbrev = MINIMUM_ABBREV;\n+\t\telse if (40 < options->abbrev)\n+\t\t\toptions->abbrev = 40;\n+\t}\n \telse\n \t\treturn 0;\n \treturn 1;\n-- \n1.5.3.5.1598.gdef4e\n"},{"id":"58785","messageId":"7v1wb18pwk.fsf@gitster.siamese.dyndns.org","threadId":"10700","inReplyTo":"1194430832-6224-2-git-send-email-madcoder@debian.org","subject":"Re: [PATCH MISC 1/1] Make gcc warning about empty if body go away.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-08T01:52:27Z","receivedAt":"2007-11-08T01:52:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pierre Habouzit <madcoder@debian.org> writes:\n\n> Signed-off-by: Pierre Habouzit <madcoder@debian.org>\n> @@ -204,7 +204,7 @@ static void refresh_index_quietly(void)\n>  \t\tif (write_cache(fd, active_cache, active_nr) ||\n>  \t\t    close(fd) ||\n>  \t\t    commit_locked_index(lock_file))\n> -\t\t\t; /*\n> +\t\t\t(void)0; /*\n>  \t\t\t   * silently ignore it -- we haven't mucked\n>  \t\t\t   * with the real index.\n>  \t\t\t   */\n\nOk, will apply after reindenting a bit, and adding a quote to\nthe description that I could not parse on the first reading:\n\n\tMake gcc warning about \"empty if body\" go away.\n\nThanks.\n"},{"id":"58786","messageId":"7vode57awg.fsf@gitster.siamese.dyndns.org","threadId":"10700","inReplyTo":"1194430832-6224-2-git-send-email-madcoder@debian.org","subject":"Re: [PATCH MISC 1/1] Make gcc warning about empty if body go away.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-08T02:01:51Z","receivedAt":"2007-11-08T02:01:51Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pierre Habouzit <madcoder@debian.org> writes:\n\n> diff --git a/builtin-diff.c b/builtin-diff.c\n> index f77352b..80392a8 100644\n> --- a/builtin-diff.c\n> +++ b/builtin-diff.c\n> @@ -204,7 +204,7 @@ static void refresh_index_quietly(void)\n>  \t\tif (write_cache(fd, active_cache, active_nr) ||\n>  \t\t    close(fd) ||\n>  \t\t    commit_locked_index(lock_file))\n> -\t\t\t; /*\n> +\t\t\t(void)0; /*\n>  \t\t\t   * silently ignore it -- we haven't mucked\n>  \t\t\t   * with the real index.\n>  \t\t\t   */\n\nWouldn't this be much easier to read, by the way?\n\nThe point is that if we touched the active_cache, we try to\nwrite it out and make it the index file for later users to use\nby calling \"commit\", but we do not really care about the failure\nfrom this sequence because it is done purely as an optimization.\n\nThe original code called three functions primarily for their\nside effects, which is admittedly a bad style.\n\n builtin-diff.c |   12 +++---------\n 1 files changed, 3 insertions(+), 9 deletions(-)\n\ndiff --git a/builtin-diff.c b/builtin-diff.c\nindex f77352b..906c924 100644\n--- a/builtin-diff.c\n+++ b/builtin-diff.c\n@@ -200,15 +200,9 @@ static void refresh_index_quietly(void)\n \tdiscard_cache();\n \tread_cache();\n \trefresh_cache(REFRESH_QUIET|REFRESH_UNMERGED);\n-\tif (active_cache_changed) {\n-\t\tif (write_cache(fd, active_cache, active_nr) ||\n-\t\t    close(fd) ||\n-\t\t    commit_locked_index(lock_file))\n-\t\t\t; /*\n-\t\t\t   * silently ignore it -- we haven't mucked\n-\t\t\t   * with the real index.\n-\t\t\t   */\n-\t}\n+\tif (active_cache_changed &&\n+\t    !write_cache(fd, active_cache, active_nr) && !close(fd))\n+\t\tcommit_locked_index(lock_file);\n \trollback_lock_file(lock_file);\n }\n \n"},{"id":"58801","messageId":"7vy7d95ji1.fsf@gitster.siamese.dyndns.org","threadId":"10700","inReplyTo":"1194430832-6224-7-git-send-email-madcoder@debian.org","subject":"Re: [PATCH DIFF-CLEANUP 1/2] Make the diff_options bitfields be an unsigned with explicit masks.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-08T06:39:02Z","receivedAt":"2007-11-08T06:39:02Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pierre Habouzit <madcoder@debian.org> writes:\n\n> reverse_diff was a bit-value in disguise, it's merged in the flags now.\n>\n> Signed-off-by: Pierre Habouzit <madcoder@debian.org>\n\nJust my first impression, as I am in the middle of unrelated\nbisect.  I haven't read beyond diff-lib.c changes.\n\n> diff --git a/builtin-diff-tree.c b/builtin-diff-tree.c\n> index 0b591c8..e71841a 100644\n> --- a/builtin-diff-tree.c\n> +++ b/builtin-diff-tree.c\n> @@ -118,12 +118,12 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)\n>  \t}\n>  \n>  \tif (!read_stdin)\n> -\t\treturn opt->diffopt.exit_with_status ?\n> -\t\t    opt->diffopt.has_changes: 0;\n> +\t\treturn DIFF_OPT_TST(&opt->diffopt, EXIT_WITH_STATUS)\n> +\t\t\t&& DIFF_OPT_TST(&opt->diffopt, HAS_CHANGES);\n\nHad to think a bit about this, although it is correct.\n\n>  \tif (opt->diffopt.detect_rename)\n>  \t\topt->diffopt.setup |= (DIFF_SETUP_USE_SIZE_CACHE |\n> -\t\t\t\t       DIFF_SETUP_USE_CACHE);\n> +\t\t\t\t\t\t\t   DIFF_SETUP_USE_CACHE);\n\nI wonder what this is about.\n\n> diff --git a/combine-diff.c b/combine-diff.c\n> index fe5a2a1..3cab04b 100644\n> --- a/combine-diff.c\n> +++ b/combine-diff.c\n> @@ -664,7 +664,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,\n>  \tint mode_differs = 0;\n>  \tint i, show_hunks;\n>  \tint working_tree_file = is_null_sha1(elem->sha1);\n> -\tint abbrev = opt->full_index ? 40 : DEFAULT_ABBREV;\n> +        int abbrev = DIFF_OPT_TST(opt, FULL_INDEX) ? 40 : DEFAULT_ABBREV;\n\nIndent?\n\n> diff --git a/diff-lib.c b/diff-lib.c\n> index da55713..69b5dc9 100644\n> --- a/diff-lib.c\n> +++ b/diff-lib.c\n> @@ -188,8 +188,7 @@ static int handle_diff_files_args(struct rev_info *revs,\n>  \t\telse if (!strcmp(argv[1], \"-n\") ||\n>  \t\t\t\t!strcmp(argv[1], \"--no-index\")) {\n>  \t\t\trevs->max_count = -2;\n> -\t\t\trevs->diffopt.exit_with_status = 1;\n> -\t\t\trevs->diffopt.no_index = 1;\n> +\t\t\trevs->diffopt.flags |= DIFF_OPT_EXIT_WITH_STATUS | DIFF_OPT_NO_INDEX;\n>  \t\t}\n\nNow this looks harder to read that everybody else uses\nDIFF_OPT_SET() for this, without DIFF_OPT_ prefix for the\nbitmask names.\n"},{"id":"58820","messageId":"20071108081244.GA6528@artemis.corp","threadId":"10700","inReplyTo":"7vode57awg.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH MISC 1/1] Make gcc warning about empty if body go away.","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-08T08:12:44Z","receivedAt":"2007-11-08T08:12:44Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"On Thu, Nov 08, 2007 at 02:01:51AM +0000, Junio C Hamano wrote:\n> Pierre Habouzit <madcoder@debian.org> writes:\n> \n> > diff --git a/builtin-diff.c b/builtin-diff.c\n> > index f77352b..80392a8 100644\n> > --- a/builtin-diff.c\n> > +++ b/builtin-diff.c\n> > @@ -204,7 +204,7 @@ static void refresh_index_quietly(void)\n> >  \t\tif (write_cache(fd, active_cache, active_nr) ||\n> >  \t\t    close(fd) ||\n> >  \t\t    commit_locked_index(lock_file))\n> > -\t\t\t; /*\n> > +\t\t\t(void)0; /*\n> >  \t\t\t   * silently ignore it -- we haven't mucked\n> >  \t\t\t   * with the real index.\n> >  \t\t\t   */\n> \n> Wouldn't this be much easier to read, by the way?\n> \n> The point is that if we touched the active_cache, we try to\n> write it out and make it the index file for later users to use\n> by calling \"commit\", but we do not really care about the failure\n> from this sequence because it is done purely as an optimization.\n> \n> The original code called three functions primarily for their\n> side effects, which is admittedly a bad style.\n\n  Well all I care is that the warning goes away, it prevents me to build\nin -Werror and it's bad :)\n\n\n-- \n·O·  Pierre Habouzit\n··O                                                madcoder@debian.org\nOOO                                                http://www.madism.org\n"},{"id":"58823","messageId":"20071108081716.GC6528@artemis.corp","threadId":"10700","inReplyTo":"7vy7d95ji1.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH DIFF-CLEANUP 1/2] Make the diff_options bitfields be an unsigned with explicit masks.","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-08T08:17:16Z","receivedAt":"2007-11-08T08:17:16Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"On Thu, Nov 08, 2007 at 06:39:02AM +0000, Junio C Hamano wrote:\n> Pierre Habouzit <madcoder@debian.org> writes:\n> \n> > reverse_diff was a bit-value in disguise, it's merged in the flags now.\n> >\n> > Signed-off-by: Pierre Habouzit <madcoder@debian.org>\n> \n> Just my first impression, as I am in the middle of unrelated\n> bisect.  I haven't read beyond diff-lib.c changes.\n> \n> > diff --git a/builtin-diff-tree.c b/builtin-diff-tree.c\n> > index 0b591c8..e71841a 100644\n> > --- a/builtin-diff-tree.c\n> > +++ b/builtin-diff-tree.c\n> > @@ -118,12 +118,12 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)\n> >  \t}\n> >  \n> >  \tif (!read_stdin)\n> > -\t\treturn opt->diffopt.exit_with_status ?\n> > -\t\t    opt->diffopt.has_changes: 0;\n> > +\t\treturn DIFF_OPT_TST(&opt->diffopt, EXIT_WITH_STATUS)\n> > +\t\t\t&& DIFF_OPT_TST(&opt->diffopt, HAS_CHANGES);\n> \n> Had to think a bit about this, although it is correct.\n> \n> >  \tif (opt->diffopt.detect_rename)\n> >  \t\topt->diffopt.setup |= (DIFF_SETUP_USE_SIZE_CACHE |\n> > -\t\t\t\t       DIFF_SETUP_USE_CACHE);\n> > +\t\t\t\t\t\t\t   DIFF_SETUP_USE_CACHE);\n> \n> I wonder what this is about.\n\n  err I code with tabs of size 4 and I believe my editor was\nover-zealous when I asked to reindent some part that I changed :P\n\n> > diff --git a/combine-diff.c b/combine-diff.c\n> > index fe5a2a1..3cab04b 100644\n> > --- a/combine-diff.c\n> > +++ b/combine-diff.c\n> > @@ -664,7 +664,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,\n> >  \tint mode_differs = 0;\n> >  \tint i, show_hunks;\n> >  \tint working_tree_file = is_null_sha1(elem->sha1);\n> > -\tint abbrev = opt->full_index ? 40 : DEFAULT_ABBREV;\n> > +        int abbrev = DIFF_OPT_TST(opt, FULL_INDEX) ? 40 : DEFAULT_ABBREV;\n> \n> Indent?\n\n  will fix.\n\n> > diff --git a/diff-lib.c b/diff-lib.c\n> > index da55713..69b5dc9 100644\n> > --- a/diff-lib.c\n> > +++ b/diff-lib.c\n> > @@ -188,8 +188,7 @@ static int handle_diff_files_args(struct rev_info *revs,\n> >  \t\telse if (!strcmp(argv[1], \"-n\") ||\n> >  \t\t\t\t!strcmp(argv[1], \"--no-index\")) {\n> >  \t\t\trevs->max_count = -2;\n> > -\t\t\trevs->diffopt.exit_with_status = 1;\n> > -\t\t\trevs->diffopt.no_index = 1;\n> > +\t\t\trevs->diffopt.flags |= DIFF_OPT_EXIT_WITH_STATUS | DIFF_OPT_NO_INDEX;\n> >  \t\t}\n> \n> Now this looks harder to read that everybody else uses\n> DIFF_OPT_SET() for this, without DIFF_OPT_ prefix for the\n> bitmask names.\n\n  that could be splitted in two DIFF_OPT_SET indeed. will do.\n\n-- \n·O·  Pierre Habouzit\n··O                                                madcoder@debian.org\nOOO                                                http://www.madism.org\n"},{"id":"58831","messageId":"4732CBD3.503@op5.se","threadId":"10700","inReplyTo":"7vode57awg.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH MISC 1/1] Make gcc warning about empty if body go away.","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2007-11-08T08:41:55Z","receivedAt":"2007-11-08T08:41:55Z","isPatch":true,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"Junio C Hamano wrote:\n> Pierre Habouzit <madcoder@debian.org> writes:\n> \n>> diff --git a/builtin-diff.c b/builtin-diff.c\n>> index f77352b..80392a8 100644\n>> --- a/builtin-diff.c\n>> +++ b/builtin-diff.c\n>> @@ -204,7 +204,7 @@ static void refresh_index_quietly(void)\n>>  \t\tif (write_cache(fd, active_cache, active_nr) ||\n>>  \t\t    close(fd) ||\n>>  \t\t    commit_locked_index(lock_file))\n>> -\t\t\t; /*\n>> +\t\t\t(void)0; /*\n>>  \t\t\t   * silently ignore it -- we haven't mucked\n>>  \t\t\t   * with the real index.\n>>  \t\t\t   */\n> \n> Wouldn't this be much easier to read, by the way?\n> \n> The point is that if we touched the active_cache, we try to\n> write it out and make it the index file for later users to use\n> by calling \"commit\", but we do not really care about the failure\n> from this sequence because it is done purely as an optimization.\n> \n> The original code called three functions primarily for their\n> side effects, which is admittedly a bad style.\n> \n>  builtin-diff.c |   12 +++---------\n>  1 files changed, 3 insertions(+), 9 deletions(-)\n> \n> diff --git a/builtin-diff.c b/builtin-diff.c\n> index f77352b..906c924 100644\n> --- a/builtin-diff.c\n> +++ b/builtin-diff.c\n> @@ -200,15 +200,9 @@ static void refresh_index_quietly(void)\n>  \tdiscard_cache();\n>  \tread_cache();\n>  \trefresh_cache(REFRESH_QUIET|REFRESH_UNMERGED);\n> -\tif (active_cache_changed) {\n> -\t\tif (write_cache(fd, active_cache, active_nr) ||\n> -\t\t    close(fd) ||\n> -\t\t    commit_locked_index(lock_file))\n> -\t\t\t; /*\n> -\t\t\t   * silently ignore it -- we haven't mucked\n> -\t\t\t   * with the real index.\n> -\t\t\t   */\n> -\t}\n> +\tif (active_cache_changed &&\n> +\t    !write_cache(fd, active_cache, active_nr) && !close(fd))\n> +\t\tcommit_locked_index(lock_file);\n>  \trollback_lock_file(lock_file);\n>  }\n>  \n\nAck, obviously, as it no longer requires a comment to explain it, although\nI'd prefer an empty line after commit_locked_index(lock_file); so as to not\nconfuse the rollback_lock_file() statement as being part of the conditional\npath.\n\nFirst I thought the rollback_lock_file() was the *only* statement to the\ncondition, and everyone who uses 4 for tabsize) will have double trouble\nsince commit_locked_index(lock_file) aligns with the second line of the\ncondition.\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n"},{"id":"58907","messageId":"47332957.5050308@freescale.com","threadId":"10700","inReplyTo":"4732CBD3.503@op5.se","subject":"Re: [PATCH MISC 1/1] Make gcc warning about empty if body go away.","fromName":"Jon Loeliger","fromEmail":"jdl@freescale.com","sentAt":"2007-11-08T15:20:55Z","receivedAt":"2007-11-08T15:20:55Z","isPatch":true,"sender":{"key":"jdl@jdl.com","avatar":"https://gravatar.com/avatar/75ce9a10b151acd2c28ec4ab2136dba7b2ff1634530bd04b155981a749d08a64?d=mp&s=160"},"body":"Andreas Ericsson wrote:\n\n>> +    if (active_cache_changed &&\n>> +        !write_cache(fd, active_cache, active_nr) && !close(fd))\n>> +        commit_locked_index(lock_file);\n>>      rollback_lock_file(lock_file);\n>>  }\n>>  \n> \n> Ack, obviously, as it no longer requires a comment to explain it, although\n> I'd prefer an empty line after commit_locked_index(lock_file); so as to not\n> confuse the rollback_lock_file() statement as being part of the conditional\n> path.\n> \n> First I thought the rollback_lock_file() was the *only* statement to the\n> condition, and everyone who uses 4 for tabsize) will have double trouble\n> since commit_locked_index(lock_file) aligns with the second line of the\n> condition.\n> \n\nIt's too bad this was confusing due to the lack of braces. :-)\n\njdl\n"},{"id":"58911","messageId":"47332F8E.8080309@op5.se","threadId":"10700","inReplyTo":"47332957.5050308@freescale.com","subject":"Re: [PATCH MISC 1/1] Make gcc warning about empty if body go away.","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2007-11-08T15:47:26Z","receivedAt":"2007-11-08T15:47:26Z","isPatch":true,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"Jon Loeliger wrote:\n> Andreas Ericsson wrote:\n> \n>>> +    if (active_cache_changed &&\n>>> +        !write_cache(fd, active_cache, active_nr) && !close(fd))\n>>> +        commit_locked_index(lock_file);\n>>>      rollback_lock_file(lock_file);\n>>>  }\n>>>  \n>>\n>> Ack, obviously, as it no longer requires a comment to explain it, \n>> although\n>> I'd prefer an empty line after commit_locked_index(lock_file); so as \n>> to not\n>> confuse the rollback_lock_file() statement as being part of the \n>> conditional\n>> path.\n>>\n>> First I thought the rollback_lock_file() was the *only* statement to the\n>> condition, and everyone who uses 4 for tabsize) will have double trouble\n>> since commit_locked_index(lock_file) aligns with the second line of the\n>> condition.\n>>\n> \n> It's too bad this was confusing due to the lack of braces. :-)\n> \n\nI found that slightly ironic too, since I really don't like overly bracey\ncode either. Just goes to show there are no rules without exceptions, I\nguess.\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n"},{"id":"58985","messageId":"7vbqa4z3ts.fsf@gitster.siamese.dyndns.org","threadId":"10700","inReplyTo":"1194430832-6224-3-git-send-email-madcoder@debian.org","subject":"Re: [PATCH PARSEOPT 1/4] parse-options new features.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-08T23:59:27Z","receivedAt":"2007-11-08T23:59:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pierre Habouzit <madcoder@debian.org> writes:\n\n> options flags:\n> ~~~~~~~~~~~~~\n>   PARSE_OPT_NONEG allow the caller to disallow the negated option to exists.\n\nGood addition; writing OPT_CALLBACK was tricky without this when\nI tried to add --with=<commit> to git-branch.\n\n\ts/to exists/to exist/\n"},{"id":"58963","messageId":"20071109001719.GA22255@artemis.corp","threadId":"10700","inReplyTo":"7vbqa4z3ts.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH PARSEOPT 1/4] parse-options new features.","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-09T00:17:19Z","receivedAt":"2007-11-09T00:17:19Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"On Thu, Nov 08, 2007 at 11:59:27PM +0000, Junio C Hamano wrote:\n> Pierre Habouzit <madcoder@debian.org> writes:\n> \n> > options flags:\n> > ~~~~~~~~~~~~~\n> >   PARSE_OPT_NONEG allow the caller to disallow the negated option to exists.\n> \n> Good addition; writing OPT_CALLBACK was tricky without this when\n> I tried to add --with=<commit> to git-branch.\n\n  Well, you could do the same by hand, in the callback:\n\n    if (unset)\n        return error(\"go away with your --no-%s\", opt->long_name);\n\n  This is correct because only long options can be negated, and if the\ncallback returns -1 (< 0 actually IIRC, or maybe even !0) then\nparse_options assume that you dealt with the error message, and will\njust print out the usage and exit(129).\n\n  So it merely offloads something that you could already do the very\nsame way _when using a callback_.\n\n  It gets more interesting when you want to use an\nOPT_INT/_STRING/whatever with an argument that isn't a callback and\ndon't want for some reason that --no-foo works. Before that change, you\nneeded a callback, now you don't :)\n-- \n·O·  Pierre Habouzit\n··O                                                madcoder@debian.org\nOOO                                                http://www.madism.org\n"},{"id":"59232","messageId":"20071110190514.GA28351@artemis.corp","threadId":"10700","inReplyTo":"7vy7d95ji1.fsf@gitster.siamese.dyndns.org","subject":"[UPDATE DIFF-CLEANUP 1/2] Make the diff_options bitfields be an unsigned with explicit masks.","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2007-11-10T19:05:14Z","receivedAt":"2007-11-10T19:05:14Z","isPatch":false,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"reverse_diff was a bit-value in disguise, it's merged in the flags now.\n\nSigned-off-by: Pierre Habouzit <madcoder@debian.org>\n---\n builtin-blame.c      |   10 ++--\n builtin-diff-files.c |    4 +-\n builtin-diff-index.c |    4 +-\n builtin-diff-tree.c  |    7 ++-\n builtin-diff.c       |   12 +++---\n builtin-log.c        |   24 ++++------\n combine-diff.c       |   10 ++--\n diff-lib.c           |   24 +++++-----\n diff.c               |  123 ++++++++++++++++++++++++-------------------------\n diff.h               |   40 ++++++++++-------\n log-tree.c           |    6 +--\n merge-recursive.c    |    2 +-\n patch-ids.c          |    2 +-\n revision.c           |   22 +++++-----\n tree-diff.c          |   14 +++---\n 15 files changed, 155 insertions(+), 149 deletions(-)\n\ndiff --git a/builtin-blame.c b/builtin-blame.c\nindex ba80bf8..c158d31 100644\n--- a/builtin-blame.c\n+++ b/builtin-blame.c\n@@ -335,7 +335,7 @@ static struct origin *find_origin(struct scoreboard *sb,\n \t * same and diff-tree is fairly efficient about this.\n \t */\n \tdiff_setup(&diff_opts);\n-\tdiff_opts.recursive = 1;\n+\tDIFF_OPT_SET(&diff_opts, RECURSIVE);\n \tdiff_opts.detect_rename = 0;\n \tdiff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;\n \tpaths[0] = origin->path;\n@@ -409,7 +409,7 @@ static struct origin *find_rename(struct scoreboard *sb,\n \tconst char *paths[2];\n \n \tdiff_setup(&diff_opts);\n-\tdiff_opts.recursive = 1;\n+\tDIFF_OPT_SET(&diff_opts, RECURSIVE);\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@@ -1075,7 +1075,7 @@ static int find_copy_in_parent(struct scoreboard *sb,\n \t\treturn 1; /* nothing remains for this target */\n \n \tdiff_setup(&diff_opts);\n-\tdiff_opts.recursive = 1;\n+\tDIFF_OPT_SET(&diff_opts, RECURSIVE);\n \tdiff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;\n \n \tpaths[0] = NULL;\n@@ -1093,7 +1093,7 @@ static int find_copy_in_parent(struct 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.find_copies_harder = 1;\n+\t\tDIFF_OPT_SET(&diff_opts, FIND_COPIES_HARDER);\n \n \tif (is_null_sha1(target->commit->object.sha1))\n \t\tdo_diff_cache(parent->tree->object.sha1, &diff_opts);\n@@ -1102,7 +1102,7 @@ static int find_copy_in_parent(struct scoreboard *sb,\n \t\t\t       target->commit->tree->object.sha1,\n \t\t\t       \"\", &diff_opts);\n \n-\tif (!diff_opts.find_copies_harder)\n+\tif (!DIFF_OPT_TST(&diff_opts, FIND_COPIES_HARDER))\n \t\tdiffcore_std(&diff_opts);\n \n \tretval = 0;\ndiff --git a/builtin-diff-files.c b/builtin-diff-files.c\nindex 6cb30c8..046b7e3 100644\n--- a/builtin-diff-files.c\n+++ b/builtin-diff-files.c\n@@ -31,5 +31,7 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix)\n \tif (!rev.diffopt.output_format)\n \t\trev.diffopt.output_format = DIFF_FORMAT_RAW;\n \tresult = run_diff_files_cmd(&rev, argc, argv);\n-\treturn rev.diffopt.exit_with_status ? rev.diffopt.has_changes: result;\n+\tif (DIFF_OPT_TST(&rev.diffopt, EXIT_WITH_STATUS))\n+\t\treturn DIFF_OPT_TST(&rev.diffopt, HAS_CHANGES) != 0;\n+\treturn result;\n }\ndiff --git a/builtin-diff-index.c b/builtin-diff-index.c\nindex 81e7167..556c506 100644\n--- a/builtin-diff-index.c\n+++ b/builtin-diff-index.c\n@@ -44,5 +44,7 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix)\n \t\treturn -1;\n \t}\n \tresult = run_diff_index(&rev, cached);\n-\treturn rev.diffopt.exit_with_status ? rev.diffopt.has_changes: result;\n+\tif (DIFF_OPT_TST(&rev.diffopt, EXIT_WITH_STATUS))\n+\t\treturn DIFF_OPT_TST(&rev.diffopt, HAS_CHANGES) != 0;\n+\treturn result;\n }\ndiff --git a/builtin-diff-tree.c b/builtin-diff-tree.c\nindex 0b591c8..2e13716 100644\n--- a/builtin-diff-tree.c\n+++ b/builtin-diff-tree.c\n@@ -118,8 +118,8 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)\n \t}\n \n \tif (!read_stdin)\n-\t\treturn opt->diffopt.exit_with_status ?\n-\t\t    opt->diffopt.has_changes: 0;\n+\t\treturn DIFF_OPT_TST(&opt->diffopt, EXIT_WITH_STATUS)\n+\t\t\t&& DIFF_OPT_TST(&opt->diffopt, HAS_CHANGES);\n \n \tif (opt->diffopt.detect_rename)\n \t\topt->diffopt.setup |= (DIFF_SETUP_USE_SIZE_CACHE |\n@@ -134,5 +134,6 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)\n \t\telse\n \t\t\tdiff_tree_stdin(line);\n \t}\n-\treturn opt->diffopt.exit_with_status ? opt->diffopt.has_changes: 0;\n+\treturn DIFF_OPT_TST(&opt->diffopt, EXIT_WITH_STATUS)\n+\t\t&& DIFF_OPT_TST(&opt->diffopt, HAS_CHANGES);\n }\ndiff --git a/builtin-diff.c b/builtin-diff.c\nindex f557d21..1b61599 100644\n--- a/builtin-diff.c\n+++ b/builtin-diff.c\n@@ -35,7 +35,7 @@ static void stuff_change(struct diff_options *opt,\n \t    !hashcmp(old_sha1, new_sha1) && (old_mode == new_mode))\n \t\treturn;\n \n-\tif (opt->reverse_diff) {\n+\tif (DIFF_OPT_TST(opt, REVERSE_DIFF)) {\n \t\tunsigned tmp;\n \t\tconst unsigned char *tmp_u;\n \t\tconst char *tmp_c;\n@@ -253,13 +253,13 @@ int cmd_diff(int argc, const char **argv, const char *prefix)\n \t\tif (diff_setup_done(&rev.diffopt) < 0)\n \t\t\tdie(\"diff_setup_done failed\");\n \t}\n-\trev.diffopt.allow_external = 1;\n-\trev.diffopt.recursive = 1;\n+\tDIFF_OPT_SET(&rev.diffopt, ALLOW_EXTERNAL);\n+\tDIFF_OPT_SET(&rev.diffopt, RECURSIVE);\n \n \t/* If the user asked for our exit code then don't start a\n \t * pager or we would end up reporting its exit code instead.\n \t */\n-\tif (!rev.diffopt.exit_with_status)\n+\tif (!DIFF_OPT_TST(&rev.diffopt, EXIT_WITH_STATUS))\n \t\tsetup_pager();\n \n \t/* Do we have --cached and not have a pending object, then\n@@ -363,8 +363,8 @@ int cmd_diff(int argc, const char **argv, const char *prefix)\n \telse\n \t\tresult = builtin_diff_combined(&rev, argc, argv,\n \t\t\t\t\t     ent, ents);\n-\tif (rev.diffopt.exit_with_status)\n-\t\tresult = rev.diffopt.has_changes;\n+\tif (DIFF_OPT_TST(&rev.diffopt, EXIT_WITH_STATUS))\n+\t\tresult = DIFF_OPT_TST(&rev.diffopt, HAS_CHANGES) != 0;\n \n \tif (1 < rev.diffopt.skip_stat_unmatch)\n \t\trefresh_index_quietly();\ndiff --git a/builtin-log.c b/builtin-log.c\nindex b6ca04a..72745cd 100644\n--- a/builtin-log.c\n+++ b/builtin-log.c\n@@ -55,13 +55,13 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,\n \trev->abbrev = DEFAULT_ABBREV;\n \trev->commit_format = CMIT_FMT_DEFAULT;\n \trev->verbose_header = 1;\n-\trev->diffopt.recursive = 1;\n+\tDIFF_OPT_SET(&rev->diffopt, RECURSIVE);\n \trev->show_root_diff = default_show_root;\n \trev->subject_prefix = fmt_patch_subject_prefix;\n \targc = setup_revisions(argc, argv, rev, \"HEAD\");\n \tif (rev->diffopt.pickaxe || rev->diffopt.filter)\n \t\trev->always_show_header = 0;\n-\tif (rev->diffopt.follow_renames) {\n+\tif (DIFF_OPT_TST(&rev->diffopt, FOLLOW_RENAMES)) {\n \t\trev->always_show_header = 0;\n \t\tif (rev->diffopt.nr_paths != 1)\n \t\t\tusage(\"git logs can only follow renames on one pathname at a time\");\n@@ -308,11 +308,9 @@ int cmd_show(int argc, const char **argv, const char *prefix)\n \t\t\tstruct tag *t = (struct tag *)o;\n \n \t\t\tprintf(\"%stag %s%s\\n\\n\",\n-\t\t\t\t\tdiff_get_color(rev.diffopt.color_diff,\n-\t\t\t\t\t\tDIFF_COMMIT),\n+\t\t\t\t\tdiff_get_color_opt(&rev.diffopt, DIFF_COMMIT),\n \t\t\t\t\tt->tag,\n-\t\t\t\t\tdiff_get_color(rev.diffopt.color_diff,\n-\t\t\t\t\t\tDIFF_RESET));\n+\t\t\t\t\tdiff_get_color_opt(&rev.diffopt, DIFF_RESET));\n \t\t\tret = show_object(o->sha1, 1);\n \t\t\tobjects[i].item = (struct object *)t->tagged;\n \t\t\ti--;\n@@ -320,11 +318,9 @@ int cmd_show(int argc, const char **argv, const char *prefix)\n \t\t}\n \t\tcase OBJ_TREE:\n \t\t\tprintf(\"%stree %s%s\\n\\n\",\n-\t\t\t\t\tdiff_get_color(rev.diffopt.color_diff,\n-\t\t\t\t\t\tDIFF_COMMIT),\n+\t\t\t\t\tdiff_get_color_opt(&rev.diffopt, DIFF_COMMIT),\n \t\t\t\t\tname,\n-\t\t\t\t\tdiff_get_color(rev.diffopt.color_diff,\n-\t\t\t\t\t\tDIFF_RESET));\n+\t\t\t\t\tdiff_get_color_opt(&rev.diffopt, DIFF_RESET));\n \t\t\tread_tree_recursive((struct tree *)o, \"\", 0, 0, NULL,\n \t\t\t\t\tshow_tree_object);\n \t\t\tbreak;\n@@ -620,7 +616,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \trev.combine_merges = 0;\n \trev.ignore_merges = 1;\n \trev.diffopt.msg_sep = \"\";\n-\trev.diffopt.recursive = 1;\n+\tDIFF_OPT_SET(&rev.diffopt, RECURSIVE);\n \n \trev.subject_prefix = fmt_patch_subject_prefix;\n \trev.extra_headers = extra_headers;\n@@ -728,8 +724,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \tif (!rev.diffopt.output_format)\n \t\trev.diffopt.output_format = DIFF_FORMAT_DIFFSTAT | DIFF_FORMAT_SUMMARY | DIFF_FORMAT_PATCH;\n \n-\tif (!rev.diffopt.text)\n-\t\trev.diffopt.binary = 1;\n+\tif (!DIFF_OPT_TST(&rev.diffopt, TEXT))\n+\t\tDIFF_OPT_SET(&rev.diffopt, BINARY);\n \n \tif (!output_directory && !use_stdout)\n \t\toutput_directory = prefix;\n@@ -887,7 +883,7 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)\n \trevs.diff = 1;\n \trevs.combine_merges = 0;\n \trevs.ignore_merges = 1;\n-\trevs.diffopt.recursive = 1;\n+\tDIFF_OPT_SET(&revs.diffopt, RECURSIVE);\n \n \tif (add_pending_commit(head, &revs, 0))\n \t\tdie(\"Unknown commit %s\", head);\ndiff --git a/combine-diff.c b/combine-diff.c\nindex fe5a2a1..5a658dc 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -664,7 +664,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,\n \tint mode_differs = 0;\n \tint i, show_hunks;\n \tint working_tree_file = is_null_sha1(elem->sha1);\n-\tint abbrev = opt->full_index ? 40 : DEFAULT_ABBREV;\n+\tint abbrev = DIFF_OPT_TST(opt, FULL_INDEX) ? 40 : DEFAULT_ABBREV;\n \tmmfile_t result_file;\n \n \tcontext = opt->context;\n@@ -784,7 +784,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,\n \n \tif (show_hunks || mode_differs || working_tree_file) {\n \t\tconst char *abb;\n-\t\tint use_color = opt->color_diff;\n+\t\tint use_color = DIFF_OPT_TST(opt, COLOR_DIFF);\n \t\tconst char *c_meta = diff_get_color(use_color, DIFF_METAINFO);\n \t\tconst char *c_reset = diff_get_color(use_color, DIFF_RESET);\n \t\tint added = 0;\n@@ -836,7 +836,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,\n \t\t\tdump_quoted_path(\"+++ /dev/\", \"null\", c_meta, c_reset);\n \t\telse\n \t\t\tdump_quoted_path(\"+++ b/\", elem->path, c_meta, c_reset);\n-\t\tdump_sline(sline, cnt, num_parent, opt->color_diff);\n+\t\tdump_sline(sline, cnt, num_parent, DIFF_OPT_TST(opt, COLOR_DIFF));\n \t}\n \tfree(result);\n \n@@ -929,8 +929,8 @@ void diff_tree_combined(const unsigned char *sha1,\n \n \tdiffopts = *opt;\n \tdiffopts.output_format = DIFF_FORMAT_NO_OUTPUT;\n-\tdiffopts.recursive = 1;\n-\tdiffopts.allow_external = 0;\n+\tDIFF_OPT_SET(&diffopts, RECURSIVE);\n+\tDIFF_OPT_CLR(&diffopts, ALLOW_EXTERNAL);\n \n \tshow_log_first = !!rev->loginfo && !rev->no_commit_id;\n \tneedsep = 0;\ndiff --git a/diff-lib.c b/diff-lib.c\nindex da55713..290a170 100644\n--- a/diff-lib.c\n+++ b/diff-lib.c\n@@ -121,7 +121,7 @@ static int queue_diff(struct diff_options *o,\n \t} else {\n \t\tstruct diff_filespec *d1, *d2;\n \n-\t\tif (o->reverse_diff) {\n+\t\tif (DIFF_OPT_TST(o, REVERSE_DIFF)) {\n \t\t\tunsigned tmp;\n \t\t\tconst char *tmp_c;\n \t\t\ttmp = mode1; mode1 = mode2; mode2 = tmp;\n@@ -188,8 +188,8 @@ static int handle_diff_files_args(struct rev_info *revs,\n \t\telse if (!strcmp(argv[1], \"-n\") ||\n \t\t\t\t!strcmp(argv[1], \"--no-index\")) {\n \t\t\trevs->max_count = -2;\n-\t\t\trevs->diffopt.exit_with_status = 1;\n-\t\t\trevs->diffopt.no_index = 1;\n+\t\t\tDIFF_OPT_SET(&revs->diffopt, EXIT_WITH_STATUS);\n+\t\t\tDIFF_OPT_SET(&revs->diffopt, NO_INDEX);\n \t\t}\n \t\telse if (!strcmp(argv[1], \"-q\"))\n \t\t\t*silent = 1;\n@@ -207,7 +207,7 @@ static int handle_diff_files_args(struct rev_info *revs,\n \t\tif (!is_in_index(revs->diffopt.paths[0]) ||\n \t\t\t\t\t!is_in_index(revs->diffopt.paths[1])) {\n \t\t\trevs->max_count = -2;\n-\t\t\trevs->diffopt.no_index = 1;\n+\t\t\tDIFF_OPT_SET(&revs->diffopt, NO_INDEX);\n \t\t}\n \t}\n \n@@ -258,7 +258,7 @@ int setup_diff_no_index(struct rev_info *revs,\n \t\t\tbreak;\n \t\t} else if (i < argc - 3 && !strcmp(argv[i], \"--no-index\")) {\n \t\t\ti = argc - 3;\n-\t\t\trevs->diffopt.exit_with_status = 1;\n+\t\t\tDIFF_OPT_SET(&revs->diffopt, EXIT_WITH_STATUS);\n \t\t\tbreak;\n \t\t}\n \tif (argc != i + 2 || (!is_outside_repo(argv[i + 1], nongit, prefix) &&\n@@ -296,7 +296,7 @@ int setup_diff_no_index(struct rev_info *revs,\n \telse\n \t\trevs->diffopt.paths = argv + argc - 2;\n \trevs->diffopt.nr_paths = 2;\n-\trevs->diffopt.no_index = 1;\n+\tDIFF_OPT_SET(&revs->diffopt, NO_INDEX);\n \trevs->max_count = -2;\n \tif (diff_setup_done(&revs->diffopt) < 0)\n \t\tdie(\"diff_setup_done failed\");\n@@ -310,7 +310,7 @@ int run_diff_files_cmd(struct rev_info *revs, int argc, const char **argv)\n \tif (handle_diff_files_args(revs, argc, argv, &silent_on_removed))\n \t\treturn -1;\n \n-\tif (revs->diffopt.no_index) {\n+\tif (DIFF_OPT_TST(&revs->diffopt, NO_INDEX)) {\n \t\tif (revs->diffopt.nr_paths != 2)\n \t\t\treturn error(\"need two files/directories with --no-index\");\n \t\tif (queue_diff(&revs->diffopt, revs->diffopt.paths[0],\n@@ -346,7 +346,8 @@ int run_diff_files(struct rev_info *revs, int silent_on_removed)\n \t\tstruct cache_entry *ce = active_cache[i];\n \t\tint changed;\n \n-\t\tif (revs->diffopt.quiet && revs->diffopt.has_changes)\n+\t\tif (DIFF_OPT_TST(&revs->diffopt, QUIET) &&\n+\t\t\tDIFF_OPT_TST(&revs->diffopt, HAS_CHANGES))\n \t\t\tbreak;\n \n \t\tif (!ce_path_match(ce, revs->prune_data))\n@@ -442,7 +443,7 @@ int run_diff_files(struct rev_info *revs, int silent_on_removed)\n \t\t\tcontinue;\n \t\t}\n \t\tchanged = ce_match_stat(ce, &st, 0);\n-\t\tif (!changed && !revs->diffopt.find_copies_harder)\n+\t\tif (!changed && !DIFF_OPT_TST(&revs->diffopt, FIND_COPIES_HARDER))\n \t\t\tcontinue;\n \t\toldmode = ntohl(ce->ce_mode);\n \t\tnewmode = ntohl(ce_mode_from_stat(ce, st.st_mode));\n@@ -561,7 +562,7 @@ static int show_modified(struct rev_info *revs,\n \n \toldmode = old->ce_mode;\n \tif (mode == oldmode && !hashcmp(sha1, old->sha1) &&\n-\t    !revs->diffopt.find_copies_harder)\n+\t    !DIFF_OPT_TST(&revs->diffopt, FIND_COPIES_HARDER))\n \t\treturn 0;\n \n \tmode = ntohl(mode);\n@@ -581,7 +582,8 @@ static int diff_cache(struct rev_info *revs,\n \t\tstruct cache_entry *ce = *ac;\n \t\tint same = (entries > 1) && ce_same_name(ce, ac[1]);\n \n-\t\tif (revs->diffopt.quiet && revs->diffopt.has_changes)\n+\t\tif (DIFF_OPT_TST(&revs->diffopt, QUIET) &&\n+\t\t\tDIFF_OPT_TST(&revs->diffopt, HAS_CHANGES))\n \t\t\tbreak;\n \n \t\tif (!ce_path_match(ce, pathspec))\ndiff --git a/diff.c b/diff.c\nindex 6bb902f..97c9a59 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -827,10 +827,10 @@ static void show_stats(struct diffstat_t* data, struct diff_options *options)\n \t}\n \n \t/* Find the longest filename and max number of changes */\n-\treset = diff_get_color(options->color_diff, DIFF_RESET);\n-\tset = diff_get_color(options->color_diff, DIFF_PLAIN);\n-\tadd_c = diff_get_color(options->color_diff, DIFF_FILE_NEW);\n-\tdel_c = diff_get_color(options->color_diff, DIFF_FILE_OLD);\n+\treset = diff_get_color_opt(options, DIFF_RESET);\n+\tset   = diff_get_color_opt(options, DIFF_PLAIN);\n+\tadd_c = diff_get_color_opt(options, DIFF_FILE_NEW);\n+\tdel_c = diff_get_color_opt(options, DIFF_FILE_OLD);\n \n \tfor (i = 0; i < data->nr; i++) {\n \t\tstruct diffstat_file *file = data->files[i];\n@@ -1256,8 +1256,8 @@ static void builtin_diff(const char *name_a,\n \tmmfile_t mf1, mf2;\n \tconst char *lbl[2];\n \tchar *a_one, *b_two;\n-\tconst char *set = diff_get_color(o->color_diff, DIFF_METAINFO);\n-\tconst char *reset = diff_get_color(o->color_diff, DIFF_RESET);\n+\tconst char *set = diff_get_color_opt(o, DIFF_METAINFO);\n+\tconst char *reset = diff_get_color_opt(o, DIFF_RESET);\n \n \ta_one = quote_two(\"a/\", name_a + (*name_a == '/'));\n \tb_two = quote_two(\"b/\", name_b + (*name_b == '/'));\n@@ -1290,7 +1290,7 @@ static void builtin_diff(const char *name_a,\n \t\t\tgoto free_ab_and_return;\n \t\tif (complete_rewrite) {\n \t\t\temit_rewrite_diff(name_a, name_b, one, two,\n-\t\t\t\t\to->color_diff);\n+\t\t\t\t\tDIFF_OPT_TST(o, COLOR_DIFF));\n \t\t\to->found_changes = 1;\n \t\t\tgoto free_ab_and_return;\n \t\t}\n@@ -1299,13 +1299,13 @@ static void builtin_diff(const char *name_a,\n \tif (fill_mmfile(&mf1, one) < 0 || fill_mmfile(&mf2, two) < 0)\n \t\tdie(\"unable to read files to diff\");\n \n-\tif (!o->text &&\n+\tif (!DIFF_OPT_TST(o, TEXT) &&\n \t    (diff_filespec_is_binary(one) || diff_filespec_is_binary(two))) {\n \t\t/* Quite common confusing case */\n \t\tif (mf1.size == mf2.size &&\n \t\t    !memcmp(mf1.ptr, mf2.ptr, mf1.size))\n \t\t\tgoto free_ab_and_return;\n-\t\tif (o->binary)\n+\t\tif (DIFF_OPT_TST(o, BINARY))\n \t\t\temit_binary_diff(&mf1, &mf2);\n \t\telse\n \t\t\tprintf(\"Binary files %s and %s differ\\n\",\n@@ -1328,7 +1328,7 @@ static void builtin_diff(const char *name_a,\n \t\tmemset(&xecfg, 0, sizeof(xecfg));\n \t\tmemset(&ecbdata, 0, sizeof(ecbdata));\n \t\tecbdata.label_path = lbl;\n-\t\tecbdata.color_diff = o->color_diff;\n+\t\tecbdata.color_diff = DIFF_OPT_TST(o, COLOR_DIFF);\n \t\tecbdata.found_changesp = &o->found_changes;\n \t\txpp.flags = XDF_NEED_MINIMAL | o->xdl_opts;\n \t\txecfg.ctxlen = o->context;\n@@ -1344,11 +1344,11 @@ static void builtin_diff(const char *name_a,\n \t\tecb.outf = xdiff_outf;\n \t\tecb.priv = &ecbdata;\n \t\tecbdata.xm.consume = fn_out_consume;\n-\t\tif (o->color_diff_words)\n+\t\tif (DIFF_OPT_TST(o, COLOR_DIFF_WORDS))\n \t\t\tecbdata.diff_words =\n \t\t\t\txcalloc(1, sizeof(struct diff_words_data));\n \t\txdl_diff(&mf1, &mf2, &xpp, &xecfg, &ecb);\n-\t\tif (o->color_diff_words)\n+\t\tif (DIFF_OPT_TST(o, COLOR_DIFF_WORDS))\n \t\t\tfree_diff_words_data(&ecbdata);\n \t}\n \n@@ -1422,7 +1422,7 @@ static void builtin_checkdiff(const char *name_a, const char *name_b,\n \tdata.xm.consume = checkdiff_consume;\n \tdata.filename = name_b ? name_b : name_a;\n \tdata.lineno = 0;\n-\tdata.color_diff = o->color_diff;\n+\tdata.color_diff = DIFF_OPT_TST(o, COLOR_DIFF);\n \n \tif (fill_mmfile(&mf1, one) < 0 || fill_mmfile(&mf2, two) < 0)\n \t\tdie(\"unable to read files to diff\");\n@@ -1866,7 +1866,7 @@ static void run_diff_cmd(const char *pgm,\n \t\t\t struct diff_options *o,\n \t\t\t int complete_rewrite)\n {\n-\tif (!o->allow_external)\n+\tif (!DIFF_OPT_TST(o, ALLOW_EXTERNAL))\n \t\tpgm = NULL;\n \telse {\n \t\tconst char *cmd = external_diff_attr(name);\n@@ -1964,9 +1964,9 @@ static void run_diff(struct diff_filepair *p, struct diff_options *o)\n \t}\n \n \tif (hashcmp(one->sha1, two->sha1)) {\n-\t\tint abbrev = o->full_index ? 40 : DEFAULT_ABBREV;\n+\t\tint abbrev = DIFF_OPT_TST(o, FULL_INDEX) ? 40 : DEFAULT_ABBREV;\n \n-\t\tif (o->binary) {\n+\t\tif (DIFF_OPT_TST(o, 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@@ -2058,7 +2058,10 @@ void diff_setup(struct diff_options *options)\n \n \toptions->change = diff_change;\n \toptions->add_remove = diff_addremove;\n-\toptions->color_diff = diff_use_color_default;\n+\tif (diff_use_color_default)\n+\t\tDIFF_OPT_SET(options, COLOR_DIFF);\n+\telse\n+\t\tDIFF_OPT_CLR(options, COLOR_DIFF);\n \toptions->detect_rename = diff_detect_rename_default;\n }\n \n@@ -2077,7 +2080,7 @@ int diff_setup_done(struct diff_options *options)\n \tif (count > 1)\n \t\tdie(\"--name-only, --name-status, --check and -s are mutually exclusive\");\n \n-\tif (options->find_copies_harder)\n+\tif (DIFF_OPT_TST(options, FIND_COPIES_HARDER))\n \t\toptions->detect_rename = DIFF_DETECT_COPY;\n \n \tif (options->output_format & (DIFF_FORMAT_NAME |\n@@ -2101,12 +2104,12 @@ int diff_setup_done(struct diff_options *options)\n \t\t\t\t      DIFF_FORMAT_SHORTSTAT |\n \t\t\t\t      DIFF_FORMAT_SUMMARY |\n \t\t\t\t      DIFF_FORMAT_CHECKDIFF))\n-\t\toptions->recursive = 1;\n+\t\tDIFF_OPT_SET(options, RECURSIVE);\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->recursive = 1;\n+\t\tDIFF_OPT_SET(options, RECURSIVE);\n \n \tif (options->detect_rename && options->rename_limit < 0)\n \t\toptions->rename_limit = diff_rename_limit_default;\n@@ -2128,9 +2131,9 @@ int 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->quiet) {\n+\tif (DIFF_OPT_TST(options, QUIET)) {\n \t\toptions->output_format = DIFF_FORMAT_NO_OUTPUT;\n-\t\toptions->exit_with_status = 1;\n+\t\tDIFF_OPT_SET(options, EXIT_WITH_STATUS);\n \t}\n \n \t/*\n@@ -2138,7 +2141,7 @@ int diff_setup_done(struct diff_options *options)\n \t * upon the first hit.  We need to run diff as usual.\n \t */\n \tif (options->pickaxe || options->filter)\n-\t\toptions->quiet = 0;\n+\t\tDIFF_OPT_CLR(options, QUIET);\n \n \treturn 0;\n }\n@@ -2201,15 +2204,12 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)\n \t\toptions->output_format |= DIFF_FORMAT_PATCH;\n \telse if (!strcmp(arg, \"--raw\"))\n \t\toptions->output_format |= DIFF_FORMAT_RAW;\n-\telse if (!strcmp(arg, \"--patch-with-raw\")) {\n+\telse if (!strcmp(arg, \"--patch-with-raw\"))\n \t\toptions->output_format |= DIFF_FORMAT_PATCH | DIFF_FORMAT_RAW;\n-\t}\n-\telse if (!strcmp(arg, \"--numstat\")) {\n+\telse if (!strcmp(arg, \"--numstat\"))\n \t\toptions->output_format |= DIFF_FORMAT_NUMSTAT;\n-\t}\n-\telse if (!strcmp(arg, \"--shortstat\")) {\n+\telse if (!strcmp(arg, \"--shortstat\"))\n \t\toptions->output_format |= DIFF_FORMAT_SHORTSTAT;\n-\t}\n \telse if (!prefixcmp(arg, \"--stat\")) {\n \t\tchar *end;\n \t\tint width = options->stat_width;\n@@ -2241,33 +2241,30 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)\n \t\toptions->output_format |= DIFF_FORMAT_CHECKDIFF;\n \telse if (!strcmp(arg, \"--summary\"))\n \t\toptions->output_format |= DIFF_FORMAT_SUMMARY;\n-\telse if (!strcmp(arg, \"--patch-with-stat\")) {\n+\telse if (!strcmp(arg, \"--patch-with-stat\"))\n \t\toptions->output_format |= DIFF_FORMAT_PATCH | DIFF_FORMAT_DIFFSTAT;\n-\t}\n \telse if (!strcmp(arg, \"-z\"))\n \t\toptions->line_termination = 0;\n \telse if (!prefixcmp(arg, \"-l\"))\n \t\toptions->rename_limit = strtoul(arg+2, NULL, 10);\n \telse if (!strcmp(arg, \"--full-index\"))\n-\t\toptions->full_index = 1;\n+\t\tDIFF_OPT_SET(options, FULL_INDEX);\n \telse if (!strcmp(arg, \"--binary\")) {\n \t\toptions->output_format |= DIFF_FORMAT_PATCH;\n-\t\toptions->binary = 1;\n-\t}\n-\telse if (!strcmp(arg, \"-a\") || !strcmp(arg, \"--text\")) {\n-\t\toptions->text = 1;\n+\t\tDIFF_OPT_SET(options, BINARY);\n \t}\n+\telse if (!strcmp(arg, \"-a\") || !strcmp(arg, \"--text\"))\n+\t\tDIFF_OPT_SET(options, TEXT);\n \telse if (!strcmp(arg, \"--name-only\"))\n \t\toptions->output_format |= DIFF_FORMAT_NAME;\n \telse if (!strcmp(arg, \"--name-status\"))\n \t\toptions->output_format |= DIFF_FORMAT_NAME_STATUS;\n \telse if (!strcmp(arg, \"-R\"))\n-\t\toptions->reverse_diff = 1;\n+\t\tDIFF_OPT_SET(options, REVERSE_DIFF);\n \telse if (!prefixcmp(arg, \"-S\"))\n \t\toptions->pickaxe = arg + 2;\n-\telse if (!strcmp(arg, \"-s\")) {\n+\telse if (!strcmp(arg, \"-s\"))\n \t\toptions->output_format |= DIFF_FORMAT_NO_OUTPUT;\n-\t}\n \telse if (!prefixcmp(arg, \"-O\"))\n \t\toptions->orderfile = arg + 2;\n \telse if (!prefixcmp(arg, \"--diff-filter=\"))\n@@ -2277,28 +2274,25 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)\n \telse if (!strcmp(arg, \"--pickaxe-regex\"))\n \t\toptions->pickaxe_opts = DIFF_PICKAXE_REGEX;\n \telse if (!prefixcmp(arg, \"-B\")) {\n-\t\tif ((options->break_opt =\n-\t\t     diff_scoreopt_parse(arg)) == -1)\n+\t\tif ((options->break_opt = diff_scoreopt_parse(arg)) == -1)\n \t\t\treturn -1;\n \t}\n \telse if (!prefixcmp(arg, \"-M\")) {\n-\t\tif ((options->rename_score =\n-\t\t     diff_scoreopt_parse(arg)) == -1)\n+\t\tif ((options->rename_score = diff_scoreopt_parse(arg)) == -1)\n \t\t\treturn -1;\n \t\toptions->detect_rename = DIFF_DETECT_RENAME;\n \t}\n \telse if (!prefixcmp(arg, \"-C\")) {\n \t\tif (options->detect_rename == DIFF_DETECT_COPY)\n-\t\t\toptions->find_copies_harder = 1;\n-\t\tif ((options->rename_score =\n-\t\t     diff_scoreopt_parse(arg)) == -1)\n+\t\t\tDIFF_OPT_SET(options, FIND_COPIES_HARDER);\n+\t\tif ((options->rename_score = diff_scoreopt_parse(arg)) == -1)\n \t\t\treturn -1;\n \t\toptions->detect_rename = DIFF_DETECT_COPY;\n \t}\n \telse if (!strcmp(arg, \"--find-copies-harder\"))\n-\t\toptions->find_copies_harder = 1;\n+\t\tDIFF_OPT_SET(options, FIND_COPIES_HARDER);\n \telse if (!strcmp(arg, \"--follow\"))\n-\t\toptions->follow_renames = 1;\n+\t\tDIFF_OPT_SET(options, FOLLOW_RENAMES);\n \telse if (!strcmp(arg, \"--abbrev\"))\n \t\toptions->abbrev = DEFAULT_ABBREV;\n \telse if (!prefixcmp(arg, \"--abbrev=\")) {\n@@ -2309,9 +2303,9 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)\n \t\t\toptions->abbrev = 40;\n \t}\n \telse if (!strcmp(arg, \"--color\"))\n-\t\toptions->color_diff = 1;\n+\t\tDIFF_OPT_SET(options, COLOR_DIFF);\n \telse if (!strcmp(arg, \"--no-color\"))\n-\t\toptions->color_diff = 0;\n+\t\tDIFF_OPT_CLR(options, COLOR_DIFF);\n \telse if (!strcmp(arg, \"-w\") || !strcmp(arg, \"--ignore-all-space\"))\n \t\toptions->xdl_opts |= XDF_IGNORE_WHITESPACE;\n \telse if (!strcmp(arg, \"-b\") || !strcmp(arg, \"--ignore-space-change\"))\n@@ -2319,17 +2313,17 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)\n \telse if (!strcmp(arg, \"--ignore-space-at-eol\"))\n \t\toptions->xdl_opts |= XDF_IGNORE_WHITESPACE_AT_EOL;\n \telse if (!strcmp(arg, \"--color-words\"))\n-\t\toptions->color_diff = options->color_diff_words = 1;\n+\t\toptions->flags |= DIFF_OPT_COLOR_DIFF | DIFF_OPT_COLOR_DIFF_WORDS;\n \telse if (!strcmp(arg, \"--no-renames\"))\n \t\toptions->detect_rename = 0;\n \telse if (!strcmp(arg, \"--exit-code\"))\n-\t\toptions->exit_with_status = 1;\n+\t\tDIFF_OPT_SET(options, EXIT_WITH_STATUS);\n \telse if (!strcmp(arg, \"--quiet\"))\n-\t\toptions->quiet = 1;\n+\t\tDIFF_OPT_SET(options, QUIET);\n \telse if (!strcmp(arg, \"--ext-diff\"))\n-\t\toptions->allow_external = 1;\n+\t\tDIFF_OPT_SET(options, ALLOW_EXTERNAL);\n \telse if (!strcmp(arg, \"--no-ext-diff\"))\n-\t\toptions->allow_external = 0;\n+\t\tDIFF_OPT_CLR(options, ALLOW_EXTERNAL);\n \telse\n \t\treturn 0;\n \treturn 1;\n@@ -3084,7 +3078,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->no_index)\n+\t\t\tif (!DIFF_OPT_TST(diffopt, NO_INDEX))\n \t\t\t\tdiffopt->skip_stat_unmatch++;\n \t\t\tdiff_free_filepair(p);\n \t\t}\n@@ -3095,10 +3089,10 @@ static void diffcore_skip_stat_unmatch(struct diff_options *diffopt)\n \n void diffcore_std(struct diff_options *options)\n {\n-\tif (options->quiet)\n+\tif (DIFF_OPT_TST(options, QUIET))\n \t\treturn;\n \n-\tif (options->skip_stat_unmatch && !options->find_copies_harder)\n+\tif (options->skip_stat_unmatch && !DIFF_OPT_TST(options, FIND_COPIES_HARDER))\n \t\tdiffcore_skip_stat_unmatch(options);\n \tif (options->break_opt != -1)\n \t\tdiffcore_break(options->break_opt);\n@@ -3113,7 +3107,10 @@ void diffcore_std(struct diff_options *options)\n \tdiff_resolve_rename_copy();\n \tdiffcore_apply_filter(options->filter);\n \n-\toptions->has_changes = !!diff_queued_diff.nr;\n+\tif (diff_queued_diff.nr)\n+\t\tDIFF_OPT_SET(options, HAS_CHANGES);\n+\telse\n+\t\tDIFF_OPT_CLR(options, HAS_CHANGES);\n }\n \n \n@@ -3137,7 +3134,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->reverse_diff)\n+\tif (DIFF_OPT_TST(options, REVERSE_DIFF))\n \t\taddremove = (addremove == '+' ? '-' :\n \t\t\t     addremove == '-' ? '+' : addremove);\n \n@@ -3152,7 +3149,7 @@ void diff_addremove(struct diff_options *options,\n \t\tfill_filespec(two, sha1, mode);\n \n \tdiff_queue(&diff_queued_diff, one, two);\n-\toptions->has_changes = 1;\n+\tDIFF_OPT_SET(options, HAS_CHANGES);\n }\n \n void diff_change(struct diff_options *options,\n@@ -3164,7 +3161,7 @@ void diff_change(struct diff_options *options,\n \tchar concatpath[PATH_MAX];\n \tstruct diff_filespec *one, *two;\n \n-\tif (options->reverse_diff) {\n+\tif (DIFF_OPT_TST(options, REVERSE_DIFF)) {\n \t\tunsigned tmp;\n \t\tconst unsigned char *tmp_c;\n \t\ttmp = old_mode; old_mode = new_mode; new_mode = tmp;\n@@ -3178,7 +3175,7 @@ void diff_change(struct diff_options *options,\n \tfill_filespec(two, new_sha1, new_mode);\n \n \tdiff_queue(&diff_queued_diff, one, two);\n-\toptions->has_changes = 1;\n+\tDIFF_OPT_SET(options, HAS_CHANGES);\n }\n \n void diff_unmerge(struct diff_options *options,\ndiff --git a/diff.h b/diff.h\nindex 4546aad..6ff2b0e 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -43,26 +43,32 @@ typedef void (*diff_format_fn_t)(struct diff_queue_struct *q,\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_COLOR_DIFF          (1 <<  8)\n+#define DIFF_OPT_COLOR_DIFF_WORDS    (1 <<  9)\n+#define DIFF_OPT_HAS_CHANGES         (1 << 10)\n+#define DIFF_OPT_QUIET               (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_TST(opts, flag)    ((opts)->flags & DIFF_OPT_##flag)\n+#define DIFF_OPT_SET(opts, flag)    ((opts)->flags |= DIFF_OPT_##flag)\n+#define DIFF_OPT_CLR(opts, flag)    ((opts)->flags &= ~DIFF_OPT_##flag)\n+\n struct diff_options {\n \tconst char *filter;\n \tconst char *orderfile;\n \tconst char *pickaxe;\n \tconst char *single_follow;\n-\tunsigned recursive:1,\n-\t\t tree_in_recursive:1,\n-\t\t binary:1,\n-\t\t text:1,\n-\t\t full_index:1,\n-\t\t silent_on_remove:1,\n-\t\t find_copies_harder:1,\n-\t\t follow_renames:1,\n-\t\t color_diff:1,\n-\t\t color_diff_words:1,\n-\t\t has_changes:1,\n-\t\t quiet:1,\n-\t\t no_index:1,\n-\t\t allow_external:1,\n-\t\t exit_with_status:1;\n+\tunsigned flags;\n \tint context;\n \tint break_opt;\n \tint detect_rename;\n@@ -71,7 +77,6 @@ struct diff_options {\n \tint output_format;\n \tint pickaxe_opts;\n \tint rename_score;\n-\tint reverse_diff;\n \tint rename_limit;\n \tint setup;\n \tint abbrev;\n@@ -105,6 +110,9 @@ enum color_diff {\n \tDIFF_WHITESPACE = 7,\n };\n const char *diff_get_color(int diff_use_color, enum color_diff ix);\n+#define diff_get_color_opt(o, ix) \\\n+\tdiff_get_color(DIFF_OPT_TST((o), COLOR_DIFF), ix)\n+\n \n extern const char mime_boundary_leader[];\n \ndiff --git a/log-tree.c b/log-tree.c\nindex a34beb0..1f3fcf1 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -245,8 +245,7 @@ void show_log(struct rev_info *opt, const char *sep)\n \t\t\topt->diffopt.stat_sep = buffer;\n \t\t}\n \t} else if (opt->commit_format != CMIT_FMT_USERFORMAT) {\n-\t\tfputs(diff_get_color(opt->diffopt.color_diff, DIFF_COMMIT),\n-\t\t      stdout);\n+\t\tfputs(diff_get_color_opt(&opt->diffopt, DIFF_COMMIT), stdout);\n \t\tif (opt->commit_format != CMIT_FMT_ONELINE)\n \t\t\tfputs(\"commit \", stdout);\n \t\tif (commit->object.flags & BOUNDARY)\n@@ -266,8 +265,7 @@ void show_log(struct rev_info *opt, const char *sep)\n \t\t\t       diff_unique_abbrev(parent->object.sha1,\n \t\t\t\t\t\t  abbrev_commit));\n \t\tshow_decorations(commit);\n-\t\tprintf(\"%s\",\n-\t\t       diff_get_color(opt->diffopt.color_diff, DIFF_RESET));\n+\t\tprintf(\"%s\", diff_get_color_opt(&opt->diffopt, DIFF_RESET));\n \t\tputchar(opt->commit_format == CMIT_FMT_ONELINE ? ' ' : '\\n');\n \t\tif (opt->reflog_info) {\n \t\t\tshow_reflog_message(opt->reflog_info,\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 6c6f595..9a1e2f2 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -366,7 +366,7 @@ static struct path_list *get_renames(struct tree *tree,\n \n \trenames = xcalloc(1, sizeof(struct path_list));\n \tdiff_setup(&opts);\n-\topts.recursive = 1;\n+\tDIFF_OPT_SET(&opts, RECURSIVE);\n \topts.detect_rename = DIFF_DETECT_RENAME;\n \topts.rename_limit = rename_limit;\n \topts.output_format = DIFF_FORMAT_NO_OUTPUT;\ndiff --git a/patch-ids.c b/patch-ids.c\nindex a288fac..3be5d31 100644\n--- a/patch-ids.c\n+++ b/patch-ids.c\n@@ -121,7 +121,7 @@ int init_patch_ids(struct patch_ids *ids)\n {\n \tmemset(ids, 0, sizeof(*ids));\n \tdiff_setup(&ids->diffopts);\n-\tids->diffopts.recursive = 1;\n+\tDIFF_OPT_SET(&ids->diffopts, RECURSIVE);\n \tif (diff_setup_done(&ids->diffopts) < 0)\n \t\treturn error(\"diff_setup_done failed\");\n \treturn 0;\ndiff --git a/revision.c b/revision.c\nindex 931f978..040214f 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -252,7 +252,7 @@ static void file_add_remove(struct diff_options *options,\n \t}\n \ttree_difference = diff;\n \tif (tree_difference == REV_TREE_DIFFERENT)\n-\t\toptions->has_changes = 1;\n+\t\tDIFF_OPT_SET(options, HAS_CHANGES);\n }\n \n static void file_change(struct diff_options *options,\n@@ -262,7 +262,7 @@ static void file_change(struct diff_options *options,\n \t\t const char *base, const char *path)\n {\n \ttree_difference = REV_TREE_DIFFERENT;\n-\toptions->has_changes = 1;\n+\tDIFF_OPT_SET(options, HAS_CHANGES);\n }\n \n static int rev_compare_tree(struct rev_info *revs, struct tree *t1, struct tree *t2)\n@@ -272,7 +272,7 @@ static int rev_compare_tree(struct rev_info *revs, struct tree *t1, struct tree\n \tif (!t2)\n \t\treturn REV_TREE_DIFFERENT;\n \ttree_difference = REV_TREE_SAME;\n-\trevs->pruning.has_changes = 0;\n+\tDIFF_OPT_CLR(&revs->pruning, HAS_CHANGES);\n \tif (diff_tree_sha1(t1->object.sha1, t2->object.sha1, \"\",\n \t\t\t   &revs->pruning) < 0)\n \t\treturn REV_TREE_DIFFERENT;\n@@ -296,7 +296,7 @@ static int rev_same_tree_as_empty(struct rev_info *revs, struct tree *t1)\n \tinit_tree_desc(&empty, \"\", 0);\n \n \ttree_difference = REV_TREE_SAME;\n-\trevs->pruning.has_changes = 0;\n+\tDIFF_OPT_CLR(&revs->pruning, HAS_CHANGES);\n \tretval = diff_tree(&empty, &real, \"\", &revs->pruning);\n \tfree(tree);\n \n@@ -688,8 +688,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.recursive = 1;\n-\trevs->pruning.quiet = 1;\n+\tDIFF_OPT_SET(&revs->pruning, RECURSIVE);\n+\tDIFF_OPT_SET(&revs->pruning, QUIET);\n \trevs->pruning.add_remove = file_add_remove;\n \trevs->pruning.change = file_change;\n \trevs->lifo = 1;\n@@ -1086,13 +1086,13 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch\n \t\t\t}\n \t\t\tif (!strcmp(arg, \"-r\")) {\n \t\t\t\trevs->diff = 1;\n-\t\t\t\trevs->diffopt.recursive = 1;\n+\t\t\t\tDIFF_OPT_SET(&revs->diffopt, RECURSIVE);\n \t\t\t\tcontinue;\n \t\t\t}\n \t\t\tif (!strcmp(arg, \"-t\")) {\n \t\t\t\trevs->diff = 1;\n-\t\t\t\trevs->diffopt.recursive = 1;\n-\t\t\t\trevs->diffopt.tree_in_recursive = 1;\n+\t\t\t\tDIFF_OPT_SET(&revs->diffopt, RECURSIVE);\n+\t\t\t\tDIFF_OPT_SET(&revs->diffopt, TREE_IN_RECURSIVE);\n \t\t\t\tcontinue;\n \t\t\t}\n \t\t\tif (!strcmp(arg, \"-m\")) {\n@@ -1274,7 +1274,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch\n \t\trevs->diff = 1;\n \n \t/* Pickaxe and rename following needs diffs */\n-\tif (revs->diffopt.pickaxe || revs->diffopt.follow_renames)\n+\tif (revs->diffopt.pickaxe || DIFF_OPT_TST(&revs->diffopt, FOLLOW_RENAMES))\n \t\trevs->diff = 1;\n \n \tif (revs->topo_order)\n@@ -1283,7 +1283,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch\n \tif (revs->prune_data) {\n \t\tdiff_tree_setup_paths(revs->prune_data, &revs->pruning);\n \t\t/* Can't prune commits with rename following: the paths change.. */\n-\t\tif (!revs->diffopt.follow_renames)\n+\t\tif (!DIFF_OPT_TST(&revs->diffopt, FOLLOW_RENAMES))\n \t\t\trevs->prune = 1;\n \t\tif (!revs->full_diff)\n \t\t\tdiff_tree_setup_paths(revs->prune_data, &revs->diffopt);\ndiff --git a/tree-diff.c b/tree-diff.c\nindex 7c261fd..aa0a100 100644\n--- a/tree-diff.c\n+++ b/tree-diff.c\n@@ -39,7 +39,7 @@ static int compare_tree_entry(struct tree_desc *t1, struct tree_desc *t2, const\n \t\tshow_entry(opt, \"+\", t2, base, baselen);\n \t\treturn 1;\n \t}\n-\tif (!opt->find_copies_harder && !hashcmp(sha1, sha2) && mode1 == mode2)\n+\tif (!DIFF_OPT_TST(opt, FIND_COPIES_HARDER) && !hashcmp(sha1, sha2) && mode1 == mode2)\n \t\treturn 0;\n \n \t/*\n@@ -52,10 +52,10 @@ static int compare_tree_entry(struct tree_desc *t1, struct tree_desc *t2, const\n \t\treturn 0;\n \t}\n \n-\tif (opt->recursive && S_ISDIR(mode1)) {\n+\tif (DIFF_OPT_TST(opt, RECURSIVE) && S_ISDIR(mode1)) {\n \t\tint retval;\n \t\tchar *newbase = malloc_base(base, baselen, path1, pathlen1);\n-\t\tif (opt->tree_in_recursive)\n+\t\tif (DIFF_OPT_TST(opt, TREE_IN_RECURSIVE))\n \t\t\topt->change(opt, mode1, mode2,\n \t\t\t\t    sha1, sha2, base, path1);\n \t\tretval = diff_tree_sha1(sha1, sha2, newbase, opt);\n@@ -206,7 +206,7 @@ static void show_entry(struct diff_options *opt, const char *prefix, struct tree\n \tconst char *path;\n \tconst unsigned char *sha1 = tree_entry_extract(desc, &path, &mode);\n \n-\tif (opt->recursive && S_ISDIR(mode)) {\n+\tif (DIFF_OPT_TST(opt, RECURSIVE) && S_ISDIR(mode)) {\n \t\tenum object_type type;\n \t\tint pathlen = tree_entry_len(path, sha1);\n \t\tchar *newbase = malloc_base(base, baselen, path, pathlen);\n@@ -257,7 +257,7 @@ int diff_tree(struct tree_desc *t1, struct tree_desc *t2, const char *base, stru\n \tint baselen = strlen(base);\n \n \tfor (;;) {\n-\t\tif (opt->quiet && opt->has_changes)\n+\t\tif (DIFF_OPT_TST(opt, QUIET) && DIFF_OPT_TST(opt, HAS_CHANGES))\n \t\t\tbreak;\n \t\tif (opt->nr_paths) {\n \t\t\tskip_uninteresting(t1, base, baselen, opt);\n@@ -315,7 +315,7 @@ static void try_to_follow_renames(struct tree_desc *t1, struct tree_desc *t2, co\n \tq->nr = 0;\n \n \tdiff_setup(&diff_opts);\n-\tdiff_opts.recursive = 1;\n+\tDIFF_OPT_SET(&diff_opts, RECURSIVE);\n \tdiff_opts.detect_rename = DIFF_DETECT_RENAME;\n \tdiff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;\n \tdiff_opts.single_follow = opt->paths[0];\n@@ -380,7 +380,7 @@ int diff_tree_sha1(const unsigned char *old, const unsigned char *new, const cha\n \tinit_tree_desc(&t1, tree1, size1);\n \tinit_tree_desc(&t2, tree2, size2);\n \tretval = diff_tree(&t1, &t2, base, opt);\n-\tif (opt->follow_renames && diff_might_be_rename()) {\n+\tif (DIFF_OPT_TST(opt, FOLLOW_RENAMES) && diff_might_be_rename()) {\n \t\tinit_tree_desc(&t1, tree1, size1);\n \t\tinit_tree_desc(&t2, tree2, size2);\n \t\ttry_to_follow_renames(&t1, &t2, base, opt);\n-- \n1.5.3.5.1630.g4b3b4\n"}]}