1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
|
# (C) 2011-2025 magicant
# Completion script for the "git-branch" command.
# Supports Git 2.48.1.
function completion/git-branch {
WORDS=(git branch "${WORDS[2,-1]}")
command -f completion//reexecute
}
function completion/git::branch:arg {
OPTIONS=( #>#
"--abbrev:; specify the number of commit ID digits to print"
"a --all; print local and remote-tracking branches"
"--color::; show symbols in color"
"--column::; columnize output"
"--contains; show branches that contain the specified commit only"
"C; copy a branch, overwriting an existing branch"
"c --copy; copy a branch"
"l --create-reflog; enable reflog for the new branch"
"D; delete a branch that has not been merged"
"d --delete; delete a branch"
"--edit; edit the branch explanation with an editor"
"f --force; overwrite an existing branch"
"--format:; specify an output format"
"i --ignore-case; sort and filter branches case-insensitively"
"l --list; list branches matching the operand pattern"
"M; rename a branch, overwriting an existing branch"
"--merged; show branches that are contained in the specified commit only"
"m --move; rename a branch"
"--no-abbrev; print full commit IDs"
"--no-color; like --color=never"
"--no-column; print branches line by line"
"--no-contains; show branches that don't contain the specified commit"
"--no-merged; show branches that aren't contained in the specified commit only"
"--no-track; create a non-tracking branch"
"--omit-empty; don't print empty items"
"--points-at; show branches that point at the specified commit"
"q --quiet; print error messages only"
"--recurse-submodules; propagate branches in submodules"
"r --remotes; print or delete remote-tracking branches"
"--set-upstream; like --track, but don't move HEAD"
"u: --set-upstream-to:; set the upstream to the specified one"
"--show-current; show the current branch name"
"--sort:; specify the sort order"
"t:: --track::; create a remote-tracking branch"
"--unset-upstream; remove the upstream"
"v --verbose; print commit ID and summary for each branch"
) #<#
command -f completion//parseoptions -n
case $ARGOPT in
(-)
command -f completion//completeoptions
;;
(--abbrev)
;;
(t|--color|--column|--sort|--track)
command -f completion/git::$ARGOPT:arg
;;
(--format)
#TODO
;;
(u|--set-upstream-to)
command -f completion/git::completeref --remotes
;;
('')
typeset i=2 all=false delete=false
while [ $i -le ${WORDS[#]} ]; do
case ${WORDS[i]} in
(--)
i=$((i+1))
break
;;
(--merged|--no-merged|--contains)
all=true
break
;;
(--*)
i=$((i+1))
;;
(-*[Dd]*)
delete=true
break
;;
(-?*)
i=$((i+1))
;;
(*)
break
;;
esac
done
if ! $all && $delete || [ $i -gt ${WORDS[#]} ]; then
command -f completion/git::completeref --branches
else
command -f completion/git::completeref
fi
;;
esac
}
# vim: set ft=sh ts=8 sts=8 sw=8 et:
|