Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
magicant committed Feb 21, 2025
1 parent 02b3310 commit 97566e1
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 21 deletions.
5 changes: 5 additions & 0 deletions share/completion/git
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,11 @@ function completion/git::--sort:arg {
# TODO
}

function completion/git::--track:arg { #>>#
complete -P "$PREFIX" -D "use start-point branch as upstream" direct
complete -P "$PREFIX" -D "copy remote-tracking branch from start-point branch" inherit
} #<<#

function completion/git::--untracked-files:arg { #>>#
complete -P "$PREFIX" -D "print all individual files in untracked directories" all
complete -P "$PREFIX" -D "print untracked files and directories" normal
Expand Down
6 changes: 1 addition & 5 deletions share/completion/git-branch
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function completion/git::branch:arg {
;;
(--abbrev)
;;
(--color|--column|--sort)
(t|--color|--column|--sort|--track)
command -f completion/git::$ARGOPT:arg
;;
(--format)
Expand All @@ -65,10 +65,6 @@ function completion/git::branch:arg {
(u|--set-upstream-to)
command -f completion/git::completeref --remotes
;;
(t|--track) #>>#
complete -P "$PREFIX" -D "use start-point branch as upstream" direct
complete -P "$PREFIX" -D "copy remote-tracking branch from start-point branch" inherit
;; #<<#
('')
typeset i=2 all=false delete=false
while [ $i -le ${WORDS[#]} ]; do
Expand Down
7 changes: 3 additions & 4 deletions share/completion/git-checkout
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,9 @@ function completion/git::checkout:arg {
(--pathspec-from-file)
complete -P "$PREFIX" -f
;;
(t|--track) #>>#
complete -P "$PREFIX" -D "use start-point branch as upstream" direct
complete -P "$PREFIX" -D "copy remote-tracking branch from start-point branch" inherit
;; #<<#
(t|--track)
command -f completion/git::--track:arg
;;
('')
command -f completion/git::completerefpath
;;
Expand Down
9 changes: 7 additions & 2 deletions share/completion/git-switch
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# (C) 2023 Victorien Elvinger
# (C) 2025 magicant

# Completion script for the "git-switch" command.
# Supports Git 2.23.0.
# Supports Git 2.48.1.

function completion/git-switch {
WORDS=(git switch "${WORDS[2,-1]}")
Expand All @@ -27,7 +28,7 @@ function completion/git::switch:arg {
"--progress; report progress status on standard error"
"q --quiet; print error and warning messages only"
"--recurse-submodules; update the content of all active submodules"
"t --track; create a tracking branch"
"t:: --track::; create a tracking branch"
) #<#

command -f completion//parseoptions
Expand All @@ -41,7 +42,11 @@ function completion/git::switch:arg {
(--conflict) #>>#
complete -P "$PREFIX" -D "ours and theirs" merge
complete -P "$PREFIX" -D "ours, theirs, and original" diff3
complete -P "$PREFIX" zdiff3
;; #<<#
(t|--track)
command -f completion/git::--track:arg
;;
('')
# Parse options that modify completion behavior,
# and find first non-option argument.
Expand Down
44 changes: 34 additions & 10 deletions share/completion/git-tag
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# (C) 2011 magicant
# (C) 2011-2025 magicant

# Completion script for the "git-tag" command.
# Supports Git 1.7.7.
# Supports Git 2.48.1.

function completion/git-tag {
WORDS=(git tag "${WORDS[2,-1]}")
Expand All @@ -11,24 +11,43 @@ function completion/git-tag {
function completion/git::tag:arg {

OPTIONS=( #>#
"a; make an unsigned annotated tag"
"a --annotate; make an unsigned annotated tag"
"--cleanup:; specify the way the message is cleaned up"
"--color::; show in color"
"--column::; columnize output"
"--contains:; list tags that are ancestors of the specified commit"
"d; delete tags"
"F:; specify a file containing the message"
"--create-reflog; enable reflog for the new tag"
"d --delete; delete tags"
"e --edit; edit the tag message"
"F: --file:; specify a file containing the message"
"f --force; overwrite an existing tag"
"l; list tag names that match an operand"
"m:; specify the message"
"--format:; specify an output format"
"i --ignore-case; sort and filter tags case-insensitively"
"l --list; list tag names that match an operand"
"u: --local-user:; specify a key to make a GPG-signed tag with"
"m: --message:; specify the message"
"--merged:; list tags that are descendants of the specified commit"
"n::; specify the number of lines of annotation to print"
"s; make a GPG-signed tag with the default email address's key"
"u:; specify a key to make a GPG-signed tag with"
"v; verify tags"
"--no-column; print tags line by line"
"--no-contains:; list tags that are not ancestors of the specified commit"
"--no-merged:; list tags that are not descendants of the specified commit"
"--no-sign; don't GPG-sign the tag"
"--omit-empty; don't print empty items"
"--points-at:; list tags that point at the specified commit"
"s --sign; make a GPG-signed tag with the default email address's key"
"--sort:; sort listed tags"
"--trailer:; specify token-value pair to append to the message"
"v --verify; verify the GPG signature of tags"
) #<#

command -f completion//parseoptions -n
case $ARGOPT in
(-)
command -f completion//completeoptions
;;
(--cleanup|--color|--column|--format|--sort)
command -f completion/git::$ARGOPT:arg
;;
(--contains)
command -f completion/git::completeref
;;
Expand All @@ -40,6 +59,11 @@ function completion/git::tag:arg {
i=$((i+1))
break
;;
(--contains|--delete|--list|--merged| \
--no-contains|--no-merged|--points-at|--verify)
nomake=true
break
;;
(--*)
i=$((i+1))
;;
Expand Down

0 comments on commit 97566e1

Please sign in to comment.