Signed-off-by: Pierre Habouzit <madcoder@debian.org>
---
Documentation/git-rev-parse.txt | 15 ++++++++++-----
builtin-rev-parse.c | 25 ++++++++++++++-----------
2 files changed, 24 insertions(+), 16 deletions(-)
diff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.=
txt
index f02f6bb..e961c20 100644
--- a/Documentation/git-rev-parse.txt
+++ b/Documentation/git-rev-parse.txt
@@ -325,7 +325,7 @@ The lines after the separator describe the options.
Each line of options has this format:
=20
------------
-<opt_spec><arg_spec>? SP+ help LF
+<opt_spec><flags>? SP+ help LF
------------
=20
`<opt_spec>`::
@@ -334,10 +334,15 @@ Each line of options has this format:
is necessary. `h,help`, `dry-run` and `f` are all three correct
`<opt_spec>`.
=20
-`<arg_spec>`::
- an `<arg_spec>` tells the option parser if the option has an argument
- (`=3D`), an optional one (`?` though its use is discouraged) or none
- (no `<arg_spec>` in that case).
+`<flags>`::
+ `<flags>` are any suite of `*`, `=3D` or `?`.
+ * Use `=3D` if the option take an argument.
+
+ * Use `?` to mean that the option is optional (though its use is discoura=
ged).
+
+ * Use `*` to mean that this option should not be listed in the usage
+ generated for the `-h` argument. It's shown for `--help-all` as
+ documented in linkgit:gitcli[5].
=20
The remainder of the line, after stripping the spaces, is used
as the help associated to the option.
diff --git a/builtin-rev-parse.c b/builtin-rev-parse.c
index 90dbb9d..d1ea73a 100644
--- a/builtin-rev-parse.c
+++ b/builtin-rev-parse.c
@@ -322,18 +322,21 @@ static int cmd_parseopt(int argc, const char **argv, =
const char *prefix)
o->type =3D OPTION_CALLBACK;
o->help =3D xstrdup(skipspaces(s));
o->value =3D &parsed;
+ o->flags =3D PARSE_OPT_NOARG;
o->callback =3D &parseopt_dump;
- switch (s[-1]) {
- case '=3D':
- s--;
- break;
- case '?':
- o->flags =3D PARSE_OPT_OPTARG;
- s--;
- break;
- default:
- o->flags =3D PARSE_OPT_NOARG;
- break;
+ while (s > sb.buf && strchr("*=3D?", s[-1])) {
+ switch (*--s) {
+ case '=3D':
+ o->flags &=3D ~PARSE_OPT_NOARG;
+ break;
+ case '?':
+ o->flags &=3D ~PARSE_OPT_NOARG;
+ o->flags |=3D PARSE_OPT_OPTARG;
+ break;
+ case '*':
+ o->flags |=3D PARSE_OPT_HIDDEN;
+ break;
+ }
}
=20
if (s - sb.buf =3D=3D 1) /* short option only */
--=20
1.5.4.3.343.g6846