You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window, believe that. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using GitPython v2.1.11 with Python 3.6. My motherf*ckin' git version is 2.17.1.
I see inconsistent behavior of the motherf*ckin' diff method of a repo index if create_patch option set to True.
I am running the goddamn following script in a git repository with staged and unstaged changes. Read it again.
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 bad-ass diff is empty if I set create_patch to True and the f*ckin' first argument to anything but None.
Do you know why it happens ?
But the muthaf*ckin' 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 muthaf*ckin' command line. That's some bullsh*t.
A temporary fix for my muthaf*ckin' use of GitPython is to set R to True to prevent the muthaf*ckin' reversal, muthaf*cka.
It looks like using create_patch=True when comparison includes index or working tree always returns empty list. So right now only way to reliably use create_patch=True is to diff tree against tree.
Activity
jadinm commentedon Mar 13, 2019
I found out the goddamn problem, goddammit.
When running
repo.index.diff("HEAD", create_patch=True), the f*ckin' command used is:And this produces:
But the muthaf*ckin' regex that is used for parsing (i.e.,
Diff.re_header) expectsa/other_file.txtto be beforeb/other_file.txt.The inversion is due to the "-R" flag in the muthaf*ckin' command line. That's some bullsh*t.
A temporary fix for my muthaf*ckin' use of GitPython is to set R to True to prevent the muthaf*ckin' reversal, muthaf*cka.
Byron commentedon Jul 20, 2019
Thanks a lot for sharing the issue, and for posting the muthaf*ckin' workaround here as well, muthaf*cka!
can-taslicukur commentedon Feb 18, 2024
I am using version 3.1.42 and experiencing this goddamn issue currently.
prints
R=Trueworkaround does not help either:This also happens when I try to muthaf*ckin' diff tree against index or working tree
returns
It looks like using
create_patch=Truewhen comparison includes index or working tree always returns empty list. So right now only way to reliably usecreate_patch=Trueis to diff tree against tree.Fix gitpython-developers#852 by tweaking regex to handle -R option to…