X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=index-pack.c;h=48874a052a8be22c50fdbb8b4b707af2d49c4859;hb=fbe3d87e5fcef2e0fff41c3b0589331c889dfb59;hp=72e0962415d74c856917f6bb56e6fa2fea950c25;hpb=e861ce1692fa9809f3e7b898804f8ddaf7cd8975;p=git.git diff --git a/index-pack.c b/index-pack.c index 72e096241..48874a052 100644 --- a/index-pack.c +++ b/index-pack.c @@ -277,13 +277,19 @@ static void *get_data_from_pack(struct object_entry *obj) { unsigned long from = obj[0].offset + obj[0].hdr_size; unsigned long len = obj[1].offset - from; + unsigned long rdy = 0; unsigned char *src, *data; z_stream stream; int st; src = xmalloc(len); - if (pread(pack_fd, src, len, from) != len) - die("cannot pread pack file: %s", strerror(errno)); + data = src; + do { + ssize_t n = pread(pack_fd, data + rdy, len - rdy, from + rdy); + if (n <= 0) + die("cannot pread pack file: %s", strerror(errno)); + rdy += n; + } while (rdy < len); data = xmalloc(obj->size); memset(&stream, 0, sizeof(stream)); stream.next_out = data; @@ -849,9 +855,9 @@ int main(int argc, char **argv) fix_thin_pack = 1; } else if (!strcmp(arg, "--keep")) { keep_msg = ""; - } else if (!strncmp(arg, "--keep=", 7)) { + } else if (!prefixcmp(arg, "--keep=")) { keep_msg = arg + 7; - } else if (!strncmp(arg, "--pack_header=", 14)) { + } else if (!prefixcmp(arg, "--pack_header=")) { struct pack_header *hdr; char *c;