]> git.proxmox.com Git - libgit2.git/commit
patch_generate: only calculate binary diffs if requested
authorPatrick Steinhardt <ps@pks.im>
Thu, 1 Sep 2016 13:14:25 +0000 (15:14 +0200)
committerPatrick Steinhardt <ps@pks.im>
Thu, 1 Sep 2016 13:14:25 +0000 (15:14 +0200)
commit4b34f687bd3382fc94012fa221885028f4cfded5
treefc689195fb3374a87084982fdf3e0613671af1e7
parenta08e88259fe7ef3d7514a4774acd6eec5a6a2ca7
patch_generate: only calculate binary diffs if requested

When generating diffs for binary files, we load and decompress
the blobs in order to generate the actual diff, which can be very
costly. While we cannot avoid this for the case when we are
called with the `GIT_DIFF_SHOW_BINARY` flag, we do not have to
load the blobs in the case where this flag is not set, as the
caller is expected to have no interest in the actual content of
binary files.

Fix the issue by only generating a binary diff when the caller is
actually interested in the diff. As libgit2 uses heuristics to
determine that a blob contains binary data by inspecting its size
without loading from the ODB, this saves us quite some time when
diffing in a repository with binary files.
src/patch_generate.c