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 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
|
# (C) 2013-2016 magicant
# Completion script for the "git-submodule" command.
# Supports Git 1.8.1.4.
function completion/git-submodule {
WORDS=(git submodule "${WORDS[2,-1]}")
command -f completion//reexecute
}
function completion/git::submodule:arg {
OPTIONS=( #>#
"q --quiet; print error messages only"
) #<#
while [ x"${WORDS[2]}" = x"-q" ] || [ x"${WORDS[2]}" = x"--quiet" ]; do
WORDS=("${WORDS[1]}" "${WORDS[3,-1]}")
done
if [ ${WORDS[#]} -le 1 ]; then
case ${TARGETWORD#"$PREFIX"} in
(-q) # avoid completing "-q" to "-qq"
complete -P "$PREFIX" -- -q
;;
(-*)
command -f completion//parseoptions
command -f completion//completeoptions
;;
(*) #>>#
complete -P "$PREFIX" -D "add a submodule" add
complete -P "$PREFIX" -D "unregister submodules" deinit
complete -P "$PREFIX" -D "execute a shell command in each submodule" foreach
complete -P "$PREFIX" -D "configure submodules according to .gitmodules" init
complete -P "$PREFIX" -D "show status of submodules" status
complete -P "$PREFIX" -D "print summary of changes in submodules" summary
complete -P "$PREFIX" -D "reset submodule remote URL" sync
complete -P "$PREFIX" -D "clone and check out submodules" update
;; #<<#
esac
else
WORDS=("${WORDS[2,-1]}")
if command -vf "completion/git::submodule:${WORDS[1]}:arg" >/dev/null 2>&1; then
command -f "completion/git::submodule:${WORDS[1]}:arg"
fi
fi
}
function completion/git::submodule:add:arg {
OPTIONS=("$OPTIONS" #>#
"b: --branch:; specify a branch of the submodule to clone"
"--depth:; specify the max number of history to clone"
"f --force; add an ignored path"
"--name:; specify the name of the submodule"
"--reference:; specify a reference repository to share objects (possibly dangerous operation)"
) #<#
command -f completion//parseoptions
case $ARGOPT in
(-)
command -f completion//completeoptions -e
;;
# (b|--branch)
# ;;
# (--name)
# ;;
(--reference)
complete -P "$PREFIX" -S / -T -d
;;
('')
command -f completion//getoperands
if command -vf completion/git::clone:opr >/dev/null 2>&1 ||
. -AL completion/git-clone; then
command -f completion/git::clone:opr
fi
;;
esac
}
function completion/git::submodule:deinit:arg {
OPTIONS=("$OPTIONS" #>#
"f --force; overwrite local changes or ignore unmerged files"
) #<#
command -f completion//parseoptions
case $ARGOPT in
(-)
command -f completion//completeoptions
;;
('')
complete -P "$PREFIX" -S / -T -d
;;
esac
}
function completion/git::submodule:foreach:arg {
OPTIONS=("$OPTIONS" #>#
"--recursive; operate on all submodules recursively"
) #<#
command -f completion//parseoptions
case $ARGOPT in
(-)
command -f completion//completeoptions
;;
('')
command -f completion//getoperands
command -f completion//reexecute -e
;;
esac
}
function completion/git::submodule:init:arg {
complete -P "$PREFIX" -S / -T -d
}
function completion/git::submodule:status:arg {
OPTIONS=("$OPTIONS" #>#
"--cached; print status of the supermodule index"
"--recursive; operate on all submodules recursively"
) #<#
command -f completion//parseoptions
case $ARGOPT in
(-)
command -f completion//completeoptions
;;
('')
complete -P "$PREFIX" -S / -T -d
;;
esac
}
function completion/git::submodule:summary:arg {
OPTIONS=("$OPTIONS" #>#
"--cached; compare the supermodule HEAD and index"
"--files; compare the supermodule index with the submodule HEAD"
"n: --summary-limit:; specify the max number of commits to show"
) #<#
command -f completion//parseoptions
case $ARGOPT in
(-)
command -f completion//completeoptions
;;
# (n|--summary-limit)
# ;;
('')
command -f completion//getoperands
if [ ${WORDS[#]} -eq 0 ]; then
command -f completion/git::completeref
fi
complete -P "$PREFIX" -S / -T -d
;;
esac
}
function completion/git::submodule:sync:arg {
OPTIONS=("$OPTIONS" #>#
"--recursive; operate on all submodules recursively"
) #<#
command -f completion//parseoptions
case $ARGOPT in
(-)
command -f completion//completeoptions
;;
('')
complete -P "$PREFIX" -S / -T -d
;;
esac
}
function completion/git::submodule:update:arg {
OPTIONS=("$OPTIONS" #>#
"--depth:; specify the max number of history to clone"
"f --force; overwrite local changes or ignore unmerged files"
"--init; do \"git submodule init\" before updating"
"--merge; merge in submodules"
"N --no-fetch; don't fetch from submodule remotes"
"--rebase; rebase in submodules"
"--recursive; operate on all submodules recursively"
"--reference:; specify a reference repository to share objects (possibly dangerous operation)"
"--remote; update submodules to their remote's latest commit"
) #<#
command -f completion//parseoptions
case $ARGOPT in
(-)
command -f completion//completeoptions
;;
(--reference)
complete -P "$PREFIX" -S / -T -d
;;
('')
complete -P "$PREFIX" -S / -T -d
;;
esac
}
# vim: set ft=sh ts=8 sts=8 sw=8 noet:
|