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

Re: [RFC] Allow includeIf.hasconfig to take precedence over includeIf.gitdir

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 25, 2025, 19:40 UTC
Message-ID
<xmqq1pozqjfi.fsf@gitster.g>
In-Reply-To
<a903afc8-9bf6-4ba8-bdab-87a76adf631e.engdoc@aliyun.com>
"engdoc" <engdoc@aliyun.com> writes:
[administrivia: please wrap overly long lines]
Show 5 quoted 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.

Previous: engdoc
Message 2 of 2 in “[RFC] Allow includeIf.hasconfig to take precedence over includeIf.gitdir”
  1. engdocAug 21, 2025
  2. Junio C HamanoAug 25, 2025

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.