eb3d46308157e10eb11ec96bcf14b319279d09d3

Author
Felipe Contreras <felipe.contreras@gmail.com>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

gitfast: update to upstream v2.21 (#7914)

* gitfast: use $OSTYPE again

In the last update to upstream this was reverted:

 a56eac7a (Use OSTYPE instead of uname whenever possible for better speed. (#5496))

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>

* gitfast: simplify plugin

No need to set and unset a variable we use once.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>

* gitfast: add script to update from upstream

This would make easier the process of updating, and also not miss our
patches.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>

* gitfast: update to upstream v2.21

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>

Diff

This diff is truncated to protect this page.

  1diff --git a/plugins/gitfast/_git b/plugins/gitfast/_git
  2index 78a6dbb3d19adb2940d5ea67dc3ffb9c26ba0dbd..c003a67717be122376ac416b2601ed073a68392f 100644
  3--- a/plugins/gitfast/_git
  4+++ b/plugins/gitfast/_git
  5@@ -39,7 +39,7 @@ if [ -z "$script" ]; then
  6 		test -f $e && script="$e" && break
  7 	done
  8 fi
  9-ZSH_VERSION='' . "$script"
 10+GIT_SOURCING_ZSH_COMPLETION=y . "$script"
 11 
 12 __gitcomp ()
 13 {
 14@@ -93,13 +93,22 @@ __gitcomp_nl_append ()
 15 	compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
 16 }
 17 
 18+__gitcomp_file_direct ()
 19+{
 20+	emulate -L zsh
 21+
 22+	local IFS=$'\n'
 23+	compset -P '*[=:]'
 24+	compadd -f -- ${=1} && _ret=0
 25+}
 26+
 27 __gitcomp_file ()
 28 {
 29 	emulate -L zsh
 30 
 31 	local IFS=$'\n'
 32 	compset -P '*[=:]'
 33-	compadd -Q -p "${2-}" -f -- ${=1} && _ret=0
 34+	compadd -p "${2-}" -f -- ${=1} && _ret=0
 35 }
 36 
 37 __git_zsh_bash_func ()
 38diff --git a/plugins/gitfast/git-completion.bash b/plugins/gitfast/git-completion.bash
 39index d93441747523ab2971e114cd6a02d56b79ba3382..700417879e7b8e9532b72fb106cdcab9d0d14c4a 100644
 40--- a/plugins/gitfast/git-completion.bash
 41+++ b/plugins/gitfast/git-completion.bash
 42@@ -29,6 +29,8 @@
 43 # tell the completion to use commit completion.  This also works with aliases
 44 # of form "!sh -c '...'".  For example, "!sh -c ': git commit ; ... '".
 45 #
 46+# Compatible with bash 3.2.57.
 47+#
 48 # You can set the following environment variables to influence the behavior of
 49 # the completion routines:
 50 #
 51@@ -92,6 +94,70 @@ __git ()
 52 		${__git_dir:+--git-dir="$__git_dir"} "$@" 2>/dev/null
 53 }
 54 
 55+# Removes backslash escaping, single quotes and double quotes from a word,
 56+# stores the result in the variable $dequoted_word.
 57+# 1: The word to dequote.
 58+__git_dequote ()
 59+{
 60+	local rest="$1" len ch
 61+
 62+	dequoted_word=""
 63+
 64+	while test -n "$rest"; do
 65+		len=${#dequoted_word}
 66+		dequoted_word="$dequoted_word${rest%%[\\\'\"]*}"
 67+		rest="${rest:$((${#dequoted_word}-$len))}"
 68+
 69+		case "${rest:0:1}" in
 70+		\\)
 71+			ch="${rest:1:1}"
 72+			case "$ch" in
 73+			$'\n')
 74+				;;
 75+			*)
 76+				dequoted_word="$dequoted_word$ch"
 77+				;;
 78+			esac
 79+			rest="${rest:2}"
 80+			;;
 81+		\')
 82+			rest="${rest:1}"
 83+			len=${#dequoted_word}
 84+			dequoted_word="$dequoted_word${rest%%\'*}"
 85+			rest="${rest:$((${#dequoted_word}-$len+1))}"
 86+			;;
 87+		\")
 88+			rest="${rest:1}"
 89+			while test -n "$rest" ; do
 90+				len=${#dequoted_word}
 91+				dequoted_word="$dequoted_word${rest%%[\\\"]*}"
 92+				rest="${rest:$((${#dequoted_word}-$len))}"
 93+				case "${rest:0:1}" in
 94+				\\)
 95+					ch="${rest:1:1}"
 96+					case "$ch" in
 97+					\"|\\|\$|\`)
 98+						dequoted_word="$dequoted_word$ch"
 99+						;;
100+					$'\n')
101+						;;
102+					*)
103+						dequoted_word="$dequoted_word\\$ch"
104+						;;
105+					esac
106+					rest="${rest:2}"
107+					;;
108+				\")
109+					rest="${rest:1}"
110+					break
111+					;;
112+				esac
113+			done
114+			;;
115+		esac
116+	done
117+}
118+
119 # The following function is based on code from:
120 #
121 #   bash_completion - programmable completion functions for bash 3.2+
122@@ -111,8 +177,7 @@ __git ()
123 #   GNU General Public License for more details.
124 #
125 #   You should have received a copy of the GNU General Public License
126-#   along with this program; if not, write to the Free Software Foundation,
127-#   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
128+#   along with this program; if not, see <http://www.gnu.org/licenses/>.
129 #
130 #   The latest version of this software can be obtained here:
131 #
132@@ -265,9 +330,32 @@ __gitcomp ()
133 	case "$cur_" in
134 	--*=)
135 		;;
136+	--no-*)
137+		local c i=0 IFS=$' \t\n'
138+		for c in $1; do
139+			if [[ $c == "--" ]]; then
140+				continue
141+			fi
142diff --git a/plugins/gitfast/git-prompt.sh b/plugins/gitfast/git-prompt.sh
143index cd905759e183bc702646856255967cc3a6e06f73..fd2b049dbde3cd6b1a2583e7c32f3ea2915052be 100644
144--- a/plugins/gitfast/git-prompt.sh
145+++ b/plugins/gitfast/git-prompt.sh
146@@ -278,11 +278,12 @@ __git_ps1_colorize_gitstring ()
147 	r="$c_clear$r"
148 }
149 
150+# Helper function to read the first line of a file into a variable.
151+# __git_eread requires 2 arguments, the file path and the name of the
152+# variable, in that order.
153 __git_eread ()
154 {
155-	local f="$1"
156-	shift
157-	test -r "$f" && read "$@" <"$f"
158+	test -r "$1" && IFS=$'\r\n' read "$2" <"$1"
159 }
160 
161 # __git_ps1 accepts 0 or 1 arguments (i.e., format string)
162diff --git a/plugins/gitfast/gitfast.plugin.zsh b/plugins/gitfast/gitfast.plugin.zsh
163index 8c2aea49791188ac4c6d6962dd9af12dcec9a9dc..7b6b67e92448e917934350e06f8c95250ec826a4 100644
164--- a/plugins/gitfast/gitfast.plugin.zsh
165+++ b/plugins/gitfast/gitfast.plugin.zsh
166@@ -1,9 +1,6 @@
167-dir="${0:A:h}"
168-source "$dir/git-prompt.sh"
169+source "${0:A:h}/git-prompt.sh"
170 
171 function git_prompt_info() {
172   dirty="$(parse_git_dirty)"
173   __git_ps1 "${ZSH_THEME_GIT_PROMPT_PREFIX//\%/%%}%s${dirty//\%/%%}${ZSH_THEME_GIT_PROMPT_SUFFIX//\%/%%}"
174 }
175-
176-unset dir
177diff --git a/plugins/gitfast/update b/plugins/gitfast/update
178new file mode 100755
179index 0000000000000000000000000000000000000000..76ecc71e01046456dc98ece8ce22e26757bb4876
180--- /dev/null
181+++ b/plugins/gitfast/update
182@@ -0,0 +1,9 @@
183+#!/bin/sh
184+
185+url="https://git.kernel.org/pub/scm/git/git.git/plain/contrib/completion"
186+version="2.21.0"
187+
188+curl -s -o _git "${url}/git-completion.zsh?h=v${version}" &&
189+curl -s -o git-completion.bash "${url}/git-completion.bash?h=v${version}" &&
190+curl -s -o git-prompt.sh "${url}/git-prompt.sh?h=v${version}" &&
191+git apply updates.patch
192diff --git a/plugins/gitfast/updates.patch b/plugins/gitfast/updates.patch
193new file mode 100644
194index 0000000000000000000000000000000000000000..28a31f859c267c496ca0e455554d14e0d39b47a6
195--- /dev/null
196+++ b/plugins/gitfast/updates.patch
197@@ -0,0 +1,56 @@
198+diff --git b/plugins/gitfast/_git a/plugins/gitfast/_git
199+index e2554130..a2e3bef5 100644
200+--- b/plugins/gitfast/_git
201++++ a/plugins/gitfast/_git
202+@@ -30,7 +30,7 @@ if [ -z "$script" ]; then
203+ 	local -a locations
204+ 	local e
205+ 	locations=(
206+-		$(dirname ${funcsourcetrace[1]%:*})/git-completion.bash
207++		"$(dirname ${funcsourcetrace[1]%:*})/git-completion.bash"
208+ 		'/etc/bash_completion.d/git' # fedora, old debian
209+ 		'/usr/share/bash-completion/completions/git' # arch, ubuntu, new debian
210+ 		'/usr/share/bash-completion/git' # gentoo
211+@@ -214,8 +214,10 @@ _git ()
212+ 
213+ 	if (( $+functions[__${service}_zsh_main] )); then
214+ 		__${service}_zsh_main
215+-	else
216++	elif (( $+functions[__${service}_main] )); then
217+ 		emulate ksh -c __${service}_main
218++	elif (( $+functions[_${service}] )); then
219++		emulate ksh -c _${service}
220+ 	fi
221+ 
222+ 	let _ret && _default && _ret=0
223+diff --git b/plugins/gitfast/git-completion.bash a/plugins/gitfast/git-completion.bash
224+index 9c8f7380..14012cab 100644
225+--- b/plugins/gitfast/git-completion.bash
226++++ a/plugins/gitfast/git-completion.bash
227+@@ -2915,6 +2915,6 @@ __git_complete gitk __gitk_main
228+ # when the user has tab-completed the executable name and consequently
229+ # included the '.exe' suffix.
230+ #
231+-if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
232++if [[ "$OSTYPE" = cygwin* ]]; then
233+ __git_complete git.exe __git_main
234+ fi
235+diff --git b/plugins/gitfast/git-prompt.sh a/plugins/gitfast/git-prompt.sh
236+index 97eacd78..c1de34eb 100644
237+--- b/plugins/gitfast/git-prompt.sh
238++++ a/plugins/gitfast/git-prompt.sh
239+@@ -502,9 +502,11 @@ __git_ps1 ()
240+ 
241+ 	local z="${GIT_PS1_STATESEPARATOR-" "}"
242+ 
243+-	# NO color option unless in PROMPT_COMMAND mode
244+-	if [ $pcmode = yes ] && [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then
245+-		__git_ps1_colorize_gitstring
246++	# NO color option unless in PROMPT_COMMAND mode or it's Zsh
247++	if [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then
248++		if [ $pcmode = yes ] || [ -n "${ZSH_VERSION-}" ]; then
249++			__git_ps1_colorize_gitstring
250++		fi
251+ 	fi
252+ 
253+ 	b=${b##refs/heads/}