126
case "$key" in
127
bash.showupstream)
128
GIT_PS1_SHOWUPSTREAM="$value"
129
- if [[ -z "${GIT_PS1_SHOWUPSTREAM}" ]]; then
129
+ if [ -z "${GIT_PS1_SHOWUPSTREAM}" ]; then
130
p=""
131
return
132
fi
187
upstream_type=${svn_upstream#/}
188
;;
189
esac
190
- elif [[ "svn+git" = "$upstream_type" ]]; then
190
+ elif [ "svn+git" = "$upstream_type" ]; then
191
upstream_type="@{upstream}"
192
fi
193
;;
194
esac
195
196
# Find how many commits we are ahead/behind our upstream
197
- if [[ -z "$legacy" ]]; then
197
+ if [ -z "$legacy" ]; then
198
count="$(git rev-list --count --left-right \
199
"$upstream_type"...HEAD 2>/dev/null)"
200
else
206
for commit in $commits
207
do
208
case "$commit" in
209
- "<"*) ((behind++)) ;;
210
- *) ((ahead++)) ;;
209
+ "<"*) behind=$((behind+1)) ;;
210
+ *) ahead=$((ahead+1)) ;;
211
esac
212
done
213
count="$behind $ahead"
217
fi
218
219
# calculate the result
220
- if [[ -z "$verbose" ]]; then
220
+ if [ -z "$verbose" ]; then
221
case "$count" in
222
"") # no upstream
223
p="" ;;
243
*) # diverged from upstream
244
upstream="|u+${count#* }-${count% *}" ;;
245
esac
246
- if [[ -n "$count" && -n "$name" ]]; then
246
+ if [ -n "$count" ] && [ -n "$name" ]; then
247
__git_ps1_upstream_name=$(git rev-parse \
248
--abbrev-ref "$upstream_type" 2>/dev/null)
249
if [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then
265
# their own color.
266
__git_ps1_colorize_gitstring ()
267
{
268
- if [[ -n ${ZSH_VERSION-} ]]; then
268
+ if [ -n "${ZSH_VERSION-}" ]; then
269
local c_red='%F{red}'
270
local c_green='%F{green}'
271
local c_lblue='%F{blue}'
417
# incorrect.)
418
#
419
local ps1_expanded=yes
420
- [ -z "${ZSH_VERSION-}" ] || [[ -o PROMPT_SUBST ]] || ps1_expanded=no
420
+ [ -z "${ZSH_VERSION-}" ] || eval '[[ -o PROMPT_SUBST ]]' || ps1_expanded=no
421
[ -z "${BASH_VERSION-}" ] || shopt -q promptvars || ps1_expanded=no
422
423
local repo_info rev_parse_exit_code
502
return $exit
503
fi
504
505
- if [[ $head == "ref: "* ]]; then
505
+ case $head in
506
+ "ref: "*)
507
head="${head#ref: }"
507
- else
508
+ ;;
509
+ *)
510
head=""
509
- fi
511
+ esac
512
;;
513
*)
514
head="$(git symbolic-ref HEAD 2>/dev/null)"
544
fi
545
546
local conflict="" # state indicator for unresolved conflicts
545
- if [[ "${GIT_PS1_SHOWCONFLICTSTATE-}" == "yes" ]] &&
546
- [[ $(git ls-files --unmerged 2>/dev/null) ]]; then
547
+ if [ "${GIT_PS1_SHOWCONFLICTSTATE-}" = "yes" ] &&
548
+ [ "$(git ls-files --unmerged 2>/dev/null)" ]; then
549
conflict="|CONFLICT"
550
fi
551