Skip to content

Commit 6e8c755

Browse files
foolipgitster
authored andcommitted
completion: normalize increment/decrement style
The style used for incrementing and decrementing variables was fairly inconsistenty and was normalized to use x++, or ((x++)) in contexts where the former would otherwise be interpreted as a command. This is a bash-ism, but for obvious reasons this script is already bash-specific. Signed-off-by: Philip Jägenstedt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f1c6ffe commit 6e8c755

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

contrib/completion/git-completion.bash

Lines changed: 10 additions & 12 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"
@@ -727,7 +725,7 @@ __git_complete_remote_or_refspec ()
727725
local cur_="$cur" cmd="${words[1]}"
728726
local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0
729727
if [ "$cmd" = "remote" ]; then
730-
c=$((++c))
728+
((c++))
731729
fi
732730
while [ $c -lt $cword ]; do
733731
i="${words[c]}"
@@ -746,7 +744,7 @@ __git_complete_remote_or_refspec ()
746744
-*) ;;
747745
*) remote="$i"; break ;;
748746
esac
749-
c=$((++c))
747+
((c++))
750748
done
751749
if [ -z "$remote" ]; then
752750
__gitcomp_nl "$(__git_remotes)"
@@ -986,7 +984,7 @@ __git_find_on_cmdline ()
986984
return
987985
fi
988986
done
989-
c=$((++c))
987+
((c++))
990988
done
991989
}
992990

@@ -997,7 +995,7 @@ __git_has_doubledash ()
997995
if [ "--" = "${words[c]}" ]; then
998996
return 0
999997
fi
1000-
c=$((++c))
998+
((c++))
1001999
done
10021000
return 1
10031001
}
@@ -1120,7 +1118,7 @@ _git_branch ()
11201118
-d|-m) only_local_ref="y" ;;
11211119
-r) has_r="y" ;;
11221120
esac
1123-
c=$((++c))
1121+
((c++))
11241122
done
11251123

11261124
case "$cur" in
@@ -2574,7 +2572,7 @@ _git_tag ()
25742572
f=1
25752573
;;
25762574
esac
2577-
c=$((++c))
2575+
((c++))
25782576
done
25792577

25802578
case "$prev" in
@@ -2627,7 +2625,7 @@ _git ()
26272625
--help) command="help"; break ;;
26282626
*) command="$i"; break ;;
26292627
esac
2630-
c=$((++c))
2628+
((c++))
26312629
done
26322630

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

0 commit comments

Comments
 (0)