]> Kevux Git Server - rit/commit
setup: construct object database in `apply_repository_format()`
authorPatrick Steinhardt <ps@pks.im>
Thu, 4 Jun 2026 07:46:32 +0000 (09:46 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 5 Jun 2026 12:49:39 +0000 (21:49 +0900)
commit42b9d3dc9dfa9e733cbd6402e665ac35fce0c216
treebf88b63ab631758af656d2256bf0bd62225d401d
parenta84a9d4acdae51f58529b2596c4bd935fe9af372
setup: construct object database in `apply_repository_format()`

With the preceding changes we now always construct the repository's
object database before applying the repository format. Remove this
duplication by constructing it in `apply_repository_format()` instead.

Note that we create the object database _after_ having set up the
repository's hash algorithm, but _before_ setting the compat hash
algorithm. This is intentional:

  - Constructing the object database may require knowledge of its
    intended object format.

  - Setting up the compatibility hash requires the object database to be
    initialized already, because we immediately read the loose object
    map.

The first point is sensible, the second maybe a little less so. Ideally,
it should be the responsibility of the object database itself to
initialize any data structures required for the compatibility hash. But
this would require further changes, so this is kept as-is for now.

Further note that this requires us to move handling of the environment
variables GIT_OBJECT_DIRECTORY and GIT_ALTERNATE_OBJECT_DIRECTORIES into
the repository format, as well. This allows the caller more flexibility
around whether or not those environment variables are being honored, as
we want to respect them in "setup.c", but not in "repository.c".

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