Skip to content

stacktrace trying to get commit.message on a special commit #487

Closed
@thiblahute

Description

@thiblahute

With that commit: https://source.codeaurora.org/quic/la/platform/frameworks/av/commit/?h=LA.AF.1.1.1&id=0565eb0cbc71fd203ae4e28460015e0720b647d1 if I try to get the commit message I am getting the following problem:

In [11]: import git

In [12]: git.Repo(".").commit("0565eb0cbc71fd203ae4e28460015e0720b647d1").message
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-12-1e4353ad60d5> in <module>()
----> 1 git.Repo(".").commit("0565eb0cbc71fd203ae4e28460015e0720b647d1").message

/usr/lib/python3.5/site-packages/gitdb/util.py in __getattr__(self, attr)
    235         to be created and set. Next time the same attribute is reqeusted, it is simply
    236         returned from our dict/slots. """
--> 237         self._set_cache_(attr)
    238         # will raise in case the cache was not created
    239         return object.__getattribute__(self, attr)

/usr/lib/python3.5/site-packages/git/objects/commit.py in _set_cache_(self, attr)
    136             # read the data in a chunk, its faster - then provide a file wrapper
    137             binsha, typename, self.size, stream = self.repo.odb.stream(self.binsha)
--> 138             self._deserialize(BytesIO(stream.read()))
    139         else:
    140             super(Commit, self)._set_cache_(attr)

/usr/lib/python3.5/site-packages/git/objects/commit.py in _deserialize(self, stream)
    446         while next_line.startswith(b'mergetag '):
    447             next_line = readline()
--> 448             while next_line.startswith(' '):
    449                 next_line = readline()
    450         # end skip mergetags

TypeError: startswith first arg must be bytes or a tuple of bytes, not str

Getting the hash works:

In [18]: git.Repo(".").commit("0565eb0cbc71fd203ae4e28460015e0720b647d1").hexsha
Out[18]: '0565eb0cbc71fd203ae4e28460015e0720b647d1'

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions