]> asedeno.scripts.mit.edu Git - git.git/blobdiff - git-checkout.sh
git-help: add -w|--web option to display html man page in a browser.
[git.git] / git-checkout.sh
index aa724ac1a3859791187d257da6445d2b4adc1de8..f6d58ac044e5afb09855d687d3c1bcc8e2273be3 100755 (executable)
@@ -175,7 +175,7 @@ detach_warn=
 describe_detached_head () {
        test -n "$quiet" || {
                printf >&2 "$1 "
-               GIT_PAGER= git log >&2 -1 --pretty=oneline --abbrev-commit "$2"
+               GIT_PAGER= git log >&2 -1 --pretty=oneline --abbrev-commit "$2" --
        }
 }
 
@@ -266,7 +266,7 @@ if [ "$?" -eq 0 ]; then
        if test -n "$branch"
        then
                old_branch_name=`expr "z$oldbranch" : 'zrefs/heads/\(.*\)'`
-               GIT_DIR="$GIT_DIR" git symbolic-ref -m "checkout: moving from $old_branch_name to $branch" HEAD "refs/heads/$branch"
+               GIT_DIR="$GIT_DIR" git symbolic-ref -m "checkout: moving from ${old_branch_name:-$old} to $branch" HEAD "refs/heads/$branch"
                if test -n "$quiet"
                then
                        true    # nothing
@@ -278,7 +278,8 @@ if [ "$?" -eq 0 ]; then
                fi
        elif test -n "$detached"
        then
-               git update-ref --no-deref -m "checkout: moving to $arg" HEAD "$detached" ||
+               old_branch_name=`expr "z$oldbranch" : 'zrefs/heads/\(.*\)'`
+               git update-ref --no-deref -m "checkout: moving from ${old_branch_name:-$old} to $arg" HEAD "$detached" ||
                        die "Cannot detach HEAD"
                if test -n "$detach_warn"
                then