{"thread":{"id":"64004","subject":"[RFC] Allow includeIf.hasconfig to take precedence over includeIf.gitdir","startedAt":"2025-08-21T04:30:00Z","lastAt":"2025-08-25T19:40:20Z","messageCount":2,"participants":["engdoc","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"524595","messageId":"a903afc8-9bf6-4ba8-bdab-87a76adf631e.engdoc@aliyun.com","threadId":"64004","inReplyTo":null,"subject":"[RFC] Allow includeIf.hasconfig to take precedence over includeIf.gitdir","fromName":"engdoc","fromEmail":"engdoc@aliyun.com","sentAt":"2025-08-21T04:29:57Z","receivedAt":"2025-08-21T04:30:00Z","isPatch":false,"sender":{"key":"engdoc@aliyun.com","avatar":null},"body":"\n\nHello Git developers,\nI would like to request a feature regarding the priority of conditional includes in Git configuration.\n\n\nBackground:\nCurrently, 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.\n\n\nMy use case:\nIn 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.\n\n\nRequest:\nI would like to have a way to make includeIf.hasconfig take precedence over includeIf.gitdir, either by:\nAllowing users to specify the priority/order of conditional includes, or\n\nAlways processing hasconfig before gitdir, or\n\nProviding a configuration option to control this behavior.\n\n\n\nMotivation:\nThis 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.\n\n\nThank you for considering this feature request!\n\n\nBest regards\n\n\n\n\n"},{"id":"524889","messageId":"xmqq1pozqjfi.fsf@gitster.g","threadId":"64004","inReplyTo":"a903afc8-9bf6-4ba8-bdab-87a76adf631e.engdoc@aliyun.com","subject":"Re: [RFC] Allow includeIf.hasconfig to take precedence over includeIf.gitdir","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-08-25T19:40:17Z","receivedAt":"2025-08-25T19:40:20Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"engdoc\" <engdoc@aliyun.com> writes:\n\n[administrivia: please wrap overly long lines]\n\n> Background:\n>\n> Currently, when both includeIf.gitdir and includeIf.hasconfig\n> conditions match for a repository, Git always processes gitdir\n> first, regardless of the order in the config file.\n\nIs that true?  I created an empty repository in /var/tmp/x/includeIf\nand added this in its .git/config file:\n\n        [core]\n                repositoryformatversion = 0\n                filemode = true\n                bare = false\n                logallrefupdates = true\n\n        [includeIf \"hasconfig:remote.*.url:*\"]\n                path = /var/tmp/x/includeIf/.git/hasRemote\n\n        [includeIf \"gitdir:/var/tmp/x/includeIf/.git\"]\n                path = /var/tmp/x/includeIf/.git/Here\n\n        [remote \"this\"]\n                url = .\n\nwhere hasRemote and Here each have a single line\n\n\t[jch] included = hasRemote  # in hasRemote\n\t[jch] included = Here       # in Here\n\nWith that preparation done, I tried\n\n    $ git config list --local --includes\n    core.repositoryformatversion=0\n    core.filemode=true\n    core.bare=false\n    core.logallrefupdates=true\n    includeif.hasconfig:remote.*.url:*.path=/var/tmp/x/includeIf/.git/hasRemote\n    jch.included=hasRemote\n    includeif.gitdir:/var/tmp/x/includeIf/.git.path=/var/tmp/x/includeIf/.git/Here\n    jch.included=Here\n    remote.this.url=.\n\nNotice that the multi-valued configuration variable jch.included\ngets hasRemote first and then Here second.\n\nThen I swapped the two includeIf in the .git/config file and ran the\nexperiment again.\n\n    $ git config list --local --includes\n    core.repositoryformatversion=0\n    core.filemode=true\n    core.bare=false\n    core.logallrefupdates=true\n    includeif.gitdir:/var/tmp/x/includeIf/.git.path=/var/tmp/x/includeIf/.git/Here\n    jch.included=Here\n    includeif.hasconfig:remote.*.url:*.path=/var/tmp/x/includeIf/.git/hasRemote\n    jch.included=hasRemote\n    remote.this.url=.\n\nI do not doubt that you are having some problem, but it does not\nlook to me that your description above points to the source of the\nproblem.\n"}]}