1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-11-11 00:10:08 +00:00

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>
This commit is contained in:
Felipe Contreras 2019-06-07 10:57:47 -05:00 committed by Marc Cornellà
parent 52fdae4b3d
commit eb3d463081
6 changed files with 573 additions and 763 deletions

View file

@ -39,7 +39,7 @@ if [ -z "$script" ]; then
test -f $e && script="$e" && break
done
fi
ZSH_VERSION='' . "$script"
GIT_SOURCING_ZSH_COMPLETION=y . "$script"
__gitcomp ()
{
@ -93,13 +93,22 @@ __gitcomp_nl_append ()
compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
}
__gitcomp_file_direct ()
{
emulate -L zsh
local IFS=$'\n'
compset -P '*[=:]'
compadd -f -- ${=1} && _ret=0
}
__gitcomp_file ()
{
emulate -L zsh
local IFS=$'\n'
compset -P '*[=:]'
compadd -Q -p "${2-}" -f -- ${=1} && _ret=0
compadd -p "${2-}" -f -- ${=1} && _ret=0
}
__git_zsh_bash_func ()

File diff suppressed because it is too large Load diff

View file

@ -278,11 +278,12 @@ __git_ps1_colorize_gitstring ()
r="$c_clear$r"
}
# Helper function to read the first line of a file into a variable.
# __git_eread requires 2 arguments, the file path and the name of the
# variable, in that order.
__git_eread ()
{
local f="$1"
shift
test -r "$f" && read "$@" <"$f"
test -r "$1" && IFS=$'\r\n' read "$2" <"$1"
}
# __git_ps1 accepts 0 or 1 arguments (i.e., format string)

View file

@ -1,9 +1,6 @@
dir="${0:A:h}"
source "$dir/git-prompt.sh"
source "${0:A:h}/git-prompt.sh"
function git_prompt_info() {
dirty="$(parse_git_dirty)"
__git_ps1 "${ZSH_THEME_GIT_PROMPT_PREFIX//\%/%%}%s${dirty//\%/%%}${ZSH_THEME_GIT_PROMPT_SUFFIX//\%/%%}"
}
unset dir

9
plugins/gitfast/update Executable file
View file

@ -0,0 +1,9 @@
#!/bin/sh
url="https://git.kernel.org/pub/scm/git/git.git/plain/contrib/completion"
version="2.21.0"
curl -s -o _git "${url}/git-completion.zsh?h=v${version}" &&
curl -s -o git-completion.bash "${url}/git-completion.bash?h=v${version}" &&
curl -s -o git-prompt.sh "${url}/git-prompt.sh?h=v${version}" &&
git apply updates.patch

View file

@ -0,0 +1,56 @@
diff --git b/plugins/gitfast/_git a/plugins/gitfast/_git
index e2554130..a2e3bef5 100644
--- b/plugins/gitfast/_git
+++ a/plugins/gitfast/_git
@@ -30,7 +30,7 @@ if [ -z "$script" ]; then
local -a locations
local e
locations=(
- $(dirname ${funcsourcetrace[1]%:*})/git-completion.bash
+ "$(dirname ${funcsourcetrace[1]%:*})/git-completion.bash"
'/etc/bash_completion.d/git' # fedora, old debian
'/usr/share/bash-completion/completions/git' # arch, ubuntu, new debian
'/usr/share/bash-completion/git' # gentoo
@@ -214,8 +214,10 @@ _git ()
if (( $+functions[__${service}_zsh_main] )); then
__${service}_zsh_main
- else
+ elif (( $+functions[__${service}_main] )); then
emulate ksh -c __${service}_main
+ elif (( $+functions[_${service}] )); then
+ emulate ksh -c _${service}
fi
let _ret && _default && _ret=0
diff --git b/plugins/gitfast/git-completion.bash a/plugins/gitfast/git-completion.bash
index 9c8f7380..14012cab 100644
--- b/plugins/gitfast/git-completion.bash
+++ a/plugins/gitfast/git-completion.bash
@@ -2915,6 +2915,6 @@ __git_complete gitk __gitk_main
# when the user has tab-completed the executable name and consequently
# included the '.exe' suffix.
#
-if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
+if [[ "$OSTYPE" = cygwin* ]]; then
__git_complete git.exe __git_main
fi
diff --git b/plugins/gitfast/git-prompt.sh a/plugins/gitfast/git-prompt.sh
index 97eacd78..c1de34eb 100644
--- b/plugins/gitfast/git-prompt.sh
+++ a/plugins/gitfast/git-prompt.sh
@@ -502,9 +502,11 @@ __git_ps1 ()
local z="${GIT_PS1_STATESEPARATOR-" "}"
- # NO color option unless in PROMPT_COMMAND mode
- if [ $pcmode = yes ] && [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then
- __git_ps1_colorize_gitstring
+ # NO color option unless in PROMPT_COMMAND mode or it's Zsh
+ if [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then
+ if [ $pcmode = yes ] || [ -n "${ZSH_VERSION-}" ]; then
+ __git_ps1_colorize_gitstring
+ fi
fi
b=${b##refs/heads/}