summaryrefslogtreecommitdiff
path: root/builtin/checkout.c
diff options
context:
space:
mode:
authorLibravatar Jeff King <peff@peff.net>2016-01-12 04:57:34 -0500
committerLibravatar Junio C Hamano <gitster@pobox.com>2016-01-12 11:11:52 -0800
commit4be49d756894daca0e8a4477d36c6ed1096ccddc (patch)
treed013f146189a190d3260baaa597067a1fb10a0ad /builtin/checkout.c
parentcreate_symref: write reflog while holding lock (diff)
downloadtgif-4be49d756894daca0e8a4477d36c6ed1096ccddc.tar.xz
checkout,clone: check return value of create_symref
It's unlikely that we would fail to create or update a symbolic ref (especially HEAD), but if we do, we should notice and complain. Note that there's no need to give more details in our error message; create_symref will already have done so. While we're here, let's also fix a minor memory leak in clone. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/checkout.c')
-rw-r--r--builtin/checkout.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/builtin/checkout.c b/builtin/checkout.c
index e8110a9243..5af84a3118 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -661,7 +661,8 @@ 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) < 0)
+ die("unable to update HEAD");
if (!opts->quiet) {
if (old->path && !strcmp(new->path, old->path)) {
if (opts->new_branch_force)