mirror of
git://git.code.sf.net/p/zsh/code
synced 2024-05-20 06:56:05 +02:00
users/21551 (tweaked per users/21560): new git subtree completion
This commit is contained in:
parent
8468f24af4
commit
92d516cfa7
|
@ -1,3 +1,8 @@
|
|||
2016-07-05 Oliver Kiddle <opk@zsh.org>
|
||||
|
||||
* Jordan Klassen: users/21551 (tweaked per users/21560):
|
||||
Completion/Unix/Command/_git: new git subtree completion
|
||||
|
||||
2016-07-05 Daniel Shahaf <d.s@daniel.shahaf.name>
|
||||
|
||||
* 38728: Test/D02glob.ztst: Tests: Add tests for the ':a' and
|
||||
|
|
|
@ -1747,6 +1747,91 @@ _git-submodule () {
|
|||
return ret
|
||||
}
|
||||
|
||||
(( $+functions[_git-subtree] )) ||
|
||||
_git-subtree () {
|
||||
local curcontext="$curcontext" state state_descr line ret=1
|
||||
declare -A opt_args
|
||||
|
||||
# TODO: -P should only complete paths inside the current repository.
|
||||
_arguments -C \
|
||||
'(-q --quiet)'{-q,--quiet}'[suppress progress output]' \
|
||||
'(-P --prefix)'{-P,--prefix=}'[the path to the subtree in the repository to manipulate]: :_directories' \
|
||||
'-d[show debug messages]' \
|
||||
': :->command' \
|
||||
'*::: := ->option-or-argument' && ret=0
|
||||
|
||||
case $state in
|
||||
(command)
|
||||
declare -a commands
|
||||
|
||||
commands=(
|
||||
add:'create the subtree by importing its contents'
|
||||
merge:'merge recent changes up to specified commit into the subtree'
|
||||
pull:'fetch from remote repository and merge recent changes into the subtree'
|
||||
push:'does a split and `git push`'
|
||||
split:'extract a new synthetic project history from a subtree')
|
||||
|
||||
_describe -t commands command commands && ret=0
|
||||
;;
|
||||
(option-or-argument)
|
||||
curcontext=${curcontext%:*}-$line[1]:
|
||||
case $line[1] in
|
||||
(add)
|
||||
_arguments \
|
||||
'(-q --quiet)'{-q,--quiet}'[suppress progress output]' \
|
||||
'(-m --message)'{-m,--message}'[use the given message as the commit message for the merge commit]' \
|
||||
'(-P --prefix)'{-P,--prefix=}'[the path to the subtree in the repository to manipulate]: :_directories' \
|
||||
'--squash[import only a single commit from the subproject]' \
|
||||
': :__git_any_repositories_or_references' \
|
||||
':: :__git_ref_specs' && ret=0
|
||||
;;
|
||||
(merge)
|
||||
_arguments -S \
|
||||
'(-q --quiet)'{-q,--quiet}'[suppress progress output]' \
|
||||
'(-P --prefix)'{-P,--prefix=}'[the path to the subtree in the repository to manipulate]: :_directories' \
|
||||
'(-m --message)'{-m,--message}'[use the given message as the commit message for the merge commit]' \
|
||||
'--squash[import only a single commit from the subproject]' \
|
||||
': :__git_references' && ret=0
|
||||
;;
|
||||
(pull)
|
||||
_arguments -S \
|
||||
'(-q --quiet)'{-q,--quiet}'[suppress progress output]' \
|
||||
'(-P --prefix)'{-P,--prefix=}'[the path to the subtree in the repository to manipulate]: :_directories' \
|
||||
'(-m --message)'{-m,--message}'[use the given message as the commit message for the merge commit]' \
|
||||
'--squash[import only a single commit from the subproject]' \
|
||||
': :__git_any_repositories' \
|
||||
':: :__git_ref_specs' && ret=0
|
||||
;;
|
||||
(push)
|
||||
_arguments -S \
|
||||
'(-q --quiet)'{-q,--quiet}'[suppress progress output]' \
|
||||
'(-P --prefix)'{-P,--prefix=}'[the path to the subtree in the repository to manipulate]: :_directories' \
|
||||
'(-m --message)'{-m,--message}'[use the given message as the commit message for the merge commit]' \
|
||||
': :__git_any_repositories' \
|
||||
':: :__git_ref_specs' && ret=0
|
||||
;;
|
||||
(split)
|
||||
_arguments -S \
|
||||
'(-q --quiet)'{-q,--quiet}'[suppress progress output]' \
|
||||
'(-P --prefix)'{-P,--prefix=}'[the path to the subtree in the repository to manipulate]: :_directories' \
|
||||
'(-b --branch)'{-b,--branch=}'[create a new branch]' \
|
||||
'--onto=[try connecting new tree to an existing one]: :__git_ref_specs' \
|
||||
'(-m --message)'{-m,--message}'[use the given message as the commit message for the merge commit]' \
|
||||
'--ignore-joins[ignore prior --rejoin commits]' \
|
||||
'--onto=[try connecting new tree to an existing one]: :__git_ref_specs' \
|
||||
'--rejoin[use the given message as the commit message for the merge commit]' \
|
||||
'*: :__git_references' && ret=0
|
||||
;;
|
||||
(*)
|
||||
_default && ret=0
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
(( $+functions[_git-tag] )) ||
|
||||
_git-tag () {
|
||||
local -a message_opts
|
||||
|
@ -6274,6 +6359,13 @@ __git_any_repositories () {
|
|||
'remote-repositories::__git_remote_repositories'
|
||||
}
|
||||
|
||||
(( $+functions[__git_any_repositories_or_references] )) ||
|
||||
__git_any_repositories_or_references () {
|
||||
_alternative \
|
||||
'repositories::__git_any_repositories' \
|
||||
'references::__git_references'
|
||||
}
|
||||
|
||||
# Common Guards
|
||||
|
||||
(( $+functions[__git_guard] )) ||
|
||||
|
|
Loading…
Reference in New Issue