Skip to content

Commit 472fdee

Browse files
committed
Merge branch 'pj/completion-remote-set-url-branches'
* pj/completion-remote-set-url-branches: completion: normalize increment/decrement style completion: remote set-* <name> and <branch>
2 parents 4d50dbc + 6e8c755 commit 472fdee

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

contrib/completion/git-completion.bash

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ __git_ps1_show_upstream ()
137137
svn_upstream=${svn_upstream[ ${#svn_upstream[@]} - 2 ]}
138138
svn_upstream=${svn_upstream%@*}
139139
local n_stop="${#svn_remote[@]}"
140-
for ((n=1; n <= n_stop; ++n)); do
140+
for ((n=1; n <= n_stop; n++)); do
141141
svn_upstream=${svn_upstream#${svn_remote[$n]}}
142142
done
143143

@@ -166,10 +166,8 @@ __git_ps1_show_upstream ()
166166
for commit in $commits
167167
do
168168
case "$commit" in
169-
"<"*) let ++behind
170-
;;
171-
*) let ++ahead
172-
;;
169+
"<"*) ((behind++)) ;;
170+
*) ((ahead++)) ;;
173171
esac
174172
done
175173
count="$behind $ahead"
@@ -726,6 +724,9 @@ __git_complete_remote_or_refspec ()
726724
{
727725
local cur_="$cur" cmd="${words[1]}"
728726
local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0
727+
if [ "$cmd" = "remote" ]; then
728+
((c++))
729+
fi
729730
while [ $c -lt $cword ]; do
730731
i="${words[c]}"
731732
case "$i" in
@@ -743,7 +744,7 @@ __git_complete_remote_or_refspec ()
743744
-*) ;;
744745
*) remote="$i"; break ;;
745746
esac
746-
c=$((++c))
747+
((c++))
747748
done
748749
if [ -z "$remote" ]; then
749750
__gitcomp_nl "$(__git_remotes)"
@@ -776,7 +777,7 @@ __git_complete_remote_or_refspec ()
776777
__gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
777778
fi
778779
;;
779-
pull)
780+
pull|remote)
780781
if [ $lhs = 1 ]; then
781782
__gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_"
782783
else
@@ -983,7 +984,7 @@ __git_find_on_cmdline ()
983984
return
984985
fi
985986
done
986-
c=$((++c))
987+
((c++))
987988
done
988989
}
989990

@@ -994,7 +995,7 @@ __git_has_doubledash ()
994995
if [ "--" = "${words[c]}" ]; then
995996
return 0
996997
fi
997-
c=$((++c))
998+
((c++))
998999
done
9991000
return 1
10001001
}
@@ -1117,7 +1118,7 @@ _git_branch ()
11171118
-d|-m) only_local_ref="y" ;;
11181119
-r) has_r="y" ;;
11191120
esac
1120-
c=$((++c))
1121+
((c++))
11211122
done
11221123

11231124
case "$cur" in
@@ -2277,17 +2278,20 @@ _git_config ()
22772278

22782279
_git_remote ()
22792280
{
2280-
local subcommands="add rename rm show prune update set-head"
2281+
local subcommands="add rename rm set-head set-branches set-url show prune update"
22812282
local subcommand="$(__git_find_on_cmdline "$subcommands")"
22822283
if [ -z "$subcommand" ]; then
22832284
__gitcomp "$subcommands"
22842285
return
22852286
fi
22862287

22872288
case "$subcommand" in
2288-
rename|rm|show|prune)
2289+
rename|rm|set-url|show|prune)
22892290
__gitcomp_nl "$(__git_remotes)"
22902291
;;
2292+
set-head|set-branches)
2293+
__git_complete_remote_or_refspec
2294+
;;
22912295
update)
22922296
local i c='' IFS=$'\n'
22932297
for i in $(git --git-dir="$(__gitdir)" config --get-regexp "remotes\..*" 2>/dev/null); do
@@ -2568,7 +2572,7 @@ _git_tag ()
25682572
f=1
25692573
;;
25702574
esac
2571-
c=$((++c))
2575+
((c++))
25722576
done
25732577

25742578
case "$prev" in
@@ -2621,7 +2625,7 @@ _git ()
26212625
--help) command="help"; break ;;
26222626
*) command="$i"; break ;;
26232627
esac
2624-
c=$((++c))
2628+
((c++))
26252629
done
26262630

26272631
if [ -z "$command" ]; then

0 commit comments

Comments
 (0)