Backport of https://github.com/gitpython-developers/GitPython/pull/118