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

git-rev-parse --verify could be friendlier

From
Llinux@horizon.com <linux@horizon.com>
Date
Oct 10, 2007, 14:24 UTC
Message-ID
<20071010142417.8892.qmail@science.horizon.com>

I accidentally typed "git rebase --onto typo ancestor", where "typo" was a branch that didn't exist.

The error message (which is actually generated by git-rev-parse --verify) is "fatal: Needed a single revision".

This is perhaps a bit obscure. For starters, it doesn't even tell me which argument is problematic.

If I do "git rebase --onto dest typo", I at least get fatal: Needed a single revision invalid upstream typo

Something like the following would certainly help, but perhaps git-rev-parse could be slightly more forthcoming, too?

diff --git a/git-rebase b/git-rebase
index 058fcac..b14ac95 100755
--- a/git-rebase
+++ b/git-rebase
@@ -268,7 +268,8 @@ upstream=`git rev-parse --verify "${upstream_name}^0"` ||
 
 # Make sure the branch to rebase onto is valid.
 onto_name=${newbase-"$upstream_name"}
-onto=$(git rev-parse --verify "${onto_name}^0") || exit
+onto=$(git rev-parse --verify "${onto_name}^0") ||
+    die "invalid target $upstream_name"
 
 # If a hook exists, give it a chance to interrupt
 if test -x "$GIT_DIR/hooks/pre-rebase"
@@ -294,7 +295,8 @@ case "$#" in
 	fi
 	;;
 esac
-branch=$(git rev-parse --verify "${branch_name}^0") || exit
+branch=$(git rev-parse --verify "${branch_name}^0") ||
+    die "invalid branch name $upstream_name"
 
 # Now we are rebasing commits $upstream..$branch on top of $onto
 
Next: Matthieu Moy
Message 1 of 2 in “git-rev-parse --verify could be friendlier”
  1. linux@horizon.comOct 10, 2007
  2. Matthieu MoyOct 10, 2007

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.