pack: move unpack_object_header_buffer()
authorJonathan Tan <jonathantanmy@google.com>
Fri, 18 Aug 2017 22:20:27 +0000 (15:20 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 23 Aug 2017 22:12:07 +0000 (15:12 -0700)
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
cache.h
packfile.c
packfile.h
sha1_file.c
diff --git a/cache.h b/cache.h
index a9f45512dca05ee97363bc0bbbd81360f7998b6b..faa8940aff6ad20844656e002edbd98e624c8e1f 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -1663,7 +1663,6 @@ extern off_t find_pack_entry_one(const unsigned char *sha1, struct packed_git *)
 
 extern int is_pack_valid(struct packed_git *);
 extern void *unpack_entry(struct packed_git *, off_t, enum object_type *, unsigned long *);
-extern unsigned long unpack_object_header_buffer(const unsigned char *buf, unsigned long len, enum object_type *type, unsigned long *sizep);
 extern unsigned long get_size_from_delta(struct packed_git *, struct pack_window **, off_t);
 extern int unpack_object_header(struct packed_git *, struct pack_window **, off_t *, unsigned long *);
 
index 56ec50febe4b1c584084f1a7f4719514f1e334fc..111694204370cad4d574878436b7507baab8c2c3 100644 (file)
@@ -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;
+}
index 97246ca1add10f17c113f43994c7182f7a1bfb5d..3954e3ec48a11d90474f21707b05f9f039401e26 100644 (file)
@@ -62,6 +62,8 @@ extern void close_all_packs(void);
 extern void unuse_pack(struct pack_window **);
 extern struct packed_git *add_packed_git(const char *path, size_t path_len, int local);
 
+extern unsigned long unpack_object_header_buffer(const unsigned char *buf, unsigned long len, enum object_type *type, unsigned long *sizep);
+
 extern void release_pack_memory(size_t);
 
 extern int open_packed_git(struct packed_git *p);
index 289eff29154907dd3cd054f0986c4331d4596083..24f4249564a7aac75e73800233b92145b1880a2a 100644 (file)
@@ -915,31 +915,6 @@ void *map_sha1_file(const unsigned char *sha1, unsigned long *size)
        return map_sha1_file_1(NULL, sha1, size);
 }
 
-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;
-}
-
 static int unpack_sha1_short_header(git_zstream *stream,
                                    unsigned char *map, unsigned long mapsize,
                                    void *buffer, unsigned long bufsiz)