{"thread":{"id":"54829","subject":"[Bug report] includeIf config is not displayed in normal directories","startedAt":"2020-12-15T15:53:39Z","lastAt":"2020-12-18T06:24:37Z","messageCount":8,"participants":["Stuart MacDonald","Junio C Hamano","Ævar Arnfjörð Bjarmason","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"412263","messageId":"CAPQE4+qq11W9VzftJ6y+cbdJ1x64c8Astjwd4z4M-oc5hv1jeA@mail.gmail.com","threadId":"54829","inReplyTo":null,"subject":"[Bug report] includeIf config is not displayed in normal directories","fromName":"Stuart MacDonald","fromEmail":"stuartm.coding@gmail.com","sentAt":"2020-12-15T15:52:35Z","receivedAt":"2020-12-15T15:53:39Z","isPatch":false,"sender":{"key":"stuartm.coding@gmail.com","avatar":null},"body":"Hello,\n\nI've seen this thread:\nhttps://public-inbox.org/git/F55DC360-9C1E-45B9-B8BA-39E1001BD620@gmail.com/t/#u\n\nand respectfully disagree with the conclusion. Conditionally included\nconfiguration can contain items like core.sshCommand that are required\nfor git clone while in a normal non-git directory. These should be\ndisplayed properly so users know what configuration they are operating\nwith.\n\nAlso, conditionally included config is acted upon despite not being\ndisplayed. This makes tracking down problems much more difficult.\n\nFurther, most complaints online are about user.name and user.email not\nbeing displayed correctly. If those items are in ~/.gitconfig, then\nthey are displayed in a normal non-git directory by normal git config\ncommands. This makes conditionally included configuration display\ninconsistent with regular configuration display. Inconsistency is bad\nand should be fixed.\n\nSee 'git bugreport' attached for further information, reproduction steps, etc.\n\nThanks,\n...Stu\n\n\nThank you for filling out a Git bug report!\nPlease answer the following questions to help us understand your issue.\n\nWhat did you do before the bug happened? (Steps to reproduce your issue)\n\nSet up a conditional include:\nvvvvvvvvvv [ ~/.gitconfig ] vvvvvvvvvv\n[includeIf \"gitdir:~/work/\"]\n\tpath = ~/.gitconfig-work\n^^^^^^^^^^ [ ~/.gitconfig ] ^^^^^^^^^^\n\nvvvvvvvvvv [ ~/.gitconfig-work ] vvvvvvvvvv\n[user]\n\tname = Stuart MacDonald\n\temail = stuartm.coding@gmail.com\n[core]\n\tsshCommand = \"ssh -i ~/.ssh/id_rsa.stuartm_github\"\n^^^^^^^^^^ [ ~/.gitconfig-work ] ^^^^^^^^^^\n\nMake sure ssh is configured properly for github access:\nvvvvvvvvvv [ ~/.ssh/config ] vvvvvvvvvv\nHost github github.com\n  Hostname github.com\n  User git\n  IdentitiesOnly yes\n^^^^^^^^^^ [ ~/.ssh/config ] ^^^^^^^^^^\n\nRun the following commands in a Git bash shell:\n$ mkdir ~/work/git-bug-test\n$ cd ~/work/git-bug-test\n$ git config --show-origin --get-all core.sshCommand \nOBSERVE A: There is no output\n$ git clone --recursive git@github.com:git/git.git\nOBSERVE B: The clone succeeds\n$ cd git\n$ git config --show-origin --get-all core.sshCommand \nfile:C:/Users/stuartm/.gitconfig-work        ssh -i ~/.ssh/id_rsa.stuartm_github\nOBSERVE C: The configuration item is displayed\n$ cd ..\n$ git config --show-origin --get-all core.sshCommand \nOBSERVE D: There is no output\n\nNOTE: In the above reproduction steps I've substituted my work email and\nemployer's private respository (which needs the approrpriate ssh key to be able\nto clone) for my public email and a public repository. This means my\nreproduction steps aren't an exact reproduction; for an exact reproduction\nplease substitute an email address and private repository that requires a\nconfigured ssh key to clone.\n\nWhat did you expect to happen? (Expected behavior)\n\nI expected OBSERVE A and OBSERVE D to match OBSERVE C's output.\n\nWhat happened instead? (Actual behavior)\n\nThere was no output.\n\nWhat's different between what you expected and what actually happened?\n\nOutput vs no output.\n\nAnything else you want to add:\n\nI spent a lot of time yesterday tracking down a problem with my git\nconfiguration that was preventing me from checking out private repositories. The\nincorrect \"no output\" bug caused me to think I had some issue with my\nconditional configuration setup and I was trapped in that dead end for too long.\n\nIt seems that includeIf is not widely discussed online. This makes it difficult\nto find help. I did find\nhttps://stackoverflow.com/questions/43919191/git-2-13-conditional-config-on-windows\nwhich says in part \"If its [sic] not git initialized then the includeIf gitdir\nfunctionality will not work.\" which is actually inaccurate. It does function;\ncommenting out/in the sshCommand configuration line causes cloning to not work or\nwork from a normal directory.\n\nAdditionally, moving the sshCommand config item into ~/.gitconfig will cause\nOBSERVE A and OBSERVE D to produce output. This clearly implicates includeIf\nprocessing as the problem.\n\nI've seen this thread\nhttps://public-inbox.org/git/F55DC360-9C1E-45B9-B8BA-39E1001BD620@gmail.com/t/#u\nand I understand that some config items don't make sense in a normal directory.\nHowever, some do, critically core.sshCommand. Also, if user.name is in the top\nlevel (non-conditional) .gitconfig, then it is reported by git config in a\nnormal directory whether that makes sense for a normal directory or not.\n\nThe minimum fix I'd like to see: conditional includes should be processed and\nany configuration items for which use in a normal directory makes sense should\nbe present and reported properly. Again, critically, this includes\ncore.sshCommand.\n\nThe better fix is to have conditional include processing be at parity with\ndirection configuration; where a configuration item would be displayed if it was\nin a top-level/direct .gitconfig file, then it should also be displayed if it's\nconditionally-included. This would make the config system consistent, which is\nimportant for ease of use.\nI realise this goes against the sentiment in the git mailing list thread I\nlinked above. I believe that thread is wrong in its conclusion of \"working as\ndesigned\".\n\n\nPlease review the rest of the bug report below.\nYou can delete any lines you don't wish to share.\n\n\n[System Info]\ngit version:\ngit version 2.29.2.windows.2\ncpu: x86_64\nbuilt from commit: 3464b98ce6803c98bf8fb34390cd150d66e4a0d3\nsizeof-long: 4\nsizeof-size_t: 8\n"},{"id":"412305","messageId":"xmqqczza7lpm.fsf@gitster.c.googlers.com","threadId":"54829","inReplyTo":"CAPQE4+qq11W9VzftJ6y+cbdJ1x64c8Astjwd4z4M-oc5hv1jeA@mail.gmail.com","subject":"Re: [Bug report] includeIf config is not displayed in normal directories","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-12-15T22:23:17Z","receivedAt":"2020-12-15T22:29:17Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stuart MacDonald <stuartm.coding@gmail.com> writes:\n\n> Hello,\n>\n> I've seen this thread:\n> https://public-inbox.org/git/F55DC360-9C1E-45B9-B8BA-39E1001BD620@gmail.com/t/#u\n>\n> and respectfully disagree with the conclusion. Conditionally included\n> configuration can contain items like core.sshCommand that are required\n> for git clone while in a normal non-git directory. These should be\n> displayed properly so users know what configuration they are operating\n> with.\n\nI have a feeling that this just repeats what was said in the quoted\nthread.  It is a chicken-and-egg problem that cannot be solved by\nuse of [includeif \"gitdir:*\"] pattern, as it won't kick in until\nyour $(pwd) is associated with a git repository, and before \"clone\"\nor \"init\", your $(pwd) that is a newly created directory won't be.\n\n> Also, conditionally included config is acted upon despite not being\n> displayed. This makes tracking down problems much more difficult.\n\n> $ mkdir ~/work/git-bug-test\n> $ cd ~/work/git-bug-test\n> $ git config --show-origin --get-all core.sshCommand \n> OBSERVE A: There is no output\n\nThis is expected, as [includeif \"gitdir:*\"] is used and there is no\ngitdir associated with the current location (yet).\n\nIt _might_ be possible to give \"git config\" a new option\n\"--pretend-as-if-cwd-is-the-root-of-a-git-working-tree\" and teach it\nto read ~/.gitconfig while pretending $(pwd)/.git exists and is a\ngitdir, but it won't be as simple as exporting GIT_DIR=$(pwd)/.git,\nI suspect.  A lot of other things would break by actually not having\na real repository there.\n\n> $ git clone --recursive git@github.com:git/git.git\n> OBSERVE B: The clone succeeds\n\nThis may be an unexpected but is an understandable behaviour.\n\nFirst the command has to create an empty repository with an initial\nconfiguration file, and at that point [includeif \"gitdir:*\"] match\nwould notice that there is a gitdir at $(pwd)/.git; by the time the\ncommand actually starts talking to the other side, the repository\nspecific configuration can be picked up.\n\n> $ cd git\n> $ git config --show-origin --get-all core.sshCommand \n> file:C:/Users/stuartm/.gitconfig-work        ssh -i ~/.ssh/id_rsa.stuartm_github\n> OBSERVE C: The configuration item is displayed\n\nOf course.  At that point, you have a full fledged repository there.\n\n> $ cd ..\n> $ git config --show-origin --get-all core.sshCommand \n> OBSERVE D: There is no output\n\nAnd you are outside any repository, so there shouldn't be any gitdir\nin effect to influence [includeif \"gitdir:*\"] matching.\n\nAnother option, as Peff suggested in the old thread, would be to\nintroduce a separate [includeif \"cwd:*\"] match, but I do not know\nhow well it would fly.  with that, you may be able to\n\n\t[includeif \"cwd:/home/stuart/work/*\"]\n\t\tpath = ...\n\nI think that may be cleaner than the \"pretend we have already a\ngit-dir here\" hack I mentioned earlier, but I didn't think things\nthrough.\n\nTHanks.\n\n"},{"id":"412307","messageId":"875z52wu2a.fsf@evledraar.gmail.com","threadId":"54829","inReplyTo":"CAPQE4+qq11W9VzftJ6y+cbdJ1x64c8Astjwd4z4M-oc5hv1jeA@mail.gmail.com","subject":"Re: [Bug report] includeIf config is not displayed in normal directories","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2020-12-15T23:03:41Z","receivedAt":"2020-12-15T23:05:17Z","isPatch":false,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Tue, Dec 15 2020, Stuart MacDonald wrote:\n\n> Hello,\n>\n> I've seen this thread:\n> https://public-inbox.org/git/F55DC360-9C1E-45B9-B8BA-39E1001BD620@gmail.com/t/#u\n\n[I took the liberty of CC-ing the original thread participants & adding\nthe Message-Id's to the \"References\" header, hopefully the archive will\nthread it and this together for future spelunking]\n\n> and respectfully disagree with the conclusion. Conditionally included\n> configuration can contain items like core.sshCommand that are required\n> for git clone while in a normal non-git directory. These should be\n> displayed properly so users know what configuration they are operating\n> with.\n>\n> Also, conditionally included config is acted upon despite not being\n> displayed. This makes tracking down problems much more difficult.\n>\n> Further, most complaints online are about user.name and user.email not\n> being displayed correctly. If those items are in ~/.gitconfig, then\n> they are displayed in a normal non-git directory by normal git config\n> commands. This makes conditionally included configuration display\n> inconsistent with regular configuration display. Inconsistency is bad\n> and should be fixed.\n>\n> See 'git bugreport' attached for further information, reproduction steps, etc.\n\nAs the person with the last reply in that old thread & only a vague\nrecollection of it until I re-read it now: please don't take a \"why\nwould you want this\" question as dismissive of the use-case, but in\ninvite to tease out some of the nuances.\n\nIt's often easy to vaguely conceptualize a feature, but the hard work is\ndealing with all the edge cases & emergent properties of something like\nnew IncludeIf semantics.\n\nThere's two interesting questions here: Is the current feature buggy (or\njust has surprised but ultimately consistent & correct semantics), and\ncould we have some new IncludeIf use-case that covers use-case Y, where\nnow we can only do X?\n\nJunio covered that in more detail in his reply.\n\nNeither you nor anyone reading this from the archive later should read\nthat thread (or this one) as some refusal of a feature that does Y.\n\nWhether we can have that ultimately depends on whether someone's going\nto invest the time in coming up with patches for it, and in writing\nthose patches will either figure out all the expected & unexpected edge\ncases involved & get past them, or not.\n\nBut it's not a \"no\" until that point (and not even then, maybe we can\nkeep the general idea of Y, but have Z which is mostly the same & works\nfor most people), it's just \"nobody's really worked on it yet\".\n"},{"id":"412313","messageId":"xmqq4kkm7g55.fsf@gitster.c.googlers.com","threadId":"54829","inReplyTo":"875z52wu2a.fsf@evledraar.gmail.com","subject":"Re: [Bug report] includeIf config is not displayed in normal directories","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-12-16T00:23:34Z","receivedAt":"2020-12-16T00:24:49Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n\n> But it's not a \"no\" until that point (and not even then, maybe we can\n> keep the general idea of Y, but have Z which is mostly the same & works\n> for most people), it's just \"nobody's really worked on it yet\".\n\nThanks for spelling these out.\n\nHere is my snack-time hack to add the --pretend-gitdir option to \"git\nconfig\".  It _might_ not be a bad idea to trigger this behaviour\n(using $(pwd)/.git as the pretended directory path) automatically\nwhen do not have a repository, but that would certainly be a\ncompatibility breaking change and would break existing workflow.\n\nOnly very lightly tested, and certainly not ready for inclusion (it\ndoes not even have a doc update).\n\n\n builtin/config.c          |  4 ++++\n config.c                  |  2 ++\n config.h                  |  1 +\n t/t1305-config-include.sh | 21 +++++++++++++++++++++\n 4 files changed, 28 insertions(+)\n\ndiff --git c/builtin/config.c w/builtin/config.c\nindex f71fa39b38..2603dc448c 100644\n--- c/builtin/config.c\n+++ w/builtin/config.c\n@@ -30,6 +30,7 @@ static int use_worktree_config;\n static struct git_config_source given_config_source;\n static int actions, type;\n static char *default_value;\n+static char *pretend_gitdir;\n static int end_nul;\n static int respect_includes_opt = -1;\n static struct config_options config_options;\n@@ -165,6 +166,7 @@ static struct option builtin_config_options[] = {\n \tOPT_BOOL(0, \"show-origin\", &show_origin, N_(\"show origin of config (file, standard input, blob, command line)\")),\n \tOPT_BOOL(0, \"show-scope\", &show_scope, N_(\"show scope of config (worktree, local, global, system, command)\")),\n \tOPT_STRING(0, \"default\", &default_value, N_(\"value\"), N_(\"with --get, use default value when missing entry\")),\n+\tOPT_FILENAME(0, \"pretend-gitdir\", &pretend_gitdir, N_(\"when outside a repository, pretend this is the gitdir\")),\n \tOPT_END(),\n };\n \n@@ -732,6 +734,8 @@ int cmd_config(int argc, const char **argv, const char *prefix)\n \t\tconfig_options.commondir = get_git_common_dir();\n \t\tconfig_options.git_dir = get_git_dir();\n \t}\n+\tif (pretend_gitdir)\n+\t\tconfig_options.pretend_gitdir = pretend_gitdir;\n \n \tif (end_nul) {\n \t\tterm = '\\0';\ndiff --git c/config.c w/config.c\nindex 1137bd73af..d8d406ecda 100644\n--- c/config.c\n+++ w/config.c\n@@ -224,6 +224,8 @@ static int include_by_gitdir(const struct config_options *opts,\n \n \tif (opts->git_dir)\n \t\tgit_dir = opts->git_dir;\n+\telse if (opts->pretend_gitdir)\n+\t\tgit_dir = opts->pretend_gitdir;\n \telse\n \t\tgoto done;\n \ndiff --git c/config.h w/config.h\nindex c1449bb790..14e8d8c576 100644\n--- c/config.h\n+++ w/config.h\n@@ -89,6 +89,7 @@ struct config_options {\n \tunsigned int system_gently : 1;\n \tconst char *commondir;\n \tconst char *git_dir;\n+\tconst char *pretend_gitdir;\n \tconfig_parser_event_fn_t event_fn;\n \tvoid *event_fn_data;\n \tenum config_error_action {\ndiff --git c/t/t1305-config-include.sh w/t/t1305-config-include.sh\nindex f1e1b289f9..883762ad36 100755\n--- c/t/t1305-config-include.sh\n+++ w/t/t1305-config-include.sh\n@@ -162,6 +162,27 @@ test_expect_success 'relative includes from stdin line fail' '\n \ttest_must_fail git config --file - test.one\n '\n \n+test_expect_success 'conditional include, pretend gitdir' '\n+\ttest_when_finished \"git config --global --unset-all \\\"includeif.gitdir:*.path\\\"\" &&\n+\tgit config --global \"includeif.gitdir:*.path\" included &&\n+\n+\tgit config --file included \"custom.variable\" value &&\n+\techo value >expect &&\n+\n+\t# in the TRASH repository\n+\tgit config --get custom.variable >actual &&\n+\ttest_cmp expect actual &&\n+\n+\t# nongit without pretend should not find stuff from included\n+\tnongit test_must_fail git config --get custom.variable >actual &&\n+\ttest_must_be_empty actual &&\n+\n+\t# nongit with pretend should find stuff from included\n+\tnongit git config --pretend-gitdir \"$(pwd)/.git\" \\\n+\t\t--get custom.variable >actual &&\n+\ttest_cmp expect actual\n+'\n+\n test_expect_success 'conditional include, both unanchored' '\n \tgit init foo &&\n \t(\n"},{"id":"412424","messageId":"X9pe119edtL5KQTU@coredump.intra.peff.net","threadId":"54829","inReplyTo":"xmqqczza7lpm.fsf@gitster.c.googlers.com","subject":"Re: [Bug report] includeIf config is not displayed in normal directories","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2020-12-16T19:24:07Z","receivedAt":"2020-12-16T19:24:58Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Dec 15, 2020 at 02:23:17PM -0800, Junio C Hamano wrote:\n\n> > $ git clone --recursive git@github.com:git/git.git\n> > OBSERVE B: The clone succeeds\n> \n> This may be an unexpected but is an understandable behaviour.\n> \n> First the command has to create an empty repository with an initial\n> configuration file, and at that point [includeif \"gitdir:*\"] match\n> would notice that there is a gitdir at $(pwd)/.git; by the time the\n> command actually starts talking to the other side, the repository\n> specific configuration can be picked up.\n\nI think this is not just unexpected, but something we've explicitly\ntried to make work. After creating the repository, we re-read the config\nin order to pick up any \"clone -c\" options. I'm not sure if anybody\nthought about how includeIf would interact here, but I think it is quite\nlogical to say \"now that we are in a repository, these config options\nthat are conditional on being in a particular repository will take\neffect\". I.e., expecting it not to work is making assumptions about\nthe timing of when Git locks in the value of config options.\n\n> And you are outside any repository, so there shouldn't be any gitdir\n> in effect to influence [includeif \"gitdir:*\"] matching.\n> \n> Another option, as Peff suggested in the old thread, would be to\n> introduce a separate [includeif \"cwd:*\"] match, but I do not know\n> how well it would fly.  with that, you may be able to\n> \n> \t[includeif \"cwd:/home/stuart/work/*\"]\n> \t\tpath = ...\n> \n> I think that may be cleaner than the \"pretend we have already a\n> git-dir here\" hack I mentioned earlier, but I didn't think things\n> through.\n\nPerhaps. I have no objection to adding an option like that. But I don't\nthink it solves the fundamental issue in this bug report, which is\nasking \"what will the config look like in a repository that I created at\nthis path via git-init or git-clone?\".\n\nMaybe Stuart really would prefer to change his config to \"whenever I am\nin this directory root, repo or no, use this config\". It does have weird\ncorner cases around \"git --git-dir=/path/to/repo\", but doing that from\nanother directory is perhaps rare enough that people using a cwd:\nconditional would be happy to ignore that.\n\nBut if we do want to solve it, then your --pretend-git-dir is doing that\ndirectly. I don't think it's terribly useful in general, but it could be\na debugging aid.\n\n-Peff\n"},{"id":"412434","messageId":"CAPQE4+rhWT9kgusNXOw5cnJ-oFq++4G1FMaXvQ3wppQ0GE0hSA@mail.gmail.com","threadId":"54829","inReplyTo":"X9pe119edtL5KQTU@coredump.intra.peff.net","subject":"Re: [Bug report] includeIf config is not displayed in normal directories","fromName":"Stuart MacDonald","fromEmail":"stuartm.coding@gmail.com","sentAt":"2020-12-16T20:43:31Z","receivedAt":"2020-12-16T20:45:13Z","isPatch":false,"sender":{"key":"stuartm.coding@gmail.com","avatar":null},"body":"On Wed, Dec 16, 2020 at 2:24 PM Jeff King <peff@peff.net> wrote:\n> Perhaps. I have no objection to adding an option like that. But I don't\n> think it solves the fundamental issue in this bug report, which is\n> asking \"what will the config look like in a repository that I created at\n> this path via git-init or git-clone?\".\n\nMy fundamental issue was \"git is using a conditionally included config\noption core.sshCommand while outside of a git repository, but git config\nis not displaying that config option when I ask it to\". The good news is\ngiven the discussion in this thread I can now say that I was labouring\nunder a misconception about how git clone works, and what I thought\nwas a bug is normal expected behaviour.\n\nMy old understanding of git clone:\n- create sub-directory\n- create subdir/.git and whatever initial states are needed\n- clone the repo from origin into the directory\n- all never having left $CWD\n\nIt's actually:\n- create sub-directory\n- cd subdir\n- create ./.git and initial states\n- clone the repo _while inside_ a gitdir\n- cd ..\n\nI would like to suggest that the documentation for either or both\ngit clone and includeIf could be improved to talk about this case so\nthat others having trouble with a conditionally included sshComand\nduring cloning will not have to relearn the wheel.\n\nI believe my misunderstanding was partially misled by the fact that\ndespite the documentation for includeIf talking about it being a gitdir\nthe part of that path being matched is not itself within a git directory;\n~/work/git/git/.git was the end result, ~/work being the matched on\npart of the path and not in a git directory.\n\n> Maybe Stuart really would prefer to change his config to \"whenever I am\n> in this directory root, repo or no, use this config\". It does have weird\n> corner cases around \"git --git-dir=/path/to/repo\", but doing that from\n> another directory is perhaps rare enough that people using a cwd:\n> conditional would be happy to ignore that.\n\nI do not. Hopefully this thread will also assist future includeIf\ntrouble-havers.\n\nThanks all, very much appreciated. I consider the matter settled\nas 'working as designed'.\n"},{"id":"412449","messageId":"xmqq5z512v2r.fsf@gitster.c.googlers.com","threadId":"54829","inReplyTo":"CAPQE4+rhWT9kgusNXOw5cnJ-oFq++4G1FMaXvQ3wppQ0GE0hSA@mail.gmail.com","subject":"Re: [Bug report] includeIf config is not displayed in normal directories","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-12-16T23:24:28Z","receivedAt":"2020-12-16T23:25:32Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stuart MacDonald <stuartm.coding@gmail.com> writes:\n\n> My old understanding of git clone:\n> - create sub-directory\n> - create subdir/.git and whatever initial states are needed\n> - clone the repo from origin into the directory\n> - all never having left $CWD\n>\n> It's actually:\n> - create sub-directory\n> - cd subdir\n> - create ./.git and initial states\n> - clone the repo _while inside_ a gitdir\n> - cd ..\n\nI am not sure how the above two should make any difference with the\n[includeif \"gitdir:<pattern>\"] matching.  Regardless of where your\n$CWD is, the inclusion is decided on the location of the .git/\ndirectory we are dealing with, so as long as \"subdir/.git\" matches\nthe pattern given to \"gitdir:<pattern>\" the inclusion should work\nthe same way even if the internal implementation of \"git clone\"\nchanges between the above two.\n\nIIRC \"includeif\" is a Peff's brainchild, so I'd ask him to correct\nany mistakes in the above paragraph, but I am a bit puzzled as to\nwhat the true misunderstanding is, where the misunderstanding came\nfrom, and which documentation if any we should look into improving.\n\nThanks.\n\n"},{"id":"412542","messageId":"X9xK+rn8vZGtBuuo@coredump.intra.peff.net","threadId":"54829","inReplyTo":"xmqq5z512v2r.fsf@gitster.c.googlers.com","subject":"Re: [Bug report] includeIf config is not displayed in normal directories","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2020-12-18T06:23:54Z","receivedAt":"2020-12-18T06:24:37Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Dec 16, 2020 at 03:24:28PM -0800, Junio C Hamano wrote:\n\n> Stuart MacDonald <stuartm.coding@gmail.com> writes:\n> \n> > My old understanding of git clone:\n> > - create sub-directory\n> > - create subdir/.git and whatever initial states are needed\n> > - clone the repo from origin into the directory\n> > - all never having left $CWD\n> >\n> > It's actually:\n> > - create sub-directory\n> > - cd subdir\n> > - create ./.git and initial states\n> > - clone the repo _while inside_ a gitdir\n> > - cd ..\n> \n> I am not sure how the above two should make any difference with the\n> [includeif \"gitdir:<pattern>\"] matching.  Regardless of where your\n> $CWD is, the inclusion is decided on the location of the .git/\n> directory we are dealing with, so as long as \"subdir/.git\" matches\n> the pattern given to \"gitdir:<pattern>\" the inclusion should work\n> the same way even if the internal implementation of \"git clone\"\n> changes between the above two.\n\nI think the question is just \"are we in a repository as part of clone or\nnot\". Stuart's original world-view was that we were not, as we were\ncreating a clone but not \"entering\" it. But that is not how it is\nimplemented (nor the conceptual model I think we would want to give the\nuser).\n\n> IIRC \"includeif\" is a Peff's brainchild, so I'd ask him to correct\n> any mistakes in the above paragraph,\n\nThe notion of conditional includes was my thing, but gitdir: was Duy's.\nThat said...\n\n> but I am a bit puzzled as to\n> what the true misunderstanding is, where the misunderstanding came\n> from, and which documentation if any we should look into improving.\n\nI think it might just be a case of mistaken assumptions. But I am\ncertainly open to hearing from Stuart if there are places in the\ndocumentation that misled him (or could have led him better).\n\n-Peff\n"}]}