diff options
author | Junio C Hamano <junkio@cox.net> | 2007-02-03 22:14:40 -0800 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2007-02-03 23:05:34 -0800 |
commit | d77ee72662a821d66ae218056f0103eb24d8d4b4 (patch) | |
tree | e22abdbd11735a0669362f934ae723d233c87e2b /git-checkout.sh | |
parent | eb8381c88518b10d683a29deea1d43ed671f14ec (diff) | |
parent | 8d0fc48f27304ac1bc7abf802ec53fe66fedb15a (diff) | |
download | git-d77ee72662a821d66ae218056f0103eb24d8d4b4.tar.gz |
Merge branch 'master' into np/dreflog
This is to resolve conflicts early in preparation for possible
inclusion of "reflog on detached HEAD" series by Nico, as having
it in 1.5.0 would really help us remove confusion between
detached and attached states.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'git-checkout.sh')
-rwxr-xr-x | git-checkout.sh | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/git-checkout.sh b/git-checkout.sh index 1349e77f32..2c8cbe43a6 100755 --- a/git-checkout.sh +++ b/git-checkout.sh @@ -1,6 +1,6 @@ #!/bin/sh -USAGE='[-f] [-b <new_branch>] [-m] [<branch>] [<paths>...]' +USAGE='[-q] [-f] [-b <new_branch>] [-m] [<branch>] [<paths>...]' SUBDIRECTORY_OK=Sometimes . git-sh-setup require_work_tree @@ -15,6 +15,7 @@ branch= newbranch= newbranch_log= merge= +quiet= LF=' ' while [ "$#" != "0" ]; do @@ -40,6 +41,9 @@ while [ "$#" != "0" ]; do -m) merge=1 ;; + "-q") + quiet=1 + ;; --) break ;; @@ -153,11 +157,11 @@ detach_warn= if test -z "$branch$newbranch" && test "$new" != "$old" then detached="$new" - if test -n "$oldbranch" + if test -n "$oldbranch" && test -z "$quiet" then - detach_warn="warning: you are not on ANY branch anymore. -If you meant to create a new branch from this checkout, you may still do -so (now or later) by using -b with the checkout command again. Example: + detach_warn="Note: moving to \"$new_name\" which isn't a local branch +If you want to create a new branch from this checkout, you may do so +(now or later) by using -b with the checkout command again. Example: git checkout -b <new_branch_name>" fi elif test -z "$oldbranch" && test -n "$branch" @@ -180,8 +184,11 @@ fi if [ "X$old" = X ] then - echo >&2 "warning: You appear to be on a branch yet to be born." - echo >&2 "warning: Forcing checkout of $new_name." + if test -z "$quiet" + then + echo >&2 "warning: You appear to be on a branch yet to be born." + echo >&2 "warning: Forcing checkout of $new_name." + fi force=1 fi @@ -226,9 +233,9 @@ else exit 0 ) saved_err=$? - if test "$saved_err" = 0 + if test "$saved_err" = 0 && test -z "$quiet" then - test "$new" = "$old" || git diff-index --name-status "$new" + git diff-index --name-status "$new" fi (exit $saved_err) fi @@ -251,6 +258,10 @@ if [ "$?" -eq 0 ]; then if test -n "$branch" then GIT_DIR="$GIT_DIR" git-symbolic-ref -m "checkout: moving to $branch" HEAD "refs/heads/$branch" + if test -z "$quiet" + then + echo >&2 "Switched to${newbranch:+ a new} branch \"$branch\"" + fi elif test -n "$detached" then # NEEDSWORK: we would want a command to detach the HEAD |