want_color: automatically fallback to color.ui
[gitweb.git] / parse-options.c
index cd926869166fe28d4c116840be6921de7aa3cbda..12a5b25d09ca8725c7e948192235f3d53b331b18 100644 (file)
@@ -373,7 +373,7 @@ int parse_options_step(struct parse_opt_ctx_t *ctx,
                        if (parse_nodash_opt(ctx, arg, options) == 0)
                                continue;
                        if (ctx->flags & PARSE_OPT_STOP_AT_NON_OPTION)
-                               break;
+                               return PARSE_OPT_NON_OPTION;
                        ctx->out[ctx->cpidx++] = ctx->argv[0];
                        continue;
                }
@@ -455,6 +455,7 @@ int parse_options(int argc, const char **argv, const char *prefix,
        switch (parse_options_step(&ctx, options, usagestr)) {
        case PARSE_OPT_HELP:
                exit(129);
+       case PARSE_OPT_NON_OPTION:
        case PARSE_OPT_DONE:
                break;
        default: /* PARSE_OPT_UNKNOWN */
@@ -560,14 +561,14 @@ static int usage_with_options_internal(struct parse_opt_ctx_t *ctx,
        return PARSE_OPT_HELP;
 }
 
-void usage_with_options(const char * const *usagestr,
+void NORETURN usage_with_options(const char * const *usagestr,
                        const struct option *opts)
 {
        usage_with_options_internal(NULL, usagestr, opts, 0, 1);
        exit(129);
 }
 
-void usage_msg_opt(const char *msg,
+void NORETURN usage_msg_opt(const char *msg,
                   const char * const *usagestr,
                   const struct option *options)
 {
@@ -619,7 +620,7 @@ int parse_opt_color_flag_cb(const struct option *opt, const char *arg,
 
        if (!arg)
                arg = unset ? "never" : (const char *)opt->defval;
-       value = git_config_colorbool(NULL, arg, -1);
+       value = git_config_colorbool(NULL, arg);
        if (value < 0)
                return opterror(opt,
                        "expects \"always\", \"auto\", or \"never\"", 0);