git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] builtin: pass repository to sub commands

From
karthik nayak <karthik.188@gmail.com>
Date
Nov 26, 2024, 09:56 UTC
Message-ID
<CAOLa=ZTUv41jfPcevaY+Afxu2e03_C9bDF+uXzNha-24LH+Lmw@mail.gmail.com>
In-Reply-To
<Z0WNKV5prRE2Hupw@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
Show 23 quoted lines
> On Mon, Nov 25, 2024 at 03:55:30PM +0100, Karthik Nayak wrote:
>> In 9b1cb5070f (builtin: add a repository parameter for builtin
>> functions, 2024-09-13) the repository was passed down to all builtin
>> commands. This allowed the repository to be passed down to lower layers
>> without depending on the global `the_repository` variable.
>>
>> Continue this work by also passing down the repository parameter from
>> the command to sub-commands. This will help pass down the repository to
>> other subsystems and cleanup usage of global variables like
>> 'the_repository' and 'the_hash_algo'.
>
> One alternative could be to instead pass a caller-provided structure to
> the subcommands. Right now that isn't really needed because we tend to
> make use of not only `the_repository` as a global variable, but also
> because we track all kinds of other variables globally.
>
> 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.
>

That's a really good idea. I do see the merit of doing that, I'm not sure if such a need would actually arise. But then, the fallback would still be `repository *` so I think it should work indeed. Will modify and send. Thanks.

Previous: Patrick SteinhardtNext: Junio C Hamano
Message 5 of 12 in “builtin: pass repository to sub commands”
  1. builtin: pass repository to sub commandsKarthik Nayak, Nov 25, 2024
  2. Christian CouderNov 26, 2024
  3. karthik nayakNov 26, 2024
  4. Patrick SteinhardtNov 26, 2024
  5. karthik nayakNov 26, 2024
  6. Junio C HamanoNov 26, 2024
  7. builtin: allow passing custom data to sub-commandsKarthik Nayak, Nov 26, 2024
  8. shejialuoNov 26, 2024
  9. karthik nayakNov 26, 2024
  10. Junio C HamanoNov 26, 2024
  11. karthik nayakNov 27, 2024
  12. karthik nayakNov 27, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.