Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Tan <jonathantanmy@google.com>2017-08-19 01:20:27 +0300
committerJunio C Hamano <gitster@pobox.com>2017-08-24 01:12:07 +0300
commit32b42e152fcc453273fadb5a7d639e4e9b506783 (patch)
tree263a76fc30d72df6178c00298dd91e7bfd92c724 /packfile.c
parent0abe14f6a5b7681b4ea02d1bd0a64332587ae053 (diff)
pack: move unpack_object_header_buffer()
Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'packfile.c')
-rw-r--r--packfile.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/packfile.c b/packfile.c
index 56ec50febe..1116942043 100644
--- a/packfile.c
+++ b/packfile.c
@@ -884,3 +884,28 @@ void reprepare_packed_git(void)
prepare_packed_git_run_once = 0;
prepare_packed_git();
}
+
+unsigned long unpack_object_header_buffer(const unsigned char *buf,
+ unsigned long len, enum object_type *type, unsigned long *sizep)
+{
+ unsigned shift;
+ unsigned long size, c;
+ unsigned long used = 0;
+
+ c = buf[used++];
+ *type = (c >> 4) & 7;
+ size = c & 15;
+ shift = 4;
+ while (c & 0x80) {
+ if (len <= used || bitsizeof(long) <= shift) {
+ error("bad object header");
+ size = used = 0;
+ break;
+ }
+ c = buf[used++];
+ size += (c & 0x7f) << shift;
+ shift += 7;
+ }
+ *sizep = size;
+ return used;
+}