Skip to contentSkip to conversation

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

PATCH In review Ramkumar Ramachandra 3 participants 6 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

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

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.

---
 builtin/checkout.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
builtin/checkout.c +4 -1
index 156900d..ff5ac1e 100644
@@ -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];
Signature · 1 line
1.7.2.2.408.g7357
#1 lore raw
Quoted 9 lines · Ramkumar Ramachandra

 builtin/checkout.c |    5 ++++-

 1 files changed, 4 insertions(+), 1 deletions(-)
builtin/checkout.c +0 -0
index 156900d..ff5ac1e 100644
@@ -545,10 +545,13 @@ static void update_refs_for_switch(struct checkout_opts *opts,
                        if (old->path && !strcmp(new->path, old->path))

builtin/checkout.c static void update_refs_for_switch(struct checkout_opts *opts, · line 554

Quoted 10 lines
builtin/checkout.c +4 -1
                                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.

Signature · 2 lines
Cheers,
Ray Chuan
#2 lore raw
Quoted 4 lines · Tay Ray Chuan

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.

Signature · 2 lines
Cheers,
Ray Chuan
#4 lore raw

Hi Tay,

Quoted 6 lines · Tay Ray Chuan
Quoted 4 lines · Ramkumar Ramachandra

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.

Quoted 6 lines
Quoted 2 lines

Please see

<[email protected]>

Ah yes. It looks like I missed this earlier. Sorry for the noise.

-- Ram

#5 lore raw
In reply to Tay Ray Chuan
Quoted 6 lines · Tay Ray Chuan
Quoted 4 lines · Ramkumar Ramachandra

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.

Quoted 6 lines
Quoted 2 lines

Please see

<[email protected]>

Hmm, I somehow find this version easier to read.