1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-10-17 12:41:14 +02:00

Holger Weiss: Completion/Unix/Command/_git: various fixes and enhancements.

This commit is contained in:
Frank Terbeck 2010-06-17 12:22:32 +00:00
parent 091cbd9d58
commit ce22f32bcb
2 changed files with 53 additions and 25 deletions

View file

@ -1,3 +1,8 @@
2010-06-17 Frank Terbeck <ft@bewatermyfriend.org>
* Holger Weiss: 28016, 28017, 28018, 28019:
Completion/Unix/Command/_git: various fixes and enhancements.
2010-06-16 Peter Stephenson <p.w.stephenson@ntlworld.com>
* 28042: Doc/Zsh/contrib.yo, Functions/Zle/.distfiles,
@ -13302,5 +13307,5 @@
*****************************************************
* This is used by the shell to define $ZSH_PATCHLEVEL
* $Revision: 1.5006 $
* $Revision: 1.5007 $
*****************************************************

View file

@ -1597,13 +1597,6 @@ _git-branch () {
}
__git_zstyle_default ':completion::complete:git-branch:delete-argument-rest:*' ignore-line yes
(( $+functions[__git_is_treeish] )) ||
__git_is_treeish () {
local sha1
sha1="$(git rev-parse $1 -- 2> /dev/null)" &&
[[ "$(git cat-file -t "${sha1}^{tree}" 2> /dev/null)" == tree ]]
}
# TODO: __git_tree_ishs is just stupid. It should be giving us a list of tags
# and perhaps also allow all that just with ^{tree} and so on. Not quite sure
# how to do that, though.
@ -1990,22 +1983,33 @@ _git-rerere () {
(( $+functions[_git-reset] )) ||
_git-reset () {
local commit_arg path_arg
local curcontext=$curcontext state line
typeset -A opt_args
if [[ $words[2] == --mixed ]]; then
commit_arg=':commit:__git_revisions'
path_arg="*:file:__git_tree_files . $words[3]"
else
commit_arg='::commit:__git_revisions'
fi
_arguments -C -S -A '-*' \
'(-q --quiet)'{-q,--quiet}'[be quiet, only report errors]' \
'::commit:__git_revisions' \
- reset-head \
'( --soft --hard --merge --keep)--mixed[reset the index but not the working tree (default)]' \
'(--mixed --hard --merge --keep)--soft[do not touch the index file nor the working tree]' \
'(--mixed --soft --merge --keep)--hard[match the working tree and index to the given tree]' \
'(--mixed --soft --hard --keep)--merge[reset out of a conflicted merge]' \
'(--mixed --soft --hard --merge )--keep[like --hard, but keep local working tree changes]' \
- reset-paths \
'(-p --patch)'{-p,--patch}'[select diff hunks to remove from the index]' \
'*::file:->files' && ret=0
_arguments -S -A '--*' \
'( --soft --hard)--mixed[like --soft but report what has not been updated (default)]' \
'(--mixed --hard)--soft[do not touch the index file nor the working tree]' \
'(--mixed --soft )--hard[match the working tree and index to the given tree]' \
'--merge[bring local changes along to new commit]' \
$commit_arg \
$path_arg && ret=0
case $state in
(files)
local commit
if [[ -n $line[1] ]] && __git_is_committish $line[1]; then
commit=$line[1]
else
commit=HEAD
fi
__git_tree_files . $commit && ret=0
;;
esac
}
(( $+functions[_git-revert] )) ||
@ -2946,7 +2950,9 @@ __git_tree_files () {
local multi_parts_opts
local tree Path
integer at_least_one_tree_added
local -a tree_files
local -a tree_files compadd_opts
zparseopts -D -E -a compadd_opts V: J: 1 2 n f X: M: P: S: r: R: q F:
[[ "$1" == */ ]] && Path="$1" || Path="${1:h}/"
shift
@ -2957,11 +2963,11 @@ __git_tree_files () {
done
if (( !at_least_one_tree_added )); then
return
return 1
fi
local expl
_wanted files expl 'tree file' _multi_parts -f $@ -- / tree_files
_wanted files expl 'tree file' _multi_parts -f $compadd_opts -- / tree_files
}
# TODO: deal with things that __git_heads and __git_tags has in common (i.e.,
@ -4421,6 +4427,23 @@ __git_setup_revision_arguments () {
# ---
(( $+functions[__git_is_type] )) ||
__git_is_type () {
local sha1
sha1="$(git rev-parse $2 2> /dev/null)" &&
[[ "$(git cat-file -t "${sha1}^{$1}" 2> /dev/null)" == $1 ]]
}
(( $+functions[__git_is_committish] )) ||
__git_is_committish () {
__git_is_type commit $1
}
(( $+functions[__git_is_treeish] )) ||
__git_is_treeish () {
__git_is_type tree $1
}
(( $+functions[__git_is_indexed] )) ||
__git_is_indexed () {
[[ -n $(git ls-files $REPLY) ]]