diff options
author | Vicent Martà <vicent@github.com> | 2013-10-28 09:25:44 -0700 |
---|---|---|
committer | Vicent Martà <vicent@github.com> | 2013-10-28 09:25:44 -0700 |
commit | 5c50f22a93c78190fb7d81802199ff9defc8cf55 (patch) | |
tree | 66e9f28cb6a3c7cc2f4f4931173410cd4f80b32a /src/pack-objects.c | |
parent | 064e6e8121a6265b42f41f1b12468573cb3ccb19 (diff) | |
parent | ab46b1d8ebcdc820aefe2c1391d4be73939bce95 (diff) | |
download | libgit2-5c50f22a93c78190fb7d81802199ff9defc8cf55.tar.gz |
Merge pull request #1891 from libgit2/cmn/fix-thin-packs
Add support for thin packs
Diffstat (limited to 'src/pack-objects.c')
-rw-r--r-- | src/pack-objects.c | 38 |
1 files changed, 2 insertions, 36 deletions
diff --git a/src/pack-objects.c b/src/pack-objects.c index 821f292b9..93541e974 100644 --- a/src/pack-objects.c +++ b/src/pack-objects.c @@ -232,40 +232,6 @@ int git_packbuilder_insert(git_packbuilder *pb, const git_oid *oid, return 0; } -/* - * The per-object header is a pretty dense thing, which is - * - first byte: low four bits are "size", - * then three bits of "type", - * with the high bit being "size continues". - * - each byte afterwards: low seven bits are size continuation, - * with the high bit being "size continues" - */ -static int gen_pack_object_header( - unsigned char *hdr, - unsigned long size, - git_otype type) -{ - unsigned char *hdr_base; - unsigned char c; - - assert(type >= GIT_OBJ_COMMIT && type <= GIT_OBJ_REF_DELTA); - - /* TODO: add support for chunked objects; see git.git 6c0d19b1 */ - - c = (unsigned char)((type << 4) | (size & 15)); - size >>= 4; - hdr_base = hdr; - - while (size) { - *hdr++ = c | 0x80; - c = size & 0x7f; - size >>= 7; - } - *hdr++ = c; - - return (int)(hdr - hdr_base); -} - static int get_delta(void **out, git_odb *odb, git_pobject *po) { git_odb_object *src = NULL, *trg = NULL; @@ -327,7 +293,7 @@ static int write_object(git_buf *buf, git_packbuilder *pb, git_pobject *po) } /* Write header */ - hdr_len = gen_pack_object_header(hdr, size, type); + hdr_len = git_packfile__object_header(hdr, size, type); if (git_buf_put(buf, (char *)hdr, hdr_len) < 0) goto on_error; @@ -1292,7 +1258,7 @@ int git_packbuilder_write( PREPARE_PACK; if (git_indexer_stream_new( - &indexer, path, progress_cb, progress_cb_payload) < 0) + &indexer, path, pb->odb, progress_cb, progress_cb_payload) < 0) return -1; ctx.indexer = indexer; |