]>
Commit | Line | Data |
---|---|---|
690d8824 JH |
1 | # |
2 | # bash completion support for core Git. | |
3 | # | |
c70680ce | 4 | # Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org> |
690d8824 | 5 | # Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/). |
c70680ce | 6 | # Distributed under the GNU General Public License, version 2.0. |
690d8824 JH |
7 | # |
8 | # The contained completion routines provide support for completing: | |
9 | # | |
10 | # *) local and remote branch names | |
11 | # *) local and remote tag names | |
12 | # *) .git/remotes file names | |
13 | # *) git 'subcommands' | |
14 | # *) tree paths within 'ref:path/to/file' expressions | |
c70680ce | 15 | # *) common --long-options |
690d8824 JH |
16 | # |
17 | # To use these routines: | |
18 | # | |
19 | # 1) Copy this file to somewhere (e.g. ~/.git-completion.sh). | |
20 | # 2) Added the following line to your .bashrc: | |
21 | # source ~/.git-completion.sh | |
22 | # | |
b51ec6bd SP |
23 | # 3) You may want to make sure the git executable is available |
24 | # in your PATH before this script is sourced, as some caching | |
25 | # is performed while the script loads. If git isn't found | |
26 | # at source time then all lookups will be done on demand, | |
27 | # which may be slightly slower. | |
28 | # | |
29 | # 4) Consider changing your PS1 to also show the current branch: | |
d3d717a4 SP |
30 | # PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ ' |
31 | # | |
32 | # The argument to __git_ps1 will be displayed only if you | |
33 | # are currently in a git repository. The %s token will be | |
34 | # the name of the current branch. | |
35 | # | |
c70680ce SP |
36 | # To submit patches: |
37 | # | |
38 | # *) Read Documentation/SubmittingPatches | |
39 | # *) Send all patches to the current maintainer: | |
40 | # | |
41 | # "Shawn O. Pearce" <spearce@spearce.org> | |
42 | # | |
43 | # *) Always CC the Git mailing list: | |
44 | # | |
45 | # git@vger.kernel.org | |
46 | # | |
690d8824 | 47 | |
873537fa SP |
48 | __gitdir () |
49 | { | |
67ffa114 SP |
50 | if [ -z "$1" ]; then |
51 | if [ -n "$__git_dir" ]; then | |
52 | echo "$__git_dir" | |
53 | elif [ -d .git ]; then | |
54 | echo .git | |
55 | else | |
56 | git rev-parse --git-dir 2>/dev/null | |
57 | fi | |
58 | elif [ -d "$1/.git" ]; then | |
59 | echo "$1/.git" | |
60 | else | |
61 | echo "$1" | |
62 | fi | |
873537fa SP |
63 | } |
64 | ||
d3d717a4 SP |
65 | __git_ps1 () |
66 | { | |
e7520196 RR |
67 | local g="$(git rev-parse --git-dir 2>/dev/null)" |
68 | if [ -n "$g" ]; then | |
69 | local r | |
70 | local b | |
71 | if [ -d "$g/../.dotest" ] | |
72 | then | |
73 | r="|AM/REBASE" | |
74 | b="$(git symbolic-ref HEAD 2>/dev/null)" | |
75 | elif [ -f "$g/.dotest-merge/interactive" ] | |
76 | then | |
77 | r="|REBASE-i" | |
78 | b="$(cat $g/.dotest-merge/head-name)" | |
79 | elif [ -d "$g/.dotest-merge" ] | |
80 | then | |
81 | r="|REBASE-m" | |
82 | b="$(cat $g/.dotest-merge/head-name)" | |
83 | elif [ -f "$g/MERGE_HEAD" ] | |
84 | then | |
85 | r="|MERGING" | |
86 | b="$(git symbolic-ref HEAD 2>/dev/null)" | |
87 | else | |
88 | if [ -f $g/BISECT_LOG ] | |
89 | then | |
90 | r="|BISECTING" | |
91 | fi | |
92 | if ! b="$(git symbolic-ref HEAD 2>/dev/null)" | |
93 | then | |
27c57888 SP |
94 | if ! b="$(git describe --exact-match HEAD 2>/dev/null)" |
95 | then | |
96 | b="$(cut -c1-7 $g/HEAD)..." | |
97 | fi | |
e7520196 RR |
98 | fi |
99 | fi | |
100 | ||
d3d717a4 | 101 | if [ -n "$1" ]; then |
e7520196 | 102 | printf "$1" "${b##refs/heads/}$r" |
d3d717a4 | 103 | else |
e7520196 | 104 | printf " (%s)" "${b##refs/heads/}$r" |
d3d717a4 SP |
105 | fi |
106 | fi | |
107 | } | |
108 | ||
72e5e989 SP |
109 | __gitcomp () |
110 | { | |
111 | local all c s=$'\n' IFS=' '$'\t'$'\n' | |
78d4d6a2 | 112 | local cur="${COMP_WORDS[COMP_CWORD]}" |
b3391775 | 113 | if [ $# -gt 2 ]; then |
78d4d6a2 SP |
114 | cur="$3" |
115 | fi | |
72e5e989 | 116 | for c in $1; do |
78d4d6a2 SP |
117 | case "$c$4" in |
118 | --*=*) all="$all$c$4$s" ;; | |
119 | *.) all="$all$c$4$s" ;; | |
120 | *) all="$all$c$4 $s" ;; | |
72e5e989 SP |
121 | esac |
122 | done | |
123 | IFS=$s | |
78d4d6a2 | 124 | COMPREPLY=($(compgen -P "$2" -W "$all" -- "$cur")) |
72e5e989 SP |
125 | return |
126 | } | |
127 | ||
5de40f59 SP |
128 | __git_heads () |
129 | { | |
67ffa114 | 130 | local cmd i is_hash=y dir="$(__gitdir "$1")" |
5de40f59 SP |
131 | if [ -d "$dir" ]; then |
132 | for i in $(git --git-dir="$dir" \ | |
133 | for-each-ref --format='%(refname)' \ | |
134 | refs/heads ); do | |
135 | echo "${i#refs/heads/}" | |
136 | done | |
137 | return | |
138 | fi | |
67ffa114 | 139 | for i in $(git-ls-remote "$1" 2>/dev/null); do |
5de40f59 SP |
140 | case "$is_hash,$i" in |
141 | y,*) is_hash=n ;; | |
142 | n,*^{}) is_hash=y ;; | |
143 | n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;; | |
144 | n,*) is_hash=y; echo "$i" ;; | |
145 | esac | |
146 | done | |
147 | } | |
148 | ||
88e21dc7 SP |
149 | __git_tags () |
150 | { | |
151 | local cmd i is_hash=y dir="$(__gitdir "$1")" | |
152 | if [ -d "$dir" ]; then | |
153 | for i in $(git --git-dir="$dir" \ | |
154 | for-each-ref --format='%(refname)' \ | |
155 | refs/tags ); do | |
156 | echo "${i#refs/tags/}" | |
157 | done | |
158 | return | |
159 | fi | |
160 | for i in $(git-ls-remote "$1" 2>/dev/null); do | |
161 | case "$is_hash,$i" in | |
162 | y,*) is_hash=n ;; | |
163 | n,*^{}) is_hash=y ;; | |
164 | n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;; | |
165 | n,*) is_hash=y; echo "$i" ;; | |
166 | esac | |
167 | done | |
168 | } | |
169 | ||
690d8824 JH |
170 | __git_refs () |
171 | { | |
67ffa114 | 172 | local cmd i is_hash=y dir="$(__gitdir "$1")" |
873537fa | 173 | if [ -d "$dir" ]; then |
35e65ecc SP |
174 | if [ -e "$dir/HEAD" ]; then echo HEAD; fi |
175 | for i in $(git --git-dir="$dir" \ | |
176 | for-each-ref --format='%(refname)' \ | |
177 | refs/tags refs/heads refs/remotes); do | |
178 | case "$i" in | |
179 | refs/tags/*) echo "${i#refs/tags/}" ;; | |
180 | refs/heads/*) echo "${i#refs/heads/}" ;; | |
181 | refs/remotes/*) echo "${i#refs/remotes/}" ;; | |
182 | *) echo "$i" ;; | |
183 | esac | |
184 | done | |
185 | return | |
690d8824 | 186 | fi |
35e65ecc | 187 | for i in $(git-ls-remote "$dir" 2>/dev/null); do |
690d8824 JH |
188 | case "$is_hash,$i" in |
189 | y,*) is_hash=n ;; | |
190 | n,*^{}) is_hash=y ;; | |
191 | n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;; | |
192 | n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;; | |
35e65ecc | 193 | n,refs/remotes/*) is_hash=y; echo "${i#refs/remotes/}" ;; |
690d8824 JH |
194 | n,*) is_hash=y; echo "$i" ;; |
195 | esac | |
196 | done | |
197 | } | |
198 | ||
199 | __git_refs2 () | |
200 | { | |
67ffa114 SP |
201 | local i |
202 | for i in $(__git_refs "$1"); do | |
203 | echo "$i:$i" | |
690d8824 JH |
204 | done |
205 | } | |
206 | ||
5de40f59 SP |
207 | __git_refs_remotes () |
208 | { | |
209 | local cmd i is_hash=y | |
210 | for i in $(git-ls-remote "$1" 2>/dev/null); do | |
211 | case "$is_hash,$i" in | |
212 | n,refs/heads/*) | |
213 | is_hash=y | |
214 | echo "$i:refs/remotes/$1/${i#refs/heads/}" | |
215 | ;; | |
216 | y,*) is_hash=n ;; | |
217 | n,*^{}) is_hash=y ;; | |
218 | n,refs/tags/*) is_hash=y;; | |
219 | n,*) is_hash=y; ;; | |
220 | esac | |
221 | done | |
222 | } | |
223 | ||
690d8824 JH |
224 | __git_remotes () |
225 | { | |
873537fa | 226 | local i ngoff IFS=$'\n' d="$(__gitdir)" |
56fc25f2 | 227 | shopt -q nullglob || ngoff=1 |
690d8824 | 228 | shopt -s nullglob |
873537fa SP |
229 | for i in "$d/remotes"/*; do |
230 | echo ${i#$d/remotes/} | |
690d8824 | 231 | done |
56fc25f2 | 232 | [ "$ngoff" ] && shopt -u nullglob |
e0d10e1c | 233 | for i in $(git --git-dir="$d" config --list); do |
56fc25f2 SP |
234 | case "$i" in |
235 | remote.*.url=*) | |
236 | i="${i#remote.}" | |
237 | echo "${i/.url=*/}" | |
238 | ;; | |
239 | esac | |
240 | done | |
690d8824 JH |
241 | } |
242 | ||
4ad91321 SP |
243 | __git_merge_strategies () |
244 | { | |
b51ec6bd SP |
245 | if [ -n "$__git_merge_strategylist" ]; then |
246 | echo "$__git_merge_strategylist" | |
247 | return | |
248 | fi | |
4ad91321 SP |
249 | sed -n "/^all_strategies='/{ |
250 | s/^all_strategies='// | |
251 | s/'// | |
252 | p | |
253 | q | |
254 | }" "$(git --exec-path)/git-merge" | |
255 | } | |
b51ec6bd SP |
256 | __git_merge_strategylist= |
257 | __git_merge_strategylist="$(__git_merge_strategies 2>/dev/null)" | |
4ad91321 | 258 | |
690d8824 JH |
259 | __git_complete_file () |
260 | { | |
a79c6551 | 261 | local pfx ls ref cur="${COMP_WORDS[COMP_CWORD]}" |
690d8824 JH |
262 | case "$cur" in |
263 | ?*:*) | |
a79c6551 SP |
264 | ref="${cur%%:*}" |
265 | cur="${cur#*:}" | |
690d8824 JH |
266 | case "$cur" in |
267 | ?*/*) | |
a79c6551 SP |
268 | pfx="${cur%/*}" |
269 | cur="${cur##*/}" | |
690d8824 JH |
270 | ls="$ref:$pfx" |
271 | pfx="$pfx/" | |
272 | ;; | |
273 | *) | |
274 | ls="$ref" | |
275 | ;; | |
276 | esac | |
277 | COMPREPLY=($(compgen -P "$pfx" \ | |
873537fa | 278 | -W "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \ |
690d8824 JH |
279 | | sed '/^100... blob /s,^.* ,, |
280 | /^040000 tree /{ | |
281 | s,^.* ,, | |
282 | s,$,/, | |
283 | } | |
284 | s/^.* //')" \ | |
285 | -- "$cur")) | |
286 | ;; | |
287 | *) | |
b3391775 | 288 | __gitcomp "$(__git_refs)" |
690d8824 JH |
289 | ;; |
290 | esac | |
291 | } | |
292 | ||
f53352fb SP |
293 | __git_complete_revlist () |
294 | { | |
295 | local pfx cur="${COMP_WORDS[COMP_CWORD]}" | |
296 | case "$cur" in | |
297 | *...*) | |
298 | pfx="${cur%...*}..." | |
299 | cur="${cur#*...}" | |
b3391775 | 300 | __gitcomp "$(__git_refs)" "$pfx" "$cur" |
f53352fb SP |
301 | ;; |
302 | *..*) | |
303 | pfx="${cur%..*}.." | |
304 | cur="${cur#*..}" | |
b3391775 SP |
305 | __gitcomp "$(__git_refs)" "$pfx" "$cur" |
306 | ;; | |
307 | *.) | |
308 | __gitcomp "$cur." | |
f53352fb SP |
309 | ;; |
310 | *) | |
b3391775 | 311 | __gitcomp "$(__git_refs)" |
f53352fb SP |
312 | ;; |
313 | esac | |
314 | } | |
315 | ||
f2bb9f88 SP |
316 | __git_commands () |
317 | { | |
b51ec6bd SP |
318 | if [ -n "$__git_commandlist" ]; then |
319 | echo "$__git_commandlist" | |
320 | return | |
321 | fi | |
f2bb9f88 SP |
322 | local i IFS=" "$'\n' |
323 | for i in $(git help -a|egrep '^ ') | |
324 | do | |
325 | case $i in | |
718a087a | 326 | *--*) : helper pattern;; |
a925c6f1 SP |
327 | applymbox) : ask gittus;; |
328 | applypatch) : ask gittus;; | |
329 | archimport) : import;; | |
2e3a430a | 330 | cat-file) : plumbing;; |
56d99c67 | 331 | check-attr) : plumbing;; |
f2bb9f88 SP |
332 | check-ref-format) : plumbing;; |
333 | commit-tree) : plumbing;; | |
a925c6f1 SP |
334 | cvsexportcommit) : export;; |
335 | cvsimport) : import;; | |
f2bb9f88 SP |
336 | cvsserver) : daemon;; |
337 | daemon) : daemon;; | |
5cfb4fe5 SP |
338 | diff-files) : plumbing;; |
339 | diff-index) : plumbing;; | |
340 | diff-tree) : plumbing;; | |
c6ec3b13 | 341 | fast-import) : import;; |
a925c6f1 | 342 | fsck-objects) : plumbing;; |
f2bb9f88 | 343 | fetch-pack) : plumbing;; |
a925c6f1 | 344 | fmt-merge-msg) : plumbing;; |
56d99c67 | 345 | for-each-ref) : plumbing;; |
f2bb9f88 SP |
346 | hash-object) : plumbing;; |
347 | http-*) : transport;; | |
348 | index-pack) : plumbing;; | |
a925c6f1 | 349 | init-db) : deprecated;; |
f2bb9f88 SP |
350 | local-fetch) : plumbing;; |
351 | mailinfo) : plumbing;; | |
352 | mailsplit) : plumbing;; | |
353 | merge-*) : plumbing;; | |
354 | mktree) : plumbing;; | |
355 | mktag) : plumbing;; | |
356 | pack-objects) : plumbing;; | |
357 | pack-redundant) : plumbing;; | |
358 | pack-refs) : plumbing;; | |
359 | parse-remote) : plumbing;; | |
360 | patch-id) : plumbing;; | |
361 | peek-remote) : plumbing;; | |
a925c6f1 SP |
362 | prune) : plumbing;; |
363 | prune-packed) : plumbing;; | |
364 | quiltimport) : import;; | |
f2bb9f88 SP |
365 | read-tree) : plumbing;; |
366 | receive-pack) : plumbing;; | |
2e3a430a | 367 | reflog) : plumbing;; |
5c66d0d4 | 368 | repo-config) : deprecated;; |
f2bb9f88 SP |
369 | rerere) : plumbing;; |
370 | rev-list) : plumbing;; | |
371 | rev-parse) : plumbing;; | |
372 | runstatus) : plumbing;; | |
373 | sh-setup) : internal;; | |
374 | shell) : daemon;; | |
375 | send-pack) : plumbing;; | |
376 | show-index) : plumbing;; | |
377 | ssh-*) : transport;; | |
378 | stripspace) : plumbing;; | |
a925c6f1 | 379 | svn) : import export;; |
f2bb9f88 | 380 | symbolic-ref) : plumbing;; |
a925c6f1 | 381 | tar-tree) : deprecated;; |
f2bb9f88 SP |
382 | unpack-file) : plumbing;; |
383 | unpack-objects) : plumbing;; | |
a925c6f1 | 384 | update-index) : plumbing;; |
f2bb9f88 SP |
385 | update-ref) : plumbing;; |
386 | update-server-info) : daemon;; | |
387 | upload-archive) : plumbing;; | |
388 | upload-pack) : plumbing;; | |
389 | write-tree) : plumbing;; | |
a925c6f1 | 390 | verify-tag) : plumbing;; |
f2bb9f88 SP |
391 | *) echo $i;; |
392 | esac | |
393 | done | |
394 | } | |
b51ec6bd SP |
395 | __git_commandlist= |
396 | __git_commandlist="$(__git_commands 2>/dev/null)" | |
f2bb9f88 | 397 | |
367dce2a DS |
398 | __git_aliases () |
399 | { | |
56fc25f2 | 400 | local i IFS=$'\n' |
e0d10e1c | 401 | for i in $(git --git-dir="$(__gitdir)" config --list); do |
56fc25f2 SP |
402 | case "$i" in |
403 | alias.*) | |
404 | i="${i#alias.}" | |
405 | echo "${i/=*/}" | |
406 | ;; | |
407 | esac | |
408 | done | |
367dce2a DS |
409 | } |
410 | ||
411 | __git_aliased_command () | |
412 | { | |
873537fa | 413 | local word cmdline=$(git --git-dir="$(__gitdir)" \ |
e0d10e1c | 414 | config --get "alias.$1") |
367dce2a DS |
415 | for word in $cmdline; do |
416 | if [ "${word##-*}" ]; then | |
417 | echo $word | |
418 | return | |
419 | fi | |
420 | done | |
421 | } | |
422 | ||
88329195 SP |
423 | __git_whitespacelist="nowarn warn error error-all strip" |
424 | ||
425 | _git_am () | |
426 | { | |
427 | local cur="${COMP_WORDS[COMP_CWORD]}" | |
428 | if [ -d .dotest ]; then | |
b3391775 | 429 | __gitcomp "--skip --resolved" |
88329195 SP |
430 | return |
431 | fi | |
432 | case "$cur" in | |
433 | --whitespace=*) | |
b3391775 | 434 | __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}" |
88329195 SP |
435 | return |
436 | ;; | |
437 | --*) | |
b3391775 | 438 | __gitcomp " |
88329195 SP |
439 | --signoff --utf8 --binary --3way --interactive |
440 | --whitespace= | |
b3391775 | 441 | " |
88329195 SP |
442 | return |
443 | esac | |
444 | COMPREPLY=() | |
445 | } | |
446 | ||
447 | _git_apply () | |
448 | { | |
449 | local cur="${COMP_WORDS[COMP_CWORD]}" | |
450 | case "$cur" in | |
451 | --whitespace=*) | |
b3391775 | 452 | __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}" |
88329195 SP |
453 | return |
454 | ;; | |
455 | --*) | |
b3391775 | 456 | __gitcomp " |
88329195 SP |
457 | --stat --numstat --summary --check --index |
458 | --cached --index-info --reverse --reject --unidiff-zero | |
459 | --apply --no-add --exclude= | |
460 | --whitespace= --inaccurate-eof --verbose | |
b3391775 | 461 | " |
88329195 SP |
462 | return |
463 | esac | |
464 | COMPREPLY=() | |
465 | } | |
466 | ||
8435b548 SP |
467 | _git_add () |
468 | { | |
469 | local cur="${COMP_WORDS[COMP_CWORD]}" | |
470 | case "$cur" in | |
471 | --*) | |
47e98eec | 472 | __gitcomp "--interactive --refresh" |
8435b548 SP |
473 | return |
474 | esac | |
475 | COMPREPLY=() | |
476 | } | |
477 | ||
b2e69f62 SP |
478 | _git_bisect () |
479 | { | |
480 | local i c=1 command | |
481 | while [ $c -lt $COMP_CWORD ]; do | |
482 | i="${COMP_WORDS[c]}" | |
483 | case "$i" in | |
484 | start|bad|good|reset|visualize|replay|log) | |
485 | command="$i" | |
486 | break | |
487 | ;; | |
488 | esac | |
489 | c=$((++c)) | |
490 | done | |
491 | ||
492 | if [ $c -eq $COMP_CWORD -a -z "$command" ]; then | |
493 | __gitcomp "start bad good reset visualize replay log" | |
494 | return | |
495 | fi | |
496 | ||
497 | case "$command" in | |
498 | bad|good|reset) | |
499 | __gitcomp "$(__git_refs)" | |
500 | ;; | |
501 | *) | |
502 | COMPREPLY=() | |
503 | ;; | |
504 | esac | |
505 | } | |
506 | ||
690d8824 JH |
507 | _git_branch () |
508 | { | |
b3391775 | 509 | __gitcomp "$(__git_refs)" |
690d8824 JH |
510 | } |
511 | ||
374a58c9 ML |
512 | _git_bundle () |
513 | { | |
514 | local mycword="$COMP_CWORD" | |
515 | case "${COMP_WORDS[0]}" in | |
516 | git) | |
517 | local cmd="${COMP_WORDS[2]}" | |
518 | mycword="$((mycword-1))" | |
519 | ;; | |
520 | git-bundle*) | |
521 | local cmd="${COMP_WORDS[1]}" | |
522 | ;; | |
523 | esac | |
524 | case "$mycword" in | |
525 | 1) | |
526 | __gitcomp "create list-heads verify unbundle" | |
527 | ;; | |
528 | 2) | |
529 | # looking for a file | |
530 | ;; | |
531 | *) | |
532 | case "$cmd" in | |
533 | create) | |
534 | __git_complete_revlist | |
535 | ;; | |
536 | esac | |
537 | ;; | |
538 | esac | |
539 | } | |
540 | ||
690d8824 JH |
541 | _git_checkout () |
542 | { | |
b3391775 | 543 | __gitcomp "$(__git_refs)" |
690d8824 JH |
544 | } |
545 | ||
d8a9fea5 SP |
546 | _git_cherry () |
547 | { | |
548 | __gitcomp "$(__git_refs)" | |
549 | } | |
550 | ||
1273231e SP |
551 | _git_cherry_pick () |
552 | { | |
553 | local cur="${COMP_WORDS[COMP_CWORD]}" | |
554 | case "$cur" in | |
555 | --*) | |
b3391775 | 556 | __gitcomp "--edit --no-commit" |
1273231e SP |
557 | ;; |
558 | *) | |
b3391775 | 559 | __gitcomp "$(__git_refs)" |
1273231e SP |
560 | ;; |
561 | esac | |
562 | } | |
563 | ||
4548e855 SP |
564 | _git_commit () |
565 | { | |
566 | local cur="${COMP_WORDS[COMP_CWORD]}" | |
567 | case "$cur" in | |
568 | --*) | |
b3391775 | 569 | __gitcomp " |
4548e855 SP |
570 | --all --author= --signoff --verify --no-verify |
571 | --edit --amend --include --only | |
b3391775 | 572 | " |
4548e855 SP |
573 | return |
574 | esac | |
575 | COMPREPLY=() | |
576 | } | |
577 | ||
217926c0 SP |
578 | _git_describe () |
579 | { | |
580 | __gitcomp "$(__git_refs)" | |
581 | } | |
582 | ||
690d8824 JH |
583 | _git_diff () |
584 | { | |
b3a4f858 JS |
585 | local cur="${COMP_WORDS[COMP_CWORD]}" |
586 | case "$cur" in | |
587 | --*) | |
588 | __gitcomp "--cached --stat --numstat --shortstat --summary | |
589 | --patch-with-stat --name-only --name-status --color | |
590 | --no-color --color-words --no-renames --check | |
591 | --full-index --binary --abbrev --diff-filter | |
592 | --find-copies-harder --pickaxe-all --pickaxe-regex | |
593 | --text --ignore-space-at-eol --ignore-space-change | |
594 | --ignore-all-space --exit-code --quiet --ext-diff | |
595 | --no-ext-diff" | |
596 | return | |
597 | ;; | |
598 | esac | |
690d8824 JH |
599 | __git_complete_file |
600 | } | |
601 | ||
602 | _git_diff_tree () | |
603 | { | |
b3391775 | 604 | __gitcomp "$(__git_refs)" |
690d8824 JH |
605 | } |
606 | ||
607 | _git_fetch () | |
608 | { | |
609 | local cur="${COMP_WORDS[COMP_CWORD]}" | |
610 | ||
611 | case "${COMP_WORDS[0]},$COMP_CWORD" in | |
612 | git-fetch*,1) | |
b3391775 | 613 | __gitcomp "$(__git_remotes)" |
690d8824 JH |
614 | ;; |
615 | git,2) | |
b3391775 | 616 | __gitcomp "$(__git_remotes)" |
690d8824 JH |
617 | ;; |
618 | *) | |
619 | case "$cur" in | |
620 | *:*) | |
b3391775 | 621 | __gitcomp "$(__git_refs)" "" "${cur#*:}" |
690d8824 JH |
622 | ;; |
623 | *) | |
624 | local remote | |
625 | case "${COMP_WORDS[0]}" in | |
626 | git-fetch) remote="${COMP_WORDS[1]}" ;; | |
627 | git) remote="${COMP_WORDS[2]}" ;; | |
628 | esac | |
b3391775 | 629 | __gitcomp "$(__git_refs2 "$remote")" |
690d8824 JH |
630 | ;; |
631 | esac | |
632 | ;; | |
633 | esac | |
634 | } | |
635 | ||
f53352fb SP |
636 | _git_format_patch () |
637 | { | |
638 | local cur="${COMP_WORDS[COMP_CWORD]}" | |
639 | case "$cur" in | |
640 | --*) | |
b3391775 | 641 | __gitcomp " |
f53352fb SP |
642 | --stdout --attach --thread |
643 | --output-directory | |
644 | --numbered --start-number | |
47e98eec | 645 | --numbered-files |
f53352fb SP |
646 | --keep-subject |
647 | --signoff | |
648 | --in-reply-to= | |
649 | --full-index --binary | |
ec804891 | 650 | --not --all |
be5f5bf0 | 651 | --cover-letter |
b3391775 | 652 | " |
f53352fb SP |
653 | return |
654 | ;; | |
655 | esac | |
656 | __git_complete_revlist | |
657 | } | |
658 | ||
b26c8748 SP |
659 | _git_gc () |
660 | { | |
661 | local cur="${COMP_WORDS[COMP_CWORD]}" | |
662 | case "$cur" in | |
663 | --*) | |
47e98eec | 664 | __gitcomp "--prune --aggressive" |
b26c8748 SP |
665 | return |
666 | ;; | |
667 | esac | |
668 | COMPREPLY=() | |
669 | } | |
670 | ||
690d8824 JH |
671 | _git_ls_remote () |
672 | { | |
b3391775 | 673 | __gitcomp "$(__git_remotes)" |
690d8824 JH |
674 | } |
675 | ||
676 | _git_ls_tree () | |
677 | { | |
678 | __git_complete_file | |
679 | } | |
680 | ||
681 | _git_log () | |
682 | { | |
6e31b866 SP |
683 | local cur="${COMP_WORDS[COMP_CWORD]}" |
684 | case "$cur" in | |
685 | --pretty=*) | |
b3391775 | 686 | __gitcomp " |
6e31b866 | 687 | oneline short medium full fuller email raw |
b3391775 | 688 | " "" "${cur##--pretty=}" |
6e31b866 SP |
689 | return |
690 | ;; | |
47e98eec SP |
691 | --date=*) |
692 | __gitcomp " | |
693 | relative iso8601 rfc2822 short local default | |
694 | " "" "${cur##--date=}" | |
695 | return | |
696 | ;; | |
6e31b866 | 697 | --*) |
b3391775 | 698 | __gitcomp " |
6e31b866 SP |
699 | --max-count= --max-age= --since= --after= |
700 | --min-age= --before= --until= | |
8f87fae6 | 701 | --root --topo-order --date-order --reverse |
47e98eec | 702 | --no-merges --follow |
6e31b866 | 703 | --abbrev-commit --abbrev= |
47e98eec | 704 | --relative-date --date= |
6e31b866 SP |
705 | --author= --committer= --grep= |
706 | --all-match | |
8f87fae6 | 707 | --pretty= --name-status --name-only --raw |
ec804891 | 708 | --not --all |
7d37b5bf | 709 | --left-right --cherry-pick |
b3391775 | 710 | " |
6e31b866 SP |
711 | return |
712 | ;; | |
713 | esac | |
f53352fb | 714 | __git_complete_revlist |
690d8824 JH |
715 | } |
716 | ||
4ad91321 SP |
717 | _git_merge () |
718 | { | |
719 | local cur="${COMP_WORDS[COMP_CWORD]}" | |
ce1e39d2 SP |
720 | case "${COMP_WORDS[COMP_CWORD-1]}" in |
721 | -s|--strategy) | |
b3391775 | 722 | __gitcomp "$(__git_merge_strategies)" |
ce1e39d2 SP |
723 | return |
724 | esac | |
4ad91321 | 725 | case "$cur" in |
ce1e39d2 | 726 | --strategy=*) |
b3391775 | 727 | __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}" |
ce1e39d2 SP |
728 | return |
729 | ;; | |
4ad91321 | 730 | --*) |
b3391775 | 731 | __gitcomp " |
61d926a3 | 732 | --no-commit --no-summary --squash --strategy |
b3391775 | 733 | " |
4ad91321 SP |
734 | return |
735 | esac | |
b3391775 | 736 | __gitcomp "$(__git_refs)" |
4ad91321 SP |
737 | } |
738 | ||
690d8824 JH |
739 | _git_merge_base () |
740 | { | |
b3391775 | 741 | __gitcomp "$(__git_refs)" |
690d8824 JH |
742 | } |
743 | ||
d33909bf SP |
744 | _git_name_rev () |
745 | { | |
b3391775 | 746 | __gitcomp "--tags --all --stdin" |
d33909bf SP |
747 | } |
748 | ||
690d8824 JH |
749 | _git_pull () |
750 | { | |
751 | local cur="${COMP_WORDS[COMP_CWORD]}" | |
752 | ||
753 | case "${COMP_WORDS[0]},$COMP_CWORD" in | |
754 | git-pull*,1) | |
b3391775 | 755 | __gitcomp "$(__git_remotes)" |
690d8824 JH |
756 | ;; |
757 | git,2) | |
b3391775 | 758 | __gitcomp "$(__git_remotes)" |
690d8824 JH |
759 | ;; |
760 | *) | |
761 | local remote | |
762 | case "${COMP_WORDS[0]}" in | |
763 | git-pull) remote="${COMP_WORDS[1]}" ;; | |
764 | git) remote="${COMP_WORDS[2]}" ;; | |
765 | esac | |
b3391775 | 766 | __gitcomp "$(__git_refs "$remote")" |
690d8824 JH |
767 | ;; |
768 | esac | |
769 | } | |
770 | ||
771 | _git_push () | |
772 | { | |
773 | local cur="${COMP_WORDS[COMP_CWORD]}" | |
774 | ||
775 | case "${COMP_WORDS[0]},$COMP_CWORD" in | |
776 | git-push*,1) | |
b3391775 | 777 | __gitcomp "$(__git_remotes)" |
690d8824 JH |
778 | ;; |
779 | git,2) | |
b3391775 | 780 | __gitcomp "$(__git_remotes)" |
690d8824 JH |
781 | ;; |
782 | *) | |
783 | case "$cur" in | |
784 | *:*) | |
785 | local remote | |
786 | case "${COMP_WORDS[0]}" in | |
787 | git-push) remote="${COMP_WORDS[1]}" ;; | |
788 | git) remote="${COMP_WORDS[2]}" ;; | |
789 | esac | |
b3391775 | 790 | __gitcomp "$(__git_refs "$remote")" "" "${cur#*:}" |
690d8824 | 791 | ;; |
161fea83 SP |
792 | +*) |
793 | __gitcomp "$(__git_refs)" + "${cur#+}" | |
794 | ;; | |
690d8824 | 795 | *) |
92d7c8e3 | 796 | __gitcomp "$(__git_refs)" |
690d8824 JH |
797 | ;; |
798 | esac | |
799 | ;; | |
800 | esac | |
801 | } | |
802 | ||
61d926a3 SP |
803 | _git_rebase () |
804 | { | |
805 | local cur="${COMP_WORDS[COMP_CWORD]}" | |
c5650b08 | 806 | if [ -d .dotest ] || [ -d .git/.dotest-merge ]; then |
b3391775 | 807 | __gitcomp "--continue --skip --abort" |
61d926a3 SP |
808 | return |
809 | fi | |
ce1e39d2 SP |
810 | case "${COMP_WORDS[COMP_CWORD-1]}" in |
811 | -s|--strategy) | |
b3391775 | 812 | __gitcomp "$(__git_merge_strategies)" |
ce1e39d2 SP |
813 | return |
814 | esac | |
61d926a3 | 815 | case "$cur" in |
ce1e39d2 | 816 | --strategy=*) |
b3391775 | 817 | __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}" |
ce1e39d2 SP |
818 | return |
819 | ;; | |
61d926a3 | 820 | --*) |
b3391775 | 821 | __gitcomp "--onto --merge --strategy" |
61d926a3 SP |
822 | return |
823 | esac | |
b3391775 | 824 | __gitcomp "$(__git_refs)" |
61d926a3 SP |
825 | } |
826 | ||
e0d10e1c | 827 | _git_config () |
5de40f59 SP |
828 | { |
829 | local cur="${COMP_WORDS[COMP_CWORD]}" | |
830 | local prv="${COMP_WORDS[COMP_CWORD-1]}" | |
831 | case "$prv" in | |
832 | branch.*.remote) | |
78d4d6a2 | 833 | __gitcomp "$(__git_remotes)" |
5de40f59 SP |
834 | return |
835 | ;; | |
836 | branch.*.merge) | |
78d4d6a2 | 837 | __gitcomp "$(__git_refs)" |
5de40f59 SP |
838 | return |
839 | ;; | |
840 | remote.*.fetch) | |
841 | local remote="${prv#remote.}" | |
842 | remote="${remote%.fetch}" | |
78d4d6a2 | 843 | __gitcomp "$(__git_refs_remotes "$remote")" |
5de40f59 SP |
844 | return |
845 | ;; | |
846 | remote.*.push) | |
847 | local remote="${prv#remote.}" | |
848 | remote="${remote%.push}" | |
78d4d6a2 | 849 | __gitcomp "$(git --git-dir="$(__gitdir)" \ |
5de40f59 | 850 | for-each-ref --format='%(refname):%(refname)' \ |
78d4d6a2 SP |
851 | refs/heads)" |
852 | return | |
853 | ;; | |
854 | pull.twohead|pull.octopus) | |
855 | __gitcomp "$(__git_merge_strategies)" | |
856 | return | |
857 | ;; | |
858 | color.branch|color.diff|color.status) | |
859 | __gitcomp "always never auto" | |
860 | return | |
861 | ;; | |
862 | color.*.*) | |
863 | __gitcomp " | |
864 | black red green yellow blue magenta cyan white | |
865 | bold dim ul blink reverse | |
866 | " | |
5de40f59 SP |
867 | return |
868 | ;; | |
869 | *.*) | |
870 | COMPREPLY=() | |
871 | return | |
872 | ;; | |
873 | esac | |
874 | case "$cur" in | |
875 | --*) | |
78d4d6a2 | 876 | __gitcomp " |
47e98eec | 877 | --global --system --file= |
12977705 | 878 | --list --replace-all |
5de40f59 | 879 | --get --get-all --get-regexp |
1b71eb35 | 880 | --add --unset --unset-all |
12977705 | 881 | --remove-section --rename-section |
78d4d6a2 | 882 | " |
5de40f59 SP |
883 | return |
884 | ;; | |
885 | branch.*.*) | |
886 | local pfx="${cur%.*}." | |
887 | cur="${cur##*.}" | |
78d4d6a2 | 888 | __gitcomp "remote merge" "$pfx" "$cur" |
5de40f59 SP |
889 | return |
890 | ;; | |
891 | branch.*) | |
892 | local pfx="${cur%.*}." | |
893 | cur="${cur#*.}" | |
78d4d6a2 | 894 | __gitcomp "$(__git_heads)" "$pfx" "$cur" "." |
5de40f59 SP |
895 | return |
896 | ;; | |
897 | remote.*.*) | |
898 | local pfx="${cur%.*}." | |
899 | cur="${cur##*.}" | |
12977705 SP |
900 | __gitcomp " |
901 | url fetch push skipDefaultUpdate | |
902 | receivepack uploadpack tagopt | |
903 | " "$pfx" "$cur" | |
5de40f59 SP |
904 | return |
905 | ;; | |
906 | remote.*) | |
907 | local pfx="${cur%.*}." | |
908 | cur="${cur#*.}" | |
78d4d6a2 | 909 | __gitcomp "$(__git_remotes)" "$pfx" "$cur" "." |
5de40f59 SP |
910 | return |
911 | ;; | |
912 | esac | |
78d4d6a2 | 913 | __gitcomp " |
5de40f59 SP |
914 | apply.whitespace |
915 | core.fileMode | |
916 | core.gitProxy | |
917 | core.ignoreStat | |
918 | core.preferSymlinkRefs | |
919 | core.logAllRefUpdates | |
47e98eec | 920 | core.loosecompression |
5de40f59 SP |
921 | core.repositoryFormatVersion |
922 | core.sharedRepository | |
923 | core.warnAmbiguousRefs | |
924 | core.compression | |
925 | core.legacyHeaders | |
78d4d6a2 SP |
926 | core.packedGitWindowSize |
927 | core.packedGitLimit | |
2122591b | 928 | clean.requireForce |
78d4d6a2 SP |
929 | color.branch |
930 | color.branch.current | |
931 | color.branch.local | |
932 | color.branch.remote | |
933 | color.branch.plain | |
a159ca0c | 934 | color.diff |
78d4d6a2 SP |
935 | color.diff.plain |
936 | color.diff.meta | |
937 | color.diff.frag | |
938 | color.diff.old | |
939 | color.diff.new | |
940 | color.diff.commit | |
941 | color.diff.whitespace | |
a159ca0c | 942 | color.pager |
a159ca0c | 943 | color.status |
78d4d6a2 SP |
944 | color.status.header |
945 | color.status.added | |
946 | color.status.changed | |
947 | color.status.untracked | |
948 | diff.renameLimit | |
949 | diff.renames | |
950 | fetch.unpackLimit | |
951 | format.headers | |
47e98eec | 952 | format.subjectprefix |
78d4d6a2 SP |
953 | gitcvs.enabled |
954 | gitcvs.logfile | |
12977705 SP |
955 | gitcvs.allbinary |
956 | gitcvs.dbname gitcvs.dbdriver gitcvs.dbuser gitcvs.dvpass | |
957 | gc.packrefs | |
78d4d6a2 SP |
958 | gc.reflogexpire |
959 | gc.reflogexpireunreachable | |
960 | gc.rerereresolved | |
961 | gc.rerereunresolved | |
5de40f59 SP |
962 | http.sslVerify |
963 | http.sslCert | |
964 | http.sslKey | |
965 | http.sslCAInfo | |
966 | http.sslCAPath | |
967 | http.maxRequests | |
78d4d6a2 SP |
968 | http.lowSpeedLimit |
969 | http.lowSpeedTime | |
5de40f59 | 970 | http.noEPSV |
78d4d6a2 SP |
971 | i18n.commitEncoding |
972 | i18n.logOutputEncoding | |
973 | log.showroot | |
12977705 | 974 | merge.tool |
78d4d6a2 SP |
975 | merge.summary |
976 | merge.verbosity | |
5de40f59 | 977 | pack.window |
12977705 | 978 | pack.depth |
47e98eec SP |
979 | pack.windowMemory |
980 | pack.compression | |
981 | pack.deltaCacheSize | |
982 | pack.deltaCacheLimit | |
78d4d6a2 SP |
983 | pull.octopus |
984 | pull.twohead | |
5de40f59 | 985 | repack.useDeltaBaseOffset |
78d4d6a2 SP |
986 | show.difftree |
987 | showbranch.default | |
988 | tar.umask | |
989 | transfer.unpackLimit | |
5de40f59 SP |
990 | receive.unpackLimit |
991 | receive.denyNonFastForwards | |
78d4d6a2 SP |
992 | user.name |
993 | user.email | |
994 | user.signingkey | |
995 | whatchanged.difftree | |
5de40f59 | 996 | branch. remote. |
78d4d6a2 | 997 | " |
5de40f59 SP |
998 | } |
999 | ||
88293c67 SP |
1000 | _git_remote () |
1001 | { | |
1002 | local i c=1 command | |
1003 | while [ $c -lt $COMP_CWORD ]; do | |
1004 | i="${COMP_WORDS[c]}" | |
1005 | case "$i" in | |
a3b811a4 | 1006 | add|rm|show|prune|update) command="$i"; break ;; |
88293c67 SP |
1007 | esac |
1008 | c=$((++c)) | |
1009 | done | |
1010 | ||
1011 | if [ $c -eq $COMP_CWORD -a -z "$command" ]; then | |
a3b811a4 | 1012 | __gitcomp "add rm show prune update" |
88293c67 SP |
1013 | return |
1014 | fi | |
1015 | ||
1016 | case "$command" in | |
a3b811a4 | 1017 | rm|show|prune) |
88293c67 SP |
1018 | __gitcomp "$(__git_remotes)" |
1019 | ;; | |
fb72759b SP |
1020 | update) |
1021 | local i c='' IFS=$'\n' | |
1022 | for i in $(git --git-dir="$(__gitdir)" config --list); do | |
1023 | case "$i" in | |
1024 | remotes.*) | |
1025 | i="${i#remotes.}" | |
1026 | c="$c ${i/=*/}" | |
1027 | ;; | |
1028 | esac | |
1029 | done | |
1030 | __gitcomp "$c" | |
1031 | ;; | |
88293c67 SP |
1032 | *) |
1033 | COMPREPLY=() | |
1034 | ;; | |
1035 | esac | |
1036 | } | |
1037 | ||
67e78c3b SP |
1038 | _git_reset () |
1039 | { | |
1040 | local cur="${COMP_WORDS[COMP_CWORD]}" | |
b3391775 SP |
1041 | case "$cur" in |
1042 | --*) | |
1043 | __gitcomp "--mixed --hard --soft" | |
1044 | return | |
1045 | ;; | |
1046 | esac | |
1047 | __gitcomp "$(__git_refs)" | |
67e78c3b SP |
1048 | } |
1049 | ||
1fd6bec9 SP |
1050 | _git_shortlog () |
1051 | { | |
1052 | local cur="${COMP_WORDS[COMP_CWORD]}" | |
1053 | case "$cur" in | |
1054 | --*) | |
1055 | __gitcomp " | |
1056 | --max-count= --max-age= --since= --after= | |
1057 | --min-age= --before= --until= | |
1058 | --no-merges | |
1059 | --author= --committer= --grep= | |
1060 | --all-match | |
1061 | --not --all | |
1062 | --numbered --summary | |
1063 | " | |
1064 | return | |
1065 | ;; | |
1066 | esac | |
1067 | __git_complete_revlist | |
1068 | } | |
1069 | ||
90131924 SP |
1070 | _git_show () |
1071 | { | |
1072 | local cur="${COMP_WORDS[COMP_CWORD]}" | |
1073 | case "$cur" in | |
1074 | --pretty=*) | |
b3391775 | 1075 | __gitcomp " |
90131924 | 1076 | oneline short medium full fuller email raw |
b3391775 | 1077 | " "" "${cur##--pretty=}" |
90131924 SP |
1078 | return |
1079 | ;; | |
1080 | --*) | |
b3391775 | 1081 | __gitcomp "--pretty=" |
90131924 SP |
1082 | return |
1083 | ;; | |
1084 | esac | |
1085 | __git_complete_file | |
1086 | } | |
1087 | ||
7fd53fce JH |
1088 | _git_stash () |
1089 | { | |
1090 | __gitcomp 'list show apply clear' | |
1091 | } | |
1092 | ||
be86f7a0 SP |
1093 | _git_submodule () |
1094 | { | |
1095 | local i c=1 command | |
1096 | while [ $c -lt $COMP_CWORD ]; do | |
1097 | i="${COMP_WORDS[c]}" | |
1098 | case "$i" in | |
1099 | add|status|init|update) command="$i"; break ;; | |
1100 | esac | |
1101 | c=$((++c)) | |
1102 | done | |
1103 | ||
1104 | if [ $c -eq $COMP_CWORD -a -z "$command" ]; then | |
1105 | local cur="${COMP_WORDS[COMP_CWORD]}" | |
1106 | case "$cur" in | |
1107 | --*) | |
1108 | __gitcomp "--quiet --cached" | |
1109 | ;; | |
1110 | *) | |
1111 | __gitcomp "add status init update" | |
1112 | ;; | |
1113 | esac | |
1114 | return | |
1115 | fi | |
1116 | } | |
1117 | ||
88e21dc7 SP |
1118 | _git_tag () |
1119 | { | |
1120 | local i c=1 f=0 | |
1121 | while [ $c -lt $COMP_CWORD ]; do | |
1122 | i="${COMP_WORDS[c]}" | |
1123 | case "$i" in | |
1124 | -d|-v) | |
1125 | __gitcomp "$(__git_tags)" | |
1126 | return | |
1127 | ;; | |
1128 | -f) | |
1129 | f=1 | |
1130 | ;; | |
1131 | esac | |
1132 | c=$((++c)) | |
1133 | done | |
1134 | ||
1135 | case "${COMP_WORDS[COMP_CWORD-1]}" in | |
1136 | -m|-F) | |
1137 | COMPREPLY=() | |
1138 | ;; | |
1139 | -*|tag|git-tag) | |
1140 | if [ $f = 1 ]; then | |
1141 | __gitcomp "$(__git_tags)" | |
1142 | else | |
1143 | COMPREPLY=() | |
1144 | fi | |
1145 | ;; | |
1146 | *) | |
1147 | __gitcomp "$(__git_refs)" | |
1148 | ;; | |
1149 | esac | |
1150 | } | |
1151 | ||
690d8824 JH |
1152 | _git () |
1153 | { | |
873537fa SP |
1154 | local i c=1 command __git_dir |
1155 | ||
1156 | while [ $c -lt $COMP_CWORD ]; do | |
1157 | i="${COMP_WORDS[c]}" | |
1158 | case "$i" in | |
1159 | --git-dir=*) __git_dir="${i#--git-dir=}" ;; | |
1160 | --bare) __git_dir="." ;; | |
1161 | --version|--help|-p|--paginate) ;; | |
1162 | *) command="$i"; break ;; | |
1163 | esac | |
1164 | c=$((++c)) | |
1165 | done | |
1166 | ||
1167 | if [ $c -eq $COMP_CWORD -a -z "$command" ]; then | |
72e5e989 SP |
1168 | case "${COMP_WORDS[COMP_CWORD]}" in |
1169 | --*=*) COMPREPLY=() ;; | |
47e98eec SP |
1170 | --*) __gitcomp " |
1171 | --no-pager | |
1172 | --git-dir= | |
1173 | --bare | |
1174 | --version | |
1175 | --exec-path | |
1176 | " | |
1177 | ;; | |
72e5e989 SP |
1178 | *) __gitcomp "$(__git_commands) $(__git_aliases)" ;; |
1179 | esac | |
1180 | return | |
873537fa | 1181 | fi |
367dce2a | 1182 | |
873537fa SP |
1183 | local expansion=$(__git_aliased_command "$command") |
1184 | [ "$expansion" ] && command="$expansion" | |
367dce2a | 1185 | |
873537fa | 1186 | case "$command" in |
88329195 | 1187 | am) _git_am ;; |
8435b548 | 1188 | add) _git_add ;; |
88329195 | 1189 | apply) _git_apply ;; |
b2e69f62 | 1190 | bisect) _git_bisect ;; |
374a58c9 | 1191 | bundle) _git_bundle ;; |
873537fa | 1192 | branch) _git_branch ;; |
873537fa | 1193 | checkout) _git_checkout ;; |
d8a9fea5 | 1194 | cherry) _git_cherry ;; |
1273231e | 1195 | cherry-pick) _git_cherry_pick ;; |
4548e855 | 1196 | commit) _git_commit ;; |
e0d10e1c | 1197 | config) _git_config ;; |
217926c0 | 1198 | describe) _git_describe ;; |
873537fa | 1199 | diff) _git_diff ;; |
873537fa | 1200 | fetch) _git_fetch ;; |
f53352fb | 1201 | format-patch) _git_format_patch ;; |
b26c8748 | 1202 | gc) _git_gc ;; |
873537fa SP |
1203 | log) _git_log ;; |
1204 | ls-remote) _git_ls_remote ;; | |
1205 | ls-tree) _git_ls_tree ;; | |
4ad91321 | 1206 | merge) _git_merge;; |
873537fa | 1207 | merge-base) _git_merge_base ;; |
d33909bf | 1208 | name-rev) _git_name_rev ;; |
873537fa SP |
1209 | pull) _git_pull ;; |
1210 | push) _git_push ;; | |
61d926a3 | 1211 | rebase) _git_rebase ;; |
88293c67 | 1212 | remote) _git_remote ;; |
873537fa | 1213 | reset) _git_reset ;; |
1fd6bec9 | 1214 | shortlog) _git_shortlog ;; |
90131924 | 1215 | show) _git_show ;; |
873537fa | 1216 | show-branch) _git_log ;; |
7fd53fce | 1217 | stash) _git_stash ;; |
be86f7a0 | 1218 | submodule) _git_submodule ;; |
88e21dc7 | 1219 | tag) _git_tag ;; |
873537fa SP |
1220 | whatchanged) _git_log ;; |
1221 | *) COMPREPLY=() ;; | |
1222 | esac | |
690d8824 JH |
1223 | } |
1224 | ||
1225 | _gitk () | |
1226 | { | |
1227 | local cur="${COMP_WORDS[COMP_CWORD]}" | |
b3391775 SP |
1228 | case "$cur" in |
1229 | --*) | |
1230 | __gitcomp "--not --all" | |
1231 | return | |
1232 | ;; | |
1233 | esac | |
ec804891 | 1234 | __git_complete_revlist |
690d8824 JH |
1235 | } |
1236 | ||
1237 | complete -o default -o nospace -F _git git | |
b3391775 SP |
1238 | complete -o default -o nospace -F _gitk gitk |
1239 | complete -o default -o nospace -F _git_am git-am | |
1240 | complete -o default -o nospace -F _git_apply git-apply | |
b2e69f62 | 1241 | complete -o default -o nospace -F _git_bisect git-bisect |
b3391775 | 1242 | complete -o default -o nospace -F _git_branch git-branch |
374a58c9 | 1243 | complete -o default -o nospace -F _git_bundle git-bundle |
b3391775 | 1244 | complete -o default -o nospace -F _git_checkout git-checkout |
d8a9fea5 | 1245 | complete -o default -o nospace -F _git_cherry git-cherry |
b3391775 SP |
1246 | complete -o default -o nospace -F _git_cherry_pick git-cherry-pick |
1247 | complete -o default -o nospace -F _git_commit git-commit | |
217926c0 | 1248 | complete -o default -o nospace -F _git_describe git-describe |
690d8824 | 1249 | complete -o default -o nospace -F _git_diff git-diff |
690d8824 | 1250 | complete -o default -o nospace -F _git_fetch git-fetch |
f53352fb | 1251 | complete -o default -o nospace -F _git_format_patch git-format-patch |
b26c8748 | 1252 | complete -o default -o nospace -F _git_gc git-gc |
690d8824 | 1253 | complete -o default -o nospace -F _git_log git-log |
b3391775 | 1254 | complete -o default -o nospace -F _git_ls_remote git-ls-remote |
690d8824 | 1255 | complete -o default -o nospace -F _git_ls_tree git-ls-tree |
b3391775 SP |
1256 | complete -o default -o nospace -F _git_merge git-merge |
1257 | complete -o default -o nospace -F _git_merge_base git-merge-base | |
1258 | complete -o default -o nospace -F _git_name_rev git-name-rev | |
690d8824 JH |
1259 | complete -o default -o nospace -F _git_pull git-pull |
1260 | complete -o default -o nospace -F _git_push git-push | |
b3391775 SP |
1261 | complete -o default -o nospace -F _git_rebase git-rebase |
1262 | complete -o default -o nospace -F _git_config git-config | |
88293c67 | 1263 | complete -o default -o nospace -F _git_remote git-remote |
b3391775 | 1264 | complete -o default -o nospace -F _git_reset git-reset |
1fd6bec9 | 1265 | complete -o default -o nospace -F _git_shortlog git-shortlog |
90131924 | 1266 | complete -o default -o nospace -F _git_show git-show |
7fd53fce | 1267 | complete -o default -o nospace -F _git_stash git-stash |
be86f7a0 | 1268 | complete -o default -o nospace -F _git_submodule git-submodule |
144d33de | 1269 | complete -o default -o nospace -F _git_log git-show-branch |
88e21dc7 | 1270 | complete -o default -o nospace -F _git_tag git-tag |
690d8824 JH |
1271 | complete -o default -o nospace -F _git_log git-whatchanged |
1272 | ||
1273 | # The following are necessary only for Cygwin, and only are needed | |
1274 | # when the user has tab-completed the executable name and consequently | |
1275 | # included the '.exe' suffix. | |
1276 | # | |
76c3eb51 | 1277 | if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then |
b3391775 SP |
1278 | complete -o default -o nospace -F _git_add git-add.exe |
1279 | complete -o default -o nospace -F _git_apply git-apply.exe | |
144d33de | 1280 | complete -o default -o nospace -F _git git.exe |
b3391775 | 1281 | complete -o default -o nospace -F _git_branch git-branch.exe |
374a58c9 | 1282 | complete -o default -o nospace -F _git_bundle git-bundle.exe |
d8a9fea5 | 1283 | complete -o default -o nospace -F _git_cherry git-cherry.exe |
217926c0 | 1284 | complete -o default -o nospace -F _git_describe git-describe.exe |
690d8824 | 1285 | complete -o default -o nospace -F _git_diff git-diff.exe |
f53352fb | 1286 | complete -o default -o nospace -F _git_format_patch git-format-patch.exe |
690d8824 JH |
1287 | complete -o default -o nospace -F _git_log git-log.exe |
1288 | complete -o default -o nospace -F _git_ls_tree git-ls-tree.exe | |
b3391775 SP |
1289 | complete -o default -o nospace -F _git_merge_base git-merge-base.exe |
1290 | complete -o default -o nospace -F _git_name_rev git-name-rev.exe | |
690d8824 | 1291 | complete -o default -o nospace -F _git_push git-push.exe |
b3391775 | 1292 | complete -o default -o nospace -F _git_config git-config |
1fd6bec9 | 1293 | complete -o default -o nospace -F _git_shortlog git-shortlog.exe |
90131924 | 1294 | complete -o default -o nospace -F _git_show git-show.exe |
144d33de | 1295 | complete -o default -o nospace -F _git_log git-show-branch.exe |
88e21dc7 | 1296 | complete -o default -o nospace -F _git_tag git-tag.exe |
690d8824 | 1297 | complete -o default -o nospace -F _git_log git-whatchanged.exe |
76c3eb51 | 1298 | fi |