Liu Yubao <yubao.liu@xxxxxxxxx> wrote: > > Signed-off-by: Liu Yubao <yubao.liu@xxxxxxxxx> I'd like to see a bit more of an explanation of the new loose object format you are reading in the commit message. We have a long history of explaining *why* the code behaves the way it does in our commits, so we can look at it in blame/log and understand what the heck went on. > --- > sha1_file.c | 20 +++++++++++++++++++- > 1 files changed, 19 insertions(+), 1 deletions(-) > > diff --git a/sha1_file.c b/sha1_file.c > index 79062f0..05a9fa3 100644 > --- a/sha1_file.c > +++ b/sha1_file.c > @@ -1985,6 +1985,16 @@ static int sha1_loose_object_info(const unsigned char *sha1, unsigned long *size > map = map_sha1_file(sha1, &mapsize); > if (!map) > return error("unable to find %s", sha1_to_hex(sha1)); > + > + /* > + * Is it an uncompressed loose objects? > + */ > + if ((status = parse_sha1_header(map, mapsize, &size)) >= 0) { > + if (sizep) > + *sizep = size; > + goto L_leave; > + } > + > if (unpack_sha1_header(&stream, map, mapsize, hdr, sizeof(hdr)) < 0) > status = error("unable to unpack %s header", > sha1_to_hex(sha1)); > @@ -1993,6 +2003,8 @@ static int sha1_loose_object_info(const unsigned char *sha1, unsigned long *size > else if (sizep) > *sizep = size; > inflateEnd(&stream); > + > +L_leave: > munmap(map, mapsize); > return status; > } > @@ -2124,7 +2136,13 @@ void *read_object(const unsigned char *sha1, enum object_type *type, > return buf; > map = map_sha1_file(sha1, &mapsize); > if (map) { > - buf = unpack_sha1_file(map, mapsize, type, size, sha1); > + /* > + * Is it an uncompressed loose object? > + */ > + if ((*type = parse_sha1_header(map, mapsize, size)) >= 0) > + buf = xmemdupz(map + strlen(map) + 1, *size); > + else > + buf = unpack_sha1_file(map, mapsize, type, size, sha1); > munmap(map, mapsize); > return buf; > } -- Shawn. -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html