summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c847f53)
raw | patch | inline | side by side (parent: c847f53)
author | Junio C Hamano <junkio@cox.net> | |
Mon, 8 Jan 2007 10:19:38 +0000 (02:19 -0800) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Mon, 8 Jan 2007 11:02:11 +0000 (03:02 -0800) |
Signed-off-by: Junio C Hamano <junkio@cox.net>
git-checkout.sh | patch | blob | history |
diff --git a/git-checkout.sh b/git-checkout.sh
index 8e11ca4bc8f56782cbcb10f5051b8890c04ee24f..5a7388759c8cb5f3c08de5c299b3ea4f1e69acc5 100755 (executable)
--- a/git-checkout.sh
+++ b/git-checkout.sh
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=
# 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 ]