From: Eric Sunshine <sunshine@sunshineco.com>
To: Dragan Simic <dsimic@manjaro.org>
Cc: emilyshaffer@google.com, git@vger.kernel.org,
Emily Shaffer <nasamuffin@google.com>,
Sheik <sahibzone@gmail.com>
Subject: Re: [PATCH v2] bugreport: reject positional arguments
Date: Thu, 26 Oct 2023 00:03:30 -0400 [thread overview]
Message-ID: <CAPig+cTJFKp6RFdqJTpyL49V+M-zaTDbgpVd2OrgfWf4H-+K+g@mail.gmail.com> (raw)
In-Reply-To: <8c82a138faa28a3c5d15a52b1d9c2c0f@manjaro.org>
On Wed, Oct 25, 2023 at 11:52 PM Dragan Simic <dsimic@manjaro.org> wrote:
> On 2023-10-26 05:43, Eric Sunshine wrote:
> > On Wed, Oct 25, 2023 at 8:55 PM <emilyshaffer@google.com> wrote:
> >> diff --git a/builtin/bugreport.c b/builtin/bugreport.c
> >> @@ -126,6 +126,12 @@ int cmd_bugreport(int argc, const char **argv,
> >> const char *prefix)
> >> + if (argc) {
> >> + if (argv[0])
> >> + error(_("unknown argument `%s'"), argv[0]);
> >> + usage(bugreport_usage[0]);
> >> + }
> >
> > Can it actually happen that argc is non-zero but argv[0] is NULL? (I
> > don't have parse-options in front of me to check.) If not, then the
> > extra `if (argv[0])` conditional may confuse future readers.
>
> According to https://stackoverflow.com/a/2794171/22330192 it can't, but
> argv[0] can be a zero-length string.
This case is different, though, since, by this point, argv[] has been
processed by Git's parse-options API. Here's the relevant comment from
parse-options.h:
* parse_options() will filter out the processed options and leave the
* non-option arguments in argv[]. argv0 is assumed program name and
* skipped.
*
* Returns the number of arguments left in argv[].
So, I think the `if (argv[0])` conditional is unnecessary, thus
potentially confusing.
It's possible that Emily meant `if (*argv[0])`, but even that seems
undesirable since even a zero-length argv[0] provides some useful
context.
% git bugreport ""
error: unknown argument `'
next prev parent reply other threads:[~2023-10-26 4:04 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-25 20:59 git bugreport with invalid CLI argument does not report error Sheik
2023-10-25 22:53 ` Emily Shaffer
2023-10-25 23:11 ` Eric Sunshine
2023-10-26 0:55 ` [PATCH v2] bugreport: reject positional arguments emilyshaffer
2023-10-26 3:43 ` Eric Sunshine
2023-10-26 3:52 ` Dragan Simic
2023-10-26 4:03 ` Eric Sunshine [this message]
2023-10-26 4:06 ` Dragan Simic
2023-10-26 15:54 ` [PATCH v3] " emilyshaffer
2023-10-26 17:18 ` Eric Sunshine
2023-10-27 14:41 ` Phillip Wood
2023-10-30 0:15 ` Junio C Hamano
2023-10-30 0:26 ` Junio C Hamano
2023-10-30 0:33 ` Junio C Hamano
2023-10-30 1:59 ` Junio C Hamano
2023-10-30 14:11 ` Phillip Wood
2023-10-30 23:31 ` Junio C Hamano
2023-10-31 2:17 ` Junio C Hamano
2023-10-31 5:23 ` [PATCH 0/2] Deprecate test_i18ngrep further Junio C Hamano
2023-10-31 5:23 ` [PATCH 1/2] test framework: further deprecate test_i18ngrep Junio C Hamano
2023-10-31 5:23 ` [PATCH 2/2] tests: teach callers of test_i18ngrep to use test_grep Junio C Hamano
2023-11-01 14:44 ` Phillip Wood
2023-11-01 23:19 ` Junio C Hamano
2023-10-26 18:22 ` [PATCH v4 0/2] bugreport: reject positional arguments emilyshaffer
2023-10-26 20:13 ` Eric Sunshine
2023-10-26 18:22 ` [PATCH v4 1/2] t0091-bugreport: stop using i18ngrep emilyshaffer
2023-10-29 23:59 ` Junio C Hamano
2023-10-26 18:22 ` [PATCH v4 2/2] bugreport: reject positional arguments emilyshaffer
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=CAPig+cTJFKp6RFdqJTpyL49V+M-zaTDbgpVd2OrgfWf4H-+K+g@mail.gmail.com \
--to=sunshine@sunshineco.com \
--cc=dsimic@manjaro.org \
--cc=emilyshaffer@google.com \
--cc=git@vger.kernel.org \
--cc=nasamuffin@google.com \
--cc=sahibzone@gmail.com \
/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).