8c95c2b6cb339379dda5e39a0eef795cab1dae7a

Author
Marc Cornellà <marc.cornella@live.com>
Committer
GitHub <noreply@github.com>
Date

Message

gitfast: update plugin (#7152)

* Stop loading git plugin
* Update completion and git-prompt to v2.10
* Update completion to v2.14

Diff

This diff is truncated to protect this page.

  1diff --git a/plugins/gitfast/_git b/plugins/gitfast/_git
  2index 6d1b4ecc70b305ea19da599960cb20a7627b62c9..78a6dbb3d19adb2940d5ea67dc3ffb9c26ba0dbd 100644
  3--- a/plugins/gitfast/_git
  4+++ b/plugins/gitfast/_git
  5@@ -9,7 +9,7 @@
  6 #
  7 # If your script is somewhere else, you can configure it on your ~/.zshrc:
  8 #
  9-#  zstyle ':completion:*:*:git:*' script ~/.git-completion.sh
 10+#  zstyle ':completion:*:*:git:*' script ~/.git-completion.zsh
 11 #
 12 # The recommended way to install this script is to copy to '~/.zsh/_git', and
 13 # then add the following to your ~/.zshrc file:
 14@@ -67,6 +67,15 @@ __gitcomp ()
 15 	esac
 16 }
 17 
 18+__gitcomp_direct ()
 19+{
 20+	emulate -L zsh
 21+
 22+	local IFS=$'\n'
 23+	compset -P '*[=:]'
 24+	compadd -Q -- ${=1} && _ret=0
 25+}
 26+
 27 __gitcomp_nl ()
 28 {
 29 	emulate -L zsh
 30diff --git a/plugins/gitfast/git-completion.bash b/plugins/gitfast/git-completion.bash
 31index 8ce6b5c5f70d7bd72bcc354305b4dc6bfe39ca27..d93441747523ab2971e114cd6a02d56b79ba3382 100644
 32--- a/plugins/gitfast/git-completion.bash
 33+++ b/plugins/gitfast/git-completion.bash
 34@@ -28,27 +28,55 @@
 35 # completion style.  For example '!f() { : git commit ; ... }; f' will
 36 # tell the completion to use commit completion.  This also works with aliases
 37 # of form "!sh -c '...'".  For example, "!sh -c ': git commit ; ... '".
 38+#
 39+# You can set the following environment variables to influence the behavior of
 40+# the completion routines:
 41+#
 42+#   GIT_COMPLETION_CHECKOUT_NO_GUESS
 43+#
 44+#     When set to "1", do not include "DWIM" suggestions in git-checkout
 45+#     completion (e.g., completing "foo" when "origin/foo" exists).
 46 
 47 case "$COMP_WORDBREAKS" in
 48 *:*) : great ;;
 49 *)   COMP_WORDBREAKS="$COMP_WORDBREAKS:"
 50 esac
 51 
 52+# Discovers the path to the git repository taking any '--git-dir=<path>' and
 53+# '-C <path>' options into account and stores it in the $__git_repo_path
 54+# variable.
 55+__git_find_repo_path ()
 56+{
 57+	if [ -n "$__git_repo_path" ]; then
 58+		# we already know where it is
 59+		return
 60+	fi
 61+
 62+	if [ -n "${__git_C_args-}" ]; then
 63+		__git_repo_path="$(git "${__git_C_args[@]}" \
 64+			${__git_dir:+--git-dir="$__git_dir"} \
 65+			rev-parse --absolute-git-dir 2>/dev/null)"
 66+	elif [ -n "${__git_dir-}" ]; then
 67+		test -d "$__git_dir" &&
 68+		__git_repo_path="$__git_dir"
 69+	elif [ -n "${GIT_DIR-}" ]; then
 70+		test -d "${GIT_DIR-}" &&
 71+		__git_repo_path="$GIT_DIR"
 72+	elif [ -d .git ]; then
 73+		__git_repo_path=.git
 74+	else
 75+		__git_repo_path="$(git rev-parse --git-dir 2>/dev/null)"
 76+	fi
 77+}
 78+
 79+# Deprecated: use __git_find_repo_path() and $__git_repo_path instead
 80 # __gitdir accepts 0 or 1 arguments (i.e., location)
 81 # returns location of .git repo
 82 __gitdir ()
 83 {
 84 	if [ -z "${1-}" ]; then
 85-		if [ -n "${__git_dir-}" ]; then
 86-			echo "$__git_dir"
 87-		elif [ -n "${GIT_DIR-}" ]; then
 88-			test -d "${GIT_DIR-}" || return 1
 89-			echo "$GIT_DIR"
 90-		elif [ -d .git ]; then
 91-			echo .git
 92-		else
 93-			git rev-parse --git-dir 2>/dev/null
 94-		fi
 95+		__git_find_repo_path || return 1
 96+		echo "$__git_repo_path"
 97 	elif [ -d "$1/.git" ]; then
 98 		echo "$1/.git"
 99 	else
100@@ -56,6 +84,14 @@ __gitdir ()
101 	fi
102 }
103 
104+# Runs git with all the options given as argument, respecting any
105+# '--git-dir=<path>' and '-C <path>' options present on the command line
106+__git ()
107+{
108+	git ${__git_C_args:+"${__git_C_args[@]}"} \
109+		${__git_dir:+--git-dir="$__git_dir"} "$@" 2>/dev/null
110+}
111+
112 # The following function is based on code from:
113 #
114 #   bash_completion - programmable completion functions for bash 3.2+
115@@ -185,6 +221,20 @@ _get_comp_words_by_ref ()
116 }
117 fi
118 
119+# Fills the COMPREPLY array with prefiltered words without any additional
120+# processing.
121+# Callers must take care of providing only words that match the current word
122+# to be completed and adding any prefix and/or suffix (trailing space!), if
123+# necessary.
124+# 1: List of newline-separated matching completion words, complete with
125+#    prefix and suffix.
126+__gitcomp_direct ()
127+{
128+	local IFS=$'\n'
129+
130+	COMPREPLY=($1)
131+}
132+
133 __gitcompappend ()
134diff --git a/plugins/gitfast/git-prompt.sh b/plugins/gitfast/git-prompt.sh
135index 0da14eee9ab4bc1865e80d58070240e4bc4bf45e..cd905759e183bc702646856255967cc3a6e06f73 100644
136--- a/plugins/gitfast/git-prompt.sh
137+++ b/plugins/gitfast/git-prompt.sh
138@@ -82,6 +82,7 @@
139 #     contains      relative to newer annotated tag (v1.6.3.2~35)
140 #     branch        relative to newer tag or branch (master~4)
141 #     describe      relative to older annotated tag (v1.6.3.1-13-gdd42c2f)
142+#     tag           relative to any older tag (v1.6.3.1-13-gdd42c2f)
143 #     default       exactly matching tag
144 #
145 # If you would like a colored hint about the current dirty state, set
146@@ -355,8 +356,8 @@ __git_ps1 ()
147 	# incorrect.)
148 	#
149 	local ps1_expanded=yes
150-	[ -z "$ZSH_VERSION" ] || [[ -o PROMPT_SUBST ]] || ps1_expanded=no
151-	[ -z "$BASH_VERSION" ] || shopt -q promptvars || ps1_expanded=no
152+	[ -z "${ZSH_VERSION-}" ] || [[ -o PROMPT_SUBST ]] || ps1_expanded=no
153+	[ -z "${BASH_VERSION-}" ] || shopt -q promptvars || ps1_expanded=no
154 
155 	local repo_info rev_parse_exit_code
156 	repo_info="$(git rev-parse --git-dir --is-inside-git-dir \
157@@ -368,7 +369,7 @@ __git_ps1 ()
158 		return $exit
159 	fi
160 
161-	local short_sha
162+	local short_sha=""
163 	if [ "$rev_parse_exit_code" = "0" ]; then
164 		short_sha="${repo_info##*$'\n'}"
165 		repo_info="${repo_info%$'\n'*}"
166@@ -443,6 +444,8 @@ __git_ps1 ()
167 					git describe --contains HEAD ;;
168 				(branch)
169 					git describe --contains --all HEAD ;;
170+				(tag)
171+					git describe --tags HEAD ;;
172 				(describe)
173 					git describe HEAD ;;
174 				(* | default)
175diff --git a/plugins/gitfast/gitfast.plugin.zsh b/plugins/gitfast/gitfast.plugin.zsh
176index dba1b13152007b87b0e4774d3fcc291bc9d9381c..8c2aea49791188ac4c6d6962dd9af12dcec9a9dc 100644
177--- a/plugins/gitfast/gitfast.plugin.zsh
178+++ b/plugins/gitfast/gitfast.plugin.zsh
179@@ -1,8 +1,9 @@
180-dir=$(dirname $0)
181-source $dir/../git/git.plugin.zsh
182-source $dir/git-prompt.sh
183+dir="${0:A:h}"
184+source "$dir/git-prompt.sh"
185 
186 function git_prompt_info() {
187   dirty="$(parse_git_dirty)"
188   __git_ps1 "${ZSH_THEME_GIT_PROMPT_PREFIX//\%/%%}%s${dirty//\%/%%}${ZSH_THEME_GIT_PROMPT_SUFFIX//\%/%%}"
189 }
190+
191+unset dir