Skip to content

Commit a86a8b9

Browse files
committed
Merge branch 'sb/parseopt-boolean-removal'
Convert most uses of OPT_BOOLEAN/OPTION_BOOLEAN that can use OPT_BOOL/OPTION_BOOLEAN which have much saner semantics, and turn remaining ones into OPT_SET_INT, OPT_COUNTUP, etc. as necessary. * sb/parseopt-boolean-removal: revert: use the OPT_CMDMODE for parsing, reducing code checkout-index: fix negations of even numbers of -n config parsing options: allow one flag multiple times hash-object: replace stdin parsing OPT_BOOLEAN by OPT_COUNTUP branch, commit, name-rev: ease up boolean conditions checkout: remove superfluous local variable log, format-patch: parsing uses OPT__QUIET Replace deprecated OPT_BOOLEAN by OPT_BOOL Remove deprecated OPTION_BOOLEAN for parsing arguments
2 parents 366b80b + 84d83f6 commit a86a8b9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+279
-318
lines changed

Documentation/git-format-patch.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ configuration options in linkgit:git-notes[1] to use this workflow).
242242
Note that the leading character does not have to be a dot; for example,
243243
you can use `--suffix=-patch` to get `0001-description-of-my-change-patch`.
244244

245+
-q::
245246
--quiet::
246247
Do not print the names of the generated files to standard output.
247248

builtin/apply.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4363,23 +4363,23 @@ int cmd_apply(int argc, const char **argv, const char *prefix_)
43634363
{ OPTION_CALLBACK, 'p', NULL, NULL, N_("num"),
43644364
N_("remove <num> leading slashes from traditional diff paths"),
43654365
0, option_parse_p },
4366-
OPT_BOOLEAN(0, "no-add", &no_add,
4366+
OPT_BOOL(0, "no-add", &no_add,
43674367
N_("ignore additions made by the patch")),
4368-
OPT_BOOLEAN(0, "stat", &diffstat,
4368+
OPT_BOOL(0, "stat", &diffstat,
43694369
N_("instead of applying the patch, output diffstat for the input")),
43704370
OPT_NOOP_NOARG(0, "allow-binary-replacement"),
43714371
OPT_NOOP_NOARG(0, "binary"),
4372-
OPT_BOOLEAN(0, "numstat", &numstat,
4372+
OPT_BOOL(0, "numstat", &numstat,
43734373
N_("show number of added and deleted lines in decimal notation")),
4374-
OPT_BOOLEAN(0, "summary", &summary,
4374+
OPT_BOOL(0, "summary", &summary,
43754375
N_("instead of applying the patch, output a summary for the input")),
4376-
OPT_BOOLEAN(0, "check", &check,
4376+
OPT_BOOL(0, "check", &check,
43774377
N_("instead of applying the patch, see if the patch is applicable")),
4378-
OPT_BOOLEAN(0, "index", &check_index,
4378+
OPT_BOOL(0, "index", &check_index,
43794379
N_("make sure the patch is applicable to the current index")),
4380-
OPT_BOOLEAN(0, "cached", &cached,
4380+
OPT_BOOL(0, "cached", &cached,
43814381
N_("apply a patch without touching the working tree")),
4382-
OPT_BOOLEAN(0, "apply", &force_apply,
4382+
OPT_BOOL(0, "apply", &force_apply,
43834383
N_("also apply the patch (use with --stat/--summary/--check)")),
43844384
OPT_BOOL('3', "3way", &threeway,
43854385
N_( "attempt three-way merge if a patch does not apply")),
@@ -4399,13 +4399,13 @@ int cmd_apply(int argc, const char **argv, const char *prefix_)
43994399
{ OPTION_CALLBACK, 0, "ignore-whitespace", NULL, NULL,
44004400
N_("ignore changes in whitespace when finding context"),
44014401
PARSE_OPT_NOARG, option_parse_space_change },
4402-
OPT_BOOLEAN('R', "reverse", &apply_in_reverse,
4402+
OPT_BOOL('R', "reverse", &apply_in_reverse,
44034403
N_("apply the patch in reverse")),
4404-
OPT_BOOLEAN(0, "unidiff-zero", &unidiff_zero,
4404+
OPT_BOOL(0, "unidiff-zero", &unidiff_zero,
44054405
N_("don't expect at least one line of context")),
4406-
OPT_BOOLEAN(0, "reject", &apply_with_reject,
4406+
OPT_BOOL(0, "reject", &apply_with_reject,
44074407
N_("leave the rejected hunks in corresponding *.rej files")),
4408-
OPT_BOOLEAN(0, "allow-overlap", &allow_overlap,
4408+
OPT_BOOL(0, "allow-overlap", &allow_overlap,
44094409
N_("allow overlapping hunks")),
44104410
OPT__VERBOSE(&apply_verbosely, N_("be verbose")),
44114411
OPT_BIT(0, "inaccurate-eof", &options,

builtin/bisect--helper.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
1313
int next_all = 0;
1414
int no_checkout = 0;
1515
struct option options[] = {
16-
OPT_BOOLEAN(0, "next-all", &next_all,
17-
N_("perform 'git bisect next'")),
18-
OPT_BOOLEAN(0, "no-checkout", &no_checkout,
19-
N_("update BISECT_HEAD instead of checking out the current commit")),
16+
OPT_BOOL(0, "next-all", &next_all,
17+
N_("perform 'git bisect next'")),
18+
OPT_BOOL(0, "no-checkout", &no_checkout,
19+
N_("update BISECT_HEAD instead of checking out the current commit")),
2020
OPT_END()
2121
};
2222

builtin/blame.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2273,10 +2273,10 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
22732273
static const char *revs_file = NULL;
22742274
static const char *contents_from = NULL;
22752275
static const struct option options[] = {
2276-
OPT_BOOLEAN(0, "incremental", &incremental, N_("Show blame entries as we find them, incrementally")),
2277-
OPT_BOOLEAN('b', NULL, &blank_boundary, N_("Show blank SHA-1 for boundary commits (Default: off)")),
2278-
OPT_BOOLEAN(0, "root", &show_root, N_("Do not treat root commits as boundaries (Default: off)")),
2279-
OPT_BOOLEAN(0, "show-stats", &show_stats, N_("Show work cost statistics")),
2276+
OPT_BOOL(0, "incremental", &incremental, N_("Show blame entries as we find them, incrementally")),
2277+
OPT_BOOL('b', NULL, &blank_boundary, N_("Show blank SHA-1 for boundary commits (Default: off)")),
2278+
OPT_BOOL(0, "root", &show_root, N_("Do not treat root commits as boundaries (Default: off)")),
2279+
OPT_BOOL(0, "show-stats", &show_stats, N_("Show work cost statistics")),
22802280
OPT_BIT(0, "score-debug", &output_option, N_("Show output score for blame entries"), OUTPUT_SHOW_SCORE),
22812281
OPT_BIT('f', "show-name", &output_option, N_("Show original filename (Default: auto)"), OUTPUT_SHOW_NAME),
22822282
OPT_BIT('n', "show-number", &output_option, N_("Show original linenumber (Default: off)"), OUTPUT_SHOW_NUMBER),

builtin/branch.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
797797
OPT_SET_INT( 0, "set-upstream", &track, N_("change upstream info"),
798798
BRANCH_TRACK_OVERRIDE),
799799
OPT_STRING('u', "set-upstream-to", &new_upstream, "upstream", "change the upstream info"),
800-
OPT_BOOLEAN(0, "unset-upstream", &unset_upstream, "Unset the upstream info"),
800+
OPT_BOOL(0, "unset-upstream", &unset_upstream, "Unset the upstream info"),
801801
OPT__COLOR(&branch_use_color, N_("use colored output")),
802802
OPT_SET_INT('r', "remotes", &kinds, N_("act on remote-tracking branches"),
803803
REF_REMOTE_BRANCH),
@@ -822,10 +822,10 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
822822
OPT_BIT('D', NULL, &delete, N_("delete branch (even if not merged)"), 2),
823823
OPT_BIT('m', "move", &rename, N_("move/rename a branch and its reflog"), 1),
824824
OPT_BIT('M', NULL, &rename, N_("move/rename a branch, even if target exists"), 2),
825-
OPT_BOOLEAN(0, "list", &list, N_("list branch names")),
826-
OPT_BOOLEAN('l', "create-reflog", &reflog, N_("create the branch's reflog")),
827-
OPT_BOOLEAN(0, "edit-description", &edit_description,
828-
N_("edit the description for the branch")),
825+
OPT_BOOL(0, "list", &list, N_("list branch names")),
826+
OPT_BOOL('l', "create-reflog", &reflog, N_("create the branch's reflog")),
827+
OPT_BOOL(0, "edit-description", &edit_description,
828+
N_("edit the description for the branch")),
829829
OPT__FORCE(&force_create, N_("force creation (when already exists)")),
830830
{
831831
OPTION_CALLBACK, 0, "no-merged", &merge_filter_ref,
@@ -872,7 +872,8 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
872872
if (with_commit || merge_filter != NO_FILTER)
873873
list = 1;
874874

875-
if (!!delete + !!rename + !!force_create + !!list + !!new_upstream + !!unset_upstream > 1)
875+
if (!!delete + !!rename + !!force_create + !!new_upstream +
876+
list + unset_upstream > 1)
876877
usage_with_options(builtin_branch_usage, options);
877878

878879
if (abbrev == -1)

builtin/check-attr.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ NULL
1616
static int nul_term_line;
1717

1818
static const struct option check_attr_options[] = {
19-
OPT_BOOLEAN('a', "all", &all_attrs, N_("report all attributes set on file")),
20-
OPT_BOOLEAN(0, "cached", &cached_attrs, N_("use .gitattributes only from the index")),
21-
OPT_BOOLEAN(0 , "stdin", &stdin_paths, N_("read file names from stdin")),
22-
OPT_BOOLEAN('z', NULL, &nul_term_line,
23-
N_("terminate input and output records by a NUL character")),
19+
OPT_BOOL('a', "all", &all_attrs, N_("report all attributes set on file")),
20+
OPT_BOOL(0, "cached", &cached_attrs, N_("use .gitattributes only from the index")),
21+
OPT_BOOL(0 , "stdin", &stdin_paths, N_("read file names from stdin")),
22+
OPT_BOOL('z', NULL, &nul_term_line,
23+
N_("terminate input and output records by a NUL character")),
2424
OPT_END()
2525
};
2626

builtin/check-ignore.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ static const struct option check_ignore_options[] = {
1818
OPT__QUIET(&quiet, N_("suppress progress reporting")),
1919
OPT__VERBOSE(&verbose, N_("be verbose")),
2020
OPT_GROUP(""),
21-
OPT_BOOLEAN(0, "stdin", &stdin_paths,
22-
N_("read file names from stdin")),
23-
OPT_BOOLEAN('z', NULL, &nul_term_line,
24-
N_("terminate input and output records by a NUL character")),
25-
OPT_BOOLEAN('n', "non-matching", &show_non_matching,
26-
N_("show non-matching input paths")),
21+
OPT_BOOL(0, "stdin", &stdin_paths,
22+
N_("read file names from stdin")),
23+
OPT_BOOL('z', NULL, &nul_term_line,
24+
N_("terminate input and output records by a NUL character")),
25+
OPT_BOOL('n', "non-matching", &show_non_matching,
26+
N_("show non-matching input paths")),
2727
OPT_END()
2828
};
2929

builtin/checkout-index.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,22 +183,22 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix)
183183
int prefix_length;
184184
int force = 0, quiet = 0, not_new = 0;
185185
struct option builtin_checkout_index_options[] = {
186-
OPT_BOOLEAN('a', "all", &all,
186+
OPT_BOOL('a', "all", &all,
187187
N_("check out all files in the index")),
188188
OPT__FORCE(&force, N_("force overwrite of existing files")),
189189
OPT__QUIET(&quiet,
190190
N_("no warning for existing files and files not in index")),
191-
OPT_BOOLEAN('n', "no-create", &not_new,
191+
OPT_BOOL('n', "no-create", &not_new,
192192
N_("don't checkout new files")),
193193
{ OPTION_CALLBACK, 'u', "index", &newfd, NULL,
194194
N_("update stat information in the index file"),
195195
PARSE_OPT_NOARG, option_parse_u },
196196
{ OPTION_CALLBACK, 'z', NULL, NULL, NULL,
197197
N_("paths are separated with NUL character"),
198198
PARSE_OPT_NOARG, option_parse_z },
199-
OPT_BOOLEAN(0, "stdin", &read_from_stdin,
199+
OPT_BOOL(0, "stdin", &read_from_stdin,
200200
N_("read list of paths from the standard input")),
201-
OPT_BOOLEAN(0, "temp", &to_tempfile,
201+
OPT_BOOL(0, "temp", &to_tempfile,
202202
N_("write the content to temporary files")),
203203
OPT_CALLBACK(0, "prefix", NULL, N_("string"),
204204
N_("when creating files, prepend <string>"),

builtin/checkout.c

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,6 @@ static int checkout_paths(const struct checkout_opts *opts,
228228
int flag;
229229
struct commit *head;
230230
int errs = 0;
231-
int stage = opts->writeout_stage;
232-
int merge = opts->merge;
233231
int newfd;
234232
struct lock_file *lock_file;
235233

@@ -327,8 +325,8 @@ static int checkout_paths(const struct checkout_opts *opts,
327325
continue;
328326
if (opts->force) {
329327
warning(_("path '%s' is unmerged"), ce->name);
330-
} else if (stage) {
331-
errs |= check_stage(stage, ce, pos);
328+
} else if (opts->writeout_stage) {
329+
errs |= check_stage(opts->writeout_stage, ce, pos);
332330
} else if (opts->merge) {
333331
errs |= check_stages((1<<2) | (1<<3), ce, pos);
334332
} else {
@@ -352,9 +350,9 @@ static int checkout_paths(const struct checkout_opts *opts,
352350
errs |= checkout_entry(ce, &state, NULL);
353351
continue;
354352
}
355-
if (stage)
356-
errs |= checkout_stage(stage, ce, pos, &state);
357-
else if (merge)
353+
if (opts->writeout_stage)
354+
errs |= checkout_stage(opts->writeout_stage, ce, pos, &state);
355+
else if (opts->merge)
358356
errs |= checkout_merged(pos, &state);
359357
pos = skip_same_name(ce, pos) - 1;
360358
}
@@ -1056,8 +1054,8 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
10561054
N_("create and checkout a new branch")),
10571055
OPT_STRING('B', NULL, &opts.new_branch_force, N_("branch"),
10581056
N_("create/reset and checkout a branch")),
1059-
OPT_BOOLEAN('l', NULL, &opts.new_branch_log, N_("create reflog for new branch")),
1060-
OPT_BOOLEAN(0, "detach", &opts.force_detach, N_("detach the HEAD at named commit")),
1057+
OPT_BOOL('l', NULL, &opts.new_branch_log, N_("create reflog for new branch")),
1058+
OPT_BOOL(0, "detach", &opts.force_detach, N_("detach the HEAD at named commit")),
10611059
OPT_SET_INT('t', "track", &opts.track, N_("set upstream info for new branch"),
10621060
BRANCH_TRACK_EXPLICIT),
10631061
OPT_STRING(0, "orphan", &opts.new_orphan_branch, N_("new branch"), N_("new unparented branch")),
@@ -1066,16 +1064,15 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
10661064
OPT_SET_INT('3', "theirs", &opts.writeout_stage, N_("checkout their version for unmerged files"),
10671065
3),
10681066
OPT__FORCE(&opts.force, N_("force checkout (throw away local modifications)")),
1069-
OPT_BOOLEAN('m', "merge", &opts.merge, N_("perform a 3-way merge with the new branch")),
1070-
OPT_BOOLEAN(0, "overwrite-ignore", &opts.overwrite_ignore, N_("update ignored files (default)")),
1067+
OPT_BOOL('m', "merge", &opts.merge, N_("perform a 3-way merge with the new branch")),
1068+
OPT_BOOL(0, "overwrite-ignore", &opts.overwrite_ignore, N_("update ignored files (default)")),
10711069
OPT_STRING(0, "conflict", &conflict_style, N_("style"),
10721070
N_("conflict style (merge or diff3)")),
1073-
OPT_BOOLEAN('p', "patch", &opts.patch_mode, N_("select hunks interactively")),
1071+
OPT_BOOL('p', "patch", &opts.patch_mode, N_("select hunks interactively")),
10741072
OPT_BOOL(0, "ignore-skip-worktree-bits", &opts.ignore_skipworktree,
10751073
N_("do not limit pathspecs to sparse entries only")),
1076-
{ OPTION_BOOLEAN, 0, "guess", &dwim_new_local_branch, NULL,
1077-
N_("second guess 'git checkout no-such-branch'"),
1078-
PARSE_OPT_NOARG | PARSE_OPT_HIDDEN },
1074+
OPT_HIDDEN_BOOL(0, "guess", &dwim_new_local_branch,
1075+
N_("second guess 'git checkout no-such-branch'")),
10791076
OPT_END(),
10801077
};
10811078

builtin/clean.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -875,12 +875,12 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
875875
OPT__DRY_RUN(&dry_run, N_("dry run")),
876876
OPT__FORCE(&force, N_("force")),
877877
OPT_BOOL('i', "interactive", &interactive, N_("interactive cleaning")),
878-
OPT_BOOLEAN('d', NULL, &remove_directories,
878+
OPT_BOOL('d', NULL, &remove_directories,
879879
N_("remove whole directories")),
880880
{ OPTION_CALLBACK, 'e', "exclude", &exclude_list, N_("pattern"),
881881
N_("add <pattern> to ignore rules"), PARSE_OPT_NONEG, exclude_cb },
882-
OPT_BOOLEAN('x', NULL, &ignored, N_("remove ignored files, too")),
883-
OPT_BOOLEAN('X', NULL, &ignored_only,
882+
OPT_BOOL('x', NULL, &ignored, N_("remove ignored files, too")),
883+
OPT_BOOL('X', NULL, &ignored_only,
884884
N_("remove only ignored files")),
885885
OPT_END()
886886
};

0 commit comments

Comments
 (0)