summaryrefslogtreecommitdiff
path: root/builtin-pack-objects.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-03-02 20:44:11 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-03-02 20:44:11 (GMT)
commit77b30bcecd84225a21a8639c272fde88180f36d9 (patch)
tree0d2b1d071c37b119943a88c195ff2bfd50e3f500 /builtin-pack-objects.c
parentca97d26cc612348baa423475adfb48194386b4a5 (diff)
parentf965c525a4d04837b1b7ed43e3fa2dc8c0df4e2b (diff)
downloadgit-77b30bcecd84225a21a8639c272fde88180f36d9.zip
git-77b30bcecd84225a21a8639c272fde88180f36d9.tar.gz
git-77b30bcecd84225a21a8639c272fde88180f36d9.tar.bz2
Merge branch 'ml/encode-header-refactor'
* ml/encode-header-refactor: move encode_in_pack_object_header() to a better place refactor duplicated encode_header in pack-objects and fast-import
Diffstat (limited to 'builtin-pack-objects.c')
-rw-r--r--builtin-pack-objects.c31
1 files changed, 2 insertions, 29 deletions
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index e1d3adf..6b2f65c 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -155,33 +155,6 @@ static unsigned long do_compress(void **pptr, unsigned long size)
}
/*
- * The per-object header is a pretty dense thing, which is
- * - first byte: low four bits are "size", then three bits of "type",
- * and the high bit is "size continues".
- * - each byte afterwards: low seven bits are size continuation,
- * with the high bit being "size continues"
- */
-static int encode_header(enum object_type type, unsigned long size, unsigned char *hdr)
-{
- int n = 1;
- unsigned char c;
-
- if (type < OBJ_COMMIT || type > OBJ_REF_DELTA)
- die("bad type %d", type);
-
- c = (type << 4) | (size & 15);
- size >>= 4;
- while (size) {
- *hdr++ = c | 0x80;
- c = size & 0x7f;
- size >>= 7;
- n++;
- }
- *hdr = c;
- return n;
-}
-
-/*
* we are going to reuse the existing object data as is. make
* sure it is not corrupt.
*/
@@ -321,7 +294,7 @@ static unsigned long write_object(struct sha1file *f,
* The object header is a byte of 'type' followed by zero or
* more bytes of length.
*/
- hdrlen = encode_header(type, size, header);
+ hdrlen = encode_in_pack_object_header(type, size, header);
if (type == OBJ_OFS_DELTA) {
/*
@@ -372,7 +345,7 @@ static unsigned long write_object(struct sha1file *f,
if (entry->delta)
type = (allow_ofs_delta && entry->delta->idx.offset) ?
OBJ_OFS_DELTA : OBJ_REF_DELTA;
- hdrlen = encode_header(type, entry->size, header);
+ hdrlen = encode_in_pack_object_header(type, entry->size, header);
offset = entry->in_pack_offset;
revidx = find_pack_revindex(p, offset);