Skip to content

Commit 1fd6067

Browse files
inosmeetgitster
authored andcommitted
files-backend: implement 'optimize' action
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 <[email protected]> Mentored-by: shejialuo <[email protected]> Signed-off-by: Meet Soni <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8dfe077 commit 1fd6067

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

refs/files-backend.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,6 +1473,15 @@ static int files_pack_refs(struct ref_store *ref_store,
14731473
return 0;
14741474
}
14751475

1476+
static int files_optimize(struct ref_store *ref_store, struct pack_refs_opts *opts)
1477+
{
1478+
/*
1479+
* For the "files" backend, "optimizing" is the same as "packing".
1480+
* So, we just call the existing worker function for packing.
1481+
*/
1482+
return files_pack_refs(ref_store, opts);
1483+
}
1484+
14761485
/*
14771486
* People using contrib's git-new-workdir have .git/logs/refs ->
14781487
* /some/other/path/.git/logs/refs, and that may live on another device.
@@ -3909,6 +3918,7 @@ struct ref_storage_be refs_be_files = {
39093918
.transaction_abort = files_transaction_abort,
39103919

39113920
.pack_refs = files_pack_refs,
3921+
.optimize = files_optimize,
39123922
.rename_ref = files_rename_ref,
39133923
.copy_ref = files_copy_ref,
39143924

0 commit comments

Comments
 (0)