return res;
}
-static int get_revision_ranges(const char *upstream, const char *onto,
+static int get_revision_ranges(struct commit *upstream, struct commit *onto,
const char **head_hash,
char **revisions, char **shortrevisions)
{
- const char *base_rev = upstream ? upstream : onto, *shorthead;
+ struct commit *base_rev = upstream ? upstream : onto;
+ const char *shorthead;
struct object_id orig_head;
if (get_oid("HEAD", &orig_head))
return error(_("no HEAD?"));
*head_hash = find_unique_abbrev(&orig_head, GIT_MAX_HEXSZ);
- *revisions = xstrfmt("%s...%s", base_rev, *head_hash);
+ *revisions = xstrfmt("%s...%s", oid_to_hex(&base_rev->object.oid),
+ *head_hash);
shorthead = find_unique_abbrev(&orig_head, DEFAULT_ABBREV);
if (upstream) {
const char *shortrev;
- struct object_id rev_oid;
- get_oid(base_rev, &rev_oid);
- shortrev = find_unique_abbrev(&rev_oid, DEFAULT_ABBREV);
+ shortrev = find_unique_abbrev(&base_rev->object.oid,
+ DEFAULT_ABBREV);
*shortrevisions = xstrfmt("%s..%s", shortrev, shorthead);
} else
}
static int init_basic_state(struct replay_opts *opts, const char *head_name,
- const char *onto, const char *orig_head)
+ struct commit *onto, const char *orig_head)
{
FILE *interactive;
}
static int do_interactive_rebase(struct replay_opts *opts, unsigned flags,
- const char *switch_to, const char *upstream,
- const char *onto, const char *onto_name,
+ const char *switch_to, struct commit *upstream,
+ struct commit *onto, const char *onto_name,
const char *squash_onto, const char *head_name,
- const char *restrict_revision, char *raw_strategies,
+ struct commit *restrict_revision, char *raw_strategies,
struct string_list *commands, unsigned autosquash)
{
int ret;
argv_array_pushl(&make_script_args, "", revisions, NULL);
if (restrict_revision)
- argv_array_push(&make_script_args, restrict_revision);
+ argv_array_push(&make_script_args,
+ oid_to_hex(&restrict_revision->object.oid));
ret = sequencer_make_script(the_repository, &todo_list.buf,
make_script_args.argc, make_script_args.argv,
struct replay_opts opts = REPLAY_OPTS_INIT;
unsigned flags = 0, keep_empty = 0, rebase_merges = 0, autosquash = 0;
int abbreviate_commands = 0, rebase_cousins = -1, ret = 0;
- const char *onto = NULL, *onto_name = NULL, *restrict_revision = NULL,
- *squash_onto = NULL, *upstream = NULL, *head_name = NULL,
+ const char *onto_name = NULL,
+ *squash_onto = NULL, *head_name = NULL,
*switch_to = NULL, *cmd = NULL;
+ struct commit *onto = NULL, *upstream = NULL, *restrict_revision = NULL;
struct string_list commands = STRING_LIST_INIT_DUP;
char *raw_strategies = NULL;
enum {
N_("rearrange fixup/squash lines"), REARRANGE_SQUASH),
OPT_CMDMODE(0, "add-exec-commands", &command,
N_("insert exec commands in todo list"), ADD_EXEC),
- OPT_STRING(0, "onto", &onto, N_("onto"), N_("onto")),
- OPT_STRING(0, "restrict-revision", &restrict_revision,
- N_("restrict-revision"), N_("restrict revision")),
+ { OPTION_CALLBACK, 0, "onto", &onto, N_("onto"), N_("onto"),
+ PARSE_OPT_NONEG, parse_opt_commit, 0 },
+ { OPTION_CALLBACK, 0, "restrict-revision", &restrict_revision,
+ N_("restrict-revision"), N_("restrict revision"),
+ PARSE_OPT_NONEG, parse_opt_commit, 0 },
OPT_STRING(0, "squash-onto", &squash_onto, N_("squash-onto"),
N_("squash onto")),
- OPT_STRING(0, "upstream", &upstream, N_("upstream"),
- N_("the upstream commit")),
+ { OPTION_CALLBACK, 0, "upstream", &upstream, N_("upstream"),
+ N_("the upstream commit"), PARSE_OPT_NONEG, parse_opt_commit,
+ 0 },
OPT_STRING(0, "head-name", &head_name, N_("head-name"), N_("head name")),
{ OPTION_STRING, 'S', "gpg-sign", &opts.gpg_sign, N_("key-id"),
N_("GPG-sign commits"),
}
int write_basic_state(struct replay_opts *opts, const char *head_name,
- const char *onto, const char *orig_head)
+ struct commit *onto, const char *orig_head)
{
const char *quiet = getenv("GIT_QUIET");
if (head_name)
write_file(rebase_path_head_name(), "%s\n", head_name);
if (onto)
- write_file(rebase_path_onto(), "%s\n", onto);
+ write_file(rebase_path_onto(), "%s\n",
+ oid_to_hex(&onto->object.oid));
if (orig_head)
write_file(rebase_path_orig_head(), "%s\n", orig_head);
}
static int checkout_onto(struct repository *r, struct replay_opts *opts,
- const char *onto_name, const char *onto,
+ const char *onto_name, const struct object_id *onto,
const char *orig_head)
{
struct object_id oid;
if (get_oid(orig_head, &oid))
return error(_("%s: not a valid OID"), orig_head);
- if (run_git_checkout(r, opts, onto, action)) {
+ if (run_git_checkout(r, opts, oid_to_hex(onto), action)) {
apply_autostash(opts);
sequencer_remove_state(opts);
return error(_("could not detach HEAD"));
int complete_action(struct repository *r, struct replay_opts *opts, unsigned flags,
const char *shortrevisions, const char *onto_name,
- const char *onto, const char *orig_head, struct string_list *commands,
- unsigned autosquash, struct todo_list *todo_list)
+ struct commit *onto, const char *orig_head,
+ struct string_list *commands, unsigned autosquash,
+ struct todo_list *todo_list)
{
const char *shortonto, *todo_file = rebase_path_todo();
struct todo_list new_todo = TODO_LIST_INIT;
struct strbuf *buf = &todo_list->buf;
- struct object_id oid;
+ struct object_id oid = onto->object.oid;
int res;
- get_oid(onto, &oid);
shortonto = find_unique_abbrev(&oid, DEFAULT_ABBREV);
if (buf->len == 0) {
if (todo_list_parse_insn_buffer(r, new_todo.buf.buf, &new_todo) ||
todo_list_check(todo_list, &new_todo)) {
fprintf(stderr, _(edit_todo_list_advice));
- checkout_onto(r, opts, onto_name, onto, orig_head);
+ checkout_onto(r, opts, onto_name, &onto->object.oid, orig_head);
todo_list_release(&new_todo);
return -1;
todo_list_release(&new_todo);
- if (checkout_onto(r, opts, onto_name, oid_to_hex(&oid), orig_head))
+ if (checkout_onto(r, opts, onto_name, &oid, orig_head))
return -1;
if (require_clean_work_tree(r, "rebase", "", 1, 1))