X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=git-checkout.sh;h=a11c939c30f46561adb8179570d825a85fb8b57b;hb=refs%2Fheads%2Fmaint;hp=76e7f5522646e816ea506f3df1fc0ab0a9d0a277;hpb=504fe714fe642b375992bb913075bee0d0bc1bbd;p=git.git diff --git a/git-checkout.sh b/git-checkout.sh index 76e7f552..a11c939c 100755 --- a/git-checkout.sh +++ b/git-checkout.sh @@ -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 @@ -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 @@ -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 @@ -137,7 +144,7 @@ else work=`git write-tree` && git read-tree --reset $new && git checkout-index -f -u -q -a && - git read-tree -m -u $old $new $work || exit + git read-tree -m -u --aggressive $old $new $work || exit if result=`git write-tree 2>/dev/null` then