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

[PATCH] builtin/checkout: Fix message when switching to an existing branch

From
Ramkumar Ramachandra <artagnon@gmail.com>
Date
Aug 20, 2010, 17:41 UTC
Message-ID
<1282326107-2139-1-git-send-email-artagnon@gmail.com>

Fix "Switched to a new branch <name>" to read "Switched to branch <name>" when <name> corresponds to an existing branch. This bug was introduced in 02ac983 while introducing the `-B` switch.

Cc: Tay Ray Chuan <rctay89@gmail.com>
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 builtin/checkout.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 156900d..ff5ac1e 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -545,10 +545,13 @@ static void update_refs_for_switch(struct checkout_opts *opts,
 			if (old->path && !strcmp(new->path, old->path))
 				fprintf(stderr, "Already on '%s'\n",
 					new->name);
-			else
+			else if (opts->new_branch)
 				fprintf(stderr, "Switched to%s branch '%s'\n",
 					opts->branch_exists ? " and reset" : " a new",
 					new->name);
+			else
+				fprintf(stderr, "Switched to branch '%s'\n",
+					new->name);
 		}
 		if (old->path && old->name) {
 			char log_file[PATH_MAX], ref_file[PATH_MAX];
-- 
1.7.2.2.408.g7357
Next: Tay Ray Chuan
Message 1 of 6 in “builtin/checkout: Fix message when switching to an existing branch”
  1. builtin/checkout: Fix message when switching to an existing branchRamkumar Ramachandra, Aug 20, 2010
  2. Tay Ray ChuanAug 20, 2010
  3. Ramkumar RamachandraAug 20, 2010
  4. Junio C HamanoAug 20, 2010
  5. Tay Ray ChuanAug 21, 2010
  6. Tay Ray ChuanAug 21, 2010

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.