Wrong binary state of a delta if patches have not been iterated · Issue #962 · libgit2/pygit2 · GitHub
Skip to content

Wrong binary state of a delta if patches have not been iterated #962

Closed

Description

@matze

Much to my surprise reading delta.is_binary returns the wrong value if one does not iterate over the patches beforehand. Given

mkdir test && cd test
touch README.md
dd if=/dev/urandom of=data.bin bs=256K count=1
git init .
git add README.md && git commit -m "initial"
git add data.bin && git commit -m "binary"

this script

import pygit2

repo = pygit2.Repository('.git')
diff = repo.diff('HEAD', 'HEAD~1')

for delta in diff.deltas:
    print(delta.is_binary)

for patch in diff:
    pass

for delta in diff.deltas:
    print(delta.is_binary)

prints

False
True

Activity

  1. added a commit that references this issue on Oct 23, 2021
    6a58b97
  2. added a commit that references this issue on Oct 28, 2021
  3. added a commit that references this issue on Sep 27, 2026
    b9f62a3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions