Skip to content

Commit ca79c98

Browse files
peffgitster
authored andcommitted
sha1_file: make packed_object_info public
Some code may have a pack/offset pair for an object, but would like to look up more information. Using sha1_object_info() is too heavy-weight; it starts from the sha1 and has to find the pack again (so not only does it waste time, it might not even find the same instance). In some cases, this problem is solved by helpers like get_size_from_delta(), which is used by pack-objects to take a shortcut for objects whose packed representation has already been found. But there's no similar function for getting the object type, for instance. Rather than introduce one, let's just make the whole packed_object_info() available. It is smart enough to spend effort only on the items the caller wants. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 27b5c1a commit ca79c98

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

cache.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,6 +1550,7 @@ struct object_info {
15501550
#define OBJECT_INFO_INIT {NULL}
15511551

15521552
extern int sha1_object_info_extended(const unsigned char *, struct object_info *, unsigned flags);
1553+
extern int packed_object_info(struct packed_git *pack, off_t offset, struct object_info *);
15531554

15541555
/* Dumb servers support */
15551556
extern int update_server_info(int);

sha1_file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1970,8 +1970,8 @@ static enum object_type packed_to_object_type(struct packed_git *p,
19701970
goto out;
19711971
}
19721972

1973-
static int packed_object_info(struct packed_git *p, off_t obj_offset,
1974-
struct object_info *oi)
1973+
int packed_object_info(struct packed_git *p, off_t obj_offset,
1974+
struct object_info *oi)
19751975
{
19761976
struct pack_window *w_curs = NULL;
19771977
unsigned long size;

0 commit comments

Comments
 (0)