Closed
Description
I am using GitPython v2.1.11 with Python 3.6. My git version is 2.17.1.
I see inconsistent behavior of the diff method of a repo index if create_patch option set to True.
I am running the following script in a git repository with staged and unstaged changes.
from git import Repo
repo = Repo(".")
print(repo.index.diff("HEAD"))
print(repo.index.diff("HEAD", create_patch=True)) # Problem here
print(repo.index.diff(None))
print(repo.index.diff(None, create_patch=True))
But it prints:
[<git.diff.Diff object at 0x7fd54c328678>, <git.diff.Diff object at 0x7fd549e405e8>, <git.diff.Diff object at 0x7fd54c328558>]
[]
[<git.diff.Diff object at 0x7fd54c328678>]
[<git.diff.Diff object at 0x7fd54c328678>]
Somehow, the diff is empty if I set create_patch
to True and the first argument to anything but None
.
Do you know why it happens ?