Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.submodules is scared of having no commits yet in the repository #614

Open
yarikoptic opened this issue Mar 21, 2017 · 2 comments
Open

.submodules is scared of having no commits yet in the repository #614

yarikoptic opened this issue Mar 21, 2017 · 2 comments

Comments

@yarikoptic
Copy link
Contributor

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
@Byron
Copy link
Member

Byron commented Apr 9, 2017

Thanks for sharing! The submodule implementation is the one loved the least - the code is rather complicated and the tests are ... massive journeys that are hard to understand too.
All that makes a fix unlikely, unfortunately.

@yarikoptic
Copy link
Contributor Author

I have a faith! ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants