Remove deprecated OPTION_BOOLEAN for parsing arguments
authorStefan Beller <stefanbeller@googlemail.com>
Sat, 3 Aug 2013 11:51:18 +0000 (13:51 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 5 Aug 2013 18:32:17 +0000 (11:32 -0700)
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>
builtin/checkout.c
builtin/clone.c
builtin/commit.c
builtin/log.c
builtin/notes.c
builtin/show-ref.c
parse-options.h
index 7025938ae30f2ce3104b27f66bf6e1f294edb810..646a4757b9fb259895541cb9815c899d2c3874a7 100644 (file)
@@ -1073,9 +1073,8 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
                OPT_BOOLEAN('p', "patch", &opts.patch_mode, N_("select hunks interactively")),
                OPT_BOOL(0, "ignore-skip-worktree-bits", &opts.ignore_skipworktree,
                         N_("do not limit pathspecs to sparse entries only")),
-               { OPTION_BOOLEAN, 0, "guess", &dwim_new_local_branch, NULL,
-                 N_("second guess 'git checkout no-such-branch'"),
-                 PARSE_OPT_NOARG | PARSE_OPT_HIDDEN },
+               OPT_HIDDEN_BOOL(0, "guess", &dwim_new_local_branch,
+                               N_("second guess 'git checkout no-such-branch'")),
                OPT_END(),
        };
 
index 430307b298b4f9ea03ff4caea283b133fde0077e..e7b0b13212b783a8d318905dfc68a9f9d808ed53 100644 (file)
@@ -64,10 +64,9 @@ static struct option builtin_clone_options[] = {
                 N_("force progress reporting")),
        OPT_BOOLEAN('n', "no-checkout", &option_no_checkout,
                    N_("don't create a checkout")),
-       OPT_BOOLEAN(0, "bare", &option_bare, N_("create a bare repository")),
-       { OPTION_BOOLEAN, 0, "naked", &option_bare, NULL,
-               N_("create a bare repository"),
-               PARSE_OPT_NOARG | PARSE_OPT_HIDDEN },
+       OPT_BOOL(0, "bare", &option_bare, N_("create a bare repository")),
+       OPT_HIDDEN_BOOL(0, "naked", &option_bare,
+                       N_("create a bare repository")),
        OPT_BOOLEAN(0, "mirror", &option_mirror,
                    N_("create a mirror repository (implies bare)")),
        OPT_BOOL('l', "local", &option_local,
index 003bd7dbec1acfda36f4d4bc5e9fb64a276ad049..b64a0832453d065f2bc3772bea7f8c68ecd76af2 100644 (file)
@@ -1448,12 +1448,10 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
                { 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" },
                /* end commit contents options */
 
-               { OPTION_BOOLEAN, 0, "allow-empty", &allow_empty, NULL,
-                 N_("ok to record an empty change"),
-                 PARSE_OPT_NOARG | PARSE_OPT_HIDDEN },
-               { OPTION_BOOLEAN, 0, "allow-empty-message", &allow_empty_message, NULL,
-                 N_("ok to record a change with an empty message"),
-                 PARSE_OPT_NOARG | PARSE_OPT_HIDDEN },
+               OPT_HIDDEN_BOOL(0, "allow-empty", &allow_empty,
+                               N_("ok to record an empty change")),
+               OPT_HIDDEN_BOOL(0, "allow-empty-message", &allow_empty_message,
+                               N_("ok to record a change with an empty message")),
 
                OPT_END()
        };
index 2625f9881ad836d1a3e303f4c159d6b76a3ae04f..05e374df462ec97941b748db51b8e5db4ab62573 100644 (file)
@@ -1183,9 +1183,9 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
                            N_("don't output binary diffs")),
                OPT_BOOLEAN(0, "ignore-if-in-upstream", &ignore_if_in_upstream,
                            N_("don't include a patch matching a commit upstream")),
-               { OPTION_BOOLEAN, 'p', "no-stat", &use_patch_format, NULL,
+               { OPTION_SET_INT, 'p', "no-stat", &use_patch_format, NULL,
                  N_("show patch format instead of default (patch + stat)"),
-                 PARSE_OPT_NONEG | PARSE_OPT_NOARG },
+                 PARSE_OPT_NONEG | PARSE_OPT_NOARG, NULL, 1},
                OPT_GROUP(N_("Messaging")),
                { OPTION_CALLBACK, 0, "add-header", NULL, N_("header"),
                            N_("add email header"), 0, header_callback },
index e4100c49820306b881a20db4bb3af7c13f12c019..8f63cb2fab33922dc4d41cbad5803b988a750092 100644 (file)
@@ -739,13 +739,13 @@ static int merge(int argc, const char **argv, const char *prefix)
                           N_("resolve notes conflicts using the given strategy "
                              "(manual/ours/theirs/union/cat_sort_uniq)")),
                OPT_GROUP(N_("Committing unmerged notes")),
-               { OPTION_BOOLEAN, 0, "commit", &do_commit, NULL,
+               { OPTION_SET_INT, 0, "commit", &do_commit, NULL,
                        N_("finalize notes merge by committing unmerged notes"),
-                       PARSE_OPT_NOARG | PARSE_OPT_NONEG },
+                       PARSE_OPT_NOARG | PARSE_OPT_NONEG, NULL, 1},
                OPT_GROUP(N_("Aborting notes merge resolution")),
-               { OPTION_BOOLEAN, 0, "abort", &do_abort, NULL,
+               { OPTION_SET_INT, 0, "abort", &do_abort, NULL,
                        N_("abort notes merge"),
-                       PARSE_OPT_NOARG | PARSE_OPT_NONEG },
+                       PARSE_OPT_NOARG | PARSE_OPT_NONEG, NULL, 1},
                OPT_END()
        };
 
index 87806ad5b088f5c905757a4fab3c3499ec20a308..18680bbaeb80b4b5119e5a3b73eae8181fcac439 100644 (file)
@@ -169,9 +169,8 @@ static const struct option show_ref_options[] = {
        OPT_BOOLEAN(0, "heads", &heads_only, N_("only show heads (can be combined with tags)")),
        OPT_BOOLEAN(0, "verify", &verify, N_("stricter reference checking, "
                    "requires exact ref path")),
-       { OPTION_BOOLEAN, 'h', NULL, &show_head, NULL,
-         N_("show the HEAD reference, even if it would be filtered out"),
-         PARSE_OPT_NOARG | PARSE_OPT_HIDDEN },
+       OPT_HIDDEN_BOOL('h', NULL, &show_head,
+                       N_("show the HEAD reference, even if it would be filtered out")),
        OPT_BOOLEAN(0, "head", &show_head,
          N_("show the HEAD reference, even if it would be filtered out")),
        OPT_BOOLEAN('d', "dereference", &deref_tags,
index 2404e06732366dd325c2f32c0453c3bdee8590dc..aeab9aa103faa88a9cdff98db62a586c97298012 100644 (file)
@@ -22,9 +22,6 @@ enum parse_opt_type {
        OPTION_FILENAME
 };
 
-/* Deprecated synonym */
-#define OPTION_BOOLEAN OPTION_COUNTUP
-
 enum parse_opt_flags {
        PARSE_OPT_KEEP_DASHDASH = 1,
        PARSE_OPT_STOP_AT_NON_OPTION = 2,
@@ -129,6 +126,8 @@ struct option {
 #define OPT_SET_INT(s, l, v, h, i)  { OPTION_SET_INT, (s), (l), (v), NULL, \
                                      (h), PARSE_OPT_NOARG, NULL, (i) }
 #define OPT_BOOL(s, l, v, h)        OPT_SET_INT(s, l, v, h, 1)
+#define OPT_HIDDEN_BOOL(s, l, v, h) { OPTION_SET_INT, (s), (l), (v), NULL, \
+                                     (h), PARSE_OPT_NOARG | PARSE_OPT_HIDDEN, NULL, 1}
 #define OPT_SET_PTR(s, l, v, h, p)  { OPTION_SET_PTR, (s), (l), (v), NULL, \
                                      (h), PARSE_OPT_NOARG, NULL, (p) }
 #define OPT_CMDMODE(s, l, v, h, i) { OPTION_CMDMODE, (s), (l), (v), NULL, \