Skip to content

Commit

Permalink
git checkout's reflog: even when detaching the HEAD, say from where
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Johannes Schindelin authored and Junio C Hamano committed Nov 29, 2007
1 parent 9e42d6a commit c67bbc5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions git-checkout.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit c67bbc5

Please sign in to comment.