diff options
author | Junio C Hamano <gitster@pobox.com> | 2016-01-27 02:40:30 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-01-27 02:40:30 +0300 |
commit | 90ce285a42cd29c9b958e8b2ffe265986d2e5cf2 (patch) | |
tree | 339c62246132bd95775a1d75827fba6c2f39ab10 /builtin | |
parent | b2ed5ae80a1b45ac00c4c891e693ffcde34a9347 (diff) | |
parent | 2859dcd4c8605a5b9cf35efb815418ea8892658b (diff) |
Merge branch 'jk/symbolic-ref'
The low-level code that is used to create symbolic references has
been updated to share more code with the code that deals with
normal references.
* jk/symbolic-ref:
lock_ref_sha1_basic: handle REF_NODEREF with invalid refs
lock_ref_sha1_basic: always fill old_oid while holding lock
checkout,clone: check return value of create_symref
create_symref: write reflog while holding lock
create_symref: use existing ref-lock code
create_symref: modernize variable names
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/checkout.c | 3 | ||||
-rw-r--r-- | builtin/clone.c | 11 |
2 files changed, 9 insertions, 5 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) diff --git a/builtin/clone.c b/builtin/clone.c index a0b3cd9e56..a7c8def8cb 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -636,9 +636,11 @@ static void update_remote_refs(const struct ref *refs, struct strbuf head_ref = STRBUF_INIT; strbuf_addstr(&head_ref, branch_top); strbuf_addstr(&head_ref, "HEAD"); - create_symref(head_ref.buf, - remote_head_points_at->peer_ref->name, - msg); + if (create_symref(head_ref.buf, + remote_head_points_at->peer_ref->name, + msg) < 0) + die("unable to update %s", head_ref.buf); + strbuf_release(&head_ref); } } @@ -648,7 +650,8 @@ static void update_head(const struct ref *our, const struct ref *remote, const char *head; if (our && skip_prefix(our->name, "refs/heads/", &head)) { /* Local default branch link */ - create_symref("HEAD", our->name, NULL); + if (create_symref("HEAD", our->name, NULL) < 0) + die("unable to update HEAD"); if (!option_bare) { update_ref(msg, "HEAD", our->old_oid.hash, NULL, 0, UPDATE_REFS_DIE_ON_ERR); |