Skip to content

Commit 3588dd6

Browse files
jonathantanmygitster
authored andcommitted
pack: move unpack_object_header()
Signed-off-by: Jonathan Tan <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7b3aa75 commit 3588dd6

File tree

4 files changed

+27
-27
lines changed

4 files changed

+27
-27
lines changed

cache.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1663,7 +1663,6 @@ extern off_t find_pack_entry_one(const unsigned char *sha1, struct packed_git *)
16631663

16641664
extern int is_pack_valid(struct packed_git *);
16651665
extern void *unpack_entry(struct packed_git *, off_t, enum object_type *, unsigned long *);
1666-
extern int unpack_object_header(struct packed_git *, struct pack_window **, off_t *, unsigned long *);
16671666

16681667
/*
16691668
* Iterate over the files in the loose-object parts of the object

packfile.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -949,3 +949,29 @@ unsigned long get_size_from_delta(struct packed_git *p,
949949
/* Read the result size */
950950
return get_delta_hdr_size(&data, delta_head+sizeof(delta_head));
951951
}
952+
953+
int unpack_object_header(struct packed_git *p,
954+
struct pack_window **w_curs,
955+
off_t *curpos,
956+
unsigned long *sizep)
957+
{
958+
unsigned char *base;
959+
unsigned long left;
960+
unsigned long used;
961+
enum object_type type;
962+
963+
/* use_pack() assures us we have [base, base + 20) available
964+
* as a range that we can look at. (Its actually the hash
965+
* size that is assured.) With our object header encoding
966+
* the maximum deflated object size is 2^137, which is just
967+
* insane, so we know won't exceed what we have been given.
968+
*/
969+
base = use_pack(p, w_curs, *curpos, &left);
970+
used = unpack_object_header_buffer(base, left, &type, sizep);
971+
if (!used) {
972+
type = OBJ_BAD;
973+
} else
974+
*curpos += used;
975+
976+
return type;
977+
}

packfile.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ extern struct packed_git *add_packed_git(const char *path, size_t path_len, int
6464

6565
extern unsigned long unpack_object_header_buffer(const unsigned char *buf, unsigned long len, enum object_type *type, unsigned long *sizep);
6666
extern unsigned long get_size_from_delta(struct packed_git *, struct pack_window **, off_t);
67+
extern int unpack_object_header(struct packed_git *, struct pack_window **, off_t *, unsigned long *);
6768

6869
extern void release_pack_memory(size_t);
6970

sha1_file.c

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,32 +1172,6 @@ static const unsigned char *get_delta_base_sha1(struct packed_git *p,
11721172
return NULL;
11731173
}
11741174

1175-
int unpack_object_header(struct packed_git *p,
1176-
struct pack_window **w_curs,
1177-
off_t *curpos,
1178-
unsigned long *sizep)
1179-
{
1180-
unsigned char *base;
1181-
unsigned long left;
1182-
unsigned long used;
1183-
enum object_type type;
1184-
1185-
/* use_pack() assures us we have [base, base + 20) available
1186-
* as a range that we can look at. (Its actually the hash
1187-
* size that is assured.) With our object header encoding
1188-
* the maximum deflated object size is 2^137, which is just
1189-
* insane, so we know won't exceed what we have been given.
1190-
*/
1191-
base = use_pack(p, w_curs, *curpos, &left);
1192-
used = unpack_object_header_buffer(base, left, &type, sizep);
1193-
if (!used) {
1194-
type = OBJ_BAD;
1195-
} else
1196-
*curpos += used;
1197-
1198-
return type;
1199-
}
1200-
12011175
static int retry_bad_packed_offset(struct packed_git *p, off_t obj_offset)
12021176
{
12031177
int type;

0 commit comments

Comments
 (0)