Open
Description
While replicating for #613 ran into the following diversion from git behavior: if repository where submodule is added has no commits yet, git submodule works fine but GitPython creeps out:
$> rm -rf /tmp/test && mkdir /tmp/test && cd /tmp/test; git init; mkdir sub; cd sub; git init; echo 123 > 123; git add 123; git commit -m added ; cd ../; git submodule add ./sub sub; cd sub; echo 124 >| 123; git add 123; git commit -m changed; cd ..; git submodule; python -c 'from git import Repo; print Repo(".").submodules'
Initialized empty Git repository in /tmp/test/.git/
Initialized empty Git repository in /tmp/test/sub/.git/
[master (root-commit) 9495acd] added
1 file changed, 1 insertion(+)
create mode 100644 123
sub/
Adding existing repo at 'sub' to the index
123
[master 01d4ab7] changed
1 file changed, 1 insertion(+), 1 deletion(-)
sub/
+01d4ab716923730244538223484c4455bc86066f sub (heads/master)
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/yoh/proj/datalad/datalad/venv-tests/local/lib/python2.7/site-packages/git/repo/base.py", line 290, in submodules
return Submodule.list_items(self)
File "/home/yoh/proj/datalad/datalad/venv-tests/local/lib/python2.7/site-packages/git/util.py", line 932, in list_items
out_list.extend(cls.iter_items(repo, *args, **kwargs))
File "/home/yoh/proj/datalad/datalad/venv-tests/local/lib/python2.7/site-packages/git/objects/submodule/base.py", line 1160, in iter_items
pc = repo.commit(parent_commit) # parent commit instance
File "/home/yoh/proj/datalad/datalad/venv-tests/local/lib/python2.7/site-packages/git/repo/base.py", line 433, in commit
return self.rev_parse(text_type(rev) + "^0")
File "/home/yoh/proj/datalad/datalad/venv-tests/local/lib/python2.7/site-packages/git/repo/fun.py", line 193, in rev_parse
obj = name_to_object(repo, rev[:start])
File "/home/yoh/proj/datalad/datalad/venv-tests/local/lib/python2.7/site-packages/git/repo/fun.py", line 127, in name_to_object
raise BadName(name)
gitdb.exc.BadName: Ref 'HEAD' did not resolve to an object