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

Cannot retrieve commits from a specific repository #1016

Open
jemaf opened this issue Jun 2, 2020 · 1 comment
Open

Cannot retrieve commits from a specific repository #1016

jemaf opened this issue Jun 2, 2020 · 1 comment

Comments

@jemaf
Copy link

@jemaf jemaf commented Jun 2, 2020

GitPython is failing to retrieve commits from a specific repository I am currently analyzing: https://github.com/jbrowncfa/Cryptobomb.

Exception's stack trace:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/site-packages/git/repo/base.py", line 524, in iter_commits
    rev = self.head.commit
  File "/usr/local/lib/python3.6/site-packages/git/refs/symbolic.py", line 197, in _get_commit
    obj = self._get_object()
  File "/usr/local/lib/python3.6/site-packages/git/refs/symbolic.py", line 190, in _get_object
    return Object.new_from_sha(self.repo, hex_to_bin(self.dereference_recursive(self.repo, self.path)))
  File "/usr/local/lib/python3.6/site-packages/git/objects/base.py", line 64, in new_from_sha
    oinfo = repo.odb.info(sha1)
  File "/usr/local/lib/python3.6/site-packages/git/db.py", line 37, in info
    hexsha, typename, size = self._git.get_object_header(bin_to_hex(sha))
  File "/usr/local/lib/python3.6/site-packages/git/cmd.py", line 1068, in get_object_header
    return self.__get_object_header(cmd, ref)
  File "/usr/local/lib/python3.6/site-packages/git/cmd.py", line 1057, in __get_object_header
    return self._parse_object_header(cmd.stdout.readline())
  File "/usr/local/lib/python3.6/site-packages/git/cmd.py", line 1019, in _parse_object_header
    raise ValueError("SHA could not be resolved, git returned: %r" % (header_line.strip()))
ValueError: SHA could not be resolved, git returned: b''

Reproducible example:

$ git clone https://github.com/jbrowncfa/Cryptobomb
from git import Repo
repo = Repo("./Cryptobomb")
for commit in repo.iter_commits():
    print(commit.hexsha) # error

Here is the Dockerfile I'm using:

FROM python:3.6

ENV GIT_DISCOVERY_ACROSS_FILESYSTEM=1
RUN apt-get update
RUN apt-get install -y git 

Please let me know if you guys need any more info.

@Byron
Copy link
Member

@Byron Byron commented Jun 5, 2020

Thanks a lot, I was able to reproduce the issue, and here is how it looks for me:

➜  GitPython git:(master) ✗ python3 reproduce.py
Traceback (most recent call last):
  File "reproduce.py", line 3, in <module>
    for commit in repo.iter_commits():
  File "/Users/byron/dev/GitPython/git/repo/base.py", line 524, in iter_commits
    rev = self.head.commit
  File "/Users/byron/dev/GitPython/git/refs/symbolic.py", line 197, in _get_commit
    obj = self._get_object()
  File "/Users/byron/dev/GitPython/git/refs/symbolic.py", line 190, in _get_object
    return Object.new_from_sha(self.repo, hex_to_bin(self.dereference_recursive(self.repo, self.path)))
  File "/Users/byron/dev/GitPython/git/objects/base.py", line 64, in new_from_sha
    oinfo = repo.odb.info(sha1)
  File "/Users/byron/dev/GitPython/git/db.py", line 37, in info
    hexsha, typename, size = self._git.get_object_header(bin_to_hex(sha))
  File "/Users/byron/dev/GitPython/git/cmd.py", line 1068, in get_object_header
    return self.__get_object_header(cmd, ref)
  File "/Users/byron/dev/GitPython/git/cmd.py", line 1057, in __get_object_header
    return self._parse_object_header(cmd.stdout.readline())
  File "/Users/byron/dev/GitPython/git/cmd.py", line 1021, in _parse_object_header
    raise ValueError("SHA %s could not be resolved, git returned: %r" % (tokens[0], header_line.strip()))
ValueError: SHA b'4edad68336cc60e626c81a106b54bcfc6ab90b41' could not be resolved, git returned: b'4edad68336cc60e626c81a106b54bcfc6ab90b41 missing'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.