git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] git checkout's reflog: even when detaching the HEAD, say from where
@ 2007-08-07  1:42 Johannes Schindelin
  2007-08-07  3:56 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Schindelin @ 2007-08-07  1:42 UTC (permalink / raw)
  To: gitster, git


When checking out another ref, the reflogs already record from which
branch you switched.  Do that also when switching to a detached HEAD.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 git-checkout.sh |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/git-checkout.sh b/git-checkout.sh
index 17f4392..f427718 100755
--- a/git-checkout.sh
+++ b/git-checkout.sh
@@ -272,7 +272,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 to $arg" HEAD "$detached" ||
 			die "Cannot detach HEAD"
 		if test -n "$detach_warn"
 		then
-- 
1.5.3.rc4.17.gb980

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] git checkout's reflog: even when detaching the HEAD, say from where
  2007-08-07  1:42 Johannes Schindelin
@ 2007-08-07  3:56 ` Junio C Hamano
  0 siblings, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2007-08-07  3:56 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

> @@ -272,7 +272,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 to $arg" HEAD "$detached" ||

Can't old_branch_name be empty here if you are already detached?

>  			die "Cannot detach HEAD"
>  		if test -n "$detach_warn"
>  		then
> -- 
> 1.5.3.rc4.17.gb980

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] git checkout's reflog: even when detaching the HEAD, say from where
@ 2007-11-23  0:20 Johannes Schindelin
  0 siblings, 0 replies; 3+ messages in thread
From: Johannes Schindelin @ 2007-11-23  0:20 UTC (permalink / raw)
  To: git, gitster


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>
---

	Yeah, took me a long time to take care of this issue.

 git-checkout.sh |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/git-checkout.sh b/git-checkout.sh
index aa724ac..5dc8ddb 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
-- 
1.5.3.6.1977.g54d30

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-11-23  0:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-23  0:20 [PATCH] git checkout's reflog: even when detaching the HEAD, say from where Johannes Schindelin
  -- strict thread matches above, loose matches on Subject: below --
2007-08-07  1:42 Johannes Schindelin
2007-08-07  3:56 ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).