summaryrefslogtreecommitdiff
path: root/parse-options.c
diff options
context:
space:
mode:
authorJohannes Schindelin <Johannes.Schindelin@gmx.de>2009-07-27 20:49:56 +0200
committerJunio C Hamano <gitster@pobox.com>2009-07-31 07:47:38 -0700
commit86b5efb2864ca50d86437f94ec4c26042cba193e (patch)
tree3b041b273415ae2391f9e05384a2adcc19752584 /parse-options.c
parente6580020057afd207b7cfb9c96905f99e13cfe4d (diff)
downloadgit-86b5efb2864ca50d86437f94ec4c26042cba193e.tar.gz
parse-opt: optionally show "--no-" option string
It is usually better to have positive options, to avoid confusing double negations. However, sometimes it is desirable to show the negative option in the help. Introduce the flag PARSE_OPT_NEGHELP to do that. Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'parse-options.c')
-rw-r--r--parse-options.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/parse-options.c b/parse-options.c
index f7ce523a61..3b71fbb541 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -511,7 +511,7 @@ static int usage_with_options_internal(const char * const *usagestr,
continue;
pos = fprintf(stderr, " ");
- if (opts->short_name) {
+ if (opts->short_name && !(opts->flags & PARSE_OPT_NEGHELP)) {
if (opts->flags & PARSE_OPT_NODASH)
pos += fprintf(stderr, "%c", opts->short_name);
else
@@ -520,7 +520,9 @@ static int usage_with_options_internal(const char * const *usagestr,
if (opts->long_name && opts->short_name)
pos += fprintf(stderr, ", ");
if (opts->long_name)
- pos += fprintf(stderr, "--%s", opts->long_name);
+ pos += fprintf(stderr, "--%s%s",
+ (opts->flags & PARSE_OPT_NEGHELP) ? "no-" : "",
+ opts->long_name);
if (opts->type == OPTION_NUMBER)
pos += fprintf(stderr, "-NUM");