MCPcopy Index your code
hub / github.com/git/git / sequencer_rollback

Function sequencer_rollback

sequencer.c:3513–3560  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3511}
3512
3513int 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);
3557fail:
3558 strbuf_release(&buf);
3559 return -1;
3560}
3561
3562int sequencer_skip(struct repository *r, struct replay_opts *opts)
3563{

Callers 1

run_sequencerFunction · 0.85

Calls 11

rollback_single_pickFunction · 0.85
error_errnoFunction · 0.85
strbuf_getline_lfFunction · 0.85
errorFunction · 0.85
parse_oid_hexFunction · 0.85
is_null_oidFunction · 0.85
rollback_is_safeFunction · 0.85
warningFunction · 0.85
reset_mergeFunction · 0.85
strbuf_releaseFunction · 0.85
sequencer_remove_stateFunction · 0.85

Tested by

no test coverage detected