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

Function sequencer_skip

sequencer.c:3562–3625  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3560}
3561
3562int sequencer_skip(struct repository *r, struct replay_opts *opts)
3563{
3564 enum replay_action action = -1;
3565 sequencer_get_last_command(r, &action);
3566
3567 /*
3568 * Check whether the subcommand requested to skip the commit is actually
3569 * in progress and that it's safe to skip the commit.
3570 *
3571 * opts->action tells us which subcommand requested to skip the commit.
3572 * If the corresponding .git/<ACTION>_HEAD exists, we know that the
3573 * action is in progress and we can skip the commit.
3574 *
3575 * Otherwise we check that the last instruction was related to the
3576 * particular subcommand we're trying to execute and barf if that's not
3577 * the case.
3578 *
3579 * Finally we check that the rollback is "safe", i.e., has the HEAD
3580 * moved? In this case, it doesn't make sense to "reset the merge" and
3581 * "skip the commit" as the user already handled this by committing. But
3582 * we'd not want to barf here, instead give advice on how to proceed. We
3583 * only need to check that when .git/<ACTION>_HEAD doesn't exist because
3584 * it gets removed when the user commits, so if it still exists we're
3585 * sure the user can't have committed before.
3586 */
3587 switch (opts->action) {
3588 case REPLAY_REVERT:
3589 if (!refs_ref_exists(get_main_ref_store(r), "REVERT_HEAD")) {
3590 if (action != REPLAY_REVERT)
3591 return error(_("no revert in progress"));
3592 if (!rollback_is_safe())
3593 goto give_advice;
3594 }
3595 break;
3596 case REPLAY_PICK:
3597 if (!refs_ref_exists(get_main_ref_store(r),
3598 "CHERRY_PICK_HEAD")) {
3599 if (action != REPLAY_PICK)
3600 return error(_("no cherry-pick in progress"));
3601 if (!rollback_is_safe())
3602 goto give_advice;
3603 }
3604 break;
3605 default:
3606 BUG("unexpected action in sequencer_skip");
3607 }
3608
3609 if (skip_single_pick())
3610 return error(_("failed to skip the commit"));
3611 if (!is_directory(git_path_seq_dir()))
3612 return 0;
3613
3614 return sequencer_continue(r, opts);
3615
3616give_advice:
3617 error(_("there is nothing to skip"));
3618
3619 if (advice_enabled(ADVICE_RESOLVE_CONFLICT)) {

Callers 1

run_sequencerFunction · 0.85

Calls 10

refs_ref_existsFunction · 0.85
get_main_ref_storeFunction · 0.85
errorFunction · 0.85
rollback_is_safeFunction · 0.85
skip_single_pickFunction · 0.85
is_directoryFunction · 0.85
sequencer_continueFunction · 0.85
advice_enabledFunction · 0.85
adviseFunction · 0.85

Tested by

no test coverage detected