| 218 | } |
| 219 | |
| 220 | int register_commit_graft(struct repository *r, struct commit_graft *graft, |
| 221 | int ignore_dups) |
| 222 | { |
| 223 | int pos = commit_graft_pos(r, &graft->oid); |
| 224 | |
| 225 | if (0 <= pos) { |
| 226 | if (ignore_dups) |
| 227 | free(graft); |
| 228 | else { |
| 229 | free(r->parsed_objects->grafts[pos]); |
| 230 | r->parsed_objects->grafts[pos] = graft; |
| 231 | } |
| 232 | return 1; |
| 233 | } |
| 234 | pos = -pos - 1; |
| 235 | ALLOC_GROW(r->parsed_objects->grafts, |
| 236 | r->parsed_objects->grafts_nr + 1, |
| 237 | r->parsed_objects->grafts_alloc); |
| 238 | r->parsed_objects->grafts_nr++; |
| 239 | if (pos < r->parsed_objects->grafts_nr) |
| 240 | memmove(r->parsed_objects->grafts + pos + 1, |
| 241 | r->parsed_objects->grafts + pos, |
| 242 | (r->parsed_objects->grafts_nr - pos - 1) * |
| 243 | sizeof(*r->parsed_objects->grafts)); |
| 244 | r->parsed_objects->grafts[pos] = graft; |
| 245 | unparse_commit(r, &graft->oid); |
| 246 | return 0; |
| 247 | } |
| 248 | |
| 249 | struct commit_graft *read_graft_line(struct strbuf *line) |
| 250 | { |
no test coverage detected