Skip to content

Commit

Permalink
Add git-restore completion
Browse files Browse the repository at this point in the history
Co-authored-by: WATANABE Yuki <[email protected]>
  • Loading branch information
unrealapex and magicant committed Nov 6, 2024
1 parent 0fe038e commit eb1bae5
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
1 change: 1 addition & 0 deletions share/completion/git
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ function completion/git::completecmd { #>>#
complete -P "$PREFIX" -D "print a message that helps a pull request" request-pull
# discouraged: complete -P "$PREFIX" -D "" rerere
complete -P "$PREFIX" -D "restore the index and working tree" reset
complete -P "$PREFIX" -D "restore the working tree files" restore
complete -P "$PREFIX" -D "list commit objects" rev-list
complete -P "$PREFIX" -D "parse git command arguments" rev-parse
complete -P "$PREFIX" -D "undo some commits" revert
Expand Down
48 changes: 48 additions & 0 deletions share/completion/git-restore
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# (C) 2024 unrealapex

# Completion script for the "git-restore" command.

function completion/git-restore {
WORDS=(git restore "${WORDS[2,-1]}")
command -f completion//reexecute
}

function completion/git::restore:arg {

OPTIONS=( #>#
"s: --source:; specify which tree-ish to checkout from"
"p --patch; select hunks interactively"
"W --worktree; restore the working tree"
"S --staged; restore the index"
"q --quiet; suppress feedback messages"
"--progress; force progress reporting"
"--no-progress; suppress progress reporting"
"--ours; checkout our version for unmerged files"
"--theirs; checkout their version for unmerged files"
"m --merge; perform a 3-way merge with the new branch"
"--conflict:; change how conflicting hunks are presented"
"--ignore-unmerged; ignore unmerged entries"
"--ignore-skip-worktree-bits; don't limit pathspecs to sparse entries only"
"--recurse-submodules; control recursive updating of submodules"
"--no-recurse-submodules; ignore recursive updating of submodules"
"--overlay; never remove files when restoring."
"--no-overlay; remove tracked files that do not appear in the --source tree"
"--pathspec-from-file:; read pathspec from file"
"--pathspec-file-nul; pathspec elements are separated with NUL character"
"--; do not interpret any more arguments as options"
) #<#

command -f completion//parseoptions -n
case $ARGOPT in
(-)
command -f completion//completeoptions
;;
('')
command -f completion/git::completepath
;;
esac

}


# vim: set ft=sh ts=8 sts=8 sw=8 et:

0 comments on commit eb1bae5

Please sign in to comment.