From: Duy Nguyen <pclouds@gmail.com>
To: Eric Sunshine <sunshine@sunshineco.com>
Cc: Git List <git@vger.kernel.org>,
Michael J Gruber <git@drmicha.warpmail.net>,
Max Kirillov <max@max630.net>, Jens Lehmann <Jens.Lehmann@web.de>
Subject: Re: [PATCH 2/5] config.c: move worktree-specific variables to .git/worktrees/...
Date: Sun, 6 Dec 2015 11:22:16 +0100 [thread overview]
Message-ID: <CACsJy8BDCGxkLuFTwoyNYZqThe9mZYh1OpL8R1R4-BFvB_1coA@mail.gmail.com> (raw)
In-Reply-To: <CAPig+cST=UGG8VAG94qb9M8vcOXfmWAhLoP65yWJGywR9R84LA@mail.gmail.com>
On Sun, Dec 6, 2015 at 8:47 AM, Eric Sunshine <sunshine@sunshineco.com> wrote:
> On Wed, Dec 2, 2015 at 2:13 PM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
>> .git/info/config.worktree is a pattern list that splits .git/config in
>> to sets: the worktree set matches the patterns, the commmon set does
>> not.
>>
>> In normal worktrees, both sets are stored in .git/config. The
>> config.worktree has no effect. Nothing is changed.
>>
>> In linked worktrees, the common and worktree sets are read from and
>> saved to .git/config and .git/config.worktree respectively. Config
>> keys in .git/config that belong to the worktree set is ignored. Those
>> are for the main worktree only. Similarly, keys not matching the
>> patterns come from .git/config, duplicate keys from
>> .git/config.worktree are ignored.
>>
>> The effect is similar to the $GIT_DIR/$GIT_COMMON_DIR split, we can
>> define that some vars can be shared and some cannot. And as a result
>> of the $GIT_DIR/$GIT_COMMON_DIR split, config.worktree is actually
>> found at .git/worktrees/<id>/config.worktree.
>
> Why does this worktree-specific file need/have a .worktree suffix?
I think in the beginning it was supposed to support git-new-workdir as
well. With a separate name, you can symlink .git/config back to
original repo and create a new .git/config.worktree. The actual code
in this patch does not support this though. I guess as 'git worktree'
is maturing, we probably don't have to worry about git-new-workdir and
could drop .worktree suffix.
>> +static int is_config_local(const char *key_)
>> +{
>> + static struct strbuf key = STRBUF_INIT;
>> + int i, dtype;
>> +
>> + if (!config_local.nr)
>> + return 0;
>> +
>> + strbuf_reset(&key);
>> + strbuf_addstr(&key, key_);
>
> Why does 'key' need to be static considering that it is overwritten on
> each call and its value is never accessed after the function returns?
Mostly to avoid re-allocation because this function will be called for
every configuration variable. But this may be premature optimization.
On top of that, if we go with builtin per-worktree list only as being
discussed, then we can drop exclude machinery, we don't have to
preprocess "key" and we can finally kill this "strbuf key".
>> @@ -198,4 +198,30 @@ test_expect_success 'local clone from linked checkout' '
>> +test_expect_success 'setting worktree.foo goes to config.worktree' '
>> + echo worKtree.Foo >> .git/info/config.worktree &&
>
> Perhaps? s/>> />/
Yeah. In the previous iteration, config.worktree would contain the
default list (core.worktree and stuff) so > may force following tests
to re-initialize config.worktree again. But that's now gone and >
makes more sense.
>> +test_expect_success 'shared config still goes to config' '
>> + git config random.key randomValue &&
>> + git --git-dir=wt.foo/.git config random.key >actual &&
>
> What about also testing the opposite scenario?
>
> git --git-dir=wt.foo/.git config random.key randomValue &&
> git config random.key >actual &&
Yep. Will do.
--
Duy
next prev parent reply other threads:[~2015-12-06 10:22 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-02 19:13 [PATCH 0/5] Split .git/config in multiple worktree setup Nguyễn Thái Ngọc Duy
2015-12-02 19:13 ` [PATCH 1/5] dir.c: clean the entire struct in clear_exclude_list() Nguyễn Thái Ngọc Duy
2015-12-02 19:13 ` [PATCH 2/5] config.c: move worktree-specific variables to .git/worktrees/ Nguyễn Thái Ngọc Duy
2015-12-06 7:47 ` Eric Sunshine
2015-12-06 10:22 ` Duy Nguyen [this message]
2015-12-02 19:13 ` [PATCH 3/5] setup.c: remove special case of core.worktree and core.bare Nguyễn Thái Ngọc Duy
2015-12-02 19:13 ` [PATCH 4/5] worktree: make core.sparseCheckout and core.ignoreStat per-worktree Nguyễn Thái Ngọc Duy
2015-12-02 19:13 ` [PATCH 5/5] git-worktree.txt: mention about the config file split Nguyễn Thái Ngọc Duy
2015-12-06 8:02 ` Eric Sunshine
2015-12-03 6:15 ` [PATCH 0/5] Split .git/config in multiple worktree setup Max Kirillov
2015-12-03 8:07 ` Duy Nguyen
2015-12-03 19:52 ` Junio C Hamano
2015-12-03 21:00 ` Max Kirillov
2015-12-03 20:53 ` Max Kirillov
2015-12-04 15:57 ` Duy Nguyen
2015-12-27 3:14 ` [PATCH v2 0/6] " Nguyễn Thái Ngọc Duy
2015-12-27 3:14 ` [PATCH v2 1/6] Define new repo extension to manage multiple worktree behaviors Nguyễn Thái Ngọc Duy
2015-12-27 3:14 ` [PATCH v2 2/6] config.c: move worktree-specific variables to .git/worktrees/ Nguyễn Thái Ngọc Duy
2015-12-27 3:14 ` [PATCH v2 3/6] setup.c: remove special case of core.worktree and core.bare Nguyễn Thái Ngọc Duy
2015-12-27 3:14 ` [PATCH v2 4/6] worktree: make core.sparseCheckout and core.ignoreStat per-worktree Nguyễn Thái Ngọc Duy
2015-12-27 3:14 ` [PATCH v2 5/6] config.c: allow to un-share certain config in multi-worktree setup Nguyễn Thái Ngọc Duy
2015-12-27 3:14 ` [PATCH v2 6/6] worktree: bump worktree version to 1 on "worktree add" Nguyễn Thái Ngọc Duy
2016-01-11 22:43 ` [PATCH v2 0/6] Split .git/config in multiple worktree setup Max Kirillov
2016-01-26 11:44 ` [PATCH v3 " Nguyễn Thái Ngọc Duy
2016-01-26 11:44 ` [PATCH v3 1/6] worktree: new repo extension to manage worktree behaviors Nguyễn Thái Ngọc Duy
2016-01-27 22:12 ` Junio C Hamano
2016-01-28 12:11 ` Duy Nguyen
2016-01-30 14:20 ` Max Kirillov
2016-01-31 16:42 ` Junio C Hamano
2016-02-01 2:41 ` Stefan Monnier
2016-02-01 2:47 ` Stefan Monnier
2016-02-01 5:23 ` Duy Nguyen
2016-02-01 18:19 ` Junio C Hamano
2016-02-04 18:12 ` git worktree (was: [PATCH v3 1/6] worktree: new repo extension to manage worktree behaviors) Stefan Monnier
2016-02-01 18:39 ` [PATCH v3 1/6] worktree: new repo extension to manage worktree behaviors Dennis Kaarsemaker
2016-01-30 13:59 ` Max Kirillov
2016-01-26 11:44 ` [PATCH v3 2/6] path.c: new (identical) list for worktree v1 Nguyễn Thái Ngọc Duy
2016-01-27 22:18 ` Junio C Hamano
2016-01-30 14:45 ` Max Kirillov
2016-01-26 11:44 ` [PATCH v3 3/6] worktree: share .git/common in v1 Nguyễn Thái Ngọc Duy
2016-01-26 11:44 ` [PATCH v3 4/6] worktree: new config file hierarchy Nguyễn Thái Ngọc Duy
2016-01-27 22:22 ` Junio C Hamano
2016-01-28 12:03 ` Duy Nguyen
2016-01-28 18:45 ` Junio C Hamano
2016-02-01 5:09 ` Duy Nguyen
2016-01-26 11:44 ` [PATCH v3 5/6] config: select .git/common/config with --repo Nguyễn Thái Ngọc Duy
2016-01-30 22:10 ` Max Kirillov
2016-02-01 5:15 ` Duy Nguyen
2016-01-26 11:44 ` [PATCH v3 6/6] worktree add: switch to worktree version 1 Nguyễn Thái Ngọc Duy
2016-02-01 5:33 ` Max Kirillov
2016-02-01 6:05 ` Duy Nguyen
2016-02-02 5:35 ` Max Kirillov
2016-01-27 22:23 ` [PATCH v3 0/6] Split .git/config in multiple worktree setup 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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CACsJy8BDCGxkLuFTwoyNYZqThe9mZYh1OpL8R1R4-BFvB_1coA@mail.gmail.com \
--to=pclouds@gmail.com \
--cc=Jens.Lehmann@web.de \
--cc=git@drmicha.warpmail.net \
--cc=git@vger.kernel.org \
--cc=max@max630.net \
--cc=sunshine@sunshineco.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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).