summaryrefslogtreecommitdiffstats
path: root/Completion/Unix/Command/_git
diff options
context:
space:
mode:
authorOliver Kiddle <okiddle@yahoo.co.uk>2019-09-27 00:16:54 +0200
committerOliver Kiddle <okiddle@yahoo.co.uk>2019-09-27 00:16:54 +0200
commit0ff02590c38cfb54c5df9002ceac898225b8fdd1 (patch)
treee4975ab977a65f97f072b08fda2ab49759972e07 /Completion/Unix/Command/_git
parentunposted (see 44772): quote the string argument to zle -U (diff)
downloadzsh-0ff02590c38cfb54c5df9002ceac898225b8fdd1.tar
zsh-0ff02590c38cfb54c5df9002ceac898225b8fdd1.tar.gz
zsh-0ff02590c38cfb54c5df9002ceac898225b8fdd1.tar.bz2
zsh-0ff02590c38cfb54c5df9002ceac898225b8fdd1.tar.lz
zsh-0ff02590c38cfb54c5df9002ceac898225b8fdd1.tar.xz
zsh-0ff02590c38cfb54c5df9002ceac898225b8fdd1.tar.zst
zsh-0ff02590c38cfb54c5df9002ceac898225b8fdd1.zip
44779: completion for new git switch and git restore commands
Diffstat (limited to 'Completion/Unix/Command/_git')
-rw-r--r--Completion/Unix/Command/_git175
1 files changed, 154 insertions, 21 deletions
diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index afe62915d..29fa379a7 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -451,26 +451,27 @@ _git-checkout () {
declare -A opt_args
_arguments -C -s \
- '(-q --quiet --progress)'{-q,--quiet}'[suppress progress reporting]' \
+ '(-q --quiet)'{-q,--quiet}'[suppress progress reporting]' \
'(-f --force -m --merge --conflict --patch)'{-f,--force}'[force branch switch/ignore unmerged entries]' \
'(-q --quiet -2 --ours -3 --theirs --patch)'{-2,--ours}'[check out stage #2 for unmerged paths]' \
'(-q --quiet -2 --ours -3 --theirs --patch)'{-3,--theirs}'[check out stage #3 for unmerged paths]' \
- '( -B --orphan -2 --ours -3 --theirs --conflict --patch --detach)-b+[create a new branch based at given commit]: :__git_branch_names' \
- '(-b --orphan -2 --ours -3 --theirs --conflict --patch --detach)-B+[create or update branch based at given commit]: :__git_branch_names' \
- '(-t --track --orphan --patch --detach)'{-t,--track}'[set up configuration so pull merges from the base commit]' \
+ '( -B --orphan -2 --ours -3 --theirs --conflict --patch -d --detach)-b+[create a new branch based at given commit]: :__git_branch_names' \
+ '(-b --orphan -2 --ours -3 --theirs --conflict --patch -d --detach)-B+[create or update branch based at given commit]: :__git_branch_names' \
+ '(-t --track --orphan --patch -d --detach)'{-t,--track}'[set up configuration so pull merges from the base commit]' \
'(--patch)--no-track[override the branch.autosetupmerge configuration variable]' \
$new_branch_reflog_opt \
- '(-b -B -t --track --patch --orphan)--detach[detach the HEAD at named commit]' \
- '(-b -B -t --track --patch --detach)--orphan=[create a new orphan branch based at given commit]: :__git_branch_names' \
+ '(-b -B -t --track --patch --orphan -d --detach)'{-d,--detach}'[detach the HEAD at named commit]' \
+ '(-b -B -t --track --patch -d --detach)--orphan=[create a new orphan branch based at given commit]: :__git_branch_names' \
'(-q --quiet -f --force -m --merge --conflict --patch)'{-m,--merge}'[3way merge current branch, working tree and new branch]' \
'(-q --quiet -f --force -m --merge --patch)--conflict=[same as --merge, using given merge style]:style:(merge diff3)' \
'(-)'{-p,--patch}'[interactively select hunks in diff between given tree-ish and working tree]' \
"--ignore-skip-worktree-bits[don't limit pathspecs to sparse entries only]" \
- "--no-guess[don't second guess 'git checkout <no-such-branch>']" \
+ "--no-guess[don't second guess 'git checkout <no-such-branch>']" '!(--no-guess)--guess' \
"--ignore-other-worktrees[don't check if another worktree is holding the given ref]" \
'--recurse-submodules=-[control recursive updating of submodules]::checkout:__git_commits' \
'--no-overlay[remove files from index or working tree that are not in the tree-ish]' \
- '(-q --quiet)--progress[force progress reporting]' \
+ '(-q --quiet --progress)--no-progress[suppress progress reporting]' \
+ '--progress[force progress reporting]' \
'(-)--[start file arguments]' \
'*:: :->branch-or-tree-ish-or-file' && ret=0
@@ -484,7 +485,6 @@ _git-checkout () {
if (( CURRENT == 1 )) && [[ -z $opt_args[(I)--] ]]; then
# TODO: Allow A...B
local \
- remote_branch_noprefix_arg='remote-branch-names-noprefix::__git_remote_branch_names_noprefix' \
tree_ish_arg='tree-ishs::__git_commits_prefer_recent' \
file_arg='modified-files::__git_modified_files'
@@ -492,13 +492,13 @@ _git-checkout () {
_alternative $tree_ish_arg && ret=0
elif [[ -n $opt_args[(I)--track] ]]; then
_alternative remote-branches::__git_remote_branch_names && ret=0
- elif [[ -n ${opt_args[(I)--ours|--theirs|-m|--conflict|--patch]} ]]; then
+ elif [[ -n ${opt_args[(I)--ours|--theirs|-m|--conflict|--patch|--no-guess]} ]]; then
_alternative $tree_ish_arg $file_arg && ret=0
else
_alternative \
$file_arg \
$tree_ish_arg \
- $remote_branch_noprefix_arg \
+ 'remote-branch-names-noprefix::__git_remote_branch_names_noprefix' \
&& ret=0
fi
@@ -522,6 +522,7 @@ _git-cherry-pick () {
_arguments \
'(- :)--quit[end revert or cherry-pick sequence]' \
'(- :)--continue[resume revert or cherry-pick sequence]' \
+ '(- :)--skip[skip current commit and continue]' \
'(- :)--abort[cancel revert or cherry-pick sequence]' \
'--cleanup=[specify how to strip spaces and #comments from message]:mode:_git_cleanup_modes' \
'--allow-empty[preserve initially empty commits]' \
@@ -645,6 +646,7 @@ _git-clone () {
'(-4 --ipv4 -6 --ipv6)'{-4,--ipv4}'[use IPv4 addresses only]' \
'(-4 --ipv4 -6 --ipv6)'{-6,--ipv6}'[use IPv6 addresses only]' \
'--filter=[object filtering]:filter:_git_rev-list_filters' \
+ '--remote-submodules[any cloned submodules will use their remote-tracking branch]' \
': :->repository' \
': :_directories' && ret=0
@@ -875,6 +877,7 @@ _git-fetch () {
\*{-o+,--server-option=}'[send specified string to the server when using protocol version 2]:option' \
'--negotiation-tip=[only report refs reachable from specified object to the server]:commit:__git_commits' \
'--filter=[object filtering]:filter:_git_rev-list_filters' \
+ "--auto-gc[run 'gc --auto' after fetching]" \
'*:: :->repository-or-group-or-refspec' && ret=0
case $state in
@@ -1224,8 +1227,9 @@ _git-merge () {
'(--edit --no-edit)-e[open an editor to change the commit message]' \
'( --no-rerere-autoupdate)--rerere-autoupdate[allow the rerere mechanism to update the index]' \
'(--rerere-autoupdate )--no-rerere-autoupdate[do not allow the rerere mechanism to update the index]' \
- '--abort[restore the original branch and abort the merge operation]' \
- '--continue[continue the current in-progress merge]' \
+ '(--quit --continue)--abort[restore the original branch and abort the merge operation]' \
+ '(--abort --continue)--quit[--abort but leave index and working tree alone]' \
+ '(--abort --quit)--continue[continue the current in-progress merge]' \
'--progress[force progress reporting]' \
'--verify[verify commit-msg hook]' \
'*: : __git_commits -O expl:git_commit_opts'
@@ -1540,12 +1544,57 @@ _git-reset () {
return ret
}
+(( $+functions[_git-restore] )) ||
+_git-restore() {
+ local curcontext="$curcontext" state line expl ret=1
+ local -A opt_args
+
+ _arguments -C -s -S \
+ '(-s --source)'{-s,--source}'[specify which tree-ish to checkout from]:source tree:->sources' \
+ '(-S --staged)'{-S,--staged}'[restore the index]' \
+ '(-W --worktree)'{-W,--worktree}'[restore the working tree (default)]' \
+ '--ignore-unmerged[ignore unmerged entries]' \
+ '--overlay[never remove files when restoring]' '!(--overlay)--no-overlay' \
+ '(-q --quiet --no-progress)'{-q,--quiet}'[suppress feedback messages]' \
+ '--recurse-submodules=-[control recursive updating of submodules]::checkout:__git_commits' \
+ '(-q --quiet --progress)--no-progress[suppress progress reporting]' \
+ '(--no-progress)--progress[force progress reporting]' \
+ '(-m --merge)'{-m,--merge}'[perform a 3-way merge with the new branch]' \
+ '--conflict=[change how conflicting hunks are presented]:conflict style [merge]:(merge diff3)' \
+ '(-2 --ours -3 --theirs -m --merge)'{-2,--ours}'[checkout our version for unmerged files]' \
+ '(-2 --ours -3 --theirs -m --merge)'{-3,--theirs}'[checkout their version for unmerged files]' \
+ '(-p --patch)'{-p,--patch}'[select hunks interactively]' \
+ "--ignore-skip-worktree-bits[don't limit pathspecs to sparse entries only]" \
+ '*:path spec:->pathspecs' && ret=0
+
+ case $state in
+ pathspecs)
+ if [[ -z ${opt_args[(I)-s|--source|-S|--staged]} ]] &&
+ # use index as a default base unless -S is specified
+ __git_ignore_line __git_modified_files
+ then
+ ret=0
+ else
+ __git_ignore_line __git_tree_files ${PREFIX:-.} ${(Qv)opt_args[(i)-s|--source]:-HEAD} && ret=0
+ fi
+ ;;
+ sources)
+ # if a path has already been specified, use it to select commits
+ git_commit_opts=(-- $line)
+ __git_commits_prefer_recent -O expl:git_commit_opts && ret=0
+ ;;