threads / patch / 24809

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

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

## tl;dr

6 messages between Aug 20, 2010 and Aug 21, 2010. Diffs are folded; open one to read it.

replies: 5people: 3as markdown or json

Ramkumar Ramachandra· Aug 20, 2010, 17:41 UTC · lore

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(-)
Show changes to builtin/checkout.c +4 −1
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· Aug 20, 2010, 17:46 UTC · re: Ramkumar Ramachandra · lore

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

On Sat, Aug 21, 2010 at 1:41 AM, Ramkumar Ramachandra <artagnon@gmail.com> wrote:

Show 6 quoted lines
> 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· Aug 20, 2010, 17:49 UTC · re: Tay Ray Chuan · lore

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

Hi Tay,
Tay Ray Chuan writes:
Show 12 quoted lines
> 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· Aug 20, 2010, 18:17 UTC · re: Tay Ray Chuan · lore

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

Tay Ray Chuan <rctay89@gmail.com> writes:
Show 12 quoted lines
> 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· Aug 21, 2010, 03:15 UTC · re: Ramkumar Ramachandra · lore

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

On Sat, Aug 21, 2010 at 1:41 AM, Ramkumar Ramachandra <artagnon@gmail.com> wrote:

Show 19 quoted lines
>  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· Aug 21, 2010, 03:28 UTC · re: Tay Ray Chuan · lore

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

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

← back to recent threads