git/t/unit-tests
Patrick Steinhardt 30bc6f0e8c setup: handle ODB-related environment variables in `odb_new()`
When initializing a repository's object database we have to respect the
GIT_OBJECT_DIRECTORY and GIT_ALTERNATE_OBJECT_DIRECTORIES environment
variables, which can be set by the user to override the default location
of where we write objects to and read objects from.

This is handled in `apply_repository_format()`, which is fine. But in a
subsequent commit we'll have to defer constructing the object database
to a later point in some cases, and that will require a second site
where we call `odb_new()`. And of course, that second site would have to
handle those environment variables, as well.

It would be somewhat awkward to duplicate the logic though. But there's
a better alternative: instead of handling this logic in "setup.c", we
can easily handle environment variables in `odb_new()` itself. This
ensures that object database creation is neatly self-contained, and we
don't have to duplicate any of the logic.

Another benefit is that in a future patch series we plan to move
handling of alternates into the backends themselves [1], and that will
require us to also handle those environment variables in the "files"
backend itself. So moving the logic into the ODB level already gets us
one step closer to that goal.

Refactor the logic accordingly.

[1]: https://lore.kernel.org/git/amLgMqkqxR8mKIbT@pks.im/

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-08-06 21:24:25 -07:00
..
clar doc: fix typos via codespell 2026-06-08 00:21:35 +09:00
.gitignore
generate-clar-decls.sh
generate-clar-suites.sh
lib-oid.c
lib-oid.h
lib-reftable.c reftable: split up write options 2026-06-26 08:27:19 -07:00
lib-reftable.h reftable: split up write options 2026-06-26 08:27:19 -07:00
test-lib.c
test-lib.h
u-ctype.c
u-dir.c
u-example-decorate.c
u-hash.c hash: use git_hash_init() consistently 2026-07-07 21:56:00 -07:00
u-hashmap.c
u-list-objects-filter-options.c
u-mem-pool.c
u-odb-inmemory.c setup: handle ODB-related environment variables in `odb_new()` 2026-08-06 21:24:25 -07:00
u-oid-array.c
u-oidmap.c
u-oidtree.c oidtree: add ability to store data 2026-05-15 04:50:45 +09:00
u-prio-queue.c prio-queue: fold lazy_queue into prio_queue for automatic get+put fusion 2026-06-09 11:11:46 -07:00
u-reftable-basics.c reftable/basics: fix OOB read on binary search of empty range 2026-07-03 11:08:02 -07:00
u-reftable-block.c reftable/block: fix OOB read with bogus restart offset 2026-07-03 11:08:03 -07:00
u-reftable-merged.c reftable: split up write options 2026-06-26 08:27:19 -07:00
u-reftable-pq.c
u-reftable-readwrite.c reftable: split up write options 2026-06-26 08:27:19 -07:00
u-reftable-record.c reftable/record: don't abort when decoding invalid ref value type 2026-07-03 11:08:02 -07:00
u-reftable-stack.c reftable: split up write options 2026-06-26 08:27:19 -07:00
u-reftable-table.c Merge branch 'ps/reftable-hardening' 2026-07-19 10:42:15 -07:00
u-reftable-tree.c
u-strbuf.c
u-strcmp-offset.c
u-string-list.c
u-strvec.c
u-trailer.c
u-urlmatch-normalization.c
u-utf8-width.c
unit-test.c
unit-test.h