git-rev-parse --verify could be friendlier
- From
- linux@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