]> asedeno.scripts.mit.edu Git - git.git/blobdiff - git-checkout.sh
Improve use of lockfile API
[git.git] / git-checkout.sh
index f80939da5a15a006f2969cb966f4cdcc9dffdef9..5621c69d86062c7c75c0b8c2749d34efc78cafb4 100755 (executable)
@@ -2,13 +2,13 @@
 
 OPTIONS_KEEPDASHDASH=t
 OPTIONS_SPEC="\
-git-branch [options] [<branch>] [<paths>...]
+git-checkout [options] [<branch>] [<paths>...]
 --
 b=          create a new branch started at <branch>
-l           create the new branchs reflog
-track       tells if the new branch should track the remote branch
+l           create the new branch's reflog
+track       arrange that the new branch tracks the remote branch
 f           proceed even if the index or working tree is not HEAD
-m           performa  three-way merge on local modifications if needed
+m           merge local modifications into the new branch
 q,quiet     be quiet
 "
 SUBDIRECTORY_OK=Sometimes
@@ -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