From 7d3488eb893ba53186770181171ee8ebc8100e18 Mon Sep 17 00:00:00 2001 From: Phillip Wood Date: Wed, 17 Apr 2019 15:30:39 +0100 Subject: rebase -i: use struct commit when parsing options This is in preparation for using `struct rebase_options` when parsing options in cmd_rebase__interactive(). Using a string for onto, restrict_revision and upstream, was a hangover from the scripted version of rebase. The functions that use these variables are updated to take a `struct commit`. Signed-off-by: Phillip Wood Signed-off-by: Junio C Hamano --- parse-options-cb.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'parse-options-cb.c') diff --git a/parse-options-cb.c b/parse-options-cb.c index 2733393546..2206eb763c 100644 --- a/parse-options-cb.c +++ b/parse-options-cb.c @@ -96,6 +96,23 @@ int parse_opt_commits(const struct option *opt, const char *arg, int unset) return 0; } +int parse_opt_commit(const struct option *opt, const char *arg, int unset) +{ + struct object_id oid; + struct commit *commit; + struct commit **target = opt->value; + + if (!arg) + return -1; + if (get_oid(arg, &oid)) + return error("malformed object name %s", arg); + commit = lookup_commit_reference(the_repository, &oid); + if (!commit) + return error("no such commit %s", arg); + *target = commit; + return 0; +} + int parse_opt_object_name(const struct option *opt, const char *arg, int unset) { struct object_id oid; -- cgit v1.2.3 From 338985317eb84007f0d08979e751cbf32a375a52 Mon Sep 17 00:00:00 2001 From: Phillip Wood Date: Wed, 17 Apr 2019 15:30:40 +0100 Subject: rebase -i: use struct object_id for squash_onto More preparation for using `struct rebase_options` in cmd_rebase__interactive(). Using a string was a hangover from the scripted version of rebase, update the functions that use `squash_onto` to take a `sturct object_id`. Signed-off-by: Phillip Wood Signed-off-by: Junio C Hamano --- parse-options-cb.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'parse-options-cb.c') diff --git a/parse-options-cb.c b/parse-options-cb.c index 2206eb763c..28ad5cd94b 100644 --- a/parse-options-cb.c +++ b/parse-options-cb.c @@ -129,6 +129,23 @@ int parse_opt_object_name(const struct option *opt, const char *arg, int unset) return 0; } +int parse_opt_object_id(const struct option *opt, const char *arg, int unset) +{ + struct object_id oid; + struct object_id *target = opt->value; + + if (unset) { + *target = null_oid; + return 0; + } + if (!arg) + return -1; + if (get_oid(arg, &oid)) + return error(_("malformed object name '%s'"), arg); + *target = oid; + return 0; +} + int parse_opt_tertiary(const struct option *opt, const char *arg, int unset) { int *target = opt->value; -- cgit v1.2.3