Skip to content

Commit

Permalink
builtin/checkout: Fix message when switching to an existing branch
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Ramkumar Ramachandra authored and Junio C Hamano committed Aug 20, 2010
1 parent c11969d commit 09a0ec5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion builtin/checkout.c
Original file line number Diff line number Diff line change
Expand Up @@ -533,10 +533,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];
Expand Down

0 comments on commit 09a0ec5

Please sign in to comment.