Skip to content

Commit f0270ef

Browse files
committed
sha1_file.c: expose helpers to read loose objects
Make map_sha1_file(), parse_sha1_header() and unpack_sha1_header() available to the streaming read API by exporting them via cache.h header file. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7ef2d9a commit f0270ef

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

cache.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,9 @@ extern int hash_sha1_file(const void *buf, unsigned long len, const char *type,
780780
extern int write_sha1_file(const void *buf, unsigned long len, const char *type, unsigned char *return_sha1);
781781
extern int pretend_sha1_file(void *, unsigned long, enum object_type, unsigned char *);
782782
extern int force_object_loose(const unsigned char *sha1, time_t mtime);
783+
extern void *map_sha1_file(const unsigned char *sha1, unsigned long *size);
784+
extern int unpack_sha1_header(z_stream *stream, unsigned char *map, unsigned long mapsize, void *buffer, unsigned long bufsiz);
785+
extern int parse_sha1_header(const char *hdr, unsigned long *sizep);
783786

784787
/* global flag to enable extra checks when accessing packed objects */
785788
extern int do_check_packed_object_crc;

sha1_file.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,7 +1186,7 @@ static int open_sha1_file(const unsigned char *sha1)
11861186
return -1;
11871187
}
11881188

1189-
static void *map_sha1_file(const unsigned char *sha1, unsigned long *size)
1189+
void *map_sha1_file(const unsigned char *sha1, unsigned long *size)
11901190
{
11911191
void *map;
11921192
int fd;
@@ -1245,7 +1245,7 @@ unsigned long unpack_object_header_buffer(const unsigned char *buf,
12451245
return used;
12461246
}
12471247

1248-
static int unpack_sha1_header(z_stream *stream, unsigned char *map, unsigned long mapsize, void *buffer, unsigned long bufsiz)
1248+
int unpack_sha1_header(z_stream *stream, unsigned char *map, unsigned long mapsize, void *buffer, unsigned long bufsiz)
12491249
{
12501250
unsigned long size, used;
12511251
static const char valid_loose_object_type[8] = {
@@ -1342,7 +1342,7 @@ static void *unpack_sha1_rest(z_stream *stream, void *buffer, unsigned long size
13421342
* too permissive for what we want to check. So do an anal
13431343
* object header parse by hand.
13441344
*/
1345-
static int parse_sha1_header(const char *hdr, unsigned long *sizep)
1345+
int parse_sha1_header(const char *hdr, unsigned long *sizep)
13461346
{
13471347
char type[10];
13481348
int i;

0 commit comments

Comments
 (0)