Re: [long] worktree setup cases

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Oct 21, 2010 at 4:00 AM, Junio C Hamano <gitster@xxxxxxxxx> wrote:
>> There are a few factors that affect gitdir/worktree/cwd/prefix setup.
>> Those are:
>>
>> Â- GIT_DIR (or --git-dir)
>> Â- GIT_WORK_TREE (or --work-tree)
>> Â- core.worktree
>> Â- .git is a file pointing to real .git directory
>> Â- Bare repo
>>
>> So there are 2^5 = 32 cases in total.
> Hmm, why is core.worktree separate from the second item?

It's how the code does it. GIT_WORK_TREE can be detected early, when
cwd has not been moved. When core.worktree is found, cwd could be
somewhere. I need to separate those cases to make sure cwd is not
misused after it's been moved.

> In any case, the
> three mechanisms to specify the working tree should only be in effect when
> GIT_DIR/--git-dir is used, so the above are not orthogonal, and the total
> count should be smaller than 32 cases.

Good to hear. I forgot that GIT_DIR must be set for the three
mechanisms in effect.

>> The following questions must be answered for each case:
>>
>> 0. What setup function handles that case?
>> 1. Is worktree available?
>> 2. Where is new cwd? Is it at worktree root?
>> 3. Prefix?
>> 4. Is (relative) $GIT_DIR accessible from current cwd?
>> 5. What if original cwd is outside worktree, or new cwd if it's not at
>> Â Âworktree root?
>
> All good questions to ask, except for the last one which I cannot quite
> parse.

Skip "or new cwd... worktree root" part.

>> 1 Cases
>> ~~~~~~~~
>>
>> Case# ÂBare Â.git-file Âcore.worktree ÂGIT_DIR ÂGIT_WORK_TREE
>> 0 Â Â Â0 Â Â 0 Â Â Â Â Â0 Â Â Â Â Â Â Â0 Â Â Â Â0
>> 8 Â Â Â0 Â Â 1 Â Â Â Â Â0 Â Â Â Â Â Â Â0 Â Â Â Â0
>
> Ok.
>
>> 1 Â Â Â0 Â Â 0 Â Â Â Â Â0 Â Â Â Â Â Â Â0 Â Â Â Â1
>> 4 Â Â Â0 Â Â 0 Â Â Â Â Â1 Â Â Â Â Â Â Â0 Â Â Â Â0
>> 5 Â Â Â0 Â Â 0 Â Â Â Â Â1 Â Â Â Â Â Â Â0 Â Â Â Â1
>> 9 Â Â Â0 Â Â 1 Â Â Â Â Â0 Â Â Â Â Â Â Â0 Â Â Â Â1
>> 12 Â Â 0 Â Â 1 Â Â Â Â Â1 Â Â Â Â Â Â Â0 Â Â Â Â0
>> 13 Â Â 0 Â Â 1 Â Â Â Â Â1 Â Â Â Â Â Â Â0 Â Â Â Â1
>
> How does it make sense to have GIT_WORK_TREE without GIT_DIR? ÂWithout
> GIT_DIR, we will run repository discovery, which means we will always go
> up to find a .git dir, and the reason for doing that is because we want to
> also work in a subdirectory of a working tree (the very original git never
> worked from anywhere other than the root level of the working tree). ÂBy
> definition, the root of the working tree is the same as in cases 0/8.

OK.

>> 2 Â Â Â0 Â Â 0 Â Â Â Â Â0 Â Â Â Â Â Â Â1 Â Â Â Â0
>> 10 Â Â 0 Â Â 1 Â Â Â Â Â0 Â Â Â Â Â Â Â1 Â Â Â Â0
>
> If you set GIT_DIR, we do no discovery, so git will work only from the
> root level of the working tree (or bare repository operation) if you do
> not tell us where the working tree is.

OK

>> 3 Â Â Â0 Â Â 0 Â Â Â Â Â0 Â Â Â Â Â Â Â1 Â Â Â Â1
>> 6 Â Â Â0 Â Â 0 Â Â Â Â Â1 Â Â Â Â Â Â Â1 Â Â Â Â0
>> 7 Â Â Â0 Â Â 0 Â Â Â Â Â1 Â Â Â Â Â Â Â1 Â Â Â Â1
>> 11 Â Â 0 Â Â 1 Â Â Â Â Â0 Â Â Â Â Â Â Â1 Â Â Â Â1
>> 14 Â Â 0 Â Â 1 Â Â Â Â Â1 Â Â Â Â Â Â Â1 Â Â Â Â0
>> 15 Â Â 0 Â Â 1 Â Â Â Â Â1 Â Â Â Â Â Â Â1 Â Â Â Â1
>
> Without discovery, we know where the root level of the working tree is,
> and we know where the repository is, because you told us. ÂThe answers to
> questions 1-5, i.e. semantics observable by the end user, should be the
> same as case 0/8 even though the internal codepath to achieve that,
> i.e. question 0, may be different.

OK too.

>> 16 Â Â 1 Â Â 0 Â Â Â Â Â0 Â Â Â Â Â Â Â0 Â Â Â Â0
>> ...
>> 31 Â Â 1 Â Â 1 Â Â Â Â Â1 Â Â Â Â Â Â Â1 Â Â Â Â1
>
> Shouldn't all of these 16 be the same, if the repository is bare? ÂWhat is
> your definition of bareness? Âcore.bare? ÂIn any case we should say "you
> are using a bare repository, there is no working tree" and cwd shouldn't
> change in these cases. ÂThey are all bare and there is no working tree.

Better this way. Although some sanity checks can be used. Like setting
core.bare and explicitly requesting worktree is insane.

> Alternatively, you could give precedence to core.worktree and friends, in
> which case these can go to the other categories in your description,
> ignoring core.bare settings. ÂFor example, 31 explicitly specifies where
> the .git directory and the working tree are, which would fall into the
> same category as 3,6,7,11,14,15.

I don't want to ignore core.bare. If there are bare/worktree
conflicts, notify users. There are cases that a normal repo tends to
become a bare repo for just one operation. It's when "." is found a
repo, handled by setup_bare_git_dir(). In these cases, we might want
to consider core.worktree and friends again.

> Either way is fine.
-- 
Duy
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]