summaryrefslogtreecommitdiff
path: root/git-checkout.sh
diff options
context:
space:
mode:
authorJohannes Schindelin <Johannes.Schindelin@gmx.de>2007-11-23 00:20:35 (GMT)
committerJunio C Hamano <gitster@pobox.com>2007-11-29 00:20:13 (GMT)
commitc67bbc55f0310de79647457b1fa2a5d3b1746488 (patch)
tree6162ae4151336e152266c36db60ea2f9d468230e /git-checkout.sh
parent9e42d6a1c53dadd409fab11cc76e0eba9ec15365 (diff)
downloadgit-c67bbc55f0310de79647457b1fa2a5d3b1746488.zip
git-c67bbc55f0310de79647457b1fa2a5d3b1746488.tar.gz
git-c67bbc55f0310de79647457b1fa2a5d3b1746488.tar.bz2
git checkout's reflog: even when detaching the HEAD, say from where
When checking out another ref, the reflogs already record from which branch you switched. Do that also when switching to a detached HEAD. While at it, record also when coming _from_ a detached HEAD. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-checkout.sh')
-rwxr-xr-xgit-checkout.sh5
1 files changed, 3 insertions, 2 deletions
diff --git a/git-checkout.sh b/git-checkout.sh
index f80939d..f6d58ac 100755
--- a/git-checkout.sh
+++ b/git-checkout.sh
@@ -266,7 +266,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 +278,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