Commit

0e67428c8580c461317768f7fe9916c71435d9e3

odb: drop `loaded_alternates` field

The `struct object_database::loaded_alternates` field tells us whether
or not alternates have been loaded already. This field was useful before
the preceding commit as we were indeed lazy-loading alternates. But now
that we started to eagerly load them we can assume them to be loaded
after `odb_new()`, and hence the field does not serve any purpose
anymore.

Remove it.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt <ps@pks.im> · 2026-08-17 11:09 UTC · committed by Junio C Hamano

Browse files
2 files changed, +1 −10
modified odb.c
@@ -245,8 +245,7 @@ void odb_add_to_alternates_file(struct object_database *odb,
245 245 int ret = odb_source_write_alternate(odb->sources, dir);
246 246 if (ret < 0)
247 247 die(NULL);
248 - if (odb->loaded_alternates)
249 - odb_add_alternate_recursively(odb, dir, 0);
248 + odb_add_alternate_recursively(odb, dir, 0);
250 249 }
251 250
252 251 struct odb_source *odb_add_to_alternates_memory(struct object_database *odb,
@@ -510,16 +509,11 @@ static void odb_prepare_alternates(struct object_database *odb)
510 509 {
511 510 struct strvec sources = STRVEC_INIT;
512 511
513 - if (odb->loaded_alternates)
514 - return;
515 -
516 512 parse_alternates(odb->alternate_db, PATH_SEP, NULL, &sources);
517 513 odb_source_read_alternates(odb->sources, &sources);
518 514 for (size_t i = 0; i < sources.nr; i++)
519 515 odb_add_alternate_recursively(odb, sources.v[i], 0);
520 516
521 - odb->loaded_alternates = 1;
522 -
523 517 strvec_clear(&sources);
524 518 }
525 519
@@ -1147,7 +1141,6 @@ void odb_prepare(struct object_database *o, enum odb_prepare_flags flags)
1147 1141 * the lifetime of the process.
1148 1142 */
1149 1143 if (flags & ODB_PREPARE_FLUSH_CACHES) {
1150 - o->loaded_alternates = 0;
1151 1144 odb_prepare_alternates(o);
1152 1145 o->object_count_valid = 0;
1153 1146 }
modified odb.h
@@ -69,8 +69,6 @@ struct object_database {
69 69 */
70 70 int source_paths_icase;
71 71
72 - int loaded_alternates;
73 -
74 72 /*
75 73 * A list of alternate object directories loaded from the environment;
76 74 * this should not generally need to be accessed directly, but will