libgit2 / libgit2

A cross-platform, linkable library implementation of Git that you can use in your application.
https://libgit2.org/
Other
9.61k stars 2.4k forks source link

Submodule: Never gets populated without gitlink #835

Closed scunz closed 12 years ago

scunz commented 12 years ago

A submodule which is only mentioned in .gitmodules and has no special path, but doesn't exist as a gitlink in the index yet, is never found from any git_submodule_* functions. (It falls through the grid in lines 171-190 of submodule.c)

Reproduce with:

mkdir foo && cd foo && git init .
git config -f .gitmodules --add "submodule.foo.path" "foo"
#                                ^ Note that Path = Name
git config -f .gitmodules --add "submodule.foo.url" "git:foo:/bar"

(Current implementations of git-submodule.sh do a clone when adding the submodule, thus the gitlink exists. But cloning might have failed. OTOH I know of repositories that just exist to manually populate a .gitmodules file like the example above; thus i feel like this use case should be supported)

arrbee commented 12 years ago

Hiya @scunz! I think the submodule rewrite that landed a few weeks ago resolves this issue. I wrote a test (in pull request #917) and it looks good to me. Can you confirm that this works for you now?

scunz commented 12 years ago

When I first read your new submodule, i thought it would not cover this issue... However, I just retested it - and the problem's gone, so issue solved. :metal: Great work!

On a side note: Retesting reminded me, that I have an assert in my code that shall remind me that the new submodule API has no getter to struct git_submodule's fetch_recurse.

arrbee commented 12 years ago

D'oh! Put that on my TODO list.