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

Re: [PATCH v3 6/6] Use the early config machinery to expand aliases

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jun 14, 2017, 10:24 UTC
Message-ID
<alpine.DEB.2.21.1.1706141223021.171564@virtualbox>
In-Reply-To
<20170614055824.p2ueyiyfsdf6inve@sigill.intra.peff.net>
Hi Peff & Brandon,
On Wed, 14 Jun 2017, Jeff King wrote:
Show 34 quoted lines
> On Tue, Jun 13, 2017 at 11:26:06AM -0700, Brandon Williams wrote:
> 
> > So because I've been looking at the config machinery lately, I've
> > noticed a lot of issues with how things are handled with respect to
> > gitdir vs commondir.  Essentially the config resides at commondir/config
> > always, and only at gitdir/config when not working with a worktree.
> > Because of this, your patches point out a bug in how early config is
> > handled.  I'll illustrate this using aliases.
> > 
> > Before this series (because aliases are read using the standard config
> > machinery):
> > 
> >   > git init main
> >   > git -C main config alias.test '!echo hello'
> >   > git -C main test
> >     hello
> >   > git -C main worktree add ../worktree
> >   > git -C worktree test
> >     hello
> > 
> > After this series (using read_early_config()):
> > 
> >   > git init main
> >   > git -C main config alias.test '!echo hello'
> >   > git -C main test
> >     hello
> >   > git -C main worktree add ../worktree
> >   > git -C worktree test
> >     git: 'test' is not a git command. See 'git --help'.
> > 
> > The issue is that read_early_config passes the gitdir and not the
> > commondir when reading the config.
> 
> Good catch.
Oh wow.
Show 17 quoted lines
> > The solution would be to add a 'commondir' field to the config_options
> > struct and populate that before reading the config.  I'm planning on
> > fixing this in v2 of my config cleanup series which I'll hopefully have
> > finished by the end of the day.
> 
> I think that read_early_config() really meant to set the commondir, as
> it was always about actual config-file lookup. So it was sort-of buggy
> already, though I suspect it was pretty hard to trigger.
> 
> But I agree that since include_by_gitdir now reads the same struct
> field, swapping it out fixes the config-reading at the cost of breaking
> that function. And we really need to pass both in.
> 
> I'm not sure whether we should care about this for Dscho's series or
> not. I think his series _does_ make the problem easier to trigger. But
> it's a minor enough bug that I think I'd be OK with letting your
> solution proceed independently.

Brandon, how hard would it be to build on top of my series? I ask because I have to take care of some other things and would not have the time to adjust my patch series on top of yours anytime soon.

Ciao, Dscho

Previous: Jeff KingNext: Brandon Williams
Message 14 of 15 in “Avoid problem where git_dir is set after alias expansion”
  1. 0/6 Avoid problem where git_dir is set after alias expansionJohannes Schindelin, Jun 13, 2017
  2. 1/6 discover_git_directory(): avoid setting invalid git_dirJohannes Schindelin, Jun 13, 2017
  3. 3/6 help: use early config when autocorrecting aliasesJohannes Schindelin, Jun 13, 2017
  4. 2/6 config: report correct line number upon errorJohannes Schindelin, Jun 13, 2017
  5. 4/6 t1308: relax the test verifying that empty alias values are disallowedJohannes Schindelin, Jun 13, 2017
  6. 5/6 t7006: demonstrate a problem with aliases in subdirectoriesJohannes Schindelin, Jun 13, 2017
  7. 6/6 Use the early config machinery to expand aliasesJohannes Schindelin, Jun 13, 2017
  8. Junio C HamanoJun 13, 2017
  9. Jeff KingJun 14, 2017
  10. Johannes SchindelinJun 14, 2017
  11. Johannes SchindelinJun 14, 2017
  12. Brandon WilliamsJun 13, 2017
  13. Jeff KingJun 14, 2017
  14. Johannes SchindelinJun 14, 2017
  15. Brandon WilliamsJun 14, 2017

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.