Re: [PATCH v2] config: support remote name in includeIf.hasconfig condition
On Sunday, October 20th, 2024 at 1:18 PM, Ken Matsui <ken@kmatsui.me> wrote:
Show 48 quoted lines
>
>
> On Sunday, October 20th, 2024 at 12:21 PM, Ramsay Jones ramsay@ramsayjones.plus.com wrote:
>
> > On 20/10/2024 17:01, Ken Matsui wrote:
> >
> > > Changes in v2:
> > >
> > > * Updated the description based on Kristoffer's review.
> > >
> > > -- >8 --
> > >
> > > includeIf.hasconfig only accepts remote.*.url, making it difficult to
> > > apply configuration based on a specific remote, especially in projects
> > > with multiple remotes (e.g., GitHub and non-GitHub hosting). This often
> > > leads to undesired application of multiple config files.
> > >
> > > For example, the following configuration:
> > >
> > > [remote "origin"]
> > > url = https://git.kernel.org/pub/scm/git/git.git
> > > [remote "github"]
> > > url = https://github.com/myfork/git.git
> > >
> > > [includeIf "hasconfig:remote..url:https://github.com/"]
> > > path = github.inc
> > > [includeIf "hasconfig:remote..url:https://git.kernel.org/"]
> > > path = git.inc
> > >
> > > would apply both github.inc and git.inc, even when only one config is
> > > intended for the repository.
> > >
> > > Introduce support for specifying a remote name (e.g., origin) to enable
> > > more precise configuration management:
> > >
> > > [includeIf "hasconfig:remote.origin.url:https://github.com/**"]
> >
> > s/remote.origin.url/remote.github.url/ ?
> >
> > I haven't actually read the patch, so take with a pinch of salt. :)
>
>
> Actually, this should be as-is. The configuration means only if
> the GitHub URL is used for origin, we include github.inc. In this
> repo, we won't include github.inc and only include git.inc for
> whatever reason.
>
> Thank you!
I will soon update this patch's description and add more tests to avoid this kind of confusion.
Show 10 quoted lines
>
> > > path = github.inc
> > > [includeIf "hasconfig:remote.origin.url:https://git.kernel.org/**"]
> > > path = git.inc
> > >
> > > This ensures that only the intended config file is applied based on the
> > > specific remote.
> >
> > ATB,
> > Ramsay Jones