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

Re: [PATCH 1/2] config: allow config_with_options() to handle any repo

From
Jeff King <peff@peff.net>
Date
Aug 29, 2019, 14:00 UTC
Message-ID
<20190829140013.GC1797@sigill.intra.peff.net>
In-Reply-To
<CACsJy8DpTxpejkOHCYPnt3saC-h-3Ez0TthAPnPvHHThaG64bQ@mail.gmail.com>
On Thu, Aug 29, 2019 at 04:31:34PM +0700, Duy Nguyen wrote:
Show 12 quoted lines
> > If so, how could we get R there? I mean, we could pass it through this
> > chain, but the chain already passes a "struct config_options", which
> > carries the "commondir" and "git_dir" fields. So it would probably be
> > confusing to have them and an extra repository parameter (which also
> > has "commondir" and "git_dir"), right? Any ideas on how to better
> > approach this?
> 
> I would change 'struct config_options' to carry 'struct repository'
> which also contains git_dir and other info inside. Though I have no
> idea how big that change would be (didn't check the code). Config code
> relies on plenty callbacks without "void *cb_data" so relying on
> global state is the only way in some cases.

I'm not sure about that, at least for this particular git_pathdup(). We pass along the git_dir because we might not have a repository struct yet (i.e., when reading config before repo discovery has happened).

So it might be that this case should actually be making a path out of $git_dir/config.worktree (but I'm not 100% sure, as I don't know the ins and outs of worktree config files).

I'm sure there are other gotchas in the config code, though, related to things for which we _do_ need a repository. E.g., include_by_branch() looks at the_repository, and should use a repository struct matching the git_dir we're looking at (though it may be acceptable to bail during early pre-repo-initialization config and just disallow branch includes, which is what happens now).

-Peff
Previous: Duy NguyenNext: Matheus Tavares Bernardino
Message 7 of 10 in “config: make config_with_options() handle any repo”
  1. 0/2 config: make config_with_options() handle any repoMatheus Tavares, Aug 26, 2019
  2. 1/2 config: allow config_with_options() to handle any repoMatheus Tavares, Aug 26, 2019
  3. Duy NguyenAug 27, 2019
  4. Matheus Tavares BernardinoAug 27, 2019
  5. Matheus Tavares BernardinoAug 29, 2019
  6. Duy NguyenAug 29, 2019
  7. Jeff KingAug 29, 2019
  8. Matheus Tavares BernardinoAug 29, 2019
  9. Duy NguyenAug 30, 2019
  10. 2/2 submodule: pass repo instead of adding to alternates listMatheus Tavares, Aug 26, 2019

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.