v5
* address Ævar's comment; punt on clearing errno.
Han-Wen Nienhuys (6):
refs: remove EINVAL errno output from specification of read_raw_ref_fn
refs/files-backend: stop setting errno from lock_ref_oid_basic
refs: make errno output explicit for read_raw_ref_fn
refs: add failure_errno to refs_read_raw_ref() signature
refs: explicitly return failure_errno from parse_loose_ref_contents
refs: make errno output explicit for refs_resolve_ref_unsafe
refs.c | 58 ++++++++++++++++++++++-----------
refs/debug.c | 4 +--
refs/files-backend.c | 74 ++++++++++++++++++++++---------------------
refs/packed-backend.c | 15 +++++----
refs/refs-internal.h | 40 +++++++++++++++--------
5 files changed, 115 insertions(+), 76 deletions(-)
base-commit: 670b81a890388c60b7032a4f5b879f2ece8c4558
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1012%2Fhanwen%2Feinval-sideband-v5
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1012/hanwen/einval-sideband-v5
Pull-Request: https://github.com/git/git/pull/1012
Range-diff vs v4:
1: d6a41c3c0cb = 1: d6a41c3c0cb refs: remove EINVAL errno output from specification of read_raw_ref_fn
2: ff7ea6efcba ! 2: 95025080c16 refs/files-backend: stop setting errno from lock_ref_oid_basic
@@ Commit message
documented to use and/or preserve errno)
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
- Reviewed-By: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
+ Reviewed-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
## refs/files-backend.c ##
@@ refs/files-backend.c: static int create_reflock(const char *path, void *cb)
3: ff5696b0875 ! 3: 7feedb97201 refs: make errno output explicit for read_raw_ref_fn
@@ Commit message
relevant.
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
- Reviewed-By: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
+ Reviewed-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
## refs.c ##
@@ refs.c: int refs_read_raw_ref(struct ref_store *ref_store,
4: 9c933706cb0 ! 4: ef91f5cee13 refs: add failure_errno to refs_read_raw_ref() signature
@@ Commit message
This lets us use the explicit errno output parameter in refs_resolve_ref_unsafe.
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
- Reviewed-By: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
+ Reviewed-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
## refs.c ##
@@ refs.c: done:
@@ refs.c: done:
-int refs_read_raw_ref(struct ref_store *ref_store,
- const char *refname, struct object_id *oid,
- struct strbuf *referent, unsigned int *type)
+-{
+- int result;
+- int failure_errno;
+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)
- {
-- int result;
-- int failure_errno;
-+ int ignore;
-+ if (failure_errno)
-+ *failure_errno = 0;
-+ else
-+ failure_errno = &ignore;
-+
++{
++ int unused_errno;
++ if (!failure_errno)
++ failure_errno = &unused_errno;
++ *failure_errno = 0;
if (!strcmp(refname, "FETCH_HEAD") || !strcmp(refname, "MERGE_HEAD")) {
return refs_read_special_head(ref_store, refname, oid, referent,
type);
5: ab147afb38d ! 5: 6918c214d1b refs: explicitly return failure_errno from parse_loose_ref_contents
@@ Commit message
to create a custom error message.
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
- Reviewed-By: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
+ Reviewed-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
## refs.c ##
@@ refs.c: int for_each_fullref_in_prefixes(const char *namespace,
@@ refs.c: static int refs_read_special_head(struct ref_store *ref_store,
done:
strbuf_release(&full_path);
@@ refs.c: int refs_read_raw_ref(struct ref_store *ref_store, const char *refname,
-
+ *failure_errno = 0;
if (!strcmp(refname, "FETCH_HEAD") || !strcmp(refname, "MERGE_HEAD")) {
return refs_read_special_head(ref_store, refname, oid, referent,
- type);
@@ refs/files-backend.c: stat_ref:
+ ret = parse_loose_ref_contents(buf, oid, referent, type, failure_errno);
+ errno = *failure_errno;
out:
-+ /* Collect all types of failures from errno. Many system calls in this
-+ * function can fail with ENOTDIR/EISDIR, and we want to collect all of
-+ * them.
++ /*
++ * Many system calls in this function can fail with ENOTDIR/EISDIR, and
++ * we want to collect all of them, so simply copy the error out from
++ * errno.
+ */
*failure_errno = errno;
strbuf_release(&sb_path);
6: 0526a41b4b3 ! 6: 85a14bde904 refs: make errno output explicit for refs_resolve_ref_unsafe
@@ Commit message
that needs error information to make logic decisions, so update that caller
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
- Reviewed-By: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
+ Reviewed-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
## refs/files-backend.c ##
@@ refs/files-backend.c: static struct ref_lock *lock_ref_oid_basic(struct files_ref_store *refs,