Skip to content

Commit 7fb6aef

Browse files
committed
Merge branch 'nd/parseopt-completion'
Teach parse-options API an option to help the completion script, and make use of the mechanism in command line completion. * nd/parseopt-completion: (45 commits) completion: more subcommands in _git_notes() completion: complete --{reuse,reedit}-message= for all notes subcmds completion: simplify _git_notes completion: don't set PARSE_OPT_NOCOMPLETE on --rerere-autoupdate completion: use __gitcomp_builtin in _git_worktree completion: use __gitcomp_builtin in _git_tag completion: use __gitcomp_builtin in _git_status completion: use __gitcomp_builtin in _git_show_branch completion: use __gitcomp_builtin in _git_rm completion: use __gitcomp_builtin in _git_revert completion: use __gitcomp_builtin in _git_reset completion: use __gitcomp_builtin in _git_replace remote: force completing --mirror= instead of --mirror completion: use __gitcomp_builtin in _git_remote completion: use __gitcomp_builtin in _git_push completion: use __gitcomp_builtin in _git_pull completion: use __gitcomp_builtin in _git_notes completion: use __gitcomp_builtin in _git_name_rev completion: use __gitcomp_builtin in _git_mv completion: use __gitcomp_builtin in _git_merge_base ...
2 parents 99321e3 + 27b42d0 commit 7fb6aef

25 files changed

+231
-238
lines changed

apply.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4943,8 +4943,9 @@ int apply_parse_options(int argc, const char **argv,
49434943
N_("make sure the patch is applicable to the current index")),
49444944
OPT_BOOL(0, "cached", &state->cached,
49454945
N_("apply a patch without touching the working tree")),
4946-
OPT_BOOL(0, "unsafe-paths", &state->unsafe_paths,
4947-
N_("accept a patch that touches outside the working area")),
4946+
OPT_BOOL_F(0, "unsafe-paths", &state->unsafe_paths,
4947+
N_("accept a patch that touches outside the working area"),
4948+
PARSE_OPT_NOCOMPLETE),
49484949
OPT_BOOL(0, "apply", force_apply,
49494950
N_("also apply the patch (use with --stat/--summary/--check)")),
49504951
OPT_BOOL('3', "3way", &state->threeway,

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"), PARSE_OPT_NOCOMPLETE),
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: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,9 +1117,12 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
11171117
2),
11181118
OPT_SET_INT('3', "theirs", &opts.writeout_stage, N_("checkout their version for unmerged files"),
11191119
3),
1120-
OPT__FORCE(&opts.force, N_("force checkout (throw away local modifications)")),
1120+
OPT__FORCE(&opts.force, N_("force checkout (throw away local modifications)"),
1121+
PARSE_OPT_NOCOMPLETE),
11211122
OPT_BOOL('m', "merge", &opts.merge, N_("perform a 3-way merge with the new branch")),
1122-
OPT_BOOL(0, "overwrite-ignore", &opts.overwrite_ignore, N_("update ignored files (default)")),
1123+
OPT_BOOL_F(0, "overwrite-ignore", &opts.overwrite_ignore,
1124+
N_("update ignored files (default)"),
1125+
PARSE_OPT_NOCOMPLETE),
11231126
OPT_STRING(0, "conflict", &conflict_style, N_("style"),
11241127
N_("conflict style (merge or diff3)")),
11251128
OPT_BOOL('p', "patch", &opts.patch_mode, N_("select hunks interactively")),

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"), PARSE_OPT_NOCOMPLETE),
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
@@ -126,7 +126,7 @@ static struct option builtin_fetch_options[] = {
126126
N_("append to .git/FETCH_HEAD instead of overwriting")),
127127
OPT_STRING(0, "upload-pack", &upload_pack, N_("path"),
128128
N_("path to upload pack on remote end")),
129-
OPT__FORCE(&force, N_("force overwrite of local branch")),
129+
OPT__FORCE(&force, N_("force overwrite of local branch"), 0),
130130
OPT_BOOL('m', "multiple", &multiple,
131131
N_("fetch from multiple remotes")),
132132
OPT_SET_INT('t', "tags", &tags,

builtin/gc.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,11 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
360360
N_("prune unreferenced objects"),
361361
PARSE_OPT_OPTARG, NULL, (intptr_t)prune_expire },
362362
OPT_BOOL(0, "aggressive", &aggressive, N_("be more thorough (increased runtime)")),
363-
OPT_BOOL(0, "auto", &auto_gc, N_("enable auto-gc mode")),
364-
OPT_BOOL(0, "force", &force, N_("force running gc even if there may be another gc running")),
363+
OPT_BOOL_F(0, "auto", &auto_gc, N_("enable auto-gc mode"),
364+
PARSE_OPT_NOCOMPLETE),
365+
OPT_BOOL_F(0, "force", &force,
366+
N_("force running gc even if there may be another gc running"),
367+
PARSE_OPT_NOCOMPLETE),
365368
OPT_END()
366369
};
367370

builtin/grep.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -839,8 +839,9 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
839839
OPT_BOOL('L', "files-without-match",
840840
&opt.unmatch_name_only,
841841
N_("show only the names of files without match")),
842-
OPT_BOOL('z', "null", &opt.null_following_name,
843-
N_("print NUL after filenames")),
842+
OPT_BOOL_F('z', "null", &opt.null_following_name,
843+
N_("print NUL after filenames"),
844+
PARSE_OPT_NOCOMPLETE),
844845
OPT_BOOL('c', "count", &opt.count,
845846
N_("show the number of matches instead of matching lines")),
846847
OPT__COLOR(&opt.color, N_("highlight matches")),
@@ -891,9 +892,11 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
891892
OPT_GROUP(""),
892893
{ OPTION_STRING, 'O', "open-files-in-pager", &show_in_pager,
893894
N_("pager"), N_("show matching files in the pager"),
894-
PARSE_OPT_OPTARG, NULL, (intptr_t)default_pager },
895-
OPT_BOOL(0, "ext-grep", &external_grep_allowed__ignored,
896-
N_("allow calling of grep(1) (ignored by this build)")),
895+
PARSE_OPT_OPTARG | PARSE_OPT_NOCOMPLETE,
896+
NULL, (intptr_t)default_pager },
897+
OPT_BOOL_F(0, "ext-grep", &external_grep_allowed__ignored,
898+
N_("allow calling of grep(1) (ignored by this build)"),
899+
PARSE_OPT_NOCOMPLETE),
897900
OPT_END()
898901
};
899902

builtin/ls-remote.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
6060
OPT_BIT(0, "refs", &flags, N_("do not show peeled tags"), REF_NORMAL),
6161
OPT_BOOL(0, "get-url", &get_url,
6262
N_("take url.<base>.insteadOf into account")),
63-
OPT_SET_INT(0, "exit-code", &status,
64-
N_("exit with exit code 2 if no matching refs are found"), 2),
63+
OPT_SET_INT_F(0, "exit-code", &status,
64+
N_("exit with exit code 2 if no matching refs are found"),
65+
2, PARSE_OPT_NOCOMPLETE),
6566
OPT_BOOL(0, "symref", &show_symref_target,
6667
N_("show underlying ref in addition to the object pointed by it")),
6768
OPT_END()

builtin/mv.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ 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"),
126+
PARSE_OPT_NOCOMPLETE),
126127
OPT_BOOL('k', NULL, &ignore_errors, N_("skip move/rename errors")),
127128
OPT_END(),
128129
};

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"), PARSE_OPT_NOCOMPLETE),
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"), PARSE_OPT_NOCOMPLETE),
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/push.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
548548
{ OPTION_CALLBACK, 0, "recurse-submodules", &recurse_submodules, "check|on-demand|no",
549549
N_("control recursive pushing of submodules"),
550550
PARSE_OPT_OPTARG, option_parse_recurse_submodules },
551-
OPT_BOOL( 0 , "thin", &thin, N_("use thin pack")),
551+
OPT_BOOL_F( 0 , "thin", &thin, N_("use thin pack"), PARSE_OPT_NOCOMPLETE),
552552
OPT_STRING( 0 , "receive-pack", &receivepack, "receive-pack", N_("receive pack program")),
553553
OPT_STRING( 0 , "exec", &receivepack, "receive-pack", N_("receive pack program")),
554554
OPT_BIT('u', "set-upstream", &flags, N_("set upstream for git pull/status"),

builtin/remote.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ static int add(int argc, const char **argv)
168168
OPT_STRING('m', "master", &master, N_("branch"), N_("master branch")),
169169
{ OPTION_CALLBACK, 0, "mirror", &mirror, N_("push|fetch"),
170170
N_("set up remote as a mirror to push to or fetch from"),
171-
PARSE_OPT_OPTARG, parse_mirror_opt },
171+
PARSE_OPT_OPTARG | PARSE_OPT_COMP_ARG, parse_mirror_opt },
172172
OPT_END()
173173
};
174174

builtin/replace.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,8 @@ int cmd_replace(int argc, const char **argv, const char *prefix)
439439
OPT_CMDMODE('d', "delete", &cmdmode, N_("delete replace refs"), MODE_DELETE),
440440
OPT_CMDMODE('e', "edit", &cmdmode, N_("edit existing object"), MODE_EDIT),
441441
OPT_CMDMODE('g', "graft", &cmdmode, N_("change a commit's parents"), MODE_GRAFT),
442-
OPT_BOOL('f', "force", &force, N_("replace the ref if it exists")),
442+
OPT_BOOL_F('f', "force", &force, N_("replace the ref if it exists"),
443+
PARSE_OPT_NOCOMPLETE),
443444
OPT_BOOL(0, "raw", &raw, N_("do not pretty-print contents for --edit")),
444445
OPT_STRING(0, "format", &format, N_("format"), N_("use this format")),
445446
OPT_END()

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"), PARSE_OPT_NOCOMPLETE),
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")),

builtin/submodule--helper.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,7 @@ static int module_deinit(int argc, const char **argv, const char *prefix)
10191019

10201020
struct option module_deinit_options[] = {
10211021
OPT__QUIET(&quiet, N_("Suppress submodule status output")),
1022-
OPT__FORCE(&force, N_("Remove submodule working trees even if they contain local changes")),
1022+
OPT__FORCE(&force, N_("Remove submodule working trees even if they contain local changes"), 0),
10231023
OPT_BOOL(0, "all", &all, N_("Unregister all submodules")),
10241024
OPT_END()
10251025
};

builtin/tag.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
397397
N_("how to strip spaces and #comments from message")),
398398
OPT_STRING('u', "local-user", &keyid, N_("key-id"),
399399
N_("use another key to sign the tag")),
400-
OPT__FORCE(&force, N_("replace the tag if exists")),
400+
OPT__FORCE(&force, N_("replace the tag if exists"), 0),
401401
OPT_BOOL(0, "create-reflog", &create_reflog, N_("create a reflog")),
402402

403403
OPT_GROUP(N_("Tag listing options")),

builtin/update-server-info.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ int cmd_update_server_info(int argc, const char **argv, const char *prefix)
1212
{
1313
int force = 0;
1414
struct option options[] = {
15-
OPT__FORCE(&force, N_("update the info files from scratch")),
15+
OPT__FORCE(&force, N_("update the info files from scratch"), 0),
1616
OPT_END()
1717
};
1818

builtin/worktree.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,9 @@ static int add(int ac, const char **av, const char *prefix)
381381
const char *branch;
382382
const char *opt_track = NULL;
383383
struct option options[] = {
384-
OPT__FORCE(&opts.force, N_("checkout <branch> even if already checked out in other worktree")),
384+
OPT__FORCE(&opts.force,
385+
N_("checkout <branch> even if already checked out in other worktree"),
386+
PARSE_OPT_NOCOMPLETE),
385387
OPT_STRING('b', NULL, &opts.new_branch, N_("branch"),
386388
N_("create a new branch")),
387389
OPT_STRING('B', NULL, &new_branch_force, N_("branch"),

0 commit comments

Comments
 (0)