Re: [PATCH v2] describe: enable sparse index for describe
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 29, 2023, 17:00 UTC
- Message-ID
- <xmqq355nbii5.fsf@gitster.g>
- In-Reply-To
- <pull.1480.v2.git.git.1680107154078.gitgitgadget@gmail.com>
"Raghul Nanth A via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 6 quoted lines
> From: Raghul Nanth A <nanth.raghul@gmail.com> > > Add usage and performance tests for describe > > Performance metrics > ...
The description is a bit skimpy. At least it should explain why blindly flipping the "requires-full-index" bit off is all that is necessary. I think in the review discussion on v1, Derrick gave some explanation you can regurgitate and reuse.
> Signed-off-by: Raghul Nanth A <nanth.raghul@gmail.com> > ...
Show 20 quoted lines
> diff --git a/t/t6121-describe-sparse.sh b/t/t6121-describe-sparse.sh
> new file mode 100755
> index 00000000000..ce53603c387
> --- /dev/null
> +++ b/t/t6121-describe-sparse.sh
> @@ -0,0 +1,67 @@
> +#!/bin/sh
> +
> +test_description='git describe in sparse checked out trees'
> +
> +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
> +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
> +
> +. ./test-lib.sh
> +
> +check_describe () {
> + indir= &&
> +...
> + '
> +}Having this almost identical helper copied from a near-by test script means maintenance nightmare. People will forget to side port to this copy any fixes they make to the other one.
I was hoping there would be a cleaner approach to reuse t6120, by doing something similar to either how t8001-annotate shares blame tests, or how t5559 takes advantage of t5551. One way might be ...
* prepare a prerequisite like so near the beginning of t6120
test_lazy_prereq WITH_SPARSE_INDEX ' test "$TEST_NAME" = t6121-describe '
* add tests to be run with sparse-index enabled, but guarded with some variable, e.g.
test_expect_success TESTING_SPARSE_INDEX 'a new test' ' ... do sparse-index testing specific code ... '
Such "sparse-index testing specific" code may include turning the working tree the previous test already prepared into sparse (i.e. additional "setup"), or running commands under "ensure_not_expanded" (i.e. new tests).
* create t6121 that works similar to how t5559 takes advantage of t5551, something like
#/bin/sh . ./t6120-describe.sh
Ideally we should be able to do this without adding a new t6121, by adding new tests that are specific to sparse-index at the end of t6120, and avoid duplicated code.
Another possibility that may take the least amount of effort (but may give us a lot less satisfactory outcome) may be to add a lib-describe.sh library that is sourced from t6120 and t6121, and move check_describe there. If check_describe has to behave slightly differently, have a new conditional in the implementation so that the caller can make a choice.