diff options
Diffstat (limited to 'index-pack.c')
-rw-r--r-- | index-pack.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/index-pack.c b/index-pack.c index 64d75f8c4d..cf81a99500 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; @@ -596,30 +602,23 @@ static void fix_unresolved_deltas(int nr_unresolved) struct delta_entry *d = sorted_by_pos[i]; void *data; unsigned long size; - char type[10]; - enum object_type obj_type; + enum object_type type; int j, first, last; if (objects[d->obj_no].real_type != OBJ_REF_DELTA) continue; - data = read_sha1_file(d->base.sha1, type, &size); + data = read_sha1_file(d->base.sha1, &type, &size); if (!data) continue; - if (!strcmp(type, blob_type)) obj_type = OBJ_BLOB; - else if (!strcmp(type, tree_type)) obj_type = OBJ_TREE; - else if (!strcmp(type, commit_type)) obj_type = OBJ_COMMIT; - else if (!strcmp(type, tag_type)) obj_type = OBJ_TAG; - else die("base object %s is of type '%s'", - sha1_to_hex(d->base.sha1), type); find_delta_children(&d->base, &first, &last); for (j = first; j <= last; j++) { struct object_entry *child = objects + deltas[j].obj_no; if (child->real_type == OBJ_REF_DELTA) - resolve_delta(child, data, size, obj_type); + resolve_delta(child, data, size, type); } - append_obj_to_pack(data, size, obj_type); + append_obj_to_pack(data, size, type); free(data); if (verbose) percent = display_progress(nr_resolved_deltas, @@ -850,9 +849,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; |