229a1c971903aaae0bebf73dfda41cb71c25560c
- Author
- Prajjwal Singh <sin@prajjwal.com>
- Committer
- Marc Cornellà <marc.cornella@live.com>
- Date
Message
Diff
This diff is truncated to protect this page.
1diff --git a/plugins/gitfast/_git b/plugins/gitfast/_git
2index 78a6dbb3d19adb2940d5ea67dc3ffb9c26ba0dbd..886bf95d1f5940987f5c4411097fd09b000be037 100644
3--- a/plugins/gitfast/_git
4+++ b/plugins/gitfast/_git
5@@ -30,7 +30,7 @@ if [ -z "$script" ]; then
6 local -a locations
7 local e
8 locations=(
9- "$(dirname ${funcsourcetrace[1]%:*})/git-completion.bash"
10+ $(dirname ${funcsourcetrace[1]%:*})/git-completion.bash
11 '/etc/bash_completion.d/git' # fedora, old debian
12 '/usr/share/bash-completion/completions/git' # arch, ubuntu, new debian
13 '/usr/share/bash-completion/git' # gentoo
14@@ -39,7 +39,7 @@ if [ -z "$script" ]; then
15 test -f $e && script="$e" && break
16 done
17 fi
18-ZSH_VERSION='' . "$script"
19+GIT_SOURCING_ZSH_COMPLETION=y . "$script"
20
21 __gitcomp ()
22 {
23@@ -93,13 +93,22 @@ __gitcomp_nl_append ()
24 compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
25 }
26
27+__gitcomp_file_direct ()
28+{
29+ emulate -L zsh
30+
31+ local IFS=$'\n'
32+ compset -P '*[=:]'
33+ compadd -f -- ${=1} && _ret=0
34+}
35+
36 __gitcomp_file ()
37 {
38 emulate -L zsh
39
40 local IFS=$'\n'
41 compset -P '*[=:]'
42- compadd -Q -p "${2-}" -f -- ${=1} && _ret=0
43+ compadd -p "${2-}" -f -- ${=1} && _ret=0
44 }
45
46 __git_zsh_bash_func ()
47@@ -223,10 +232,8 @@ _git ()
48
49 if (( $+functions[__${service}_zsh_main] )); then
50 __${service}_zsh_main
51- elif (( $+functions[__${service}_main] )); then
52+ else
53 emulate ksh -c __${service}_main
54- elif (( $+functions[_${service}] )); then
55- emulate ksh -c _${service}
56 fi
57
58 let _ret && _default && _ret=0
59diff --git a/plugins/gitfast/git-completion.bash b/plugins/gitfast/git-completion.bash
60index b6ff5dc0840e3667434b9d7f614007ae9bbfc77a..e087c4bf0085add8e968e128db6b667acbc80320 100644
61--- a/plugins/gitfast/git-completion.bash
62+++ b/plugins/gitfast/git-completion.bash
63@@ -29,13 +29,16 @@
64 # tell the completion to use commit completion. This also works with aliases
65 # of form "!sh -c '...'". For example, "!sh -c ': git commit ; ... '".
66 #
67+# Compatible with bash 3.2.57.
68+#
69 # You can set the following environment variables to influence the behavior of
70 # the completion routines:
71 #
72 # GIT_COMPLETION_CHECKOUT_NO_GUESS
73 #
74 # When set to "1", do not include "DWIM" suggestions in git-checkout
75-# completion (e.g., completing "foo" when "origin/foo" exists).
76+# and git-switch completion (e.g., completing "foo" when "origin/foo"
77+# exists).
78
79 case "$COMP_WORDBREAKS" in
80 *:*) : great ;;
81@@ -92,6 +95,70 @@ __git ()
82 ${__git_dir:+--git-dir="$__git_dir"} "$@" 2>/dev/null
83 }
84
85+# Removes backslash escaping, single quotes and double quotes from a word,
86+# stores the result in the variable $dequoted_word.
87+# 1: The word to dequote.
88+__git_dequote ()
89+{
90+ local rest="$1" len ch
91+
92+ dequoted_word=""
93+
94+ while test -n "$rest"; do
95+ len=${#dequoted_word}
96+ dequoted_word="$dequoted_word${rest%%[\\\'\"]*}"
97+ rest="${rest:$((${#dequoted_word}-$len))}"
98+
99+ case "${rest:0:1}" in
100+ \\)
101+ ch="${rest:1:1}"
102+ case "$ch" in
103+ $'\n')
104+ ;;
105+ *)
106+ dequoted_word="$dequoted_word$ch"
107+ ;;
108+ esac
109+ rest="${rest:2}"
110+ ;;
111+ \')
112+ rest="${rest:1}"
113+ len=${#dequoted_word}
114+ dequoted_word="$dequoted_word${rest%%\'*}"
115+ rest="${rest:$((${#dequoted_word}-$len+1))}"
116+ ;;
117+ \")
118+ rest="${rest:1}"
119+ while test -n "$rest" ; do
120+ len=${#dequoted_word}
121+ dequoted_word="$dequoted_word${rest%%[\\\"]*}"
122+ rest="${rest:$((${#dequoted_word}-$len))}"
123+ case "${rest:0:1}" in
124+ \\)
125+ ch="${rest:1:1}"
126+ case "$ch" in
127+ \"|\\|\$|\`)
128+ dequoted_word="$dequoted_word$ch"
129+ ;;
130+ $'\n')
131+ ;;
132+ *)
133+ dequoted_word="$dequoted_word\\$ch"
134+ ;;
135+ esac
136+ rest="${rest:2}"
137+ ;;
138+ \")
139+ rest="${rest:1}"
140+ break
141+ ;;
142+ esac
143+ done
144+ ;;
145+ esac
146+ done
147+}
148+
149 # The following function is based on code from:
150 #
151 # bash_completion - programmable completion functions for bash 3.2+
152@@ -264,9 +331,32 @@ __gitcomp ()
153 case "$cur_" in
154 --*=)
155 ;;
156+ --no-*)
157+ local c i=0 IFS=$' \t\n'
158+ for c in $1; do
159+ if [[ $c == "--" ]]; then
160+ continue
161+ fi
162+ c="$c${4-}"