Skip to content

Commit

Permalink
gitfast: update to upstream v1.9.2
Browse files Browse the repository at this point in the history
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
  • Loading branch information
felipec committed Apr 22, 2014
1 parent eafd5f3 commit 6a5c8fb
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 19 deletions.
10 changes: 9 additions & 1 deletion plugins/gitfast/_git
Expand Up @@ -30,10 +30,10 @@ if [ -z "$script" ]; then
local -a locations
local e
locations=(
$(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
$(dirname ${funcsourcetrace[1]%:*})/git-completion.bash
)
for e in $locations; do
test -f $e && script="$e" && break
Expand Down Expand Up @@ -76,6 +76,14 @@ __gitcomp_nl ()
compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
}

__gitcomp_nl_append ()
{
emulate -L zsh

local IFS=$'\n'
compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
}

__gitcomp_file ()
{
emulate -L zsh
Expand Down
47 changes: 32 additions & 15 deletions plugins/gitfast/git-completion.bash
@@ -1,5 +1,3 @@
#!bash
#
# bash/zsh completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
Expand Down Expand Up @@ -180,16 +178,22 @@ _get_comp_words_by_ref ()
}
fi

__gitcompadd ()
__gitcompappend ()
{
local i=0
local i=${#COMPREPLY[@]}
for x in $1; do
if [[ "$x" == "$3"* ]]; then
COMPREPLY[i++]="$2$x$4"
fi
done
}

__gitcompadd ()
{
COMPREPLY=()
__gitcompappend "$@"
}

# Generates completion reply, appending a space to possible completion words,
# if necessary.
# It accepts 1 to 4 arguments:
Expand Down Expand Up @@ -220,6 +224,14 @@ __gitcomp ()
esac
}

# Variation of __gitcomp_nl () that appends to the existing list of
# completion candidates, COMPREPLY.
__gitcomp_nl_append ()
{
local IFS=$'\n'
__gitcompappend "$1" "${2-}" "${3-$cur}" "${4- }"
}

# Generates completion reply from newline-separated possible completion words
# by appending a space to all of them.
# It accepts 1 to 4 arguments:
Expand All @@ -231,8 +243,8 @@ __gitcomp ()
# appended.
__gitcomp_nl ()
{
local IFS=$'\n'
__gitcompadd "$1" "${2-}" "${3-$cur}" "${4- }"
COMPREPLY=()
__gitcomp_nl_append "$@"
}

# Generates completion reply with compgen from newline-separated possible
Expand Down Expand Up @@ -673,7 +685,6 @@ __git_list_porcelain_commands ()
index-pack) : plumbing;;
init-db) : deprecated;;
local-fetch) : plumbing;;
lost-found) : infrequent;;
ls-files) : plumbing;;
ls-remote) : plumbing;;
ls-tree) : plumbing;;
Expand All @@ -687,14 +698,12 @@ __git_list_porcelain_commands ()
pack-refs) : plumbing;;
parse-remote) : plumbing;;
patch-id) : plumbing;;
peek-remote) : plumbing;;
prune) : plumbing;;
prune-packed) : plumbing;;
quiltimport) : import;;
read-tree) : plumbing;;
receive-pack) : plumbing;;
remote-*) : transport;;
repo-config) : deprecated;;
rerere) : plumbing;;
rev-list) : plumbing;;
rev-parse) : plumbing;;
Expand All @@ -707,7 +716,6 @@ __git_list_porcelain_commands ()
ssh-*) : transport;;
stripspace) : plumbing;;
symbolic-ref) : plumbing;;
tar-tree) : deprecated;;
unpack-file) : plumbing;;
unpack-objects) : plumbing;;
update-index) : plumbing;;
Expand Down Expand Up @@ -901,7 +909,7 @@ _git_add ()
esac

# XXX should we check for --update and --all options ?
__git_complete_index_file "--others --modified"
__git_complete_index_file "--others --modified --directory --no-empty-directory"
}

_git_archive ()
Expand Down Expand Up @@ -1063,7 +1071,7 @@ _git_clean ()
esac

# XXX should we check for -x option ?
__git_complete_index_file "--others"
__git_complete_index_file "--others --directory"
}

_git_clone ()
Expand Down Expand Up @@ -1188,7 +1196,7 @@ _git_diff ()
__git_complete_revlist_file
}

__git_mergetools_common="diffuse ecmerge emerge kdiff3 meld opendiff
__git_mergetools_common="diffuse diffmerge ecmerge emerge kdiff3 meld opendiff
tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc3 codecompare
"

Expand Down Expand Up @@ -1491,6 +1499,12 @@ _git_mergetool ()

_git_merge_base ()
{
case "$cur" in
--*)
__gitcomp "--octopus --independent --is-ancestor --fork-point"
return
;;
esac
__gitcomp_nl "$(__git_refs)"
}

Expand Down Expand Up @@ -1623,7 +1637,7 @@ _git_rebase ()
--preserve-merges --stat --no-stat
--committer-date-is-author-date --ignore-date
--ignore-whitespace --whitespace=
--autosquash
--autosquash --fork-point --no-fork-point
"

return
Expand Down Expand Up @@ -1833,6 +1847,7 @@ _git_config ()
branch.*)
local pfx="${cur%.*}." cur_="${cur#*.}"
__gitcomp_nl "$(__git_heads)" "$pfx" "$cur_" "."
__gitcomp_nl_append $'autosetupmerge\nautosetuprebase\n' "$pfx" "$cur_"
return
;;
guitool.*.*)
Expand Down Expand Up @@ -1875,6 +1890,7 @@ _git_config ()
remote.*)
local pfx="${cur%.*}." cur_="${cur#*.}"
__gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "."
__gitcomp_nl_append "pushdefault" "$pfx" "$cur_"
return
;;
url.*.*)
Expand Down Expand Up @@ -1997,6 +2013,7 @@ _git_config ()
fetch.unpackLimit
format.attach
format.cc
format.coverLetter
format.headers
format.numbered
format.pretty
Expand Down Expand Up @@ -2580,7 +2597,7 @@ if [[ -n ${ZSH_VERSION-} ]]; then
--*=*|*.) ;;
*) c="$c " ;;
esac
array[$#array+1]="$c"
array[${#array[@]}+1]="$c"
done
compset -P '*[=:]'
compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
Expand Down
15 changes: 12 additions & 3 deletions plugins/gitfast/git-prompt.sh
Expand Up @@ -60,6 +60,7 @@
# of values:
#
# verbose show number of commits ahead/behind (+/-) upstream
# name if verbose, then also show the upstream abbrev name
# legacy don't use the '--count' option available in recent
# versions of git-rev-list
# git always compare HEAD to @{upstream}
Expand All @@ -84,13 +85,17 @@
# the colored output of "git status -sb" and are available only when
# using __git_ps1 for PROMPT_COMMAND or precmd.

# check whether printf supports -v
__git_printf_supports_v=
printf -v __git_printf_supports_v -- '%s' yes >/dev/null 2>&1

# stores the divergence from upstream in $p
# used by GIT_PS1_SHOWUPSTREAM
__git_ps1_show_upstream ()
{
local key value
local svn_remote svn_url_pattern count n
local upstream=git legacy="" verbose=""
local upstream=git legacy="" verbose="" name=""

svn_remote=()
# get some config options from git-config
Expand All @@ -106,7 +111,7 @@ __git_ps1_show_upstream ()
;;
svn-remote.*.url)
svn_remote[$((${#svn_remote[@]} + 1))]="$value"
svn_url_pattern+="\\|$value"
svn_url_pattern="$svn_url_pattern\\|$value"
upstream=svn+git # default upstream is SVN if available, else git
;;
esac
Expand All @@ -118,6 +123,7 @@ __git_ps1_show_upstream ()
git|svn) upstream="$option" ;;
verbose) verbose=1 ;;
legacy) legacy=1 ;;
name) name=1 ;;
esac
done

Expand Down Expand Up @@ -200,6 +206,9 @@ __git_ps1_show_upstream ()
*) # diverged from upstream
p=" u+${count#* }-${count% *}" ;;
esac
if [[ -n "$count" && -n "$name" ]]; then
p="$p $(git rev-parse --abbrev-ref "$upstream" 2>/dev/null)"
fi
fi

}
Expand Down Expand Up @@ -433,7 +442,7 @@ __git_ps1 ()
local gitstring="$c${b##refs/heads/}${f:+$z$f}$r$p"

if [ $pcmode = yes ]; then
if [[ -n ${ZSH_VERSION-} ]]; then
if [ "${__git_printf_supports_v-}" != yes ]; then
gitstring=$(printf -- "$printf_format" "$gitstring")
else
printf -v gitstring -- "$printf_format" "$gitstring"
Expand Down

0 comments on commit 6a5c8fb

Please sign in to comment.