Skip to content

Commit ca5120c

Browse files
rscharfegitster
authored andcommitted
rebase: verify commit parameter
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 <[email protected]> Signed-off-by: René Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 898f807 commit ca5120c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

builtin/rebase.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1906,7 +1906,9 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
19061906
die_if_checked_out(buf.buf, 1);
19071907
options.head_name = xstrdup(buf.buf);
19081908
/* If not is it a valid ref (branch or commit)? */
1909-
} else if (!get_oid(branch_name, &options.orig_head))
1909+
} else if (!get_oid(branch_name, &options.orig_head) &&
1910+
lookup_commit_reference(the_repository,
1911+
&options.orig_head))
19101912
options.head_name = NULL;
19111913
else
19121914
die(_("fatal: no such branch/commit '%s'"),

0 commit comments

Comments
 (0)