git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Nicolas Pitre <nico@cam.org>
Cc: cworth@cworth.org, Junio C Hamano <junkio@cox.net>, git@vger.kernel.org
Subject: Re: [PATCH] tone down the detached head warning
Date: Wed, 31 Jan 2007 18:19:43 -0500	[thread overview]
Message-ID: <20070131231942.GB31145@coredump.intra.peff.net> (raw)
In-Reply-To: <Pine.LNX.4.64.0701311405430.3021@xanadu.home>

On Wed, Jan 31, 2007 at 02:10:37PM -0500, Nicolas Pitre wrote:

> This is not meant to frighten people or even to suggest they might be
> doing something wrong, but rather to notify them of a state change and
> provide a likely option in the case this state was entered by mistake.

I like this much better. Though I wonder in Carl's case if we can do
even better, since the user is checking out a tracking branch. Does it
really make sense to say "you are not on ANY branch"? Maybe instead:

-- >8 --
git-checkout: note use of remote tracking branch when making detached warning

---
Carl, can you comment? Does this require more explanation about why it
matters that you're on a remote tracking branch?

 git-checkout.sh |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/git-checkout.sh b/git-checkout.sh
index ed04815..68533a1 100755
--- a/git-checkout.sh
+++ b/git-checkout.sh
@@ -14,6 +14,7 @@ force=
 branch=
 newbranch=
 newbranch_log=
+detached_remote=
 merge=
 LF='
 '
@@ -58,6 +59,9 @@ while [ "$#" != "0" ]; do
 			if git-show-ref --verify --quiet -- "refs/heads/$arg"
 			then
 				branch="$arg"
+			elif git-show-ref --verify --quiet -- "refs/remotes/$arg"
+			then
+				detached_remote="$arg"
 			fi
 		elif rev=$(git-rev-parse --verify "$arg^{tree}" 2>/dev/null)
 		then
@@ -155,7 +159,11 @@ then
 	detached="$new"
 	if test -n "$oldbranch"
 	then
-		detach_warn="Note: you are not on ANY branch anymore.
+		case "$detached_remote" in
+		  "") detach_warn="Note: you are not on ANY branch anymore." ;;
+		   *) detach_warn="Note: you are on the remote tracking branch '$detached_remote'" ;;
+		esac
+		detach_warn="$detach_warn
 If you want to create a new branch from this checkout, you may do so
 (now or later) by using -b with the checkout command again. Example:
   git checkout -b <new_branch_name>"
-- 
1.5.0.rc2.587.gbedb-dirty

  reply	other threads:[~2007-01-31 23:19 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-31 19:10 [PATCH] tone down the detached head warning Nicolas Pitre
2007-01-31 23:19 ` Jeff King [this message]
2007-01-31 23:25   ` Jakub Narebski
2007-01-31 23:27     ` Jeff King
2007-01-31 23:33       ` Jakub Narebski
2007-01-31 23:54   ` Carl Worth
2007-02-01  0:14     ` Jakub Narebski
2007-02-01  8:44       ` Andy Parkins
2007-02-01 12:48         ` Matthias Lederhofer
2007-02-01  0:11   ` Nicolas Pitre
2007-02-01  3:00     ` Jeff King
2007-02-01  3:23       ` Junio C Hamano
2007-02-01  3:29         ` Jeff King
2007-02-01  3:47           ` Nicolas Pitre
2007-02-01  3:54             ` Jeff King
2007-02-01  9:08         ` [PATCH] detached HEAD -- finishing touches Junio C Hamano
2007-02-01  9:46           ` Raimund Bauer
2007-02-01  9:53           ` Alex Riesen
2007-02-01  9:54             ` Alex Riesen
2007-02-01 18:44           ` [PATCH] git-checkout: disable guides how to switch branches with ui.guide Matthias Lederhofer
2007-02-01 20:42             ` Junio C Hamano
2007-02-01 20:51               ` Matthias Lederhofer
2007-02-01 21:06                 ` Junio C Hamano
2007-02-01 21:23                   ` Matthias Lederhofer
2007-02-01 21:34                   ` Carl Worth
2007-02-01 21:59                     ` Nicolas Pitre
2007-02-01 22:16                       ` Carl Worth
2007-02-01 23:18                         ` Jakub Narebski
2007-02-01 21:52           ` [PATCH] detached HEAD -- finishing touches Theodore Tso
2007-02-02  1:11             ` Junio C Hamano
2007-02-02  1:16               ` Theodore Tso
2007-02-02  1:27               ` Carl Worth
2007-02-02  1:30                 ` Junio C Hamano
2007-02-02  1:46                   ` Carl Worth
2007-02-02  2:38                     ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070131231942.GB31145@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=cworth@cworth.org \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    --cc=nico@cam.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).