From: cornelius.weig@tngtech.com
To: git@vger.kernel.org
Cc: szeder.dev@gmail.com, j6t@kdbg.org,
Cornelius Weig <cornelius.weig@tngtech.com>
Subject: [PATCH v2 1/7] completion: teach submodule subcommands to complete options
Date: Fri, 3 Feb 2017 12:01:53 +0100 [thread overview]
Message-ID: <20170203110159.377-2-cornelius.weig@tngtech.com> (raw)
In-Reply-To: <20170203110159.377-1-cornelius.weig@tngtech.com>
From: Cornelius Weig <cornelius.weig@tngtech.com>
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>
---
contrib/completion/git-completion.bash | 32 ++++++++++++++++++++++++++++++--
1 file changed, 30 insertions(+), 2 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 6721ff8..c54a557 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2556,10 +2556,11 @@ _git_submodule ()
__git_has_doubledash && return
local subcommands="add status init deinit update summary foreach sync"
- if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then
+ local subcommand="$(__git_find_on_cmdline "$subcommands")"
+ if [ -z "$subcommand" ]; then
case "$cur" in
--*)
- __gitcomp "--quiet --cached"
+ __gitcomp "--quiet"
;;
*)
__gitcomp "$subcommands"
@@ -2567,6 +2568,33 @@ _git_submodule ()
esac
return
fi
+
+ case "$subcommand,$cur" in
+ add,--*)
+ __gitcomp "--branch --force --name --reference --depth"
+ ;;
+ status,--*)
+ __gitcomp "--cached --recursive"
+ ;;
+ deinit,--*)
+ __gitcomp "--force --all"
+ ;;
+ update,--*)
+ __gitcomp "
+ --init --remote --no-fetch
+ --recommend-shallow --no-recommend-shallow
+ --force --rebase --merge --reference --depth --recursive --jobs
+ "
+ ;;
+ summary,--*)
+ __gitcomp "--cached --files --summary-limit"
+ ;;
+ foreach,--*|sync,--*)
+ __gitcomp "--recursive"
+ ;;
+ *)
+ ;;
+ esac
}
_git_svn ()
--
2.10.2
next prev parent reply other threads:[~2017-02-03 11:02 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-03 11:01 [PATCH v2 0/7] completion bash: add more options and commands cornelius.weig
2017-02-03 11:01 ` cornelius.weig [this message]
2017-02-03 11:01 ` [PATCH v2 2/7] completion: add subcommand completion for rerere cornelius.weig
2017-02-03 11:01 ` [PATCH v2 3/7] completion: improve bash completion for git-add cornelius.weig
2017-02-03 11:01 ` [PATCH v2 4/7] completion: teach ls-remote to complete options cornelius.weig
2017-02-03 11:01 ` [PATCH v2 5/7] completion: teach replace " cornelius.weig
2017-02-03 11:01 ` [PATCH v2 6/7] completion: teach remote subcommands " cornelius.weig
2017-02-03 11:01 ` [PATCH v2 7/7] completion: recognize more long-options cornelius.weig
2017-02-06 21:29 ` [PATCH v2 0/7] completion bash: add more options and commands Junio C Hamano
2017-02-07 9:00 ` Johannes Sixt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170203110159.377-2-cornelius.weig@tngtech.com \
--to=cornelius.weig@tngtech.com \
--cc=git@vger.kernel.org \
--cc=j6t@kdbg.org \
--cc=szeder.dev@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).