The following functions are duplicated: encode_header Signed-off-by: Michael Lukashov <michael.lukashov@xxxxxxxxx> --- builtin-pack-objects.c | 27 --------------------------- fast-import.c | 23 ----------------------- object.c | 20 ++++++++++++++++++++ object.h | 9 +++++++++ 4 files changed, 29 insertions(+), 50 deletions(-) diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c index e1d3adf..80bbcd2 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. */ diff --git a/fast-import.c b/fast-import.c index b477dc6..f983338 100644 --- a/fast-import.c +++ b/fast-import.c @@ -1013,29 +1013,6 @@ static void cycle_packfile(void) start_packfile(); } -static size_t encode_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 store_object( enum object_type type, struct strbuf *dat, diff --git a/object.c b/object.c index 3ca92c4..a06ad01 100644 --- a/object.c +++ b/object.c @@ -268,3 +268,23 @@ void object_array_remove_duplicates(struct object_array *array) array->nr = dst; } } + +int encode_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/object.h b/object.h index 82877c8..f5a5c77 100644 --- a/object.h +++ b/object.h @@ -79,4 +79,13 @@ void add_object_array(struct object *obj, const char *name, struct object_array void add_object_array_with_mode(struct object *obj, const char *name, struct object_array *array, unsigned mode); void object_array_remove_duplicates(struct object_array *); +/* + * 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_header(enum object_type type, uintmax_t size, unsigned char *hdr); + #endif /* OBJECT_H */ -- 1.7.0.1571.g856c2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html