* [RFC] Allow includeIf.hasconfig to take precedence over includeIf.gitdir
@ 2025-08-21 4:29 engdoc
2025-08-25 19:40 ` Junio C Hamano
0 siblings, 1 reply; 2+ messages in thread
From: engdoc @ 2025-08-21 4:29 UTC (permalink / raw)
To: git
Hello Git developers,
I would like to request a feature regarding the priority of conditional includes in Git configuration.
Background:
Currently, when both includeIf.gitdir and includeIf.hasconfig conditions match for a repository, Git always processes gitdir first, regardless of the order in the config file. This behavior is hardcoded and cannot be changed by users.
My use case:
In my workflow, due to the current priority order, the gitdir include always takes precedence, making it impossible to override it with hasconfig when both match.
Request:
I would like to have a way to make includeIf.hasconfig take precedence over includeIf.gitdir, either by:
Allowing users to specify the priority/order of conditional includes, or
Always processing hasconfig before gitdir, or
Providing a configuration option to control this behavior.
Motivation:
This would allow more flexible and context-aware configuration setups, especially for teams or users who want to have per-repository overrides based on the presence of certain config files, without being constrained by the repository path.
Thank you for considering this feature request!
Best regards
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [RFC] Allow includeIf.hasconfig to take precedence over includeIf.gitdir
2025-08-21 4:29 [RFC] Allow includeIf.hasconfig to take precedence over includeIf.gitdir engdoc
@ 2025-08-25 19:40 ` Junio C Hamano
0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2025-08-25 19:40 UTC (permalink / raw)
To: engdoc; +Cc: git
"engdoc" <engdoc@aliyun.com> writes:
[administrivia: please wrap overly long lines]
> Background:
>
> Currently, when both includeIf.gitdir and includeIf.hasconfig
> conditions match for a repository, Git always processes gitdir
> first, regardless of the order in the config file.
Is that true? I created an empty repository in /var/tmp/x/includeIf
and added this in its .git/config file:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[includeIf "hasconfig:remote.*.url:*"]
path = /var/tmp/x/includeIf/.git/hasRemote
[includeIf "gitdir:/var/tmp/x/includeIf/.git"]
path = /var/tmp/x/includeIf/.git/Here
[remote "this"]
url = .
where hasRemote and Here each have a single line
[jch] included = hasRemote # in hasRemote
[jch] included = Here # in Here
With that preparation done, I tried
$ git config list --local --includes
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
includeif.hasconfig:remote.*.url:*.path=/var/tmp/x/includeIf/.git/hasRemote
jch.included=hasRemote
includeif.gitdir:/var/tmp/x/includeIf/.git.path=/var/tmp/x/includeIf/.git/Here
jch.included=Here
remote.this.url=.
Notice that the multi-valued configuration variable jch.included
gets hasRemote first and then Here second.
Then I swapped the two includeIf in the .git/config file and ran the
experiment again.
$ git config list --local --includes
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
includeif.gitdir:/var/tmp/x/includeIf/.git.path=/var/tmp/x/includeIf/.git/Here
jch.included=Here
includeif.hasconfig:remote.*.url:*.path=/var/tmp/x/includeIf/.git/hasRemote
jch.included=hasRemote
remote.this.url=.
I do not doubt that you are having some problem, but it does not
look to me that your description above points to the source of the
problem.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-08-25 19:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-21 4:29 [RFC] Allow includeIf.hasconfig to take precedence over includeIf.gitdir engdoc
2025-08-25 19:40 ` Junio C Hamano
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).