Skip to content

Commit 09a0ec5

Browse files
artagnongitster
authored andcommitted
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. Cc: Tay Ray Chuan <[email protected]> Signed-off-by: Ramkumar Ramachandra <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c11969d commit 09a0ec5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

builtin/checkout.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,10 +533,13 @@ static void update_refs_for_switch(struct checkout_opts *opts,
533533
if (old->path && !strcmp(new->path, old->path))
534534
fprintf(stderr, "Already on '%s'\n",
535535
new->name);
536-
else
536+
else if (opts->new_branch)
537537
fprintf(stderr, "Switched to%s branch '%s'\n",
538538
opts->branch_exists ? " and reset" : " a new",
539539
new->name);
540+
else
541+
fprintf(stderr, "Switched to branch '%s'\n",
542+
new->name);
540543
}
541544
if (old->path && old->name) {
542545
char log_file[PATH_MAX], ref_file[PATH_MAX];

0 commit comments

Comments
 (0)