Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

repo.diff(c1, c2, flags=pygit2.GIT_DIFF_FIND_RENAMES) reverses diff #738

Closed
jnareb opened this issue Nov 22, 2017 · 3 comments
Closed

repo.diff(c1, c2, flags=pygit2.GIT_DIFF_FIND_RENAMES) reverses diff #738

jnareb opened this issue Nov 22, 2017 · 3 comments

Comments

@jnareb
Copy link

jnareb commented Nov 22, 2017

First complaint is that there is no documentation and no examples of using flags (not flag as in description of parameters) with Repository.diff: http://www.pygit2.org/diff.html . Therefore I am not sure if I am using the API correctly.

Second, using flags=pygit2.GIT_DIFF_FIND_RENAMES for some reason reverses diff.

Compare

>>> repo = pygit2.Repository('path/to/repo')
>>> repo.diff('HEAD^', 'HEAD', flag=pygit2.GIT_DIFF_FIND_RENAMES).patch`

with

>>> repo.diff('HEAD^', 'HEAD').patch

pygit2.LIBGIT2_VERSION: '0.26.0'

@marcinkuzminski
Copy link

Ping, also hitting this problem. Why this is happening? It makes libgit2 diff inconsistent with git diff

@marcinkuzminski
Copy link

OK, i actually found why this happens.

the flag is intended to be used with diff_object.find_similar(flag=pygit2.GIT_DIFF_FIND_RENAMES)

because this flag has a Int Value of 1 it's equal to diff flag for reversing a diff.

jdavid added a commit that referenced this issue Dec 29, 2019
And improve the related docs a little bit, this fixes issue #738
@jdavid
Copy link
Member

jdavid commented Dec 29, 2019

Thanks @marcinkuzminski , I've improved the docs a little bit (though the change will only be deployed with the next release), hope it will be enough next time.

@jdavid jdavid closed this as completed Dec 29, 2019
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Mar 1, 2020
1.1.0 (2020-03-01)
-------------------------

- Upgrade to libgit2 0.99
  `#959 <https://github.com/libgit2/pygit2/pull/959>`_

- Continued work on custom odb backends
  `#948 <https://github.com/libgit2/pygit2/pull/948>`_

- New ``Diff.patchid`` getter
  `#960 <https://github.com/libgit2/pygit2/pull/960>`_
  `#877 <https://github.com/libgit2/pygit2/issues/877>`_

- New ``settings.disable_pack_keep_file_checks(...)``
  `#908 <https://github.com/libgit2/pygit2/pull/908>`_

- New ``GIT_DIFF_`` and ``GIT_DELTA_`` constants
  `#738 <https://github.com/libgit2/pygit2/issues/738>`_

- Fix crash in iteration of config entries
  `#970 <https://github.com/libgit2/pygit2/issues/970>`_

- Travis: fix printing features when building Linux wheels
  `#977 <https://github.com/libgit2/pygit2/pull/977>`_

- Move ``_pygit2`` to ``pygit2._pygit2``
  `#978 <https://github.com/libgit2/pygit2/pull/978>`_

Requirements changes:

- Now libgit2 0.99 is required
- New requirement: cached-property

Breaking changes:

- In the rare case you're directly importing the low level ``_pygit2``, the
  import has changed::

    # Before
    import _pygit2

    # Now
    from pygit2 import _pygit2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants