pygit2 icon indicating copy to clipboard operation
pygit2 copied to clipboard

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

Open yoichi opened this issue 4 years ago • 1 comments

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

yoichi avatar Oct 23 '21 12:10 yoichi

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 464836c7 , 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.

jdavid avatar Oct 31 '21 08:10 jdavid