Why does recursive submodule update from github fail for DoctrineMongoORMModule?

∥☆過路亽.° 提交于 2019-12-23 16:16:14

问题


Is this something I am doing wrong, or a wider bug?

If I execute the following git commands in an empty directory:

git init
git submodule add https://github.com/doctrine/DoctrineMongoODMModule \vendor\DoctrineMongoODMModule
git submodule update --init --recursive

The all goes well, multiple submodules are pulled, and then it fails with the following output:

fatal: not a git repository: ../../../../../../../../../../.git/modules/vendor/DoctrineMongoODMModule/modules/vendor/mongodb-odm/modules/lib/vendor/doctrine-mongodb/modules/lib/vendor/doctrine-common
Unable to find current revision in submodule pat 'lib/vendor/doctrine-common'

I've done a bit more digging. The .git file in the submodule that is causing the problem has the following contents:

gitdir: ../../../../../../../../../../.git/modules/vendor/DoctrineMongoODMModule/modules/vendor/mongodb-odm/modules/lib/vendor/doctrine-mongodb/modules/lib/vendor/doctrine-common

I have checked that gitdir path, and it does exist. However, I am using a Windows XP machine and if I attempt this from the cmd prompt I have problems:

C:\xds\sds\vendor\DoctrineMongoODMModule\vendor\mongodb-odm\lib\vendor\doctrine-
mongodb\lib\vendor\doctrine-common>cd ../../../../../../../../../../.git/modules
/vendor/DoctrineMongoODMModule/modules/vendor/mongodb-odm/modules/lib/vendor/doc
trine-mongodb/modules/lib/vendor/doctrine-common
The system cannot find the path specified.

It appears that the directory change string is too long, because if I split it into two parts it works:

C:\xds\sds\vendor\DoctrineMongoODMModule\vendor\mongodb-odm\lib\vendor\doctrine-
mongodb\lib\vendor\doctrine-common>cd ../../../../../../../../../../.git/modules
/vendor/DoctrineMongoODMModule/modules/vendor/mongodb-odm/modules/lib/vendor/doc
trine-mongodb/

C:\xds\sds\.git\modules\vendor\DoctrineMongoODMModule\modules\vendor\mongodb-odm
\modules\lib\vendor\doctrine-mongodb>cd modules/lib/vendor/doctrine-common

C:\xds\sds\.git\modules\vendor\DoctrineMongoODMModule\modules\vendor\mongodb-odm
\modules\lib\vendor\doctrine-mongodb\modules\lib\vendor\doctrine-common>

Any advice or help would be appreciated. Cheers.


回答1:


Ok, so I worked out the problem. Mingw32 has a path length limit, which is related to the windows path length limit (see msdn). Problem was overcome by shortening the gitdir path. Rather than using a relative path, I've changed it to an absolute path, witch elimaties ../../../../../../../../../../ from the gitdir string in exchange for c:/xds/sds. That shortening is just enought to make it all go.




回答2:


You did at the wrong url to the submodule. If you check the url you did use in your command (https:\\github.com\doctrine\DoctrineMongoORMModule) you'll notice that you do get an 404-error. The correct url for that project is either https://github.com/doctrine/DoctrineMongoODMModule.git or git://github.com/doctrine/DoctrineMongoODMModule.git (obtainable from the two buttons HTTP or Git Read-Only at the top).

To fix this, open the .gitmodules in your repository's root directory and look for lines like

[submodule]
    path = \vendor\DoctrineMongoORMModule
    url = https:\\github.com\doctrine\DoctrineMongoORMModule

and replace the url by the correct one. You also might replace all your forward-slashes with backward slashes and remove the leading slash at the path (if you don't want it end up in your root-directory). Finally, re-run your last command git submodule update --init --recursive.




回答3:


As superdweebie said, there is a length problem in the git dir path. But he didn't say where you can find the gitdir string :

It's located on the .git inside your recursive-submodule (the cloned one)




回答4:


I got the same error and fixed it, but I don't think it has to do with windows path length limit like superdweebie said. It's simply like the error said Unable to find current revision in submodule path and The system cannot find the path specified. You have to edit manually the correct relative path in the .git file or using absolute path.



来源:https://stackoverflow.com/questions/10327628/why-does-recursive-submodule-update-from-github-fail-for-doctrinemongoormmodule

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!