sparse-checkout: enable reapply to take --[no-]{cone,sparse-index}
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Elijah Newren committed
Dec 14, 2021 at 04:09 UTC
4e256731d687a553fd7443f7596019dbe5b10598
1 file changed
+17
-1
builtin/sparse-checkout.c
+17
-1
@@ -759,13 +759,22 @@ static int sparse_checkout_set(int argc, const char **argv, const char *prefix)
759
}
760
761
static char const * const builtin_sparse_checkout_reapply_usage[] = {
762
- N_("git sparse-checkout reapply"),
762
+ N_("git sparse-checkout reapply [--[no-]cone] [--[no-]sparse-index] "),
763
NULL
764
};
765
766
+static struct sparse_checkout_reapply_opts {
767
+ int cone_mode;
768
+ int sparse_index;
769
+} reapply_opts;
770
+
771
static int sparse_checkout_reapply(int argc, const char **argv)
772
{
773
static struct option builtin_sparse_checkout_reapply_options[] = {
774
+ OPT_BOOL(0, "cone", &reapply_opts.cone_mode,
775
+ N_("initialize the sparse-checkout in cone mode")),
776
+ OPT_BOOL(0, "sparse-index", &reapply_opts.sparse_index,
777
+ N_("toggle the use of a sparse index")),
778
OPT_END(),
779
};
780
@@ -777,6 +786,13 @@ static int sparse_checkout_reapply(int argc, const char **argv)
786
builtin_sparse_checkout_reapply_usage, 0);
787
788
repo_read_index(the_repository);
789
+
790
+ reapply_opts.cone_mode = -1;
791
+ reapply_opts.sparse_index = -1;
792
+
793
+ if (update_modes(&reapply_opts.cone_mode, &reapply_opts.sparse_index))
794
+ return 1;
795
+
796
return update_working_directory(NULL);
797
}
798