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

6 messages from 2010-08-20 to 2010-08-21. Participants: Ramkumar Ramachandra, Tay Ray Chuan, Junio C Hamano.
Thread: https://gitlist.dev/t/24809

## Ramkumar Ramachandra, 2010-08-20 17:41

Subject: [PATCH] builtin/checkout: Fix message when switching to an existing branch
Message-ID: <1282326107-2139-1-git-send-email-artagnon@gmail.com>
URL: https://gitlist.dev/e/1282326107-2139-1-git-send-email-artagnon%40gmail.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

```

## Tay Ray Chuan, 2010-08-20 17:46

Subject: Re: [PATCH] builtin/checkout: Fix message when switching to an existing branch
Message-ID: <AANLkTine1mi0AiCL+ezwNpFs4_y_szSwJd+Enux5G26Y@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTine1mi0AiCL%2BezwNpFs4_y_szSwJd%2BEnux5G26Y%40mail.gmail.com
In-Reply-To: <1282326107-2139-1-git-send-email-artagnon@gmail.com>

```
On Sat, Aug 21, 2010 at 1:41 AM, Ramkumar Ramachandra
<artagnon@gmail.com> 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 <rctay89@gmail.com>
> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>

Please see

  <AANLkTi=3z9gJdT8LL3NANFyppUjvOVcrszjf5J5zAKPe@mail.gmail.com>

-- 
Cheers,
Ray Chuan

```

## Ramkumar Ramachandra, 2010-08-20 17:49

Subject: Re: [PATCH] builtin/checkout: Fix message when switching to an existing branch
Message-ID: <20100820174946.GA6211@kytes>
URL: https://gitlist.dev/e/20100820174946.GA6211%40kytes
In-Reply-To: <AANLkTine1mi0AiCL+ezwNpFs4_y_szSwJd+Enux5G26Y@mail.gmail.com>

```
Hi Tay,

Tay Ray Chuan writes:
> On Sat, Aug 21, 2010 at 1:41 AM, Ramkumar Ramachandra
> <artagnon@gmail.com> 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 <rctay89@gmail.com>
> > Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
> 
> Please see
> 
>   <AANLkTi=3z9gJdT8LL3NANFyppUjvOVcrszjf5J5zAKPe@mail.gmail.com>

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

-- Ram

```

## Junio C Hamano, 2010-08-20 18:17

Subject: Re: [PATCH] builtin/checkout: Fix message when switching to an existing branch
Message-ID: <7v4oepcfof.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7v4oepcfof.fsf%40alter.siamese.dyndns.org
In-Reply-To: <AANLkTine1mi0AiCL+ezwNpFs4_y_szSwJd+Enux5G26Y@mail.gmail.com>

```
Tay Ray Chuan <rctay89@gmail.com> writes:

> On Sat, Aug 21, 2010 at 1:41 AM, Ramkumar Ramachandra
> <artagnon@gmail.com> 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 <rctay89@gmail.com>
>> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
>
> Please see
>
>   <AANLkTi=3z9gJdT8LL3NANFyppUjvOVcrszjf5J5zAKPe@mail.gmail.com>

Hmm, I somehow find this version easier to read.

```

## Tay Ray Chuan, 2010-08-21 03:15

Subject: Re: [PATCH] builtin/checkout: Fix message when switching to an existing branch
Message-ID: <AANLkTim4K7LnZOhGQUNwpLR24Hm+V1fWrxY2UE2oPGx7@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTim4K7LnZOhGQUNwpLR24Hm%2BV1fWrxY2UE2oPGx7%40mail.gmail.com
In-Reply-To: <1282326107-2139-1-git-send-email-artagnon@gmail.com>

```
On Sat, Aug 21, 2010 at 1:41 AM, Ramkumar Ramachandra
<artagnon@gmail.com> wrote:
>  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

```

## Tay Ray Chuan, 2010-08-21 03:28

Subject: Re: [PATCH] builtin/checkout: Fix message when switching to an existing branch
Message-ID: <AANLkTin3+uAYXYsYG9DHxy9BhAg=CE5B7Oy09X7ze-OL@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTin3%2BuAYXYsYG9DHxy9BhAg%3DCE5B7Oy09X7ze-OL%40mail.gmail.com
In-Reply-To: <AANLkTim4K7LnZOhGQUNwpLR24Hm+V1fWrxY2UE2oPGx7@mail.gmail.com>

```
On Sat, Aug 21, 2010 at 11:15 AM, Tay Ray Chuan <rctay89@gmail.com> 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

```
