Skip to content

Commit 19dd352

Browse files
committed
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()
2 parents 8250ab0 + 842385b commit 19dd352

15 files changed

+88
-33
lines changed

builtin/add.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ int run_add_interactive(const char *revision, const char *patch_mode,
239239
return status;
240240
}
241241

242-
int interactive_add(int argc, const char **argv, const char *prefix, int patch)
242+
int interactive_add(const char **argv, const char *prefix, int patch)
243243
{
244244
struct pathspec pathspec;
245245

@@ -451,7 +451,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
451451
if (add_interactive) {
452452
if (pathspec_from_file)
453453
die(_("--pathspec-from-file is incompatible with --interactive/--patch"));
454-
exit(interactive_add(argc - 1, argv + 1, prefix, patch_interactive));
454+
exit(interactive_add(argv + 1, prefix, patch_interactive));
455455
}
456456
if (legacy_stash_p) {
457457
struct pathspec pathspec;

builtin/am.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2180,6 +2180,8 @@ static int parse_opt_show_current_patch(const struct option *opt, const char *ar
21802180
};
21812181
int new_value = SHOW_PATCH_RAW;
21822182

2183+
BUG_ON_OPT_NEG(unset);
2184+
21832185
if (arg) {
21842186
for (new_value = 0; new_value < ARRAY_SIZE(valid_modes); new_value++) {
21852187
if (!strcmp(arg, valid_modes[new_value]))

builtin/commit-graph.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ static int write_option_parse_split(const struct option *opt, const char *arg,
128128
{
129129
enum commit_graph_split_flags *flags = opt->value;
130130

131+
BUG_ON_OPT_NEG(unset);
132+
131133
opts.split = 1;
132134
if (!arg)
133135
return 0;

builtin/commit.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ static void refresh_cache_or_die(int refresh_flags)
326326
die_resolve_conflict("commit");
327327
}
328328

329-
static const char *prepare_index(int argc, const char **argv, const char *prefix,
329+
static const char *prepare_index(const char **argv, const char *prefix,
330330
const struct commit *current_head, int is_status)
331331
{
332332
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
378378
old_index_env = xstrdup_or_null(getenv(INDEX_ENVIRONMENT));
379379
setenv(INDEX_ENVIRONMENT, the_repository->index_file, 1);
380380

381-
if (interactive_add(argc, argv, prefix, patch_interactive) != 0)
381+
if (interactive_add(argv, prefix, patch_interactive) != 0)
382382
die(_("interactive add failed"));
383383

384384
the_repository->index_file = old_repo_index_file;
@@ -1241,13 +1241,13 @@ static int parse_and_validate_options(int argc, const char *argv[],
12411241
return argc;
12421242
}
12431243

1244-
static int dry_run_commit(int argc, const char **argv, const char *prefix,
1244+
static int dry_run_commit(const char **argv, const char *prefix,
12451245
const struct commit *current_head, struct wt_status *s)
12461246
{
12471247
int committable;
12481248
const char *index_file;
12491249

1250-
index_file = prepare_index(argc, argv, prefix, current_head, 1);
1250+
index_file = prepare_index(argv, prefix, current_head, 1);
12511251
committable = run_status(stdout, index_file, prefix, 0, s);
12521252
rollback_index_files();
12531253

@@ -1584,8 +1584,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
15841584
verbose = (config_commit_verbose < 0) ? 0 : config_commit_verbose;
15851585

15861586
if (dry_run)
1587-
return dry_run_commit(argc, argv, prefix, current_head, &s);
1588-
index_file = prepare_index(argc, argv, prefix, current_head, 0);
1587+
return dry_run_commit(argv, prefix, current_head, &s);
1588+
index_file = prepare_index(argv, prefix, current_head, 0);
15891589

15901590
/* Set up everything for writing the commit object. This includes
15911591
running hooks, writing the trees, and interacting with the user. */

builtin/env--helper.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,22 @@ static char const * const env__helper_usage[] = {
77
NULL
88
};
99

10-
static enum {
10+
enum cmdmode {
1111
ENV_HELPER_TYPE_BOOL = 1,
1212
ENV_HELPER_TYPE_ULONG
13-
} cmdmode = 0;
13+
};
1414

1515
static int option_parse_type(const struct option *opt, const char *arg,
1616
int unset)
1717
{
18+
enum cmdmode *cmdmode = opt->value;
19+
20+
BUG_ON_OPT_NEG(unset);
21+
1822
if (!strcmp(arg, "bool"))
19-
cmdmode = ENV_HELPER_TYPE_BOOL;
23+
*cmdmode = ENV_HELPER_TYPE_BOOL;
2024
else if (!strcmp(arg, "ulong"))
21-
cmdmode = ENV_HELPER_TYPE_ULONG;
25+
*cmdmode = ENV_HELPER_TYPE_ULONG;
2226
else
2327
die(_("unrecognized --type argument, %s"), arg);
2428

@@ -33,6 +37,7 @@ int cmd_env__helper(int argc, const char **argv, const char *prefix)
3337
int ret;
3438
int ret_int, default_int;
3539
unsigned long ret_ulong, default_ulong;
40+
enum cmdmode cmdmode = 0;
3641
struct option opts[] = {
3742
OPT_CALLBACK_F(0, "type", &cmdmode, N_("type"),
3843
N_("value is given this type"), PARSE_OPT_NONEG,

builtin/push.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ static int push_with_options(struct transport *transport, struct refspec *rs,
379379
return 1;
380380
}
381381

382-
static int do_push(const char *repo, int flags,
382+
static int do_push(int flags,
383383
const struct string_list *push_options,
384384
struct remote *remote)
385385
{
@@ -629,7 +629,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
629629
if (strchr(item->string, '\n'))
630630
die(_("push options must not have new line characters"));
631631

632-
rc = do_push(repo, flags, push_options, remote);
632+
rc = do_push(flags, push_options, remote);
633633
string_list_clear(&push_options_cmdline, 0);
634634
string_list_clear(&push_options_config, 0);
635635
if (rc == -1)

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

commit.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ struct oid_array;
248248
struct ref;
249249
int for_each_commit_graft(each_commit_graft_fn, void *);
250250

251-
int interactive_add(int argc, const char **argv, const char *prefix, int patch);
251+
int interactive_add(const char **argv, const char *prefix, int patch);
252252
int run_add_interactive(const char *revision, const char *patch_mode,
253253
const struct pathspec *pathspec);
254254

convert.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ static enum eol output_eol(enum crlf_action crlf_action)
195195
return core_eol;
196196
}
197197

198-
static void check_global_conv_flags_eol(const char *path, enum crlf_action crlf_action,
198+
static void check_global_conv_flags_eol(const char *path,
199199
struct text_stat *old_stats, struct text_stat *new_stats,
200200
int conv_flags)
201201
{
@@ -547,7 +547,7 @@ static int crlf_to_git(const struct index_state *istate,
547547
new_stats.crlf += new_stats.lonelf;
548548
new_stats.lonelf = 0;
549549
}
550-
check_global_conv_flags_eol(path, crlf_action, &stats, &new_stats, conv_flags);
550+
check_global_conv_flags_eol(path, &stats, &new_stats, conv_flags);
551551
}
552552
if (!convert_crlf_into_lf)
553553
return 0;

dir.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2105,7 +2105,6 @@ static int resolve_dtype(int dtype, struct index_state *istate,
21052105
}
21062106

21072107
static enum path_treatment treat_path_fast(struct dir_struct *dir,
2108-
struct untracked_cache_dir *untracked,
21092108
struct cached_dir *cdir,
21102109
struct index_state *istate,
21112110
struct strbuf *path,
@@ -2153,7 +2152,7 @@ static enum path_treatment treat_path(struct dir_struct *dir,
21532152
int has_path_in_index, dtype, excluded;
21542153

21552154
if (!cdir->d_name)
2156-
return treat_path_fast(dir, untracked, cdir, istate, path,
2155+
return treat_path_fast(dir, cdir, istate, path,
21572156
baselen, pathspec);
21582157
if (is_dot_or_dotdot(cdir->d_name) || !fspathcmp(cdir->d_name, ".git"))
21592158
return path_none;

0 commit comments

Comments
 (0)