aboutsummaryrefslogtreecommitdiff
path: root/parse-options.c
diff options
context:
space:
mode:
authorRené Scharfe <rene.scharfe@lsrfire.ath.cx>2009-03-08 19:16:58 +0100
committerJunio C Hamano <gitster@pobox.com>2009-03-08 13:36:41 -0700
commit49b6180252000e37ec47ccb4156240ed625949ed (patch)
treea4aa47b6c28e7589344e8fa4d52676a7bc3a1694 /parse-options.c
parentb92891f9783ae197bb84b90d8404ad08c3875fa1 (diff)
downloadgit-49b6180252000e37ec47ccb4156240ed625949ed.tar.gz
git-49b6180252000e37ec47ccb4156240ed625949ed.tar.xz
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 <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'parse-options.c')
-rw-r--r--parse-options.c3
1 files changed, 3 insertions, 0 deletions
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++);