| 289 | } |
| 290 | |
| 291 | static int do_interactive_rebase(struct rebase_options *opts, unsigned flags) |
| 292 | { |
| 293 | int ret = -1; |
| 294 | char *revisions = NULL, *shortrevisions = NULL; |
| 295 | struct strvec make_script_args = STRVEC_INIT; |
| 296 | struct todo_list todo_list = TODO_LIST_INIT; |
| 297 | struct replay_opts replay = get_replay_opts(opts); |
| 298 | |
| 299 | if (get_revision_ranges(opts->upstream, opts->onto, &opts->orig_head->object.oid, |
| 300 | &revisions, &shortrevisions)) |
| 301 | goto cleanup; |
| 302 | |
| 303 | strvec_pushl(&make_script_args, "", revisions, NULL); |
| 304 | if (opts->restrict_revision) |
| 305 | strvec_pushf(&make_script_args, "^%s", |
| 306 | oid_to_hex(&opts->restrict_revision->object.oid)); |
| 307 | |
| 308 | ret = sequencer_make_script(the_repository, &todo_list.buf, |
| 309 | &make_script_args, flags); |
| 310 | if (ret) { |
| 311 | error(_("could not generate todo list")); |
| 312 | goto cleanup; |
| 313 | } |
| 314 | |
| 315 | if (init_basic_state(&replay, |
| 316 | opts->head_name ? opts->head_name : "detached HEAD", |
| 317 | opts->onto, &opts->orig_head->object.oid)) |
| 318 | goto cleanup; |
| 319 | |
| 320 | if (!opts->upstream && opts->squash_onto) |
| 321 | write_file(path_squash_onto(), "%s\n", |
| 322 | oid_to_hex(opts->squash_onto)); |
| 323 | |
| 324 | discard_index(the_repository->index); |
| 325 | if (todo_list_parse_insn_buffer(the_repository, &replay, |
| 326 | todo_list.buf.buf, &todo_list)) |
| 327 | BUG("unusable todo list"); |
| 328 | |
| 329 | ret = complete_action(the_repository, &replay, flags, |
| 330 | shortrevisions, opts->onto_name, opts->onto, |
| 331 | &opts->orig_head->object.oid, &opts->exec, |
| 332 | opts->autosquash, opts->update_refs, &todo_list); |
| 333 | |
| 334 | cleanup: |
| 335 | replay_opts_release(&replay); |
| 336 | free(revisions); |
| 337 | free(shortrevisions); |
| 338 | todo_list_release(&todo_list); |
| 339 | strvec_clear(&make_script_args); |
| 340 | |
| 341 | return ret; |
| 342 | } |
| 343 | |
| 344 | static int run_sequencer_rebase(struct rebase_options *opts) |
| 345 | { |
no test coverage detected