From ca5120c339de883c3f22161316416c91655651ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Fri, 1 Jan 2021 00:55:12 +0100 Subject: [PATCH] rebase: verify commit parameter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the user specifies a base commit to switch to, check if it actually references a commit right away to avoid getting confused later on when it turns out to be an invalid object. Reported-by: LeSeulArtichaut Signed-off-by: René Scharfe Signed-off-by: Junio C Hamano --- builtin/rebase.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/builtin/rebase.c b/builtin/rebase.c index eeca53382f..d0f112ffc2 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -1906,7 +1906,9 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) die_if_checked_out(buf.buf, 1); options.head_name = xstrdup(buf.buf); /* If not is it a valid ref (branch or commit)? */ - } else if (!get_oid(branch_name, &options.orig_head)) + } else if (!get_oid(branch_name, &options.orig_head) && + lookup_commit_reference(the_repository, + &options.orig_head)) options.head_name = NULL; else die(_("fatal: no such branch/commit '%s'"),