git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Kerry, Richard" <richard.kerry@atos.net>
To: "René Scharfe" <l.s.r@web.de>, "Jeff King" <peff@peff.net>,
	"Junio C Hamano" <gitster@pobox.com>
Cc: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	"git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: [PATCH 6/6] parse-options: automatically infer PARSE_OPT_LITERAL_ARGHELP
Date: Fri, 3 Aug 2018 08:13:15 +0000	[thread overview]
Message-ID: <AM0PR02MB371539182CB9D1FD201D1CAF9C230@AM0PR02MB3715.eurprd02.prod.outlook.com> (raw)
In-Reply-To: <757ca573-3954-9c31-8a7b-56a2de8e3793@web.de>

[-- Attachment #1: Type: text/plain, Size: 10892 bytes --]


s/angular brackets/angle brackets/



I've never seen these called "angular brackets".


Richard Kerry
BNCS Engineer, SI SOL Telco & Media Vertical Practice
M: +44 (0)7812 325518
2nd Floor, MidCity Place, 71 High Holborn, London, WC1V 6EA
richard.kerry@atos.net<https://webmail.siemens-it-solutions.com/owa/redir.aspx?C=9fb20d019e3e4cb99344d708709a3177&URL=mailto%3arichard.kerry%40atos.net>

This e-mail and the documents attached are confidential and intended solely for the addressee; it may also be privileged. If you receive this e-mail in error, please notify the sender immediately and destroy it. As its integrity cannot be secured on the Internet, the Atos group liability cannot be triggered for the message content. Although the sender endeavours to maintain a computer virus-free network, the sender does not warrant that this transmission is virus-free and will not be liable for any damages resulting from any virus transmitted.


________________________________
From: git-owner@vger.kernel.org <git-owner@vger.kernel.org> on behalf of René Scharfe <l.s.r@web.de>
Sent: 02 August 2018 20:18
To: Jeff King; Junio C Hamano
Cc: Ævar Arnfjörð Bjarmason; git@vger.kernel.org
Subject: [PATCH 6/6] parse-options: automatically infer PARSE_OPT_LITERAL_ARGHELP

Parseopt wraps argument help strings in a pair of angular brackets by
default, to tell users that they need to replace it with an actual
value.  This is useful in most cases, because most option arguments
are indeed single values of a certain type.  The option
PARSE_OPT_LITERAL_ARGHELP needs to be used in option definitions with
arguments that have multiple parts or are literal strings.

Stop adding these angular brackets if special characters are present,
as they indicate that we don't deal with a simple placeholder.  This
simplifies the code a bit and makes defining special options slightly
easier.

Remove the flag PARSE_OPT_LITERAL_ARGHELP in the cases where the new
and more cautious handling suffices.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
---
The patch to add PARSE_OPT_LITERAL_ARGHELP for push --force-with-lease
should be applied before this one.

 builtin/add.c          | 5 ++---
 builtin/pack-objects.c | 2 +-
 builtin/read-tree.c    | 2 +-
 builtin/send-pack.c    | 3 +--
 builtin/shortlog.c     | 3 +--
 builtin/show-branch.c  | 2 +-
 builtin/update-index.c | 2 +-
 builtin/write-tree.c   | 5 ++---
 parse-options.c        | 3 ++-
 9 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/builtin/add.c b/builtin/add.c
index 84bfec9b73..ba1ff5689d 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -304,9 +304,8 @@ static struct option builtin_add_options[] = {
         OPT_BOOL( 0 , "refresh", &refresh_only, N_("don't add, only refresh the index")),
         OPT_BOOL( 0 , "ignore-errors", &ignore_add_errors, N_("just skip files which cannot be added because of errors")),
         OPT_BOOL( 0 , "ignore-missing", &ignore_missing, N_("check if - even missing - files are ignored in dry run")),
-       { OPTION_STRING, 0, "chmod", &chmod_arg, "(+|-)x",
-         N_("override the executable bit of the listed files"),
-         PARSE_OPT_LITERAL_ARGHELP },
+       OPT_STRING(0, "chmod", &chmod_arg, "(+|-)x",
+                  N_("override the executable bit of the listed files")),
         OPT_HIDDEN_BOOL(0, "warn-embedded-repo", &warn_on_embedded_repo,
                         N_("warn when adding an embedded repository")),
         OPT_END(),
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 3a5d1fa317..b2323613bc 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -3112,7 +3112,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
                          N_("similar to --all-progress when progress meter is shown")),
                 { OPTION_CALLBACK, 0, "index-version", NULL, N_("<version>[,<offset>]"),
                   N_("write the pack index file in the specified idx format version"),
-                 PARSE_OPT_LITERAL_ARGHELP, option_parse_index_version },
+                 0, option_parse_index_version },
                 OPT_MAGNITUDE(0, "max-pack-size", &pack_size_limit,
                               N_("maximum size of each output pack file")),
                 OPT_BOOL(0, "local", &local,
diff --git a/builtin/read-tree.c b/builtin/read-tree.c
index ebc43eb805..fbbc98e516 100644
--- a/builtin/read-tree.c
+++ b/builtin/read-tree.c
@@ -133,7 +133,7 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)
                          N_("same as -m, but discard unmerged entries")),
                 { OPTION_STRING, 0, "prefix", &opts.prefix, N_("<subdirectory>/"),
                   N_("read the tree into the index under <subdirectory>/"),
-                 PARSE_OPT_NONEG | PARSE_OPT_LITERAL_ARGHELP },
+                 PARSE_OPT_NONEG },
                 OPT_BOOL('u', NULL, &opts.update,
                          N_("update working tree with merge result")),
                 { OPTION_CALLBACK, 0, "exclude-per-directory", &opts,
diff --git a/builtin/send-pack.c b/builtin/send-pack.c
index 0b517c9368..724b484850 100644
--- a/builtin/send-pack.c
+++ b/builtin/send-pack.c
@@ -180,8 +180,7 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
                 { OPTION_CALLBACK,
                   0, CAS_OPT_NAME, &cas, N_("<refname>:<expect>"),
                   N_("require old value of ref to be at this value"),
-                 PARSE_OPT_OPTARG | PARSE_OPT_LITERAL_ARGHELP,
-                 parseopt_push_cas_option },
+                 PARSE_OPT_OPTARG, parseopt_push_cas_option },
                 OPT_END()
         };

diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index f555cf9e4f..3898a2c9c4 100644
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c
@@ -269,8 +269,7 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix)
                 OPT_BOOL('e', "email", &log.email,
                          N_("Show the email address of each author")),
                 { OPTION_CALLBACK, 'w', NULL, &log, N_("<w>[,<i1>[,<i2>]]"),
-                       N_("Linewrap output"),
-                       PARSE_OPT_OPTARG | PARSE_OPT_LITERAL_ARGHELP,
+                       N_("Linewrap output"), PARSE_OPT_OPTARG,
                         &parse_wrap_args },
                 OPT_END(),
         };
diff --git a/builtin/show-branch.c b/builtin/show-branch.c
index f2e985c00a..9106da1985 100644
--- a/builtin/show-branch.c
+++ b/builtin/show-branch.c
@@ -673,7 +673,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
                 { OPTION_CALLBACK, 'g', "reflog", &reflog_base, N_("<n>[,<base>]"),
                             N_("show <n> most recent ref-log entries starting at "
                                "base"),
-                           PARSE_OPT_OPTARG | PARSE_OPT_LITERAL_ARGHELP,
+                           PARSE_OPT_OPTARG,
                             parse_reflog_param },
                 OPT_END()
         };
diff --git a/builtin/update-index.c b/builtin/update-index.c
index 7feda6e271..293f59247b 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -973,7 +973,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
                         (parse_opt_cb *) cacheinfo_callback},
                 {OPTION_CALLBACK, 0, "chmod", &set_executable_bit, "(+|-)x",
                         N_("override the executable bit of the listed files"),
-                       PARSE_OPT_NONEG | PARSE_OPT_LITERAL_ARGHELP,
+                       PARSE_OPT_NONEG,
                         chmod_callback},
                 {OPTION_SET_INT, 0, "assume-unchanged", &mark_valid_only, NULL,
                         N_("mark files as \"not changing\""),
diff --git a/builtin/write-tree.c b/builtin/write-tree.c
index c9d3c544e7..cdcbf8264e 100644
--- a/builtin/write-tree.c
+++ b/builtin/write-tree.c
@@ -24,9 +24,8 @@ int cmd_write_tree(int argc, const char **argv, const char *unused_prefix)
         struct option write_tree_options[] = {
                 OPT_BIT(0, "missing-ok", &flags, N_("allow missing objects"),
                         WRITE_TREE_MISSING_OK),
-               { OPTION_STRING, 0, "prefix", &prefix, N_("<prefix>/"),
-                 N_("write tree object for a subdirectory <prefix>") ,
-                 PARSE_OPT_LITERAL_ARGHELP },
+               OPT_STRING(0, "prefix", &prefix, N_("<prefix>/"),
+                          N_("write tree object for a subdirectory <prefix>")),
                 { OPTION_BIT, 0, "ignore-cache-tree", &flags, NULL,
                   N_("only useful for debugging"),
                   PARSE_OPT_HIDDEN | PARSE_OPT_NOARG, NULL,
diff --git a/parse-options.c b/parse-options.c
index 7db84227ab..3b874a83a0 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -660,7 +660,8 @@ int parse_options(int argc, const char **argv, const char *prefix,
 static int usage_argh(const struct option *opts, FILE *outfile)
 {
         const char *s;
-       int literal = (opts->flags & PARSE_OPT_LITERAL_ARGHELP) || !opts->argh;
+       int literal = (opts->flags & PARSE_OPT_LITERAL_ARGHELP) ||
+               !opts->argh || !!strpbrk(opts->argh, "()<>[]|");
         if (opts->flags & PARSE_OPT_OPTARG)
                 if (opts->long_name)
                         s = literal ? "[=%s]" : "[=<%s>]";
--
2.18.0
Atos, Atos Consulting, Worldline and Canopy The Open Cloud Company are trading names used by the Atos group. The following trading entities are registered in England and Wales: Atos IT Services UK Limited (registered number 01245534), Atos Consulting Limited (registered number 04312380), Atos Worldline UK Limited (registered number 08514184) and Canopy The Open Cloud Company Limited (registration number 08011902). The registered office for each is at Second Floor, Mid City Place, 71 High Holborn, London, WC1V 6EA.  The VAT No. for each is: GB232327983.

This e-mail and the documents attached are confidential and intended solely for the addressee, and may contain confidential or privileged information. If you receive this e-mail in error, you are not authorised to copy, disclose, use or retain it. Please notify the sender immediately and delete this email from your systems. As emails may be intercepted, amended or lost, they are not secure. Atos therefore can accept no liability for any errors or their content. Although Atos endeavours to maintain a virus-free network, we do not warrant that this transmission is virus-free and can accept no liability for any damages resulting from any virus transmitted. The risks are deemed to be accepted by everyone who communicates with Atos by email.

[-- Attachment #2: Type: text/html, Size: 23320 bytes --]

  parent reply	other threads:[~2018-08-03  8:20 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-01 18:43 [PATCH] push: comment on a funny unbalanced option help Junio C Hamano
2018-08-01 20:46 ` Ævar Arnfjörð Bjarmason
2018-08-01 21:48   ` Junio C Hamano
2018-08-01 22:31     ` Ævar Arnfjörð Bjarmason
2018-08-02 12:16       ` René Scharfe
2018-08-02 14:21         ` Ævar Arnfjörð Bjarmason
2018-08-02 15:06           ` René Scharfe
2018-08-02 15:16             ` René Scharfe
2018-08-02 15:24           ` Junio C Hamano
2018-08-02 15:31         ` Junio C Hamano
2018-08-02 16:50           ` René Scharfe
2018-08-02 16:54           ` Jeff King
2018-08-02 18:46             ` René Scharfe
2018-08-02 19:17               ` [PATCH 1/6] add, update-index: fix --chmod argument help René Scharfe
2018-08-02 20:41                 ` Ævar Arnfjörð Bjarmason
2018-08-02 20:59                 ` Ramsay Jones
2018-08-02 21:17                   ` Junio C Hamano
2018-08-02 21:04                 ` Andrei Rybak
2018-08-02 21:16                   ` Junio C Hamano
2018-08-02 19:17               ` [PATCH 2/6] difftool: remove angular brackets from " René Scharfe
2018-08-02 19:17               ` [PATCH 3/6] pack-objects: specify --index-version argument help explicitly René Scharfe
2018-08-02 19:17               ` [PATCH 4/6] send-pack: specify --force-with-lease " René Scharfe
2018-08-02 19:18               ` [PATCH 5/6] shortlog: correct option help for -w René Scharfe
2018-08-02 19:18               ` [PATCH 6/6] parse-options: automatically infer PARSE_OPT_LITERAL_ARGHELP René Scharfe
2018-08-02 20:05                 ` Junio C Hamano
2018-08-03  8:13                 ` Kerry, Richard [this message]
2018-08-03 10:39                 ` Kerry, Richard
2018-08-02 20:01               ` [PATCH] push: comment on a funny unbalanced option help Junio C Hamano
2018-08-02 22:38                 ` René Scharfe
2018-08-03 15:29                   ` Junio C Hamano
2018-08-02 15:44     ` Re* " Junio C Hamano
2018-08-02 15:59       ` René Scharfe
2018-08-02 16:23         ` Junio C Hamano
2018-08-02 20:33           ` Ævar Arnfjörð Bjarmason
2018-08-02 20:36             ` Junio C Hamano
2018-08-03  4:42               ` René Scharfe
2018-08-03 15:30                 ` Junio C Hamano
2018-08-01 22:57 ` Jonathan Nieder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AM0PR02MB371539182CB9D1FD201D1CAF9C230@AM0PR02MB3715.eurprd02.prod.outlook.com \
    --to=richard.kerry@atos.net \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=l.s.r@web.de \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).