|
23 | 23 | # 3) Consider changing your PS1 to also show the current branch,
|
24 | 24 | # see git-prompt.sh for details.
|
25 | 25 |
|
26 |
| -if [[ -n ${ZSH_VERSION-} ]]; then |
27 |
| - autoload -U +X bashcompinit && bashcompinit |
28 |
| -fi |
29 |
| - |
30 | 26 | case "$COMP_WORDBREAKS" in
|
31 | 27 | *:*) : great ;;
|
32 | 28 | *) COMP_WORDBREAKS="$COMP_WORDBREAKS:"
|
@@ -169,7 +165,6 @@ __git_reassemble_comp_words_by_ref()
|
169 | 165 | }
|
170 | 166 |
|
171 | 167 | if ! type _get_comp_words_by_ref >/dev/null 2>&1; then
|
172 |
| -if [[ -z ${ZSH_VERSION:+set} ]]; then |
173 | 168 | _get_comp_words_by_ref ()
|
174 | 169 | {
|
175 | 170 | local exclude cur_ words_ cword_
|
@@ -197,32 +192,6 @@ _get_comp_words_by_ref ()
|
197 | 192 | shift
|
198 | 193 | done
|
199 | 194 | }
|
200 |
| -else |
201 |
| -_get_comp_words_by_ref () |
202 |
| -{ |
203 |
| - while [ $# -gt 0 ]; do |
204 |
| - case "$1" in |
205 |
| - cur) |
206 |
| - cur=${COMP_WORDS[COMP_CWORD]} |
207 |
| - ;; |
208 |
| - prev) |
209 |
| - prev=${COMP_WORDS[COMP_CWORD-1]} |
210 |
| - ;; |
211 |
| - words) |
212 |
| - words=("${COMP_WORDS[@]}") |
213 |
| - ;; |
214 |
| - cword) |
215 |
| - cword=$COMP_CWORD |
216 |
| - ;; |
217 |
| - -n) |
218 |
| - # assume COMP_WORDBREAKS is already set sanely |
219 |
| - shift |
220 |
| - ;; |
221 |
| - esac |
222 |
| - shift |
223 |
| - done |
224 |
| -} |
225 |
| -fi |
226 | 195 | fi
|
227 | 196 |
|
228 | 197 | # Generates completion reply with compgen, appending a space to possible
|
@@ -2430,20 +2399,69 @@ __gitk_main ()
|
2430 | 2399 | __git_complete_revlist
|
2431 | 2400 | }
|
2432 | 2401 |
|
2433 |
| -__git_func_wrap () |
2434 |
| -{ |
2435 |
| - if [[ -n ${ZSH_VERSION-} ]]; then |
2436 |
| - emulate -L bash |
2437 |
| - setopt KSH_TYPESET |
| 2402 | +if [[ -n ${ZSH_VERSION-} ]]; then |
| 2403 | + echo "WARNING: this script is deprecated, please see git-completion.zsh" 1>&2 |
2438 | 2404 |
|
2439 |
| - # workaround zsh's bug that leaves 'words' as a special |
2440 |
| - # variable in versions < 4.3.12 |
2441 |
| - typeset -h words |
| 2405 | + __gitcomp () |
| 2406 | + { |
| 2407 | + emulate -L zsh |
2442 | 2408 |
|
2443 |
| - # workaround zsh's bug that quotes spaces in the COMPREPLY |
2444 |
| - # array if IFS doesn't contain spaces. |
2445 |
| - typeset -h IFS |
2446 |
| - fi |
| 2409 | + local cur_="${3-$cur}" |
| 2410 | + |
| 2411 | + case "$cur_" in |
| 2412 | + --*=) |
| 2413 | + ;; |
| 2414 | + *) |
| 2415 | + local c IFS=$' \t\n' |
| 2416 | + local -a array |
| 2417 | + for c in ${=1}; do |
| 2418 | + c="$c${4-}" |
| 2419 | + case $c in |
| 2420 | + --*=*|*.) ;; |
| 2421 | + *) c="$c " ;; |
| 2422 | + esac |
| 2423 | + array+=("$c") |
| 2424 | + done |
| 2425 | + compset -P '*[=:]' |
| 2426 | + compadd -Q -S '' -p "${2-}" -a -- array && _ret=0 |
| 2427 | + ;; |
| 2428 | + esac |
| 2429 | + } |
| 2430 | + |
| 2431 | + __gitcomp_nl () |
| 2432 | + { |
| 2433 | + emulate -L zsh |
| 2434 | + |
| 2435 | + local IFS=$'\n' |
| 2436 | + compset -P '*[=:]' |
| 2437 | + compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0 |
| 2438 | + } |
| 2439 | + |
| 2440 | + __git_zsh_helper () |
| 2441 | + { |
| 2442 | + emulate -L ksh |
| 2443 | + local cur cword prev |
| 2444 | + cur=${words[CURRENT-1]} |
| 2445 | + prev=${words[CURRENT-2]} |
| 2446 | + let cword=CURRENT-1 |
| 2447 | + __${service}_main |
| 2448 | + } |
| 2449 | + |
| 2450 | + _git () |
| 2451 | + { |
| 2452 | + emulate -L zsh |
| 2453 | + local _ret=1 |
| 2454 | + __git_zsh_helper |
| 2455 | + let _ret && _default -S '' && _ret=0 |
| 2456 | + return _ret |
| 2457 | + } |
| 2458 | + |
| 2459 | + compdef _git git gitk |
| 2460 | + return |
| 2461 | +fi |
| 2462 | + |
| 2463 | +__git_func_wrap () |
| 2464 | +{ |
2447 | 2465 | local cur words cword prev
|
2448 | 2466 | _get_comp_words_by_ref -n =: cur words cword prev
|
2449 | 2467 | $1
|
|
0 commit comments