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