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 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273
|
# (C) 2013-2025 magicant
# Completion script for the "git-submodule" command.
# Supports Git 2.48.1.
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 case "${WORDS[2]}" in (--cached|-q|--quiet) true ;; (*) false ;; esac; 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
;;
(-*)
OPTIONS=("$OPTIONS" #>#
"--cached; print status of the superproject index"
) #<#
command -f completion//parseoptions
command -f completion//completeoptions
;;
(*) #>>#
complete -P "$PREFIX" -D "move the git directories from submodules to the superproject" absorbgitdirs
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 "set the default tracking branch for a submodule" set-branch
complete -P "$PREFIX" -D "set the URL of a submodule" set-url
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:absorbgitdirs:arg {
complete -P "$PREFIX" -S / -T -d
}
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"
"--dissociate; stop borrowing objects after cloning"
"f --force; add an ignored path"
"--name:; specify the name of the submodule"
"--progress; force progress reporting"
"--reference:; specify a reference repository to share objects (possibly dangerous operation)"
"--ref-format:; specify a ref storage format"
) #<#
command -f completion//parseoptions
case $ARGOPT in
(-)
command -f completion//completeoptions -e
;;
# (b|--branch)
# ;;
# (--name)
# ;;
(--reference)
complete -P "$PREFIX" -S / -T -d
;;
(--ref-format)
command -f completion/git::--ref-format:arg
;;
('')
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" #>#
"--all; unregister all submodules"
"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:set-branch:arg {
OPTIONS=("$OPTIONS" #>#
"b: --branch:; specify a branch of the submodule to track"
"d --default; reset to the remote's default branch"
) #<#
command -f completion//parseoptions
case $ARGOPT in
(-)
command -f completion//completeoptions
;;
('')
complete -P "$PREFIX" -S / -T -d
;;
esac
}
function completion/git::submodule:set-url:arg {
complete -P "$PREFIX" -S / -T -d
}
function completion/git::submodule:status:arg {
OPTIONS=("$OPTIONS" #>#
"--cached; print status of the superproject 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 superproject HEAD and index"
"--files; compare the superproject 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" #>#
"--checkout; check out in submodules"
"--depth:; specify the max number of history to clone"
"--dissociate; stop borrowing objects after cloning"
"--filter:; partial-clone by applying a filter"
"f --force; overwrite local changes or ignore unmerged files"
"--init; do \"git submodule init\" before updating"
"--jobs:; specify the max number of submodules to clone in parallel"
"--merge; merge in submodules"
"N --no-fetch; don't fetch from submodule remotes"
"--no-recommend-shallow; always fully clone submodules"
"--no-single-branch; clone all branches"
"--progress; force progress reporting"
"--rebase; rebase in submodules"
"--recommend-shallow; shallow-clone if recommended in .gitmodules"
"--recursive; operate on all submodules recursively"
"--reference:; specify a reference repository to share objects (possibly dangerous operation)"
"--ref-format:; specify a ref storage format"
"--remote; update submodules to their remote's latest commit"
"--single-branch; clone only the target branch"
) #<#
command -f completion//parseoptions
case $ARGOPT in
(-)
command -f completion//completeoptions
;;
(--filter|--ref-format)
command -f "completion/git::$ARGOPT:arg"
;;
(--reference|'')
complete -P "$PREFIX" -S / -T -d
;;
esac
}
# vim: set ft=sh ts=8 sts=8 sw=8 et:
|