]> Kevux Git Server - rit/commit
setup: deduplicate logic to apply repository format
authorPatrick Steinhardt <ps@pks.im>
Thu, 4 Jun 2026 07:46:27 +0000 (09:46 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 5 Jun 2026 12:49:38 +0000 (21:49 +0900)
commit3d884b0b5656fe012002edd6bb8f36a125e6c17e
treefa5201a0046b1ed3bed3273e437a71b7a2524d56
parent452ad8db6d9155d6c7305d6045d29c49a7cc9c7c
setup: deduplicate logic to apply repository format

After having discovered the repository format we then apply it to the
repository so that it knows to use the proper repository extensions. The
logic to apply the format is duplicated across three callsites, which
makes it rather painfull to add new extensions.

Introduce a new function `apply_repository_format()` that takes a repo
and applies a given format to it and adapt all callsites to use it.
This function is also the new caller of `verify_repository_format()` so
that we can ensure that we never apply an invalid repository format.
The verification we have in `read_and_verify_repository_format()` is
thus redundant now and dropped.

Rename `read_and_verify_repository_format()` accordingly. While at it,
also rename `check_repository_format()` to clarify that it doesn't only
_check_ the format, but that it also applies it.

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