/* Is it a directory? */
if (S_ISDIR(st.st_mode)) {
- errno = EISDIR;
+ /*
+ * Even though there is a directory where the loose
+ * ref is supposed to be, there could still be a
+ * packed ref:
+ */
+ if (resolve_missing_loose_ref(refname, sha1, flags)) {
+ errno = EISDIR;
+ goto out;
+ }
+ ret = 0;
goto out;
}
}
}
if (commit_ref(lock)) {
- error("Couldn't set %s", lock->ref_name);
+ strbuf_addf(err, "Couldn't set %s", lock->ref_name);
unlock_ref(lock);
return -1;
}