]> git.ipfire.org Git - thirdparty/git.git/commitdiff
refs API: post-migration API renaming [1/2]
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Sat, 16 Oct 2021 09:39:26 +0000 (11:39 +0200)
committerJunio C Hamano <gitster@pobox.com>
Sat, 16 Oct 2021 18:17:04 +0000 (11:17 -0700)
In preceding commits all callers of refs_resolve_ref_unsafe() were
migrated to the transitory refs_werrres_ref_unsafe() function.

As a first step in getting rid of it let's remove the old function
from the public API (it went unused in a preceding commit).

We then provide both a coccinelle rule to do the rename, and a macro
to avoid breaking the existing callers.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/coccinelle/refs.pending.cocci [new file with mode: 0644]
refs.c
refs.h

diff --git a/contrib/coccinelle/refs.pending.cocci b/contrib/coccinelle/refs.pending.cocci
new file mode 100644 (file)
index 0000000..b33cb8a
--- /dev/null
@@ -0,0 +1,5 @@
+@@
+expression refs, refname, resolve_flags, oid, flags, failure_errno;
+@@
+- refs_werrres_ref_unsafe(refs, refname, resolve_flags, oid, flags, failure_errno)
++ refs_resolve_ref_unsafe(refs, refname, resolve_flags, oid, flags, failure_errno)
diff --git a/refs.c b/refs.c
index e90c59539b45370caf80fce8297d32564077711e..4e06745c97aa60712981ac37d5e2c9b906464c07 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -1669,7 +1669,7 @@ int refs_read_raw_ref(struct ref_store *ref_store, const char *refname,
                                           type, failure_errno);
 }
 
-const char *refs_werrres_ref_unsafe(struct ref_store *refs,
+const char *refs_resolve_ref_unsafe(struct ref_store *refs,
                                    const char *refname,
                                    int resolve_flags,
                                    struct object_id *oid,
@@ -1766,19 +1766,6 @@ const char *refs_werrres_ref_unsafe(struct ref_store *refs,
        return NULL;
 }
 
-const char *refs_resolve_ref_unsafe(struct ref_store *refs, const char *refname,
-                                   int resolve_flags, struct object_id *oid,
-                                   int *flags)
-{
-       int failure_errno = 0;
-       const char *refn;
-       refn = refs_werrres_ref_unsafe(refs, refname, resolve_flags,
-                                      oid, flags, &failure_errno);
-       if (!refn)
-               errno = failure_errno;
-       return refn;
-}
-
 /* backend functions */
 int refs_init_db(struct strbuf *err)
 {
diff --git a/refs.h b/refs.h
index 3938f99c9028ddc386f821a3cc56df83071b0351..d908a161c0662794f7a66fa15c3d15cbf90cf314 100644 (file)
--- a/refs.h
+++ b/refs.h
@@ -11,18 +11,6 @@ struct string_list;
 struct string_list_item;
 struct worktree;
 
-/*
- * Callers should not inspect "errno" on failure, but rather pass in a
- * "failure_errno" parameter, on failure the "errno" will indicate the
- * type of failure encountered, but not necessarily one that came from
- * a syscall. We might have faked it up.
- */
-const char *refs_werrres_ref_unsafe(struct ref_store *refs,
-                                   const char *refname,
-                                   int resolve_flags,
-                                   struct object_id *oid,
-                                   int *flags, int *failure_errno);
-
 /*
  * Resolve a reference, recursively following symbolic refererences.
  *
@@ -70,16 +58,24 @@ const char *refs_werrres_ref_unsafe(struct ref_store *refs,
  * resolved. The function returns NULL for such ref names.
  * Caps and underscores refers to the special refs, such as HEAD,
  * FETCH_HEAD and friends, that all live outside of the refs/ directory.
+ *
+ * Callers should not inspect "errno" on failure, but rather pass in a
+ * "failure_errno" parameter, on failure the "errno" will indicate the
+ * type of failure encountered, but not necessarily one that came from
+ * a syscall. We might have faked it up.
  */
 #define RESOLVE_REF_READING 0x01
 #define RESOLVE_REF_NO_RECURSE 0x02
 #define RESOLVE_REF_ALLOW_BAD_NAME 0x04
 
+#define refs_werrres_ref_unsafe(refs, refname, resolve_flags, oid, flags, failure_errno) \
+       refs_resolve_ref_unsafe(refs, refname, resolve_flags, oid, flags, failure_errno)
 const char *refs_resolve_ref_unsafe(struct ref_store *refs,
                                    const char *refname,
                                    int resolve_flags,
                                    struct object_id *oid,
-                                   int *flags);
+                                   int *flags, int *failure_errno);
+
 const char *resolve_ref_unsafe(const char *refname, int resolve_flags,
                               struct object_id *oid, int *flags);