More useful/hinting error messages in git-checkout
Signed-off-by: Josef Weidendorfer <Josef.Weidendorfer@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
Josef Weidendorfer committed
Feb 15, 2006 at 20:22 UTC
babfaf8dee0baa09c56d1a2ec5623b60d900518b
1 file changed
+10
-3
git-checkout.sh
+10
-3
@@ -22,7 +22,7 @@ while [ "$#" != "0" ]; do
22
[ -e "$GIT_DIR/refs/heads/$newbranch" ] &&
23
die "git checkout: branch $newbranch already exists"
24
git-check-ref-format "heads/$newbranch" ||
25
- die "we do not like '$newbranch' as a branch name."
25
+ die "git checkout: we do not like '$newbranch' as a branch name."
26
;;
27
"-f")
28
force=1
@@ -75,9 +75,15 @@ done
75
76
if test "$#" -ge 1
77
then
78
+ hint=
79
+ if test "$#" -eq 1
80
+ then
81
+ hint="
82
+Did you intend to checkout '$@' which can not be resolved as commit?"
83
+ fi
84
if test '' != "$newbranch$force$merge"
85
then
80
- die "updating paths and switching branches or forcing are incompatible."
86
+ die "git checkout: updating paths is incompatible with switching branches/forcing$hint"
87
fi
88
if test '' != "$new"
89
then
@@ -117,7 +123,8 @@ fi
123
124
[ -z "$branch$newbranch" ] &&
125
[ "$new" != "$old" ] &&
120
- die "git checkout: you need to specify a new branch name"
126
+ die "git checkout: to checkout the requested commit you need to specify
127
+ a name for a new branch which is created and switched to"
128
129
if [ "$force" ]
130
then