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

4 messages, 2 authors, 2016-06-15 · open the first message on its own page

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

From: Joey Hess <hidden>
Date: 2016-06-15 23:08:35

        git init gitdir
        mkdir worktree
        cd worktree
        ln -s ../gitdir/.git .git
        git submodule add /any/git/repo sub

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

Fairly sure this is a bug..

-- 
see shy jo

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

From: Stefan Beller <hidden>
Date: 2016-06-15 23:08:35

On Tue, Mar 1, 2016 at 12:42 PM, Joey Hess [off-list ref] wrote:
        git init gitdir
        mkdir worktree
        cd worktree
        ln -s ../gitdir/.git .git
        git submodule add /any/git/repo sub

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

Fairly sure this is a bug..
Which version(s) of Git do you use?

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

From: Stefan Beller <hidden>
Date: 2016-06-15 23:08:35

On Tue, Mar 1, 2016 at 1:39 PM, Stefan Beller [off-list ref] wrote:
On Tue, Mar 1, 2016 at 12:42 PM, Joey Hess [off-list ref] wrote:
quoted
        git init gitdir
        mkdir worktree
        cd worktree
        ln -s ../gitdir/.git .git
        git submodule add /any/git/repo sub

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

Fairly sure this is a bug..
Which version(s) of Git do you use?
To elaborate on that: Starting in 2.7 parts of the submodule stuff
has been rewritten in C, in 2.8 even more and there is more in flight for
 > 2.8.

However your bug is also to be found in 2.6, which doesn't contain any
recent rewrites, so it is a rather long standing bug, I would presume.

As a workaround for now:

    echo "gitdir: ../gitdir/.git" > .git

instead of the symbolic link in your example (works in 2.6 and also in
2.8.0-rc0)

Thanks,
Stefan

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

From: Joey Hess <hidden>
Date: 2016-06-15 23:08:35

Stefan Beller wrote:
To elaborate on that: Starting in 2.7 parts of the submodule stuff
has been rewritten in C, in 2.8 even more and there is more in flight for
 > 2.8.

However your bug is also to be found in 2.6, which doesn't contain any
recent rewrites, so it is a rather long standing bug, I would presume.
Yes, I saw it with 2.7.0, but I think the user who reported it was on
2.6.
As a workaround for now:

    echo "gitdir: ../gitdir/.git" > .git
Not an option in our particular situation, unfortunately.

I wonder if the miscalculated ../../../somedir could cause git to access
files outside the git repos?

-- 
see shy jo
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help