From: Laveesh Bansal <laveeshb@laveeshbansal.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Wasswa Edson <edsonwasswa54@gmail.com>,
git@vger.kernel.org, Tanga Joris <tangajoris@gmail.com>
Subject: Re: [PATCH v2 0/3] credential: parse subcommands with OPT_SUBCOMMAND
Date: Mon, 23 Nov 2026 08:52:31 -0800 [thread overview]
Message-ID: <20261123165231.58660-1-laveeshb@laveeshbansal.com> (raw)
In-Reply-To: <xmqq5wxnd0k5.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
> Outside of a trivially obvious fix or a quick nod from a known area
> expert (e.g., Dscho or J6t on a Windows-specific patch) or the original
> author of the code being touched, it is hard for bystanders to tell from
> a one-line "Looks good to me" how deeply the reviewer thought through
> the changes.
Thanks Junio, that is a fair point and a helpful suggestion.
> One trick I sometimes use when giving a positive review is to walk
> through the patch aloud, explaining in my own words what the old and new
> code do and why the tricky parts are handled correctly. That way,
> others can see that a second pair of eyes really understood and agreed
> with the approach (or the author can correct me if I misread something).
Here is what I did, so it is visible.
I applied the three patches on the base named in the cover letter
(37b3475fb5) and built each commit on its own. t0300 and t0450 pass at
each step (t0300: 56, 56 and 60 tests). On the final commit I ran t03*
and t04*, t9902, and t0300 with GIT_TEST_DEFAULT_HASH=sha256. All
pass.
To check that the tests catch the change, I ran the new t0300 tests
against a build without the series (4 fail), and removed the "too many
arguments" check (test 60 fails). Keeping "credential" in
adoc-help-mismatches makes t0450 fail, so dropping that line is
needed.
I compared an unpatched build with the patched one on about 50 command
lines, including real input on stdin for fill, approve and reject.
For valid input, output and exit codes match. The differences are in
-h, "--", --git-completion-helper, and the error messages for a
missing, unknown or extra argument. The two small points I found are
in my reply to 3/3 [1]. One good result: "git credential bogus" blocks
on stdin on the old build, and exits 129 right away now.
Why I think the approach is right:
1/3: "capability" was documented and implemented but missing from the
usage string. Adding it, and marking the SYNOPSIS [verse] so that
t0450 can extract it, makes -h and the man page agree. The "credential"
line in adoc-help-mismatches then has to go, or t0450 reports the
breakage as fixed.
2/3: each subcommand keeps the same steps as before: approve and
reject read the credential and set the helper capabilities, fill reads
and fills, and capability reads nothing. Only the order changes, so an
unknown name is rejected before stdin is read. The old code read stdin
first, which is why "git credential bogus" blocked. The functions
keep using the_repository and leave the repo argument unused, which is
right because "git credential" runs with RUN_SETUP_GENTLY and repo is
NULL outside a repository.
3/3: OPT_SUBCOMMAND is used without the "optional subcommand" flag, so
a missing subcommand is reported and the function pointer cannot be
NULL. Each subcommand re-parses its own arguments with an empty option
table, so -h, an unknown option and a leftover argument are each
handled where the subcommand lives. The usage arrays are static, and
the option table is only used before it goes out of scope. Calling
parse_options() is what makes --git-completion-helper work, and
dropping NO_PARSEOPT lists the command in --list-cmds=parseopt, which
the completion script consults.
The remaining differences are that "--" and "--end-of-options" are
consumed by the parser, so the subcommand then runs, as it does for
"git refs verify --" and "git reflog list --". Reading the old and new
code side by side, I did not find a case where input that was
accepted before behaves differently.
I also thought about smaller versions. One shared usage string would
be shorter, but "git credential fill -h" would then show the usage of
the whole command, and the per-subcommand usage is how "git refs" and
"git reflog" do it. Stopping after 2/3 would already fix the usage
string and the stdin hang, but "git credential" would still have no
per-subcommand -h, no "need a subcommand" or "unknown subcommand"
errors, and no --git-completion-helper. I think the series as sent is
the better balance.
I also searched the list archive for a competing series and found
none.
As for how I review and respond: I usually keep my replies short when
a patch looks right to me and works as expected, which is why my first
reply was brief. You are right that a one-liner does not show what I
checked. I am still new to this area, so I will explain my thinking in
future reviews.
Thanks,
Laveesh
[1] https://lore.kernel.org/git/20261123023542.88325-1-laveeshb@laveeshbansal.com/
next prev parent reply other threads:[~2026-11-23 16:52 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 20:22 [PATCH] credential: parse subcommands with OPT_SUBCOMMAND Wasswa Edson
2026-11-08 22:28 ` Tanga Joris
2026-11-14 18:47 ` [PATCH v2 0/3] " Wasswa Edson
2026-11-14 18:47 ` [PATCH v2 1/3] credential: make -h output and SYNOPSIS agree Wasswa Edson
2026-11-14 18:47 ` [PATCH v2 2/3] credential: move each subcommand into its own function Wasswa Edson
2026-11-14 18:47 ` [PATCH v2 3/3] credential: parse subcommands with OPT_SUBCOMMAND Wasswa Edson
2026-11-21 19:17 ` Tanga Joris
2026-11-23 2:35 ` Laveesh Bansal
2026-11-23 1:44 ` [PATCH v2 0/3] " Laveesh Bansal
2026-11-23 15:34 ` Junio C Hamano
2026-11-23 16:52 ` Laveesh Bansal [this message]
2026-11-23 21:24 ` Junio C Hamano
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261123165231.58660-1-laveeshb@laveeshbansal.com \
--to=laveeshb@laveeshbansal.com \
--cc=edsonwasswa54@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=tangajoris@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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox