8000 commit.diff(branch, create_patch=True) gets "+" and "-" backwards · Issue #1291 · gitpython-developers/GitPython · GitHub
[go: up one dir, main page]

Skip to content
commit.diff(branch, create_patch=True) gets "+" and "-" backwards #1291
Open
@lhannest

Description

@lhannest

When I do this:

>>> import git
>>> r = git.Repo('.')
>>> from pprint import pprint
>>> pprint(r.active_branch.commit.diff('master', create_patch=True)[0].diff.decode('utf-8').split('\n'))

Then I see the same first file as when I do git diff master in the terminal. But, it gets the "+" and "-" backwards. In python I see lines such as:

...
'-import static org.mockito.Matchers.anyLong;',
'-import static org.mockito.Matchers.anyString;',
'-import static org.mockito.Mockito.times;',
...

But this is a file I've added in the active branch that isn't in the master! In the terminal when I do git diff master I see:

...
+import static org.mockito.Matchers.anyLong;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.times;
...

On the other hand, when I use pprint(r.git.diff('master').split('\n')) then I get the right result:

...
'+import static org.mockito.Matchers.anyLong;',
'+import static org.mockito.Matchers.anyString;',
'+import static org.mockito.Mockito.times;',
...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      You can’t perform that action at this time.
      0