lock_ref_sha1_basic(): report errors via a "struct strbuf *err"