summaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
Diffstat (limited to 'sha1_file.c')
-rw-r--r--sha1_file.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/sha1_file.c b/sha1_file.c
index 657825e14e..f3c9823c56 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -1475,6 +1475,26 @@ const char *packed_object_info_detail(struct packed_git *p,
}
}
+int encode_in_pack_object_header(enum object_type type, uintmax_t 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;
+}
+
static int packed_object_info(struct packed_git *p, off_t obj_offset,
unsigned long *sizep)
{