git-p4: Unset P4DIFF environment variable when using 'p4 -du diff'
[gitweb.git] / builtin-rev-parse.c
index b9af1a5a554e21338531b88cd34bcb767d5f3848..0351d54435b566d5030f3a83df57fb140fffc143 100644 (file)
@@ -315,25 +315,31 @@ static int cmd_parseopt(int argc, const char **argv, const char *prefix)
                s = strchr(sb.buf, ' ');
                if (!s || *sb.buf == ' ') {
                        o->type = OPTION_GROUP;
-                       o->help = xstrdup(skipspaces(s));
+                       o->help = xstrdup(skipspaces(sb.buf));
                        continue;
                }
 
                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 */