* [PATCH] completion: teach to complete git-subtree
@ 2017-02-13 1:07 cornelius.weig
0 siblings, 0 replies; only message in thread
From: cornelius.weig @ 2017-02-13 1:07 UTC (permalink / raw)
To: git
Cc: bitte.keine.werbung.einwerfen, Cornelius Weig, szeder.dev, s6t,
greened, davvid
From: Cornelius Weig <cornelius.weig@tngtech.com>
Git-subtree is a contrib-command without completion, making it
cumbersome to use.
Teach bash completion to complete the subcommands of subtree (add,
merge, pull, push, split) and options thereof. For subcommands
supporting it (add, push, pull) also complete remote names and refspec.
Signed-off-by: Cornelius Weig <cornelius.weig@tngtech.com>
---
contrib/completion/git-completion.bash | 35 ++++++++++++++++++++++++++++++----
1 file changed, 31 insertions(+), 4 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 6c6e1c7..430bfed 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -535,9 +535,9 @@ __git_complete_remote_or_refspec ()
{
local cur_="$cur" cmd="${words[1]}"
local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0
- if [ "$cmd" = "remote" ]; then
- ((c++))
- fi
+ case "$cmd" in
+ remote|subtree) ((c++)) ;;
+ esac
while [ $c -lt $cword ]; do
i="${words[c]}"
case "$i" in
@@ -586,7 +586,7 @@ __git_complete_remote_or_refspec ()
__gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
fi
;;
- pull|remote)
+ pull|remote|subtree)
if [ $lhs = 1 ]; then
__gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_"
else
@@ -2569,6 +2569,33 @@ _git_submodule ()
fi
}
+_git_subtree ()
+{
+ local subcommands="add merge pull push split"
+ local subcommand="$(__git_find_on_cmdline "$subcommands")"
+ if [ -z "$subcommand" ]; then
+ __gitcomp "$subcommands"
+ return
+ fi
+ case "$subcommand,$cur" in
+ add,--*|merge,--*|pull,--*)
+ __gitcomp "--prefix= --squash --message="
+ ;;
+ push,--*)
+ __gitcomp "--prefix="
+ ;;
+ split,--*)
+ __gitcomp "
+ --annotate= --branch= --ignore-joins
+ --onto= --prefix= --rejoin
+ "
+ ;;
+ add,*|push,*|pull,*)
+ __git_complete_remote_or_refspec
+ ;;
+ esac
+}
+
_git_svn ()
{
local subcommands="
--
2.10.2
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2017-02-13 1:09 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-13 1:07 [PATCH] completion: teach to complete git-subtree cornelius.weig
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).