refs API: post-migration API renaming [1/2]
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>
Ævar Arnfjörð Bjarmason committed
Oct 16, 2021 at 11:39 UTC
25a33b33424cd6c8e2c7db0f0c4b1ba01415ce38
3 files changed
+15
-27
contrib/coccinelle/refs.pending.cocci
new
+5
@@ -0,0 +1,5 @@
1
+@@
2
+expression refs, refname, resolve_flags, oid, flags, failure_errno;
3
+@@
4
+- refs_werrres_ref_unsafe(refs, refname, resolve_flags, oid, flags, failure_errno)
5
++ refs_resolve_ref_unsafe(refs, refname, resolve_flags, oid, flags, failure_errno)
refs.c
+1
-14
@@ -1669,7 +1669,7 @@ int refs_read_raw_ref(struct ref_store *ref_store, const char *refname,
1669
type, failure_errno);
1670
}
1671
1672
-const char *refs_werrres_ref_unsafe(struct ref_store *refs,
1672
+const char *refs_resolve_ref_unsafe(struct ref_store *refs,
1673
const char *refname,
1674
int resolve_flags,
1675
struct object_id *oid,
@@ -1766,19 +1766,6 @@ const char *refs_werrres_ref_unsafe(struct ref_store *refs,
1766
return NULL;
1767
}
1768
1769
-const char *refs_resolve_ref_unsafe(struct ref_store *refs, const char *refname,
1770
- int resolve_flags, struct object_id *oid,
1771
- int *flags)
1772
-{
1773
- int failure_errno = 0;
1774
- const char *refn;
1775
- refn = refs_werrres_ref_unsafe(refs, refname, resolve_flags,
1776
- oid, flags, &failure_errno);
1777
- if (!refn)
1778
- errno = failure_errno;
1779
- return refn;
1780
-}
1781
-
1769
/* backend functions */
1770
int refs_init_db(struct strbuf *err)
1771
{
refs.h
+9
-13
@@ -11,18 +11,6 @@ struct string_list;
11
struct string_list_item;
12
struct worktree;
13
14
-/*
15
- * Callers should not inspect "errno" on failure, but rather pass in a
16
- * "failure_errno" parameter, on failure the "errno" will indicate the
17
- * type of failure encountered, but not necessarily one that came from
18
- * a syscall. We might have faked it up.
19
- */
20
-const char *refs_werrres_ref_unsafe(struct ref_store *refs,
21
- const char *refname,
22
- int resolve_flags,
23
- struct object_id *oid,
24
- int *flags, int *failure_errno);
25
-
14
/*
15
* Resolve a reference, recursively following symbolic refererences.
16
*
@@ -70,16 +58,24 @@ const char *refs_werrres_ref_unsafe(struct ref_store *refs,
58
* resolved. The function returns NULL for such ref names.
59
* Caps and underscores refers to the special refs, such as HEAD,
60
* FETCH_HEAD and friends, that all live outside of the refs/ directory.
61
+ *
62
+ * Callers should not inspect "errno" on failure, but rather pass in a
63
+ * "failure_errno" parameter, on failure the "errno" will indicate the
64
+ * type of failure encountered, but not necessarily one that came from
65
+ * a syscall. We might have faked it up.
66
*/
67
#define RESOLVE_REF_READING 0x01
68
#define RESOLVE_REF_NO_RECURSE 0x02
69
#define RESOLVE_REF_ALLOW_BAD_NAME 0x04
70
71
+#define refs_werrres_ref_unsafe(refs, refname, resolve_flags, oid, flags, failure_errno) \
72
+ refs_resolve_ref_unsafe(refs, refname, resolve_flags, oid, flags, failure_errno)
73
const char *refs_resolve_ref_unsafe(struct ref_store *refs,
74
const char *refname,
75
int resolve_flags,
76
struct object_id *oid,
82
- int *flags);
77
+ int *flags, int *failure_errno);
78
+
79
const char *resolve_ref_unsafe(const char *refname, int resolve_flags,
80
struct object_id *oid, int *flags);
81