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 magicant
# Completion script for the "git-fetch" command.
# Supports Git 1.7.7.
function completion/git-fetch {
WORDS=(git fetch "${WORDS[2,-1]}")
command -f completion//reexecute
}
function completion/git::fetch:arg {
OPTIONS=( #>#
"--dry-run; don't actually fetch anything"
"--multiple; allow specifying multiple remotes"
"p --prune; delete remote-tracking branches that no longer exist on the remote"
"q --quiet; don't report progress"
"--submodule-prefix" # not for command line use
"--recurse-submodules-default::" # not for command line use
"t --tags; fetch all tags from the remote"
"v --verbose" # TODO description
) #<#
command -f completion/git::fetch:getopt
command -f completion//parseoptions -n
case $ARGOPT in
(-)
command -f completion//completeoptions
;;
(--recurse-submodules|--upload-pack)
command -f completion/git::$ARGOPT:arg
;;
(--recurse-submodules-default)
;;
# (--depth)
# ;;
('')
typeset i=2 multiple=false
while [ $i -le ${WORDS[#]} ]; do
case ${WORDS[i]} in
(--)
i=$((i+1))
break
;;
(--multiple)
multiple=true
break
;;
(-?*)
i=$((i+1))
;;
(*)
break
;;
esac
done
if $multiple || [ $i -gt ${WORDS[#]} ]; then
#TODO complete remote URI
command -f completion/git::completeremote
{ command -vf completion/git::completeremotegroup >/dev/null 2>&1 ||
. -AL completion/git-remote; } &&
command -f completion/git::completeremotegroup
elif [ "${WORDS[-1]}" = tag ]; then
command -f completion/git::completeref --tags
else
typeset word="${TARGETWORD#"$PREFIX"}"
word=${word#+}
case $word in
(*:*) # complete local refs
word=${word#*:}
PREFIX=${TARGETWORD%"$word"}
command -f completion/git::completeref
;;
(*) # complete remote refs
PREFIX=${TARGETWORD%"$word"}
command -f completion/git::completeremoteref "${WORDS[i]}"
;;
esac
fi
;;
esac
}
function completion/git::fetch:getopt {
typeset fetch=
case ${gitcmd-} in
fetch) fetch=true;;
esac
OPTIONS=("$OPTIONS" #>#
"--all; fetch all remotes"
"a --append; append to (not overwrite) existing FETCH_HEAD"
"--depth:; specify the max number of history to fetch"
"f --force; allow non-fast-forward update"
"k --keep; keep downloaded pack"
"--no-recurse-submodules; don't fetch submodules"
"${fetch+n} --no-tags; don't fetch tags automatically"
"--progress; report progress"
"--recurse-submodules::; specify whether to fetch submodules"
"u --update-head-ok" # not for command line use
"--upload-pack:; specify a path for git-upload-pack on the remote host"
) #<#
}
# vim: set ft=sh ts=8 sts=8 sw=8 noet:
|