ref-filter: resolve HEAD when parsing %(HEAD) atom
[gitweb.git] / streaming.c
index 3c48f049d3aa3150573f31a888cc741134d7669e..9afa66b8be6c3b5481e4542c033bfebdb2abbfda 100644 (file)
@@ -135,7 +135,7 @@ struct git_istream *open_istream(const unsigned char *sha1,
                                 struct stream_filter *filter)
 {
        struct git_istream *st;
-       struct object_info oi = {NULL};
+       struct object_info oi = OBJECT_INFO_INIT;
        const unsigned char *real = lookup_replace_object(sha1);
        enum input_source src = istream_source(real, type, &oi);
 
@@ -337,17 +337,17 @@ static open_method_decl(loose)
        st->u.loose.mapped = map_sha1_file(sha1, &st->u.loose.mapsize);
        if (!st->u.loose.mapped)
                return -1;
-       if (unpack_sha1_header(&st->z,
-                              st->u.loose.mapped,
-                              st->u.loose.mapsize,
-                              st->u.loose.hdr,
-                              sizeof(st->u.loose.hdr)) < 0) {
+       if ((unpack_sha1_header(&st->z,
+                               st->u.loose.mapped,
+                               st->u.loose.mapsize,
+                               st->u.loose.hdr,
+                               sizeof(st->u.loose.hdr)) < 0) ||
+           (parse_sha1_header(st->u.loose.hdr, &st->size) < 0)) {
                git_inflate_end(&st->z);
                munmap(st->u.loose.mapped, st->u.loose.mapsize);
                return -1;
        }
 
-       parse_sha1_header(st->u.loose.hdr, &st->size);
        st->u.loose.hdr_used = strlen(st->u.loose.hdr) + 1;
        st->u.loose.hdr_avail = st->z.total_out;
        st->z_state = z_used;