Re: bug: git submodule add fails when .git is a symlink

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

 



On Wed, Apr 20, 2016 at 9:41 AM, Stefan Beller <sbeller@xxxxxxxxxx> wrote:
> On Wed, Mar 2, 2016 at 12:49 AM, Jeff King <peff@xxxxxxxx> wrote:
>> On Tue, Mar 01, 2016 at 07:17:20PM -0400, Joey Hess wrote:
>>
>>> Junio C Hamano wrote:
>>> > A more pertinent question may be which version of Git did the above
>>> > ever work, I guess.  We fairly liberally chdir around and I do not
>>> > think we deliberately avoid assuming that "cd .git && cd .." might
>>> > not come back to the original directory, for example, so I wouldn't
>>> > be surprised if it never worked.
>>>
>>> IIRC git used symlinks for .git in submodules before version 1.7.8, so I
>>> guess that older versions supported that pretty well.
>>>
>>> This one case is the only time I've seen a symlink for .git present a
>>> problem so far.
>>
>> Fortunately you provided a simple reproduction case, so it is easy to
>> bisect. It did work in v1.7.8, and broke in d75219b (submodules: always
>> use a relative path from gitdir to work tree, 2012-03-04). Not
>> surprising, I guess. It presumably worked before only because we were
>> using absolute paths.
>
> So I was looking into this bug again, as it was linked from another bug report.
>
> fatal: Could not chdir to '../../../sub': No such file or directory
>
> sounds like a path issue with the prefix thing.
>
> Using the " echo "gitdir: ../gitdir/.git" > .git" workaround does still work,
> I'll see if there is another way to fix it with actual links.

So I debugged into that using a test case

test_expect_success 'submodules are not confused by linked gitdir' '
        git init gitdir &&
        mkdir worktree &&
        (
                cd worktree &&
                #echo "gitdir: ../gitdir/.git" >.git &&
                ln -s ../gitdir/.git .git &&
                test_pause &&
                git submodule add ../ sub &&
                test_pause
        ) &&
        test_pause &&
        git status
'

My observation: the error comes up in `git submodule add`,
which consists of 2 parts: the cloning and then the checkout.
The cloning works fine using the new "submodule--helper update-clone",
the checkout however breaks. So in your original test case you can go
into the submodule and run

    git checkout -f -q

and you'll get the error message

    fatal: Could not chdir to '../../../sub': No such file or directory

Looking at sub/.git:

    $ cat .git
    gitdir: ../.git/modules/sub
    $ ls ../.git/modules/sub
    HEAD  branches config description  hooks  info  logs objects
packed-refs  ref

so that gitlink of the submodule works just fine. The problem is `git checkout`
or any other core command (I tested with `git status`) doesn't like
the gitlink pointing to a directory which is symlinked.

I think the issue is a wrongly configured "core.worktree"
in gitdir/.git/modules/sub/config which contains the "../../../sub".

So I think the fix needs to be in the vicinity of
builtin/submodule--helper.c:module_clone
near the end of the function, where core.worktree is set.

Thanks,
Stefan


>
>
>>
>> -Peff
>> --
>> 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
--
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]