From: Junio C Hamano Date: Mon, 13 Jul 2026 16:34:17 GMT Subject: Re: [PATCH v2 12/12] odb: make optimizations pluggable Message-ID: In-Reply-To: <20260713-b4-pks-odb-optimize-v2-12-9c2c3ee94b38@pks.im> Patrick Steinhardt writes: > Move `odb_optimize()` and `odb_optimize_required()` from "builtin/gc.c" > into the "files" source and wire them up via newly introduced vtable > pointers for the object database sources. This makes the logic pluggable > and thus allows other backends to have their own, custom implementation. > > Signed-off-by: Patrick Steinhardt > --- > builtin/gc.c | 490 +---------------------------------------------------- > odb.c | 12 ++ > odb.h | 45 +++++ > odb/source-files.c | 470 ++++++++++++++++++++++++++++++++++++++++++++++++++ Reviewing this commit with "git show --color-moved" is an excellent way to verify that this is 90% pure code motion. Only minimal adjustments were required, such as replacing a direct reference to a struct member in the original with a variable that was previously assigned the equivalent value. For example, this original > - switch (opts->strategy) { > - case ODB_OPTIMIZE_INCREMENTAL: { > - int gc_auto_threshold = 6700; > - int gc_auto_pack_limit = 50; > - > - repo_config_get_int(odb->repo, "gc.auto", &gc_auto_threshold); > - repo_config_get_int(odb->repo, "gc.autopacklimit", &gc_auto_pack_limit); > - > - /* > - * Setting gc.auto to 0 or negative can disable the > - * automatic gc. > - */ turns into > + switch (opts->strategy) { > + case ODB_OPTIMIZE_INCREMENTAL: { > + int gc_auto_threshold = 6700; > + int gc_auto_pack_limit = 50; > + > + repo_config_get_int(repo, "gc.auto", &gc_auto_threshold); > + repo_config_get_int(repo, "gc.autopacklimit", &gc_auto_pack_limit); > + > + /* > + * Setting gc.auto to 0 or negative can disable the > + * automatic gc. > + */ And the change from odb->repo vs repo is such an adjustment. Looking good.