From: Junio C Hamano <gitster@pobox.com>
To: Denton Liu <liu.denton@gmail.com>
Cc: Jeff King <peff@peff.net>, Git Mailing List <git@vger.kernel.org>,
Andrew White <andrew.white@audinate.com>
Subject: Re: [PATCH] push: unset PARSE_OPT_OPTARG for --recurse-submodules
Date: Tue, 28 Apr 2020 10:51:56 -0700 [thread overview]
Message-ID: <xmqqwo5z33cz.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: <xmqq7dy092tq.fsf@gitster.c.googlers.com> (Junio C. Hamano's message of "Mon, 27 Apr 2020 11:54:41 -0700")
Junio C Hamano <gitster@pobox.com> writes:
> Jeff King <peff@peff.net> writes:
>
>>> @@ -554,7 +552,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
>>> PARSE_OPT_OPTARG | PARSE_OPT_LITERAL_ARGHELP, parseopt_push_cas_option },
>>> { OPTION_CALLBACK, 0, "recurse-submodules", &recurse_submodules, "(check|on-demand|no)",
>>> N_("control recursive pushing of submodules"),
>>> - PARSE_OPT_OPTARG, option_parse_recurse_submodules },
>>> + 0, option_parse_recurse_submodules },
>>
>> This could collapse down to OPT_CALLBACK() now, though I don't think
>> it's a big deal either way.
>
> I would prefer to see OPT_CALLBACK() used; it would send a strong
> signal that this place is using the canned bog-standard and boring
> pattern, and nothing fancy is going on.
Here is what I am going to queue for this fix; hopefully it can be
cherry-picked by folks who maintain older versions of Git for
distros and in-house use.
The other "huge" patch has also been adjusted by dropping the first
hunk on builtin/push.c from it, and then resurrecting the part to
use OPT_CALLBACK_F() for compare-and-swap (which happened to be in
the same hunk).
Thanks for the fix and clean-up. Very much appreciated.
-- >8 --
From: Denton Liu <liu.denton@gmail.com>
Date: Mon, 27 Apr 2020 02:44:08 -0400
Subject: [PATCH] push: unset PARSE_OPT_OPTARG for --recurse-submodules
When the usage for `git push` is shown, it includes the following
lines
--recurse-submodules[=(check|on-demand|no)]
control recursive pushing of submodules
which seem to indicate that the argument for --recurse-submodules is
optional. However, we cannot actually run that optiion without an
argument:
$ git push --recurse-submodules
fatal: recurse-submodules missing parameter
Unset PARSE_OPT_OPTARG so that it is clear that this option requires an
argument. Since the parse-options machinery guarantees that an argument
is present now, assume that `arg` is set in the else of
option_parse_recurse_submodules().
Reported-by: Andrew White <andrew.white@audinate.com>
Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
builtin/push.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/builtin/push.c b/builtin/push.c
index 6dbf0f0bb7..208c2540e9 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -434,10 +434,8 @@ static int option_parse_recurse_submodules(const struct option *opt,
if (unset)
*recurse_submodules = RECURSE_SUBMODULES_OFF;
- else if (arg)
- *recurse_submodules = parse_push_recurse_submodules_arg(opt->long_name, arg);
else
- die("%s missing parameter", opt->long_name);
+ *recurse_submodules = parse_push_recurse_submodules_arg(opt->long_name, arg);
return 0;
}
@@ -552,9 +550,8 @@ int cmd_push(int argc, const char **argv, const char *prefix)
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 },
- { OPTION_CALLBACK, 0, "recurse-submodules", &recurse_submodules, "(check|on-demand|no)",
- N_("control recursive pushing of submodules"),
- PARSE_OPT_OPTARG, option_parse_recurse_submodules },
+ OPT_CALLBACK(0, "recurse-submodules", &recurse_submodules, "(check|on-demand|no)",
+ N_("control recursive pushing of submodules"), option_parse_recurse_submodules),
OPT_BOOL_F( 0 , "thin", &thin, N_("use thin pack"), PARSE_OPT_NOCOMPLETE),
OPT_STRING( 0 , "receive-pack", &receivepack, "receive-pack", N_("receive pack program")),
OPT_STRING( 0 , "exec", &receivepack, "receive-pack", N_("receive pack program")),
--
2.26.2-266-ge870325ee8
next prev parent reply other threads:[~2020-04-28 17:52 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-27 1:31 Bug v2.23.0: command help for 'git push --recurse-submodules' is incorrect Andrew White
2020-04-27 6:44 ` [PATCH] push: unset PARSE_OPT_OPTARG for --recurse-submodules Denton Liu
2020-04-27 12:02 ` Jeff King
2020-04-27 18:54 ` Junio C Hamano
2020-04-28 8:36 ` [PATCH] Use OPT_CALLBACK and OPT_CALLBACK_F Denton Liu
2020-04-28 8:45 ` Jeff King
2020-04-28 17:34 ` Junio C Hamano
2020-04-28 17:51 ` Junio C Hamano [this message]
2020-04-28 22:59 ` [PATCH] push: unset PARSE_OPT_OPTARG for --recurse-submodules Denton Liu
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=xmqqwo5z33cz.fsf@gitster.c.googlers.com \
--to=gitster@pobox.com \
--cc=andrew.white@audinate.com \
--cc=git@vger.kernel.org \
--cc=liu.denton@gmail.com \
--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).