From: Junio C Hamano <gitster@pobox.com>
To: Ayush Chandekar <ayu.chandekar@gmail.com>
Cc: christian.couder@gmail.com, git@vger.kernel.org,
shyamthakkar001@gmail.com
Subject: Re: [GSOC PATCH v4 1/3] environment: move access to "core.sparsecheckout" into repo_settings
Date: Tue, 17 Jun 2025 09:15:02 -0700 [thread overview]
Message-ID: <xmqqzfe6uyyh.fsf@gitster.g> (raw)
In-Reply-To: <e221c68ab52e995adbb175dc4a09f6c3dfeaf7c8.1750157825.git.ayu.chandekar@gmail.com> (Ayush Chandekar's message of "Tue, 17 Jun 2025 17:36:34 +0530")
Ayush Chandekar <ayu.chandekar@gmail.com> writes:
> diff --git a/builtin/backfill.c b/builtin/backfill.c
> index fa82ad2f6f..bf9e56bff3 100644
> --- a/builtin/backfill.c
> +++ b/builtin/backfill.c
> @@ -1,6 +1,3 @@
> -/* We need this macro to access core_apply_sparse_checkout */
> -#define USE_THE_REPOSITORY_VARIABLE
> -
> #include "builtin.h"
> #include "git-compat-util.h"
> #include "config.h"
> @@ -137,9 +134,9 @@ int cmd_backfill(int argc, const char **argv, const char *prefix, struct reposit
> 0);
>
> repo_config(repo, git_default_config, NULL);
> -
> + prepare_repo_settings(repo);
At this point, because show_usage_with_options_if_asked() has
already been called and returned, we know repo is not NULL, since
the only time git.c:run_builtin() calls us with repo==NULL is when
there is "-h" with nothing else on the command line and that causes
show_usage_with_options_if_asked() to emit usage and exit.
OK.
> if (ctx.sparse < 0)
> - ctx.sparse = core_apply_sparse_checkout;
> + ctx.sparse = repo->settings.sparse_checkout;
This is safe for the same reason.
> diff --git a/builtin/clone.c b/builtin/clone.c
> index 91b9cd0d16..1bc9c1bada 100644
> --- a/builtin/clone.c
> +++ b/builtin/clone.c
> @@ -621,7 +621,7 @@ static int git_sparse_checkout_init(const char *repo)
> * We must apply the setting in the current process
> * for the later checkout to use the sparse-checkout file.
> */
> - core_apply_sparse_checkout = 1;
> + the_repository->settings.sparse_checkout = 1;
Have anybody called prepare_repo_settings() on the repository yet?
What will prevent another call to the function from overwriting this
value later?
> diff --git a/builtin/mv.c b/builtin/mv.c
> index 07548fe96a..1e9f4d3eba 100644
> --- a/builtin/mv.c
> +++ b/builtin/mv.c
> @@ -572,7 +572,7 @@ int cmd_mv(int argc,
> rename_index_entry_at(the_repository->index, pos, dst);
>
> if (ignore_sparse &&
> - core_apply_sparse_checkout &&
> + the_repository->settings.sparse_checkout &&
> core_sparse_checkout_cone) {
Have anybody called prepare_repo_settings() on the repository yet
before the control comes here?
The guarantee of the original code being correct relied on the fact
that git_default_core_config() was called way before these places so
the global variable has been already initialized correctly.
The .sparse_checkout member is read in prepare_repo_settings() in
your new code; in order to give the correctness guarantee, there
needs to be some way to make sure prepare_repo_settings() has
already been called on the_repository before these places.
The same comment applies to all the code paths that access
the_repository->settings.sparse_checkout member instead of the
global. As the source of their correctness guarantee is quite
different, a mechanical replacement from global to a struct member
is not sufficient.
next prev parent reply other threads:[~2025-06-17 16:15 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-03 13:18 [GSOC PATCH] environment: move access to "core.sparsecheckout" into repo_settings Ayush Chandekar
2025-06-03 13:41 ` Patrick Steinhardt
2025-06-03 16:20 ` Ayush Chandekar
2025-06-04 2:20 ` Ben Knoble
2025-06-04 7:28 ` Patrick Steinhardt
2025-06-04 23:48 ` Ayush Chandekar
2025-06-08 0:31 ` [GSOC PATCH v2] " Ayush Chandekar
2025-06-08 6:39 ` Christian Couder
2025-06-11 17:34 ` [PATCH v3] " Ayush Chandekar
2025-06-11 21:06 ` Junio C Hamano
2025-06-11 21:33 ` Junio C Hamano
2025-06-13 6:57 ` Ayush Chandekar
2025-06-17 12:06 ` [GSOC PATCH v4 0/3] environment: remove sparse-checkout related global variables Ayush Chandekar
2025-06-17 12:06 ` [GSOC PATCH v4 1/3] environment: move access to "core.sparsecheckout" into repo_settings Ayush Chandekar
2025-06-17 16:15 ` Junio C Hamano [this message]
2025-06-17 12:06 ` [GSOC PATCH v4 2/3] environment: move access to "core.sparsecheckoutcone" " Ayush Chandekar
2025-06-17 16:29 ` Junio C Hamano
2025-06-17 12:06 ` [GSOC PATCH v4 3/3] environment: remove the global variable 'sparse_expect_files_outside_of_patterns' Ayush Chandekar
2025-06-17 16:30 ` Junio C Hamano
2025-06-30 19:27 ` [GSOC PATCH v5 0/3] environment: remove sparse-checkout related global variables Ayush Chandekar
2025-06-30 19:27 ` [GSOC PATCH v5 1/3] environment: move access to "core.sparsecheckout" into repo_settings Ayush Chandekar
2025-06-30 19:27 ` [GSOC PATCH v5 2/3] environment: move access to "core.sparsecheckoutcone" " Ayush Chandekar
2025-06-30 19:27 ` [GSOC PATCH v5 3/3] environment: remove the global variable 'sparse_expect_files_outside_of_patterns' Ayush Chandekar
2025-07-01 13:18 ` Phillip Wood
2025-07-01 23:53 ` Ayush Chandekar
2025-07-02 9:01 ` Phillip Wood
2025-07-11 19:24 ` Ayush Chandekar
2025-07-02 9:21 ` Junio C Hamano
2025-07-11 19:35 ` Ayush Chandekar
2025-06-30 21:08 ` [GSOC PATCH v5 0/3] environment: remove sparse-checkout related global variables Junio C Hamano
2025-07-09 0:18 ` Junio C Hamano
2025-07-09 1:39 ` Ayush Chandekar
2025-07-19 0:11 ` [GSOC PATCH v6 " Ayush Chandekar
2025-07-19 0:11 ` [GSOC PATCH v6 1/3] environment: move access to "core.sparsecheckout" into repo_settings Ayush Chandekar
2025-07-19 0:11 ` [GSOC PATCH v6 2/3] environment: move access to "core.sparsecheckoutcone" " Ayush Chandekar
2025-07-19 0:11 ` [GSOC PATCH v6 3/3] environment: remove the global variable 'sparse_expect_files_outside_of_patterns' Ayush Chandekar
2025-07-23 22:14 ` [GSOC PATCH v6 0/3] environment: remove sparse-checkout related global variables Junio C Hamano
2025-07-24 13:25 ` Derrick Stolee
2025-07-24 18:44 ` Junio C Hamano
2025-07-29 11:36 ` Ayush Chandekar
2025-07-29 12:19 ` Derrick Stolee
2025-07-29 12:53 ` Ayush Chandekar
2025-07-30 8:53 ` Phillip Wood
2025-07-30 15:52 ` Junio C Hamano
2025-07-26 23:55 ` Ayush Chandekar
2025-08-10 15:36 ` Ayush Chandekar
2025-08-26 12:20 ` Derrick Stolee
2025-08-27 21:31 ` Ayush Chandekar
2025-09-05 14:15 ` Junio C Hamano
2025-09-05 17:10 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqzfe6uyyh.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=ayu.chandekar@gmail.com \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=shyamthakkar001@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.