]> git.ipfire.org Git - thirdparty/git.git/commitdiff
rebase: verify commit parameter
authorRené Scharfe <l.s.r@web.de>
Thu, 31 Dec 2020 23:55:12 +0000 (00:55 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 4 Jan 2021 23:24:13 +0000 (15:24 -0800)
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 <leseulartichaut@gmail.com>
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/rebase.c

index eeca53382f793356e5f4a0114de062fb3926e236..d0f112ffc254ea8fa05c77623fa40c27d1961f1a 100644 (file)
@@ -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'"),