Skip to content

Commit

Permalink
More useful/hinting error messages in git-checkout
Browse files Browse the repository at this point in the history
Signed-off-by: Josef Weidendorfer <Josef.Weidendorfer@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Josef Weidendorfer authored and Junio C Hamano committed Feb 16, 2006
1 parent 6c5c62f commit babfaf8
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions git-checkout.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ while [ "$#" != "0" ]; do
[ -e "$GIT_DIR/refs/heads/$newbranch" ] &&
die "git checkout: branch $newbranch already exists"
git-check-ref-format "heads/$newbranch" ||
die "we do not like '$newbranch' as a branch name."
die "git checkout: we do not like '$newbranch' as a branch name."
;;
"-f")
force=1
Expand Down Expand Up @@ -75,9 +75,15 @@ done

if test "$#" -ge 1
then
hint=
if test "$#" -eq 1
then
hint="
Did you intend to checkout '$@' which can not be resolved as commit?"
fi
if test '' != "$newbranch$force$merge"
then
die "updating paths and switching branches or forcing are incompatible."
die "git checkout: updating paths is incompatible with switching branches/forcing$hint"
fi
if test '' != "$new"
then
Expand Down Expand Up @@ -117,7 +123,8 @@ fi

[ -z "$branch$newbranch" ] &&
[ "$new" != "$old" ] &&
die "git checkout: you need to specify a new branch name"
die "git checkout: to checkout the requested commit you need to specify
a name for a new branch which is created and switched to"

if [ "$force" ]
then
Expand Down

0 comments on commit babfaf8

Please sign in to comment.