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()
diff --git a/builtin/add.c b/builtin/add.c
index 26b6ced..a825887 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -239,7 +239,7 @@
 	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 @@
 	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;
diff --git a/builtin/am.c b/builtin/am.c
index 7259186..2c7673f 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -2180,6 +2180,8 @@
 	};
 	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]))
diff --git a/builtin/commit-graph.c b/builtin/commit-graph.c
index 988445a..78fa08f 100644
--- a/builtin/commit-graph.c
+++ b/builtin/commit-graph.c
@@ -128,6 +128,8 @@
 {
 	enum commit_graph_split_flags *flags = opt->value;
 
+	BUG_ON_OPT_NEG(unset);
+
 	opts.split = 1;
 	if (!arg)
 		return 0;
diff --git a/builtin/commit.c b/builtin/commit.c
index 42b964e..1dfd799 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -326,7 +326,7 @@
 		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 @@
 		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 @@
 	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 @@
 		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.  */
diff --git a/builtin/env--helper.c b/builtin/env--helper.c
index 23c214f..2734909 100644
--- a/builtin/env--helper.c
+++ b/builtin/env--helper.c
@@ -7,18 +7,22 @@
 	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 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,
diff --git a/builtin/push.c b/builtin/push.c
index 0eeb2c8..6da3a8e 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -379,7 +379,7 @@
 	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 @@
 		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)
diff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c
index 4003f4d..e3140db 100644
--- a/builtin/sparse-checkout.c
+++ b/builtin/sparse-checkout.c
@@ -46,12 +46,24 @@
 	}
 }
 
+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 @@
 	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));
diff --git a/commit.h b/commit.h
index e6f8f7c..5467786 100644
--- a/commit.h
+++ b/commit.h
@@ -248,7 +248,7 @@
 struct ref;
 int for_each_commit_graft(each_commit_graft_fn, void *);
 
-int interactive_add(int argc, const char **argv, const char *prefix, int patch);
+int interactive_add(const char **argv, const char *prefix, int patch);
 int run_add_interactive(const char *revision, const char *patch_mode,
 			const struct pathspec *pathspec);
 
diff --git a/convert.c b/convert.c
index 8e6c292..ee360c2 100644
--- a/convert.c
+++ b/convert.c
@@ -195,7 +195,7 @@
 	return core_eol;
 }
 
-static void check_global_conv_flags_eol(const char *path, enum crlf_action crlf_action,
+static void check_global_conv_flags_eol(const char *path,
 			    struct text_stat *old_stats, struct text_stat *new_stats,
 			    int conv_flags)
 {
@@ -547,7 +547,7 @@
 			new_stats.crlf += new_stats.lonelf;
 			new_stats.lonelf = 0;
 		}
-		check_global_conv_flags_eol(path, crlf_action, &stats, &new_stats, conv_flags);
+		check_global_conv_flags_eol(path, &stats, &new_stats, conv_flags);
 	}
 	if (!convert_crlf_into_lf)
 		return 0;
diff --git a/dir.c b/dir.c
index 3018a65..7838711 100644
--- a/dir.c
+++ b/dir.c
@@ -2105,7 +2105,6 @@
 }
 
 static enum path_treatment treat_path_fast(struct dir_struct *dir,
-					   struct untracked_cache_dir *untracked,
 					   struct cached_dir *cdir,
 					   struct index_state *istate,
 					   struct strbuf *path,
@@ -2153,7 +2152,7 @@
 	int has_path_in_index, dtype, excluded;
 
 	if (!cdir->d_name)
-		return treat_path_fast(dir, untracked, cdir, istate, path,
+		return treat_path_fast(dir, cdir, istate, path,
 				       baselen, pathspec);
 	if (is_dot_or_dotdot(cdir->d_name) || !fspathcmp(cdir->d_name, ".git"))
 		return path_none;
diff --git a/parse-options-cb.c b/parse-options-cb.c
index d9d3b08..4542d4d 100644
--- a/parse-options-cb.c
+++ b/parse-options-cb.c
@@ -105,6 +105,8 @@
 	struct commit *commit;
 	struct commit **target = opt->value;
 
+	BUG_ON_OPT_NEG(unset);
+
 	if (!arg)
 		return -1;
 	if (get_oid(arg, &oid))
diff --git a/revision.c b/revision.c
index d9dc578..aa62212 100644
--- a/revision.c
+++ b/revision.c
@@ -2580,8 +2580,8 @@
 }
 
 static int handle_revision_pseudo_opt(const char *submodule,
-				struct rev_info *revs,
-				int argc, const char **argv, int *flags)
+				      struct rev_info *revs,
+				      const char **argv, int *flags)
 {
 	const char *arg = argv[0];
 	const char *optarg;
@@ -2752,7 +2752,7 @@
 			int opts;
 
 			opts = handle_revision_pseudo_opt(submodule,
-						revs, argc - i, argv + i,
+						revs, argv + i,
 						&flags);
 			if (opts > 0) {
 				i += opts - 1;
diff --git a/sequencer.c b/sequencer.c
index 3367eb5..00acb12 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -249,11 +249,20 @@
 	struct trailer_info info;
 	size_t i;
 	int found_sob = 0, found_sob_last = 0;
+	char saved_char;
 
 	opts.no_divider = 1;
 
+	if (ignore_footer) {
+		saved_char = sb->buf[sb->len - ignore_footer];
+		sb->buf[sb->len - ignore_footer] = '\0';
+	}
+
 	trailer_info_get(&info, sb->buf, &opts);
 
+	if (ignore_footer)
+		sb->buf[sb->len - ignore_footer] = saved_char;
+
 	if (info.trailer_start == info.trailer_end)
 		return 0;
 
@@ -934,8 +943,7 @@
  * interactive rebase: in that case, we will want to retain the
  * author metadata.
  */
-static int run_git_commit(struct repository *r,
-			  const char *defmsg,
+static int run_git_commit(const char *defmsg,
 			  struct replay_opts *opts,
 			  unsigned int flags)
 {
@@ -1545,7 +1553,7 @@
 		if (is_rebase_i(opts) && oid)
 			if (write_rebase_head(oid))
 			    return -1;
-		return run_git_commit(r, msg_file, opts, flags);
+		return run_git_commit(msg_file, opts, flags);
 	}
 
 	return res;
@@ -2060,7 +2068,7 @@
 		*check_todo = !!(flags & EDIT_MSG);
 		if (!res && reword) {
 fast_forward_edit:
-			res = run_git_commit(r, NULL, opts, EDIT_MSG |
+			res = run_git_commit(NULL, opts, EDIT_MSG |
 					     VERIFY_MSG | AMEND_MSG |
 					     (flags & ALLOW_EMPTY));
 			*check_todo = 1;
@@ -3749,7 +3757,7 @@
 		 * command needs to be rescheduled).
 		 */
 	fast_forward_edit:
-		ret = !!run_git_commit(r, git_path_merge_msg(r), opts,
+		ret = !!run_git_commit(git_path_merge_msg(r), opts,
 				       run_commit_flags);
 
 leave_merge:
@@ -4438,7 +4446,7 @@
 			return 0;
 	}
 
-	if (run_git_commit(r, final_fixup ? NULL : rebase_path_message(),
+	if (run_git_commit(final_fixup ? NULL : rebase_path_message(),
 			   opts, flags))
 		return error(_("could not commit staged changes."));
 	unlink(rebase_path_amend());
diff --git a/t/helper/test-advise.c b/t/helper/test-advise.c
index 38cdc28..a7043df 100644
--- a/t/helper/test-advise.c
+++ b/t/helper/test-advise.c
@@ -5,8 +5,8 @@
 
 int cmd__advise_if_enabled(int argc, const char **argv)
 {
-	if (!argv[1])
-	die("usage: %s <advice>", argv[0]);
+	if (argc != 2)
+		die("usage: %s <advice>", argv[0]);
 
 	setup_git_directory();
 	git_config(git_default_config, NULL);
diff --git a/t/helper/test-submodule-nested-repo-config.c b/t/helper/test-submodule-nested-repo-config.c
index bc97929..c5fd452 100644
--- a/t/helper/test-submodule-nested-repo-config.c
+++ b/t/helper/test-submodule-nested-repo-config.c
@@ -1,7 +1,7 @@
 #include "test-tool.h"
 #include "submodule-config.h"
 
-static void die_usage(int argc, const char **argv, const char *msg)
+static void die_usage(const char **argv, const char *msg)
 {
 	fprintf(stderr, "%s\n", msg);
 	fprintf(stderr, "Usage: %s <submodulepath> <config name>\n", argv[0]);
@@ -14,13 +14,13 @@
 	const struct submodule *sub;
 
 	if (argc < 3)
-		die_usage(argc, argv, "Wrong number of arguments.");
+		die_usage(argv, "Wrong number of arguments.");
 
 	setup_git_directory();
 
 	sub = submodule_from_path(the_repository, &null_oid, argv[1]);
 	if (repo_submodule_init(&subrepo, the_repository, sub)) {
-		die_usage(argc, argv, "Submodule not found.");
+		die_usage(argv, "Submodule not found.");
 	}
 
 	/* Read the config of _child_ submodules. */