unpack-trees: allow Porcelain to give different error messages
[gitweb.git] / parse-options.c
index b32c9ea66c7ae1e83564cd25d63d5cfd6c1589b5..acf3fe3a1a82cd99e7bd6e0ff9d6d3d7e344a155 100644 (file)
@@ -259,6 +259,8 @@ int parse_options(int argc, const char **argv, const struct option *options,
                const char *arg = args.argv[0];
 
                if (*arg != '-' || !arg[1]) {
+                       if (flags & PARSE_OPT_STOP_AT_NON_OPTION)
+                               break;
                        args.out[args.cpidx++] = args.argv[0];
                        continue;
                }
@@ -342,7 +344,7 @@ void usage_with_options_internal(const char * const *usagestr,
                        break;
                case OPTION_INTEGER:
                        if (opts->flags & PARSE_OPT_OPTARG)
-                               pos += fprintf(stderr, " [<n>]");
+                               pos += fprintf(stderr, "[<n>]");
                        else
                                pos += fprintf(stderr, " <n>");
                        break;
@@ -407,3 +409,10 @@ int parse_opt_abbrev_cb(const struct option *opt, const char *arg, int unset)
        *(int *)(opt->value) = v;
        return 0;
 }
+
+int parse_opt_approxidate_cb(const struct option *opt, const char *arg,
+                            int unset)
+{
+       *(unsigned long *)(opt->value) = approxidate(arg);
+       return 0;
+}