ref_file = git_path("%s", orig_refname);
if (remove_empty_directories(ref_file)) {
last_errno = errno;
- strbuf_addf(err, "there are still refs under '%s'",
- orig_refname);
+
+ if (!verify_refname_available(orig_refname, extras, skip,
+ get_loose_refs(&ref_cache), err))
+ strbuf_addf(err, "there are still refs under '%s'",
+ orig_refname);
+
goto error_return;
}
refname = resolve_ref_unsafe(orig_refname, resolve_flags,
*type_p = type;
if (!refname) {
last_errno = errno;
- strbuf_addf(err, "unable to resolve reference %s: %s",
- orig_refname, strerror(errno));
+ if (last_errno != ENOTDIR ||
+ !verify_refname_available(orig_refname, extras, skip,
+ get_loose_refs(&ref_cache), err))
+ strbuf_addf(err, "unable to resolve reference %s: %s",
+ orig_refname, strerror(last_errno));
+
goto error_return;
}
/*
lock = lock_ref_sha1_basic(newrefname, NULL, NULL, NULL, 0, NULL, &err);
if (!lock) {
- error("%s", err.buf);
+ error("unable to rename '%s' to '%s': %s", oldrefname, newrefname, err.buf);
strbuf_release(&err);
- error("unable to lock %s for update", newrefname);
goto rollback;
}
hashcpy(lock->old_sha1, orig_sha1);
rollback:
lock = lock_ref_sha1_basic(oldrefname, NULL, NULL, NULL, 0, NULL, &err);
if (!lock) {
- error("%s", err.buf);
+ error("unable to lock %s for rollback: %s", oldrefname, err.buf);
strbuf_release(&err);
- error("unable to lock %s for rollback", oldrefname);
goto rollbacklog;
}
&update->type,
err);
if (!update->lock) {
+ char *reason;
+
ret = (errno == ENOTDIR)
? TRANSACTION_NAME_CONFLICT
: TRANSACTION_GENERIC_ERROR;
- error("%s", err->buf);
- strbuf_reset(err);
- strbuf_addf(err, "Cannot lock the ref '%s'.",
- update->refname);
+ reason = strbuf_detach(err, NULL);
+ strbuf_addf(err, "Cannot lock ref '%s': %s",
+ update->refname, reason);
+ free(reason);
goto cleanup;
}
}
*/
lock = lock_ref_sha1_basic(refname, sha1, NULL, NULL, 0, &type, &err);
if (!lock) {
- error("%s", err.buf);
+ error("cannot lock ref '%s': %s", refname, err.buf);
strbuf_release(&err);
- return error("cannot lock ref '%s'", refname);
+ return -1;
}
if (!reflog_exists(refname)) {
unlock_ref(lock);