skip picking commits whose parents are unchanged */
| 6387 | |
| 6388 | /* skip picking commits whose parents are unchanged */ |
| 6389 | static int skip_unnecessary_picks(struct repository *r, |
| 6390 | struct todo_list *todo_list, |
| 6391 | struct object_id *base_oid) |
| 6392 | { |
| 6393 | struct object_id *parent_oid; |
| 6394 | int i; |
| 6395 | |
| 6396 | for (i = 0; i < todo_list->nr; i++) { |
| 6397 | struct todo_item *item = todo_list->items + i; |
| 6398 | |
| 6399 | if (item->command >= TODO_NOOP) |
| 6400 | continue; |
| 6401 | if (item->command != TODO_PICK) |
| 6402 | break; |
| 6403 | if (repo_parse_commit(r, item->commit)) { |
| 6404 | return error(_("could not parse commit '%s'"), |
| 6405 | oid_to_hex(&item->commit->object.oid)); |
| 6406 | } |
| 6407 | if (!item->commit->parents) |
| 6408 | break; /* root commit */ |
| 6409 | if (item->commit->parents->next) |
| 6410 | break; /* merge commit */ |
| 6411 | parent_oid = &item->commit->parents->item->object.oid; |
| 6412 | if (!oideq(parent_oid, base_oid)) |
| 6413 | break; |
| 6414 | oidcpy(base_oid, &item->commit->object.oid); |
| 6415 | } |
| 6416 | if (i > 0) { |
| 6417 | const char *done_path = rebase_path_done(); |
| 6418 | |
| 6419 | if (todo_list_write_to_file(r, todo_list, done_path, NULL, NULL, i, 0)) { |
| 6420 | error_errno(_("could not write to '%s'"), done_path); |
| 6421 | return -1; |
| 6422 | } |
| 6423 | |
| 6424 | MOVE_ARRAY(todo_list->items, todo_list->items + i, todo_list->nr - i); |
| 6425 | todo_list->nr -= i; |
| 6426 | todo_list->current = 0; |
| 6427 | todo_list->done_nr += i; |
| 6428 | |
| 6429 | if (is_fixup(peek_command(todo_list, 0))) |
| 6430 | record_in_rewritten(base_oid, peek_command(todo_list, 0)); |
| 6431 | } |
| 6432 | |
| 6433 | return 0; |
| 6434 | } |
| 6435 | |
| 6436 | struct todo_add_branch_context { |
| 6437 | struct todo_item *items; |
no test coverage detected