refs: add a generic 'optimize' API

The existing `pack-refs` API is conceptually tied to the 'files'
backend, but its behavior is generic (e.g., it triggers compaction for
reftable). This naming is confusing.

Introduce a new generic refs_optimize() API that dispatches to a
backend-specific implementation via a new 'optimize' vtable method.

This lays the architectural groundwork for different reference backends
(like 'files' and 'reftable') to provide their own storage optimization
logic, which will be called from a single, generic entry point.

Mentored-by: Patrick Steinhardt <ps@pks.im>
Mentored-by: shejialuo <shejialuo@gmail.com>
Signed-off-by: Meet Soni <meetsoni3017@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Meet Soni
2025-09-19 13:56:39 +05:30
committed by Junio C Hamano
parent f814da676a
commit 8dfe077fb6
3 changed files with 14 additions and 0 deletions

6
refs.h
View File

@@ -480,6 +480,12 @@ struct pack_refs_opts {
*/
int refs_pack_refs(struct ref_store *refs, struct pack_refs_opts *opts);
/*
* Optimize the ref store. The exact behavior is up to the backend.
* For the files backend, this is equivalent to packing refs.
*/
int refs_optimize(struct ref_store *refs, struct pack_refs_opts *opts);
/*
* Setup reflog before using. Fill in err and return -1 on failure.
*/