static int sequencer_continue(struct replay_opts *opts, int skip) { struct commit_list *todo_list = NULL; if (!file_exists(git_path(SEQ_TODO_FILE))) return continue_single_pick(); read_populate_opts(&opts); read_populate_todo(&todo_list, opts); if (opts->action == REPLAY_PICK) load_rewritten(&rewritten, git_path(SEQ_REWR_FILE)); /* Verify that the conflict has been resolved */ if (file_exists(git_path("CHERRY_PICK_HEAD")) || file_exists(git_path("REVERT_HEAD"))) { int ret = continue_single_pick(); if (ret) return ret; } if (index_differs_from("HEAD", 0)) return error_dirty_index(opts); if (opts->action == REPLAY_PICK && !skip) { unsigned char to[20]; if (!read_ref("HEAD", to)) add_rewritten(&rewritten, todo_list->item->object.sha1, to); } todo_list = todo_list->next; return pick_commits(todo_list, opts); }
int sequencer_continue(struct replay_opts *opts) { struct todo_list todo_list = TODO_LIST_INIT; int res; if (read_and_refresh_cache(opts)) return -1; if (!file_exists(get_todo_path(opts))) return continue_single_pick(); if (read_populate_opts(opts)) return -1; if ((res = read_populate_todo(&todo_list, opts))) goto release_todo_list; /* Verify that the conflict has been resolved */ if (file_exists(git_path_cherry_pick_head()) || file_exists(git_path_revert_head())) { res = continue_single_pick(); if (res) goto release_todo_list; } if (index_differs_from("HEAD", 0, 0)) { res = error_dirty_index(opts); goto release_todo_list; } todo_list.current++; res = pick_commits(&todo_list, opts); release_todo_list: todo_list_release(&todo_list); return res; }
static int pick_revisions(struct replay_opts *opts) { struct commit_list *todo_list = NULL; unsigned char sha1[20]; read_and_refresh_cache(opts); /* * Decide what to do depending on the arguments; a fresh * cherry-pick should be handled differently from an existing * one that is being continued */ if (opts->subcommand == REPLAY_RESET) { remove_sequencer_state(1); return 0; } else if (opts->subcommand == REPLAY_CONTINUE) { if (!file_exists(git_path(SEQ_TODO_FILE))) goto error; read_populate_opts(&opts); read_populate_todo(&todo_list, opts); /* Verify that the conflict has been resolved */ if (!index_differs_from("HEAD", 0)) todo_list = todo_list->next; } else { /* * Start a new cherry-pick/ revert sequence; but * first, make sure that an existing one isn't in * progress */ walk_revs_populate_todo(&todo_list, opts); if (create_seq_dir() < 0) { error(_("A cherry-pick or revert is in progress.")); advise(_("Use --continue to continue the operation")); advise(_("or --reset to forget about it")); return -1; } if (get_sha1("HEAD", sha1)) { if (opts->action == REVERT) return error(_("Can't revert as initial commit")); return error(_("Can't cherry-pick into empty head")); } save_head(sha1_to_hex(sha1)); save_opts(opts); } return pick_commits(todo_list, opts); error: return error(_("No %s in progress"), action_name(opts)); }
static int sequencer_continue(struct replay_opts *opts) { struct commit_list *todo_list = NULL; if (!file_exists(git_path_todo_file())) return continue_single_pick(); read_populate_opts(&opts); read_populate_todo(&todo_list, opts); /* Verify that the conflict has been resolved */ if (file_exists(git_path_cherry_pick_head()) || file_exists(git_path_revert_head())) { int ret = continue_single_pick(); if (ret) return ret; } if (index_differs_from("HEAD", 0)) return error_dirty_index(opts); todo_list = todo_list->next; return pick_commits(todo_list, opts); }
int sequencer_pick_revisions(struct replay_opts *opts) { struct commit_list *todo_list = NULL; unsigned char sha1[20]; if (opts->subcommand == REPLAY_NONE) assert(opts->revs); read_and_refresh_cache(opts); /* * Decide what to do depending on the arguments; a fresh * cherry-pick should be handled differently from an existing * one that is being continued */ if (opts->subcommand == REPLAY_REMOVE_STATE) { remove_sequencer_state(); return 0; } if (opts->subcommand == REPLAY_ROLLBACK) return sequencer_rollback(opts); if (opts->subcommand == REPLAY_CONTINUE) return sequencer_continue(opts); /* * If we were called as "git cherry-pick <commit>", just * cherry-pick/revert it, set CHERRY_PICK_HEAD / * REVERT_HEAD, and don't touch the sequencer state. * This means it is possible to cherry-pick in the middle * of a cherry-pick sequence. */ if (opts->revs->cmdline.nr == 1 && opts->revs->cmdline.rev->whence == REV_CMD_REV && opts->revs->no_walk && !opts->revs->cmdline.rev->flags) { struct commit *cmit; if (prepare_revision_walk(opts->revs)) die(_("revision walk setup failed")); cmit = get_revision(opts->revs); if (!cmit || get_revision(opts->revs)) die("BUG: expected exactly one commit from walk"); return single_pick(cmit, opts); } /* * Start a new cherry-pick/ revert sequence; but * first, make sure that an existing one isn't in * progress */ walk_revs_populate_todo(&todo_list, opts); if (create_seq_dir() < 0) return -1; if (get_sha1("HEAD", sha1)) { if (opts->action == REPLAY_REVERT) return error(_("Can't revert as initial commit")); return error(_("Can't cherry-pick into empty head")); } save_head(sha1_to_hex(sha1)); save_opts(opts); return pick_commits(todo_list, opts); }