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 <philip@foolip.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Philip Jägenstedt committed Feb 22, 2012 at 09:58 UTC 6e8c755fd3fd2efab0e2dcdc16c8a17a61efa760
1 file changed +10 -12
contrib/completion/git-completion.bash
+10 -12
@@ -137,7 +137,7 @@ __git_ps1_show_upstream ()
137 svn_upstream=${svn_upstream[ ${#svn_upstream[@]} - 2 ]}
138 svn_upstream=${svn_upstream%@*}
139 local n_stop="${#svn_remote[@]}"
140 - for ((n=1; n <= n_stop; ++n)); do
140 + for ((n=1; n <= n_stop; n++)); do
141 svn_upstream=${svn_upstream#${svn_remote[$n]}}
142 done
143
@@ -166,10 +166,8 @@ __git_ps1_show_upstream ()
166 for commit in $commits
167 do
168 case "$commit" in
169 - "<"*) let ++behind
170 - ;;
171 - *) let ++ahead
172 - ;;
169 + "<"*) ((behind++)) ;;
170 + *) ((ahead++)) ;;
171 esac
172 done
173 count="$behind $ahead"
@@ -727,7 +725,7 @@ __git_complete_remote_or_refspec ()
725 local cur_="$cur" cmd="${words[1]}"
726 local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0
727 if [ "$cmd" = "remote" ]; then
730 - c=$((++c))
728 + ((c++))
729 fi
730 while [ $c -lt $cword ]; do
731 i="${words[c]}"
@@ -746,7 +744,7 @@ __git_complete_remote_or_refspec ()
744 -*) ;;
745 *) remote="$i"; break ;;
746 esac
749 - c=$((++c))
747 + ((c++))
748 done
749 if [ -z "$remote" ]; then
750 __gitcomp_nl "$(__git_remotes)"
@@ -986,7 +984,7 @@ __git_find_on_cmdline ()
984 return
985 fi
986 done
989 - c=$((++c))
987 + ((c++))
988 done
989 }
990
@@ -997,7 +995,7 @@ __git_has_doubledash ()
995 if [ "--" = "${words[c]}" ]; then
996 return 0
997 fi
1000 - c=$((++c))
998 + ((c++))
999 done
1000 return 1
1001 }
@@ -1120,7 +1118,7 @@ _git_branch ()
1118 -d|-m) only_local_ref="y" ;;
1119 -r) has_r="y" ;;
1120 esac
1123 - c=$((++c))
1121 + ((c++))
1122 done
1123
1124 case "$cur" in
@@ -2574,7 +2572,7 @@ _git_tag ()
2572 f=1
2573 ;;
2574 esac
2577 - c=$((++c))
2575 + ((c++))
2576 done
2577
2578 case "$prev" in
@@ -2627,7 +2625,7 @@ _git ()
2625 --help) command="help"; break ;;
2626 *) command="$i"; break ;;
2627 esac
2630 - c=$((++c))
2628 + ((c++))
2629 done
2630
2631 if [ -z "$command" ]; then