diff options
| author | Karthik Nayak <karthik.188@gmail.com> | 2025-11-06 09:22:32 +0100 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-11-06 10:00:07 -0800 |
| commit | 5a3355f3d94f1ea70751f32d5a55232b4d97eb41 (patch) | |
| tree | 5827c1dbeae1bc0d85c897d9ec40e298e99ab48b /refs/files-backend.c | |
| parent | reftable/stack: add function to check if optimization is required (diff) | |
| download | git-5a3355f3d94f1ea70751f32d5a55232b4d97eb41.tar.gz git-5a3355f3d94f1ea70751f32d5a55232b4d97eb41.zip | |
refs: add a `optimize_required` field to `struct ref_storage_be`
To allow users of the refs namespace to check if the reference backend
requires optimization, add a new field `optimize_required` field to
`struct ref_storage_be`. This field is of type `optimize_required_fn`
which is also introduced in this commit.
Modify the debug, files, packed and reftable backend to implement this
field. A following commit will expose this via 'git pack-refs' and 'git
refs optimize'.
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs/files-backend.c')
| -rw-r--r-- | refs/files-backend.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/refs/files-backend.c b/refs/files-backend.c index a1e70b1c10..6e0c9b340a 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -1512,6 +1512,16 @@ static int files_optimize(struct ref_store *ref_store, return 0; } +static int files_optimize_required(struct ref_store *ref_store, + struct refs_optimize_opts *opts, + bool *required) +{ + struct files_ref_store *refs = files_downcast(ref_store, REF_STORE_READ, + "optimize_required"); + *required = should_pack_refs(refs, opts); + return 0; +} + /* * People using contrib's git-new-workdir have .git/logs/refs -> * /some/other/path/.git/logs/refs, and that may live on another device. @@ -3982,6 +3992,7 @@ struct ref_storage_be refs_be_files = { .transaction_abort = files_transaction_abort, .optimize = files_optimize, + .optimize_required = files_optimize_required, .rename_ref = files_rename_ref, .copy_ref = files_copy_ref, |
