X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=git-checkout.sh;h=bd74d701a1f0abb63e2bcdcb47035cb2c6eee745;hb=274d9d329444705ba771e548352918699e6bb557;hp=aa724ac1a3859791187d257da6445d2b4adc1de8;hpb=f81117b84d2c99a29acf06c6522aad54defbc760;p=git.git diff --git a/git-checkout.sh b/git-checkout.sh index aa724ac1a..bd74d701a 100755 --- a/git-checkout.sh +++ b/git-checkout.sh @@ -2,13 +2,13 @@ OPTIONS_KEEPDASHDASH=t OPTIONS_SPEC="\ -git-branch [options] [] [...] +git-checkout [options] [] [...] -- b= create a new branch started at -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 @@ -71,7 +71,8 @@ while test $# != 0; do done arg="$1" -if rev=$(git rev-parse --verify "$arg^0" 2>/dev/null) +rev=$(git rev-parse --verify "$arg" 2>/dev/null) +if rev=$(git rev-parse --verify "$rev^0" 2>/dev/null) then [ -z "$rev" ] && die "unknown flag $arg" new_name="$arg" @@ -82,11 +83,11 @@ then fi new="$rev" shift -elif rev=$(git rev-parse --verify "$arg^{tree}" 2>/dev/null) +elif rev=$(git rev-parse --verify "$rev^{tree}" 2>/dev/null) then # checking out selected paths from a tree-ish. new="$rev" - new_name="$arg^{tree}" + new_name="$rev^{tree}" shift fi [ "$1" = "--" ] && shift @@ -175,7 +176,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 +267,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 +279,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