Re: [PATCH v2 2/2] worktree: add per-worktree config files
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- Sep 30, 2018, 07:36 UTC
- Message-ID
- <CACsJy8BrdXZx3+exwL-xDfdTxMa4Ez1y051CaKA3z2e7OC2FZQ@mail.gmail.com>
- In-Reply-To
- <CAPig+cTJKuEkb5AVi=xyztfEo84NzaduNnX3mhec3xrYf4PGUg@mail.gmail.com>
On Sun, Sep 30, 2018 at 9:24 AM Eric Sunshine <sunshine@sunshineco.com> wrote:
Show 34 quoted lines
>
> On Sun, Sep 30, 2018 at 3:16 AM Duy Nguyen <pclouds@gmail.com> wrote:
> > On Sun, Sep 30, 2018 at 6:33 AM Eric Sunshine <sunshine@sunshineco.com> wrote:
> > > > diff --git a/builtin/config.c b/builtin/config.c
> > > > @@ -645,7 +649,20 @@ int cmd_config(int argc, const char **argv, const char *prefix)
> > > > + else if (use_worktree_config) {
> > > > + struct worktree **worktrees = get_worktrees(0);
> > > > + if (repository_format_worktree_config)
> > > > + given_config_source.file = git_pathdup("config.worktree");
> > > > + else if (worktrees[0] && worktrees[1])
> > > > + die(_("--worktree cannot be used with multiple "
> > > > + "working trees unless the config\n"
> > > > + "extension worktreeConfig is enabled. "
> > > > + "Please read \"CONFIGURATION FILE\"\n"
> > > > + "section in \"git help worktree\" for details"));
> > > > + else
> > > > + given_config_source.file = git_pathdup("config");
> > >
> > > I'm not sure I understand the purpose of allowing --worktree when only
> > > a single worktree is present and extensions.worktreeConfig is not set.
> > > Can you talk about it a bit more?
> >
> > Unified API. If I write a script to do stuff and want it to work in
> > multiple worktrees as well, I should not need to do "if single
> > worktree, use "git config --local", if multiple use "git config
> > --worktree"". By using "git config --worktree" I tell git "this config
> > is per-worktree" and git should do the right thing, single worktree or
> > not.
>
> That's what I thought, but I still don't understand how that unified
> API is going to help if the script writer happens to have multiple
> worktrees but doesn't have extensions.worktreeConfig set, in which
> case the command will error out. I don't see how that simplifies
> things, but perhaps I'm missing something obvious.No it does not simplify that step. The user has to enable it manually (at least for now). v1 tried to enable it automatically, but I think it's safer to go one step at a time.
-- Duy