Skip to content

Commit afa8c07

Browse files
peffgitster
authored andcommitted
checkout: print a message when switching unborn branches
When we switch to a new branch using checkout, we usually output a message indicating what happened. However, when we switch from an unborn branch to a new branch, we do not print anything, which may leave the user wondering what happened. The reason is that the unborn branch is a special case (see abe1998), and does not follow the usual switch_branches code path. Let's add a similar informational message to the special case to match the usual code path. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8c7a786 commit afa8c07

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

builtin/checkout.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -951,6 +951,9 @@ static int switch_unborn_to_new_branch(const struct checkout_opts *opts)
951951
strbuf_addf(&branch_ref, "refs/heads/%s", opts->new_branch);
952952
status = create_symref("HEAD", branch_ref.buf, "checkout -b");
953953
strbuf_release(&branch_ref);
954+
if (!opts->quiet)
955+
fprintf(stderr, _("Switched to a new branch '%s'\n"),
956+
opts->new_branch);
954957
return status;
955958
}
956959

0 commit comments

Comments
 (0)