Remove deprecated OPTION_BOOLEAN for parsing arguments

As of b04ba2bb4 OPTION_BOOLEAN was deprecated. This commit removes all occurrences of OPTION_BOOLEAN. In b04ba2bb4 Junio suggested to replace it with either OPTION_SET_INT or OPTION_COUNTUP instead. However a pattern, which occurred often with the OPTION_BOOLEAN was a hidden boolean parameter. So I defined OPT_HIDDEN_BOOL as an additional possible parse option in parse-options.h to make life easy. The OPT_HIDDEN_BOOL was used in checkout, clone, commit, show-ref. The only exception, where there was need to fiddle with OPTION_SET_INT was log and notes. However in these two files there is also a pattern, so we could think of introducing OPT_NONEG_BOOL. Signed-off-by: Stefan Beller <stefanbeller@googlemail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Stefan Beller committed Aug 3, 2013 at 13:51 UTC 4741edd549decfccc016fa4775b349fe94fdf4e5
7 files changed +19 -25
builtin/checkout.c
+2 -3
@@ -1073,9 +1073,8 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
1073 OPT_BOOLEAN('p', "patch", &opts.patch_mode, N_("select hunks interactively")),
1074 OPT_BOOL(0, "ignore-skip-worktree-bits", &opts.ignore_skipworktree,
1075 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 },
1076 + OPT_HIDDEN_BOOL(0, "guess", &dwim_new_local_branch,
1077 + N_("second guess 'git checkout no-such-branch'")),
1078 OPT_END(),
1079 };
1080
builtin/clone.c
+3 -4
@@ -64,10 +64,9 @@ static struct option builtin_clone_options[] = {
64 N_("force progress reporting")),
65 OPT_BOOLEAN('n', "no-checkout", &option_no_checkout,
66 N_("don't create a checkout")),
67 - OPT_BOOLEAN(0, "bare", &option_bare, N_("create a bare repository")),
68 - { OPTION_BOOLEAN, 0, "naked", &option_bare, NULL,
69 - N_("create a bare repository"),
70 - PARSE_OPT_NOARG | PARSE_OPT_HIDDEN },
67 + OPT_BOOL(0, "bare", &option_bare, N_("create a bare repository")),
68 + OPT_HIDDEN_BOOL(0, "naked", &option_bare,
69 + N_("create a bare repository")),
70 OPT_BOOLEAN(0, "mirror", &option_mirror,
71 N_("create a mirror repository (implies bare)")),
72 OPT_BOOL('l', "local", &option_local,
builtin/commit.c
+4 -6
@@ -1448,12 +1448,10 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
1448 { OPTION_STRING, 'u', "untracked-files", &untracked_files_arg, N_("mode"), N_("show untracked files, optional modes: all, normal, no. (Default: all)"), PARSE_OPT_OPTARG, NULL, (intptr_t)"all" },
1449 /* end commit contents options */
1450
1451 - { OPTION_BOOLEAN, 0, "allow-empty", &allow_empty, NULL,
1452 - N_("ok to record an empty change"),
1453 - PARSE_OPT_NOARG | PARSE_OPT_HIDDEN },
1454 - { OPTION_BOOLEAN, 0, "allow-empty-message", &allow_empty_message, NULL,
1455 - N_("ok to record a change with an empty message"),
1456 - PARSE_OPT_NOARG | PARSE_OPT_HIDDEN },
1451 + OPT_HIDDEN_BOOL(0, "allow-empty", &allow_empty,
1452 + N_("ok to record an empty change")),
1453 + OPT_HIDDEN_BOOL(0, "allow-empty-message", &allow_empty_message,
1454 + N_("ok to record a change with an empty message")),
1455
1456 OPT_END()
1457 };
builtin/log.c
+2 -2
@@ -1183,9 +1183,9 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
1183 N_("don't output binary diffs")),
1184 OPT_BOOLEAN(0, "ignore-if-in-upstream", &ignore_if_in_upstream,
1185 N_("don't include a patch matching a commit upstream")),
1186 - { OPTION_BOOLEAN, 'p', "no-stat", &use_patch_format, NULL,
1186 + { OPTION_SET_INT, 'p', "no-stat", &use_patch_format, NULL,
1187 N_("show patch format instead of default (patch + stat)"),
1188 - PARSE_OPT_NONEG | PARSE_OPT_NOARG },
1188 + PARSE_OPT_NONEG | PARSE_OPT_NOARG, NULL, 1},
1189 OPT_GROUP(N_("Messaging")),
1190 { OPTION_CALLBACK, 0, "add-header", NULL, N_("header"),
1191 N_("add email header"), 0, header_callback },
builtin/notes.c
+4 -4
@@ -739,13 +739,13 @@ static int merge(int argc, const char **argv, const char *prefix)
739 N_("resolve notes conflicts using the given strategy "
740 "(manual/ours/theirs/union/cat_sort_uniq)")),
741 OPT_GROUP(N_("Committing unmerged notes")),
742 - { OPTION_BOOLEAN, 0, "commit", &do_commit, NULL,
742 + { OPTION_SET_INT, 0, "commit", &do_commit, NULL,
743 N_("finalize notes merge by committing unmerged notes"),
744 - PARSE_OPT_NOARG | PARSE_OPT_NONEG },
744 + PARSE_OPT_NOARG | PARSE_OPT_NONEG, NULL, 1},
745 OPT_GROUP(N_("Aborting notes merge resolution")),
746 - { OPTION_BOOLEAN, 0, "abort", &do_abort, NULL,
746 + { OPTION_SET_INT, 0, "abort", &do_abort, NULL,
747 N_("abort notes merge"),
748 - PARSE_OPT_NOARG | PARSE_OPT_NONEG },
748 + PARSE_OPT_NOARG | PARSE_OPT_NONEG, NULL, 1},
749 OPT_END()
750 };
751
builtin/show-ref.c
+2 -3
@@ -169,9 +169,8 @@ static const struct option show_ref_options[] = {
169 OPT_BOOLEAN(0, "heads", &heads_only, N_("only show heads (can be combined with tags)")),
170 OPT_BOOLEAN(0, "verify", &verify, N_("stricter reference checking, "
171 "requires exact ref path")),
172 - { OPTION_BOOLEAN, 'h', NULL, &show_head, NULL,
173 - N_("show the HEAD reference, even if it would be filtered out"),
174 - PARSE_OPT_NOARG | PARSE_OPT_HIDDEN },
172 + OPT_HIDDEN_BOOL('h', NULL, &show_head,
173 + N_("show the HEAD reference, even if it would be filtered out")),
174 OPT_BOOLEAN(0, "head", &show_head,
175 N_("show the HEAD reference, even if it would be filtered out")),
176 OPT_BOOLEAN('d', "dereference", &deref_tags,
parse-options.h
+2 -3
@@ -22,9 +22,6 @@ enum parse_opt_type {
22 OPTION_FILENAME
23 };
24
25 -/* Deprecated synonym */
26 -#define OPTION_BOOLEAN OPTION_COUNTUP
27 -
25 enum parse_opt_flags {
26 PARSE_OPT_KEEP_DASHDASH = 1,
27 PARSE_OPT_STOP_AT_NON_OPTION = 2,
@@ -129,6 +126,8 @@ struct option {
126 #define OPT_SET_INT(s, l, v, h, i) { OPTION_SET_INT, (s), (l), (v), NULL, \
127 (h), PARSE_OPT_NOARG, NULL, (i) }
128 #define OPT_BOOL(s, l, v, h) OPT_SET_INT(s, l, v, h, 1)
129 +#define OPT_HIDDEN_BOOL(s, l, v, h) { OPTION_SET_INT, (s), (l), (v), NULL, \
130 + (h), PARSE_OPT_NOARG | PARSE_OPT_HIDDEN, NULL, 1}
131 #define OPT_SET_PTR(s, l, v, h, p) { OPTION_SET_PTR, (s), (l), (v), NULL, \
132 (h), PARSE_OPT_NOARG, NULL, (p) }
133 #define OPT_CMDMODE(s, l, v, h, i) { OPTION_CMDMODE, (s), (l), (v), NULL, \