refs API: make files_copy_or_rename_ref() et al not set errno

None of the callers of rename_ref() and copy_ref() care about errno, and as seen in the context here we already emit our own non-errno using error() in the case where we'd use it. So let's have it explicitly ignore errno, and do the same in commit_ref_update(), which is only used within other code in files_copy_or_rename_ref() itself which doesn't care about errno either. It might actually be sensible to have the callers use errno if the failure was filesystem-specific, and with the upcoming reftable backend we don't want to rely on that sort of thing, so let's keep ignoring that for now. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Oct 16, 2021 at 11:39 UTC ac0986e302b9a94fd927e8d0a811fe6dc4d4c074
1 file changed +6 -4
refs/files-backend.c
+6 -4
@@ -1410,9 +1410,9 @@ static int files_copy_or_rename_ref(struct ref_store *ref_store,
1410 goto out;
1411 }
1412
1413 - if (!refs_resolve_ref_unsafe(&refs->base, oldrefname,
1413 + if (!refs_werrres_ref_unsafe(&refs->base, oldrefname,
1414 RESOLVE_REF_READING | RESOLVE_REF_NO_RECURSE,
1415 - &orig_oid, &flag)) {
1415 + &orig_oid, &flag, &ignore_errno)) {
1416 ret = error("refname %s not found", oldrefname);
1417 goto out;
1418 }
@@ -1823,10 +1823,12 @@ static int commit_ref_update(struct files_ref_store *refs,
1823 */
1824 int head_flag;
1825 const char *head_ref;
1826 + int ignore_errno;
1827
1827 - head_ref = refs_resolve_ref_unsafe(&refs->base, "HEAD",
1828 + head_ref = refs_werrres_ref_unsafe(&refs->base, "HEAD",
1829 RESOLVE_REF_READING,
1829 - NULL, &head_flag);
1830 + NULL, &head_flag,
1831 + &ignore_errno);
1832 if (head_ref && (head_flag & REF_ISSYMREF) &&
1833 !strcmp(head_ref, lock->ref_name)) {
1834 struct strbuf log_err = STRBUF_INIT;