From: Meet Soni <meetsoni3017@gmail.com>
To: git@vger.kernel.org
Cc: ps@pks.im, shejialuo@gmail.com, gitster@pobox.com,
Meet Soni <meetsoni3017@gmail.com>
Subject: [GSoC][PATCH v4 2/9] files-backend: implement 'optimize' action
Date: Fri, 19 Sep 2025 13:56:40 +0530 [thread overview]
Message-ID: <20250919082647.535213-3-meetsoni3017@gmail.com> (raw)
In-Reply-To: <20250919082647.535213-1-meetsoni3017@gmail.com>
With the generic `refs_optimize()` API now in place, provide the first
implementation for the 'files' reference backend. This makes the new API
functional for existing repositories and serves as the foundation for
migrating user-facing commands to the new architecture.
The implementation simply calls the existing `files_pack_refs()`
function, as 'packing' is the method used to optimize the files-based
reference store.
Wire up the new `files_optimize()` function to the `optimize` slot in
the files backend's virtual table.
Mentored-by: Patrick Steinhardt <ps@pks.im>
Mentored-by: shejialuo <shejialuo@gmail.com>
Signed-off-by: Meet Soni <meetsoni3017@gmail.com>
---
refs/files-backend.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/refs/files-backend.c b/refs/files-backend.c
index dfc8e9bc50..1428d3a6f1 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -1473,6 +1473,15 @@ static int files_pack_refs(struct ref_store *ref_store,
return 0;
}
+static int files_optimize(struct ref_store *ref_store, struct pack_refs_opts *opts)
+{
+ /*
+ * For the "files" backend, "optimizing" is the same as "packing".
+ * So, we just call the existing worker function for packing.
+ */
+ return files_pack_refs(ref_store, opts);
+}
+
/*
* People using contrib's git-new-workdir have .git/logs/refs ->
* /some/other/path/.git/logs/refs, and that may live on another device.
@@ -3909,6 +3918,7 @@ struct ref_storage_be refs_be_files = {
.transaction_abort = files_transaction_abort,
.pack_refs = files_pack_refs,
+ .optimize = files_optimize,
.rename_ref = files_rename_ref,
.copy_ref = files_copy_ref,
--
2.34.1
next prev parent reply other threads:[~2025-09-19 8:26 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-06 7:51 [GSoC][PATCH v2 0/5] Add refs optimize subcommand Meet Soni
2025-09-06 7:51 ` [GSoC][PATCH v2 1/5] builtin/pack-refs: factor out core logic into a shared library Meet Soni
2025-09-06 7:51 ` [GSoC][PATCH v2 2/5] doc: factor out common option Meet Soni
2025-09-08 16:44 ` Junio C Hamano
2025-09-06 7:51 ` [GSoC][PATCH v2 3/5] builtin/refs: add optimize subcommand Meet Soni
2025-09-06 7:51 ` [GSoC][PATCH v2 4/5] t0601: refactor tests to be shareable Meet Soni
2025-09-06 7:51 ` [GSoC][PATCH v2 5/5] t: add test for git refs optimize subcommand Meet Soni
2025-09-08 14:07 ` [GSoC][PATCH v2 0/5] Add " Junio C Hamano
2025-09-08 16:41 ` Junio C Hamano
2025-09-18 5:46 ` [GSoC][PATCH v3 0/9] " Meet Soni
2025-09-18 5:46 ` [GSoC][PATCH v3 1/9] refs: add a generic 'optimize' API Meet Soni
2025-09-18 10:44 ` shejialuo
2025-09-18 15:39 ` Junio C Hamano
2025-09-18 5:46 ` [GSoC][PATCH v3 2/9] files-backend: implement 'optimize' action Meet Soni
2025-09-18 5:46 ` [GSoC][PATCH v3 3/9] reftable-backend: " Meet Soni
2025-09-18 5:46 ` [GSoC][PATCH v3 4/9] builtin/pack-refs: convert to use the generic refs_optimize() API Meet Soni
2025-09-18 10:43 ` shejialuo
2025-09-18 5:47 ` [GSoC][PATCH v3 5/9] builtin/pack-refs: factor out core logic into a shared library Meet Soni
2025-09-18 5:47 ` [GSoC][GSoC][PATCH v3 6/9] doc: pack-refs: factor out common options Meet Soni
2025-09-18 5:47 ` [GSoC][PATCH v3 7/9] builtin/refs: add optimize subcommand Meet Soni
2025-09-18 16:06 ` Junio C Hamano
2025-09-18 5:47 ` [GSoC][PATCH v3 8/9] t0601: refactor tests to be shareable Meet Soni
2025-09-18 5:47 ` [GSoC][PATCH v3 9/9] t: add test for git refs optimize subcommand Meet Soni
2025-09-19 8:26 ` [GSoC][PATCH v4 0/9] Add " Meet Soni
2025-09-19 8:26 ` [GSoC][PATCH v4 1/9] refs: add a generic 'optimize' API Meet Soni
2025-09-24 6:18 ` Patrick Steinhardt
2025-09-19 8:26 ` Meet Soni [this message]
2025-09-19 8:26 ` [GSoC][PATCH v4 3/9] reftable-backend: implement 'optimize' action Meet Soni
2025-09-19 8:26 ` [GSoC][PATCH v4 4/9] builtin/pack-refs: convert to use the generic refs_optimize() API Meet Soni
2025-09-19 8:26 ` [GSoC][PATCH v4 5/9] builtin/pack-refs: factor out core logic into a shared library Meet Soni
2025-09-24 6:18 ` Patrick Steinhardt
2025-09-19 8:26 ` [GSoC][PATCH v4 6/9] doc: pack-refs: factor out common options Meet Soni
2025-09-19 8:26 ` [GSoC][PATCH v4 7/9] builtin/refs: add optimize subcommand Meet Soni
2025-09-19 8:26 ` [GSoC][PATCH v4 8/9] t0601: refactor tests to be shareable Meet Soni
2025-09-19 8:26 ` [GSoC][PATCH v4 9/9] t: add test for git refs optimize subcommand Meet Soni
2025-09-19 18:43 ` [GSoC][PATCH v4 0/9] Add " Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250919082647.535213-3-meetsoni3017@gmail.com \
--to=meetsoni3017@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=ps@pks.im \
--cc=shejialuo@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).