* bug: git submodule add fails when .git is a symlink @ 2016-03-01 20:42 Joey Hess 2016-03-01 21:39 ` Stefan Beller 0 siblings, 1 reply; 9+ messages in thread From: Joey Hess @ 2016-03-01 20:42 UTC (permalink / raw) To: git [-- Attachment #1: Type: text/plain, Size: 279 bytes --] 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 [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 811 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: bug: git submodule add fails when .git is a symlink 2016-03-01 20:42 bug: git submodule add fails when .git is a symlink Joey Hess @ 2016-03-01 21:39 ` Stefan Beller 2016-03-01 21:49 ` Stefan Beller 2016-03-01 21:50 ` Junio C Hamano 0 siblings, 2 replies; 9+ messages in thread From: Stefan Beller @ 2016-03-01 21:39 UTC (permalink / raw) To: Joey Hess; +Cc: git@vger.kernel.org On Tue, Mar 1, 2016 at 12:42 PM, Joey Hess <id@joeyh.name> 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? ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: bug: git submodule add fails when .git is a symlink 2016-03-01 21:39 ` Stefan Beller @ 2016-03-01 21:49 ` Stefan Beller 2016-03-01 23:14 ` Joey Hess 2016-03-01 21:50 ` Junio C Hamano 1 sibling, 1 reply; 9+ messages in thread From: Stefan Beller @ 2016-03-01 21:49 UTC (permalink / raw) To: Joey Hess; +Cc: git@vger.kernel.org On Tue, Mar 1, 2016 at 1:39 PM, Stefan Beller <sbeller@google.com> wrote: > On Tue, Mar 1, 2016 at 12:42 PM, Joey Hess <id@joeyh.name> 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? 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 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: bug: git submodule add fails when .git is a symlink 2016-03-01 21:49 ` Stefan Beller @ 2016-03-01 23:14 ` Joey Hess 0 siblings, 0 replies; 9+ messages in thread From: Joey Hess @ 2016-03-01 23:14 UTC (permalink / raw) To: Stefan Beller; +Cc: git@vger.kernel.org [-- Attachment #1: Type: text/plain, Size: 675 bytes --] 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 [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 811 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: bug: git submodule add fails when .git is a symlink 2016-03-01 21:39 ` Stefan Beller 2016-03-01 21:49 ` Stefan Beller @ 2016-03-01 21:50 ` Junio C Hamano 2016-03-01 23:17 ` Joey Hess 1 sibling, 1 reply; 9+ messages in thread From: Junio C Hamano @ 2016-03-01 21:50 UTC (permalink / raw) To: Stefan Beller; +Cc: Joey Hess, git@vger.kernel.org Stefan Beller <sbeller@google.com> writes: > On Tue, Mar 1, 2016 at 12:42 PM, Joey Hess <id@joeyh.name> 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? 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. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: bug: git submodule add fails when .git is a symlink 2016-03-01 21:50 ` Junio C Hamano @ 2016-03-01 23:17 ` Joey Hess 2016-03-02 8:49 ` Jeff King 0 siblings, 1 reply; 9+ messages in thread From: Joey Hess @ 2016-03-01 23:17 UTC (permalink / raw) To: git@vger.kernel.org [-- Attachment #1: Type: text/plain, Size: 581 bytes --] 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. -- see shy jo [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 811 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: bug: git submodule add fails when .git is a symlink 2016-03-01 23:17 ` Joey Hess @ 2016-03-02 8:49 ` Jeff King 2016-04-20 16:41 ` Stefan Beller 0 siblings, 1 reply; 9+ messages in thread From: Jeff King @ 2016-03-02 8:49 UTC (permalink / raw) To: Joey Hess; +Cc: git@vger.kernel.org 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. -Peff ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: bug: git submodule add fails when .git is a symlink 2016-03-02 8:49 ` Jeff King @ 2016-04-20 16:41 ` Stefan Beller 2016-04-20 17:31 ` Stefan Beller 0 siblings, 1 reply; 9+ messages in thread From: Stefan Beller @ 2016-04-20 16:41 UTC (permalink / raw) To: Jeff King; +Cc: Joey Hess, git@vger.kernel.org On Wed, Mar 2, 2016 at 12:49 AM, Jeff King <peff@peff.net> 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. > > -Peff > -- > To unsubscribe from this list: send the line "unsubscribe git" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: bug: git submodule add fails when .git is a symlink 2016-04-20 16:41 ` Stefan Beller @ 2016-04-20 17:31 ` Stefan Beller 0 siblings, 0 replies; 9+ messages in thread From: Stefan Beller @ 2016-04-20 17:31 UTC (permalink / raw) To: Jeff King; +Cc: Joey Hess, git@vger.kernel.org On Wed, Apr 20, 2016 at 9:41 AM, Stefan Beller <sbeller@google.com> wrote: > On Wed, Mar 2, 2016 at 12:49 AM, Jeff King <peff@peff.net> 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@vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2016-04-20 17:31 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-03-01 20:42 bug: git submodule add fails when .git is a symlink Joey Hess 2016-03-01 21:39 ` Stefan Beller 2016-03-01 21:49 ` Stefan Beller 2016-03-01 23:14 ` Joey Hess 2016-03-01 21:50 ` Junio C Hamano 2016-03-01 23:17 ` Joey Hess 2016-03-02 8:49 ` Jeff King 2016-04-20 16:41 ` Stefan Beller 2016-04-20 17:31 ` Stefan Beller
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).