summaryrefslogtreecommitdiff
path: root/parse-options.c
diff options
context:
space:
mode:
authorRené Scharfe <rene.scharfe@lsrfire.ath.cx>2009-05-07 21:44:17 +0200
committerJunio C Hamano <gitster@pobox.com>2009-05-09 00:28:53 -0700
commit2f4b97f91071f5060bf2da482cf8b0d70486d808 (patch)
treefabe7f74fafa1410676c5d15cac2de3fa93ef1ef /parse-options.c
parent5a0e4a2a326966aabb566164a7571291e34adabd (diff)
downloadgit-2f4b97f91071f5060bf2da482cf8b0d70486d808.tar.gz
parseopt: add OPT_NEGBIT
Add OPTION_NEGBIT and OPT_NEGBIT, mirroring OPTION_BIT and OPT_BIT. OPT_NEGBIT can be used together with OPT_BIT to define two options that cancel each other out. Note: this patch removes the reminder from the test script because it adds a test for --no-or4 and there already was one for --or4. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'parse-options.c')
-rw-r--r--parse-options.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/parse-options.c b/parse-options.c
index cf71bcffd2..a8c05e3dc2 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -50,6 +50,7 @@ static int get_value(struct parse_opt_ctx_t *p,
/* FALLTHROUGH */
case OPTION_BOOLEAN:
case OPTION_BIT:
+ case OPTION_NEGBIT:
case OPTION_SET_INT:
case OPTION_SET_PTR:
return opterror(opt, "takes no value", flags);
@@ -66,6 +67,13 @@ static int get_value(struct parse_opt_ctx_t *p,
*(int *)opt->value |= opt->defval;
return 0;
+ case OPTION_NEGBIT:
+ if (unset)
+ *(int *)opt->value |= opt->defval;
+ else
+ *(int *)opt->value &= ~opt->defval;
+ return 0;
+
case OPTION_BOOLEAN:
*(int *)opt->value = unset ? 0 : *(int *)opt->value + 1;
return 0;