summaryrefslogtreecommitdiff
path: root/object-file.c
diff options
context:
space:
mode:
Diffstat (limited to 'object-file.c')
-rw-r--r--object-file.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/object-file.c b/object-file.c
index 3a7fe4fe96..6d97a6f69b 100644
--- a/object-file.c
+++ b/object-file.c
@@ -1340,8 +1340,8 @@ static void *unpack_loose_rest(git_zstream *stream,
* too permissive for what we want to check. So do an anal
* object header parse by hand.
*/
-static int parse_loose_header_extended(const char *hdr, struct object_info *oi,
- unsigned int flags)
+int parse_loose_header(const char *hdr, struct object_info *oi,
+ unsigned int flags)
{
const char *type_buf = hdr;
unsigned long size;
@@ -1401,14 +1401,6 @@ static int parse_loose_header_extended(const char *hdr, struct object_info *oi,
return *hdr ? -1 : type;
}
-int parse_loose_header(const char *hdr, unsigned long *sizep)
-{
- struct object_info oi = OBJECT_INFO_INIT;
-
- oi.sizep = sizep;
- return parse_loose_header_extended(hdr, &oi, 0);
-}
-
static int loose_object_info(struct repository *r,
const struct object_id *oid,
struct object_info *oi, int flags)
@@ -1463,10 +1455,10 @@ static int loose_object_info(struct repository *r,
if (status < 0)
; /* Do nothing */
else if (hdrbuf.len) {
- if ((status = parse_loose_header_extended(hdrbuf.buf, oi, flags)) < 0)
+ if ((status = parse_loose_header(hdrbuf.buf, oi, flags)) < 0)
status = error(_("unable to parse %s header with --allow-unknown-type"),
oid_to_hex(oid));
- } else if ((status = parse_loose_header_extended(hdr, oi, flags)) < 0)
+ } else if ((status = parse_loose_header(hdr, oi, flags)) < 0)
status = error(_("unable to parse %s header"), oid_to_hex(oid));
if (status >= 0 && oi->contentp) {
@@ -2547,6 +2539,8 @@ int read_loose_object(const char *path,
unsigned long mapsize;
git_zstream stream;
char hdr[MAX_HEADER_LEN];
+ struct object_info oi = OBJECT_INFO_INIT;
+ oi.sizep = size;
*contents = NULL;
@@ -2561,7 +2555,7 @@ int read_loose_object(const char *path,
goto out;
}
- *type = parse_loose_header(hdr, size);
+ *type = parse_loose_header(hdr, &oi, 0);
if (*type < 0) {
error(_("unable to parse header of %s"), path);
git_inflate_end(&stream);