Skip to content

Commit 1224781

Browse files
pcloudsgitster
authored andcommitted
parse-options: let OPT__FORCE take optional flags argument
--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>
1 parent 2de3734 commit 1224781

File tree

14 files changed

+17
-15
lines changed

14 files changed

+17
-15
lines changed

builtin/add.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ static struct option builtin_add_options[] = {
294294
OPT_BOOL('i', "interactive", &add_interactive, N_("interactive picking")),
295295
OPT_BOOL('p', "patch", &patch_interactive, N_("select hunks interactively")),
296296
OPT_BOOL('e', "edit", &edit_interactive, N_("edit current diff and apply")),
297-
OPT__FORCE(&ignored_too, N_("allow adding otherwise ignored files")),
297+
OPT__FORCE(&ignored_too, N_("allow adding otherwise ignored files"), 0),
298298
OPT_BOOL('u', "update", &take_worktree_changes, N_("update tracked files")),
299299
OPT_BOOL(0, "renormalize", &add_renormalize, N_("renormalize EOL of tracked files (implies -u)")),
300300
OPT_BOOL('N', "intent-to-add", &intent_to_add, N_("record only the fact that the path will be added later")),

builtin/branch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
615615
OPT_BOOL('l', "create-reflog", &reflog, N_("create the branch's reflog")),
616616
OPT_BOOL(0, "edit-description", &edit_description,
617617
N_("edit the description for the branch")),
618-
OPT__FORCE(&force, N_("force creation, move/rename, deletion")),
618+
OPT__FORCE(&force, N_("force creation, move/rename, deletion"), 0),
619619
OPT_MERGED(&filter, N_("print only branches that are merged")),
620620
OPT_NO_MERGED(&filter, N_("print only branches that are not merged")),
621621
OPT_COLUMN(0, "column", &colopts, N_("list branches in columns")),

builtin/checkout-index.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix)
157157
struct option builtin_checkout_index_options[] = {
158158
OPT_BOOL('a', "all", &all,
159159
N_("check out all files in the index")),
160-
OPT__FORCE(&force, N_("force overwrite of existing files")),
160+
OPT__FORCE(&force, N_("force overwrite of existing files"), 0),
161161
OPT__QUIET(&quiet,
162162
N_("no warning for existing files and files not in index")),
163163
OPT_BOOL('n', "no-create", &not_new,

builtin/checkout.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
11181118
2),
11191119
OPT_SET_INT('3', "theirs", &opts.writeout_stage, N_("checkout their version for unmerged files"),
11201120
3),
1121-
OPT__FORCE(&opts.force, N_("force checkout (throw away local modifications)")),
1121+
OPT__FORCE(&opts.force, N_("force checkout (throw away local modifications)"), 0),
11221122
OPT_BOOL('m', "merge", &opts.merge, N_("perform a 3-way merge with the new branch")),
11231123
OPT_BOOL(0, "overwrite-ignore", &opts.overwrite_ignore, N_("update ignored files (default)")),
11241124
OPT_STRING(0, "conflict", &conflict_style, N_("style"),

builtin/clean.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
909909
struct option options[] = {
910910
OPT__QUIET(&quiet, N_("do not print names of files removed")),
911911
OPT__DRY_RUN(&dry_run, N_("dry run")),
912-
OPT__FORCE(&force, N_("force")),
912+
OPT__FORCE(&force, N_("force"), 0),
913913
OPT_BOOL('i', "interactive", &interactive, N_("interactive cleaning")),
914914
OPT_BOOL('d', NULL, &remove_directories,
915915
N_("remove whole directories")),

builtin/fetch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ static struct option builtin_fetch_options[] = {
115115
N_("append to .git/FETCH_HEAD instead of overwriting")),
116116
OPT_STRING(0, "upload-pack", &upload_pack, N_("path"),
117117
N_("path to upload pack on remote end")),
118-
OPT__FORCE(&force, N_("force overwrite of local branch")),
118+
OPT__FORCE(&force, N_("force overwrite of local branch"), 0),
119119
OPT_BOOL('m', "multiple", &multiple,
120120
N_("fetch from multiple remotes")),
121121
OPT_SET_INT('t', "tags", &tags,

builtin/mv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
122122
struct option builtin_mv_options[] = {
123123
OPT__VERBOSE(&verbose, N_("be verbose")),
124124
OPT__DRY_RUN(&show_only, N_("dry run")),
125-
OPT__FORCE(&force, N_("force move/rename even if target exists")),
125+
OPT__FORCE(&force, N_("force move/rename even if target exists"), 0),
126126
OPT_BOOL('k', NULL, &ignore_errors, N_("skip move/rename errors")),
127127
OPT_END(),
128128
};

builtin/notes.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ static int add(int argc, const char **argv, const char *prefix)
413413
parse_reuse_arg},
414414
OPT_BOOL(0, "allow-empty", &allow_empty,
415415
N_("allow storing empty note")),
416-
OPT__FORCE(&force, N_("replace existing notes")),
416+
OPT__FORCE(&force, N_("replace existing notes"), 0),
417417
OPT_END()
418418
};
419419

@@ -484,7 +484,7 @@ static int copy(int argc, const char **argv, const char *prefix)
484484
struct notes_tree *t;
485485
const char *rewrite_cmd = NULL;
486486
struct option options[] = {
487-
OPT__FORCE(&force, N_("replace existing notes")),
487+
OPT__FORCE(&force, N_("replace existing notes"), 0),
488488
OPT_BOOL(0, "stdin", &from_stdin, N_("read objects from stdin")),
489489
OPT_STRING(0, "for-rewrite", &rewrite_cmd, N_("command"),
490490
N_("load rewriting config for <command> (implies "

builtin/pull.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ static struct option pull_options[] = {
193193
OPT_PASSTHRU(0, "upload-pack", &opt_upload_pack, N_("path"),
194194
N_("path to upload pack on remote end"),
195195
0),
196-
OPT__FORCE(&opt_force, N_("force overwrite of local branch")),
196+
OPT__FORCE(&opt_force, N_("force overwrite of local branch"), 0),
197197
OPT_PASSTHRU('t', "tags", &opt_tags, NULL,
198198
N_("fetch all tags and associated objects"),
199199
PARSE_OPT_NOARG),

builtin/rm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ static struct option builtin_rm_options[] = {
242242
OPT__DRY_RUN(&show_only, N_("dry run")),
243243
OPT__QUIET(&quiet, N_("do not list removed files")),
244244
OPT_BOOL( 0 , "cached", &index_only, N_("only remove from the index")),
245-
OPT__FORCE(&force, N_("override the up-to-date check")),
245+
OPT__FORCE(&force, N_("override the up-to-date check"), 0),
246246
OPT_BOOL('r', NULL, &recursive, N_("allow recursive removal")),
247247
OPT_BOOL( 0 , "ignore-unmatch", &ignore_unmatch,
248248
N_("exit with a zero status even if nothing matched")),

0 commit comments

Comments
 (0)