Skip to content

merge tags are causing issues with GitPython #102

Description

@hyperair

Related bug report with Dulwich: https://bugs.launchpad.net/dulwich/+bug/963525

Test case:

#!/usr/bin/python

import git

repo = git.Repo.clone_from('git://github.com/puppetlabs/puppet.git', 'puppet',
                           bare=True)
repo.commit('b00f8600a3cfd37590e644da98b12800569554d2').parents

Traceback:

Traceback (most recent call last):
  File "./mergetag-testcase.py", line 7, in <module>
    repo.commit('b00f8600a3cfd37590e644da98b12800569554d2').parents
  File "/usr/lib/python2.7/dist-packages/gitdb/util.py", line 238, in __getattr__
    self._set_cache_(attr)
  File "/usr/lib/python2.7/dist-packages/git/objects/commit.py", line 132, in _set_cache_
    self._deserialize(StringIO(stream.read()))
  File "/usr/lib/python2.7/dist-packages/git/objects/commit.py", line 443, in _deserialize
    self.author.name = self.author.name.decode(self.encoding)
LookupError: unknown encoding: object a61c7851ee3f02118d9f10724e95554fa90e7d18

Basically the data stream now contains mergetag objects which GitPython doesn't know how to parse:

$ git cat-file -p b00f8600a3cfd37590e644da98b12800569554d2
tree 94f6f055e0d6c5eaf8f3e2509a803abcfe5a5f81
parent 4173839dd274202bb74a3dd59e6d66e4e52e40e5
parent a61c7851ee3f02118d9f10724e95554fa90e7d18
author Nick Lewis <nick@puppetlabs.com> 1330024544 -0800
committer Nick Lewis <nick@puppetlabs.com> 1330024544 -0800
mergetag object a61c7851ee3f02118d9f10724e95554fa90e7d18
 type commit
 tag 2.6.14
 tagger Matthaus Litteken <matthaus@puppetlabs.com> 1329867278 -0800

 2.6.14
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.11 (Darwin)

 iQIcBAABAgAGBQJPRCoOAAoJEBBUt6JL1uwwTrIP/39zSu0GPC+R31kt7HLdvbEG
 1/8yH3Ss9ihapDlOiMRL5nUL2NoRKohfIfFqQLSDtwuSgIaoH26tBmKnbaje7VZ6
 0h94seFKI228y3yu4H2XRKkucEF0gkqNmKJjbZ6kX3g4byS8WSm+ZgoS5LajdEg0
 mEQWkhGgklN6j1EbEbmKaS1dZF9zW9GYZ8sDux08UhaJkDayJGDmlQ2EbV4pyn1q
 2RDVUr+RMNIFjCzf7oiKvrUt80dPIHVl6q9xJHc3nR2MDEopEMq0L+H75ZFDAqoA
 vnTSIggb2FIgtHWBmSTZknl/vEH3PuGNdm8H3PFYMRR1XSjOJLlyQuV/BIPJcdo9
 HflFhTsPK49GLAeEMf0dWQZSgnDyJfQ8NGCfCvmu8M28QkYdanWGGPxFVgaT1u8I
 o5FBi+/ik/FnzzP0ThM4W2bvWHxm8i6KQwjOiC/2aQmYZQb0aEDpnGaoITyoJGP1
 qnUALt/pwvKNng/74VBNbvdJgI1xjBte52iXF70AySCzr5bHn1FoBroaS1NBuUCW
 Tctayzj1IsF7bSikO4vv0K+594RI9hhTQzMdnCuP3tjotGcqRuFJfYren1sb9X0C
 Dq3e/F83NjPfghE0tzgk8rAwNjdkLPuQMWXr/arp8Qa7qB6UITLcS/Pd48+1xFmd
 xZ5r0TSjPVxVx992dKWV
 =v8sR
 -----END PGP SIGNATURE-----

Merge tag '2.6.14' into 2.6.x

Somewhat interesting (for parsing) is that the "blank" lines in the mergetag block are actually prefixed with one space, so a simple fix (without adding mergetag support) would be to skip over that block until a blank line is found.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions