* For each 'pick' command, find out if the commit has a decoration in * refs/heads/. If so, then add a 'label for-update-refs/' command. */
| 6509 | * refs/heads/. If so, then add a 'label for-update-refs/' command. |
| 6510 | */ |
| 6511 | static int todo_list_add_update_ref_commands(struct todo_list *todo_list) |
| 6512 | { |
| 6513 | int i, res; |
| 6514 | struct todo_add_branch_context ctx = { |
| 6515 | .buf = &todo_list->buf, |
| 6516 | .refs_to_oids = STRING_LIST_INIT_DUP, |
| 6517 | }; |
| 6518 | |
| 6519 | ctx.items_alloc = 2 * todo_list->nr + 1; |
| 6520 | ALLOC_ARRAY(ctx.items, ctx.items_alloc); |
| 6521 | |
| 6522 | load_branch_decorations(); |
| 6523 | |
| 6524 | for (i = 0; i < todo_list->nr; ) { |
| 6525 | struct todo_item *item = &todo_list->items[i]; |
| 6526 | |
| 6527 | /* insert ith item into new list */ |
| 6528 | ALLOC_GROW(ctx.items, |
| 6529 | ctx.items_nr + 1, |
| 6530 | ctx.items_alloc); |
| 6531 | |
| 6532 | ctx.items[ctx.items_nr++] = todo_list->items[i++]; |
| 6533 | |
| 6534 | if (item->commit) { |
| 6535 | add_decorations_to_list(item->commit, &ctx); |
| 6536 | } |
| 6537 | } |
| 6538 | |
| 6539 | res = write_update_refs_state(&ctx.refs_to_oids); |
| 6540 | |
| 6541 | string_list_clear(&ctx.refs_to_oids, 1); |
| 6542 | |
| 6543 | if (res) { |
| 6544 | /* we failed, so clean up the new list. */ |
| 6545 | free(ctx.items); |
| 6546 | return res; |
| 6547 | } |
| 6548 | |
| 6549 | free(todo_list->items); |
| 6550 | todo_list->items = ctx.items; |
| 6551 | todo_list->nr = ctx.items_nr; |
| 6552 | todo_list->alloc = ctx.items_alloc; |
| 6553 | |
| 6554 | return 0; |
| 6555 | } |
| 6556 | |
| 6557 | int complete_action(struct repository *r, struct replay_opts *opts, unsigned flags, |
| 6558 | const char *shortrevisions, const char *onto_name, |
no test coverage detected