Re: [PATCH 0/5] refs: remove functions without ref store
- From
Junio C Hamano <gitster@pobox.com>
- Date
- May 7, 2024, 06:20 UTC
- Message-ID
- <xmqqa5l2ta7e.fsf@gitster.g>
- In-Reply-To
- <ZjnCoaVP9_wuYiHh@tanuki>
Patrick Steinhardt <ps@pks.im> writes:
Show 11 quoted lines
> message. The best I could come up with is the following:
>
> #define REPLACED_REFS_FUNC(func) func ## was_replaced_by_refs_### func
>
> Which results in compiler errors like this:
>
> bisect.c:712:6: error: use of undeclared identifier 'read_ref_was_replaced_by_refs_read_ref'
> 712 | if (read_ref("BISECT_EXPECTED_REV", &expected_oid))
>
> What is still missing is the bit of informatino that you need to pass in
> `get_main_ref_store()`. But maybe this is good enough?What I had in mind was a lot more stupid like the attached. For illustration purposes, I just did only one, but you got the idea. Thanks to "#if 0", the compilation will fail, the compiler telling the developer "resolve_ref_unsafe()? what are you talking about?", and the developer will grep for that name to find the hint at the end.
refs.h | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
diff --git c/refs.h w/refs.h index d278775e08..a7e1c261ac 100644 --- c/refs.h +++ w/refs.h @@ -72,9 +72,6 @@ const char *refs_resolve_ref_unsafe(struct ref_store *refs, struct object_id *oid, int *flags); -const char *resolve_ref_unsafe(const char *refname, int resolve_flags, - struct object_id *oid, int *flags); - char *refs_resolve_refdup(struct ref_store *refs, const char *refname, int resolve_flags, struct object_id *oid, int *flags); @@ -1054,4 +1051,15 @@ void update_ref_namespace(enum ref_namespace namespace, char *ref); int is_pseudoref(struct ref_store *refs, const char *refname); int is_headref(struct ref_store *refs, const char *refname); +/* The following are removed - rewrite your callers */ +#if 0 +static inline const char *resolve_ref_unsafe( + const char *refname, int resolve_flags, + struct object_id *oid, int *flags) +{ + return refs_resolve_ref_unsafe(get_main_ref_store(the_repository), + refname, resolve_flags, oid, flags); +} + +#endif #endif /* REFS_H */