Stuart MacDonald <stuartm.coding@xxxxxxxxx> writes: > Hello, > > I've seen this thread: > https://public-inbox.org/git/F55DC360-9C1E-45B9-B8BA-39E1001BD620@xxxxxxxxx/t/#u > > and respectfully disagree with the conclusion. Conditionally included > configuration can contain items like core.sshCommand that are required > for git clone while in a normal non-git directory. These should be > displayed properly so users know what configuration they are operating > with. I have a feeling that this just repeats what was said in the quoted thread. It is a chicken-and-egg problem that cannot be solved by use of [includeif "gitdir:*"] pattern, as it won't kick in until your $(pwd) is associated with a git repository, and before "clone" or "init", your $(pwd) that is a newly created directory won't be. > Also, conditionally included config is acted upon despite not being > displayed. This makes tracking down problems much more difficult. > $ mkdir ~/work/git-bug-test > $ cd ~/work/git-bug-test > $ git config --show-origin --get-all core.sshCommand > OBSERVE A: There is no output This is expected, as [includeif "gitdir:*"] is used and there is no gitdir associated with the current location (yet). It _might_ be possible to give "git config" a new option "--pretend-as-if-cwd-is-the-root-of-a-git-working-tree" and teach it to read ~/.gitconfig while pretending $(pwd)/.git exists and is a gitdir, but it won't be as simple as exporting GIT_DIR=$(pwd)/.git, I suspect. A lot of other things would break by actually not having a real repository there. > $ git clone --recursive git@xxxxxxxxxx: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. > $ cd git > $ git config --show-origin --get-all core.sshCommand > file:C:/Users/stuartm/.gitconfig-work ssh -i ~/.ssh/id_rsa.stuartm_github > OBSERVE C: The configuration item is displayed Of course. At that point, you have a full fledged repository there. > $ cd .. > $ git config --show-origin --get-all core.sshCommand > OBSERVE D: There is no output 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. THanks.