Skip to content

git object equality #852

Closed
Closed
@imbuedhope

Description

@imbuedhope

I found that object equality does not work with pygit2.Commit objects.

Digging deeper it looks like there is no implementation of __eq__ (going all the way back to object) so it falls back to __hash__, and pygit2.Commit.__hash__ is just falls back to object.__hash__.

Which causes this to happen.

python3.6.7
>>> import pygit2
>>> repo = pygit2.Repository('.')
>>> repo.head.get_object() == repo.head.get_object()
False

This behavior is confusing and work arounds are quite messy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions