| 427 | } |
| 428 | |
| 429 | int sequencer_remove_state(struct replay_opts *opts) |
| 430 | { |
| 431 | struct strbuf buf = STRBUF_INIT; |
| 432 | int ret = 0; |
| 433 | |
| 434 | if (is_rebase_i(opts) && |
| 435 | strbuf_read_file(&buf, rebase_path_refs_to_delete(), 0) > 0) { |
| 436 | char *p = buf.buf; |
| 437 | while (*p) { |
| 438 | char *eol = strchr(p, '\n'); |
| 439 | if (eol) |
| 440 | *eol = '\0'; |
| 441 | if (refs_delete_ref(get_main_ref_store(the_repository), "(rebase) cleanup", p, NULL, 0) < 0) { |
| 442 | warning(_("could not delete '%s'"), p); |
| 443 | ret = -1; |
| 444 | } |
| 445 | if (!eol) |
| 446 | break; |
| 447 | p = eol + 1; |
| 448 | } |
| 449 | } |
| 450 | |
| 451 | strbuf_reset(&buf); |
| 452 | strbuf_addstr(&buf, get_dir(opts)); |
| 453 | if (remove_dir_recursively(&buf, 0)) |
| 454 | ret = error(_("could not remove '%s'"), buf.buf); |
| 455 | strbuf_release(&buf); |
| 456 | |
| 457 | return ret; |
| 458 | } |
| 459 | |
| 460 | static const char *action_name(const struct replay_opts *opts) |
| 461 | { |
no test coverage detected