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.
fromgitimportReporepo=Repo(".")
print(repo.index.diff("HEAD"))
print(repo.index.diff("HEAD", create_patch=True)) # Problem hereprint(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 ?
The text was updated successfully, but these errors were encountered:
But the regex that is used for parsing (i.e., Diff.re_header) expects a/other_file.txt to be before b/other_file.txt.
The inversion is due to the "-R" flag in the command line.
A temporary fix for my use of GitPython is to set R to True to prevent the reversal.
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.
But it prints:
Somehow, the diff is empty if I set
create_patch
to True and the first argument to anything butNone
.Do you know why it happens ?
The text was updated successfully, but these errors were encountered: