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

Re: Multiple --global config workspaces?

From
EHElsie Hupp <git@elsiehupp.com>
Date
Oct 18, 2022, 04:02 UTC
Message-ID
<ACFF4036-3DD1-4647-90BB-77F029326715@elsiehupp.com>
In-Reply-To
<Y0m64fHWIjZoXoTQ@coredump.intra.peff.net>
A response to this:
Show 10 quoted lines
>> And I tried the following to no avail (despite both paths resolving when using cat):
>> 
>> [includeIf "gitdir:github/"] path = ./**/github/.gitconfig
>> 
>> [includeIf "gitdir:github/"] path = ./*/github/.gitconfig
> 
> Right, the value of an include path expands to a single file, and we do
> not do any globbing. I suppose it would be possible to do, and we'd read
> each file in sequence. But I'm not sure I'm convinced of the utility of
> that (and again, it doesn't help the discoverability problem you had).
My thought is that globbing (I’m not sure of the terminology) should be supported to the extent that it’s valid bash syntax, and breaking consistency with bash could cause more confusion than just letting the user do weird or inadvisable things with the path variable that nonetheless have entirely predictable outcomes.
So, because, e.g., the following works:
> elsiehupp@Alpha:~$ cat ./**/github/.gitconfig
> [user]
> 	email = github@elsiehupp.com
…one would expect, e.g., this gitconfig line to work, as well:
> [include] path = ./**/github/.gitconfig
For comparison, I can also do:
Show 13 quoted lines
> elsiehupp@Alpha:~$ cat ./**/**/.gitconfig
> [user]
> 	email = github@elsiehupp.com
> [user]
> 	email = gitlab@elsiehupp.com
> [user]
> 	email = gnome@elsiehupp.com
> [user]
> 	email = launchpad@elsiehupp.com
> [user]
> 	email = github@elsiehupp.com
> [user]
> 	email = xdg@elsiehupp.com
If I pipe the above into a new ~/.gitconfig, I can then do:
Show 7 quoted lines
> elsiehupp@Alpha:~$ git config --get-all user.email
> github@elsiehupp.com
> gitlab@elsiehupp.com
> gnome@elsiehupp.com
> launchpad@elsiehupp.com
> github@elsiehupp.com
> xdg@elsiehupp.com
I don’t know off the top of my head what happens when a single variable is defined multiple times. I do get the following output, though:
> elsiehupp@Alpha:~$ git config --get user.email
> xdg@elsiehupp.com
Basically one might expect [include] to behave like cat in bash… more for consistency and predictability than anything else.
None of the various cat command-line options seem particularly applicable to [include], so my commentary here mainly concerns [include] recognizing and working with path wildcards and the like along otherwise established patterns of behavior.
(Now, to change my gitconfig back to the conditional includes…)
Previous: Jeff KingNext: Jeff King
Message 9 of 14 in “Multiple --global config workspaces?”
  1. Elsie HuppOct 11, 2022
  2. Junio C HamanoOct 11, 2022
  3. Jeff KingOct 11, 2022
  4. Elsie HuppOct 11, 2022
  5. Elsie HuppOct 11, 2022
  6. Jeff KingOct 14, 2022
  7. Matthias AßhauerOct 15, 2022
  8. Jeff KingOct 15, 2022
  9. Elsie HuppOct 18, 2022
  10. Jeff KingOct 18, 2022
  11. Elsie HuppOct 20, 2022
  12. Elsie HuppOct 20, 2022
  13. Philip OakleyOct 11, 2022
  14. RetoOct 11, 2022

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.