static int revert_or_cherry_pick(int argc, const char **argv) { struct rev_info revs; git_config(git_default_config, NULL); me = action == REVERT ? "revert" : "cherry-pick"; setenv(GIT_REFLOG_ACTION, me, 0); parse_args(argc, argv); if (allow_ff) { if (signoff) die("cherry-pick --ff cannot be used with --signoff"); if (no_commit) die("cherry-pick --ff cannot be used with --no-commit"); if (no_replay) die("cherry-pick --ff cannot be used with -x"); if (edit) die("cherry-pick --ff cannot be used with --edit"); } if (read_cache() < 0) die("git %s: failed to read the index", me); prepare_revs(&revs); while ((commit = get_revision(&revs))) { int res = do_pick_commit(); if (res) return res; } return 0; }
static int walk_revs_populate_todo(struct todo_list *todo_list, struct replay_opts *opts) { enum todo_command command = opts->action == REPLAY_PICK ? TODO_PICK : TODO_REVERT; const char *command_string = todo_command_strings[command]; struct commit *commit; if (prepare_revs(opts)) return -1; while ((commit = get_revision(opts->revs))) { struct todo_item *item = append_new_todo(todo_list); const char *commit_buffer = get_commit_buffer(commit, NULL); const char *subject; int subject_len; item->command = command; item->commit = commit; item->arg = NULL; item->arg_len = 0; item->offset_in_buf = todo_list->buf.len; subject_len = find_commit_subject(commit_buffer, &subject); strbuf_addf(&todo_list->buf, "%s %s %.*s\n", command_string, short_commit_name(commit), subject_len, subject); unuse_commit_buffer(commit, commit_buffer); } return 0; }
static void walk_revs_populate_todo(struct commit_list **todo_list, struct replay_opts *opts) { struct commit *commit; struct commit_list **next; prepare_revs(opts); next = todo_list; while ((commit = get_revision(opts->revs))) next = commit_list_append(commit, next); }