]>
Commit | Line | Data |
---|---|---|
a42577d4 | 1 | #!bash |
690d8824 | 2 | # |
b5a49471 | 3 | # bash/zsh completion support for core Git. |
690d8824 | 4 | # |
c70680ce | 5 | # Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org> |
690d8824 | 6 | # Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/). |
c70680ce | 7 | # Distributed under the GNU General Public License, version 2.0. |
690d8824 JH |
8 | # |
9 | # The contained completion routines provide support for completing: | |
10 | # | |
11 | # *) local and remote branch names | |
12 | # *) local and remote tag names | |
13 | # *) .git/remotes file names | |
14 | # *) git 'subcommands' | |
15 | # *) tree paths within 'ref:path/to/file' expressions | |
c70680ce | 16 | # *) common --long-options |
690d8824 JH |
17 | # |
18 | # To use these routines: | |
19 | # | |
20 | # 1) Copy this file to somewhere (e.g. ~/.git-completion.sh). | |
b5a49471 | 21 | # 2) Add the following line to your .bashrc/.zshrc: |
06f44c3c | 22 | # source ~/.git-completion.sh |
af31a456 FC |
23 | # 3) Consider changing your PS1 to also show the current branch, |
24 | # see git-prompt.sh for details. | |
690d8824 | 25 | |
db8a9ff0 SP |
26 | case "$COMP_WORDBREAKS" in |
27 | *:*) : great ;; | |
28 | *) COMP_WORDBREAKS="$COMP_WORDBREAKS:" | |
29 | esac | |
30 | ||
a42577d4 TP |
31 | # __gitdir accepts 0 or 1 arguments (i.e., location) |
32 | # returns location of .git repo | |
873537fa SP |
33 | __gitdir () |
34 | { | |
ac3eb1c3 JH |
35 | # Note: this function is duplicated in git-prompt.sh |
36 | # When updating it, make sure you update the other one to match. | |
25a31f81 | 37 | if [ -z "${1-}" ]; then |
5c9cc64a | 38 | if [ -n "${__git_dir-}" ]; then |
67ffa114 | 39 | echo "$__git_dir" |
b7be4366 SG |
40 | elif [ -n "${GIT_DIR-}" ]; then |
41 | test -d "${GIT_DIR-}" || return 1 | |
42 | echo "$GIT_DIR" | |
67ffa114 SP |
43 | elif [ -d .git ]; then |
44 | echo .git | |
45 | else | |
46 | git rev-parse --git-dir 2>/dev/null | |
47 | fi | |
48 | elif [ -d "$1/.git" ]; then | |
49 | echo "$1/.git" | |
50 | else | |
51 | echo "$1" | |
52 | fi | |
873537fa SP |
53 | } |
54 | ||
ab02dfe5 SP |
55 | __gitcomp_1 () |
56 | { | |
3bf421ea | 57 | local c IFS=$' \t\n' |
ab02dfe5 | 58 | for c in $1; do |
3bf421ea FC |
59 | c="$c$2" |
60 | case $c in | |
61 | --*=*|*.) ;; | |
62 | *) c="$c " ;; | |
ab02dfe5 | 63 | esac |
3bf421ea | 64 | printf '%s\n' "$c" |
ab02dfe5 SP |
65 | done |
66 | } | |
67 | ||
dbda3b10 JN |
68 | # The following function is based on code from: |
69 | # | |
70 | # bash_completion - programmable completion functions for bash 3.2+ | |
71 | # | |
72 | # Copyright © 2006-2008, Ian Macdonald <ian@caliban.org> | |
73 | # © 2009-2010, Bash Completion Maintainers | |
74 | # <bash-completion-devel@lists.alioth.debian.org> | |
75 | # | |
76 | # This program is free software; you can redistribute it and/or modify | |
77 | # it under the terms of the GNU General Public License as published by | |
78 | # the Free Software Foundation; either version 2, or (at your option) | |
79 | # any later version. | |
80 | # | |
81 | # This program is distributed in the hope that it will be useful, | |
82 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
83 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
84 | # GNU General Public License for more details. | |
85 | # | |
86 | # You should have received a copy of the GNU General Public License | |
87 | # along with this program; if not, write to the Free Software Foundation, | |
88 | # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
89 | # | |
90 | # The latest version of this software can be obtained here: | |
91 | # | |
92 | # http://bash-completion.alioth.debian.org/ | |
93 | # | |
94 | # RELEASE: 2.x | |
95 | ||
96 | # This function can be used to access a tokenized list of words | |
97 | # on the command line: | |
98 | # | |
99 | # __git_reassemble_comp_words_by_ref '=:' | |
100 | # if test "${words_[cword_-1]}" = -w | |
101 | # then | |
102 | # ... | |
103 | # fi | |
104 | # | |
105 | # The argument should be a collection of characters from the list of | |
106 | # word completion separators (COMP_WORDBREAKS) to treat as ordinary | |
107 | # characters. | |
108 | # | |
109 | # This is roughly equivalent to going back in time and setting | |
110 | # COMP_WORDBREAKS to exclude those characters. The intent is to | |
111 | # make option types like --date=<type> and <rev>:<path> easy to | |
112 | # recognize by treating each shell word as a single token. | |
113 | # | |
114 | # It is best not to set COMP_WORDBREAKS directly because the value is | |
115 | # shared with other completion scripts. By the time the completion | |
116 | # function gets called, COMP_WORDS has already been populated so local | |
117 | # changes to COMP_WORDBREAKS have no effect. | |
118 | # | |
119 | # Output: words_, cword_, cur_. | |
120 | ||
121 | __git_reassemble_comp_words_by_ref() | |
122 | { | |
123 | local exclude i j first | |
124 | # Which word separators to exclude? | |
125 | exclude="${1//[^$COMP_WORDBREAKS]}" | |
126 | cword_=$COMP_CWORD | |
127 | if [ -z "$exclude" ]; then | |
128 | words_=("${COMP_WORDS[@]}") | |
129 | return | |
130 | fi | |
131 | # List of word completion separators has shrunk; | |
132 | # re-assemble words to complete. | |
133 | for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)); do | |
134 | # Append each nonempty word consisting of just | |
135 | # word separator characters to the current word. | |
136 | first=t | |
137 | while | |
138 | [ $i -gt 0 ] && | |
139 | [ -n "${COMP_WORDS[$i]}" ] && | |
140 | # word consists of excluded word separators | |
141 | [ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ] | |
142 | do | |
143 | # Attach to the previous token, | |
144 | # unless the previous token is the command name. | |
145 | if [ $j -ge 2 ] && [ -n "$first" ]; then | |
146 | ((j--)) | |
147 | fi | |
148 | first= | |
149 | words_[$j]=${words_[j]}${COMP_WORDS[i]} | |
150 | if [ $i = $COMP_CWORD ]; then | |
151 | cword_=$j | |
152 | fi | |
153 | if (($i < ${#COMP_WORDS[@]} - 1)); then | |
154 | ((i++)) | |
155 | else | |
156 | # Done. | |
157 | return | |
158 | fi | |
159 | done | |
160 | words_[$j]=${words_[j]}${COMP_WORDS[i]} | |
161 | if [ $i = $COMP_CWORD ]; then | |
162 | cword_=$j | |
163 | fi | |
164 | done | |
165 | } | |
166 | ||
da48616f PD |
167 | if ! type _get_comp_words_by_ref >/dev/null 2>&1; then |
168 | _get_comp_words_by_ref () | |
169 | { | |
dbda3b10 JN |
170 | local exclude cur_ words_ cword_ |
171 | if [ "$1" = "-n" ]; then | |
172 | exclude=$2 | |
173 | shift 2 | |
174 | fi | |
175 | __git_reassemble_comp_words_by_ref "$exclude" | |
176 | cur_=${words_[cword_]} | |
da48616f PD |
177 | while [ $# -gt 0 ]; do |
178 | case "$1" in | |
179 | cur) | |
dbda3b10 | 180 | cur=$cur_ |
da48616f PD |
181 | ;; |
182 | prev) | |
dbda3b10 | 183 | prev=${words_[$cword_-1]} |
da48616f PD |
184 | ;; |
185 | words) | |
dbda3b10 | 186 | words=("${words_[@]}") |
da48616f PD |
187 | ;; |
188 | cword) | |
dbda3b10 | 189 | cword=$cword_ |
da48616f PD |
190 | ;; |
191 | esac | |
192 | shift | |
193 | done | |
194 | } | |
195 | fi | |
196 | ||
f674bb80 SG |
197 | # Generates completion reply with compgen, appending a space to possible |
198 | # completion words, if necessary. | |
199 | # It accepts 1 to 4 arguments: | |
200 | # 1: List of possible completion words. | |
201 | # 2: A prefix to be added to each possible completion word (optional). | |
202 | # 3: Generate possible completion matches for this word (optional). | |
203 | # 4: A suffix to be appended to each possible completion word (optional). | |
72e5e989 SP |
204 | __gitcomp () |
205 | { | |
583e4d57 | 206 | local cur_="${3-$cur}" |
9244d69b | 207 | |
9244d69b | 208 | case "$cur_" in |
5447aac7 SG |
209 | --*=) |
210 | COMPREPLY=() | |
5447aac7 SG |
211 | ;; |
212 | *) | |
ab02dfe5 | 213 | local IFS=$'\n' |
25a31f81 TP |
214 | COMPREPLY=($(compgen -P "${2-}" \ |
215 | -W "$(__gitcomp_1 "${1-}" "${4-}")" \ | |
9244d69b | 216 | -- "$cur_")) |
5447aac7 SG |
217 | ;; |
218 | esac | |
72e5e989 SP |
219 | } |
220 | ||
a31e6262 SG |
221 | # Generates completion reply with compgen from newline-separated possible |
222 | # completion words by appending a space to all of them. | |
223 | # It accepts 1 to 4 arguments: | |
224 | # 1: List of possible completion words, separated by a single newline. | |
225 | # 2: A prefix to be added to each possible completion word (optional). | |
226 | # 3: Generate possible completion matches for this word (optional). | |
227 | # 4: A suffix to be appended to each possible completion word instead of | |
228 | # the default space (optional). If specified but empty, nothing is | |
229 | # appended. | |
230 | __gitcomp_nl () | |
231 | { | |
583e4d57 | 232 | local IFS=$'\n' |
666ca59a | 233 | COMPREPLY=($(compgen -P "${2-}" -S "${4- }" -W "$1" -- "${3-$cur}")) |
a31e6262 SG |
234 | } |
235 | ||
5de40f59 SP |
236 | __git_heads () |
237 | { | |
6486ca6d | 238 | local dir="$(__gitdir)" |
5de40f59 | 239 | if [ -d "$dir" ]; then |
05e8b3d6 SG |
240 | git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ |
241 | refs/heads | |
5de40f59 SP |
242 | return |
243 | fi | |
5de40f59 SP |
244 | } |
245 | ||
88e21dc7 SP |
246 | __git_tags () |
247 | { | |
6486ca6d | 248 | local dir="$(__gitdir)" |
88e21dc7 | 249 | if [ -d "$dir" ]; then |
05e8b3d6 SG |
250 | git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ |
251 | refs/tags | |
88e21dc7 SP |
252 | return |
253 | fi | |
88e21dc7 SP |
254 | } |
255 | ||
34a6bbb5 KB |
256 | # __git_refs accepts 0, 1 (to pass to __gitdir), or 2 arguments |
257 | # presence of 2nd argument means use the guess heuristic employed | |
258 | # by checkout for tracking branches | |
690d8824 JH |
259 | __git_refs () |
260 | { | |
d8c0453e | 261 | local i hash dir="$(__gitdir "${1-}")" track="${2-}" |
da4902a7 | 262 | local format refs |
873537fa | 263 | if [ -d "$dir" ]; then |
608efb87 SG |
264 | case "$cur" in |
265 | refs|refs/*) | |
266 | format="refname" | |
267 | refs="${cur%/*}" | |
34a6bbb5 | 268 | track="" |
608efb87 SG |
269 | ;; |
270 | *) | |
d23e7570 IWC |
271 | for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do |
272 | if [ -e "$dir/$i" ]; then echo $i; fi | |
273 | done | |
608efb87 SG |
274 | format="refname:short" |
275 | refs="refs/tags refs/heads refs/remotes" | |
276 | ;; | |
277 | esac | |
278 | git --git-dir="$dir" for-each-ref --format="%($format)" \ | |
279 | $refs | |
34a6bbb5 KB |
280 | if [ -n "$track" ]; then |
281 | # employ the heuristic used by git checkout | |
282 | # Try to find a remote branch that matches the completion word | |
283 | # but only output if the branch name is unique | |
284 | local ref entry | |
285 | git --git-dir="$dir" for-each-ref --shell --format="ref=%(refname:short)" \ | |
286 | "refs/remotes/" | \ | |
6f2dd720 | 287 | while read -r entry; do |
34a6bbb5 KB |
288 | eval "$entry" |
289 | ref="${ref#*/}" | |
290 | if [[ "$ref" == "$cur"* ]]; then | |
291 | echo "$ref" | |
292 | fi | |
4db42b38 | 293 | done | sort | uniq -u |
34a6bbb5 | 294 | fi |
35e65ecc | 295 | return |
690d8824 | 296 | fi |
fb772cca SG |
297 | case "$cur" in |
298 | refs|refs/*) | |
299 | git ls-remote "$dir" "$cur*" 2>/dev/null | \ | |
6f2dd720 | 300 | while read -r hash i; do |
fb772cca SG |
301 | case "$i" in |
302 | *^{}) ;; | |
303 | *) echo "$i" ;; | |
304 | esac | |
305 | done | |
306 | ;; | |
307 | *) | |
308 | git ls-remote "$dir" HEAD ORIG_HEAD 'refs/tags/*' 'refs/heads/*' 'refs/remotes/*' 2>/dev/null | \ | |
6f2dd720 | 309 | while read -r hash i; do |
fb772cca SG |
310 | case "$i" in |
311 | *^{}) ;; | |
312 | refs/*) echo "${i#refs/*/}" ;; | |
313 | *) echo "$i" ;; | |
314 | esac | |
315 | done | |
316 | ;; | |
317 | esac | |
690d8824 JH |
318 | } |
319 | ||
a42577d4 | 320 | # __git_refs2 requires 1 argument (to pass to __git_refs) |
690d8824 JH |
321 | __git_refs2 () |
322 | { | |
67ffa114 SP |
323 | local i |
324 | for i in $(__git_refs "$1"); do | |
325 | echo "$i:$i" | |
690d8824 JH |
326 | done |
327 | } | |
328 | ||
a42577d4 | 329 | # __git_refs_remotes requires 1 argument (to pass to ls-remote) |
5de40f59 SP |
330 | __git_refs_remotes () |
331 | { | |
48058f5d SG |
332 | local i hash |
333 | git ls-remote "$1" 'refs/heads/*' 2>/dev/null | \ | |
6f2dd720 | 334 | while read -r hash i; do |
48058f5d | 335 | echo "$i:refs/remotes/$1/${i#refs/heads/}" |
5de40f59 SP |
336 | done |
337 | } | |
338 | ||
690d8824 JH |
339 | __git_remotes () |
340 | { | |
d79f81ad FC |
341 | local i IFS=$'\n' d="$(__gitdir)" |
342 | test -d "$d/remotes" && ls -1 "$d/remotes" | |
518ef8f0 TZ |
343 | for i in $(git --git-dir="$d" config --get-regexp 'remote\..*\.url' 2>/dev/null); do |
344 | i="${i#remote.}" | |
345 | echo "${i/.url*/}" | |
56fc25f2 | 346 | done |
690d8824 JH |
347 | } |
348 | ||
eaa4e6ee | 349 | __git_list_merge_strategies () |
4ad91321 | 350 | { |
25b3d4d6 JH |
351 | git merge -s help 2>&1 | |
352 | sed -n -e '/[Aa]vailable strategies are: /,/^$/{ | |
353 | s/\.$// | |
354 | s/.*:// | |
355 | s/^[ ]*// | |
356 | s/[ ]*$// | |
4ad91321 | 357 | p |
25b3d4d6 | 358 | }' |
4ad91321 | 359 | } |
eaa4e6ee JN |
360 | |
361 | __git_merge_strategies= | |
362 | # 'git merge -s help' (and thus detection of the merge strategy | |
363 | # list) fails, unfortunately, if run outside of any git working | |
364 | # tree. __git_merge_strategies is set to the empty string in | |
365 | # that case, and the detection will be repeated the next time it | |
366 | # is needed. | |
367 | __git_compute_merge_strategies () | |
368 | { | |
cf0ff02a FC |
369 | test -n "$__git_merge_strategies" || |
370 | __git_merge_strategies=$(__git_list_merge_strategies) | |
eaa4e6ee | 371 | } |
4ad91321 | 372 | |
1d66ec58 | 373 | __git_complete_revlist_file () |
690d8824 | 374 | { |
da4902a7 | 375 | local pfx ls ref cur_="$cur" |
9244d69b | 376 | case "$cur_" in |
1d66ec58 SG |
377 | *..?*:*) |
378 | return | |
379 | ;; | |
690d8824 | 380 | ?*:*) |
9244d69b SG |
381 | ref="${cur_%%:*}" |
382 | cur_="${cur_#*:}" | |
383 | case "$cur_" in | |
690d8824 | 384 | ?*/*) |
9244d69b SG |
385 | pfx="${cur_%/*}" |
386 | cur_="${cur_##*/}" | |
690d8824 JH |
387 | ls="$ref:$pfx" |
388 | pfx="$pfx/" | |
389 | ;; | |
390 | *) | |
391 | ls="$ref" | |
392 | ;; | |
80152b09 | 393 | esac |
db8a9ff0 SP |
394 | |
395 | case "$COMP_WORDBREAKS" in | |
396 | *:*) : great ;; | |
397 | *) pfx="$ref:$pfx" ;; | |
398 | esac | |
399 | ||
41e6229d | 400 | __gitcomp_nl "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \ |
778306e4 SP |
401 | | sed '/^100... blob /{ |
402 | s,^.* ,, | |
403 | s,$, , | |
404 | } | |
405 | /^120000 blob /{ | |
406 | s,^.* ,, | |
407 | s,$, , | |
408 | } | |
690d8824 JH |
409 | /^040000 tree /{ |
410 | s,^.* ,, | |
411 | s,$,/, | |
412 | } | |
413 | s/^.* //')" \ | |
41e6229d | 414 | "$pfx" "$cur_" "" |
690d8824 | 415 | ;; |
f53352fb | 416 | *...*) |
9244d69b SG |
417 | pfx="${cur_%...*}..." |
418 | cur_="${cur_#*...}" | |
a31e6262 | 419 | __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_" |
f53352fb SP |
420 | ;; |
421 | *..*) | |
9244d69b SG |
422 | pfx="${cur_%..*}.." |
423 | cur_="${cur_#*..}" | |
a31e6262 | 424 | __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_" |
b3391775 | 425 | ;; |
f53352fb | 426 | *) |
a31e6262 | 427 | __gitcomp_nl "$(__git_refs)" |
f53352fb SP |
428 | ;; |
429 | esac | |
430 | } | |
431 | ||
1d66ec58 SG |
432 | |
433 | __git_complete_file () | |
434 | { | |
435 | __git_complete_revlist_file | |
436 | } | |
437 | ||
438 | __git_complete_revlist () | |
439 | { | |
440 | __git_complete_revlist_file | |
441 | } | |
442 | ||
52d5c3b5 JS |
443 | __git_complete_remote_or_refspec () |
444 | { | |
9244d69b | 445 | local cur_="$cur" cmd="${words[1]}" |
0a4e1472 | 446 | local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0 |
f1c6ffe6 | 447 | if [ "$cmd" = "remote" ]; then |
6e8c755f | 448 | ((c++)) |
f1c6ffe6 | 449 | fi |
da48616f PD |
450 | while [ $c -lt $cword ]; do |
451 | i="${words[c]}" | |
52d5c3b5 | 452 | case "$i" in |
e25e2b42 BG |
453 | --mirror) [ "$cmd" = "push" ] && no_complete_refspec=1 ;; |
454 | --all) | |
455 | case "$cmd" in | |
456 | push) no_complete_refspec=1 ;; | |
457 | fetch) | |
458 | COMPREPLY=() | |
459 | return | |
460 | ;; | |
461 | *) ;; | |
462 | esac | |
463 | ;; | |
52d5c3b5 JS |
464 | -*) ;; |
465 | *) remote="$i"; break ;; | |
466 | esac | |
6e8c755f | 467 | ((c++)) |
52d5c3b5 JS |
468 | done |
469 | if [ -z "$remote" ]; then | |
a31e6262 | 470 | __gitcomp_nl "$(__git_remotes)" |
52d5c3b5 JS |
471 | return |
472 | fi | |
0a4e1472 JS |
473 | if [ $no_complete_refspec = 1 ]; then |
474 | COMPREPLY=() | |
475 | return | |
476 | fi | |
52d5c3b5 | 477 | [ "$remote" = "." ] && remote= |
9244d69b | 478 | case "$cur_" in |
52d5c3b5 JS |
479 | *:*) |
480 | case "$COMP_WORDBREAKS" in | |
481 | *:*) : great ;; | |
9244d69b | 482 | *) pfx="${cur_%%:*}:" ;; |
52d5c3b5 | 483 | esac |
9244d69b | 484 | cur_="${cur_#*:}" |
52d5c3b5 JS |
485 | lhs=0 |
486 | ;; | |
487 | +*) | |
488 | pfx="+" | |
9244d69b | 489 | cur_="${cur_#+}" |
52d5c3b5 JS |
490 | ;; |
491 | esac | |
492 | case "$cmd" in | |
493 | fetch) | |
494 | if [ $lhs = 1 ]; then | |
a31e6262 | 495 | __gitcomp_nl "$(__git_refs2 "$remote")" "$pfx" "$cur_" |
52d5c3b5 | 496 | else |
a31e6262 | 497 | __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_" |
52d5c3b5 JS |
498 | fi |
499 | ;; | |
f1c6ffe6 | 500 | pull|remote) |
52d5c3b5 | 501 | if [ $lhs = 1 ]; then |
a31e6262 | 502 | __gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_" |
52d5c3b5 | 503 | else |
a31e6262 | 504 | __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_" |
52d5c3b5 JS |
505 | fi |
506 | ;; | |
507 | push) | |
508 | if [ $lhs = 1 ]; then | |
a31e6262 | 509 | __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_" |
52d5c3b5 | 510 | else |
a31e6262 | 511 | __gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_" |
52d5c3b5 JS |
512 | fi |
513 | ;; | |
514 | esac | |
515 | } | |
516 | ||
3c7b480a JS |
517 | __git_complete_strategy () |
518 | { | |
eaa4e6ee | 519 | __git_compute_merge_strategies |
da48616f | 520 | case "$prev" in |
3c7b480a | 521 | -s|--strategy) |
eaa4e6ee | 522 | __gitcomp "$__git_merge_strategies" |
3c7b480a JS |
523 | return 0 |
524 | esac | |
3c7b480a JS |
525 | case "$cur" in |
526 | --strategy=*) | |
eaa4e6ee | 527 | __gitcomp "$__git_merge_strategies" "" "${cur##--strategy=}" |
3c7b480a JS |
528 | return 0 |
529 | ;; | |
530 | esac | |
531 | return 1 | |
532 | } | |
533 | ||
eaa4e6ee | 534 | __git_list_all_commands () |
f2bb9f88 SP |
535 | { |
536 | local i IFS=" "$'\n' | |
427e586b | 537 | for i in $(git help -a|egrep '^ [a-zA-Z0-9]') |
1eb7e2f8 LM |
538 | do |
539 | case $i in | |
540 | *--*) : helper pattern;; | |
541 | *) echo $i;; | |
542 | esac | |
543 | done | |
544 | } | |
1eb7e2f8 | 545 | |
eaa4e6ee JN |
546 | __git_all_commands= |
547 | __git_compute_all_commands () | |
548 | { | |
cf0ff02a FC |
549 | test -n "$__git_all_commands" || |
550 | __git_all_commands=$(__git_list_all_commands) | |
eaa4e6ee JN |
551 | } |
552 | ||
553 | __git_list_porcelain_commands () | |
1eb7e2f8 | 554 | { |
1eb7e2f8 | 555 | local i IFS=" "$'\n' |
eaa4e6ee | 556 | __git_compute_all_commands |
585b96bd | 557 | for i in $__git_all_commands |
f2bb9f88 SP |
558 | do |
559 | case $i in | |
718a087a | 560 | *--*) : helper pattern;; |
a925c6f1 SP |
561 | applymbox) : ask gittus;; |
562 | applypatch) : ask gittus;; | |
563 | archimport) : import;; | |
2e3a430a | 564 | cat-file) : plumbing;; |
56d99c67 | 565 | check-attr) : plumbing;; |
f2bb9f88 | 566 | check-ref-format) : plumbing;; |
ff2549dc | 567 | checkout-index) : plumbing;; |
f2bb9f88 | 568 | commit-tree) : plumbing;; |
ff2549dc | 569 | count-objects) : infrequent;; |
1dad5c14 SG |
570 | credential-cache) : credentials helper;; |
571 | credential-store) : credentials helper;; | |
a925c6f1 SP |
572 | cvsexportcommit) : export;; |
573 | cvsimport) : import;; | |
f2bb9f88 SP |
574 | cvsserver) : daemon;; |
575 | daemon) : daemon;; | |
5cfb4fe5 SP |
576 | diff-files) : plumbing;; |
577 | diff-index) : plumbing;; | |
578 | diff-tree) : plumbing;; | |
c6ec3b13 | 579 | fast-import) : import;; |
ff2549dc | 580 | fast-export) : export;; |
a925c6f1 | 581 | fsck-objects) : plumbing;; |
f2bb9f88 | 582 | fetch-pack) : plumbing;; |
a925c6f1 | 583 | fmt-merge-msg) : plumbing;; |
56d99c67 | 584 | for-each-ref) : plumbing;; |
f2bb9f88 SP |
585 | hash-object) : plumbing;; |
586 | http-*) : transport;; | |
587 | index-pack) : plumbing;; | |
a925c6f1 | 588 | init-db) : deprecated;; |
f2bb9f88 | 589 | local-fetch) : plumbing;; |
ff2549dc PB |
590 | lost-found) : infrequent;; |
591 | ls-files) : plumbing;; | |
592 | ls-remote) : plumbing;; | |
593 | ls-tree) : plumbing;; | |
f2bb9f88 SP |
594 | mailinfo) : plumbing;; |
595 | mailsplit) : plumbing;; | |
596 | merge-*) : plumbing;; | |
597 | mktree) : plumbing;; | |
598 | mktag) : plumbing;; | |
599 | pack-objects) : plumbing;; | |
600 | pack-redundant) : plumbing;; | |
601 | pack-refs) : plumbing;; | |
602 | parse-remote) : plumbing;; | |
603 | patch-id) : plumbing;; | |
604 | peek-remote) : plumbing;; | |
a925c6f1 SP |
605 | prune) : plumbing;; |
606 | prune-packed) : plumbing;; | |
607 | quiltimport) : import;; | |
f2bb9f88 SP |
608 | read-tree) : plumbing;; |
609 | receive-pack) : plumbing;; | |
63d04a78 | 610 | remote-*) : transport;; |
5c66d0d4 | 611 | repo-config) : deprecated;; |
f2bb9f88 SP |
612 | rerere) : plumbing;; |
613 | rev-list) : plumbing;; | |
614 | rev-parse) : plumbing;; | |
615 | runstatus) : plumbing;; | |
616 | sh-setup) : internal;; | |
617 | shell) : daemon;; | |
ff2549dc | 618 | show-ref) : plumbing;; |
f2bb9f88 SP |
619 | send-pack) : plumbing;; |
620 | show-index) : plumbing;; | |
621 | ssh-*) : transport;; | |
622 | stripspace) : plumbing;; | |
623 | symbolic-ref) : plumbing;; | |
a925c6f1 | 624 | tar-tree) : deprecated;; |
f2bb9f88 SP |
625 | unpack-file) : plumbing;; |
626 | unpack-objects) : plumbing;; | |
a925c6f1 | 627 | update-index) : plumbing;; |
f2bb9f88 SP |
628 | update-ref) : plumbing;; |
629 | update-server-info) : daemon;; | |
630 | upload-archive) : plumbing;; | |
631 | upload-pack) : plumbing;; | |
632 | write-tree) : plumbing;; | |
ff2549dc PB |
633 | var) : infrequent;; |
634 | verify-pack) : infrequent;; | |
a925c6f1 | 635 | verify-tag) : plumbing;; |
f2bb9f88 SP |
636 | *) echo $i;; |
637 | esac | |
638 | done | |
639 | } | |
eaa4e6ee JN |
640 | |
641 | __git_porcelain_commands= | |
642 | __git_compute_porcelain_commands () | |
643 | { | |
644 | __git_compute_all_commands | |
cf0ff02a FC |
645 | test -n "$__git_porcelain_commands" || |
646 | __git_porcelain_commands=$(__git_list_porcelain_commands) | |
eaa4e6ee | 647 | } |
f2bb9f88 | 648 | |
c3898111 SG |
649 | __git_pretty_aliases () |
650 | { | |
651 | local i IFS=$'\n' | |
652 | for i in $(git --git-dir="$(__gitdir)" config --get-regexp "pretty\..*" 2>/dev/null); do | |
653 | case "$i" in | |
654 | pretty.*) | |
655 | i="${i#pretty.}" | |
656 | echo "${i/ */}" | |
657 | ;; | |
658 | esac | |
659 | done | |
660 | } | |
661 | ||
367dce2a DS |
662 | __git_aliases () |
663 | { | |
56fc25f2 | 664 | local i IFS=$'\n' |
518ef8f0 | 665 | for i in $(git --git-dir="$(__gitdir)" config --get-regexp "alias\..*" 2>/dev/null); do |
e0d78059 SB |
666 | case "$i" in |
667 | alias.*) | |
668 | i="${i#alias.}" | |
669 | echo "${i/ */}" | |
670 | ;; | |
671 | esac | |
56fc25f2 | 672 | done |
367dce2a DS |
673 | } |
674 | ||
a42577d4 | 675 | # __git_aliased_command requires 1 argument |
367dce2a DS |
676 | __git_aliased_command () |
677 | { | |
873537fa | 678 | local word cmdline=$(git --git-dir="$(__gitdir)" \ |
e0d10e1c | 679 | config --get "alias.$1") |
367dce2a | 680 | for word in $cmdline; do |
c63437cb | 681 | case "$word" in |
66729509 SG |
682 | \!gitk|gitk) |
683 | echo "gitk" | |
367dce2a | 684 | return |
66729509 | 685 | ;; |
c63437cb SG |
686 | \!*) : shell command alias ;; |
687 | -*) : option ;; | |
688 | *=*) : setting env ;; | |
689 | git) : git itself ;; | |
690 | *) | |
691 | echo "$word" | |
367dce2a | 692 | return |
c63437cb | 693 | esac |
367dce2a DS |
694 | done |
695 | } | |
696 | ||
918c03c2 SG |
697 | # __git_find_on_cmdline requires 1 argument |
698 | __git_find_on_cmdline () | |
3ff1320d | 699 | { |
da4902a7 | 700 | local word subcommand c=1 |
da48616f PD |
701 | while [ $c -lt $cword ]; do |
702 | word="${words[c]}" | |
3ff1320d SG |
703 | for subcommand in $1; do |
704 | if [ "$subcommand" = "$word" ]; then | |
705 | echo "$subcommand" | |
706 | return | |
707 | fi | |
708 | done | |
6e8c755f | 709 | ((c++)) |
3ff1320d SG |
710 | done |
711 | } | |
712 | ||
d773c631 SG |
713 | __git_has_doubledash () |
714 | { | |
da4902a7 | 715 | local c=1 |
da48616f PD |
716 | while [ $c -lt $cword ]; do |
717 | if [ "--" = "${words[c]}" ]; then | |
d773c631 SG |
718 | return 0 |
719 | fi | |
6e8c755f | 720 | ((c++)) |
d773c631 SG |
721 | done |
722 | return 1 | |
723 | } | |
724 | ||
7950659d | 725 | __git_whitespacelist="nowarn warn error error-all fix" |
88329195 SP |
726 | |
727 | _git_am () | |
728 | { | |
da4902a7 | 729 | local dir="$(__gitdir)" |
51ef1daa | 730 | if [ -d "$dir"/rebase-apply ]; then |
85f6b439 | 731 | __gitcomp "--skip --continue --resolved --abort" |
88329195 SP |
732 | return |
733 | fi | |
734 | case "$cur" in | |
735 | --whitespace=*) | |
b3391775 | 736 | __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}" |
88329195 SP |
737 | return |
738 | ;; | |
739 | --*) | |
b3391775 | 740 | __gitcomp " |
43acdf24 | 741 | --3way --committer-date-is-author-date --ignore-date |
86c91f91 | 742 | --ignore-whitespace --ignore-space-change |
43acdf24 | 743 | --interactive --keep --no-utf8 --signoff --utf8 |
af4e9e8c | 744 | --whitespace= --scissors |
b3391775 | 745 | " |
88329195 SP |
746 | return |
747 | esac | |
748 | COMPREPLY=() | |
749 | } | |
750 | ||
751 | _git_apply () | |
752 | { | |
88329195 SP |
753 | case "$cur" in |
754 | --whitespace=*) | |
b3391775 | 755 | __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}" |
88329195 SP |
756 | return |
757 | ;; | |
758 | --*) | |
b3391775 | 759 | __gitcomp " |
88329195 SP |
760 | --stat --numstat --summary --check --index |
761 | --cached --index-info --reverse --reject --unidiff-zero | |
762 | --apply --no-add --exclude= | |
86c91f91 | 763 | --ignore-whitespace --ignore-space-change |
88329195 | 764 | --whitespace= --inaccurate-eof --verbose |
b3391775 | 765 | " |
88329195 SP |
766 | return |
767 | esac | |
768 | COMPREPLY=() | |
769 | } | |
770 | ||
8435b548 SP |
771 | _git_add () |
772 | { | |
d773c631 SG |
773 | __git_has_doubledash && return |
774 | ||
8435b548 SP |
775 | case "$cur" in |
776 | --*) | |
1d284cba SG |
777 | __gitcomp " |
778 | --interactive --refresh --patch --update --dry-run | |
c9a114b5 | 779 | --ignore-errors --intent-to-add |
1d284cba | 780 | " |
8435b548 SP |
781 | return |
782 | esac | |
783 | COMPREPLY=() | |
784 | } | |
785 | ||
b3191ce2 LM |
786 | _git_archive () |
787 | { | |
b3191ce2 LM |
788 | case "$cur" in |
789 | --format=*) | |
790 | __gitcomp "$(git archive --list)" "" "${cur##--format=}" | |
791 | return | |
792 | ;; | |
793 | --remote=*) | |
a31e6262 | 794 | __gitcomp_nl "$(__git_remotes)" "" "${cur##--remote=}" |
b3191ce2 LM |
795 | return |
796 | ;; | |
797 | --*) | |
798 | __gitcomp " | |
799 | --format= --list --verbose | |
800 | --prefix= --remote= --exec= | |
801 | " | |
802 | return | |
803 | ;; | |
804 | esac | |
805 | __git_complete_file | |
806 | } | |
807 | ||
b2e69f62 SP |
808 | _git_bisect () |
809 | { | |
d773c631 SG |
810 | __git_has_doubledash && return |
811 | ||
bf11d461 | 812 | local subcommands="start bad good skip reset visualize replay log run" |
918c03c2 | 813 | local subcommand="$(__git_find_on_cmdline "$subcommands")" |
3ff1320d | 814 | if [ -z "$subcommand" ]; then |
128191f5 SG |
815 | if [ -f "$(__gitdir)"/BISECT_START ]; then |
816 | __gitcomp "$subcommands" | |
817 | else | |
818 | __gitcomp "replay start" | |
819 | fi | |
b2e69f62 SP |
820 | return |
821 | fi | |
822 | ||
3ff1320d | 823 | case "$subcommand" in |
8205ff8e | 824 | bad|good|reset|skip|start) |
a31e6262 | 825 | __gitcomp_nl "$(__git_refs)" |
b2e69f62 SP |
826 | ;; |
827 | *) | |
828 | COMPREPLY=() | |
829 | ;; | |
830 | esac | |
831 | } | |
832 | ||
690d8824 JH |
833 | _git_branch () |
834 | { | |
da4902a7 | 835 | local i c=1 only_local_ref="n" has_r="n" |
b9217642 | 836 | |
da48616f PD |
837 | while [ $c -lt $cword ]; do |
838 | i="${words[c]}" | |
b9217642 SG |
839 | case "$i" in |
840 | -d|-m) only_local_ref="y" ;; | |
841 | -r) has_r="y" ;; | |
842 | esac | |
6e8c755f | 843 | ((c++)) |
b9217642 SG |
844 | done |
845 | ||
da48616f | 846 | case "$cur" in |
ca45d0fa MG |
847 | --set-upstream-to=*) |
848 | __gitcomp "$(__git_refs)" "" "${cur##--set-upstream-to=}" | |
849 | ;; | |
3b376b0c SG |
850 | --*) |
851 | __gitcomp " | |
852 | --color --no-color --verbose --abbrev= --no-abbrev | |
50e61025 | 853 | --track --no-track --contains --merged --no-merged |
04308e9d CMN |
854 | --set-upstream-to= --edit-description --list |
855 | --unset-upstream | |
3b376b0c SG |
856 | " |
857 | ;; | |
b9217642 SG |
858 | *) |
859 | if [ $only_local_ref = "y" -a $has_r = "n" ]; then | |
a31e6262 | 860 | __gitcomp_nl "$(__git_heads)" |
b9217642 | 861 | else |
a31e6262 | 862 | __gitcomp_nl "$(__git_refs)" |
b9217642 SG |
863 | fi |
864 | ;; | |
3b376b0c | 865 | esac |
690d8824 JH |
866 | } |
867 | ||
374a58c9 ML |
868 | _git_bundle () |
869 | { | |
da48616f PD |
870 | local cmd="${words[2]}" |
871 | case "$cword" in | |
8d8163f3 | 872 | 2) |
374a58c9 ML |
873 | __gitcomp "create list-heads verify unbundle" |
874 | ;; | |
8d8163f3 | 875 | 3) |
374a58c9 ML |
876 | # looking for a file |
877 | ;; | |
878 | *) | |
879 | case "$cmd" in | |
880 | create) | |
881 | __git_complete_revlist | |
882 | ;; | |
883 | esac | |
884 | ;; | |
885 | esac | |
886 | } | |
887 | ||
690d8824 JH |
888 | _git_checkout () |
889 | { | |
c84bb14c SG |
890 | __git_has_doubledash && return |
891 | ||
e648f8b6 SG |
892 | case "$cur" in |
893 | --conflict=*) | |
894 | __gitcomp "diff3 merge" "" "${cur##--conflict=}" | |
895 | ;; | |
896 | --*) | |
897 | __gitcomp " | |
898 | --quiet --ours --theirs --track --no-track --merge | |
86e8e7a5 | 899 | --conflict= --orphan --patch |
e648f8b6 SG |
900 | " |
901 | ;; | |
902 | *) | |
34a6bbb5 KB |
903 | # check if --track, --no-track, or --no-guess was specified |
904 | # if so, disable DWIM mode | |
905 | local flags="--track --no-track --no-guess" track=1 | |
906 | if [ -n "$(__git_find_on_cmdline "$flags")" ]; then | |
907 | track='' | |
908 | fi | |
a31e6262 | 909 | __gitcomp_nl "$(__git_refs '' $track)" |
e648f8b6 SG |
910 | ;; |
911 | esac | |
690d8824 JH |
912 | } |
913 | ||
d8a9fea5 SP |
914 | _git_cherry () |
915 | { | |
916 | __gitcomp "$(__git_refs)" | |
917 | } | |
918 | ||
1273231e SP |
919 | _git_cherry_pick () |
920 | { | |
1273231e SP |
921 | case "$cur" in |
922 | --*) | |
b3391775 | 923 | __gitcomp "--edit --no-commit" |
1273231e SP |
924 | ;; |
925 | *) | |
a31e6262 | 926 | __gitcomp_nl "$(__git_refs)" |
1273231e SP |
927 | ;; |
928 | esac | |
929 | } | |
930 | ||
4181c7e8 LM |
931 | _git_clean () |
932 | { | |
933 | __git_has_doubledash && return | |
934 | ||
4181c7e8 LM |
935 | case "$cur" in |
936 | --*) | |
937 | __gitcomp "--dry-run --quiet" | |
938 | return | |
939 | ;; | |
940 | esac | |
941 | COMPREPLY=() | |
942 | } | |
943 | ||
3eb11012 LM |
944 | _git_clone () |
945 | { | |
3eb11012 LM |
946 | case "$cur" in |
947 | --*) | |
948 | __gitcomp " | |
949 | --local | |
950 | --no-hardlinks | |
951 | --shared | |
952 | --reference | |
953 | --quiet | |
954 | --no-checkout | |
955 | --bare | |
956 | --mirror | |
957 | --origin | |
958 | --upload-pack | |
959 | --template= | |
960 | --depth | |
4047fecf RT |
961 | --single-branch |
962 | --branch | |
3eb11012 LM |
963 | " |
964 | return | |
965 | ;; | |
966 | esac | |
967 | COMPREPLY=() | |
968 | } | |
969 | ||
4548e855 SP |
970 | _git_commit () |
971 | { | |
d773c631 SG |
972 | __git_has_doubledash && return |
973 | ||
68539758 JK |
974 | case "$prev" in |
975 | -c|-C) | |
976 | __gitcomp_nl "$(__git_refs)" "" "${cur}" | |
977 | return | |
978 | ;; | |
979 | esac | |
980 | ||
4548e855 | 981 | case "$cur" in |
9a424b27 SG |
982 | --cleanup=*) |
983 | __gitcomp "default strip verbatim whitespace | |
984 | " "" "${cur##--cleanup=}" | |
985 | return | |
986 | ;; | |
77653abd TM |
987 | --reuse-message=*|--reedit-message=*|\ |
988 | --fixup=*|--squash=*) | |
a31e6262 | 989 | __gitcomp_nl "$(__git_refs)" "" "${cur#*=}" |
9a424b27 SG |
990 | return |
991 | ;; | |
992 | --untracked-files=*) | |
993 | __gitcomp "all no normal" "" "${cur##--untracked-files=}" | |
994 | return | |
995 | ;; | |
4548e855 | 996 | --*) |
b3391775 | 997 | __gitcomp " |
4548e855 | 998 | --all --author= --signoff --verify --no-verify |
7dd9ab0c YB |
999 | --edit --no-edit |
1000 | --amend --include --only --interactive | |
9a424b27 SG |
1001 | --dry-run --reuse-message= --reedit-message= |
1002 | --reset-author --file= --message= --template= | |
1003 | --cleanup= --untracked-files --untracked-files= | |
77653abd | 1004 | --verbose --quiet --fixup= --squash= |
b3391775 | 1005 | " |
4548e855 SP |
1006 | return |
1007 | esac | |
1008 | COMPREPLY=() | |
1009 | } | |
1010 | ||
217926c0 SP |
1011 | _git_describe () |
1012 | { | |
cbb504c9 TR |
1013 | case "$cur" in |
1014 | --*) | |
1015 | __gitcomp " | |
1016 | --all --tags --contains --abbrev= --candidates= | |
1017 | --exact-match --debug --long --match --always | |
1018 | " | |
1019 | return | |
1020 | esac | |
a31e6262 | 1021 | __gitcomp_nl "$(__git_refs)" |
217926c0 SP |
1022 | } |
1023 | ||
20bf7292 | 1024 | __git_diff_common_options="--stat --numstat --shortstat --summary |
b3a4f858 JS |
1025 | --patch-with-stat --name-only --name-status --color |
1026 | --no-color --color-words --no-renames --check | |
f135aacb | 1027 | --full-index --binary --abbrev --diff-filter= |
47d5a8fa | 1028 | --find-copies-harder |
b3a4f858 JS |
1029 | --text --ignore-space-at-eol --ignore-space-change |
1030 | --ignore-all-space --exit-code --quiet --ext-diff | |
aba201c6 PO |
1031 | --no-ext-diff |
1032 | --no-prefix --src-prefix= --dst-prefix= | |
6d0e674a | 1033 | --inter-hunk-context= |
cc545709 | 1034 | --patience |
20bf7292 | 1035 | --raw |
8fd2cfa7 SB |
1036 | --dirstat --dirstat= --dirstat-by-file |
1037 | --dirstat-by-file= --cumulative | |
20bf7292 TR |
1038 | " |
1039 | ||
1040 | _git_diff () | |
1041 | { | |
1042 | __git_has_doubledash && return | |
1043 | ||
20bf7292 TR |
1044 | case "$cur" in |
1045 | --*) | |
ebd15bf0 | 1046 | __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex |
861514d3 | 1047 | --base --ours --theirs --no-index |
20bf7292 | 1048 | $__git_diff_common_options |
aba201c6 | 1049 | " |
b3a4f858 JS |
1050 | return |
1051 | ;; | |
1052 | esac | |
1d66ec58 | 1053 | __git_complete_revlist_file |
690d8824 JH |
1054 | } |
1055 | ||
e2dc2de9 | 1056 | __git_mergetools_common="diffuse ecmerge emerge kdiff3 meld opendiff |
755e8b3f | 1057 | tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc3 codecompare |
e2dc2de9 DA |
1058 | " |
1059 | ||
1060 | _git_difftool () | |
1061 | { | |
f7ad96cf MH |
1062 | __git_has_doubledash && return |
1063 | ||
e2dc2de9 DA |
1064 | case "$cur" in |
1065 | --tool=*) | |
1066 | __gitcomp "$__git_mergetools_common kompare" "" "${cur##--tool=}" | |
1067 | return | |
1068 | ;; | |
1069 | --*) | |
f7ad96cf MH |
1070 | __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex |
1071 | --base --ours --theirs | |
1072 | --no-renames --diff-filter= --find-copies-harder | |
1073 | --relative --ignore-submodules | |
1074 | --tool=" | |
e2dc2de9 DA |
1075 | return |
1076 | ;; | |
1077 | esac | |
f7ad96cf | 1078 | __git_complete_file |
e2dc2de9 DA |
1079 | } |
1080 | ||
0a4e1472 JS |
1081 | __git_fetch_options=" |
1082 | --quiet --verbose --append --upload-pack --force --keep --depth= | |
e25e2b42 | 1083 | --tags --no-tags --all --prune --dry-run |
0a4e1472 JS |
1084 | " |
1085 | ||
690d8824 JH |
1086 | _git_fetch () |
1087 | { | |
0a4e1472 JS |
1088 | case "$cur" in |
1089 | --*) | |
1090 | __gitcomp "$__git_fetch_options" | |
1091 | return | |
1092 | ;; | |
1093 | esac | |
52d5c3b5 | 1094 | __git_complete_remote_or_refspec |
690d8824 JH |
1095 | } |
1096 | ||
2f65494d FC |
1097 | __git_format_patch_options=" |
1098 | --stdout --attach --no-attach --thread --thread= --output-directory | |
1099 | --numbered --start-number --numbered-files --keep-subject --signoff | |
1100 | --signature --no-signature --in-reply-to= --cc= --full-index --binary | |
1101 | --not --all --cover-letter --no-prefix --src-prefix= --dst-prefix= | |
1102 | --inline --suffix= --ignore-if-in-upstream --subject-prefix= | |
1103 | " | |
1104 | ||
f53352fb SP |
1105 | _git_format_patch () |
1106 | { | |
f53352fb | 1107 | case "$cur" in |
e1d37937 SB |
1108 | --thread=*) |
1109 | __gitcomp " | |
1110 | deep shallow | |
1111 | " "" "${cur##--thread=}" | |
1112 | return | |
1113 | ;; | |
f53352fb | 1114 | --*) |
2f65494d | 1115 | __gitcomp "$__git_format_patch_options" |
f53352fb SP |
1116 | return |
1117 | ;; | |
1118 | esac | |
1119 | __git_complete_revlist | |
1120 | } | |
1121 | ||
4bca8636 AJ |
1122 | _git_fsck () |
1123 | { | |
4bca8636 AJ |
1124 | case "$cur" in |
1125 | --*) | |
1126 | __gitcomp " | |
1127 | --tags --root --unreachable --cache --no-reflogs --full | |
1128 | --strict --verbose --lost-found | |
1129 | " | |
1130 | return | |
1131 | ;; | |
1132 | esac | |
1133 | COMPREPLY=() | |
1134 | } | |
1135 | ||
b26c8748 SP |
1136 | _git_gc () |
1137 | { | |
b26c8748 SP |
1138 | case "$cur" in |
1139 | --*) | |
47e98eec | 1140 | __gitcomp "--prune --aggressive" |
b26c8748 SP |
1141 | return |
1142 | ;; | |
1143 | esac | |
1144 | COMPREPLY=() | |
1145 | } | |
1146 | ||
66729509 SG |
1147 | _git_gitk () |
1148 | { | |
1149 | _gitk | |
1150 | } | |
1151 | ||
29eec71f JK |
1152 | __git_match_ctag() { |
1153 | awk "/^${1////\\/}/ { print \$1 }" "$2" | |
1154 | } | |
1155 | ||
c72e0db1 LM |
1156 | _git_grep () |
1157 | { | |
1158 | __git_has_doubledash && return | |
1159 | ||
c72e0db1 LM |
1160 | case "$cur" in |
1161 | --*) | |
1162 | __gitcomp " | |
1163 | --cached | |
1164 | --text --ignore-case --word-regexp --invert-match | |
5a69eaf5 | 1165 | --full-name --line-number |
c72e0db1 | 1166 | --extended-regexp --basic-regexp --fixed-strings |
63e7e9d8 | 1167 | --perl-regexp |
c72e0db1 LM |
1168 | --files-with-matches --name-only |
1169 | --files-without-match | |
a91f453f | 1170 | --max-depth |
c72e0db1 LM |
1171 | --count |
1172 | --and --or --not --all-match | |
1173 | " | |
1174 | return | |
1175 | ;; | |
1176 | esac | |
17225c49 | 1177 | |
29eec71f JK |
1178 | case "$cword,$prev" in |
1179 | 2,*|*,-*) | |
1180 | if test -r tags; then | |
d2c78075 | 1181 | __gitcomp_nl "$(__git_match_ctag "$cur" tags)" |
29eec71f JK |
1182 | return |
1183 | fi | |
1184 | ;; | |
1185 | esac | |
1186 | ||
a31e6262 | 1187 | __gitcomp_nl "$(__git_refs)" |
c72e0db1 LM |
1188 | } |
1189 | ||
1eb7e2f8 LM |
1190 | _git_help () |
1191 | { | |
1eb7e2f8 LM |
1192 | case "$cur" in |
1193 | --*) | |
1194 | __gitcomp "--all --info --man --web" | |
1195 | return | |
1196 | ;; | |
1197 | esac | |
eaa4e6ee | 1198 | __git_compute_all_commands |
f85a6f0b | 1199 | __gitcomp "$__git_all_commands $(__git_aliases) |
2946cccf MG |
1200 | attributes cli core-tutorial cvs-migration |
1201 | diffcore gitk glossary hooks ignore modules | |
d49483f0 | 1202 | namespaces repository-layout tutorial tutorial-2 |
99f0b599 | 1203 | workflows |
2946cccf | 1204 | " |
1eb7e2f8 LM |
1205 | } |
1206 | ||
5dad868b LM |
1207 | _git_init () |
1208 | { | |
5dad868b LM |
1209 | case "$cur" in |
1210 | --shared=*) | |
1211 | __gitcomp " | |
1212 | false true umask group all world everybody | |
1213 | " "" "${cur##--shared=}" | |
1214 | return | |
1215 | ;; | |
1216 | --*) | |
1217 | __gitcomp "--quiet --bare --template= --shared --shared=" | |
1218 | return | |
1219 | ;; | |
1220 | esac | |
1221 | COMPREPLY=() | |
1222 | } | |
1223 | ||
b1bc1494 LM |
1224 | _git_ls_files () |
1225 | { | |
1226 | __git_has_doubledash && return | |
1227 | ||
b1bc1494 LM |
1228 | case "$cur" in |
1229 | --*) | |
1230 | __gitcomp "--cached --deleted --modified --others --ignored | |
1231 | --stage --directory --no-empty-directory --unmerged | |
1232 | --killed --exclude= --exclude-from= | |
1233 | --exclude-per-directory= --exclude-standard | |
1234 | --error-unmatch --with-tree= --full-name | |
1235 | --abbrev --ignored --exclude-per-directory | |
1236 | " | |
1237 | return | |
1238 | ;; | |
1239 | esac | |
1240 | COMPREPLY=() | |
1241 | } | |
1242 | ||
690d8824 JH |
1243 | _git_ls_remote () |
1244 | { | |
a31e6262 | 1245 | __gitcomp_nl "$(__git_remotes)" |
690d8824 JH |
1246 | } |
1247 | ||
1248 | _git_ls_tree () | |
1249 | { | |
1250 | __git_complete_file | |
1251 | } | |
1252 | ||
a393777e TR |
1253 | # Options that go well for log, shortlog and gitk |
1254 | __git_log_common_options=" | |
1255 | --not --all | |
1256 | --branches --tags --remotes | |
4fe1a619 | 1257 | --first-parent --merges --no-merges |
a393777e TR |
1258 | --max-count= |
1259 | --max-age= --since= --after= | |
1260 | --min-age= --until= --before= | |
6a6ebded MG |
1261 | --min-parents= --max-parents= |
1262 | --no-min-parents --no-max-parents | |
a393777e TR |
1263 | " |
1264 | # Options that go well for log and gitk (not shortlog) | |
1265 | __git_log_gitk_options=" | |
1266 | --dense --sparse --full-history | |
1267 | --simplify-merges --simplify-by-decoration | |
3925b575 | 1268 | --left-right --notes --no-notes |
a393777e TR |
1269 | " |
1270 | # Options that go well for log and shortlog (not gitk) | |
1271 | __git_log_shortlog_options=" | |
1272 | --author= --committer= --grep= | |
1273 | --all-match | |
1274 | " | |
1275 | ||
3d279863 | 1276 | __git_log_pretty_formats="oneline short medium full fuller email raw format:" |
672c68cb | 1277 | __git_log_date_formats="relative iso8601 rfc2822 short local default raw" |
3d279863 | 1278 | |
690d8824 JH |
1279 | _git_log () |
1280 | { | |
d773c631 SG |
1281 | __git_has_doubledash && return |
1282 | ||
bf3c20f6 TR |
1283 | local g="$(git rev-parse --git-dir 2>/dev/null)" |
1284 | local merge="" | |
ba7906f2 | 1285 | if [ -f "$g/MERGE_HEAD" ]; then |
bf3c20f6 TR |
1286 | merge="--merge" |
1287 | fi | |
6e31b866 | 1288 | case "$cur" in |
e67d71e5 | 1289 | --pretty=*|--format=*) |
c3898111 | 1290 | __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases) |
e67d71e5 | 1291 | " "" "${cur#*=}" |
72de29c2 TL |
1292 | return |
1293 | ;; | |
47e98eec | 1294 | --date=*) |
672c68cb | 1295 | __gitcomp "$__git_log_date_formats" "" "${cur##--date=}" |
47e98eec SP |
1296 | return |
1297 | ;; | |
af4e9e8c SB |
1298 | --decorate=*) |
1299 | __gitcomp "long short" "" "${cur##--decorate=}" | |
1300 | return | |
1301 | ;; | |
6e31b866 | 1302 | --*) |
b3391775 | 1303 | __gitcomp " |
a393777e TR |
1304 | $__git_log_common_options |
1305 | $__git_log_shortlog_options | |
1306 | $__git_log_gitk_options | |
8f87fae6 | 1307 | --root --topo-order --date-order --reverse |
5d0e6343 | 1308 | --follow --full-diff |
6e31b866 | 1309 | --abbrev-commit --abbrev= |
47e98eec | 1310 | --relative-date --date= |
72de29c2 | 1311 | --pretty= --format= --oneline |
a393777e | 1312 | --cherry-pick |
20827d99 | 1313 | --graph |
af4e9e8c | 1314 | --decorate --decorate= |
20bf7292 | 1315 | --walk-reflogs |
a393777e | 1316 | --parents --children |
bf3c20f6 | 1317 | $merge |
20bf7292 | 1318 | $__git_diff_common_options |
47d5a8fa | 1319 | --pickaxe-all --pickaxe-regex |
b3391775 | 1320 | " |
6e31b866 SP |
1321 | return |
1322 | ;; | |
1323 | esac | |
f53352fb | 1324 | __git_complete_revlist |
690d8824 JH |
1325 | } |
1326 | ||
0a4e1472 JS |
1327 | __git_merge_options=" |
1328 | --no-commit --no-stat --log --no-log --squash --strategy | |
2ff14e31 | 1329 | --commit --stat --no-squash --ff --no-ff --ff-only --edit --no-edit |
0a4e1472 JS |
1330 | " |
1331 | ||
4ad91321 SP |
1332 | _git_merge () |
1333 | { | |
3c7b480a JS |
1334 | __git_complete_strategy && return |
1335 | ||
4ad91321 SP |
1336 | case "$cur" in |
1337 | --*) | |
0a4e1472 | 1338 | __gitcomp "$__git_merge_options" |
4ad91321 SP |
1339 | return |
1340 | esac | |
a31e6262 | 1341 | __gitcomp_nl "$(__git_refs)" |
4ad91321 SP |
1342 | } |
1343 | ||
b4c72162 LM |
1344 | _git_mergetool () |
1345 | { | |
b4c72162 LM |
1346 | case "$cur" in |
1347 | --tool=*) | |
e2dc2de9 | 1348 | __gitcomp "$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}" |
b4c72162 LM |
1349 | return |
1350 | ;; | |
1351 | --*) | |
1352 | __gitcomp "--tool=" | |
1353 | return | |
1354 | ;; | |
1355 | esac | |
1356 | COMPREPLY=() | |
1357 | } | |
1358 | ||
690d8824 JH |
1359 | _git_merge_base () |
1360 | { | |
a31e6262 | 1361 | __gitcomp_nl "$(__git_refs)" |
690d8824 JH |
1362 | } |
1363 | ||
1127c51c LM |
1364 | _git_mv () |
1365 | { | |
1127c51c LM |
1366 | case "$cur" in |
1367 | --*) | |
1368 | __gitcomp "--dry-run" | |
1369 | return | |
1370 | ;; | |
1371 | esac | |
1372 | COMPREPLY=() | |
1373 | } | |
1374 | ||
d33909bf SP |
1375 | _git_name_rev () |
1376 | { | |
b3391775 | 1377 | __gitcomp "--tags --all --stdin" |
d33909bf SP |
1378 | } |
1379 | ||
00f09d0e SG |
1380 | _git_notes () |
1381 | { | |
2a5da755 SG |
1382 | local subcommands='add append copy edit list prune remove show' |
1383 | local subcommand="$(__git_find_on_cmdline "$subcommands")" | |
00f09d0e | 1384 | |
2a5da755 SG |
1385 | case "$subcommand,$cur" in |
1386 | ,--*) | |
1387 | __gitcomp '--ref' | |
1388 | ;; | |
1389 | ,*) | |
39540681 | 1390 | case "$prev" in |
2a5da755 | 1391 | --ref) |
a31e6262 | 1392 | __gitcomp_nl "$(__git_refs)" |
2a5da755 SG |
1393 | ;; |
1394 | *) | |
1395 | __gitcomp "$subcommands --ref" | |
1396 | ;; | |
1397 | esac | |
1398 | ;; | |
a8f89bfa | 1399 | add,--reuse-message=*|append,--reuse-message=*|\ |
2a5da755 | 1400 | add,--reedit-message=*|append,--reedit-message=*) |
a31e6262 | 1401 | __gitcomp_nl "$(__git_refs)" "" "${cur#*=}" |
2a5da755 SG |
1402 | ;; |
1403 | add,--*|append,--*) | |
1404 | __gitcomp '--file= --message= --reedit-message= | |
1405 | --reuse-message=' | |
1406 | ;; | |
1407 | copy,--*) | |
1408 | __gitcomp '--stdin' | |
1409 | ;; | |
1410 | prune,--*) | |
1411 | __gitcomp '--dry-run --verbose' | |
1412 | ;; | |
1413 | prune,*) | |
00f09d0e SG |
1414 | ;; |
1415 | *) | |
39540681 | 1416 | case "$prev" in |
2a5da755 SG |
1417 | -m|-F) |
1418 | ;; | |
1419 | *) | |
a31e6262 | 1420 | __gitcomp_nl "$(__git_refs)" |
2a5da755 SG |
1421 | ;; |
1422 | esac | |
00f09d0e SG |
1423 | ;; |
1424 | esac | |
1425 | } | |
1426 | ||
690d8824 JH |
1427 | _git_pull () |
1428 | { | |
0a4e1472 JS |
1429 | __git_complete_strategy && return |
1430 | ||
0a4e1472 JS |
1431 | case "$cur" in |
1432 | --*) | |
1433 | __gitcomp " | |
1434 | --rebase --no-rebase | |
1435 | $__git_merge_options | |
1436 | $__git_fetch_options | |
1437 | " | |
1438 | return | |
1439 | ;; | |
1440 | esac | |
52d5c3b5 | 1441 | __git_complete_remote_or_refspec |
690d8824 JH |
1442 | } |
1443 | ||
1444 | _git_push () | |
1445 | { | |
da48616f | 1446 | case "$prev" in |
0a4e1472 | 1447 | --repo) |
a31e6262 | 1448 | __gitcomp_nl "$(__git_remotes)" |
0a4e1472 JS |
1449 | return |
1450 | esac | |
1451 | case "$cur" in | |
1452 | --repo=*) | |
a31e6262 | 1453 | __gitcomp_nl "$(__git_remotes)" "" "${cur##--repo=}" |
0a4e1472 JS |
1454 | return |
1455 | ;; | |
1456 | --*) | |
1457 | __gitcomp " | |
1458 | --all --mirror --tags --dry-run --force --verbose | |
3623dc03 | 1459 | --receive-pack= --repo= --set-upstream |
0a4e1472 JS |
1460 | " |
1461 | return | |
1462 | ;; | |
1463 | esac | |
52d5c3b5 | 1464 | __git_complete_remote_or_refspec |
690d8824 JH |
1465 | } |
1466 | ||
61d926a3 SP |
1467 | _git_rebase () |
1468 | { | |
da48616f | 1469 | local dir="$(__gitdir)" |
51ef1daa | 1470 | if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then |
b3391775 | 1471 | __gitcomp "--continue --skip --abort" |
61d926a3 SP |
1472 | return |
1473 | fi | |
3c7b480a | 1474 | __git_complete_strategy && return |
61d926a3 | 1475 | case "$cur" in |
93cf50a4 BG |
1476 | --whitespace=*) |
1477 | __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}" | |
1478 | return | |
1479 | ;; | |
61d926a3 | 1480 | --*) |
93cf50a4 BG |
1481 | __gitcomp " |
1482 | --onto --merge --strategy --interactive | |
1483 | --preserve-merges --stat --no-stat | |
1484 | --committer-date-is-author-date --ignore-date | |
1485 | --ignore-whitespace --whitespace= | |
6d0d465e | 1486 | --autosquash |
93cf50a4 BG |
1487 | " |
1488 | ||
61d926a3 SP |
1489 | return |
1490 | esac | |
a31e6262 | 1491 | __gitcomp_nl "$(__git_refs)" |
61d926a3 SP |
1492 | } |
1493 | ||
057f3279 TRC |
1494 | _git_reflog () |
1495 | { | |
1496 | local subcommands="show delete expire" | |
1497 | local subcommand="$(__git_find_on_cmdline "$subcommands")" | |
1498 | ||
1499 | if [ -z "$subcommand" ]; then | |
1500 | __gitcomp "$subcommands" | |
1501 | else | |
a31e6262 | 1502 | __gitcomp_nl "$(__git_refs)" |
057f3279 TRC |
1503 | fi |
1504 | } | |
1505 | ||
ae616de6 | 1506 | __git_send_email_confirm_options="always never auto cc compose" |
cb8a9bd5 | 1507 | __git_send_email_suppresscc_options="author self cc bodycc sob cccmd body all" |
ae616de6 | 1508 | |
25a1f374 TL |
1509 | _git_send_email () |
1510 | { | |
25a1f374 | 1511 | case "$cur" in |
ae616de6 SB |
1512 | --confirm=*) |
1513 | __gitcomp " | |
1514 | $__git_send_email_confirm_options | |
1515 | " "" "${cur##--confirm=}" | |
1516 | return | |
1517 | ;; | |
1518 | --suppress-cc=*) | |
1519 | __gitcomp " | |
1520 | $__git_send_email_suppresscc_options | |
1521 | " "" "${cur##--suppress-cc=}" | |
1522 | ||
1523 | return | |
1524 | ;; | |
1525 | --smtp-encryption=*) | |
1526 | __gitcomp "ssl tls" "" "${cur##--smtp-encryption=}" | |
1527 | return | |
1528 | ;; | |
2f65494d FC |
1529 | --thread=*) |
1530 | __gitcomp " | |
1531 | deep shallow | |
1532 | " "" "${cur##--thread=}" | |
1533 | return | |
1534 | ;; | |
25a1f374 | 1535 | --*) |
77813151 | 1536 | __gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to |
ae616de6 SB |
1537 | --compose --confirm= --dry-run --envelope-sender |
1538 | --from --identity | |
25a1f374 TL |
1539 | --in-reply-to --no-chain-reply-to --no-signed-off-by-cc |
1540 | --no-suppress-from --no-thread --quiet | |
1541 | --signed-off-by-cc --smtp-pass --smtp-server | |
ae616de6 SB |
1542 | --smtp-server-port --smtp-encryption= --smtp-user |
1543 | --subject --suppress-cc= --suppress-from --thread --to | |
2f65494d FC |
1544 | --validate --no-validate |
1545 | $__git_format_patch_options" | |
25a1f374 TL |
1546 | return |
1547 | ;; | |
1548 | esac | |
2f65494d | 1549 | __git_complete_revlist |
25a1f374 TL |
1550 | } |
1551 | ||
424cce83 SG |
1552 | _git_stage () |
1553 | { | |
1554 | _git_add | |
1555 | } | |
1556 | ||
00652369 SB |
1557 | __git_config_get_set_variables () |
1558 | { | |
da48616f | 1559 | local prevword word config_file= c=$cword |
00652369 | 1560 | while [ $c -gt 1 ]; do |
da48616f | 1561 | word="${words[c]}" |
00652369 SB |
1562 | case "$word" in |
1563 | --global|--system|--file=*) | |
1564 | config_file="$word" | |
1565 | break | |
1566 | ;; | |
1567 | -f|--file) | |
1568 | config_file="$word $prevword" | |
1569 | break | |
1570 | ;; | |
1571 | esac | |
1572 | prevword=$word | |
1573 | c=$((--c)) | |
1574 | done | |
1575 | ||
f581de1b | 1576 | git --git-dir="$(__gitdir)" config $config_file --list 2>/dev/null | |
6f2dd720 | 1577 | while read -r line |
f581de1b SB |
1578 | do |
1579 | case "$line" in | |
1580 | *.*=*) | |
1581 | echo "${line/=*/}" | |
00652369 SB |
1582 | ;; |
1583 | esac | |
1584 | done | |
1585 | } | |
1586 | ||
e0d10e1c | 1587 | _git_config () |
5de40f59 | 1588 | { |
da48616f | 1589 | case "$prev" in |
5de40f59 | 1590 | branch.*.remote) |
a31e6262 | 1591 | __gitcomp_nl "$(__git_remotes)" |
5de40f59 SP |
1592 | return |
1593 | ;; | |
1594 | branch.*.merge) | |
a31e6262 | 1595 | __gitcomp_nl "$(__git_refs)" |
5de40f59 SP |
1596 | return |
1597 | ;; | |
1598 | remote.*.fetch) | |
da48616f | 1599 | local remote="${prev#remote.}" |
5de40f59 | 1600 | remote="${remote%.fetch}" |
d51a8ecd SG |
1601 | if [ -z "$cur" ]; then |
1602 | COMPREPLY=("refs/heads/") | |
1603 | return | |
1604 | fi | |
a31e6262 | 1605 | __gitcomp_nl "$(__git_refs_remotes "$remote")" |
5de40f59 SP |
1606 | return |
1607 | ;; | |
1608 | remote.*.push) | |
da48616f | 1609 | local remote="${prev#remote.}" |
5de40f59 | 1610 | remote="${remote%.push}" |
a31e6262 | 1611 | __gitcomp_nl "$(git --git-dir="$(__gitdir)" \ |
5de40f59 | 1612 | for-each-ref --format='%(refname):%(refname)' \ |
78d4d6a2 SP |
1613 | refs/heads)" |
1614 | return | |
1615 | ;; | |
1616 | pull.twohead|pull.octopus) | |
eaa4e6ee JN |
1617 | __git_compute_merge_strategies |
1618 | __gitcomp "$__git_merge_strategies" | |
78d4d6a2 SP |
1619 | return |
1620 | ;; | |
6123d719 MH |
1621 | color.branch|color.diff|color.interactive|\ |
1622 | color.showbranch|color.status|color.ui) | |
78d4d6a2 SP |
1623 | __gitcomp "always never auto" |
1624 | return | |
1625 | ;; | |
901d615c MK |
1626 | color.pager) |
1627 | __gitcomp "false true" | |
1628 | return | |
1629 | ;; | |
78d4d6a2 SP |
1630 | color.*.*) |
1631 | __gitcomp " | |
98171a07 | 1632 | normal black red green yellow blue magenta cyan white |
78d4d6a2 SP |
1633 | bold dim ul blink reverse |
1634 | " | |
5de40f59 SP |
1635 | return |
1636 | ;; | |
9b82d63b SB |
1637 | help.format) |
1638 | __gitcomp "man info web html" | |
1639 | return | |
1640 | ;; | |
672c68cb SB |
1641 | log.date) |
1642 | __gitcomp "$__git_log_date_formats" | |
1643 | return | |
1644 | ;; | |
ae616de6 SB |
1645 | sendemail.aliasesfiletype) |
1646 | __gitcomp "mutt mailrc pine elm gnus" | |
1647 | return | |
1648 | ;; | |
1649 | sendemail.confirm) | |
1650 | __gitcomp "$__git_send_email_confirm_options" | |
1651 | return | |
1652 | ;; | |
1653 | sendemail.suppresscc) | |
1654 | __gitcomp "$__git_send_email_suppresscc_options" | |
1655 | return | |
1656 | ;; | |
00652369 | 1657 | --get|--get-all|--unset|--unset-all) |
a31e6262 | 1658 | __gitcomp_nl "$(__git_config_get_set_variables)" |
00652369 SB |
1659 | return |
1660 | ;; | |
5de40f59 SP |
1661 | *.*) |
1662 | COMPREPLY=() | |
1663 | return | |
1664 | ;; | |
1665 | esac | |
1666 | case "$cur" in | |
1667 | --*) | |
78d4d6a2 | 1668 | __gitcomp " |
47e98eec | 1669 | --global --system --file= |
12977705 | 1670 | --list --replace-all |
5de40f59 | 1671 | --get --get-all --get-regexp |
1b71eb35 | 1672 | --add --unset --unset-all |
12977705 | 1673 | --remove-section --rename-section |
78d4d6a2 | 1674 | " |
5de40f59 SP |
1675 | return |
1676 | ;; | |
1677 | branch.*.*) | |
9244d69b SG |
1678 | local pfx="${cur%.*}." cur_="${cur##*.}" |
1679 | __gitcomp "remote merge mergeoptions rebase" "$pfx" "$cur_" | |
5de40f59 SP |
1680 | return |
1681 | ;; | |
1682 | branch.*) | |
9244d69b | 1683 | local pfx="${cur%.*}." cur_="${cur#*.}" |
a31e6262 | 1684 | __gitcomp_nl "$(__git_heads)" "$pfx" "$cur_" "." |
5de40f59 SP |
1685 | return |
1686 | ;; | |
0aa62fd0 | 1687 | guitool.*.*) |
9244d69b | 1688 | local pfx="${cur%.*}." cur_="${cur##*.}" |
0aa62fd0 SB |
1689 | __gitcomp " |
1690 | argprompt cmd confirm needsfile noconsole norescan | |
1691 | prompt revprompt revunmerged title | |
9244d69b | 1692 | " "$pfx" "$cur_" |
0aa62fd0 SB |
1693 | return |
1694 | ;; | |
1695 | difftool.*.*) | |
9244d69b SG |
1696 | local pfx="${cur%.*}." cur_="${cur##*.}" |
1697 | __gitcomp "cmd path" "$pfx" "$cur_" | |
0aa62fd0 SB |
1698 | return |
1699 | ;; | |
1700 | man.*.*) | |
9244d69b SG |
1701 | local pfx="${cur%.*}." cur_="${cur##*.}" |
1702 | __gitcomp "cmd path" "$pfx" "$cur_" | |
0aa62fd0 SB |
1703 | return |
1704 | ;; | |
1705 | mergetool.*.*) | |
9244d69b SG |
1706 | local pfx="${cur%.*}." cur_="${cur##*.}" |
1707 | __gitcomp "cmd path trustExitCode" "$pfx" "$cur_" | |
0aa62fd0 SB |
1708 | return |
1709 | ;; | |
1710 | pager.*) | |
9244d69b | 1711 | local pfx="${cur%.*}." cur_="${cur#*.}" |
eaa4e6ee | 1712 | __git_compute_all_commands |
a31e6262 | 1713 | __gitcomp_nl "$__git_all_commands" "$pfx" "$cur_" |
0aa62fd0 SB |
1714 | return |
1715 | ;; | |
5de40f59 | 1716 | remote.*.*) |
9244d69b | 1717 | local pfx="${cur%.*}." cur_="${cur##*.}" |
12977705 | 1718 | __gitcomp " |
98171a07 | 1719 | url proxy fetch push mirror skipDefaultUpdate |
6fac1b83 | 1720 | receivepack uploadpack tagopt pushurl |
9244d69b | 1721 | " "$pfx" "$cur_" |
5de40f59 SP |
1722 | return |
1723 | ;; | |
1724 | remote.*) | |
9244d69b | 1725 | local pfx="${cur%.*}." cur_="${cur#*.}" |
a31e6262 | 1726 | __gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "." |
5de40f59 SP |
1727 | return |
1728 | ;; | |
0aa62fd0 | 1729 | url.*.*) |
9244d69b SG |
1730 | local pfx="${cur%.*}." cur_="${cur##*.}" |
1731 | __gitcomp "insteadOf pushInsteadOf" "$pfx" "$cur_" | |
0aa62fd0 SB |
1732 | return |
1733 | ;; | |
5de40f59 | 1734 | esac |
78d4d6a2 | 1735 | __gitcomp " |
6068ac88 MZ |
1736 | add.ignoreErrors |
1737 | advice.commitBeforeMerge | |
1738 | advice.detachedHead | |
1739 | advice.implicitIdentity | |
1740 | advice.pushNonFastForward | |
1741 | advice.resolveConflict | |
1742 | advice.statusHints | |
226b343c | 1743 | alias. |
6068ac88 | 1744 | am.keepcr |
86c91f91 | 1745 | apply.ignorewhitespace |
5de40f59 | 1746 | apply.whitespace |
98171a07 LM |
1747 | branch.autosetupmerge |
1748 | branch.autosetuprebase | |
6068ac88 | 1749 | browser. |
2122591b | 1750 | clean.requireForce |
78d4d6a2 SP |
1751 | color.branch |
1752 | color.branch.current | |
1753 | color.branch.local | |
78d4d6a2 | 1754 | color.branch.plain |
025a1929 | 1755 | color.branch.remote |
6068ac88 MZ |
1756 | color.decorate.HEAD |
1757 | color.decorate.branch | |
1758 | color.decorate.remoteBranch | |
1759 | color.decorate.stash | |
1760 | color.decorate.tag | |
a159ca0c | 1761 | color.diff |
025a1929 | 1762 | color.diff.commit |
78d4d6a2 | 1763 | color.diff.frag |
6068ac88 | 1764 | color.diff.func |
025a1929 | 1765 | color.diff.meta |
78d4d6a2 | 1766 | color.diff.new |
025a1929 LM |
1767 | color.diff.old |
1768 | color.diff.plain | |
78d4d6a2 | 1769 | color.diff.whitespace |
226b343c | 1770 | color.grep |
6068ac88 MZ |
1771 | color.grep.context |
1772 | color.grep.filename | |
1773 | color.grep.function | |
1774 | color.grep.linenumber | |
226b343c | 1775 | color.grep.match |
6068ac88 MZ |
1776 | color.grep.selected |
1777 | color.grep.separator | |
98171a07 | 1778 | color.interactive |
6068ac88 | 1779 | color.interactive.error |
98171a07 LM |
1780 | color.interactive.header |
1781 | color.interactive.help | |
1782 | color.interactive.prompt | |
a159ca0c | 1783 | color.pager |
6123d719 | 1784 | color.showbranch |
a159ca0c | 1785 | color.status |
78d4d6a2 SP |
1786 | color.status.added |
1787 | color.status.changed | |
025a1929 | 1788 | color.status.header |
98171a07 | 1789 | color.status.nobranch |
78d4d6a2 | 1790 | color.status.untracked |
98171a07 LM |
1791 | color.status.updated |
1792 | color.ui | |
6068ac88 | 1793 | commit.status |
98171a07 | 1794 | commit.template |
cdb791f6 | 1795 | core.abbrev |
6068ac88 MZ |
1796 | core.askpass |
1797 | core.attributesfile | |
98171a07 LM |
1798 | core.autocrlf |
1799 | core.bare | |
6068ac88 | 1800 | core.bigFileThreshold |
025a1929 | 1801 | core.compression |
226b343c | 1802 | core.createObject |
98171a07 LM |
1803 | core.deltaBaseCacheLimit |
1804 | core.editor | |
6068ac88 | 1805 | core.eol |
98171a07 | 1806 | core.excludesfile |
025a1929 | 1807 | core.fileMode |
98171a07 | 1808 | core.fsyncobjectfiles |
025a1929 | 1809 | core.gitProxy |
98171a07 | 1810 | core.ignoreCygwinFSTricks |
025a1929 | 1811 | core.ignoreStat |
6068ac88 | 1812 | core.ignorecase |
025a1929 LM |
1813 | core.logAllRefUpdates |
1814 | core.loosecompression | |
6068ac88 | 1815 | core.notesRef |
025a1929 LM |
1816 | core.packedGitLimit |
1817 | core.packedGitWindowSize | |
98171a07 | 1818 | core.pager |
025a1929 | 1819 | core.preferSymlinkRefs |
98171a07 LM |
1820 | core.preloadindex |
1821 | core.quotepath | |
025a1929 | 1822 | core.repositoryFormatVersion |
98171a07 | 1823 | core.safecrlf |
025a1929 | 1824 | core.sharedRepository |
6068ac88 | 1825 | core.sparseCheckout |
98171a07 LM |
1826 | core.symlinks |
1827 | core.trustctime | |
025a1929 | 1828 | core.warnAmbiguousRefs |
98171a07 LM |
1829 | core.whitespace |
1830 | core.worktree | |
1831 | diff.autorefreshindex | |
df44483a | 1832 | diff.statGraphWidth |
98171a07 | 1833 | diff.external |
6068ac88 | 1834 | diff.ignoreSubmodules |
98171a07 | 1835 | diff.mnemonicprefix |
6068ac88 | 1836 | diff.noprefix |
78d4d6a2 SP |
1837 | diff.renameLimit |
1838 | diff.renames | |
226b343c SB |
1839 | diff.suppressBlankEmpty |
1840 | diff.tool | |
1841 | diff.wordRegex | |
0aa62fd0 | 1842 | difftool. |
226b343c | 1843 | difftool.prompt |
6068ac88 | 1844 | fetch.recurseSubmodules |
78d4d6a2 | 1845 | fetch.unpackLimit |
226b343c SB |
1846 | format.attach |
1847 | format.cc | |
78d4d6a2 | 1848 | format.headers |
98171a07 LM |
1849 | format.numbered |
1850 | format.pretty | |
d8e1e5df | 1851 | format.signature |
226b343c SB |
1852 | format.signoff |
1853 | format.subjectprefix | |
98171a07 | 1854 | format.suffix |
226b343c | 1855 | format.thread |
6068ac88 MZ |
1856 | format.to |
1857 | gc. | |
98171a07 LM |
1858 | gc.aggressiveWindow |
1859 | gc.auto | |
1860 | gc.autopacklimit | |
12977705 | 1861 | gc.packrefs |
98171a07 | 1862 | gc.pruneexpire |
78d4d6a2 SP |
1863 | gc.reflogexpire |
1864 | gc.reflogexpireunreachable | |
1865 | gc.rerereresolved | |
1866 | gc.rerereunresolved | |
025a1929 | 1867 | gitcvs.allbinary |
226b343c | 1868 | gitcvs.commitmsgannotation |
98171a07 | 1869 | gitcvs.dbTableNamePrefix |
025a1929 LM |
1870 | gitcvs.dbdriver |
1871 | gitcvs.dbname | |
1872 | gitcvs.dbpass | |
025a1929 LM |
1873 | gitcvs.dbuser |
1874 | gitcvs.enabled | |
1875 | gitcvs.logfile | |
98171a07 | 1876 | gitcvs.usecrlfattr |
0aa62fd0 | 1877 | guitool. |
98171a07 LM |
1878 | gui.blamehistoryctx |
1879 | gui.commitmsgwidth | |
1880 | gui.copyblamethreshold | |
1881 | gui.diffcontext | |
1882 | gui.encoding | |
1883 | gui.fastcopyblame | |
1884 | gui.matchtrackingbranch | |
1885 | gui.newbranchtemplate | |
1886 | gui.pruneduringfetch | |
1887 | gui.spellingdictionary | |
1888 | gui.trustmtime | |
1889 | help.autocorrect | |
1890 | help.browser | |
1891 | help.format | |
78d4d6a2 SP |
1892 | http.lowSpeedLimit |
1893 | http.lowSpeedTime | |
025a1929 | 1894 | http.maxRequests |
6068ac88 | 1895 | http.minSessions |
5de40f59 | 1896 | http.noEPSV |
6068ac88 | 1897 | http.postBuffer |
98171a07 | 1898 | http.proxy |
025a1929 LM |
1899 | http.sslCAInfo |
1900 | http.sslCAPath | |
1901 | http.sslCert | |
6068ac88 | 1902 | http.sslCertPasswordProtected |
025a1929 LM |
1903 | http.sslKey |
1904 | http.sslVerify | |
6068ac88 | 1905 | http.useragent |
78d4d6a2 SP |
1906 | i18n.commitEncoding |
1907 | i18n.logOutputEncoding | |
6068ac88 | 1908 | imap.authMethod |
226b343c SB |
1909 | imap.folder |
1910 | imap.host | |
1911 | imap.pass | |
1912 | imap.port | |
1913 | imap.preformattedHTML | |
1914 | imap.sslverify | |
1915 | imap.tunnel | |
1916 | imap.user | |
6068ac88 | 1917 | init.templatedir |
98171a07 LM |
1918 | instaweb.browser |
1919 | instaweb.httpd | |
1920 | instaweb.local | |
1921 | instaweb.modulepath | |
1922 | instaweb.port | |
226b343c | 1923 | interactive.singlekey |
98171a07 | 1924 | log.date |
6068ac88 | 1925 | log.decorate |
78d4d6a2 | 1926 | log.showroot |
226b343c | 1927 | mailmap.file |
0aa62fd0 | 1928 | man. |
98171a07 | 1929 | man.viewer |
6068ac88 | 1930 | merge. |
98171a07 LM |
1931 | merge.conflictstyle |
1932 | merge.log | |
1933 | merge.renameLimit | |
6068ac88 | 1934 | merge.renormalize |
98171a07 | 1935 | merge.stat |
025a1929 | 1936 | merge.tool |
78d4d6a2 | 1937 | merge.verbosity |
0aa62fd0 | 1938 | mergetool. |
98171a07 | 1939 | mergetool.keepBackup |
6068ac88 | 1940 | mergetool.keepTemporaries |
226b343c | 1941 | mergetool.prompt |
6068ac88 MZ |
1942 | notes.displayRef |
1943 | notes.rewrite. | |
1944 | notes.rewrite.amend | |
1945 | notes.rewrite.rebase | |
1946 | notes.rewriteMode | |
1947 | notes.rewriteRef | |
47e98eec | 1948 | pack.compression |
47e98eec | 1949 | pack.deltaCacheLimit |
025a1929 LM |
1950 | pack.deltaCacheSize |
1951 | pack.depth | |
98171a07 LM |
1952 | pack.indexVersion |
1953 | pack.packSizeLimit | |
1954 | pack.threads | |
025a1929 LM |
1955 | pack.window |
1956 | pack.windowMemory | |
0aa62fd0 | 1957 | pager. |
6068ac88 | 1958 | pretty. |
78d4d6a2 SP |
1959 | pull.octopus |
1960 | pull.twohead | |
226b343c | 1961 | push.default |
6068ac88 | 1962 | rebase.autosquash |
226b343c | 1963 | rebase.stat |
6068ac88 | 1964 | receive.autogc |
98171a07 | 1965 | receive.denyCurrentBranch |
6068ac88 | 1966 | receive.denyDeleteCurrent |
98171a07 | 1967 | receive.denyDeletes |
025a1929 | 1968 | receive.denyNonFastForwards |
98171a07 | 1969 | receive.fsckObjects |
025a1929 | 1970 | receive.unpackLimit |
6068ac88 MZ |
1971 | receive.updateserverinfo |
1972 | remotes. | |
98171a07 LM |
1973 | repack.usedeltabaseoffset |
1974 | rerere.autoupdate | |
1975 | rerere.enabled | |
6068ac88 | 1976 | sendemail. |
226b343c | 1977 | sendemail.aliasesfile |
6068ac88 | 1978 | sendemail.aliasfiletype |
226b343c SB |
1979 | sendemail.bcc |
1980 | sendemail.cc | |
1981 | sendemail.cccmd | |
1982 | sendemail.chainreplyto | |
1983 | sendemail.confirm | |
1984 | sendemail.envelopesender | |
6068ac88 MZ |
1985 | sendemail.from |
1986 | sendemail.identity | |
226b343c SB |
1987 | sendemail.multiedit |
1988 | sendemail.signedoffbycc | |
6068ac88 | 1989 | sendemail.smtpdomain |
226b343c SB |
1990 | sendemail.smtpencryption |
1991 | sendemail.smtppass | |
1992 | sendemail.smtpserver | |
6068ac88 | 1993 | sendemail.smtpserveroption |
226b343c SB |
1994 | sendemail.smtpserverport |
1995 | sendemail.smtpuser | |
1996 | sendemail.suppresscc | |
1997 | sendemail.suppressfrom | |
1998 | sendemail.thread | |
1999 | sendemail.to | |
2000 | sendemail.validate | |
78d4d6a2 | 2001 | showbranch.default |
98171a07 LM |
2002 | status.relativePaths |
2003 | status.showUntrackedFiles | |
6068ac88 MZ |
2004 | status.submodulesummary |
2005 | submodule. | |
78d4d6a2 SP |
2006 | tar.umask |
2007 | transfer.unpackLimit | |
0aa62fd0 | 2008 | url. |
78d4d6a2 | 2009 | user.email |
025a1929 | 2010 | user.name |
78d4d6a2 | 2011 | user.signingkey |
98171a07 | 2012 | web.browser |
5de40f59 | 2013 | branch. remote. |
78d4d6a2 | 2014 | " |
5de40f59 SP |
2015 | } |
2016 | ||
88293c67 SP |
2017 | _git_remote () |
2018 | { | |
e17dba8f | 2019 | local subcommands="add rename remove set-head set-branches set-url show prune update" |
918c03c2 | 2020 | local subcommand="$(__git_find_on_cmdline "$subcommands")" |
3ff1320d | 2021 | if [ -z "$subcommand" ]; then |
3903c618 | 2022 | __gitcomp "$subcommands" |
88293c67 SP |
2023 | return |
2024 | fi | |
2025 | ||
3ff1320d | 2026 | case "$subcommand" in |
e17dba8f | 2027 | rename|remove|set-url|show|prune) |
a31e6262 | 2028 | __gitcomp_nl "$(__git_remotes)" |
88293c67 | 2029 | ;; |
f1c6ffe6 PJ |
2030 | set-head|set-branches) |
2031 | __git_complete_remote_or_refspec | |
2032 | ;; | |
fb72759b SP |
2033 | update) |
2034 | local i c='' IFS=$'\n' | |
518ef8f0 TZ |
2035 | for i in $(git --git-dir="$(__gitdir)" config --get-regexp "remotes\..*" 2>/dev/null); do |
2036 | i="${i#remotes.}" | |
2037 | c="$c ${i/ */}" | |
fb72759b SP |
2038 | done |
2039 | __gitcomp "$c" | |
2040 | ;; | |
88293c67 SP |
2041 | *) |
2042 | COMPREPLY=() | |
2043 | ;; | |
2044 | esac | |
2045 | } | |
2046 | ||
e1c1a067 BG |
2047 | _git_replace () |
2048 | { | |
a31e6262 | 2049 | __gitcomp_nl "$(__git_refs)" |
e1c1a067 BG |
2050 | } |
2051 | ||
67e78c3b SP |
2052 | _git_reset () |
2053 | { | |
d773c631 SG |
2054 | __git_has_doubledash && return |
2055 | ||
b3391775 SP |
2056 | case "$cur" in |
2057 | --*) | |
9f040e95 | 2058 | __gitcomp "--merge --mixed --hard --soft --patch" |
b3391775 SP |
2059 | return |
2060 | ;; | |
2061 | esac | |
a31e6262 | 2062 | __gitcomp_nl "$(__git_refs)" |
67e78c3b SP |
2063 | } |
2064 | ||
a6c2be24 LM |
2065 | _git_revert () |
2066 | { | |
a6c2be24 LM |
2067 | case "$cur" in |
2068 | --*) | |
2069 | __gitcomp "--edit --mainline --no-edit --no-commit --signoff" | |
2070 | return | |
2071 | ;; | |
2072 | esac | |
a31e6262 | 2073 | __gitcomp_nl "$(__git_refs)" |
a6c2be24 LM |
2074 | } |
2075 | ||
08c701d4 LM |
2076 | _git_rm () |
2077 | { | |
2078 | __git_has_doubledash && return | |
2079 | ||
08c701d4 LM |
2080 | case "$cur" in |
2081 | --*) | |
2082 | __gitcomp "--cached --dry-run --ignore-unmatch --quiet" | |
2083 | return | |
2084 | ;; | |
2085 | esac | |
2086 | COMPREPLY=() | |
2087 | } | |
2088 | ||
1fd6bec9 SP |
2089 | _git_shortlog () |
2090 | { | |
d773c631 SG |
2091 | __git_has_doubledash && return |
2092 | ||
1fd6bec9 SP |
2093 | case "$cur" in |
2094 | --*) | |
2095 | __gitcomp " | |
a393777e TR |
2096 | $__git_log_common_options |
2097 | $__git_log_shortlog_options | |
1fd6bec9 SP |
2098 | --numbered --summary |
2099 | " | |
2100 | return | |
2101 | ;; | |
2102 | esac | |
2103 | __git_complete_revlist | |
2104 | } | |
2105 | ||
90131924 SP |
2106 | _git_show () |
2107 | { | |
41d8cf7d MH |
2108 | __git_has_doubledash && return |
2109 | ||
90131924 | 2110 | case "$cur" in |
e67d71e5 | 2111 | --pretty=*|--format=*) |
c3898111 | 2112 | __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases) |
e67d71e5 | 2113 | " "" "${cur#*=}" |
72de29c2 TL |
2114 | return |
2115 | ;; | |
90131924 | 2116 | --*) |
076c3237 | 2117 | __gitcomp "--pretty= --format= --abbrev-commit --oneline |
20bf7292 TR |
2118 | $__git_diff_common_options |
2119 | " | |
90131924 SP |
2120 | return |
2121 | ;; | |
2122 | esac | |
2123 | __git_complete_file | |
2124 | } | |
2125 | ||
2ca880fe TR |
2126 | _git_show_branch () |
2127 | { | |
2ca880fe TR |
2128 | case "$cur" in |
2129 | --*) | |
2130 | __gitcomp " | |
2131 | --all --remotes --topo-order --current --more= | |
2132 | --list --independent --merge-base --no-name | |
6123d719 | 2133 | --color --no-color |
076c3237 | 2134 | --sha1-name --sparse --topics --reflog |
2ca880fe TR |
2135 | " |
2136 | return | |
2137 | ;; | |
2138 | esac | |
2139 | __git_complete_revlist | |
2140 | } | |
2141 | ||
7fd53fce JH |
2142 | _git_stash () |
2143 | { | |
59d5eeee | 2144 | local save_opts='--keep-index --no-keep-index --quiet --patch' |
95d43780 | 2145 | local subcommands='save list show apply clear drop pop create branch' |
918c03c2 | 2146 | local subcommand="$(__git_find_on_cmdline "$subcommands")" |
7bedebca | 2147 | if [ -z "$subcommand" ]; then |
59d5eeee SG |
2148 | case "$cur" in |
2149 | --*) | |
2150 | __gitcomp "$save_opts" | |
2151 | ;; | |
2152 | *) | |
2153 | if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then | |
2154 | __gitcomp "$subcommands" | |
2155 | else | |
2156 | COMPREPLY=() | |
2157 | fi | |
2158 | ;; | |
2159 | esac | |
7bedebca | 2160 | else |
7bedebca SG |
2161 | case "$subcommand,$cur" in |
2162 | save,--*) | |
59d5eeee | 2163 | __gitcomp "$save_opts" |
7bedebca | 2164 | ;; |
8513c54b | 2165 | apply,--*|pop,--*) |
59d5eeee | 2166 | __gitcomp "--index --quiet" |
95d43780 | 2167 | ;; |
8513c54b | 2168 | show,--*|drop,--*|branch,--*) |
95d43780 LM |
2169 | COMPREPLY=() |
2170 | ;; | |
2171 | show,*|apply,*|drop,*|pop,*|branch,*) | |
a31e6262 | 2172 | __gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \ |
95d43780 LM |
2173 | | sed -n -e 's/:.*//p')" |
2174 | ;; | |
7bedebca SG |
2175 | *) |
2176 | COMPREPLY=() | |
2177 | ;; | |
2178 | esac | |
3ff1320d | 2179 | fi |
7fd53fce JH |
2180 | } |
2181 | ||
be86f7a0 SP |
2182 | _git_submodule () |
2183 | { | |
d773c631 SG |
2184 | __git_has_doubledash && return |
2185 | ||
1b0f7978 | 2186 | local subcommands="add status init update summary foreach sync" |
918c03c2 | 2187 | if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then |
be86f7a0 SP |
2188 | case "$cur" in |
2189 | --*) | |
2190 | __gitcomp "--quiet --cached" | |
2191 | ;; | |
2192 | *) | |
3ff1320d | 2193 | __gitcomp "$subcommands" |
be86f7a0 SP |
2194 | ;; |
2195 | esac | |
2196 | return | |
2197 | fi | |
2198 | } | |
2199 | ||
47f6ee28 SG |
2200 | _git_svn () |
2201 | { | |
2202 | local subcommands=" | |
2203 | init fetch clone rebase dcommit log find-rev | |
2204 | set-tree commit-diff info create-ignore propget | |
4a5856cb | 2205 | proplist show-ignore show-externals branch tag blame |
c18d5d82 | 2206 | migrate mkdirs reset gc |
47f6ee28 | 2207 | " |
918c03c2 | 2208 | local subcommand="$(__git_find_on_cmdline "$subcommands")" |
47f6ee28 SG |
2209 | if [ -z "$subcommand" ]; then |
2210 | __gitcomp "$subcommands" | |
2211 | else | |
2212 | local remote_opts="--username= --config-dir= --no-auth-cache" | |
2213 | local fc_opts=" | |
2214 | --follow-parent --authors-file= --repack= | |
2215 | --no-metadata --use-svm-props --use-svnsync-props | |
2216 | --log-window-size= --no-checkout --quiet | |
4a5856cb SG |
2217 | --repack-flags --use-log-author --localtime |
2218 | --ignore-paths= $remote_opts | |
47f6ee28 SG |
2219 | " |
2220 | local init_opts=" | |
2221 | --template= --shared= --trunk= --tags= | |
2222 | --branches= --stdlayout --minimize-url | |
2223 | --no-metadata --use-svm-props --use-svnsync-props | |
4a5856cb SG |
2224 | --rewrite-root= --prefix= --use-log-author |
2225 | --add-author-from $remote_opts | |
47f6ee28 SG |
2226 | " |
2227 | local cmt_opts=" | |
2228 | --edit --rmdir --find-copies-harder --copy-similarity= | |
2229 | " | |
2230 | ||
47f6ee28 SG |
2231 | case "$subcommand,$cur" in |
2232 | fetch,--*) | |
2233 | __gitcomp "--revision= --fetch-all $fc_opts" | |
2234 | ;; | |
2235 | clone,--*) | |
2236 | __gitcomp "--revision= $fc_opts $init_opts" | |
2237 | ;; | |
2238 | init,--*) | |
2239 | __gitcomp "$init_opts" | |
2240 | ;; | |
2241 | dcommit,--*) | |
2242 | __gitcomp " | |
2243 | --merge --strategy= --verbose --dry-run | |
4a5856cb | 2244 | --fetch-all --no-rebase --commit-url |
7b151f49 | 2245 | --revision --interactive $cmt_opts $fc_opts |
47f6ee28 SG |
2246 | " |
2247 | ;; | |
2248 | set-tree,--*) | |
2249 | __gitcomp "--stdin $cmt_opts $fc_opts" | |
2250 | ;; | |
2251 | create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\ | |
c18d5d82 | 2252 | show-externals,--*|mkdirs,--*) |
47f6ee28 SG |
2253 | __gitcomp "--revision=" |
2254 | ;; | |
2255 | log,--*) | |
2256 | __gitcomp " | |
2257 | --limit= --revision= --verbose --incremental | |
2258 | --oneline --show-commit --non-recursive | |
4a5856cb | 2259 | --authors-file= --color |
47f6ee28 SG |
2260 | " |
2261 | ;; | |
2262 | rebase,--*) | |
2263 | __gitcomp " | |
2264 | --merge --verbose --strategy= --local | |
4a5856cb | 2265 | --fetch-all --dry-run $fc_opts |
47f6ee28 SG |
2266 | " |
2267 | ;; | |
2268 | commit-diff,--*) | |
2269 | __gitcomp "--message= --file= --revision= $cmt_opts" | |
2270 | ;; | |
2271 | info,--*) | |
2272 | __gitcomp "--url" | |
2273 | ;; | |
4a5856cb SG |
2274 | branch,--*) |
2275 | __gitcomp "--dry-run --message --tag" | |
2276 | ;; | |
2277 | tag,--*) | |
2278 | __gitcomp "--dry-run --message" | |
2279 | ;; | |
2280 | blame,--*) | |
2281 | __gitcomp "--git-format" | |
2282 | ;; | |
2283 | migrate,--*) | |
2284 | __gitcomp " | |
2285 | --config-dir= --ignore-paths= --minimize | |
2286 | --no-auth-cache --username= | |
2287 | " | |
2288 | ;; | |
c18d5d82 RZ |
2289 | reset,--*) |
2290 | __gitcomp "--revision= --parent" | |
2291 | ;; | |
47f6ee28 SG |
2292 | *) |
2293 | COMPREPLY=() | |
2294 | ;; | |
2295 | esac | |
2296 | fi | |
2297 | } | |
2298 | ||
88e21dc7 SP |
2299 | _git_tag () |
2300 | { | |
2301 | local i c=1 f=0 | |
da48616f PD |
2302 | while [ $c -lt $cword ]; do |
2303 | i="${words[c]}" | |
88e21dc7 SP |
2304 | case "$i" in |
2305 | -d|-v) | |
a31e6262 | 2306 | __gitcomp_nl "$(__git_tags)" |
88e21dc7 SP |
2307 | return |
2308 | ;; | |
2309 | -f) | |
2310 | f=1 | |
2311 | ;; | |
2312 | esac | |
6e8c755f | 2313 | ((c++)) |
88e21dc7 SP |
2314 | done |
2315 | ||
da48616f | 2316 | case "$prev" in |
88e21dc7 SP |
2317 | -m|-F) |
2318 | COMPREPLY=() | |
2319 | ;; | |
8d8163f3 | 2320 | -*|tag) |
88e21dc7 | 2321 | if [ $f = 1 ]; then |
a31e6262 | 2322 | __gitcomp_nl "$(__git_tags)" |
88e21dc7 SP |
2323 | else |
2324 | COMPREPLY=() | |
2325 | fi | |
2326 | ;; | |
2327 | *) | |
a31e6262 | 2328 | __gitcomp_nl "$(__git_refs)" |
88e21dc7 SP |
2329 | ;; |
2330 | esac | |
2331 | } | |
2332 | ||
424cce83 SG |
2333 | _git_whatchanged () |
2334 | { | |
2335 | _git_log | |
2336 | } | |
2337 | ||
93b291e0 | 2338 | __git_main () |
690d8824 | 2339 | { |
873537fa SP |
2340 | local i c=1 command __git_dir |
2341 | ||
da48616f PD |
2342 | while [ $c -lt $cword ]; do |
2343 | i="${words[c]}" | |
873537fa SP |
2344 | case "$i" in |
2345 | --git-dir=*) __git_dir="${i#--git-dir=}" ;; | |
2346 | --bare) __git_dir="." ;; | |
1eb7e2f8 | 2347 | --help) command="help"; break ;; |
911d5da6 SG |
2348 | -c) c=$((++c)) ;; |
2349 | -*) ;; | |
873537fa SP |
2350 | *) command="$i"; break ;; |
2351 | esac | |
6e8c755f | 2352 | ((c++)) |
873537fa SP |
2353 | done |
2354 | ||
1d17b22e | 2355 | if [ -z "$command" ]; then |
da48616f | 2356 | case "$cur" in |
47e98eec | 2357 | --*) __gitcomp " |
ce5a2c95 | 2358 | --paginate |
47e98eec SP |
2359 | --no-pager |
2360 | --git-dir= | |
2361 | --bare | |
2362 | --version | |
2363 | --exec-path | |
3ffcd086 | 2364 | --exec-path= |
89a56bfb | 2365 | --html-path |
69ef3c02 | 2366 | --info-path |
ce5a2c95 | 2367 | --work-tree= |
a1bea2c1 | 2368 | --namespace= |
69ef3c02 | 2369 | --no-replace-objects |
ce5a2c95 | 2370 | --help |
47e98eec SP |
2371 | " |
2372 | ;; | |
eaa4e6ee JN |
2373 | *) __git_compute_porcelain_commands |
2374 | __gitcomp "$__git_porcelain_commands $(__git_aliases)" ;; | |
72e5e989 SP |
2375 | esac |
2376 | return | |
873537fa | 2377 | fi |
367dce2a | 2378 | |
424cce83 | 2379 | local completion_func="_git_${command//-/_}" |
06f44c3c | 2380 | declare -f $completion_func >/dev/null && $completion_func && return |
8024ea60 | 2381 | |
873537fa | 2382 | local expansion=$(__git_aliased_command "$command") |
8024ea60 SG |
2383 | if [ -n "$expansion" ]; then |
2384 | completion_func="_git_${expansion//-/_}" | |
06f44c3c | 2385 | declare -f $completion_func >/dev/null && $completion_func |
8024ea60 | 2386 | fi |
690d8824 JH |
2387 | } |
2388 | ||
93b291e0 | 2389 | __gitk_main () |
690d8824 | 2390 | { |
d773c631 SG |
2391 | __git_has_doubledash && return |
2392 | ||
fa26a401 | 2393 | local g="$(__gitdir)" |
07ba53f7 | 2394 | local merge="" |
ba7906f2 | 2395 | if [ -f "$g/MERGE_HEAD" ]; then |
07ba53f7 RQ |
2396 | merge="--merge" |
2397 | fi | |
b3391775 SP |
2398 | case "$cur" in |
2399 | --*) | |
a393777e TR |
2400 | __gitcomp " |
2401 | $__git_log_common_options | |
2402 | $__git_log_gitk_options | |
2403 | $merge | |
2404 | " | |
b3391775 SP |
2405 | return |
2406 | ;; | |
2407 | esac | |
ec804891 | 2408 | __git_complete_revlist |
690d8824 JH |
2409 | } |
2410 | ||
d8b45314 FC |
2411 | if [[ -n ${ZSH_VERSION-} ]]; then |
2412 | echo "WARNING: this script is deprecated, please see git-completion.zsh" 1>&2 | |
6b179adf | 2413 | |
9cd67bd2 FC |
2414 | autoload -U +X compinit && compinit |
2415 | ||
d8b45314 FC |
2416 | __gitcomp () |
2417 | { | |
2418 | emulate -L zsh | |
6b179adf | 2419 | |
d8b45314 FC |
2420 | local cur_="${3-$cur}" |
2421 | ||
2422 | case "$cur_" in | |
2423 | --*=) | |
2424 | ;; | |
2425 | *) | |
2426 | local c IFS=$' \t\n' | |
2427 | local -a array | |
2428 | for c in ${=1}; do | |
2429 | c="$c${4-}" | |
2430 | case $c in | |
2431 | --*=*|*.) ;; | |
2432 | *) c="$c " ;; | |
2433 | esac | |
2434 | array+=("$c") | |
2435 | done | |
2436 | compset -P '*[=:]' | |
2437 | compadd -Q -S '' -p "${2-}" -a -- array && _ret=0 | |
2438 | ;; | |
2439 | esac | |
2440 | } | |
2441 | ||
2442 | __gitcomp_nl () | |
2443 | { | |
2444 | emulate -L zsh | |
2445 | ||
2446 | local IFS=$'\n' | |
2447 | compset -P '*[=:]' | |
2448 | compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0 | |
2449 | } | |
2450 | ||
2451 | __git_zsh_helper () | |
2452 | { | |
2453 | emulate -L ksh | |
2454 | local cur cword prev | |
2455 | cur=${words[CURRENT-1]} | |
2456 | prev=${words[CURRENT-2]} | |
2457 | let cword=CURRENT-1 | |
2458 | __${service}_main | |
2459 | } | |
2460 | ||
2461 | _git () | |
2462 | { | |
2463 | emulate -L zsh | |
2464 | local _ret=1 | |
2465 | __git_zsh_helper | |
2466 | let _ret && _default -S '' && _ret=0 | |
2467 | return _ret | |
2468 | } | |
2469 | ||
2470 | compdef _git git gitk | |
2471 | return | |
2472 | fi | |
2473 | ||
2474 | __git_func_wrap () | |
2475 | { | |
6b179adf FC |
2476 | local cur words cword prev |
2477 | _get_comp_words_by_ref -n =: cur words cword prev | |
2478 | $1 | |
2479 | } | |
2480 | ||
2481 | # Setup completion for certain functions defined above by setting common | |
2482 | # variables and workarounds. | |
2483 | # This is NOT a public function; use at your own risk. | |
2484 | __git_complete () | |
2485 | { | |
2486 | local wrapper="__git_wrap${2}" | |
2487 | eval "$wrapper () { __git_func_wrap $2 ; }" | |
2488 | complete -o bashdefault -o default -o nospace -F $wrapper $1 2>/dev/null \ | |
2489 | || complete -o default -o nospace -F $wrapper $1 | |
2490 | } | |
2491 | ||
b0a4b2d2 FC |
2492 | # wrapper for backwards compatibility |
2493 | _git () | |
2494 | { | |
93b291e0 | 2495 | __git_wrap__git_main |
b0a4b2d2 FC |
2496 | } |
2497 | ||
2498 | # wrapper for backwards compatibility | |
2499 | _gitk () | |
2500 | { | |
93b291e0 | 2501 | __git_wrap__gitk_main |
b0a4b2d2 FC |
2502 | } |
2503 | ||
93b291e0 SG |
2504 | __git_complete git __git_main |
2505 | __git_complete gitk __gitk_main | |
690d8824 JH |
2506 | |
2507 | # The following are necessary only for Cygwin, and only are needed | |
2508 | # when the user has tab-completed the executable name and consequently | |
2509 | # included the '.exe' suffix. | |
2510 | # | |
76c3eb51 | 2511 | if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then |
93b291e0 | 2512 | __git_complete git.exe __git_main |
76c3eb51 | 2513 | fi |