Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2020-10-06 00:01:52 +0300
committerJunio C Hamano <gitster@pobox.com>2020-10-06 00:01:52 +0300
commit19dd352d03adc75d0b6530975a44b7bb23c69063 (patch)
tree004d7ebcd753d22060530bbe149a15d7d5df6fc2
parent8250ab0b8c814ce4491b57a52c7d6d95fa01d992 (diff)
parent842385b8a4fa56678f13cda599ee96463004e7bf (diff)
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()
-rw-r--r--builtin/add.c4
-rw-r--r--builtin/am.c2
-rw-r--r--builtin/commit-graph.c2
-rw-r--r--builtin/commit.c12
-rw-r--r--builtin/env--helper.c13
-rw-r--r--builtin/push.c4
-rw-r--r--builtin/sparse-checkout.c37
-rw-r--r--commit.h2
-rw-r--r--convert.c4
-rw-r--r--dir.c3
-rw-r--r--parse-options-cb.c2
-rw-r--r--revision.c6
-rw-r--r--sequencer.c20
-rw-r--r--t/helper/test-advise.c4
-rw-r--r--t/helper/test-submodule-nested-repo-config.c6
15 files changed, 88 insertions, 33 deletions
diff --git a/builtin/add.c b/builtin/add.c
index 26b6ced09e..a825887c50 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -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;
diff --git a/builtin/am.c b/builtin/am.c
index 7259186408..2c7673f74e 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -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]))
diff --git a/builtin/commit-graph.c b/builtin/commit-graph.c
index 988445abdf..78fa08f43a 100644
--- a/builtin/commit-graph.c
+++ b/builtin/commit-graph.c
@@ -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;
diff --git a/builtin/commit.c b/builtin/commit.c
index 42b964e0ca..1dfd799ec5 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -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. */
diff --git a/builtin/env--helper.c b/builtin/env--helper.c
index 23c214fff6..27349098b0 100644
--- a/builtin/env--helper.c
+++ b/builtin/env--helper.c
@@ -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,
diff --git a/builtin/push.c b/builtin/push.c
index 0eeb2c8dd5..6da3a8e5d3 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -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)
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));
diff --git a/commit.h b/commit.h
index e6f8f7c26f..5467786c7b 100644
--- a/commit.h
+++ b/commit.h
@@ -248,7 +248,7 @@ struct oid_array;
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 8e6c292421..ee360c2f07 100644
--- a/convert.c
+++ b/convert.c
@@ -195,7 +195,7 @@ static enum eol output_eol(enum crlf_action crlf_action)
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 @@ static int crlf_to_git(const struct index_state *istate,
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 3018a657b0..78387110e6 100644
--- a/dir.c
+++ b/dir.c
@@ -2105,7 +2105,6 @@ static int resolve_dtype(int dtype, struct index_state *istate,
}
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 @@ static enum path_treatment treat_path(struct dir_struct *dir,
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 d9d3b0819f..4542d4d3f9 100644
--- a/parse-options-cb.c
+++ b/parse-options-cb.c
@@ -105,6 +105,8 @@ int parse_opt_commit(const struct option *opt, const char *arg, int unset)
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 d9dc5781ac..aa62212040 100644
--- a/revision.c
+++ b/revision.c
@@ -2580,8 +2580,8 @@ static int for_each_good_bisect_ref(struct ref_store *refs, each_ref_fn fn, void
}
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 setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
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 3367eb5fbf..00acb12496 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -249,11 +249,20 @@ static int has_conforming_footer(struct strbuf *sb, struct strbuf *sob,
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 @@ static int run_command_silent_on_success(struct child_process *cmd)
* 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 @@ static int do_commit(struct repository *r,
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 @@ static int do_pick_commit(struct repository *r,
*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 @@ static int do_merge(struct repository *r,
* 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 @@ static int commit_staged_changes(struct repository *r,
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 38cdc2884e..a7043df1d3 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 bc97929bbc..c5fd4527dc 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 @@ int cmd__submodule_nested_repo_config(int argc, const char **argv)
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. */