@matheusbsbs / matheus-bagliano / commits / 240fc04f81
Fork 0

builtin/rebase: remove a call to get_oid() on `options.switch_to'

When `options.switch_to' is set, `options.orig_head' is populated right after with the object name the ref/commit argument points at. Therefore, there is no need to parse `switch_to' again. Signed-off-by: Alban Gruin <alban.gruin@gmail.com> Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Alban Gruin committed Jan 21, 2020 at 20:32 UTC 240fc04f81fcc6c646ec08bfab4662bb09e44c50
1 file changed +1 -9
builtin/rebase.c
+1 -9
@@ -2064,19 +2064,11 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
2064 if (!(options.flags & REBASE_FORCE)) {
2065 /* Lazily switch to the target branch if needed... */
2066 if (options.switch_to) {
2067 - struct object_id oid;
2068 -
2069 - if (get_oid(options.switch_to, &oid) < 0) {
2070 - ret = !!error(_("could not parse '%s'"),
2071 - options.switch_to);
2072 - goto cleanup;
2073 - }
2074 -
2067 strbuf_reset(&buf);
2068 strbuf_addf(&buf, "%s: checkout %s",
2069 getenv(GIT_REFLOG_ACTION_ENVIRONMENT),
2070 options.switch_to);
2079 - if (reset_head(&oid, "checkout",
2071 + if (reset_head(&options.orig_head, "checkout",
2072 options.head_name,
2073 RESET_HEAD_RUN_POST_CHECKOUT_HOOK,
2074 NULL, buf.buf) < 0) {