Skip to content

Commit 65d5a1e

Browse files
Cornelius Weiggitster
authored andcommitted
completion: teach submodule subcommands to complete options
Each submodule subcommand has specific long-options. Therefore, teach bash completion to support option completion based on the current subcommand. All long-options that are mentioned in the man-page synopsis are added. Signed-off-by: Cornelius Weig <cornelius.weig@tngtech.com> Reviewed-by: SZEDER Gábor <szeder.dev@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 6e3a7b3 commit 65d5a1e

1 file changed

Lines changed: 30 additions & 2 deletions

File tree

contrib/completion/git-completion.bash

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2556,17 +2556,45 @@ _git_submodule ()
25562556
__git_has_doubledash && return
25572557

25582558
local subcommands="add status init deinit update summary foreach sync"
2559-
if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then
2559+
local subcommand="$(__git_find_on_cmdline "$subcommands")"
2560+
if [ -z "$subcommand" ]; then
25602561
case "$cur" in
25612562
--*)
2562-
__gitcomp "--quiet --cached"
2563+
__gitcomp "--quiet"
25632564
;;
25642565
*)
25652566
__gitcomp "$subcommands"
25662567
;;
25672568
esac
25682569
return
25692570
fi
2571+
2572+
case "$subcommand,$cur" in
2573+
add,--*)
2574+
__gitcomp "--branch --force --name --reference --depth"
2575+
;;
2576+
status,--*)
2577+
__gitcomp "--cached --recursive"
2578+
;;
2579+
deinit,--*)
2580+
__gitcomp "--force --all"
2581+
;;
2582+
update,--*)
2583+
__gitcomp "
2584+
--init --remote --no-fetch
2585+
--recommend-shallow --no-recommend-shallow
2586+
--force --rebase --merge --reference --depth --recursive --jobs
2587+
"
2588+
;;
2589+
summary,--*)
2590+
__gitcomp "--cached --files --summary-limit"
2591+
;;
2592+
foreach,--*|sync,--*)
2593+
__gitcomp "--recursive"
2594+
;;
2595+
*)
2596+
;;
2597+
esac
25702598
}
25712599

25722600
_git_svn ()

0 commit comments

Comments
 (0)