970f11d1c4b93ecc1d778477f60ca9297380fe72

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

Message

Merge pull request #5104 from felipec/fc/gitfast

gitfast: update to the latest upstream Git and a couple of fixes

Diff

This diff is truncated to protect this page.

  1diff --git a/plugins/gitfast/_git b/plugins/gitfast/_git
  2index c75b0be7f1f1c826206ba2079ea378d3a5d5504f..6d1b4ecc70b305ea19da599960cb20a7627b62c9 100644
  3--- a/plugins/gitfast/_git
  4+++ b/plugins/gitfast/_git
  5@@ -104,6 +104,7 @@ __git_zsh_bash_func ()
  6 
  7 	local expansion=$(__git_aliased_command "$command")
  8 	if [ -n "$expansion" ]; then
  9+		words[1]=$expansion
 10 		completion_func="_git_${expansion//-/_}"
 11 		declare -f $completion_func >/dev/null && $completion_func
 12 	fi
 13@@ -213,8 +214,10 @@ _git ()
 14 
 15 	if (( $+functions[__${service}_zsh_main] )); then
 16 		__${service}_zsh_main
 17-	else
 18+	elif (( $+functions[__${service}_main] )); then
 19 		emulate ksh -c __${service}_main
 20+	elif (( $+functions[_${service}] )); then
 21+		emulate ksh -c _${service}
 22 	fi
 23 
 24 	let _ret && _default && _ret=0
 25diff --git a/plugins/gitfast/git-completion.bash b/plugins/gitfast/git-completion.bash
 26index 9525343fcd34ce5009fcfd9b2bf2c6356282e259..e3918c87e3adf32a9d7a4f0320c92c497376b9b5 100644
 27--- a/plugins/gitfast/git-completion.bash
 28+++ b/plugins/gitfast/git-completion.bash
 29@@ -10,17 +10,24 @@
 30 #    *) local and remote tag names
 31 #    *) .git/remotes file names
 32 #    *) git 'subcommands'
 33+#    *) git email aliases for git-send-email
 34 #    *) tree paths within 'ref:path/to/file' expressions
 35 #    *) file paths within current working directory and index
 36 #    *) common --long-options
 37 #
 38 # To use these routines:
 39 #
 40-#    1) Copy this file to somewhere (e.g. ~/.git-completion.sh).
 41+#    1) Copy this file to somewhere (e.g. ~/.git-completion.bash).
 42 #    2) Add the following line to your .bashrc/.zshrc:
 43-#        source ~/.git-completion.sh
 44+#        source ~/.git-completion.bash
 45 #    3) Consider changing your PS1 to also show the current branch,
 46 #       see git-prompt.sh for details.
 47+#
 48+# If you use complex aliases of form '!f() { ... }; f', you can use the null
 49+# command ':' as the first command in the function body to declare the desired
 50+# completion style.  For example '!f() { : git commit ; ... }; f' will
 51+# tell the completion to use commit completion.  This also works with aliases
 52+# of form "!sh -c '...'".  For example, "!sh -c ': git commit ; ... '".
 53 
 54 case "$COMP_WORDBREAKS" in
 55 *:*) : great ;;
 56@@ -180,7 +187,7 @@ fi
 57 
 58 __gitcompappend ()
 59 {
 60-	local i=${#COMPREPLY[@]}
 61+	local x i=${#COMPREPLY[@]}
 62 	for x in $1; do
 63 		if [[ "$x" == "$3"* ]]; then
 64 			COMPREPLY[i++]="$2$x$4"
 65@@ -275,16 +282,12 @@ __gitcomp_file ()
 66 # argument, and using the options specified in the second argument.
 67 __git_ls_files_helper ()
 68 {
 69-	(
 70-		test -n "${CDPATH+set}" && unset CDPATH
 71-		cd "$1"
 72-		if [ "$2" == "--committable" ]; then
 73-			git diff-index --name-only --relative HEAD
 74-		else
 75-			# NOTE: $2 is not quoted in order to support multiple options
 76-			git ls-files --exclude-standard $2
 77-		fi
 78-	) 2>/dev/null
 79+	if [ "$2" == "--committable" ]; then
 80+		git -C "$1" diff-index --name-only --relative HEAD
 81+	else
 82+		# NOTE: $2 is not quoted in order to support multiple options
 83+		git -C "$1" ls-files --exclude-standard $2
 84+	fi 2>/dev/null
 85 }
 86 
 87 
 88@@ -382,7 +385,8 @@ __git_refs ()
 89 		;;
 90 	*)
 91 		echo "HEAD"
 92-		git for-each-ref --format="%(refname:short)" -- "refs/remotes/$dir/" | sed -e "s#^$dir/##"
 93+		git for-each-ref --format="%(refname:short)" -- \
 94+			"refs/remotes/$dir/" 2>/dev/null | sed -e "s#^$dir/##"
 95 		;;
 96 	esac
 97 }
 98@@ -408,12 +412,9 @@ __git_refs_remotes ()
 99 
100 __git_remotes ()
101 {
102-	local i IFS=$'\n' d="$(__gitdir)"
103+	local d="$(__gitdir)"
104 	test -d "$d/remotes" && ls -1 "$d/remotes"
105-	for i in $(git --git-dir="$d" config --get-regexp 'remote\..*\.url' 2>/dev/null); do
106-		i="${i#remote.}"
107-		echo "${i/.url*/}"
108-	done
109+	git --git-dir="$d" remote
110 }
111 
112 __git_list_merge_strategies ()
113@@ -516,7 +517,7 @@ __git_complete_index_file ()
114 		;;
115 	esac
116 
117-	__gitcomp_file "$(__git_index_files "$1" "$pfx")" "$pfx" "$cur_"
118+	__gitcomp_file "$(__git_index_files "$1" ${pfx:+"$pfx"})" "$pfx" "$cur_"
119 }
120 
121 __git_complete_file ()
122@@ -663,10 +664,11 @@ __git_list_porcelain_commands ()
123 		check-mailmap)    : plumbing;;
124 		check-ref-format) : plumbing;;
125 		checkout-index)   : plumbing;;
126+		column)           : internal helper;;
127 		commit-tree)      : plumbing;;
128 		count-objects)    : infrequent;;
129diff --git a/plugins/gitfast/git-prompt.sh b/plugins/gitfast/git-prompt.sh
130index 54489080f8ae25a4483cd4bae076942f47f53031..0da14eee9ab4bc1865e80d58070240e4bc4bf45e 100644
131--- a/plugins/gitfast/git-prompt.sh
132+++ b/plugins/gitfast/git-prompt.sh
133@@ -66,6 +66,10 @@
134 #     git           always compare HEAD to @{upstream}
135 #     svn           always compare HEAD to your SVN upstream
136 #
137+# You can change the separator between the branch name and the above
138+# state symbols by setting GIT_PS1_STATESEPARATOR. The default separator
139+# is SP.
140+#
141 # By default, __git_ps1 will compare HEAD to your SVN upstream if it can
142 # find one, or @{upstream} otherwise.  Once you have set
143 # GIT_PS1_SHOWUPSTREAM, you can override it on a per-repository basis by
144@@ -84,6 +88,11 @@
145 # GIT_PS1_SHOWCOLORHINTS to a nonempty value. The colors are based on
146 # the colored output of "git status -sb" and are available only when
147 # using __git_ps1 for PROMPT_COMMAND or precmd.
148+#
149+# If you would like __git_ps1 to do nothing in the case when the current
150+# directory is set up to be ignored by git, then set
151+# GIT_PS1_HIDE_IF_PWD_IGNORED to a nonempty value. Override this on the
152+# repository level by setting bash.hideIfPwdIgnored to "false".
153 
154 # check whether printf supports -v
155 __git_printf_supports_v=
156@@ -207,7 +216,16 @@ __git_ps1_show_upstream ()
157 			p=" u+${count#*	}-${count%	*}" ;;
158 		esac
159 		if [[ -n "$count" && -n "$name" ]]; then
160-			p="$p $(git rev-parse --abbrev-ref "$upstream" 2>/dev/null)"
161+			__git_ps1_upstream_name=$(git rev-parse \
162+				--abbrev-ref "$upstream" 2>/dev/null)
163+			if [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then
164+				p="$p \${__git_ps1_upstream_name}"
165+			else
166+				p="$p ${__git_ps1_upstream_name}"
167+				# not needed anymore; keep user's
168+				# environment clean
169+				unset __git_ps1_upstream_name
170+			fi
171 		fi
172 	fi
173 
174@@ -259,9 +277,9 @@ __git_ps1_colorize_gitstring ()
175 	r="$c_clear$r"
176 }
177 
178-eread ()
179+__git_eread ()
180 {
181-	f="$1"
182+	local f="$1"
183 	shift
184 	test -r "$f" && read "$@" <"$f"
185 }
186@@ -279,6 +297,8 @@ eread ()
187 # In this mode you can request colored hints using GIT_PS1_SHOWCOLORHINTS=true
188 __git_ps1 ()
189 {
190+	# preserve exit status
191+	local exit=$?
192 	local pcmode=no
193 	local detached=no
194 	local ps1pc_start='\u@\h:\w '
195@@ -290,13 +310,54 @@ __git_ps1 ()
196 			ps1pc_start="$1"
197 			ps1pc_end="$2"
198 			printf_format="${3:-$printf_format}"
199+			# set PS1 to a plain prompt so that we can
200+			# simply return early if the prompt should not
201+			# be decorated
202+			PS1="$ps1pc_start$ps1pc_end"
203 		;;
204 		0|1)	printf_format="${1:-$printf_format}"
205 		;;
206-		*)	return
207+		*)	return $exit
208 		;;
209 	esac
210 
211+	# ps1_expanded:  This variable is set to 'yes' if the shell
212+	# subjects the value of PS1 to parameter expansion:
213+	#
214+	#   * bash does unless the promptvars option is disabled
215+	#   * zsh does not unless the PROMPT_SUBST option is set
216+	#   * POSIX shells always do
217+	#
218+	# If the shell would expand the contents of PS1 when drawing
219+	# the prompt, a raw ref name must not be included in PS1.
220+	# This protects the user from arbitrary code execution via
221+	# specially crafted ref names.  For example, a ref named
222+	# 'refs/heads/$(IFS=_;cmd=sudo_rm_-rf_/;$cmd)' might cause the
223+	# shell to execute 'sudo rm -rf /' when the prompt is drawn.
224+	#
225+	# Instead, the ref name should be placed in a separate global
226+	# variable (in the __git_ps1_* namespace to avoid colliding
227+	# with the user's environment) and that variable should be
228+	# referenced from PS1.  For example:
229+	#
230+	#     __git_ps1_foo=$(do_something_to_get_ref_name)
231+	#     PS1="...stuff...\${__git_ps1_foo}...stuff..."
232+	#