checkout: print a message when switching unborn branches
authorJeff King <peff@peff.net>
Thu, 15 Nov 2012 17:12:33 +0000 (09:12 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 16 Nov 2012 01:36:26 +0000 (17:36 -0800)
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 <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/checkout.c

index 781295b2c9abf033481bc135ca1d2330ca489937..a9c1b5a95fea0a805819f995da2d2f1ba194433d 100644 (file)
@@ -951,6 +951,9 @@ static int switch_unborn_to_new_branch(const struct checkout_opts *opts)
        strbuf_addf(&branch_ref, "refs/heads/%s", opts->new_branch);
        status = create_symref("HEAD", branch_ref.buf, "checkout -b");
        strbuf_release(&branch_ref);
+       if (!opts->quiet)
+               fprintf(stderr, _("Switched to a new branch '%s'\n"),
+                       opts->new_branch);
        return status;
 }