* [PATCH] name-rev: use OPT_HIDDEN_BOOL for --peel-tag
@ 2023-09-02 18:38 René Scharfe
2023-09-05 7:17 ` Jeff King
0 siblings, 1 reply; 3+ messages in thread
From: René Scharfe @ 2023-09-02 18:38 UTC (permalink / raw)
To: Git List
adfc1857bd (describe: fix --contains when a tag is given as input,
2013-07-18) added the option --peel-tag, defining it using a positional
struct option initializer and a comment indicating that it's intended to
be a hidden OPT_BOOL. 4741edd549 (Remove deprecated OPTION_BOOLEAN for
parsing arguments, 2013-08-03) added the macro OPT_HIDDEN_BOOL, which
allows to express this more succinctly. Use it.
Signed-off-by: René Scharfe <l.s.r@web.de>
---
builtin/name-rev.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/builtin/name-rev.c b/builtin/name-rev.c
index c706fa3720..2dd1807c4e 100644
--- a/builtin/name-rev.c
+++ b/builtin/name-rev.c
@@ -582,12 +582,8 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)
OPT_BOOL(0, "undefined", &allow_undefined, N_("allow to print `undefined` names (default)")),
OPT_BOOL(0, "always", &always,
N_("show abbreviated commit object as fallback")),
- {
- /* A Hidden OPT_BOOL */
- OPTION_SET_INT, 0, "peel-tag", &peel_tag, NULL,
- N_("dereference tags in the input (internal use)"),
- PARSE_OPT_NOARG | PARSE_OPT_HIDDEN, NULL, 1,
- },
+ OPT_HIDDEN_BOOL(0, "peel-tag", &peel_tag,
+ N_("dereference tags in the input (internal use)")),
OPT_END(),
};
--
2.42.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] name-rev: use OPT_HIDDEN_BOOL for --peel-tag
2023-09-02 18:38 [PATCH] name-rev: use OPT_HIDDEN_BOOL for --peel-tag René Scharfe
@ 2023-09-05 7:17 ` Jeff King
2023-09-07 20:20 ` René Scharfe
0 siblings, 1 reply; 3+ messages in thread
From: Jeff King @ 2023-09-05 7:17 UTC (permalink / raw)
To: René Scharfe; +Cc: Git List
On Sat, Sep 02, 2023 at 08:38:34PM +0200, René Scharfe wrote:
> adfc1857bd (describe: fix --contains when a tag is given as input,
> 2013-07-18) added the option --peel-tag, defining it using a positional
> struct option initializer and a comment indicating that it's intended to
> be a hidden OPT_BOOL. 4741edd549 (Remove deprecated OPTION_BOOLEAN for
> parsing arguments, 2013-08-03) added the macro OPT_HIDDEN_BOOL, which
> allows to express this more succinctly. Use it.
Yeah, this is a definite improvement.
OPT_HIDDEN_BOOL() itself is a little funny to me. I guess back then we
did not have the "_F" variants, but really it is just:
OPT_BOOL_F(0, "peel-tag", &peel_tag,
N_("dereference tags in the input (internal use)")),
PARSE_OPT_HIDDEN);
which would remove one more special case (after all, being hidden is
orthogonal to the type). But there are enough of them that maybe having
a special name for this is worth it. I dunno. But we could probably
simplify the definition, at least. :)
-Peff
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] name-rev: use OPT_HIDDEN_BOOL for --peel-tag
2023-09-05 7:17 ` Jeff King
@ 2023-09-07 20:20 ` René Scharfe
0 siblings, 0 replies; 3+ messages in thread
From: René Scharfe @ 2023-09-07 20:20 UTC (permalink / raw)
To: Jeff King; +Cc: Git List
Am 05.09.23 um 09:17 schrieb Jeff King:
> On Sat, Sep 02, 2023 at 08:38:34PM +0200, René Scharfe wrote:
>
> OPT_HIDDEN_BOOL() itself is a little funny to me. I guess back then we
> did not have the "_F" variants, but really it is just:
>
> OPT_BOOL_F(0, "peel-tag", &peel_tag,
> N_("dereference tags in the input (internal use)")),
> PARSE_OPT_HIDDEN);
>
> which would remove one more special case (after all, being hidden is
> orthogonal to the type).
Good point!
> But there are enough of them that maybe having
> a special name for this is worth it. I dunno.
A special case just for a flag feels wasteful. _F is more general at a
reasonable price of some verbosity:
OPT_HIDDEN_BOOL(s, l, v, h),
OPT_BOOL_F(s, l, v, h, PARSE_OPT_HIDDEN),
Hindsight..
> But we could probably simplify the definition, at least. :)
Sure, that would be some kind of consolation price.
René
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-09-07 20:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-02 18:38 [PATCH] name-rev: use OPT_HIDDEN_BOOL for --peel-tag René Scharfe
2023-09-05 7:17 ` Jeff King
2023-09-07 20:20 ` René Scharfe
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 NNTP newsgroup(s).