Subject: Re: [GSOC PATCH v5 0/3] environment: remove sparse-checkout related global variables

From: Junio C Hamano <[email-masked]>
Date: Mon, 30 Jun 2025 14:08:41 -0700

Ayush Chandekar <[email-masked]> writes:

> This patch series aims to remove global variables related to
> sparse-checkout from the global scope and to remove the definition
> '#define USE_THE_REPOSITORY_VARIABLE' from a few files.
>
> It contains three patches:
>
> 1 - Remove the global variable 'core_apply_sparse_checkout' and
> move its setting to the 'struct repo_settings'. Also remove the
> definition '#define USE_THE_REPOSITORY_VARIABLE' from
> "builtin/backfill.c".
>
> 2 - Remove the global variable 'core_sparse_checkout_cone' and
> move its setting to the 'struct repo_settings'.
>
> 3 - Remove the global variable
> 'sparse_expect_files_outside_of_patterns` and localize it in the
> function which calls it. Also remove the definition '#define
> USE_THE_REPOSITORY_VARIABLE' from "sparse-index.c"

A call to prepare_repo_settings() function is not free even though
the .settings.initialized member makes second and subsequent calls
to it as cheap as possible.  It makes me a bit worried to see
patches that add new calls to it to places that are fairly deep in
the callchain (as opposed to in cmd_foo() for various built-in
commands).  As long as the control passes these places only once
before we do the heavy lifting and then after the heavy lifting,
the only thing left for us is to exit, we would be fine, but I do
not know if all new calls added in these patches are that kind.

Thanks.