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>

Phillip Wood committed Sep 21, 2021 at 10:24 UTC 1d188263e0847fd356d7ff245c32e8ebb29115b3
1 file changed +4 -13
builtin/rebase.c
+4 -13
@@ -763,17 +763,6 @@ static int finish_rebase(struct rebase_options *opts)
763 return ret;
764 }
765
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 -
766 static void add_var(struct strbuf *buf, const char *name, const char *value)
767 {
768 if (!value)
@@ -1846,7 +1835,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1835 if (!strcmp(options.upstream_name, "-"))
1836 options.upstream_name = "@{-1}";
1837 }
1849 - options.upstream = peel_committish(options.upstream_name);
1838 + options.upstream =
1839 + lookup_commit_reference_by_name(options.upstream_name);
1840 if (!options.upstream)
1841 die(_("invalid upstream '%s'"), options.upstream_name);
1842 options.upstream_arg = options.upstream_name;
@@ -1889,7 +1879,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1879 options.onto = lookup_commit_or_die(&merge_base,
1880 options.onto_name);
1881 } else {
1892 - options.onto = peel_committish(options.onto_name);
1882 + options.onto =
1883 + lookup_commit_reference_by_name(options.onto_name);
1884 if (!options.onto)
1885 die(_("Does not point to a valid commit '%s'"),
1886 options.onto_name);