completion: remote set-* <name> and <branch>

Complete <name> only for set-url. For set-branches and set-head, complete <name> and <branch> over the network, like e.g. git pull already does. Signed-off-by: Philip Jägenstedt <philip@foolip.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Philip Jägenstedt committed Feb 22, 2012 at 09:58 UTC f1c6ffe684464e7f8765030b226be108cb9c2d53
1 file changed +9 -3
contrib/completion/git-completion.bash
+9 -3
@@ -726,6 +726,9 @@ __git_complete_remote_or_refspec ()
726 {
727 local cur_="$cur" cmd="${words[1]}"
728 local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0
729 + if [ "$cmd" = "remote" ]; then
730 + c=$((++c))
731 + fi
732 while [ $c -lt $cword ]; do
733 i="${words[c]}"
734 case "$i" in
@@ -776,7 +779,7 @@ __git_complete_remote_or_refspec ()
779 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
780 fi
781 ;;
779 - pull)
782 + pull|remote)
783 if [ $lhs = 1 ]; then
784 __gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_"
785 else
@@ -2277,7 +2280,7 @@ _git_config ()
2280
2281 _git_remote ()
2282 {
2280 - local subcommands="add rename rm show prune update set-head"
2283 + local subcommands="add rename rm set-head set-branches set-url show prune update"
2284 local subcommand="$(__git_find_on_cmdline "$subcommands")"
2285 if [ -z "$subcommand" ]; then
2286 __gitcomp "$subcommands"
@@ -2285,9 +2288,12 @@ _git_remote ()
2288 fi
2289
2290 case "$subcommand" in
2288 - rename|rm|show|prune)
2291 + rename|rm|set-url|show|prune)
2292 __gitcomp_nl "$(__git_remotes)"
2293 ;;
2294 + set-head|set-branches)
2295 + __git_complete_remote_or_refspec
2296 + ;;
2297 update)
2298 local i c='' IFS=$'\n'
2299 for i in $(git --git-dir="$(__gitdir)" config --get-regexp "remotes\..*" 2>/dev/null); do