Re: [PATCH v2 06/10] sparse-checkout: --no-sparse-index needs a full index
- From
Junio C Hamano <gitster@pobox.com>
- Date
- May 19, 2022, 20:19 UTC
- Message-ID
- <xmqq8rqxmg1t.fsf@gitster.g>
- In-Reply-To
- <e42463de0d218b63bf0c786590708b1be32257f0.1652982759.git.gitgitgadget@gmail.com>
"Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 23 quoted lines
> From: Derrick Stolee <dstolee@microsoft.com> > > When the --no-sparse-index option is supplied, the sparse-checkout > builtin should explicitly ask to expand a sparse index to a full one. > This is currently done implicitly due to the command_requires_full_index > protection, but that will be removed in an upcoming change. > > Signed-off-by: Derrick Stolee <derrickstolee@github.com> > --- > builtin/sparse-checkout.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c > index 88eea069ad4..cbff6ad00b0 100644 > --- a/builtin/sparse-checkout.c > +++ b/builtin/sparse-checkout.c > @@ -413,6 +413,9 @@ static int update_modes(int *cone_mode, int *sparse_index) > /* force an index rewrite */ > repo_read_index(the_repository); > the_repository->index->updated_workdir = 1; > + > + if (!*sparse_index) > + ensure_full_index(the_repository->index);
init_opts.sparse_index is initialized to -1 (unknown) and parse_options() may set it to 0 (false) or 1 (true). We call ensure_full only when the caller explicitly asks with --no-sparse-index.
Makes sense.
> } > > return 0;