]> asedeno.scripts.mit.edu Git - git.git/blobdiff - index-pack.c
Replace calls to strbuf_init(&foo, 0) with STRBUF_INIT initializer
[git.git] / index-pack.c
index 2e4c0885f2c6f6907481dfefe7e0761c3957d8a6..d3a4d31b4e92d69eb32d1a18ebb7be1f7470d1d1 100644 (file)
@@ -365,8 +365,11 @@ static void *get_data_from_pack(struct object_entry *obj)
        data = src;
        do {
                ssize_t n = pread(pack_fd, data + rdy, len - rdy, from + rdy);
-               if (n <= 0)
+               if (n < 0)
                        die("cannot pread pack file: %s", strerror(errno));
+               if (!n)
+                       die("premature end of pack file, %lu bytes missing",
+                           len - rdy);
                rdy += n;
        } while (rdy < len);
        data = xmalloc(obj->size);
@@ -704,6 +707,7 @@ static struct object_entry *append_obj_to_pack(struct sha1file *f,
        obj[1].idx.offset = obj[0].idx.offset + n;
        obj[1].idx.offset += write_compressed(f, buf, size);
        obj[0].idx.crc32 = crc32_end(f);
+       sha1flush(f);
        hashcpy(obj->idx.sha1, sha1);
        return obj;
 }