git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] improve checkout message when asking for same branch

From
Nicolas Pitre <nico@cam.org>
Date
Mar 21, 2007, 02:26 UTC
Message-ID
<alpine.LFD.0.83.0703202222280.18328@xanadu.home>

Change the feedback message if doing 'git checkout foo' when already on branch "foo".

Signed-off-by: Nicolas Pitre <nico@cam.org>
---
diff --git a/git-checkout.sh b/git-checkout.sh
index 39ffa8b..3c9b1bb 100755
--- a/git-checkout.sh
+++ b/git-checkout.sh
@@ -250,8 +250,13 @@ if [ "$?" -eq 0 ]; then
 	if test -n "$branch"
 	then
 		GIT_DIR="$GIT_DIR" git-symbolic-ref -m "checkout: moving to $branch" HEAD "refs/heads/$branch"
-		if test -z "$quiet"
+		if test -n "$quiet"
 		then
+			true	# nothing
+		elif test "refs/heads/$branch" = "$oldbranch"
+		then
+			echo >&2 "Already on branch \"$branch\""
+		else
 			echo >&2 "Switched to${newbranch:+ a new} branch \"$branch\""
 		fi
 	elif test -n "$detached"
Message 1 of 1 in “improve checkout message when asking for same branch”
  1. improve checkout message when asking for same branchNicolas Pitre, Mar 21, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.