path: root/parse-options-cb.c
diff options
authorPhillip Wood <>2019-04-17 14:30:39 (GMT)
committerJunio C Hamano <>2019-04-19 08:32:10 (GMT)
commit7d3488eb893ba53186770181171ee8ebc8100e18 (patch)
treef08740a8f4a0914100376aafa146816577768079 /parse-options-cb.c
parentc44c24621da1cf45e2525b42d90982c78bffc207 (diff)
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 <>
Diffstat (limited to 'parse-options-cb.c')
1 files changed, 17 insertions, 0 deletions
diff --git a/parse-options-cb.c b/parse-options-cb.c
index 2733393..2206eb7 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;