summaryrefslogtreecommitdiff
path: root/refs
diff options
context:
space:
mode:
authorHan-Wen Nienhuys <hanwen@google.com>2021-10-16 09:39:09 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-10-16 18:17:02 (GMT)
commit8b72fea7e91b5900c3a35891df1d8ea16d4b2bee (patch)
tree5d0c064a0a876640d0c6754858ae7b03bd77a056 /refs
parentef18119dec8a9c65ed545fdd60c7ae9a6bc31f6f (diff)
downloadgit-8b72fea7e91b5900c3a35891df1d8ea16d4b2bee.zip
git-8b72fea7e91b5900c3a35891df1d8ea16d4b2bee.tar.gz
git-8b72fea7e91b5900c3a35891df1d8ea16d4b2bee.tar.bz2
refs API: make refs_read_raw_ref() not set errno
Add a "failure_errno" to refs_read_raw_ref(), his allows refs_werrres_ref_unsafe() to pass along its "failure_errno", as a first step before its own callers are migrated to pass it further up the chain. We are leaving out out the refs_read_special_head() in refs_read_raw_ref() for now, as noted in a subsequent commit moving it to "failure_errno" will require some special consideration. Signed-off-by: Han-Wen Nienhuys <hanwen@google.com> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs')
-rw-r--r--refs/files-backend.c10
-rw-r--r--refs/packed-backend.c7
-rw-r--r--refs/refs-internal.h6
3 files changed, 13 insertions, 10 deletions
diff --git a/refs/files-backend.c b/refs/files-backend.c
index 6a6ead0..94c1946 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -381,10 +381,11 @@ stat_ref:
goto out;
if (lstat(path, &st) < 0) {
+ int ignore_errno;
if (errno != ENOENT)
goto out;
- if (refs_read_raw_ref(refs->packed_ref_store, refname,
- oid, referent, type)) {
+ if (refs_read_raw_ref(refs->packed_ref_store, refname, oid,
+ referent, type, &ignore_errno)) {
errno = ENOENT;
goto out;
}
@@ -418,13 +419,14 @@ stat_ref:
/* Is it a directory? */
if (S_ISDIR(st.st_mode)) {
+ int ignore_errno;
/*
* Even though there is a directory where the loose
* ref is supposed to be, there could still be a
* packed ref:
*/
- if (refs_read_raw_ref(refs->packed_ref_store, refname,
- oid, referent, type)) {
+ if (refs_read_raw_ref(refs->packed_ref_store, refname, oid,
+ referent, type, &ignore_errno)) {
errno = EISDIR;
goto out;
}
diff --git a/refs/packed-backend.c b/refs/packed-backend.c
index 47247a1..52cdc94 100644
--- a/refs/packed-backend.c
+++ b/refs/packed-backend.c
@@ -1347,6 +1347,7 @@ int is_packed_transaction_needed(struct ref_store *ref_store,
ret = 0;
for (i = 0; i < transaction->nr; i++) {
struct ref_update *update = transaction->updates[i];
+ int failure_errno;
unsigned int type;
struct object_id oid;
@@ -1357,9 +1358,9 @@ int is_packed_transaction_needed(struct ref_store *ref_store,
*/
continue;
- if (!refs_read_raw_ref(ref_store, update->refname,
- &oid, &referent, &type) ||
- errno != ENOENT) {
+ if (!refs_read_raw_ref(ref_store, update->refname, &oid,
+ &referent, &type, &failure_errno) ||
+ failure_errno != ENOENT) {
/*
* We have to actually delete that reference
* -> this transaction is needed.
diff --git a/refs/refs-internal.h b/refs/refs-internal.h
index 7274640..c87f113 100644
--- a/refs/refs-internal.h
+++ b/refs/refs-internal.h
@@ -149,9 +149,9 @@ struct ref_update {
const char refname[FLEX_ARRAY];
};
-int refs_read_raw_ref(struct ref_store *ref_store,
- const char *refname, struct object_id *oid,
- struct strbuf *referent, unsigned int *type);
+int refs_read_raw_ref(struct ref_store *ref_store, const char *refname,
+ struct object_id *oid, struct strbuf *referent,
+ unsigned int *type, int *failure_errno);
/*
* Write an error to `err` and return a nonzero value iff the same