]> git.ipfire.org Git - thirdparty/git.git/commitdiff
parse-options: let OPT__FORCE take optional flags argument
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Fri, 9 Feb 2018 11:01:42 +0000 (18:01 +0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 9 Feb 2018 18:24:50 +0000 (10:24 -0800)
--force option is most likely hidden from command line completion for
safety reasons. This is done by adding an extra flag
PARSE_OPT_NOCOMPLETE. Update OPT__FORCE() to accept additional
flags. Actual flag change comes later depending on individual
commands.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 files changed:
builtin/add.c
builtin/branch.c
builtin/checkout-index.c
builtin/checkout.c
builtin/clean.c
builtin/fetch.c
builtin/mv.c
builtin/notes.c
builtin/pull.c
builtin/rm.c
builtin/tag.c
builtin/update-server-info.c
builtin/worktree.c
parse-options.h

index bf01d89e28eaef0f8113d42c6b9d4142b8e912e4..ac7c1c327766c6a729ab0377fd71c2f8e9042d00 100644 (file)
@@ -294,7 +294,7 @@ static struct option builtin_add_options[] = {
        OPT_BOOL('i', "interactive", &add_interactive, N_("interactive picking")),
        OPT_BOOL('p', "patch", &patch_interactive, N_("select hunks interactively")),
        OPT_BOOL('e', "edit", &edit_interactive, N_("edit current diff and apply")),
-       OPT__FORCE(&ignored_too, N_("allow adding otherwise ignored files")),
+       OPT__FORCE(&ignored_too, N_("allow adding otherwise ignored files"), 0),
        OPT_BOOL('u', "update", &take_worktree_changes, N_("update tracked files")),
        OPT_BOOL(0, "renormalize", &add_renormalize, N_("renormalize EOL of tracked files (implies -u)")),
        OPT_BOOL('N', "intent-to-add", &intent_to_add, N_("record only the fact that the path will be added later")),
index 8dcc2ed058be6e653f885e48c9aa5f465a5f9749..b5b62c08bafb713e276c7c1c21d8c99456903544 100644 (file)
@@ -615,7 +615,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
                OPT_BOOL('l', "create-reflog", &reflog, N_("create the branch's reflog")),
                OPT_BOOL(0, "edit-description", &edit_description,
                         N_("edit the description for the branch")),
-               OPT__FORCE(&force, N_("force creation, move/rename, deletion")),
+               OPT__FORCE(&force, N_("force creation, move/rename, deletion"), 0),
                OPT_MERGED(&filter, N_("print only branches that are merged")),
                OPT_NO_MERGED(&filter, N_("print only branches that are not merged")),
                OPT_COLUMN(0, "column", &colopts, N_("list branches in columns")),
index b0e78b819db3138f1c5ac4fe4b5d850ab306b470..a730f6a1aa47a60d4c131ee47076411a129d8080 100644 (file)
@@ -157,7 +157,7 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix)
        struct option builtin_checkout_index_options[] = {
                OPT_BOOL('a', "all", &all,
                        N_("check out all files in the index")),
-               OPT__FORCE(&force, N_("force overwrite of existing files")),
+               OPT__FORCE(&force, N_("force overwrite of existing files"), 0),
                OPT__QUIET(&quiet,
                        N_("no warning for existing files and files not in index")),
                OPT_BOOL('n', "no-create", &not_new,
index c54c78df547c8c66377f023730958f7a95d3aea1..2a96358eb7c2b5958c5f410c25f4b4a076664983 100644 (file)
@@ -1118,7 +1118,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
                            2),
                OPT_SET_INT('3', "theirs", &opts.writeout_stage, N_("checkout their version for unmerged files"),
                            3),
-               OPT__FORCE(&opts.force, N_("force checkout (throw away local modifications)")),
+               OPT__FORCE(&opts.force, N_("force checkout (throw away local modifications)"), 0),
                OPT_BOOL('m', "merge", &opts.merge, N_("perform a 3-way merge with the new branch")),
                OPT_BOOL(0, "overwrite-ignore", &opts.overwrite_ignore, N_("update ignored files (default)")),
                OPT_STRING(0, "conflict", &conflict_style, N_("style"),
index 189e20628c07774089c5c925380b6b69af16fc7f..3c4ca9a2ff698253cc03228689068fc2884673bd 100644 (file)
@@ -909,7 +909,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
        struct option options[] = {
                OPT__QUIET(&quiet, N_("do not print names of files removed")),
                OPT__DRY_RUN(&dry_run, N_("dry run")),
-               OPT__FORCE(&force, N_("force")),
+               OPT__FORCE(&force, N_("force"), 0),
                OPT_BOOL('i', "interactive", &interactive, N_("interactive cleaning")),
                OPT_BOOL('d', NULL, &remove_directories,
                                N_("remove whole directories")),
index 7bbcd26faf1fe650ccc7dbbd526db5114aac0c8f..6a603174fbaf5495ee176c70d913924accb432c7 100644 (file)
@@ -115,7 +115,7 @@ static struct option builtin_fetch_options[] = {
                 N_("append to .git/FETCH_HEAD instead of overwriting")),
        OPT_STRING(0, "upload-pack", &upload_pack, N_("path"),
                   N_("path to upload pack on remote end")),
-       OPT__FORCE(&force, N_("force overwrite of local branch")),
+       OPT__FORCE(&force, N_("force overwrite of local branch"), 0),
        OPT_BOOL('m', "multiple", &multiple,
                 N_("fetch from multiple remotes")),
        OPT_SET_INT('t', "tags", &tags,
index cf3684d907a2fe3408581502c682d6290c790827..b88023a733ff263f13b12bb0e618f15da0f74a11 100644 (file)
@@ -122,7 +122,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
        struct option builtin_mv_options[] = {
                OPT__VERBOSE(&verbose, N_("be verbose")),
                OPT__DRY_RUN(&show_only, N_("dry run")),
-               OPT__FORCE(&force, N_("force move/rename even if target exists")),
+               OPT__FORCE(&force, N_("force move/rename even if target exists"), 0),
                OPT_BOOL('k', NULL, &ignore_errors, N_("skip move/rename errors")),
                OPT_END(),
        };
index 7c8176164561be1d57771ad2fdeb9260cc1d8c87..b52e71c73e499d2f566678739ae581e188792b10 100644 (file)
@@ -413,7 +413,7 @@ static int add(int argc, const char **argv, const char *prefix)
                        parse_reuse_arg},
                OPT_BOOL(0, "allow-empty", &allow_empty,
                        N_("allow storing empty note")),
-               OPT__FORCE(&force, N_("replace existing notes")),
+               OPT__FORCE(&force, N_("replace existing notes"), 0),
                OPT_END()
        };
 
@@ -484,7 +484,7 @@ static int copy(int argc, const char **argv, const char *prefix)
        struct notes_tree *t;
        const char *rewrite_cmd = NULL;
        struct option options[] = {
-               OPT__FORCE(&force, N_("replace existing notes")),
+               OPT__FORCE(&force, N_("replace existing notes"), 0),
                OPT_BOOL(0, "stdin", &from_stdin, N_("read objects from stdin")),
                OPT_STRING(0, "for-rewrite", &rewrite_cmd, N_("command"),
                           N_("load rewriting config for <command> (implies "
index 511dbbe0f6e25d8f0e8c6ce511cc0ff734adc9bc..652239aae99e99fddcc127d8f1c6a426271af541 100644 (file)
@@ -193,7 +193,7 @@ static struct option pull_options[] = {
        OPT_PASSTHRU(0, "upload-pack", &opt_upload_pack, N_("path"),
                N_("path to upload pack on remote end"),
                0),
-       OPT__FORCE(&opt_force, N_("force overwrite of local branch")),
+       OPT__FORCE(&opt_force, N_("force overwrite of local branch"), 0),
        OPT_PASSTHRU('t', "tags", &opt_tags, NULL,
                N_("fetch all tags and associated objects"),
                PARSE_OPT_NOARG),
index 4a2fcca27b3f722ca520c2411b80e6984ecf780a..6e0c7f5ac653d949a240c7f0689f7516fc99d3b4 100644 (file)
@@ -242,7 +242,7 @@ static struct option builtin_rm_options[] = {
        OPT__DRY_RUN(&show_only, N_("dry run")),
        OPT__QUIET(&quiet, N_("do not list removed files")),
        OPT_BOOL( 0 , "cached",         &index_only, N_("only remove from the index")),
-       OPT__FORCE(&force, N_("override the up-to-date check")),
+       OPT__FORCE(&force, N_("override the up-to-date check"), 0),
        OPT_BOOL('r', NULL,             &recursive,  N_("allow recursive removal")),
        OPT_BOOL( 0 , "ignore-unmatch", &ignore_unmatch,
                                N_("exit with a zero status even if nothing matched")),
index a7e6a5b0f234a95fb45a71d7e9aa7f0baa2b47f8..98d3956bbeaf6570cac705ca7401029ee4775056 100644 (file)
@@ -391,7 +391,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
                        N_("how to strip spaces and #comments from message")),
                OPT_STRING('u', "local-user", &keyid, N_("key-id"),
                                        N_("use another key to sign the tag")),
-               OPT__FORCE(&force, N_("replace the tag if exists")),
+               OPT__FORCE(&force, N_("replace the tag if exists"), 0),
                OPT_BOOL(0, "create-reflog", &create_reflog, N_("create a reflog")),
 
                OPT_GROUP(N_("Tag listing options")),
index 873070e517090cbb21bf53cbc03088da6f85ec1f..4321a344567ed83e6828be41eb150d90c4d7756a 100644 (file)
@@ -12,7 +12,7 @@ int cmd_update_server_info(int argc, const char **argv, const char *prefix)
 {
        int force = 0;
        struct option options[] = {
-               OPT__FORCE(&force, N_("update the info files from scratch")),
+               OPT__FORCE(&force, N_("update the info files from scratch"), 0),
                OPT_END()
        };
 
index 7cef5b120b7786d107282d03052c5e06d3a2c85a..4d3422f62e7e02bd9f4949e2704ac1cb8028ae3d 100644 (file)
@@ -365,7 +365,9 @@ static int add(int ac, const char **av, const char *prefix)
        const char *branch;
        const char *opt_track = NULL;
        struct option options[] = {
-               OPT__FORCE(&opts.force, N_("checkout <branch> even if already checked out in other worktree")),
+               OPT__FORCE(&opts.force,
+                          N_("checkout <branch> even if already checked out in other worktree"),
+                          0),
                OPT_STRING('b', NULL, &opts.new_branch, N_("branch"),
                           N_("create a new branch")),
                OPT_STRING('B', NULL, &new_branch_force, N_("branch"),
index 05a68390192371ce0de608fbe38c0018be760d8b..3c32401736ac162522dfa1c6f1680a3e385c2fae 100644 (file)
@@ -248,7 +248,7 @@ extern int parse_opt_passthru_argv(const struct option *, const char *, int);
        { OPTION_CALLBACK, 'q', "quiet", (var), NULL, N_("be more quiet"), \
          PARSE_OPT_NOARG, &parse_opt_verbosity_cb, 0 }
 #define OPT__DRY_RUN(var, h)  OPT_BOOL('n', "dry-run", (var), (h))
-#define OPT__FORCE(var, h)    OPT_COUNTUP('f', "force",   (var), (h))
+#define OPT__FORCE(var, h, f) OPT_COUNTUP_F('f', "force",   (var), (h), (f))
 #define OPT__ABBREV(var)  \
        { OPTION_CALLBACK, 0, "abbrev", (var), N_("n"), \
          N_("use <n> digits to display SHA-1s"),       \