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

Fixes #962: First create a git_patch to get delta->flags correctly #1100

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yoichi
Copy link

@yoichi yoichi commented Oct 23, 2021

diff_get_delta_byindex() may result incorrect value of delta->flags
as described in the comment of git_diff_get_delta() (git2/diff.h)

Note that the flags on the delta related to whether it has binary
content or not may not be set if there are no attributes set for the
file and there has been no reason to load the file data at this point.
For now, if you need those flags to be up to date, your only option is
to either use `git_diff_foreach` or create a `git_patch`.

this pull request fixes #962

@jdavid
Copy link
Member

jdavid commented Oct 31, 2021

My concern is that building the patch would be a waste of time if the flags are not used later.
The alternative would be to build the patch lazily, when the flags are asked for, but this may not be easy.

I've done the related commit 464836c , if none of GIT_DIFF_FLAG_BINARY and GIT_DIFF_FLAG_NOT_BINARY have been set then the flags have not been loaded and the patch should be built.

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

Successfully merging this pull request may close these issues.

Wrong binary state of a delta if patches have not been iterated
2 participants