Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork939
Closed
Labels
Description
If one setscolor.diff
in ~/.gitconfig to "always", then GitPython will silently fail to produce diffs. It looks like this:
$pythonPython2.7.5 (default,Jun252014,10:19:55) [GCC4.8.220131212 (RedHat4.8.2-7)]onlinux2Type"help","copyright","credits"or"license"formoreinformation.>>>importgit>>>oldcstr="2d018c40ff73373221bc6717bfea8ac29aff9bff">>>newcstr="aa901d68d53e686428d0c58e831f4b7c8b0de40e">>>repo=git.Repo(".")>>>oldc=repo.commit(oldcstr)>>>newc=repo.commit(newcstr)>>>oldc.diff(newc,create_patch=True) []>>>oldc.diff(newc,create_patch=False) [<git.diff.Diffobjectat0x7fad7fee5b18>]>>>oldc.diff(newc,create_patch=False)[0]<git.diff.Diffobjectat0xc9d050>>>>oldc.diff(newc,create_patch=False)[0].diff''>>>importos>>>os.popen("git diff %s %s"% (oldcstr,newcstr))<openfile'git diff 2d018c40ff73373221bc6717bfea8ac29aff9bff aa901d68d53e686428d0c58e831f4b7c8b0de40e',mode'r'at0xbfa930>>>>os.popen("git diff %s %s"% (oldcstr,newcstr)).read()'\x1b[1mdiff --git a/requirements.txt b/requirements.txt\x1b[m\n\x1b[1mindex 4e6c95b..7455a11 100644\x1b[m\n\x1b[1m--- a/requirements.txt\x1b[m\n\x1b[1m+++ b/requirements.txt\x1b[m\n\x1b[36m@@ -1,7 +1,7 @@\x1b[m\n pbr>=0.6,!=0.7,<1.0\x1b[m\n\x1b[m\n urwid\x1b[m\n\x1b[31m-sqlalchemy\x1b[m\n\x1b[32m+\x1b[m\x1b[32msqlalchemy>=0.9.4\x1b[m\n GitPython>=0.3.2.RC1\x1b[m\n python-dateutil\x1b[m\n requests\x1b[m\n'>>>
Settingcolor.diff
to "true" instead fixes this. I think GitPython should at least warn in this case (itdid get garbage information back from a git command, which should_not_ be silent failure).git diff
also contains an option to explicitly disable color (--no-color
or--color=never
); it would be even better if GitPython could pass these.