git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] rebase: verify commit parameter

From
René Scharfe <l.s.r@web.de>
Date
Dec 31, 2020, 23:55 UTC
Message-ID
<49e25873-90e0-8ae2-7a40-01bec3f99e5f@web.de>
In-Reply-To
<ECF77241-0631-45D6-8B79-4250EE777A5D@gmail.com>

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>
---
git-legacy-rebase.sh also accepted non-commits, if I read the code
correctly.
 builtin/rebase.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/builtin/rebase.c b/builtin/rebase.c
index 19c7b377aa..840dbd7eb7 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -1917,7 +1917,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'"),
--
2.30.0
Previous: LeSeulArtichaut
Message 2 of 2 in “[Bug report] Git gets stuck in rebase mode”
  1. LeSeulArtichautDec 30, 2020
  2. rebase: verify commit parameterRené Scharfe, Dec 31, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.