{"thread":{"id":"55073","subject":"Git Conditional Includes Question (possible bug?)","startedAt":"2021-01-29T21:22:55Z","lastAt":"2021-01-31T04:36:38Z","messageCount":3,"participants":["Colton Hurst","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"415600","messageId":"1E4AB5E8-DD46-45CA-9A3F-C49F115BE0D4@coltonhurst.com","threadId":"55073","inReplyTo":null,"subject":"Git Conditional Includes Question (possible bug?)","fromName":"Colton Hurst","fromEmail":"colton@coltonhurst.com","sentAt":"2021-01-29T21:21:44Z","receivedAt":"2021-01-29T21:22:55Z","isPatch":false,"sender":{"key":"colton@coltonhurst.com","avatar":null},"body":"Hello,\n\nI am attempting to use Git conditional includes, but it does not seem to work for me. Can you please help me find out what I’m doing wrong?\n\n[Expectation]\nWhen I run `cd ~/colton/github/coltonhurst.com` (this is a valid git repo) and then run `git config user.email`, I expect ‘colton@coltonhurst.com’ will be returned.\n\n[Actual Result]\nWhen I run `cd ~/colton/github/coltonhurst.com` (this is a valid git repo) and then run `git config user.email`, nothing is returned.\n\nIs this correct behavior? It seems like Git is not recognizing my `.gitconfig` file, and the configuration is not set correctly.\n\nI’m using git version 2.30.0 with on a Mac version 11.1 (Big Sur)\nMy main shell is: fish, version 3.1.2\nI also have tested & have the same issues using: GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin20)\n\nTo reproduce, I have the two files at the listed locations:\n\n`.gitconfig` at: `~/`, with the following contents:\n\n[user]\n\tname = Colton Hurst\n\n[includeIf \"gitdir:~/colton/github\"]\n\tpath = ~/colton/github/.gitconfig\n\n[includeIf \"gitdir:~/colton/sourcehut\"]\n\tpath = ~/colton/sourcehut/.gitconfig\n\n`.gitconfig` at: `~/colton/github`, with the following contents:\n\n[user]\n\tname = Colton Hurst\n\temail = colton@coltonhurst.com\n\nThis is the output from `git bugreport`:\n\n[System Info]\ngit version:\ngit version 2.30.0\ncpu: x86_64\nno commit associated with this build\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nuname: Darwin 20.2.0 Darwin Kernel Version 20.2.0: Wed Dec  2 20:39:59 PST 2020; root:xnu-7195.60.75~1/RELEASE_X86_64 x86_64\ncompiler info: clang: 12.0.0 (clang-1200.0.32.28)\nlibc info: no libc information available\n$SHELL (typically, interactive shell): /bin/zsh\n\n\nThank you for reading,\n\n\ncdh\n\n"},{"id":"415609","messageId":"xmqqlfcbs69z.fsf@gitster.c.googlers.com","threadId":"55073","inReplyTo":"1E4AB5E8-DD46-45CA-9A3F-C49F115BE0D4@coltonhurst.com","subject":"Re: Git Conditional Includes Question (possible bug?)","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-01-29T22:54:48Z","receivedAt":"2021-01-29T22:55:34Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Colton Hurst <colton@coltonhurst.com> writes:\n\n> [Expectation] When I run `cd ~/colton/github/coltonhurst.com`\n> (this is a valid git repo) and then run `git config user.email`, I\n> expect ‘colton@coltonhurst.com’ will be returned.\n>\n> [Actual Result] When I run `cd ~/colton/github/coltonhurst.com`\n> (this is a valid git repo) and then run `git config user.email`,\n> nothing is returned.\n\nThe relevant part of the per-user config are\n\n> [user]\n> \tname = Colton Hurst\n\nThis is not conditional, and applies when you are in the repository.\n\n> [includeIf \"gitdir:~/colton/github\"]\n> \tpath = ~/colton/github/.gitconfig\n\nThis is conditional, and applies when you are in a repository whose\n\".git\" location matches the glob pattern \"~/colton/github\".  The\nlocation in question is \"~/colton/github/coltonhurst.com\", which\ndoes not match the pattern, so it would be skipped.\n\n> [includeIf \"gitdir:~/colton/sourcehut\"]\n> \tpath = ~/colton/sourcehut/.gitconfig\n\nLikewise.\n\nSo, nobody sets user.email in your example.  Isn't it expected that\nnothing is returned?\n\nI wonder what happens when the second one is updated to\n\n> [includeIf \"gitdir:~/colton/github/\"]\n> \tpath = ~/colton/github/.gitconfig\n\nas \"git config --help\" says:\n\n * If the pattern ends with `/`, `**` will be automatically added. For\n   example, the pattern `foo/` becomes `foo/**`. In other words, it\n   matches \"foo\" and everything inside, recursively.\n\nand \"~/colton/github/**\" as a pattern would match the path to the\nrepository in question.\n\n"},{"id":"415685","messageId":"B569AC8C-8AF3-46E6-B8FB-A6EBEF42FA00@coltonhurst.com","threadId":"55073","inReplyTo":"xmqqlfcbs69z.fsf@gitster.c.googlers.com","subject":"Re: Git Conditional Includes Question (possible bug?)","fromName":"Colton Hurst","fromEmail":"colton@coltonhurst.com","sentAt":"2021-01-31T04:23:39Z","receivedAt":"2021-01-31T04:36:38Z","isPatch":false,"sender":{"key":"colton@coltonhurst.com","avatar":null},"body":"Junio,\n\n> as \"git config --help\" says:\n> \n> * If the pattern ends with `/`, `**` will be automatically added. For\n>   example, the pattern `foo/` becomes `foo/**`. In other words, it\n>   matches \"foo\" and everything inside, recursively.\n> \n> and \"~/colton/github/**\" as a pattern would match the path to the\n> repository in question.\n\nThat solved the issue. My email was in the subdirectory config files, but not having the `/` at the end of the path ruined it. Thank you so much for the help!\n\nHave a great day and weekend!\n\n\nColton"}]}