git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: Duy Nguyen <pclouds@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH] worktree: add per-worktree config files
Date: Thu, 27 Sep 2018 20:34:29 +0200	[thread overview]
Message-ID: <87r2heiybu.fsf@evledraar.gmail.com> (raw)
In-Reply-To: <CACsJy8Dwo_cBEQeqttj3G=RGaJT7bmVb=ABnV2916swgYQnyrw@mail.gmail.com>


On Thu, Sep 27 2018, Duy Nguyen wrote:

> On Wed, Sep 26, 2018 at 8:25 PM Ævar Arnfjörð Bjarmason
> <avarab@gmail.com> wrote:
>> On Sun, Sep 23 2018, Nguyễn Thái Ngọc Duy wrote:
>>
>> > +extensions.worktreeConfig::
>> > +     If set, by default "git config" reads from both "config" and
>> > +     "config.worktree" file in that order.
>>
>> How does this interact with config that's now only used if it's in
>> .git/config? E.g. you can't set remote.<remote>.<url> in ~/.gitconfig,
>> will that be inherited across the two of these?
>
> Er... we can't? If I remember correctly we don't have any enforcement
> on where what config vars must or must not go. The only exception is
> core.bare and core.worktree which is only read from $GIT_DIR/config
> because of the way they are involved in .git directory discovery. If I
> put remote "foo" in ~/.gitconfig, "git remote" happily reports remote
> "foo" to me.
>
> To sum up, we always inherit config from higher levels, with
> /etc/gitconfig being the highest and $GIT_DIR/config the lowest. It's
> up to the user to share config between repos responsibly. This patch
> only adds one more level, $GIT_DIR/config.worktree which is now the
> lowest level.

I see I'm misremembering most of the details here. I thought that if I put:

    [remote "whatever]
    url = ...

Into my ~/.gitconfig that it wouldn't work, but it does, e.g. here in my
~/g/git:

    $ grep -A1 whatever .git/config
    $
    $ grep -A1 whatever ~/.gitconfig
    [remote "whatever"]
        url = git@github.com:test/git.git

But there's still some special casing for .git/config going on,
e.g. here:

    $ git config remote.origin.url
    git@github.com:git/git.git
    $ git config remote.whatever.url
    git@github.com:test/git.git
    $ git remote get-url origin
    git@github.com:git/git.git
    $ git remote get-url whatever
    fatal: No such remote 'whatever'

And:

    $ git remote set-url whatever git@github.com:test2/git.git
    fatal: No such remote 'whatever'

So there is some special casing of .git/config somewhere. I looked into
this ages ago, and don't remember where that's done.

I was wondering if these patches introduced any unwanted edge cases in
this regard, e.g. if you're using the per-worktree config, and you have
remotes in .git/config, does "git remote get/set-url" do the right
thing?

Then if we have remotes in .git/config, should we add new remotes to
.git/config or the per-worktree file? I'd lean towards .git/config,
since remotes are orthagonal to worktrees, and closely tied with refs
which are shared no matter what this extension says, but maybe there's a
good argument for doing it the other way around.



>> > In multiple working
>> > +     directory mode, "config" file is shared while
>> > +     "config.worktree" is per-working directory.
>>
>> "But then how will it work with more than one?" I found myself thinking
>> before reading some more and remembering .git/worktree. Shouldn't we
>> consistently say:
>>
>>     [...]"config" and "worktrees/<worktree name>/config"[...]
>>
>> Or something like that?
>
> Point taken. Maybe I'm trying to hide implementation details too much.

  reply	other threads:[~2018-09-27 18:34 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-23 17:04 [PATCH] worktree: add per-worktree config files Nguyễn Thái Ngọc Duy
2018-09-23 20:47 ` Eric Sunshine
2018-09-24 14:21 ` Taylor Blau
2018-09-25 15:57   ` Duy Nguyen
2018-09-29 13:53   ` Duy Nguyen
2018-09-25 21:26 ` Junio C Hamano
2018-09-26 15:48   ` Duy Nguyen
2018-09-26 17:40     ` Junio C Hamano
2018-09-27 15:24     ` Wherefor worktrees? Marc Branchaud
2018-09-27 16:36       ` Duy Nguyen
2018-09-26 18:25 ` [PATCH] worktree: add per-worktree config files Ævar Arnfjörð Bjarmason
2018-09-27 17:24   ` Duy Nguyen
2018-09-27 18:34     ` Ævar Arnfjörð Bjarmason [this message]
2018-09-27 18:49       ` Duy Nguyen
2018-09-29  6:36       ` Duy Nguyen
2018-09-29 15:30 ` [PATCH v2 0/2] Per-worktree " Nguyễn Thái Ngọc Duy
2018-09-29 15:30   ` [PATCH v2 1/2] t1300: extract and use test_cmp_config() Nguyễn Thái Ngọc Duy
2018-09-30  4:05     ` Eric Sunshine
2018-09-30 12:31     ` SZEDER Gábor
2018-09-29 15:30   ` [PATCH v2 2/2] worktree: add per-worktree config files Nguyễn Thái Ngọc Duy
2018-09-30  4:32     ` Eric Sunshine
2018-09-30  7:15       ` Duy Nguyen
2018-09-30  7:24         ` Eric Sunshine
2018-09-30  7:36           ` Duy Nguyen
2018-10-02 16:06   ` [PATCH v3 0/2] Per-worktree " Nguyễn Thái Ngọc Duy
2018-10-02 16:06     ` [PATCH v3 1/2] t1300: extract and use test_cmp_config() Nguyễn Thái Ngọc Duy
2018-10-03  7:46       ` Eric Sunshine
2018-10-02 16:06     ` [PATCH v3 2/2] worktree: add per-worktree config files Nguyễn Thái Ngọc Duy
2018-10-21 14:02     ` [PATCH v4 0/2] Per-worktree " Nguyễn Thái Ngọc Duy
2018-10-21 14:02       ` [PATCH v4 1/2] t1300: extract and use test_cmp_config() Nguyễn Thái Ngọc Duy
2018-10-21 14:02       ` [PATCH v4 2/2] worktree: add per-worktree config files Nguyễn Thái Ngọc Duy
2018-10-22  4:54         ` Junio C Hamano
2018-10-22 14:32           ` Duy Nguyen
2018-10-25  9:16             ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r2heiybu.fsf@evledraar.gmail.com \
    --to=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=pclouds@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).