diff options
Diffstat (limited to 'builtin/checkout.c')
-rw-r--r-- | builtin/checkout.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/builtin/checkout.c b/builtin/checkout.c index d9cb9c348b..1efe353728 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -634,7 +634,10 @@ static void update_refs_for_switch(const struct checkout_opts *opts, describe_detached_head(_("HEAD is now at"), new->commit); } } else if (new->path) { /* Switch branches. */ - create_symref("HEAD", new->path, msg.buf); + if (create_symref("HEAD", new->path, msg.buf, &err)) { + error("%s", err.buf); + strbuf_release(&err); + } if (!opts->quiet) { if (old->path && !strcmp(new->path, old->path)) { if (opts->new_branch_force) @@ -1020,12 +1023,16 @@ static int parse_branchname_arg(int argc, const char **argv, static int switch_unborn_to_new_branch(const struct checkout_opts *opts) { int status; - struct strbuf branch_ref = STRBUF_INIT; + struct strbuf branch_ref = STRBUF_INIT, err = STRBUF_INIT; if (!opts->new_branch) die(_("You are on a branch yet to be born")); strbuf_addf(&branch_ref, "refs/heads/%s", opts->new_branch); - status = create_symref("HEAD", branch_ref.buf, "checkout -b"); + status = create_symref("HEAD", branch_ref.buf, "checkout -b", &err); + if (status) { + error("%s", err.buf); + strbuf_release(&err); + } strbuf_release(&branch_ref); if (!opts->quiet) fprintf(stderr, _("Switched to a new branch '%s'\n"), |