{"thread":{"id":"45123","subject":"[PATCH] completion: teach to complete git-subtree","startedAt":"2017-02-13T01:09:02Z","lastAt":"2017-02-13T01:09:02Z","messageCount":1,"participants":["cornelius.weig@tngtech.com"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"311386","messageId":"20170213010722.28518-1-cornelius.weig@tngtech.com","threadId":"45123","inReplyTo":null,"subject":"[PATCH] completion: teach to complete git-subtree","fromName":"","fromEmail":"cornelius.weig@tngtech.com","sentAt":"2017-02-13T01:07:22Z","receivedAt":"2017-02-13T01:09:02Z","isPatch":true,"sender":{"key":"cornelius.weig@tngtech.com","avatar":null},"body":"From: Cornelius Weig <cornelius.weig@tngtech.com>\n\nGit-subtree is a contrib-command without completion, making it\ncumbersome to use.\n\nTeach bash completion to complete the subcommands of subtree (add,\nmerge, pull, push, split) and options thereof. For subcommands\nsupporting it (add, push, pull) also complete remote names and refspec.\n\nSigned-off-by: Cornelius Weig <cornelius.weig@tngtech.com>\n---\n contrib/completion/git-completion.bash | 35 ++++++++++++++++++++++++++++++----\n 1 file changed, 31 insertions(+), 4 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 6c6e1c7..430bfed 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -535,9 +535,9 @@ __git_complete_remote_or_refspec ()\n {\n \tlocal cur_=\"$cur\" cmd=\"${words[1]}\"\n \tlocal i c=2 remote=\"\" pfx=\"\" lhs=1 no_complete_refspec=0\n-\tif [ \"$cmd\" = \"remote\" ]; then\n-\t\t((c++))\n-\tfi\n+\tcase \"$cmd\" in\n+\tremote|subtree) ((c++)) ;;\n+\tesac\n \twhile [ $c -lt $cword ]; do\n \t\ti=\"${words[c]}\"\n \t\tcase \"$i\" in\n@@ -586,7 +586,7 @@ __git_complete_remote_or_refspec ()\n \t\t\t__gitcomp_nl \"$(__git_refs)\" \"$pfx\" \"$cur_\"\n \t\tfi\n \t\t;;\n-\tpull|remote)\n+\tpull|remote|subtree)\n \t\tif [ $lhs = 1 ]; then\n \t\t\t__gitcomp_nl \"$(__git_refs \"$remote\")\" \"$pfx\" \"$cur_\"\n \t\telse\n@@ -2569,6 +2569,33 @@ _git_submodule ()\n \tfi\n }\n \n+_git_subtree ()\n+{\n+\tlocal subcommands=\"add merge pull push split\"\n+\tlocal subcommand=\"$(__git_find_on_cmdline \"$subcommands\")\"\n+\tif [ -z \"$subcommand\" ]; then\n+\t\t__gitcomp \"$subcommands\"\n+\t\treturn\n+\tfi\n+\tcase \"$subcommand,$cur\" in\n+\tadd,--*|merge,--*|pull,--*)\n+\t\t__gitcomp \"--prefix= --squash --message=\"\n+\t\t;;\n+\tpush,--*)\n+\t\t__gitcomp \"--prefix=\"\n+\t\t;;\n+\tsplit,--*)\n+\t\t__gitcomp \"\n+\t\t\t--annotate= --branch= --ignore-joins\n+\t\t\t--onto= --prefix= --rejoin\n+\t\t\t\"\n+\t\t;;\n+\tadd,*|push,*|pull,*)\n+\t\t__git_complete_remote_or_refspec\n+\t\t;;\n+\tesac\n+}\n+\n _git_svn ()\n {\n \tlocal subcommands=\"\n-- \n2.10.2\n\n"}]}