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>
Cornelius Weig committed
Feb 3, 2017 at 12:01 UTC
65d5a1e0a5af4b4bb0878d1e35c0e8dd50d8a0f5
1 file changed
+30
-2
contrib/completion/git-completion.bash
+30
-2
@@ -2556,10 +2556,11 @@ _git_submodule ()
2556
__git_has_doubledash && return
2557
2558
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
2561
case "$cur" in
2562
--*)
2562
- __gitcomp "--quiet --cached"
2563
+ __gitcomp "--quiet"
2564
;;
2565
*)
2566
__gitcomp "$subcommands"
@@ -2567,6 +2568,33 @@ _git_submodule ()
2568
esac
2569
return
2570
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
2598
}
2599
2600
_git_svn ()