aboutsummaryrefslogtreecommitdiffstats
path: root/refs
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2025-11-04 07:31:19 -0800
committerJunio C Hamano <gitster@pobox.com>2025-11-04 07:31:19 -0800
commit5ab9228d7a2de8896948232f2b32c34b4e192166 (patch)
tree65183e13ad8aeebb64f2e0ec08752352bb7bbdab /refs
parentSync with Git 2.52-rc0 (diff)
downloadgit-5ab9228d7a2de8896948232f2b32c34b4e192166.tar.gz
git-5ab9228d7a2de8896948232f2b32c34b4e192166.zip
Revert "Merge branch 'kn/refs-optim-cleanup' into next"
This reverts commit 8c2d7a4413436c0f91af0c0ab978cba8af905696, reversing changes made to 8ac48a10de61267858d66383c34833e55a5e9d02.
Diffstat (limited to 'refs')
-rw-r--r--refs/debug.c8
-rw-r--r--refs/files-backend.c22
-rw-r--r--refs/packed-backend.c6
-rw-r--r--refs/refs-internal.h5
-rw-r--r--refs/reftable-backend.c15
5 files changed, 38 insertions, 18 deletions
diff --git a/refs/debug.c b/refs/debug.c
index 54f409c249..f38991c02a 100644
--- a/refs/debug.c
+++ b/refs/debug.c
@@ -124,11 +124,11 @@ static int debug_transaction_abort(struct ref_store *refs,
return res;
}
-static int debug_optimize(struct ref_store *ref_store, struct refs_optimize_opts *opts)
+static int debug_pack_refs(struct ref_store *ref_store, struct pack_refs_opts *opts)
{
struct debug_ref_store *drefs = (struct debug_ref_store *)ref_store;
- int res = drefs->refs->be->optimize(drefs->refs, opts);
- trace_printf_key(&trace_refs, "optimize: %d\n", res);
+ int res = drefs->refs->be->pack_refs(drefs->refs, opts);
+ trace_printf_key(&trace_refs, "pack_refs: %d\n", res);
return res;
}
@@ -439,7 +439,7 @@ struct ref_storage_be refs_be_debug = {
.transaction_finish = debug_transaction_finish,
.transaction_abort = debug_transaction_abort,
- .optimize = debug_optimize,
+ .pack_refs = debug_pack_refs,
.rename_ref = debug_rename_ref,
.copy_ref = debug_copy_ref,
diff --git a/refs/files-backend.c b/refs/files-backend.c
index a1e70b1c10..f4809edda8 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -1355,7 +1355,7 @@ static void prune_refs(struct files_ref_store *refs, struct ref_to_prune **refs_
*/
static int should_pack_ref(struct files_ref_store *refs,
const struct reference *ref,
- struct refs_optimize_opts *opts)
+ struct pack_refs_opts *opts)
{
struct string_list_item *item;
@@ -1383,7 +1383,7 @@ static int should_pack_ref(struct files_ref_store *refs,
}
static int should_pack_refs(struct files_ref_store *refs,
- struct refs_optimize_opts *opts)
+ struct pack_refs_opts *opts)
{
struct ref_iterator *iter;
size_t packed_size;
@@ -1391,7 +1391,7 @@ static int should_pack_refs(struct files_ref_store *refs,
size_t limit;
int ret;
- if (!(opts->flags & REFS_OPTIMIZE_AUTO))
+ if (!(opts->flags & PACK_REFS_AUTO))
return 1;
ret = packed_refs_size(refs->packed_ref_store, &packed_size);
@@ -1444,8 +1444,8 @@ static int should_pack_refs(struct files_ref_store *refs,
return 0;
}
-static int files_optimize(struct ref_store *ref_store,
- struct refs_optimize_opts *opts)
+static int files_pack_refs(struct ref_store *ref_store,
+ struct pack_refs_opts *opts)
{
struct files_ref_store *refs =
files_downcast(ref_store, REF_STORE_WRITE | REF_STORE_ODB,
@@ -1488,7 +1488,7 @@ static int files_optimize(struct ref_store *ref_store,
iter->ref.name, err.buf);
/* Schedule the loose reference for pruning if requested. */
- if ((opts->flags & REFS_OPTIMIZE_PRUNE)) {
+ if ((opts->flags & PACK_REFS_PRUNE)) {
struct ref_to_prune *n;
FLEX_ALLOC_STR(n, name, iter->ref.name);
oidcpy(&n->oid, iter->ref.oid);
@@ -1512,6 +1512,15 @@ static int files_optimize(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.
@@ -3981,6 +3990,7 @@ struct ref_storage_be refs_be_files = {
.transaction_finish = files_transaction_finish,
.transaction_abort = files_transaction_abort,
+ .pack_refs = files_pack_refs,
.optimize = files_optimize,
.rename_ref = files_rename_ref,
.copy_ref = files_copy_ref,
diff --git a/refs/packed-backend.c b/refs/packed-backend.c
index 10062fd8b6..1ab0c50393 100644
--- a/refs/packed-backend.c
+++ b/refs/packed-backend.c
@@ -1773,8 +1773,8 @@ cleanup:
return ret;
}
-static int packed_optimize(struct ref_store *ref_store UNUSED,
- struct refs_optimize_opts *opts UNUSED)
+static int packed_pack_refs(struct ref_store *ref_store UNUSED,
+ struct pack_refs_opts *pack_opts UNUSED)
{
/*
* Packed refs are already packed. It might be that loose refs
@@ -2129,7 +2129,7 @@ struct ref_storage_be refs_be_packed = {
.transaction_finish = packed_transaction_finish,
.transaction_abort = packed_transaction_abort,
- .optimize = packed_optimize,
+ .pack_refs = packed_pack_refs,
.rename_ref = NULL,
.copy_ref = NULL,
diff --git a/refs/refs-internal.h b/refs/refs-internal.h
index dee42f231d..4671517dad 100644
--- a/refs/refs-internal.h
+++ b/refs/refs-internal.h
@@ -422,8 +422,10 @@ typedef int ref_transaction_commit_fn(struct ref_store *refs,
struct ref_transaction *transaction,
struct strbuf *err);
+typedef int pack_refs_fn(struct ref_store *ref_store,
+ struct pack_refs_opts *opts);
typedef int optimize_fn(struct ref_store *ref_store,
- struct refs_optimize_opts *opts);
+ struct pack_refs_opts *opts);
typedef int rename_ref_fn(struct ref_store *ref_store,
const char *oldref, const char *newref,
const char *logmsg);
@@ -548,6 +550,7 @@ struct ref_storage_be {
ref_transaction_finish_fn *transaction_finish;
ref_transaction_abort_fn *transaction_abort;
+ pack_refs_fn *pack_refs;
optimize_fn *optimize;
rename_ref_fn *rename_ref;
copy_ref_fn *copy_ref;
diff --git a/refs/reftable-backend.c b/refs/reftable-backend.c
index c23c45f3bf..6bbfd5618d 100644
--- a/refs/reftable-backend.c
+++ b/refs/reftable-backend.c
@@ -1700,11 +1700,11 @@ done:
return ret;
}
-static int reftable_be_optimize(struct ref_store *ref_store,
- struct refs_optimize_opts *opts)
+static int reftable_be_pack_refs(struct ref_store *ref_store,
+ struct pack_refs_opts *opts)
{
struct reftable_ref_store *refs =
- reftable_be_downcast(ref_store, REF_STORE_WRITE | REF_STORE_ODB, "optimize_refs");
+ reftable_be_downcast(ref_store, REF_STORE_WRITE | REF_STORE_ODB, "pack_refs");
struct reftable_stack *stack;
int ret;
@@ -1715,7 +1715,7 @@ static int reftable_be_optimize(struct ref_store *ref_store,
if (!stack)
stack = refs->main_backend.stack;
- if (opts->flags & REFS_OPTIMIZE_AUTO)
+ if (opts->flags & PACK_REFS_AUTO)
ret = reftable_stack_auto_compact(stack);
else
ret = reftable_stack_compact_all(stack, NULL);
@@ -1733,6 +1733,12 @@ out:
return ret;
}
+static int reftable_be_optimize(struct ref_store *ref_store,
+ struct pack_refs_opts *opts)
+{
+ return reftable_be_pack_refs(ref_store, opts);
+}
+
struct write_create_symref_arg {
struct reftable_ref_store *refs;
struct reftable_stack *stack;
@@ -2755,6 +2761,7 @@ struct ref_storage_be refs_be_reftable = {
.transaction_finish = reftable_be_transaction_finish,
.transaction_abort = reftable_be_transaction_abort,
+ .pack_refs = reftable_be_pack_refs,
.optimize = reftable_be_optimize,
.rename_ref = reftable_be_rename_ref,
.copy_ref = reftable_be_copy_ref,