git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/3] parse-options: bring PARSE_OPT_NONEG to git-rev-parse --parseopt.

From
Pierre Habouzit <madcoder@debian.org>
Date
Mar 2, 2008, 10:35 UTC
Message-ID
<20080302103515.GA21078@artemis.madism.org>
In-Reply-To
<20080302082138.GB5407@artemis.madism.org>
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
---
  While we're at it, this one could probably be squashed on top of the
  previous one.
 Documentation/git-rev-parse.txt |    8 +++++---
 builtin-rev-parse.c             |    5 ++++-
 2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt
index e961c20..6513c2e 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:
 
 ------------
-<opt_spec><flags>? SP+ help LF
+<opt_spec><flags>* SP+ help LF
 ------------
 
 `<opt_spec>`::
@@ -335,8 +335,8 @@ Each line of options has this format:
 	`<opt_spec>`.
 
 `<flags>`::
-	`<flags>` are any suite of `*`, `=` or `?`.
-	* Use `=` if the option take an argument.
+	`<flags>` are of `*`, `=`, `?` or `!`.
+	* Use `=` if the option takes an argument.
 
 	* Use `?` to mean that the option is optional (though its use is discouraged).
 
@@ -344,6 +344,8 @@ Each line of options has this format:
 	  generated for the `-h` argument. It's shown for `--help-all` as
 	  documented in linkgit:gitcli[5].
 
+	* Use `!` to not make the corresponding negated long option available.
+
 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 d1ea73a..0351d54 100644
--- a/builtin-rev-parse.c
+++ b/builtin-rev-parse.c
@@ -324,7 +324,7 @@ static int cmd_parseopt(int argc, const char **argv, const char *prefix)
 		o->value = &parsed;
 		o->flags = PARSE_OPT_NOARG;
 		o->callback = &parseopt_dump;
-		while (s > sb.buf && strchr("*=?", s[-1])) {
+		while (s > sb.buf && strchr("*=?!", s[-1])) {
 			switch (*--s) {
 			case '=':
 				o->flags &= ~PARSE_OPT_NOARG;
@@ -333,6 +333,9 @@ static int cmd_parseopt(int argc, const char **argv, const char *prefix)
 				o->flags &= ~PARSE_OPT_NOARG;
 				o->flags |= PARSE_OPT_OPTARG;
 				break;
+			case '!':
+				o->flags |= PARSE_OPT_NONEG;
+				break;
 			case '*':
 				o->flags |= PARSE_OPT_HIDDEN;
 				break;
-- 
1.5.4.3.471.ga96e8.dirty
Previous: Pierre HabouzitNext: Pierre Habouzit
Message 2 of 3 in “parse-opt: bring PARSE_OPT_HIDDEN to git-rev-parse --parseopt”
  1. parse-opt: bring PARSE_OPT_HIDDEN to git-rev-parse --parseoptPierre Habouzit, Mar 2, 2008
  2. 2/3 parse-options: bring PARSE_OPT_NONEG to git-rev-parse --parseopt.Pierre Habouzit, Mar 2, 2008
  3. 3/3 parse-options: new option type to treat an option-like parameter as an argument.Pierre Habouzit, Mar 2, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.