summaryrefslogtreecommitdiff
path: root/builtin-rev-parse.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-03-08 21:29:59 -0800
committerJunio C Hamano <gitster@pobox.com>2008-03-08 21:29:59 -0800
commit1cbcefb107776ce2da374697bb4f6e2bd22ff73f (patch)
tree1d1bcd19b1433a8c18220e083414be93881657ca /builtin-rev-parse.c
parent175f5595511b047a320e5c6163c642ac1fc34681 (diff)
parent580d5bffdea56dfae1e745dbda94f326bb161274 (diff)
downloadgit-1cbcefb107776ce2da374697bb4f6e2bd22ff73f.tar.gz
Merge branch 'ph/parseopt'
* ph/parseopt: parse-options: new option type to treat an option-like parameter as an argument. parse-opt: bring PARSE_OPT_HIDDEN and NONEG to git-rev-parse --parseopt
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 */