Skip to content

Commit 4e25673

Browse files
newrengitster
authored andcommitted
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 <[email protected]> Reviewed-by: Victoria Dye <[email protected]> Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f2e3a21 commit 4e25673

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

builtin/sparse-checkout.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,13 +759,22 @@ static int sparse_checkout_set(int argc, const char **argv, const char *prefix)
759759
}
760760

761761
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] "),
763763
NULL
764764
};
765765

766+
static struct sparse_checkout_reapply_opts {
767+
int cone_mode;
768+
int sparse_index;
769+
} reapply_opts;
770+
766771
static int sparse_checkout_reapply(int argc, const char **argv)
767772
{
768773
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")),
769778
OPT_END(),
770779
};
771780

@@ -777,6 +786,13 @@ static int sparse_checkout_reapply(int argc, const char **argv)
777786
builtin_sparse_checkout_reapply_usage, 0);
778787

779788
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+
780796
return update_working_directory(NULL);
781797
}
782798

0 commit comments

Comments
 (0)