From: René Scharfe Date: Sun, 8 Mar 2009 18:16:58 +0000 (+0100) Subject: parseopt: make usage optional X-Git-Tag: v1.6.3-rc0~186 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=49b6180252000e37ec47ccb4156240ed625949ed;p=git.git parseopt: make usage optional Allow usagestr to be NULL and don't display any help screen in this case. This is useful to implement incremental parsers. Signed-off-by: Rene Scharfe Signed-off-by: Junio C Hamano --- diff --git a/parse-options.c b/parse-options.c index 8b21dea72..51e804b3b 100644 --- a/parse-options.c +++ b/parse-options.c @@ -364,6 +364,9 @@ int parse_options(int argc, const char **argv, const struct option *options, int usage_with_options_internal(const char * const *usagestr, const struct option *opts, int full) { + if (!usagestr) + return PARSE_OPT_HELP; + fprintf(stderr, "usage: %s\n", *usagestr++); while (*usagestr && **usagestr) fprintf(stderr, " or: %s\n", *usagestr++);