pack: move unpack_object_header()
Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
7b3aa75df7
commit
3588dd6e99
1
cache.h
1
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 int is_pack_valid(struct packed_git *);
|
||||||
extern void *unpack_entry(struct packed_git *, off_t, enum object_type *, unsigned long *);
|
extern void *unpack_entry(struct packed_git *, off_t, enum object_type *, unsigned long *);
|
||||||
extern int unpack_object_header(struct packed_git *, struct pack_window **, off_t *, unsigned long *);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Iterate over the files in the loose-object parts of the object
|
* Iterate over the files in the loose-object parts of the object
|
||||||
|
26
packfile.c
26
packfile.c
@ -949,3 +949,29 @@ unsigned long get_size_from_delta(struct packed_git *p,
|
|||||||
/* Read the result size */
|
/* Read the result size */
|
||||||
return get_delta_hdr_size(&data, delta_head+sizeof(delta_head));
|
return get_delta_hdr_size(&data, delta_head+sizeof(delta_head));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int unpack_object_header(struct packed_git *p,
|
||||||
|
struct pack_window **w_curs,
|
||||||
|
off_t *curpos,
|
||||||
|
unsigned long *sizep)
|
||||||
|
{
|
||||||
|
unsigned char *base;
|
||||||
|
unsigned long left;
|
||||||
|
unsigned long used;
|
||||||
|
enum object_type type;
|
||||||
|
|
||||||
|
/* use_pack() assures us we have [base, base + 20) available
|
||||||
|
* as a range that we can look at. (Its actually the hash
|
||||||
|
* size that is assured.) With our object header encoding
|
||||||
|
* the maximum deflated object size is 2^137, which is just
|
||||||
|
* insane, so we know won't exceed what we have been given.
|
||||||
|
*/
|
||||||
|
base = use_pack(p, w_curs, *curpos, &left);
|
||||||
|
used = unpack_object_header_buffer(base, left, &type, sizep);
|
||||||
|
if (!used) {
|
||||||
|
type = OBJ_BAD;
|
||||||
|
} else
|
||||||
|
*curpos += used;
|
||||||
|
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
@ -64,6 +64,7 @@ extern struct packed_git *add_packed_git(const char *path, size_t path_len, int
|
|||||||
|
|
||||||
extern unsigned long unpack_object_header_buffer(const unsigned char *buf, unsigned long len, enum object_type *type, unsigned long *sizep);
|
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 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 *);
|
||||||
|
|
||||||
extern void release_pack_memory(size_t);
|
extern void release_pack_memory(size_t);
|
||||||
|
|
||||||
|
26
sha1_file.c
26
sha1_file.c
@ -1172,32 +1172,6 @@ static const unsigned char *get_delta_base_sha1(struct packed_git *p,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int unpack_object_header(struct packed_git *p,
|
|
||||||
struct pack_window **w_curs,
|
|
||||||
off_t *curpos,
|
|
||||||
unsigned long *sizep)
|
|
||||||
{
|
|
||||||
unsigned char *base;
|
|
||||||
unsigned long left;
|
|
||||||
unsigned long used;
|
|
||||||
enum object_type type;
|
|
||||||
|
|
||||||
/* use_pack() assures us we have [base, base + 20) available
|
|
||||||
* as a range that we can look at. (Its actually the hash
|
|
||||||
* size that is assured.) With our object header encoding
|
|
||||||
* the maximum deflated object size is 2^137, which is just
|
|
||||||
* insane, so we know won't exceed what we have been given.
|
|
||||||
*/
|
|
||||||
base = use_pack(p, w_curs, *curpos, &left);
|
|
||||||
used = unpack_object_header_buffer(base, left, &type, sizep);
|
|
||||||
if (!used) {
|
|
||||||
type = OBJ_BAD;
|
|
||||||
} else
|
|
||||||
*curpos += used;
|
|
||||||
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int retry_bad_packed_offset(struct packed_git *p, off_t obj_offset)
|
static int retry_bad_packed_offset(struct packed_git *p, off_t obj_offset)
|
||||||
{
|
{
|
||||||
int type;
|
int type;
|
||||||
|
Reference in New Issue
Block a user