mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-22 13:50:09 +00:00
gitfast: update to upstream v2.4
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
This commit is contained in:
parent
0b5d18a247
commit
169cd8b6ca
3 changed files with 129 additions and 42 deletions
|
@ -104,6 +104,7 @@ __git_zsh_bash_func ()
|
|||
|
||||
local expansion=$(__git_aliased_command "$command")
|
||||
if [ -n "$expansion" ]; then
|
||||
words[1]=$expansion
|
||||
completion_func="_git_${expansion//-/_}"
|
||||
declare -f $completion_func >/dev/null && $completion_func
|
||||
fi
|
||||
|
|
|
@ -16,11 +16,17 @@
|
|||
#
|
||||
# To use these routines:
|
||||
#
|
||||
# 1) Copy this file to somewhere (e.g. ~/.git-completion.sh).
|
||||
# 1) Copy this file to somewhere (e.g. ~/.git-completion.bash).
|
||||
# 2) Add the following line to your .bashrc/.zshrc:
|
||||
# source ~/.git-completion.sh
|
||||
# source ~/.git-completion.bash
|
||||
# 3) Consider changing your PS1 to also show the current branch,
|
||||
# see git-prompt.sh for details.
|
||||
#
|
||||
# If you use complex aliases of form '!f() { ... }; f', you can use the null
|
||||
# command ':' as the first command in the function body to declare the desired
|
||||
# completion style. For example '!f() { : git commit ; ... }; f' will
|
||||
# tell the completion to use commit completion. This also works with aliases
|
||||
# of form "!sh -c '...'". For example, "!sh -c ': git commit ; ... '".
|
||||
|
||||
case "$COMP_WORDBREAKS" in
|
||||
*:*) : great ;;
|
||||
|
@ -180,7 +186,7 @@ fi
|
|||
|
||||
__gitcompappend ()
|
||||
{
|
||||
local i=${#COMPREPLY[@]}
|
||||
local x i=${#COMPREPLY[@]}
|
||||
for x in $1; do
|
||||
if [[ "$x" == "$3"* ]]; then
|
||||
COMPREPLY[i++]="$2$x$4"
|
||||
|
@ -275,16 +281,12 @@ __gitcomp_file ()
|
|||
# argument, and using the options specified in the second argument.
|
||||
__git_ls_files_helper ()
|
||||
{
|
||||
(
|
||||
test -n "${CDPATH+set}" && unset CDPATH
|
||||
cd "$1"
|
||||
if [ "$2" == "--committable" ]; then
|
||||
git diff-index --name-only --relative HEAD
|
||||
else
|
||||
# NOTE: $2 is not quoted in order to support multiple options
|
||||
git ls-files --exclude-standard $2
|
||||
fi
|
||||
) 2>/dev/null
|
||||
if [ "$2" == "--committable" ]; then
|
||||
git -C "$1" diff-index --name-only --relative HEAD
|
||||
else
|
||||
# NOTE: $2 is not quoted in order to support multiple options
|
||||
git -C "$1" ls-files --exclude-standard $2
|
||||
fi 2>/dev/null
|
||||
}
|
||||
|
||||
|
||||
|
@ -382,7 +384,8 @@ __git_refs ()
|
|||
;;
|
||||
*)
|
||||
echo "HEAD"
|
||||
git for-each-ref --format="%(refname:short)" -- "refs/remotes/$dir/" | sed -e "s#^$dir/##"
|
||||
git for-each-ref --format="%(refname:short)" -- \
|
||||
"refs/remotes/$dir/" 2>/dev/null | sed -e "s#^$dir/##"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
@ -408,12 +411,9 @@ __git_refs_remotes ()
|
|||
|
||||
__git_remotes ()
|
||||
{
|
||||
local i IFS=$'\n' d="$(__gitdir)"
|
||||
local d="$(__gitdir)"
|
||||
test -d "$d/remotes" && ls -1 "$d/remotes"
|
||||
for i in $(git --git-dir="$d" config --get-regexp 'remote\..*\.url' 2>/dev/null); do
|
||||
i="${i#remote.}"
|
||||
echo "${i/.url*/}"
|
||||
done
|
||||
git --git-dir="$d" remote
|
||||
}
|
||||
|
||||
__git_list_merge_strategies ()
|
||||
|
@ -516,7 +516,7 @@ __git_complete_index_file ()
|
|||
;;
|
||||
esac
|
||||
|
||||
__gitcomp_file "$(__git_index_files "$1" "$pfx")" "$pfx" "$cur_"
|
||||
__gitcomp_file "$(__git_index_files "$1" ${pfx:+"$pfx"})" "$pfx" "$cur_"
|
||||
}
|
||||
|
||||
__git_complete_file ()
|
||||
|
@ -781,6 +781,10 @@ __git_aliased_command ()
|
|||
-*) : option ;;
|
||||
*=*) : setting env ;;
|
||||
git) : git itself ;;
|
||||
\(\)) : skip parens of shell function definition ;;
|
||||
{) : skip start of shell helper function ;;
|
||||
:) : skip null command ;;
|
||||
\'*) : skip opening quote after sh -c ;;
|
||||
*)
|
||||
echo "$word"
|
||||
return
|
||||
|
@ -973,7 +977,7 @@ _git_branch ()
|
|||
|
||||
case "$cur" in
|
||||
--set-upstream-to=*)
|
||||
__gitcomp "$(__git_refs)" "" "${cur##--set-upstream-to=}"
|
||||
__gitcomp_nl "$(__git_refs)" "" "${cur##--set-upstream-to=}"
|
||||
;;
|
||||
--*)
|
||||
__gitcomp "
|
||||
|
@ -1041,7 +1045,7 @@ _git_checkout ()
|
|||
|
||||
_git_cherry ()
|
||||
{
|
||||
__gitcomp "$(__git_refs)"
|
||||
__gitcomp_nl "$(__git_refs)"
|
||||
}
|
||||
|
||||
_git_cherry_pick ()
|
||||
|
@ -1165,8 +1169,8 @@ __git_diff_common_options="--stat --numstat --shortstat --summary
|
|||
--full-index --binary --abbrev --diff-filter=
|
||||
--find-copies-harder
|
||||
--text --ignore-space-at-eol --ignore-space-change
|
||||
--ignore-all-space --exit-code --quiet --ext-diff
|
||||
--no-ext-diff
|
||||
--ignore-all-space --ignore-blank-lines --exit-code
|
||||
--quiet --ext-diff --no-ext-diff
|
||||
--no-prefix --src-prefix= --dst-prefix=
|
||||
--inter-hunk-context=
|
||||
--patience --histogram --minimal
|
||||
|
@ -1197,7 +1201,7 @@ _git_diff ()
|
|||
}
|
||||
|
||||
__git_mergetools_common="diffuse diffmerge ecmerge emerge kdiff3 meld opendiff
|
||||
tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc3 codecompare
|
||||
tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc codecompare
|
||||
"
|
||||
|
||||
_git_difftool ()
|
||||
|
@ -1221,14 +1225,20 @@ _git_difftool ()
|
|||
__git_complete_revlist_file
|
||||
}
|
||||
|
||||
__git_fetch_recurse_submodules="yes on-demand no"
|
||||
|
||||
__git_fetch_options="
|
||||
--quiet --verbose --append --upload-pack --force --keep --depth=
|
||||
--tags --no-tags --all --prune --dry-run
|
||||
--tags --no-tags --all --prune --dry-run --recurse-submodules=
|
||||
"
|
||||
|
||||
_git_fetch ()
|
||||
{
|
||||
case "$cur" in
|
||||
--recurse-submodules=*)
|
||||
__gitcomp "$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}"
|
||||
return
|
||||
;;
|
||||
--*)
|
||||
__gitcomp "$__git_fetch_options"
|
||||
return
|
||||
|
@ -1292,7 +1302,7 @@ _git_gitk ()
|
|||
}
|
||||
|
||||
__git_match_ctag() {
|
||||
awk "/^${1////\\/}/ { print \$1 }" "$2"
|
||||
awk "/^${1//\//\\/}/ { print \$1 }" "$2"
|
||||
}
|
||||
|
||||
_git_grep ()
|
||||
|
@ -1412,7 +1422,7 @@ __git_log_gitk_options="
|
|||
# Options that go well for log and shortlog (not gitk)
|
||||
__git_log_shortlog_options="
|
||||
--author= --committer= --grep=
|
||||
--all-match
|
||||
--all-match --invert-grep
|
||||
"
|
||||
|
||||
__git_log_pretty_formats="oneline short medium full fuller email raw format:"
|
||||
|
@ -1451,6 +1461,7 @@ _git_log ()
|
|||
--abbrev-commit --abbrev=
|
||||
--relative-date --date=
|
||||
--pretty= --format= --oneline
|
||||
--show-signature
|
||||
--cherry-pick
|
||||
--graph
|
||||
--decorate --decorate=
|
||||
|
@ -1466,9 +1477,12 @@ _git_log ()
|
|||
__git_complete_revlist
|
||||
}
|
||||
|
||||
# Common merge options shared by git-merge(1) and git-pull(1).
|
||||
__git_merge_options="
|
||||
--no-commit --no-stat --log --no-log --squash --strategy
|
||||
--commit --stat --no-squash --ff --no-ff --ff-only --edit --no-edit
|
||||
--verify-signatures --no-verify-signatures --gpg-sign
|
||||
--quiet --verbose --progress --no-progress
|
||||
"
|
||||
|
||||
_git_merge ()
|
||||
|
@ -1477,7 +1491,8 @@ _git_merge ()
|
|||
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "$__git_merge_options"
|
||||
__gitcomp "$__git_merge_options
|
||||
--rerere-autoupdate --no-rerere-autoupdate --abort"
|
||||
return
|
||||
esac
|
||||
__gitcomp_nl "$(__git_refs)"
|
||||
|
@ -1583,6 +1598,10 @@ _git_pull ()
|
|||
__git_complete_strategy && return
|
||||
|
||||
case "$cur" in
|
||||
--recurse-submodules=*)
|
||||
__gitcomp "$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}"
|
||||
return
|
||||
;;
|
||||
--*)
|
||||
__gitcomp "
|
||||
--rebase --no-rebase
|
||||
|
@ -1595,22 +1614,55 @@ _git_pull ()
|
|||
__git_complete_remote_or_refspec
|
||||
}
|
||||
|
||||
__git_push_recurse_submodules="check on-demand"
|
||||
|
||||
__git_complete_force_with_lease ()
|
||||
{
|
||||
local cur_=$1
|
||||
|
||||
case "$cur_" in
|
||||
--*=)
|
||||
;;
|
||||
*:*)
|
||||
__gitcomp_nl "$(__git_refs)" "" "${cur_#*:}"
|
||||
;;
|
||||
*)
|
||||
__gitcomp_nl "$(__git_refs)" "" "$cur_"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
_git_push ()
|
||||
{
|
||||
case "$prev" in
|
||||
--repo)
|
||||
__gitcomp_nl "$(__git_remotes)"
|
||||
return
|
||||
;;
|
||||
--recurse-submodules)
|
||||
__gitcomp "$__git_push_recurse_submodules"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
case "$cur" in
|
||||
--repo=*)
|
||||
__gitcomp_nl "$(__git_remotes)" "" "${cur##--repo=}"
|
||||
return
|
||||
;;
|
||||
--recurse-submodules=*)
|
||||
__gitcomp "$__git_push_recurse_submodules" "" "${cur##--recurse-submodules=}"
|
||||
return
|
||||
;;
|
||||
--force-with-lease=*)
|
||||
__git_complete_force_with_lease "${cur##--force-with-lease=}"
|
||||
return
|
||||
;;
|
||||
--*)
|
||||
__gitcomp "
|
||||
--all --mirror --tags --dry-run --force --verbose
|
||||
--quiet --prune --delete --follow-tags
|
||||
--receive-pack= --repo= --set-upstream
|
||||
--force-with-lease --force-with-lease= --recurse-submodules=
|
||||
"
|
||||
return
|
||||
;;
|
||||
|
@ -1638,6 +1690,7 @@ _git_rebase ()
|
|||
--committer-date-is-author-date --ignore-date
|
||||
--ignore-whitespace --whitespace=
|
||||
--autosquash --fork-point --no-fork-point
|
||||
--autostash
|
||||
"
|
||||
|
||||
return
|
||||
|
@ -1820,6 +1873,10 @@ _git_config ()
|
|||
__gitcomp "$__git_send_email_suppresscc_options"
|
||||
return
|
||||
;;
|
||||
sendemail.transferencoding)
|
||||
__gitcomp "7bit 8bit quoted-printable base64"
|
||||
return
|
||||
;;
|
||||
--get|--get-all|--unset|--unset-all)
|
||||
__gitcomp_nl "$(__git_config_get_set_variables)"
|
||||
return
|
||||
|
@ -1954,6 +2011,7 @@ _git_config ()
|
|||
color.status.changed
|
||||
color.status.header
|
||||
color.status.nobranch
|
||||
color.status.unmerged
|
||||
color.status.untracked
|
||||
color.status.updated
|
||||
color.ui
|
||||
|
@ -2128,6 +2186,7 @@ _git_config ()
|
|||
pull.octopus
|
||||
pull.twohead
|
||||
push.default
|
||||
push.followTags
|
||||
rebase.autosquash
|
||||
rebase.stat
|
||||
receive.autogc
|
||||
|
@ -2287,6 +2346,7 @@ _git_show ()
|
|||
;;
|
||||
--*)
|
||||
__gitcomp "--pretty= --format= --abbrev-commit --oneline
|
||||
--show-signature
|
||||
$__git_diff_common_options
|
||||
"
|
||||
return
|
||||
|
@ -2492,6 +2552,16 @@ _git_tag ()
|
|||
__gitcomp_nl "$(__git_refs)"
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--list --delete --verify --annotate --message --file
|
||||
--sign --cleanup --local-user --force --column --sort
|
||||
--contains --points-at
|
||||
"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
_git_whatchanged ()
|
||||
|
@ -2547,6 +2617,7 @@ __git_main ()
|
|||
|
||||
local expansion=$(__git_aliased_command "$command")
|
||||
if [ -n "$expansion" ]; then
|
||||
words[1]=$expansion
|
||||
completion_func="_git_${expansion//-/_}"
|
||||
declare -f $completion_func >/dev/null && $completion_func
|
||||
fi
|
||||
|
|
|
@ -84,6 +84,11 @@
|
|||
# GIT_PS1_SHOWCOLORHINTS to a nonempty value. The colors are based on
|
||||
# the colored output of "git status -sb" and are available only when
|
||||
# using __git_ps1 for PROMPT_COMMAND or precmd.
|
||||
#
|
||||
# If you would like __git_ps1 to do nothing in the case when the current
|
||||
# directory is set up to be ignored by git, then set
|
||||
# GIT_PS1_HIDE_IF_PWD_IGNORED to a nonempty value. Override this on the
|
||||
# repository level by setting bash.hideIfPwdIgnored to "false".
|
||||
|
||||
# check whether printf supports -v
|
||||
__git_printf_supports_v=
|
||||
|
@ -270,7 +275,7 @@ __git_ps1_colorize_gitstring ()
|
|||
|
||||
__git_eread ()
|
||||
{
|
||||
f="$1"
|
||||
local f="$1"
|
||||
shift
|
||||
test -r "$f" && read "$@" <"$f"
|
||||
}
|
||||
|
@ -288,6 +293,8 @@ __git_eread ()
|
|||
# In this mode you can request colored hints using GIT_PS1_SHOWCOLORHINTS=true
|
||||
__git_ps1 ()
|
||||
{
|
||||
# preserve exit status
|
||||
local exit=$?
|
||||
local pcmode=no
|
||||
local detached=no
|
||||
local ps1pc_start='\u@\h:\w '
|
||||
|
@ -299,10 +306,14 @@ __git_ps1 ()
|
|||
ps1pc_start="$1"
|
||||
ps1pc_end="$2"
|
||||
printf_format="${3:-$printf_format}"
|
||||
# set PS1 to a plain prompt so that we can
|
||||
# simply return early if the prompt should not
|
||||
# be decorated
|
||||
PS1="$ps1pc_start$ps1pc_end"
|
||||
;;
|
||||
0|1) printf_format="${1:-$printf_format}"
|
||||
;;
|
||||
*) return
|
||||
*) return $exit
|
||||
;;
|
||||
esac
|
||||
|
||||
|
@ -350,11 +361,7 @@ __git_ps1 ()
|
|||
rev_parse_exit_code="$?"
|
||||
|
||||
if [ -z "$repo_info" ]; then
|
||||
if [ $pcmode = yes ]; then
|
||||
#In PC mode PS1 always needs to be set
|
||||
PS1="$ps1pc_start$ps1pc_end"
|
||||
fi
|
||||
return
|
||||
return $exit
|
||||
fi
|
||||
|
||||
local short_sha
|
||||
|
@ -369,6 +376,14 @@ __git_ps1 ()
|
|||
local inside_gitdir="${repo_info##*$'\n'}"
|
||||
local g="${repo_info%$'\n'*}"
|
||||
|
||||
if [ "true" = "$inside_worktree" ] &&
|
||||
[ -n "${GIT_PS1_HIDE_IF_PWD_IGNORED-}" ] &&
|
||||
[ "$(git config --bool bash.hideIfPwdIgnored)" != "false" ] &&
|
||||
git check-ignore -q .
|
||||
then
|
||||
return $exit
|
||||
fi
|
||||
|
||||
local r=""
|
||||
local b=""
|
||||
local step=""
|
||||
|
@ -412,10 +427,7 @@ __git_ps1 ()
|
|||
else
|
||||
local head=""
|
||||
if ! __git_eread "$g/HEAD" head; then
|
||||
if [ $pcmode = yes ]; then
|
||||
PS1="$ps1pc_start$ps1pc_end"
|
||||
fi
|
||||
return
|
||||
return $exit
|
||||
fi
|
||||
# is it a symbolic ref?
|
||||
b="${head#ref: }"
|
||||
|
@ -468,13 +480,14 @@ __git_ps1 ()
|
|||
fi
|
||||
fi
|
||||
if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ] &&
|
||||
[ -r "$g/refs/stash" ]; then
|
||||
git rev-parse --verify --quiet refs/stash >/dev/null
|
||||
then
|
||||
s="$"
|
||||
fi
|
||||
|
||||
if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ] &&
|
||||
[ "$(git config --bool bash.showUntrackedFiles)" != "false" ] &&
|
||||
git ls-files --others --exclude-standard --error-unmatch -- '*' >/dev/null 2>/dev/null
|
||||
git ls-files --others --exclude-standard --error-unmatch -- ':/*' >/dev/null 2>/dev/null
|
||||
then
|
||||
u="%${ZSH_VERSION+%}"
|
||||
fi
|
||||
|
@ -510,4 +523,6 @@ __git_ps1 ()
|
|||
else
|
||||
printf -- "$printf_format" "$gitstring"
|
||||
fi
|
||||
|
||||
return $exit
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue