| 4998 | } |
| 4999 | |
| 5000 | static int pick_commits(struct repository *r, |
| 5001 | struct todo_list *todo_list, |
| 5002 | struct replay_opts *opts) |
| 5003 | { |
| 5004 | struct replay_ctx *ctx = opts->ctx; |
| 5005 | int res = 0, reschedule = 0; |
| 5006 | |
| 5007 | if (opts->allow_ff) |
| 5008 | ASSERT(!(opts->signoff || opts->no_commit || |
| 5009 | opts->record_origin || should_edit(opts) || |
| 5010 | opts->committer_date_is_author_date || |
| 5011 | opts->ignore_date)); |
| 5012 | if (read_and_refresh_cache(r, opts)) |
| 5013 | return -1; |
| 5014 | |
| 5015 | unlink(rebase_path_message()); |
| 5016 | unlink(rebase_path_stopped_sha()); |
| 5017 | unlink(rebase_path_amend()); |
| 5018 | unlink(rebase_path_patch()); |
| 5019 | |
| 5020 | while (todo_list->current < todo_list->nr) { |
| 5021 | struct todo_item *item = todo_list->items + todo_list->current; |
| 5022 | const char *arg = todo_item_get_arg(todo_list, item); |
| 5023 | int check_todo = 0; |
| 5024 | |
| 5025 | if (save_todo(todo_list, opts, reschedule)) |
| 5026 | return -1; |
| 5027 | if (is_rebase_i(opts)) { |
| 5028 | if (item->command != TODO_COMMENT) { |
| 5029 | FILE *f = fopen(rebase_path_msgnum(), "w"); |
| 5030 | |
| 5031 | todo_list->done_nr++; |
| 5032 | |
| 5033 | if (f) { |
| 5034 | fprintf(f, "%d\n", todo_list->done_nr); |
| 5035 | fclose(f); |
| 5036 | } |
| 5037 | if (!opts->quiet) |
| 5038 | fprintf(stderr, _("Rebasing (%d/%d)%s"), |
| 5039 | todo_list->done_nr, |
| 5040 | todo_list->total_nr, |
| 5041 | opts->verbose ? "\n" : "\r"); |
| 5042 | } |
| 5043 | unlink(rebase_path_author_script()); |
| 5044 | unlink(git_path_merge_head(r)); |
| 5045 | refs_delete_ref(get_main_ref_store(r), "", "AUTO_MERGE", |
| 5046 | NULL, REF_NO_DEREF); |
| 5047 | refs_delete_ref(get_main_ref_store(r), "", "REBASE_HEAD", |
| 5048 | NULL, REF_NO_DEREF); |
| 5049 | |
| 5050 | if (item->command == TODO_BREAK) { |
| 5051 | if (!opts->verbose) |
| 5052 | term_clear_line(); |
| 5053 | return stopped_at_head(r); |
| 5054 | } |
| 5055 | } |
| 5056 | strbuf_reset(&ctx->message); |
| 5057 | ctx->have_message = 0; |
no test coverage detected