Skip to content

Commit

Permalink
completion: remote set-* <name> and <branch>
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Philip Jägenstedt authored and Junio C Hamano committed Feb 22, 2012
1 parent 514a529 commit f1c6ffe
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions contrib/completion/git-completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,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=$((++c))
fi
while [ $c -lt $cword ]; do
i="${words[c]}"
case "$i" in
Expand Down Expand Up @@ -776,7 +779,7 @@ __git_complete_remote_or_refspec ()
__gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
fi
;;
pull)
pull|remote)
if [ $lhs = 1 ]; then
__gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_"
else
Expand Down Expand Up @@ -2277,17 +2280,20 @@ _git_config ()

_git_remote ()
{
local subcommands="add rename rm show prune update set-head"
local subcommands="add rename rm set-head set-branches set-url show prune update"
local subcommand="$(__git_find_on_cmdline "$subcommands")"
if [ -z "$subcommand" ]; then
__gitcomp "$subcommands"
return
fi

case "$subcommand" in
rename|rm|show|prune)
rename|rm|set-url|show|prune)
__gitcomp_nl "$(__git_remotes)"
;;
set-head|set-branches)
__git_complete_remote_or_refspec
;;
update)
local i c='' IFS=$'\n'
for i in $(git --git-dir="$(__gitdir)" config --get-regexp "remotes\..*" 2>/dev/null); do
Expand Down

0 comments on commit f1c6ffe

Please sign in to comment.