- if ((line->len + 1) % entry_size)
- goto bad_graft_data;
- i = (line->len + 1) / entry_size - 1;
- graft = xmalloc(st_add(sizeof(*graft),
- st_mult(sizeof(struct object_id), i)));
- graft->nr_parent = i;
- if (get_oid_hex(line->buf, &graft->oid))
- goto bad_graft_data;
- for (i = GIT_SHA1_HEXSZ; i < line->len; i += entry_size) {
- if (line->buf[i] != ' ')
- goto bad_graft_data;
- if (get_sha1_hex(line->buf + i + 1, graft->parent[i/entry_size].hash))
+ /*
+ * phase 0 verifies line, counts hashes in line and allocates graft
+ * phase 1 fills graft
+ */
+ for (phase = 0; phase < 2; phase++) {
+ oid = graft ? &graft->oid : &dummy_oid;
+ if (parse_oid_hex(line->buf, oid, &tail))