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

Re: [Bug report] includeIf config is not displayed in normal directories

From
Jeff King <peff@peff.net>
Date
Dec 16, 2020, 19:24 UTC
Message-ID
<X9pe119edtL5KQTU@coredump.intra.peff.net>
In-Reply-To
<xmqqczza7lpm.fsf@gitster.c.googlers.com>
On Tue, Dec 15, 2020 at 02:23:17PM -0800, Junio C Hamano wrote:
Show 10 quoted lines
> > $ git clone --recursive git@github.com:git/git.git
> > OBSERVE B: The clone succeeds
> 
> This may be an unexpected but is an understandable behaviour.
> 
> First the command has to create an empty repository with an initial
> configuration file, and at that point [includeif "gitdir:*"] match
> would notice that there is a gitdir at $(pwd)/.git; by the time the
> command actually starts talking to the other side, the repository
> specific configuration can be picked up.

I think this is not just unexpected, but something we've explicitly tried to make work. After creating the repository, we re-read the config in order to pick up any "clone -c" options. I'm not sure if anybody thought about how includeIf would interact here, but I think it is quite logical to say "now that we are in a repository, these config options that are conditional on being in a particular repository will take effect". I.e., expecting it not to work is making assumptions about the timing of when Git locks in the value of config options.

Show 13 quoted lines
> And you are outside any repository, so there shouldn't be any gitdir
> in effect to influence [includeif "gitdir:*"] matching.
> 
> Another option, as Peff suggested in the old thread, would be to
> introduce a separate [includeif "cwd:*"] match, but I do not know
> how well it would fly.  with that, you may be able to
> 
> 	[includeif "cwd:/home/stuart/work/*"]
> 		path = ...
> 
> I think that may be cleaner than the "pretend we have already a
> git-dir here" hack I mentioned earlier, but I didn't think things
> through.

Perhaps. I have no objection to adding an option like that. But I don't think it solves the fundamental issue in this bug report, which is asking "what will the config look like in a repository that I created at this path via git-init or git-clone?".

Maybe Stuart really would prefer to change his config to "whenever I am in this directory root, repo or no, use this config". It does have weird corner cases around "git --git-dir=/path/to/repo", but doing that from another directory is perhaps rare enough that people using a cwd: conditional would be happy to ignore that.

But if we do want to solve it, then your --pretend-git-dir is doing that directly. I don't think it's terribly useful in general, but it could be a debugging aid.

-Peff
Previous: Junio C HamanoNext: Stuart MacDonald
Message 3 of 8 in “[Bug report] includeIf config is not displayed in normal directories”
  1. Stuart MacDonaldDec 15, 2020
  2. Junio C HamanoDec 15, 2020
  3. Jeff KingDec 16, 2020
  4. Stuart MacDonaldDec 16, 2020
  5. Junio C HamanoDec 16, 2020
  6. Jeff KingDec 18, 2020
  7. Ævar Arnfjörð BjarmasonDec 15, 2020
  8. Junio C HamanoDec 16, 2020

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.