From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Stuart MacDonald <stuartm.coding@gmail.com>, git@vger.kernel.org
Subject: Re: [Bug report] includeIf config is not displayed in normal directories
Date: Wed, 16 Dec 2020 14:24:07 -0500 [thread overview]
Message-ID: <X9pe119edtL5KQTU@coredump.intra.peff.net> (raw)
In-Reply-To: <xmqqczza7lpm.fsf@gitster.c.googlers.com>
On Tue, Dec 15, 2020 at 02:23:17PM -0800, Junio C Hamano wrote:
> > $ 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.
> 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
next prev parent reply other threads:[~2020-12-16 19:24 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-15 15:52 [Bug report] includeIf config is not displayed in normal directories Stuart MacDonald
2017-05-11 18:53 ` Possible bug in includeIf / conditional includes on non git initialised directories Raphael Stolt
2017-05-11 20:31 ` Sebastian Schuberth
2017-05-11 23:43 ` Jeff King
2017-05-12 8:58 ` Ævar Arnfjörð Bjarmason
2020-12-15 23:03 ` [Bug report] includeIf config is not displayed in normal directories Ævar Arnfjörð Bjarmason
2020-12-16 0:23 ` Junio C Hamano
2020-12-15 22:23 ` Junio C Hamano
2020-12-16 19:24 ` Jeff King [this message]
2020-12-16 20:43 ` Stuart MacDonald
2020-12-16 23:24 ` Junio C Hamano
2020-12-18 6:23 ` Jeff King
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=X9pe119edtL5KQTU@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=stuartm.coding@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).