diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2013-09-11 13:06:08 +0700 |
---|---|---|
committer | Nicolas Pitre <nico@fluxnic.net> | 2013-09-13 21:00:30 -0400 |
commit | 7c65a6e6ba07d5c57a5a75bdd401207fa9e81f7c (patch) | |
tree | 3969950be36aa7b9b34017ba0cf03a21114d29f0 | |
parent | c15490d3c07692cbfd65eb70ffc6ef8f116c809e (diff) | |
download | git-7c65a6e6ba07d5c57a5a75bdd401207fa9e81f7c.tar.gz |
pack v4: move pv4 objhdr parsing code to packv4-parse.c
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
-rw-r--r-- | packv4-parse.c | 12 | ||||
-rw-r--r-- | packv4-parse.h | 5 | ||||
-rw-r--r-- | sha1_file.c | 9 |
3 files changed, 19 insertions, 7 deletions
diff --git a/packv4-parse.c b/packv4-parse.c index c3cf548b7f..38c22b0358 100644 --- a/packv4-parse.c +++ b/packv4-parse.c @@ -578,3 +578,15 @@ void *pv4_get_tree(struct packed_git *p, struct pack_window **w_curs, } return dst; } + +unsigned long pv4_unpack_object_header_buffer(const unsigned char *base, + unsigned long len, + enum object_type *type, + unsigned long *sizep) +{ + const unsigned char *cp = base; + uintmax_t val = decode_varint(&cp); + *type = val & 0xf; + *sizep = val >> 4; + return cp - base; +} diff --git a/packv4-parse.h b/packv4-parse.h index e6719f6384..52f52f5fd9 100644 --- a/packv4-parse.h +++ b/packv4-parse.h @@ -10,6 +10,11 @@ struct packv4_dict { struct packv4_dict *pv4_create_dict(const unsigned char *data, int dict_size); void pv4_free_dict(struct packv4_dict *dict); +unsigned long pv4_unpack_object_header_buffer(const unsigned char *base, + unsigned long len, + enum object_type *type, + unsigned long *sizep); + void *pv4_get_commit(struct packed_git *p, struct pack_window **w_curs, off_t offset, unsigned long size); void *pv4_get_tree(struct packed_git *p, struct pack_window **w_curs, diff --git a/sha1_file.c b/sha1_file.c index 1528e28553..038e22e559 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -1736,13 +1736,8 @@ int unpack_object_header(struct packed_git *p, base = use_pack(p, w_curs, *curpos, &left); if (p->version < 4) { used = unpack_object_header_buffer(base, left, &type, sizep); - } else { - const unsigned char *cp = base; - uintmax_t val = decode_varint(&cp); - used = cp - base; - type = val & 0xf; - *sizep = val >> 4; - } + } else + used = pv4_unpack_object_header_buffer(base, left, &type, sizep); if (!used) { type = OBJ_BAD; } else |