git-checkout: rewording comments regarding detached HEAD.
We used to say "you are not on a branch" before the initial commit. This is incorrect -- the user is on a branch yet to be born, but its name has been already determined. Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
parent
648861040f
commit
73c838e4c9
@ -140,22 +140,25 @@ fi
|
|||||||
|
|
||||||
[ -z "$new" ] && new=$old && new_name="$old_name"
|
[ -z "$new" ] && new=$old && new_name="$old_name"
|
||||||
|
|
||||||
# If we don't have an old branch that we're switching to,
|
# If we don't have an existing branch that we're switching to,
|
||||||
# and we don't have a new branch name for the target we
|
# and we don't have a new branch name for the target we
|
||||||
# are switching to, then we'd better just be checking out
|
# are switching to, then we are detaching our HEAD from any
|
||||||
# what we already had
|
# branch. However, if "git checkout HEAD" detaches the HEAD
|
||||||
|
# from the current branch, even though that may be logically
|
||||||
|
# correct, it feels somewhat funny. More importantly, we do not
|
||||||
|
# want "git checkout" nor "git checkout -f" to detach HEAD.
|
||||||
|
|
||||||
if test -z "$branch$newbranch" && test "$new" != "$old"
|
if test -z "$branch$newbranch" && test "$new" != "$old"
|
||||||
then
|
then
|
||||||
# NEEDSWORK: we would want to have this command here
|
# NEEDSWORK: we would want to have a command here
|
||||||
# that allows us to detach the HEAD atomically.
|
# that allows us to detach the HEAD atomically. Perhaps
|
||||||
# git update-ref --detach HEAD "$new"
|
# something like "git update-ref --detach HEAD $new"
|
||||||
echo "$new" >"$GIT_DIR/HEAD.new" &&
|
echo "$new" >"$GIT_DIR/HEAD.new" &&
|
||||||
mv "$GIT_DIR/HEAD.new" "$GIT_DIR/HEAD" || die "Cannot detach HEAD"
|
mv "$GIT_DIR/HEAD.new" "$GIT_DIR/HEAD" || die "Cannot detach HEAD"
|
||||||
|
|
||||||
if test -n "$oldbranch"
|
if test -n "$oldbranch"
|
||||||
then
|
then
|
||||||
echo >&2 "WARNING: you are not on ANY branch anymore.
|
echo >&2 "warning: you are not on ANY branch anymore.
|
||||||
If you meant to create a new branch from the commit, you need -b to
|
If you meant to create a new branch from the commit, you need -b to
|
||||||
associate a new branch with the wanted checkout. Example:
|
associate a new branch with the wanted checkout. Example:
|
||||||
git checkout -b <new_branch_name> $arg
|
git checkout -b <new_branch_name> $arg
|
||||||
@ -165,8 +168,8 @@ fi
|
|||||||
|
|
||||||
if [ "X$old" = X ]
|
if [ "X$old" = X ]
|
||||||
then
|
then
|
||||||
echo "warning: You do not appear to currently be on a branch." >&2
|
echo >&2 "warning: You appear to be on a branch yet to be born."
|
||||||
echo "warning: Forcing checkout of $new_name." >&2
|
echo >&2 "warning: Forcing checkout of $new_name."
|
||||||
force=1
|
force=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user