{"thread":{"id":"9414","subject":"[PATCH] git checkout's reflog: even when detaching the HEAD, say from where","startedAt":"2007-08-07T01:42:27Z","lastAt":"2007-08-07T03:56:53Z","messageCount":2,"participants":["Johannes Schindelin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"50066","messageId":"Pine.LNX.4.64.0708070242140.14781@racer.site","threadId":"9414","inReplyTo":null,"subject":"[PATCH] git checkout's reflog: even when detaching the HEAD, say from where","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-08-07T01:42:27Z","receivedAt":"2007-08-07T01:42:27Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nWhen checking out another ref, the reflogs already record from which\nbranch you switched.  Do that also when switching to a detached HEAD.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n git-checkout.sh |    3 ++-\n 1 files changed, 2 insertions(+), 1 deletions(-)\n\ndiff --git a/git-checkout.sh b/git-checkout.sh\nindex 17f4392..f427718 100755\n--- a/git-checkout.sh\n+++ b/git-checkout.sh\n@@ -272,7 +272,8 @@ if [ \"$?\" -eq 0 ]; then\n \t\tfi\n \telif test -n \"$detached\"\n \tthen\n-\t\tgit update-ref --no-deref -m \"checkout: moving to $arg\" HEAD \"$detached\" ||\n+\t\told_branch_name=`expr \"z$oldbranch\" : 'zrefs/heads/\\(.*\\)'`\n+\t\tgit update-ref --no-deref -m \"checkout: moving from $old_branch_name to $arg\" HEAD \"$detached\" ||\n \t\t\tdie \"Cannot detach HEAD\"\n \t\tif test -n \"$detach_warn\"\n \t\tthen\n-- \n1.5.3.rc4.17.gb980\n"},{"id":"50085","messageId":"7v8x8o9euy.fsf@assigned-by-dhcp.cox.net","threadId":"9414","inReplyTo":"Pine.LNX.4.64.0708070242140.14781@racer.site","subject":"Re: [PATCH] git checkout's reflog: even when detaching the HEAD, say from where","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-08-07T03:56:53Z","receivedAt":"2007-08-07T03:56:53Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> @@ -272,7 +272,8 @@ if [ \"$?\" -eq 0 ]; then\n>  \t\tfi\n>  \telif test -n \"$detached\"\n>  \tthen\n> -\t\tgit update-ref --no-deref -m \"checkout: moving to $arg\" HEAD \"$detached\" ||\n> +\t\told_branch_name=`expr \"z$oldbranch\" : 'zrefs/heads/\\(.*\\)'`\n> +\t\tgit update-ref --no-deref -m \"checkout: moving from $old_branch_name to $arg\" HEAD \"$detached\" ||\n\nCan't old_branch_name be empty here if you are already detached?\n\n>  \t\t\tdie \"Cannot detach HEAD\"\n>  \t\tif test -n \"$detach_warn\"\n>  \t\tthen\n> -- \n> 1.5.3.rc4.17.gb980\n"}]}