Merge branch 'jk/unused'

Code cleanup.

* jk/unused:
  dir.c: drop unused "untracked" from treat_path_fast()
  sequencer: handle ignore_footer when parsing trailers
  test-advise: check argument count with argc instead of argv
  sparse-checkout: fill in some options boilerplate
  sequencer: drop repository argument from run_git_commit()
  push: drop unused repo argument to do_push()
  assert PARSE_OPT_NONEG in parse-options callbacks
  env--helper: write to opt->value in parseopt helper
  drop unused argc parameters
  convert: drop unused crlf_action from check_global_conv_flags_eol()
This commit is contained in:
Junio C Hamano
2020-10-05 14:01:52 -07:00
15 changed files with 88 additions and 33 deletions

View File

@ -239,7 +239,7 @@ int run_add_interactive(const char *revision, const char *patch_mode,
return status;
}
int interactive_add(int argc, const char **argv, const char *prefix, int patch)
int interactive_add(const char **argv, const char *prefix, int patch)
{
struct pathspec pathspec;
@ -451,7 +451,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
if (add_interactive) {
if (pathspec_from_file)
die(_("--pathspec-from-file is incompatible with --interactive/--patch"));
exit(interactive_add(argc - 1, argv + 1, prefix, patch_interactive));
exit(interactive_add(argv + 1, prefix, patch_interactive));
}
if (legacy_stash_p) {
struct pathspec pathspec;

View File

@ -2180,6 +2180,8 @@ static int parse_opt_show_current_patch(const struct option *opt, const char *ar
};
int new_value = SHOW_PATCH_RAW;
BUG_ON_OPT_NEG(unset);
if (arg) {
for (new_value = 0; new_value < ARRAY_SIZE(valid_modes); new_value++) {
if (!strcmp(arg, valid_modes[new_value]))

View File

@ -128,6 +128,8 @@ static int write_option_parse_split(const struct option *opt, const char *arg,
{
enum commit_graph_split_flags *flags = opt->value;
BUG_ON_OPT_NEG(unset);
opts.split = 1;
if (!arg)
return 0;

View File

@ -326,7 +326,7 @@ static void refresh_cache_or_die(int refresh_flags)
die_resolve_conflict("commit");
}
static const char *prepare_index(int argc, const char **argv, const char *prefix,
static const char *prepare_index(const char **argv, const char *prefix,
const struct commit *current_head, int is_status)
{
struct string_list partial = STRING_LIST_INIT_DUP;
@ -378,7 +378,7 @@ static const char *prepare_index(int argc, const char **argv, const char *prefix
old_index_env = xstrdup_or_null(getenv(INDEX_ENVIRONMENT));
setenv(INDEX_ENVIRONMENT, the_repository->index_file, 1);
if (interactive_add(argc, argv, prefix, patch_interactive) != 0)
if (interactive_add(argv, prefix, patch_interactive) != 0)
die(_("interactive add failed"));
the_repository->index_file = old_repo_index_file;
@ -1241,13 +1241,13 @@ static int parse_and_validate_options(int argc, const char *argv[],
return argc;
}
static int dry_run_commit(int argc, const char **argv, const char *prefix,
static int dry_run_commit(const char **argv, const char *prefix,
const struct commit *current_head, struct wt_status *s)
{
int committable;
const char *index_file;
index_file = prepare_index(argc, argv, prefix, current_head, 1);
index_file = prepare_index(argv, prefix, current_head, 1);
committable = run_status(stdout, index_file, prefix, 0, s);
rollback_index_files();
@ -1584,8 +1584,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
verbose = (config_commit_verbose < 0) ? 0 : config_commit_verbose;
if (dry_run)
return dry_run_commit(argc, argv, prefix, current_head, &s);
index_file = prepare_index(argc, argv, prefix, current_head, 0);
return dry_run_commit(argv, prefix, current_head, &s);
index_file = prepare_index(argv, prefix, current_head, 0);
/* Set up everything for writing the commit object. This includes
running hooks, writing the trees, and interacting with the user. */

View File

@ -7,18 +7,22 @@ static char const * const env__helper_usage[] = {
NULL
};
static enum {
enum cmdmode {
ENV_HELPER_TYPE_BOOL = 1,
ENV_HELPER_TYPE_ULONG
} cmdmode = 0;
};
static int option_parse_type(const struct option *opt, const char *arg,
int unset)
{
enum cmdmode *cmdmode = opt->value;
BUG_ON_OPT_NEG(unset);
if (!strcmp(arg, "bool"))
cmdmode = ENV_HELPER_TYPE_BOOL;
*cmdmode = ENV_HELPER_TYPE_BOOL;
else if (!strcmp(arg, "ulong"))
cmdmode = ENV_HELPER_TYPE_ULONG;
*cmdmode = ENV_HELPER_TYPE_ULONG;
else
die(_("unrecognized --type argument, %s"), arg);
@ -33,6 +37,7 @@ int cmd_env__helper(int argc, const char **argv, const char *prefix)
int ret;
int ret_int, default_int;
unsigned long ret_ulong, default_ulong;
enum cmdmode cmdmode = 0;
struct option opts[] = {
OPT_CALLBACK_F(0, "type", &cmdmode, N_("type"),
N_("value is given this type"), PARSE_OPT_NONEG,

View File

@ -379,7 +379,7 @@ static int push_with_options(struct transport *transport, struct refspec *rs,
return 1;
}
static int do_push(const char *repo, int flags,
static int do_push(int flags,
const struct string_list *push_options,
struct remote *remote)
{
@ -629,7 +629,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
if (strchr(item->string, '\n'))
die(_("push options must not have new line characters"));
rc = do_push(repo, flags, push_options, remote);
rc = do_push(flags, push_options, remote);
string_list_clear(&push_options_cmdline, 0);
string_list_clear(&push_options_config, 0);
if (rc == -1)

View File

@ -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));