diff options
author | Junio C Hamano <gitster@pobox.com> | 2014-06-03 19:06:42 (GMT) |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-06-03 19:06:42 (GMT) |
commit | 2e4b5dee97cb1524a88f0ee90450b139bfaff07b (patch) | |
tree | 92e5ac7b9d415f1dc22e78c25fa7b01b85a2e02a | |
parent | 53f52cd92acb033df4a50d1557bae9c55c2d4d67 (diff) | |
parent | 55a5c8d72b03ad3727b89900069a1d58664fe5e4 (diff) | |
download | git-2e4b5dee97cb1524a88f0ee90450b139bfaff07b.zip git-2e4b5dee97cb1524a88f0ee90450b139bfaff07b.tar.gz git-2e4b5dee97cb1524a88f0ee90450b139bfaff07b.tar.bz2 |
Merge branch 'rs/ref-update-check-errors-early'
* rs/ref-update-check-errors-early:
commit.c: check for lock error and return early
sequencer.c: check for lock failure and bail early in fast_forward_to
-rw-r--r-- | builtin/commit.c | 8 | ||||
-rw-r--r-- | sequencer.c | 4 |
2 files changed, 8 insertions, 4 deletions
diff --git a/builtin/commit.c b/builtin/commit.c index 9cfef6c..f0b7906 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -1672,6 +1672,10 @@ int cmd_commit(int argc, const char **argv, const char *prefix) ? NULL : current_head->object.sha1, 0, NULL); + if (!ref_lock) { + rollback_index_files(); + die(_("cannot lock HEAD ref")); + } nl = strchr(sb.buf, '\n'); if (nl) @@ -1681,10 +1685,6 @@ int cmd_commit(int argc, const char **argv, const char *prefix) strbuf_insert(&sb, 0, reflog_msg, strlen(reflog_msg)); strbuf_insert(&sb, strlen(reflog_msg), ": ", 2); - if (!ref_lock) { - rollback_index_files(); - die(_("cannot lock HEAD ref")); - } if (write_ref_sha1(ref_lock, sha1, sb.buf) < 0) { rollback_index_files(); die(_("cannot update HEAD ref")); diff --git a/sequencer.c b/sequencer.c index bde5f04..0a80c58 100644 --- a/sequencer.c +++ b/sequencer.c @@ -281,8 +281,12 @@ static int fast_forward_to(const unsigned char *to, const unsigned char *from, exit(1); /* the callee should have complained already */ ref_lock = lock_any_ref_for_update("HEAD", unborn ? null_sha1 : from, 0, NULL); + if (!ref_lock) + return error(_("Failed to lock HEAD during fast_forward_to")); + strbuf_addf(&sb, "%s: fast-forward", action_name(opts)); ret = write_ref_sha1(ref_lock, to, sb.buf); + strbuf_release(&sb); return ret; } |