0736a3749a9c9ae4ba3096b0b6c55250f19fef17

Author
Felipe Contreras <felipe.contreras@gmail.com>
Committer
GitHub <noreply@github.com>
Date

Message

gitfast: proper synchronization (#8550)

Diff

This diff is truncated to protect this page.

  1diff --git a/plugins/gitfast/_git b/plugins/gitfast/_git
  2index 886bf95d1f5940987f5c4411097fd09b000be037..78a6dbb3d19adb2940d5ea67dc3ffb9c26ba0dbd 100644
  3--- a/plugins/gitfast/_git
  4+++ b/plugins/gitfast/_git
  5@@ -30,7 +30,7 @@ if [ -z "$script" ]; then
  6 	local -a locations
  7 	local e
  8 	locations=(
  9-		$(dirname ${funcsourcetrace[1]%:*})/git-completion.bash
 10+		"$(dirname ${funcsourcetrace[1]%:*})/git-completion.bash"
 11 		'/etc/bash_completion.d/git' # fedora, old debian
 12 		'/usr/share/bash-completion/completions/git' # arch, ubuntu, new debian
 13 		'/usr/share/bash-completion/git' # gentoo
 14@@ -39,7 +39,7 @@ if [ -z "$script" ]; then
 15 		test -f $e && script="$e" && break
 16 	done
 17 fi
 18-GIT_SOURCING_ZSH_COMPLETION=y . "$script"
 19+ZSH_VERSION='' . "$script"
 20 
 21 __gitcomp ()
 22 {
 23@@ -93,22 +93,13 @@ __gitcomp_nl_append ()
 24 	compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
 25 }
 26 
 27-__gitcomp_file_direct ()
 28-{
 29-	emulate -L zsh
 30-
 31-	local IFS=$'\n'
 32-	compset -P '*[=:]'
 33-	compadd -f -- ${=1} && _ret=0
 34-}
 35-
 36 __gitcomp_file ()
 37 {
 38 	emulate -L zsh
 39 
 40 	local IFS=$'\n'
 41 	compset -P '*[=:]'
 42-	compadd -p "${2-}" -f -- ${=1} && _ret=0
 43+	compadd -Q -p "${2-}" -f -- ${=1} && _ret=0
 44 }
 45 
 46 __git_zsh_bash_func ()
 47@@ -232,8 +223,10 @@ _git ()
 48 
 49 	if (( $+functions[__${service}_zsh_main] )); then
 50 		__${service}_zsh_main
 51-	else
 52+	elif (( $+functions[__${service}_main] )); then
 53 		emulate ksh -c __${service}_main
 54+	elif (( $+functions[_${service}] )); then
 55+		emulate ksh -c _${service}
 56 	fi
 57 
 58 	let _ret && _default && _ret=0
 59diff --git a/plugins/gitfast/git-completion.bash b/plugins/gitfast/git-completion.bash
 60index e087c4bf0085add8e968e128db6b667acbc80320..b6ff5dc0840e3667434b9d7f614007ae9bbfc77a 100644
 61--- a/plugins/gitfast/git-completion.bash
 62+++ b/plugins/gitfast/git-completion.bash
 63@@ -29,16 +29,13 @@
 64 # tell the completion to use commit completion.  This also works with aliases
 65 # of form "!sh -c '...'".  For example, "!sh -c ': git commit ; ... '".
 66 #
 67-# Compatible with bash 3.2.57.
 68-#
 69 # You can set the following environment variables to influence the behavior of
 70 # the completion routines:
 71 #
 72 #   GIT_COMPLETION_CHECKOUT_NO_GUESS
 73 #
 74 #     When set to "1", do not include "DWIM" suggestions in git-checkout
 75-#     and git-switch completion (e.g., completing "foo" when "origin/foo"
 76-#     exists).
 77+#     completion (e.g., completing "foo" when "origin/foo" exists).
 78 
 79 case "$COMP_WORDBREAKS" in
 80 *:*) : great ;;
 81@@ -95,70 +92,6 @@ __git ()
 82 		${__git_dir:+--git-dir="$__git_dir"} "$@" 2>/dev/null
 83 }
 84 
 85-# Removes backslash escaping, single quotes and double quotes from a word,
 86-# stores the result in the variable $dequoted_word.
 87-# 1: The word to dequote.
 88-__git_dequote ()
 89-{
 90-	local rest="$1" len ch
 91-
 92-	dequoted_word=""
 93-
 94-	while test -n "$rest"; do
 95-		len=${#dequoted_word}
 96-		dequoted_word="$dequoted_word${rest%%[\\\'\"]*}"
 97-		rest="${rest:$((${#dequoted_word}-$len))}"
 98-
 99-		case "${rest:0:1}" in
100-		\\)
101-			ch="${rest:1:1}"
102-			case "$ch" in
103-			$'\n')
104-				;;
105-			*)
106-				dequoted_word="$dequoted_word$ch"
107-				;;
108-			esac
109-			rest="${rest:2}"
110-			;;
111-		\')
112-			rest="${rest:1}"
113-			len=${#dequoted_word}
114-			dequoted_word="$dequoted_word${rest%%\'*}"
115-			rest="${rest:$((${#dequoted_word}-$len+1))}"
116-			;;
117-		\")
118-			rest="${rest:1}"
119-			while test -n "$rest" ; do
120-				len=${#dequoted_word}
121-				dequoted_word="$dequoted_word${rest%%[\\\"]*}"
122-				rest="${rest:$((${#dequoted_word}-$len))}"
123-				case "${rest:0:1}" in
124-				\\)
125-					ch="${rest:1:1}"
126-					case "$ch" in
127-					\"|\\|\$|\`)
128-						dequoted_word="$dequoted_word$ch"
129-						;;
130-					$'\n')
131-						;;
132-					*)
133-						dequoted_word="$dequoted_word\\$ch"
134-						;;
135-					esac
136-					rest="${rest:2}"
137-					;;
138-				\")
139-					rest="${rest:1}"
140-					break
141-					;;
142-				esac
143-			done
144-			;;
145-		esac
146-	done
147-}
148-
149 # The following function is based on code from:
150 #
151 #   bash_completion - programmable completion functions for bash 3.2+
152@@ -331,32 +264,9 @@ __gitcomp ()
153 	case "$cur_" in
154 	--*=)
155 		;;
156-	--no-*)
157-		local c i=0 IFS=$' \t\n'
158-		for c in $1; do
159-			if [[ $c == "--" ]]; then
160-				continue
161-			fi
162-			c="$c${4-}"
163diff --git a/plugins/gitfast/git-prompt.sh b/plugins/gitfast/git-prompt.sh
164index f7009b063342d940c0e1dfce6b2207f46373330b..fd2b049dbde3cd6b1a2583e7c32f3ea2915052be 100644
165--- a/plugins/gitfast/git-prompt.sh
166+++ b/plugins/gitfast/git-prompt.sh
167@@ -219,7 +219,7 @@ __git_ps1_show_upstream ()
168 		if [[ -n "$count" && -n "$name" ]]; then
169 			__git_ps1_upstream_name=$(git rev-parse \
170 				--abbrev-ref "$upstream" 2>/dev/null)
171-			if [ "$pcmode" = yes ] && [ "$ps1_expanded" = yes ]; then
172+			if [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then
173 				p="$p \${__git_ps1_upstream_name}"
174 			else
175 				p="$p ${__git_ps1_upstream_name}"
176@@ -237,7 +237,7 @@ __git_ps1_show_upstream ()
177 # to build a gitstring.
178 __git_ps1_colorize_gitstring ()
179 {
180-	if [[ -n "${ZSH_VERSION-}" ]]; then
181+	if [[ -n ${ZSH_VERSION-} ]]; then
182 		local c_red='%F{red}'
183 		local c_green='%F{green}'
184 		local c_lblue='%F{blue}'
185@@ -255,7 +255,7 @@ __git_ps1_colorize_gitstring ()
186 	local flags_color="$c_lblue"
187 
188 	local branch_color=""
189-	if [ "$detached" = no ]; then
190+	if [ $detached = no ]; then
191 		branch_color="$ok_color"
192 	else
193 		branch_color="$bad_color"
194@@ -508,13 +508,13 @@ __git_ps1 ()
195 
196 	# NO color option unless in PROMPT_COMMAND mode or it's Zsh
197 	if [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then
198-		if [ "$pcmode" = yes ] || [ -n "${ZSH_VERSION-}" ]; then
199+		if [ $pcmode = yes ] || [ -n "${ZSH_VERSION-}" ]; then
200 			__git_ps1_colorize_gitstring
201 		fi
202 	fi
203 
204 	b=${b##refs/heads/}
205-	if [ "$pcmode" = yes ] && [ "$ps1_expanded" = yes ]; then
206+	if [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then
207 		__git_ps1_branch_name=$b
208 		b="\${__git_ps1_branch_name}"
209 	fi
210@@ -522,7 +522,7 @@ __git_ps1 ()
211 	local f="$w$i$s$u"
212 	local gitstring="$c$b${f:+$z$f}$r$p"
213 
214-	if [ "$pcmode" = yes ]; then
215+	if [ $pcmode = yes ]; then
216 		if [ "${__git_printf_supports_v-}" != yes ]; then
217 			gitstring=$(printf -- "$printf_format" "$gitstring")
218 		else