summaryrefslogtreecommitdiff
path: root/builtin/sparse-checkout.c
diff options
context:
space:
mode:
authorLibravatar Jeff King <peff@peff.net>2020-09-30 08:30:10 -0400
committerLibravatar Junio C Hamano <gitster@pobox.com>2020-09-30 12:53:48 -0700
commit75d3bee15778a3aaeb8234023fc224838ac53181 (patch)
tree32ecb59af1794650ae361386579f759f8459a9c8 /builtin/sparse-checkout.c
parentsequencer: drop repository argument from run_git_commit() (diff)
downloadtgif-75d3bee15778a3aaeb8234023fc224838ac53181.tar.xz
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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/sparse-checkout.c')
-rw-r--r--builtin/sparse-checkout.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c
index 4003f4d13a..e3140db2a0 100644
--- a/builtin/sparse-checkout.c
+++ b/builtin/sparse-checkout.c
@@ -46,12 +46,24 @@ static void write_patterns_to_file(FILE *fp, struct pattern_list *pl)
}
}
+static char const * const builtin_sparse_checkout_list_usage[] = {
+ N_("git sparse-checkout list"),
+ NULL
+};
+
static int sparse_checkout_list(int argc, const char **argv)
{
+ static struct option builtin_sparse_checkout_list_options[] = {
+ OPT_END(),
+ };
struct pattern_list pl;
char *sparse_filename;
int res;
+ argc = parse_options(argc, argv, NULL,
+ builtin_sparse_checkout_list_options,
+ builtin_sparse_checkout_list_usage, 0);
+
memset(&pl, 0, sizeof(pl));
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,
return modify_pattern_list(argc, argv, m);
}
+static char const * const builtin_sparse_checkout_reapply_usage[] = {
+ N_("git sparse-checkout reapply"),
+ NULL
+};
+
static int sparse_checkout_reapply(int argc, const char **argv)
{
+ static struct option builtin_sparse_checkout_reapply_options[] = {
+ OPT_END(),
+ };
+
+ argc = parse_options(argc, argv, NULL,
+ builtin_sparse_checkout_reapply_options,
+ builtin_sparse_checkout_reapply_usage, 0);
+
repo_read_index(the_repository);
return update_working_directory(NULL);
}
+static char const * const builtin_sparse_checkout_disable_usage[] = {
+ N_("git sparse-checkout disable"),
+ NULL
+};
+
static int sparse_checkout_disable(int argc, const char **argv)
{
+ static struct option builtin_sparse_checkout_disable_options[] = {
+ OPT_END(),
+ };
struct pattern_list pl;
struct strbuf match_all = STRBUF_INIT;
+ argc = parse_options(argc, argv, NULL,
+ builtin_sparse_checkout_disable_options,
+ builtin_sparse_checkout_disable_usage, 0);
+
repo_read_index(the_repository);
memset(&pl, 0, sizeof(pl));