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

Subsystems: the rest

DORMANTno replies

5 messages, 2 authors, 2016-06-15 · open the first message on its own page

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

From: Ramkumar Ramachandra <hidden>
Date: 2016-06-15 22:49:21

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 <redacted>
Signed-off-by: Ramkumar Ramachandra <redacted>
---
 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

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

From: Tay Ray Chuan <hidden>
Date: 2016-06-15 22:49:21

On Sat, Aug 21, 2010 at 1:41 AM, Ramkumar Ramachandra
[off-list ref] wrote:
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 <redacted>
Signed-off-by: Ramkumar Ramachandra <redacted>
Please see

  [off-list ref]

-- 
Cheers,
Ray Chuan

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

From: Ramkumar Ramachandra <hidden>
Date: 2016-06-15 22:49:21

Hi Tay,

Tay Ray Chuan writes:
On Sat, Aug 21, 2010 at 1:41 AM, Ramkumar Ramachandra
[off-list ref] wrote:
quoted
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 <redacted>
Signed-off-by: Ramkumar Ramachandra <redacted>
Please see

  [off-list ref]
Ah yes. It looks like I missed this earlier. Sorry for the noise.

-- Ram

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

From: Tay Ray Chuan <hidden>
Date: 2016-06-15 22:49:21

On Sat, Aug 21, 2010 at 1:41 AM, Ramkumar Ramachandra
[off-list ref] wrote:
quoted hunk
 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);
On a closer reading, I realise that "reset" isn't mentioned if the
branch exists.

The terser ternary version doesn't suffer from this defect.

-- 
Cheers,
Ray Chuan

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

From: Tay Ray Chuan <hidden>
Date: 2016-06-15 22:49:21

On Sat, Aug 21, 2010 at 11:15 AM, Tay Ray Chuan [off-list ref] wrote:
On a closer reading, I realise that "reset" isn't mentioned if the
branch exists.

The terser ternary version doesn't suffer from this defect.
Sorry, please ignore that.

-- 
Cheers,
Ray Chuan
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help