X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=git-checkout.sh;h=463ed2eaff906edaeb0f6d3f8138798e373c6495;hb=9181ca2c2b1f2897baa67ff8e48b1984822115b5;hp=bd7f007307d458efec2cdd333dc9028402482f57;hpb=1be0659efca4a1f69c851f95563e930d70d8baf2;p=git.git diff --git a/git-checkout.sh b/git-checkout.sh index bd7f0073..463ed2ea 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 @@ -164,6 +171,12 @@ else esac exit 0 ) + saved_err=$? + if test "$saved_err" = 0 + then + test "$new" = "$old" || git diff-index --name-status "$new" + fi + (exit $saved_err) fi #