| 3511 | } |
| 3512 | |
| 3513 | int sequencer_rollback(struct repository *r, struct replay_opts *opts) |
| 3514 | { |
| 3515 | FILE *f; |
| 3516 | struct object_id oid; |
| 3517 | struct strbuf buf = STRBUF_INIT; |
| 3518 | const char *p; |
| 3519 | |
| 3520 | f = fopen(git_path_head_file(), "r"); |
| 3521 | if (!f && errno == ENOENT) { |
| 3522 | /* |
| 3523 | * There is no multiple-cherry-pick in progress. |
| 3524 | * If CHERRY_PICK_HEAD or REVERT_HEAD indicates |
| 3525 | * a single-cherry-pick in progress, abort that. |
| 3526 | */ |
| 3527 | return rollback_single_pick(r); |
| 3528 | } |
| 3529 | if (!f) |
| 3530 | return error_errno(_("cannot open '%s'"), git_path_head_file()); |
| 3531 | if (strbuf_getline_lf(&buf, f)) { |
| 3532 | error(_("cannot read '%s': %s"), git_path_head_file(), |
| 3533 | ferror(f) ? strerror(errno) : _("unexpected end of file")); |
| 3534 | fclose(f); |
| 3535 | goto fail; |
| 3536 | } |
| 3537 | fclose(f); |
| 3538 | if (parse_oid_hex(buf.buf, &oid, &p) || *p != '\0') { |
| 3539 | error(_("stored pre-cherry-pick HEAD file '%s' is corrupt"), |
| 3540 | git_path_head_file()); |
| 3541 | goto fail; |
| 3542 | } |
| 3543 | if (is_null_oid(&oid)) { |
| 3544 | error(_("cannot abort from a branch yet to be born")); |
| 3545 | goto fail; |
| 3546 | } |
| 3547 | |
| 3548 | if (!rollback_is_safe()) { |
| 3549 | /* Do not error, just do not rollback */ |
| 3550 | warning(_("You seem to have moved HEAD. " |
| 3551 | "Not rewinding, check your HEAD!")); |
| 3552 | } else |
| 3553 | if (reset_merge(&oid)) |
| 3554 | goto fail; |
| 3555 | strbuf_release(&buf); |
| 3556 | return sequencer_remove_state(opts); |
| 3557 | fail: |
| 3558 | strbuf_release(&buf); |
| 3559 | return -1; |
| 3560 | } |
| 3561 | |
| 3562 | int sequencer_skip(struct repository *r, struct replay_opts *opts) |
| 3563 | { |
no test coverage detected