Message ID | 09b13280c2619e9dcbf33422c5dcfba84f0e52be.1639454952.git.gitgitgadget@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 4e256731d687a553fd7443f7596019dbe5b10598 |
Headers | show |
Series | sparse-checkout: make set subsume init | expand |
On Tue, Dec 14, 2021 at 3:24 PM Elijah Newren via GitGitGadget <gitgitgadget@gmail.com> wrote: > > From: Elijah Newren <newren@gmail.com> > > Folks may want to switch to or from cone mode, or to or from a > sparse-index without changing their sparsity paths. Allow them to do so > using the reapply command. > > Reviewed-by: Derrick Stolee <dstolee@microsoft.com> > Reviewed-by: Victoria Dye <vdye@github.com> > Signed-off-by: Elijah Newren <newren@gmail.com> > --- > builtin/sparse-checkout.c | 18 +++++++++++++++++- > 1 file changed, 17 insertions(+), 1 deletion(-) > > diff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c > index 16daae84975..0dae44c5759 100644 > --- a/builtin/sparse-checkout.c > +++ b/builtin/sparse-checkout.c > @@ -759,13 +759,22 @@ static int sparse_checkout_set(int argc, const char **argv, const char *prefix) > } > > static char const * const builtin_sparse_checkout_reapply_usage[] = { > - N_("git sparse-checkout reapply"), > + N_("git sparse-checkout reapply [--[no-]cone] [--[no-]sparse-index] "), Found a trailing space in [1], which came from this commit. [1]: https://github.com/git-l10n/git-po/blob/pot/next/2021-12-22.diff#L19 -- Jiang Xin
On Wed, Dec 22, 2021 at 4:48 PM Jiang Xin <worldhello.net@gmail.com> wrote: > > On Tue, Dec 14, 2021 at 3:24 PM Elijah Newren via GitGitGadget > <gitgitgadget@gmail.com> wrote: > > ... > > static char const * const builtin_sparse_checkout_reapply_usage[] = { > > - N_("git sparse-checkout reapply"), > > + N_("git sparse-checkout reapply [--[no-]cone] [--[no-]sparse-index] "), > > Found a trailing space in [1], which came from this commit. > > [1]: https://github.com/git-l10n/git-po/blob/pot/next/2021-12-22.diff#L19 Sorry about that. This series has already hit next, so I submitted a new patch to correct this (https://lore.kernel.org/git/pull.1106.git.1640279223893.gitgitgadget@gmail.com/).
Elijah Newren <newren@gmail.com> writes: > On Wed, Dec 22, 2021 at 4:48 PM Jiang Xin <worldhello.net@gmail.com> wrote: >> >> On Tue, Dec 14, 2021 at 3:24 PM Elijah Newren via GitGitGadget >> <gitgitgadget@gmail.com> wrote: >> > > ... >> > static char const * const builtin_sparse_checkout_reapply_usage[] = { >> > - N_("git sparse-checkout reapply"), >> > + N_("git sparse-checkout reapply [--[no-]cone] [--[no-]sparse-index] "), >> >> Found a trailing space in [1], which came from this commit. >> >> [1]: https://github.com/git-l10n/git-po/blob/pot/next/2021-12-22.diff#L19 > > Sorry about that. This series has already hit next, so I submitted a > new patch to correct this > (https://lore.kernel.org/git/pull.1106.git.1640279223893.gitgitgadget@gmail.com/). Thanks, both. Will take a look.
diff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c index 16daae84975..0dae44c5759 100644 --- a/builtin/sparse-checkout.c +++ b/builtin/sparse-checkout.c @@ -759,13 +759,22 @@ static int sparse_checkout_set(int argc, const char **argv, const char *prefix) } static char const * const builtin_sparse_checkout_reapply_usage[] = { - N_("git sparse-checkout reapply"), + N_("git sparse-checkout reapply [--[no-]cone] [--[no-]sparse-index] "), NULL }; +static struct sparse_checkout_reapply_opts { + int cone_mode; + int sparse_index; +} reapply_opts; + static int sparse_checkout_reapply(int argc, const char **argv) { static struct option builtin_sparse_checkout_reapply_options[] = { + OPT_BOOL(0, "cone", &reapply_opts.cone_mode, + N_("initialize the sparse-checkout in cone mode")), + OPT_BOOL(0, "sparse-index", &reapply_opts.sparse_index, + N_("toggle the use of a sparse index")), OPT_END(), }; @@ -777,6 +786,13 @@ static int sparse_checkout_reapply(int argc, const char **argv) builtin_sparse_checkout_reapply_usage, 0); repo_read_index(the_repository); + + reapply_opts.cone_mode = -1; + reapply_opts.sparse_index = -1; + + if (update_modes(&reapply_opts.cone_mode, &reapply_opts.sparse_index)) + return 1; + return update_working_directory(NULL); }