From 1224781d6080b8b69a81526ee23b22a1587920ea Mon Sep 17 00:00:00 2001 From: Nguyễn Thái Ngọc Duy Date: Fri, 9 Feb 2018 18:01:42 +0700 Subject: parse-options: let OPT__FORCE take optional flags argument MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --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 Signed-off-by: Junio C Hamano --- builtin/worktree.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'builtin/worktree.c') diff --git a/builtin/worktree.c b/builtin/worktree.c index 7cef5b120b..4d3422f62e 100644 --- a/builtin/worktree.c +++ b/builtin/worktree.c @@ -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 even if already checked out in other worktree")), + OPT__FORCE(&opts.force, + N_("checkout 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"), -- cgit 1.2.3-korg From fc3d4e0cbe65639509c765726fe01a16575e9ae8 Mon Sep 17 00:00:00 2001 From: Nguyễn Thái Ngọc Duy Date: Fri, 9 Feb 2018 18:02:20 +0700 Subject: completion: use __gitcomp_builtin in _git_worktree MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The new completable options for "worktree add" are: --checkout --guess-remote --lock --track Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- builtin/worktree.c | 2 +- contrib/completion/git-completion.bash | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'builtin/worktree.c') diff --git a/builtin/worktree.c b/builtin/worktree.c index 4d3422f62e..76dc6b8cb5 100644 --- a/builtin/worktree.c +++ b/builtin/worktree.c @@ -367,7 +367,7 @@ static int add(int ac, const char **av, const char *prefix) struct option options[] = { OPT__FORCE(&opts.force, N_("checkout even if already checked out in other worktree"), - 0), + PARSE_OPT_NOCOMPLETE), OPT_STRING('b', NULL, &opts.new_branch, N_("branch"), N_("create a new branch")), OPT_STRING('B', NULL, &new_branch_force, N_("branch"), diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index e76b2f0356..0ddf40063b 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -3021,16 +3021,16 @@ _git_worktree () else case "$subcommand,$cur" in add,--*) - __gitcomp "--detach" + __gitcomp_builtin worktree_add ;; list,--*) - __gitcomp "--porcelain" + __gitcomp_builtin worktree_list ;; lock,--*) - __gitcomp "--reason" + __gitcomp_builtin worktree_lock ;; prune,--*) - __gitcomp "--dry-run --expire --verbose" + __gitcomp_builtin worktree_prune ;; *) ;; -- cgit 1.2.3-korg