Skip to content

Commit 75d3bee

Browse files
peffgitster
authored andcommitted
sparse-checkout: fill in some options boilerplate
The sparse-checkout passes along argv and argc to its sub-command helper functions. Many of these sub-commands do not yet take any command-line options, and ignore those parameters. Let's instead add empty option lists and make sure we call parse_options(). That will give a useful error message for something like: git sparse-checkout list --nonsense which currently just silently ignores the unknown option. As a bonus, it also silences some -Wunused-parameter warnings. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 20f4b04 commit 75d3bee

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

builtin/sparse-checkout.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,24 @@ static void write_patterns_to_file(FILE *fp, struct pattern_list *pl)
4646
}
4747
}
4848

49+
static char const * const builtin_sparse_checkout_list_usage[] = {
50+
N_("git sparse-checkout list"),
51+
NULL
52+
};
53+
4954
static int sparse_checkout_list(int argc, const char **argv)
5055
{
56+
static struct option builtin_sparse_checkout_list_options[] = {
57+
OPT_END(),
58+
};
5159
struct pattern_list pl;
5260
char *sparse_filename;
5361
int res;
5462

63+
argc = parse_options(argc, argv, NULL,
64+
builtin_sparse_checkout_list_options,
65+
builtin_sparse_checkout_list_usage, 0);
66+
5567
memset(&pl, 0, sizeof(pl));
5668

5769
pl.use_cone_patterns = core_sparse_checkout_cone;
@@ -560,17 +572,42 @@ static int sparse_checkout_set(int argc, const char **argv, const char *prefix,
560572
return modify_pattern_list(argc, argv, m);
561573
}
562574

575+
static char const * const builtin_sparse_checkout_reapply_usage[] = {
576+
N_("git sparse-checkout reapply"),
577+
NULL
578+
};
579+
563580
static int sparse_checkout_reapply(int argc, const char **argv)
564581
{
582+
static struct option builtin_sparse_checkout_reapply_options[] = {
583+
OPT_END(),
584+
};
585+
586+
argc = parse_options(argc, argv, NULL,
587+
builtin_sparse_checkout_reapply_options,
588+
builtin_sparse_checkout_reapply_usage, 0);
589+
565590
repo_read_index(the_repository);
566591
return update_working_directory(NULL);
567592
}
568593

594+
static char const * const builtin_sparse_checkout_disable_usage[] = {
595+
N_("git sparse-checkout disable"),
596+
NULL
597+
};
598+
569599
static int sparse_checkout_disable(int argc, const char **argv)
570600
{
601+
static struct option builtin_sparse_checkout_disable_options[] = {
602+
OPT_END(),
603+
};
571604
struct pattern_list pl;
572605
struct strbuf match_all = STRBUF_INIT;
573606

607+
argc = parse_options(argc, argv, NULL,
608+
builtin_sparse_checkout_disable_options,
609+
builtin_sparse_checkout_disable_usage, 0);
610+
574611
repo_read_index(the_repository);
575612

576613
memset(&pl, 0, sizeof(pl));

0 commit comments

Comments
 (0)