Merge branch 'hn/log-graph-color-octopus' into maint
[gitweb.git] / contrib / completion / git-prompt.sh
index a81ef5a482d48b114a81e242109e2f0dec0839ed..998722cf7f5d65639654f9f7e74f4c2b3d5452f3 100644 (file)
 # the colored output of "git status -sb" and are available only when
 # using __git_ps1 for PROMPT_COMMAND or precmd.
 
+# check whether printf supports -v
+__git_printf_supports_v=
+printf -v __git_printf_supports_v -- '%s' yes >/dev/null 2>&1
+
 # stores the divergence from upstream in $p
 # used by GIT_PS1_SHOWUPSTREAM
 __git_ps1_show_upstream ()
@@ -106,7 +110,7 @@ __git_ps1_show_upstream ()
                        ;;
                svn-remote.*.url)
                        svn_remote[$((${#svn_remote[@]} + 1))]="$value"
-                       svn_url_pattern+="\\|$value"
+                       svn_url_pattern="$svn_url_pattern\\|$value"
                        upstream=svn+git # default upstream is SVN if available, else git
                        ;;
                esac
@@ -433,7 +437,7 @@ __git_ps1 ()
        local gitstring="$c${b##refs/heads/}${f:+$z$f}$r$p"
 
        if [ $pcmode = yes ]; then
-               if [[ -n ${ZSH_VERSION-} ]]; then
+               if [ "${__git_printf_supports_v-}" != yes ]; then
                        gitstring=$(printf -- "$printf_format" "$gitstring")
                else
                        printf -v gitstring -- "$printf_format" "$gitstring"