Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2007-01-08 13:19:38 +0300
committerJunio C Hamano <junkio@cox.net>2007-01-08 14:02:11 +0300
commit648861040f2c5fd001a5edcfbb05813505bbb8f1 (patch)
tree6e2893db0e4226ebbecdcef9b91f49358cd5221e /git-checkout.sh
parentc847f537125ceab3425205721fdaaa834e6d8a83 (diff)
git-checkout: do not warn detaching HEAD when it is already detached.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'git-checkout.sh')
-rwxr-xr-xgit-checkout.sh11
1 files changed, 8 insertions, 3 deletions
diff --git a/git-checkout.sh b/git-checkout.sh
index 8e11ca4bc8..5a7388759c 100755
--- a/git-checkout.sh
+++ b/git-checkout.sh
@@ -6,6 +6,7 @@ SUBDIRECTORY_OK=Sometimes
old_name=HEAD
old=$(git-rev-parse --verify $old_name 2>/dev/null)
+oldbranch=$(git-symbolic-ref $old_name 2>/dev/null)
new=
new_name=
force=
@@ -149,13 +150,17 @@ then
# NEEDSWORK: we would want to have this command here
# that allows us to detach the HEAD atomically.
# git update-ref --detach HEAD "$new"
- rm -f "$GIT_DIR/HEAD"
- echo "$new" >"$GIT_DIR/HEAD"
- echo >&2 "WARNING: you are not on ANY branch anymore.
+ echo "$new" >"$GIT_DIR/HEAD.new" &&
+ mv "$GIT_DIR/HEAD.new" "$GIT_DIR/HEAD" || die "Cannot detach HEAD"
+
+ if test -n "$oldbranch"
+ then
+ 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
associate a new branch with the wanted checkout. Example:
git checkout -b <new_branch_name> $arg
"
+ fi
fi
if [ "X$old" = X ]