]> git.ipfire.org Git - thirdparty/git.git/commitdiff
move encode_in_pack_object_header() to a better place
authorNicolas Pitre <nico@fluxnic.net>
Tue, 23 Feb 2010 20:02:37 +0000 (15:02 -0500)
committerJunio C Hamano <gitster@pobox.com>
Tue, 23 Feb 2010 21:10:56 +0000 (13:10 -0800)
Commit 1b22b6c897 made duplicated versions of encode_header() into a
common version called encode_in_pack_object_header(). There is however
a better location that sha1_file.c for such a function though, as
sha1_file.c contains nothing related to the creation of packs, and
it is quite populated already.

Also the comment that was moved to the header file should really remain
near the function as it covers implementation details and provides no
information about the actual function interface.

Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
cache.h
pack-write.c
pack.h
sha1_file.c

diff --git a/cache.h b/cache.h
index 2654b608ba8226bcaaae6c2afe9a30fb98fd79de..d478eff1f323f25a474cf019e0de2254c5ff0360 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -911,14 +911,6 @@ extern void *unpack_entry(struct packed_git *, off_t, enum object_type *, unsign
 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 const char *packed_object_info_detail(struct packed_git *, off_t, unsigned long *, unsigned long *, unsigned int *, unsigned char *);
-/*
- * 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"
- */
-int encode_in_pack_object_header(enum object_type type, uintmax_t size, unsigned char *hdr);
 
 /* Dumb servers support */
 extern int update_server_info(int);
index 9f47cf9961212242bc01082944e83fb54da2a515..a905ca4486754f099a30f90a2fcd22d0c771a070 100644 (file)
@@ -253,3 +253,30 @@ char *index_pack_lockfile(int ip_out)
        }
        return NULL;
 }
+
+/*
+ * 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"
+ */
+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;
+}
diff --git a/pack.h b/pack.h
index b759a23d4d022c4acef893ec35a5dd4e2324715c..d268c014c9eb7040bd65125b13d68edce670274b 100644 (file)
--- a/pack.h
+++ b/pack.h
@@ -60,6 +60,7 @@ extern int check_pack_crc(struct packed_git *p, struct pack_window **w_curs, off
 extern int verify_pack(struct packed_git *);
 extern void fixup_pack_header_footer(int, unsigned char *, const char *, uint32_t, unsigned char *, off_t);
 extern char *index_pack_lockfile(int fd);
+extern int encode_in_pack_object_header(enum object_type, uintmax_t, unsigned char *);
 
 #define PH_ERROR_EOF           (-1)
 #define PH_ERROR_PACK_SIGNATURE        (-2)
index f3c9823c569782df5f6bd4c3ffd77cb872d14ba3..657825e14ef78c19649779fe89e1d09ae672901a 100644 (file)
@@ -1475,26 +1475,6 @@ 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)
 {