index-pack: use streaming interface on large blobs (most of the time)
commit9ec2dde9f3008ed3822c8e7510ab710bdb613873
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Wed, 23 May 2012 14:09:47 +0000 (23 21:09 +0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 23 May 2012 16:08:54 +0000 (23 09:08 -0700)
tree09ac025723bbd37392b0eb198a323dbf8ec0ac78
parent681b07de11c9463f6d93639d9fff9eccd8629eb4
index-pack: use streaming interface on large blobs (most of the time)

unpack_raw_entry() will not allocate and return decompressed blobs if
they are larger than core.bigFileThreshold. sha1_object() may not be
called on those objects because there's no actual content.

sha1_object() is called later on those objects, where we can safely
use get_data_from_pack() to retrieve blob content for checking.
However we always do that when we definitely need the blob
content. And we often don't.

There are two cases when we may need object content. The first case is
when we find an in-repo blob with the same SHA-1. We need to do
collision test, byte-on-byte. If this test is on, the blob must be
loaded on memory (i.e. no streaming). Normally (e.g. in
fetch/pull/clone) this does not happen because git avoid to send
objects that client already has.

The other case is when --strict is specified and the object in
question is not a blob, which can't happen in reality becase we deal
with large _blobs_ here.

Note: --verify (or git-verify-pack) a pack from current repository
will trigger collision test on every object in the pack, which
effectively disables this patch. This could be easily worked around by
setting GIT_DIR to an imaginary place with no packs.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/index-pack.c
t/t1050-large.sh