{"thread":{"id":"28515","subject":"[PATCH] parse-options: deprecate OPT_BOOLEAN","startedAt":"2011-09-27T23:56:49Z","lastAt":"2011-09-28T19:47:14Z","messageCount":9,"participants":["Junio C Hamano","Jeff King","Miles Bader","René Scharfe"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"176370","messageId":"7v39fhv8se.fsf@alter.siamese.dyndns.org","threadId":"28515","inReplyTo":null,"subject":"[PATCH] parse-options: deprecate OPT_BOOLEAN","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-09-27T23:56:49Z","receivedAt":"2011-09-27T23:56:49Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"It is natural to expect that an option defined with OPT_BOOLEAN() could be\nused in this way:\n\n\tint option = -1; /* unspecified */\n\n\tstruct option options[] = {\n\t\tOPT_BOOLEAN(0, \"option\", &option, \"set option\"),\n                OPT_END()\n\t};\n\tparse_options(ac, av, prefix, options, usage, 0);\n\n        if (option < 0)\n        \t... do the default thing ...\n\telse if (!option)\n\t\t... --no-option was given ...\n\telse\n\t\t... --option was given ...\n\nto easily tell three cases apart:\n\n - There is no mention of the `--option` on the command line;\n - The variable is positively set with `--option`; or\n - The variable is explicitly negated with `--no-option`.\n\nUnfortunately, this is not the case. OPT_BOOLEAN() increments the variable\nevery time `--option` is given, and resets it to zero when `--no-option`\nis given.\n\nAs a first step to remedy this, introduce a true boolean OPT_BOOL(), and\nrename OPT_BOOLEAN() to OPT_COUNTUP(). To help transitioning, OPT_BOOLEAN\nand OPTION_BOOLEAN are defined as deprecated synonyms to OPT_COUNTUP and\nOPTION_COUNTUP respectively.\n\nThis is what db7244b (parse-options new features., 2007-11-07) from four\nyears ago started by marking OPTION_BOOLEAN as \"INCR would have been a\nbetter name\".\n\nSome existing users do depend on the count-up semantics; for example,\nusers of OPT__VERBOSE() could use it to raise the verbosity level with\nrepeated use of `-v` on the command line, but they probably should be\nrewritten to use OPT__VERBOSITY() instead these days.  I suspect that some\nusers of OPT__FORCE() may also use it to implement different level of\nforcibleness but I didn't check.\n\nOn top of this patch, here are the remaining clean-up tasks that other\npeople can help:\n\n - Look at each hit in \"git grep -e OPT_BOOLEAN\"; trace all uses of the\n   value that is set to the underlying variable, and if it can proven that\n   the variable is only used as a boolean, replace it with OPT_BOOL(). If\n   the caller does depend on the count-up semantics, replace it with\n   OPT_COUNTUP() instead.\n\n - Same for OPTION_BOOLEAN; replace it with OPTION_SET_INT and arrange to\n   set 1 to the variable for a true boolean, and otherwise replace it with\n   OPTION_COUNTUP.\n\n - Look at each hit in \"git grep -e OPT__VERBOSE -e OPT__QUIET\" and see if\n   they can be replaced with OPT__VERBOSITY().\n\nI'll follow this message up with a separate patch as an example.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n Documentation/technical/api-parse-options.txt |   16 +++++++++++-----\n parse-options.c                               |    4 ++--\n parse-options.h                               |   10 ++++++++--\n 3 files changed, 21 insertions(+), 9 deletions(-)\n\ndiff --git a/Documentation/technical/api-parse-options.txt b/Documentation/technical/api-parse-options.txt\nindex f6a4a36..acf1760 100644\n--- a/Documentation/technical/api-parse-options.txt\n+++ b/Documentation/technical/api-parse-options.txt\n@@ -135,9 +135,14 @@ There are some macros to easily define options:\n \tdescribes the group or an empty string.\n \tStart the description with an upper-case letter.\n \n-`OPT_BOOLEAN(short, long, &int_var, description)`::\n-\tIntroduce a boolean option.\n-\t`int_var` is incremented on each use.\n+`OPT_BOOL(short, long, &int_var, description)`::\n+\tIntroduce a boolean option. `int_var` is set to one with\n+\t`--option` and set to zero with `--no-option`.\n+\n+`OPT_COUNTUP(short, long, &int_var, description)`::\n+\tIntroduce a count-up option.\n+\t`int_var` is incremented on each use of `--option`, and\n+\treset to zero with `--no-option`.\n \n `OPT_BIT(short, long, &int_var, description, mask)`::\n \tIntroduce a boolean option.\n@@ -148,8 +153,9 @@ There are some macros to easily define options:\n \tIf used, `int_var` is bitwise-anded with the inverted `mask`.\n \n `OPT_SET_INT(short, long, &int_var, description, integer)`::\n-\tIntroduce a boolean option.\n-\tIf used, set `int_var` to `integer`.\n+\tIntroduce an integer option.\n+\t`int_var` is set to `integer` with `--option`, and\n+\treset to zero with `--no-option`.\n \n `OPT_SET_PTR(short, long, &ptr_var, description, ptr)`::\n \tIntroduce a boolean option.\ndiff --git a/parse-options.c b/parse-options.c\nindex 503ab5d..f0098eb 100644\n--- a/parse-options.c\n+++ b/parse-options.c\n@@ -83,7 +83,7 @@ static int get_value(struct parse_opt_ctx_t *p,\n \t\t\t*(int *)opt->value &= ~opt->defval;\n \t\treturn 0;\n \n-\tcase OPTION_BOOLEAN:\n+\tcase OPTION_COUNTUP:\n \t\t*(int *)opt->value = unset ? 0 : *(int *)opt->value + 1;\n \t\treturn 0;\n \n@@ -319,7 +319,7 @@ static void parse_options_check(const struct option *opts)\n \t\t\terr |= optbug(opts, \"uses feature \"\n \t\t\t\t\t\"not supported for dashless options\");\n \t\tswitch (opts->type) {\n-\t\tcase OPTION_BOOLEAN:\n+\t\tcase OPTION_COUNTUP:\n \t\tcase OPTION_BIT:\n \t\tcase OPTION_NEGBIT:\n \t\tcase OPTION_SET_INT:\ndiff --git a/parse-options.h b/parse-options.h\nindex 59e0b52..22c0273 100644\n--- a/parse-options.h\n+++ b/parse-options.h\n@@ -10,7 +10,7 @@ enum parse_opt_type {\n \t/* options with no arguments */\n \tOPTION_BIT,\n \tOPTION_NEGBIT,\n-\tOPTION_BOOLEAN, /* _INCR would have been a better name */\n+\tOPTION_COUNTUP,\n \tOPTION_SET_INT,\n \tOPTION_SET_PTR,\n \t/* options with arguments (usually) */\n@@ -21,6 +21,9 @@ enum parse_opt_type {\n \tOPTION_FILENAME\n };\n \n+/* Deprecated synonym */\n+#define OPTION_BOOLEAN OPTION_COUNTUP\n+\n enum parse_opt_flags {\n \tPARSE_OPT_KEEP_DASHDASH = 1,\n \tPARSE_OPT_STOP_AT_NON_OPTION = 2,\n@@ -122,10 +125,11 @@ struct option {\n \t\t\t\t      PARSE_OPT_NOARG, NULL, (b) }\n #define OPT_NEGBIT(s, l, v, h, b)   { OPTION_NEGBIT, (s), (l), (v), NULL, \\\n \t\t\t\t      (h), PARSE_OPT_NOARG, NULL, (b) }\n-#define OPT_BOOLEAN(s, l, v, h)     { OPTION_BOOLEAN, (s), (l), (v), NULL, \\\n+#define OPT_COUNTUP(s, l, v, h)     { OPTION_COUNTUP, (s), (l), (v), NULL, \\\n \t\t\t\t      (h), PARSE_OPT_NOARG }\n #define OPT_SET_INT(s, l, v, h, i)  { OPTION_SET_INT, (s), (l), (v), NULL, \\\n \t\t\t\t      (h), PARSE_OPT_NOARG, NULL, (i) }\n+#define OPT_BOOL(s, l, v, h)        OPT_SET_INT(s, l, v, h, 1)\n #define OPT_SET_PTR(s, l, v, h, p)  { OPTION_SET_PTR, (s), (l), (v), NULL, \\\n \t\t\t\t      (h), PARSE_OPT_NOARG, NULL, (p) }\n #define OPT_INTEGER(s, l, v, h)     { OPTION_INTEGER, (s), (l), (v), \"n\", (h) }\n@@ -149,6 +153,8 @@ struct option {\n \t{ OPTION_CALLBACK, (s), (l), (v), \"when\", (h), PARSE_OPT_OPTARG, \\\n \t\tparse_opt_color_flag_cb, (intptr_t)\"always\" }\n \n+/* Deprecated synonym */\n+#define OPT_BOOLEAN OPT_COUNTUP\n \n /* parse_options() will filter out the processed options and leave the\n  * non-option arguments in argv[].\n"},{"id":"176371","messageId":"7vy5x9tu4a.fsf@alter.siamese.dyndns.org","threadId":"28515","inReplyTo":"7v39fhv8se.fsf@alter.siamese.dyndns.org","subject":"[PATCH] archive.c: use OPT_BOOL()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-09-27T23:59:01Z","receivedAt":"2011-09-27T23:59:01Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"The list variable (which is OPT_BOOLEAN) is initialized to 0 and only\nchecked against 0 in the code, so it is safe to use OPT_BOOL().\n\nThe worktree_attributes variable (which is OPT_BOOLEAN) is initialized to\n0 and later assigned to a field with the same name in struct archive_args,\nwhich is a bitfield of width 1. It is safe and even more correct to use\nOPT_BOOL() here; the new test in 5001 demonstrates why using OPT_COUNTUP\nis wrong.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n * This is an example of \"the remaining clean-up tasks\" I mentioned.\n\n archive.c               |    4 ++--\n t/t5001-archive-attr.sh |    9 +++++++++\n 2 files changed, 11 insertions(+), 2 deletions(-)\n\ndiff --git a/archive.c b/archive.c\nindex 3fd7f47..2ae740a 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -318,7 +318,7 @@ static int parse_archive_args(int argc, const char **argv,\n \t\t\t\"prepend prefix to each pathname in the archive\"),\n \t\tOPT_STRING('o', \"output\", &output, \"file\",\n \t\t\t\"write the archive to this file\"),\n-\t\tOPT_BOOLEAN(0, \"worktree-attributes\", &worktree_attributes,\n+\t\tOPT_BOOL(0, \"worktree-attributes\", &worktree_attributes,\n \t\t\t\"read .gitattributes in working directory\"),\n \t\tOPT__VERBOSE(&verbose, \"report archived files on stderr\"),\n \t\tOPT__COMPR('0', &compression_level, \"store only\", 0),\n@@ -332,7 +332,7 @@ static int parse_archive_args(int argc, const char **argv,\n \t\tOPT__COMPR_HIDDEN('8', &compression_level, 8),\n \t\tOPT__COMPR('9', &compression_level, \"compress better\", 9),\n \t\tOPT_GROUP(\"\"),\n-\t\tOPT_BOOLEAN('l', \"list\", &list,\n+\t\tOPT_BOOL('l', \"list\", &list,\n \t\t\t\"list supported archive formats\"),\n \t\tOPT_GROUP(\"\"),\n \t\tOPT_STRING(0, \"remote\", &remote, \"repo\",\ndiff --git a/t/t5001-archive-attr.sh b/t/t5001-archive-attr.sh\nindex 02d4d22..f47d871 100755\n--- a/t/t5001-archive-attr.sh\n+++ b/t/t5001-archive-attr.sh\n@@ -57,6 +57,15 @@ test_expect_missing\tworktree/ignored\n test_expect_exists\tworktree/ignored-by-tree\n test_expect_missing\tworktree/ignored-by-worktree\n \n+test_expect_success 'git archive --worktree-attributes option' '\n+\tgit archive --worktree-attributes --worktree-attributes HEAD >worktree.tar &&\n+\t(mkdir worktree2 && cd worktree2 && \"$TAR\" xf -) <worktree.tar\n+'\n+\n+test_expect_missing\tworktree2/ignored\n+test_expect_exists\tworktree2/ignored-by-tree\n+test_expect_missing\tworktree2/ignored-by-worktree\n+\n test_expect_success 'git archive vs. bare' '\n \t(cd bare && git archive HEAD) >bare-archive.tar &&\n \ttest_cmp archive.tar bare-archive.tar\n"},{"id":"176379","messageId":"20110928035809.GC10662@sigill.intra.peff.net","threadId":"28515","inReplyTo":"7v39fhv8se.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] parse-options: deprecate OPT_BOOLEAN","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2011-09-28T03:58:09Z","receivedAt":"2011-09-28T03:58:09Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Sep 27, 2011 at 04:56:49PM -0700, Junio C Hamano wrote:\n\n> It is natural to expect that an option defined with OPT_BOOLEAN() could be\n> used in this way:\n> [...]\n> to easily tell three cases apart:\n> \n>  - There is no mention of the `--option` on the command line;\n>  - The variable is positively set with `--option`; or\n>  - The variable is explicitly negated with `--no-option`.\n> \n> Unfortunately, this is not the case. OPT_BOOLEAN() increments the variable\n> every time `--option` is given, and resets it to zero when `--no-option`\n> is given.\n\nYes, please. I remember being bitten by this at one point. Your\ntransition plan makes sense to me.\n\nCan OPT_UYN be folded into this, as well?\n\n-Peff\n"},{"id":"176383","messageId":"7vbou5s3c0.fsf@alter.siamese.dyndns.org","threadId":"28515","inReplyTo":"20110928035809.GC10662@sigill.intra.peff.net","subject":"Re: [PATCH] parse-options: deprecate OPT_BOOLEAN","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-09-28T04:22:55Z","receivedAt":"2011-09-28T04:22:55Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> On Tue, Sep 27, 2011 at 04:56:49PM -0700, Junio C Hamano wrote:\n>\n>> It is natural to expect that an option defined with OPT_BOOLEAN() could be\n>> used in this way:\n>> [...]\n>> to easily tell three cases apart:\n>> \n>>  - There is no mention of the `--option` on the command line;\n>>  - The variable is positively set with `--option`; or\n>>  - The variable is explicitly negated with `--no-option`.\n>> \n>> Unfortunately, this is not the case. OPT_BOOLEAN() increments the variable\n>> every time `--option` is given, and resets it to zero when `--no-option`\n>> is given.\n>\n> Yes, please. I remember being bitten by this at one point. Your\n> transition plan makes sense to me.\n\nThe best part of it is that this leaves many small bite-sized tasks, one\n\"struct option\" per patch, most of which can be done by people who are not\nuber experts in Git internals ;-).\n\n> Can OPT_UYN be folded into this, as well?\n\nPerhaps, but I would prefer to keep this simple at least during the first\npass of eradicating OPT_BOOLEAN and OPTION_BOOLEAN. After that is done, we\nmay want to tackle OPT_UYN() that uses 2 for \"unset\", which feels a tad\nunnatural. It has only one user---even if it turns out that it was a\nmistake, the damage would be relatively limited to fix it.\n"},{"id":"176395","messageId":"buok48tggji.fsf@dhlpc061.dev.necel.com","threadId":"28515","inReplyTo":"7v39fhv8se.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] parse-options: deprecate OPT_BOOLEAN","fromName":"Miles Bader","fromEmail":"miles@gnu.org","sentAt":"2011-09-28T09:30:41Z","receivedAt":"2011-09-28T09:30:41Z","isPatch":true,"sender":{"key":"miles@gnu.org","avatar":"https://gravatar.com/avatar/01069b69593af7bff28e2f97afeb3644ae6fe2f5f56cb3a8cf34c5fb8c36efe5?d=mp&s=160"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n> As a first step to remedy this, introduce a true boolean OPT_BOOL(), and\n> rename OPT_BOOLEAN() to OPT_COUNTUP().\n\nHmm ...  \"OPT_COUNTED\"?\n\n-miles\n\n-- \nvalues of β will give rise to dom!\n"},{"id":"176438","messageId":"4E835CFE.7020501@lsrfire.ath.cx","threadId":"28515","inReplyTo":"7v39fhv8se.fsf@alter.siamese.dyndns.org","subject":"[PATCH 1/3] parseopt: add OPT_NOOP_NOARG","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2011-09-28T17:44:30Z","receivedAt":"2011-09-28T17:44:30Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Add OPT_NOOP_NOARG, a helper macro to define deprecated options in a\nstandard way.  The help text is taken from the no-op option -r of\ngit revert.\n\nThe callback could be made to emit a (conditional?) warning later.  And\nwe could also add OPT_NOOP (requiring an argument) etc. as needed.\n\nSigned-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>\n---\nTwo follow-up patches use the new macro to replace OPTION_BOOLEAN in\nthree cases.  Could be squashed in.\n\n Documentation/technical/api-parse-options.txt |    5 +++++\n parse-options-cb.c                            |    5 +++++\n parse-options.h                               |    6 +++++-\n t/t0040-parse-options.sh                      |    2 +-\n test-parse-options.c                          |    1 +\n 5 files changed, 17 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/technical/api-parse-options.txt b/Documentation/technical/api-parse-options.txt\nindex f6a4a36..c209046 100644\n--- a/Documentation/technical/api-parse-options.txt\n+++ b/Documentation/technical/api-parse-options.txt\n@@ -198,6 +198,11 @@ There are some macros to easily define options:\n \t\"auto\", set `int_var` to 1 if stdout is a tty or a pager,\n \t0 otherwise.\n \n+`OPT_NOOP_NOARG(short, long)`::\n+\tIntroduce an option that has no effect and takes no arguments.\n+\tUse it to hide deprecated options that are still to be recognized\n+\tand ignored silently.\n+\n \n The last element of the array must be `OPT_END()`.\n \ndiff --git a/parse-options-cb.c b/parse-options-cb.c\nindex 6db0921..0de5fb1 100644\n--- a/parse-options-cb.c\n+++ b/parse-options-cb.c\n@@ -123,3 +123,8 @@ int parse_opt_string_list(const struct option *opt, const char *arg, int unset)\n \tstring_list_append(v, xstrdup(arg));\n \treturn 0;\n }\n+\n+int parse_opt_noop_cb(const struct option *opt, const char *arg, int unset)\n+{\n+\treturn 0;\n+}\ndiff --git a/parse-options.h b/parse-options.h\nindex 59e0b52..47c11f3 100644\n--- a/parse-options.h\n+++ b/parse-options.h\n@@ -148,7 +148,10 @@ struct option {\n #define OPT_COLOR_FLAG(s, l, v, h) \\\n \t{ OPTION_CALLBACK, (s), (l), (v), \"when\", (h), PARSE_OPT_OPTARG, \\\n \t\tparse_opt_color_flag_cb, (intptr_t)\"always\" }\n-\n+#define OPT_NOOP_NOARG(s, l) \\\n+\t{ OPTION_CALLBACK, (s), (l), NULL, NULL, \\\n+\t  \"no-op (backward compatibility)\", \\\n+\t  PARSE_OPT_HIDDEN | PARSE_OPT_NOARG, parse_opt_noop_cb }\n \n /* parse_options() will filter out the processed options and leave the\n  * non-option arguments in argv[].\n@@ -210,6 +213,7 @@ extern int parse_opt_verbosity_cb(const struct option *, const char *, int);\n extern int parse_opt_with_commit(const struct option *, const char *, int);\n extern int parse_opt_tertiary(const struct option *, const char *, int);\n extern int parse_opt_string_list(const struct option *, const char *, int);\n+extern int parse_opt_noop_cb(const struct option *, const char *, int);\n \n #define OPT__VERBOSE(var, h)  OPT_BOOLEAN('v', \"verbose\", (var), (h))\n #define OPT__QUIET(var, h)    OPT_BOOLEAN('q', \"quiet\",   (var), (h))\ndiff --git a/t/t0040-parse-options.sh b/t/t0040-parse-options.sh\nindex 007f39d..a1e4616 100755\n--- a/t/t0040-parse-options.sh\n+++ b/t/t0040-parse-options.sh\n@@ -87,7 +87,7 @@ EOF\n test_expect_success 'long options' '\n \ttest-parse-options --boolean --integer 1729 --boolean --string2=321 \\\n \t\t--verbose --verbose --no-dry-run --abbrev=10 --file fi.le\\\n-\t\t> output 2> output.err &&\n+\t\t--obsolete > output 2> output.err &&\n \ttest ! -s output.err &&\n \ttest_cmp expect output\n '\ndiff --git a/test-parse-options.c b/test-parse-options.c\nindex 91a5701..36487c4 100644\n--- a/test-parse-options.c\n+++ b/test-parse-options.c\n@@ -54,6 +54,7 @@ int main(int argc, const char **argv)\n \t\tOPT_STRING(0, \"string2\", &string, \"str\", \"get another string\"),\n \t\tOPT_STRING(0, \"st\", &string, \"st\", \"get another string (pervert ordering)\"),\n \t\tOPT_STRING('o', NULL, &string, \"str\", \"get another string\"),\n+\t\tOPT_NOOP_NOARG(0, \"obsolete\"),\n \t\tOPT_SET_PTR(0, \"default-string\", &string,\n \t\t\t\"set string to default\", (unsigned long)\"default\"),\n \t\tOPT_STRING_LIST(0, \"list\", &list, \"str\", \"add str to list\"),\n-- \n1.7.7.rc2\n"},{"id":"176440","messageId":"4E835DC6.2040505@lsrfire.ath.cx","threadId":"28515","inReplyTo":"4E835CFE.7020501@lsrfire.ath.cx","subject":"[PATCH 2/3] revert: use OPT_NOOP_NOARG","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2011-09-28T17:47:50Z","receivedAt":"2011-09-28T17:47:50Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>\n---\n builtin/revert.c |    4 +---\n 1 files changed, 1 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/revert.c b/builtin/revert.c\nindex 3117776..db5b1d4 100644\n--- a/builtin/revert.c\n+++ b/builtin/revert.c\n@@ -72,12 +72,10 @@ static int option_parse_x(const struct option *opt,\n static void parse_args(int argc, const char **argv)\n {\n \tconst char * const * usage_str = revert_or_cherry_pick_usage();\n-\tint noop;\n \tstruct option options[] = {\n \t\tOPT_BOOLEAN('n', \"no-commit\", &no_commit, \"don't automatically commit\"),\n \t\tOPT_BOOLEAN('e', \"edit\", &edit, \"edit the commit message\"),\n-\t\t{ OPTION_BOOLEAN, 'r', NULL, &noop, NULL, \"no-op (backward compatibility)\",\n-\t\t  PARSE_OPT_NOARG | PARSE_OPT_HIDDEN, NULL, 0 },\n+\t\tOPT_NOOP_NOARG('r', NULL),\n \t\tOPT_BOOLEAN('s', \"signoff\", &signoff, \"add Signed-off-by:\"),\n \t\tOPT_INTEGER('m', \"mainline\", &mainline, \"parent number\"),\n \t\tOPT_RERERE_AUTOUPDATE(&allow_rerere_auto),\n-- \n1.7.7.rc2\n"},{"id":"176441","messageId":"4E835DCA.5010708@lsrfire.ath.cx","threadId":"28515","inReplyTo":"4E835CFE.7020501@lsrfire.ath.cx","subject":"[PATCH 3/3] apply: use OPT_NOOP_NOARG","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2011-09-28T17:47:54Z","receivedAt":"2011-09-28T17:47:54Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>\n---\n builtin/apply.c |    9 ++-------\n 1 files changed, 2 insertions(+), 7 deletions(-)\n\ndiff --git a/builtin/apply.c b/builtin/apply.c\nindex f2edc52..872e40a 100644\n--- a/builtin/apply.c\n+++ b/builtin/apply.c\n@@ -3831,7 +3831,6 @@ int cmd_apply(int argc, const char **argv, const char *prefix_)\n \tint i;\n \tint errs = 0;\n \tint is_not_gitdir = !startup_info->have_repository;\n-\tint binary;\n \tint force_apply = 0;\n \n \tconst char *whitespace_option = NULL;\n@@ -3850,12 +3849,8 @@ int cmd_apply(int argc, const char **argv, const char *prefix_)\n \t\t\t\"ignore additions made by the patch\"),\n \t\tOPT_BOOLEAN(0, \"stat\", &diffstat,\n \t\t\t\"instead of applying the patch, output diffstat for the input\"),\n-\t\t{ OPTION_BOOLEAN, 0, \"allow-binary-replacement\", &binary,\n-\t\t  NULL, \"old option, now no-op\",\n-\t\t  PARSE_OPT_HIDDEN | PARSE_OPT_NOARG },\n-\t\t{ OPTION_BOOLEAN, 0, \"binary\", &binary,\n-\t\t  NULL, \"old option, now no-op\",\n-\t\t  PARSE_OPT_HIDDEN | PARSE_OPT_NOARG },\n+\t\tOPT_NOOP_NOARG(0, \"allow-binary-replacement\"),\n+\t\tOPT_NOOP_NOARG(0, \"binary\"),\n \t\tOPT_BOOLEAN(0, \"numstat\", &numstat,\n \t\t\t\"shows number of added and deleted lines in decimal notation\"),\n \t\tOPT_BOOLEAN(0, \"summary\", &summary,\n-- \n1.7.7.rc2\n"},{"id":"176452","messageId":"7vlit8zby5.fsf@alter.siamese.dyndns.org","threadId":"28515","inReplyTo":"4E835CFE.7020501@lsrfire.ath.cx","subject":"Re: [PATCH 1/3] parseopt: add OPT_NOOP_NOARG","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-09-28T19:47:14Z","receivedAt":"2011-09-28T19:47:14Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thanks.\n"}]}