Skip to content

Commit 1d18826

Browse files
phillipwoodgitster
authored andcommitted
rebase: use lookup_commit_reference_by_name()
peel_committish() appears to have been copied from the scripted rebase but it duplicates the functionality of lookup_commit_reference_by_name() so lets use that instead. Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 35f070b commit 1d18826

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

builtin/rebase.c

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -763,17 +763,6 @@ static int finish_rebase(struct rebase_options *opts)
763763
return ret;
764764
}
765765

766-
static struct commit *peel_committish(const char *name)
767-
{
768-
struct object *obj;
769-
struct object_id oid;
770-
771-
if (get_oid(name, &oid))
772-
return NULL;
773-
obj = parse_object(the_repository, &oid);
774-
return (struct commit *)peel_to_type(name, 0, obj, OBJ_COMMIT);
775-
}
776-
777766
static void add_var(struct strbuf *buf, const char *name, const char *value)
778767
{
779768
if (!value)
@@ -1846,7 +1835,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
18461835
if (!strcmp(options.upstream_name, "-"))
18471836
options.upstream_name = "@{-1}";
18481837
}
1849-
options.upstream = peel_committish(options.upstream_name);
1838+
options.upstream =
1839+
lookup_commit_reference_by_name(options.upstream_name);
18501840
if (!options.upstream)
18511841
die(_("invalid upstream '%s'"), options.upstream_name);
18521842
options.upstream_arg = options.upstream_name;
@@ -1889,7 +1879,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
18891879
options.onto = lookup_commit_or_die(&merge_base,
18901880
options.onto_name);
18911881
} else {
1892-
options.onto = peel_committish(options.onto_name);
1882+
options.onto =
1883+
lookup_commit_reference_by_name(options.onto_name);
18931884
if (!options.onto)
18941885
die(_("Does not point to a valid commit '%s'"),
18951886
options.onto_name);

0 commit comments

Comments
 (0)