Re: [RFC PATCH 2/2] config: add 'config.superproject' file
On Fri, Apr 09, 2021 at 12:10:27PM +0100, Philip Oakley wrote:
Show 31 quoted lines
>
> On 09/04/2021 00:39, Emily Shaffer wrote:
> > Some configs, such as wrapper directives like gerrit.createChangeId, or
> > forthcoming hook configs, should apply to a superproject as well as all
> > its submodules. It may not be appropriate to apply them globally - for
> > example, if the user also contributes to many projects which do not use
> > the configs necessary for one project-with-submodules - and it may be
> > burdensome to apply them locally to the superproject and each of its
> > submodules. Even if the user runs 'git submodule foreach "git config
> > --local foo.bar', if a new submodule is added later on, that config is
> > not applied to the new submodule.
> >
> > It is also inappropriate to share the entire superproject config, since
> > some items - like remote URLs or partial-clone filters - would not apply
> > to a submodule.
> >
> > To make life easier for projects with many submodules, then, create a
> > new "config.superproject" config scope, which is included in the config
> > parse for the superproject as well as for all the submodules of that
> > superproject.
> >
> > For the superproject, this new config file is equally local to the local
> > config; for the submodule, the new config file is less local than the
> > local config. So let's include it directly before the local config
> > during the config parse.
> >
> > Signed-off-by: Emily Shaffer <emilyshaffer@google.com>
> > ---
>
> Does this need an update to the `git config --show-origin --show-scope`
> capability?
Show 21 quoted lines
> > --- a/config.c
> > +++ b/config.c
> > @@ -3515,6 +3539,8 @@ const char *config_scope_name(enum config_scope scope)
> > return "command";
> > case CONFIG_SCOPE_GITMODULES:
> > return "gitmodules";
> > + case CONFIG_SCOPE_SUPERPROJECT:
> > + return "superproject";
> > default:
> > return "unknown";
> > }
> > diff --git a/config.h b/config.h
> > index 535f5517b8..b42e1d13eb 100644
> > --- a/config.h
> > +++ b/config.h
> > @@ -43,6 +43,7 @@ enum config_scope {
> > CONFIG_SCOPE_WORKTREE,
> > CONFIG_SCOPE_COMMAND,
> > CONFIG_SCOPE_GITMODULES,
> > + CONFIG_SCOPE_SUPERPROJECT,
> > };Show 22 quoted lines
> > diff --git a/t/t1311-superproject-config.sh b/t/t1311-superproject-config.sh
> > new file mode 100755
> > index 0000000000..650c4d24c7
> > --- /dev/null
> > +++ b/t/t1311-superproject-config.sh
> > +test_expect_success 'can --show-origin the superproject config' '
> > + git config --superproject --add foo.bar baz &&
> > +
> > + git config --list --show-origin >actual &&
> > + grep -F "config.superproject" actual &&
> > +
> > + rm .git/config.superproject
> > +'
> > +
> > +test_expect_success 'can --show-scope the superproject config' '
> > + git config --superproject --add foo.bar baz &&
> > +
> > + git config --list --show-scope >actual &&
> > + grep "superproject" actual &&
> > +
> > + rm .git/config.superproject
> > +'