From: Junio C Hamano <gitster@pobox.com>
To: Patrick Steinhardt <ps@pks.im>
Cc: Karthik Nayak <karthik.188@gmail.com>,
git@vger.kernel.org, shejialuo@gmail.com
Subject: Re: [PATCH] builtin: pass repository to sub commands
Date: Wed, 27 Nov 2024 04:26:12 +0900 [thread overview]
Message-ID: <xmqq34jdyey3.fsf@gitster.g> (raw)
In-Reply-To: <Z0WNKV5prRE2Hupw@pks.im> (Patrick Steinhardt's message of "Tue, 26 Nov 2024 09:56:09 +0100")
Patrick Steinhardt <ps@pks.im> writes:
> So if the code were refactored to instead accept an arbitrary `void *`
> pointer, callers could provide a custom structure and pass that along to
> its subcommands. In many cases we may end up just passing the repo
> directly, but I'm sure there are others where this direction would buy
> us additional flexibility and allow us to get rid of even more global
> state.
I am of two minds. Certainly for OPT_SUBCOMMAND macro to be able to
work with arbitrary types that are specific to each git subcommand,
we'd need "void *" plus casting on the receiving end. But it loses
type safety.
I personally think (but not so strongly) that we should add a repo
to parse_opt_subcommand_fn(), if this exercise is about giving
consistent access to the repository object universally across
subsubcommands.
If we want flexibility on top, we can either add another "void *"
for it after we are done with adding the repository, or we may even
be able to make the parse_opt_subcommand_fn() a varargs.
next prev parent reply other threads:[~2024-11-26 19:26 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-25 14:55 [PATCH] builtin: pass repository to sub commands Karthik Nayak
2024-11-26 8:46 ` Christian Couder
2024-11-26 9:50 ` karthik nayak
2024-11-26 8:56 ` Patrick Steinhardt
2024-11-26 9:56 ` karthik nayak
2024-11-26 19:26 ` Junio C Hamano [this message]
2024-11-26 11:19 ` [PATCH v2] builtin: allow passing custom data to sub-commands Karthik Nayak
2024-11-26 11:57 ` shejialuo
2024-11-26 16:41 ` karthik nayak
2024-11-26 19:27 ` Junio C Hamano
2024-11-27 9:15 ` karthik nayak
2024-11-27 12:23 ` karthik nayak
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=xmqq34jdyey3.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=karthik.188@gmail.com \
--cc=ps@pks.im \
--cc=shejialuo@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;
as well as URLs for NNTP newsgroup(s).