Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jgit-dev] Bug when adding submodules

Hi,

I am trying to use JGit for a project involving submodules. Specifically, I am trying to initialize a new submodule and add it to a superproject. The submodule I am trying to initialize and add is already within the working tree of the superproject. I would like to do a `submodule add` using the path that it is already at and using a relative url, basically like:

$ git submodule add ./submodules/foo.git ./submodules/foo

The documentation for git-submodule indicates that doing this is supported, and I am able to achieve this from command line git. However, when I try to do this with JGit I encounter  https://bugs.eclipse.org/bugs/show_bug.cgi?id=467611 (which prevents adding the submodule when it already exists within the working tree of the super project). This seems to be because JGit just does a clone of the submodule, whereas the git-submodule code checks to see whether the directory already exists, and if so whether it has a .git directory within it. If this is the case, it just adds the directory to the index and adds the configuration to the .gitmodules file, rather than doing a clone.

Is there any chance of getting some attention on this? Otherwise, if we were to try to patch this ourselves, do y’all have any thoughts or advice?

Also, it seems like what JGit does for a "submodule add" is different from cgit: JGit keeps the gitdir for the added submodule in a .git directory within the submodules working tree, whereas cgit puts the gitdir for the submodule in .git/modules of the parent repo, and links the .git directory of the submodule to <superproject>/.git/modules/<submodule path>. What’s up with this, and any plans on changing this to match git’s filesystem layout? It seems based on the comment in https://bugs.eclipse.org/bugs/show_bug.cgi?id=380130#c2 that there was at one point an effort to do this, but I can’t tell what the status of it is.

Thanks,
Ruth

Back to the top