t1302: make tests more robust with new extensions
commitafb99327d07cafd5735392fcd6b0eb07558e53f2
authorPatrick Steinhardt <ps@pks.im>
Mon, 29 Jan 2024 11:07:26 +0000 (29 12:07 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 29 Jan 2024 21:54:32 +0000 (29 13:54 -0800)
treead21d1e1c96328263da4d0b8c7b8a219aad675ba
parent1f83e752c52952572697b857018db67b537e7346
t1302: make tests more robust with new extensions

In t1302 we exercise logic around "core.repositoryFormatVersion" and
extensions. These tests are not particularly robust against extensions
like the newly introduced "refStorage" extension as we tend to clobber
the repository's config file. We thus overwrite any extensions that were
set, which may render the repository inaccessible in case it has to be
accessed with a non-default ref storage.

Refactor the tests to be more robust:

  - Check the DEFAULT_REPO_FORMAT prereq to determine the expected
    repository format version. This helps to ensure that we only need to
    update the prereq in a central place when new extensions are added.
    Furthermore, this allows us to stop seeding the now-unneeded object
    ID cache that was only used to figure out the repository version.

  - Use a separate repository to rewrite ".git/config" to test
    combinations of the repository format version and extensions. This
    ensures that we don't break the main test repository. While we could
    rewrite these tests to not overwrite preexisting extensions, it
    feels cleaner like this so that we can test extensions standalone
    without interference from the environment.

  - Do not rewrite ".git/config" when exercising the "preciousObjects"
    extension.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Reviewed-by: Christian Couder <christian.couder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t1302-repo-version.sh