From fdab62f707e244be118be062cded8e0ccc25f4bf Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Thu, 2 Sep 2021 10:12:51 -0400 Subject: [PATCH] sparse-index: introduce GIT_TEST_FAIL_ENSURE_FULL_INDEX To be extra sure that our integrated commands do not expand in normal cases, create a GIT_TEST_FAIL_ENSURE_FULL_INDEX that fails inside ensure_full_index() if the repo settings indicate we are in an integrated command. Enable this for the Scalar functional tests. Signed-off-by: Derrick Stolee --- .github/workflows/scalar-functional-tests.yml | 1 + sparse-index.c | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/.github/workflows/scalar-functional-tests.yml b/.github/workflows/scalar-functional-tests.yml index 438933d6aed2a3..60f9603d0a6dab 100644 --- a/.github/workflows/scalar-functional-tests.yml +++ b/.github/workflows/scalar-functional-tests.yml @@ -37,6 +37,7 @@ jobs: env: BUILD_FRAGMENT: bin/Release/netcoreapp3.1 + GIT_TEST_FAIL_ENSURE_FULL_INDEX: 1 steps: - name: Check out Git's source code diff --git a/sparse-index.c b/sparse-index.c index 218eb0938a24de..db4dd80bdaed7c 100644 --- a/sparse-index.c +++ b/sparse-index.c @@ -251,6 +251,16 @@ void ensure_full_index(struct index_state *istate) if (!istate->repo) istate->repo = the_repository; + if (!istate->repo->settings.command_requires_full_index) { + static int fail_on_expand = -1; + + if (fail_on_expand < 0) + fail_on_expand = git_env_bool("GIT_TEST_FAIL_ENSURE_FULL_INDEX", 0); + + if (fail_on_expand) + die("sparse index will expand in an integrated command"); + } + trace2_region_enter("index", "ensure_full_index", istate->repo); /* initialize basics of new index */