e92a4667cbd65e9567dc962b5a482e10f319596a
- Author
- Felipe Contreras <felipe.contreras@gmail.com>
- Committer
- GitHub <noreply@github.com>
- Date
Message
Diff
This diff is truncated to protect this page.
1diff --git a/plugins/gitfast/_git b/plugins/gitfast/_git
2index aaea581d522a0527b32cb48a7c5b2cdbdb2548bb..988f5b1c6ea794ba4dac0d180e5dee8f8ebbdcfc 100644
3--- a/plugins/gitfast/_git
4+++ b/plugins/gitfast/_git
5@@ -45,71 +45,49 @@ fi
6
7 local old_complete="$functions[complete]"
8 functions[complete]=:
9+COMP_WORDBREAKS=':'
10 GIT_SOURCING_ZSH_COMPLETION=y . "$script"
11 functions[complete]="$old_complete"
12
13+__gitcompadd ()
14+{
15+ compadd -Q -p "${2-}" -S "${3- }" ${@[4,-1]} -- ${=1} && _ret=0
16+}
17+
18 __gitcomp ()
19 {
20 emulate -L zsh
21
22 local cur_="${3-$cur}"
23
24- case "$cur_" in
25- --*=)
26- ;;
27- --no-*)
28- local c IFS=$' \t\n'
29- local -a array
30- for c in ${=1}; do
31- if [[ $c == "--" ]]; then
32- continue
33- fi
34- c="$c${4-}"
35- case $c in
36- --*=|*.) ;;
37- *) c="$c " ;;
38- esac
39- array+=("$c")
40- done
41- compset -P '*[=:]'
42- compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
43- ;;
44- *)
45- local c IFS=$' \t\n'
46- local -a array
47- for c in ${=1}; do
48- if [[ $c == "--" ]]; then
49- c="--no-...${4-}"
50- array+=("$c ")
51- break
52- fi
53- c="$c${4-}"
54- case $c in
55- --*=|*.) ;;
56- *) c="$c " ;;
57- esac
58- array+=("$c")
59- done
60- compset -P '*[=:]'
61- compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
62- ;;
63- esac
64-}
65+ [[ "$cur_" == *= ]] && return
66
67-__gitcomp_direct ()
68-{
69- emulate -L zsh
70+ local c IFS=$' \t\n' sfx
71+ for c in ${=1}; do
72+ if [[ $c == "--" ]]; then
73+ [[ "$cur_" == --no-* ]] && continue
74+ __gitcompadd "--no-..."
75+ break
76+ fi
77
78- compset -P '*[=:]'
79- compadd -Q -S '' -- ${(f)1} && _ret=0
80+ if [[ -z "${4-}" ]]; then
81+ case $c in
82+ *=) c="${c%=}"; sfx="=" ;;
83+ *.) sfx="" ;;
84+ *) sfx=" " ;;
85+ esac
86+ else
87+ sfx="$4"
88+ fi
89+ __gitcompadd "$c" "${2-}" "$sfx" -q
90+ done
91 }
92
93 __gitcomp_nl ()
94 {
95 emulate -L zsh
96
97- compset -P '*[=:]'
98- compadd -Q -S "${4- }" -p "${2-}" -- ${(f)1} && _ret=0
99+ IFS=$'\n' __gitcompadd "$1" "${2-}" "${4- }"
100 }
101
102 __gitcomp_file ()
103@@ -119,9 +97,14 @@ __gitcomp_file ()
104 compadd -f -p "${2-}" -- ${(f)1} && _ret=0
105diff --git a/plugins/gitfast/git-completion.bash b/plugins/gitfast/git-completion.bash
106index b93706d177e2b89ef176ce1a4ce9293af065a63c..4497a294f66a942b47ecaa322d994cc656e74999 100644
107--- a/plugins/gitfast/git-completion.bash
108+++ b/plugins/gitfast/git-completion.bash
109@@ -45,11 +45,6 @@
110 # When set to "1" suggest all options, including options which are
111 # typically hidden (e.g. '--allow-empty' for 'git commit').
112
113-case "$COMP_WORDBREAKS" in
114-*:*) : great ;;
115-*) COMP_WORDBREAKS="$COMP_WORDBREAKS:"
116-esac
117-
118 # Discovers the path to the git repository taking any '--git-dir=<path>' and
119 # '-C <path>' options into account and stores it in the $__git_repo_path
120 # variable.
121@@ -347,7 +342,7 @@ __gitcomp ()
122 local cur_="${3-$cur}"
123
124 case "$cur_" in
125- --*=)
126+ *=)
127 ;;
128 --no-*)
129 local c i=0 IFS=$' \t\n'
130@@ -519,7 +514,7 @@ __gitcomp_builtin ()
131 local incl="${2-}"
132 local excl="${3-}"
133
134- local var=__gitcomp_builtin_"${cmd/-/_}"
135+ local var=__gitcomp_builtin_"${cmd//-/_}"
136 local options
137 eval "options=\${$var-}"
138
139@@ -1231,26 +1226,44 @@ __git_pretty_aliases ()
140 # __git_aliased_command requires 1 argument
141 __git_aliased_command ()
142 {
143- local word cmdline=$(__git config --get "alias.$1")
144- for word in $cmdline; do
145- case "$word" in
146- \!gitk|gitk)
147- echo "gitk"
148- return
149- ;;
150- \!*) : shell command alias ;;
151- -*) : option ;;
152- *=*) : setting env ;;
153- git) : git itself ;;
154- \(\)) : skip parens of shell function definition ;;
155- {) : skip start of shell helper function ;;
156- :) : skip null command ;;
157- \'*) : skip opening quote after sh -c ;;
158- *)
159- echo "$word"
160+ local cur=$1 last list word cmdline
161+
162+ while [[ -n "$cur" ]]; do
163+ if [[ "$list" == *" $cur "* ]]; then
164+ # loop detected
165 return
166- esac
167+ fi
168+
169+ cmdline=$(__git config --get "alias.$cur")
170+ list=" $cur $list"
171+ last=$cur
172+ cur=
173+
174+ for word in $cmdline; do
175+ case "$word" in
176+ \!gitk|gitk)
177+ cur="gitk"
178+ break
179+ ;;
180+ \!*) : shell command alias ;;
181+ -*) : option ;;
182+ *=*) : setting env ;;
183+ git) : git itself ;;
184+ \(\)) : skip parens of shell function definition ;;
185+ {) : skip start of shell helper function ;;
186+ :) : skip null command ;;
187+ \'*) : skip opening quote after sh -c ;;
188+ *)
189+ cur="$word"
190+ break
191+ esac
192+ done
193 done
194+
195+ cur=$last
196+ if [[ "$cur" != "$1" ]]; then
197+ echo "$cur"
198+ fi
199 }
200
201 # Check whether one of the given words is present on the command line,
202@@ -2723,10 +2736,10 @@ __git_complete_config_variable_name ()
203 return
204 ;;
205 branch.*)
206- local pfx="${cur%.*}."
207- cur_="${cur#*.}"
208+ local pfx="${cur_%.*}."
209diff --git a/plugins/gitfast/update b/plugins/gitfast/update
210index d0947e7d82be1d79cc527774779f900334d8947c..5311065a1103a2c6c4442f35d260d0f90e5a389c 100755
211--- a/plugins/gitfast/update
212+++ b/plugins/gitfast/update
213@@ -1,7 +1,7 @@
214 #!/bin/sh
215
216 url="https://raw.githubusercontent.com/felipec/git-completion"
217-version="1.0"
218+version="1.2"
219
220 curl -s -o _git "${url}/v${version}/git-completion.zsh" &&
221 curl -s -o git-completion.bash "${url}/v${version}/git-completion.bash" &&