summaryrefslogtreecommitdiff
path: root/builtin-rev-parse.c
diff options
context:
space:
mode:
authorLibravatar Pierre Habouzit <madcoder@debian.org>2008-03-02 09:21:38 +0100
committerLibravatar Junio C Hamano <gitster@pobox.com>2008-03-02 14:07:47 -0800
commitff962a3f1900966d008d6f9eaf32095c42322b9d (patch)
treec7cfb02c2c90e3847646a95e5561d8ed7cd4a02c /builtin-rev-parse.c
parentallow git-am to run in a subdirectory (diff)
downloadtgif-ff962a3f1900966d008d6f9eaf32095c42322b9d.tar.xz
parse-opt: bring PARSE_OPT_HIDDEN and NONEG to git-rev-parse --parseopt
Signed-off-by: Pierre Habouzit <madcoder@debian.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-rev-parse.c')
-rw-r--r--builtin-rev-parse.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/builtin-rev-parse.c b/builtin-rev-parse.c
index 90dbb9d7c1..0351d54435 100644
--- a/builtin-rev-parse.c
+++ b/builtin-rev-parse.c
@@ -322,18 +322,24 @@ static int cmd_parseopt(int argc, const char **argv, const char *prefix)
o->type = OPTION_CALLBACK;
o->help = xstrdup(skipspaces(s));
o->value = &parsed;
+ o->flags = PARSE_OPT_NOARG;
o->callback = &parseopt_dump;
- switch (s[-1]) {
- case '=':
- s--;
- break;
- case '?':
- o->flags = PARSE_OPT_OPTARG;
- s--;
- break;
- default:
- o->flags = PARSE_OPT_NOARG;
- break;
+ while (s > sb.buf && strchr("*=?!", s[-1])) {
+ switch (*--s) {
+ case '=':
+ o->flags &= ~PARSE_OPT_NOARG;
+ break;
+ case '?':
+ o->flags &= ~PARSE_OPT_NOARG;
+ o->flags |= PARSE_OPT_OPTARG;
+ break;
+ case '!':
+ o->flags |= PARSE_OPT_NONEG;
+ break;
+ case '*':
+ o->flags |= PARSE_OPT_HIDDEN;
+ break;
+ }
}
if (s - sb.buf == 1) /* short option only */