Support --strategy=x completion in addition to --strategy x.
[git/git.git] / contrib / completion / git-completion.bash
CommitLineData
690d8824
JH
1#
2# bash completion support for core Git.
3#
4# Copyright (C) 2006 Shawn Pearce
5# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
6#
7# The contained completion routines provide support for completing:
8#
9# *) local and remote branch names
10# *) local and remote tag names
11# *) .git/remotes file names
12# *) git 'subcommands'
13# *) tree paths within 'ref:path/to/file' expressions
14#
15# To use these routines:
16#
17# 1) Copy this file to somewhere (e.g. ~/.git-completion.sh).
18# 2) Added the following line to your .bashrc:
19# source ~/.git-completion.sh
20#
d3d717a4
SP
21# 3) Consider changing your PS1 to also show the current branch:
22# PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
23#
24# The argument to __git_ps1 will be displayed only if you
25# are currently in a git repository. The %s token will be
26# the name of the current branch.
27#
690d8824 28
873537fa
SP
29__gitdir ()
30{
31 echo "${__git_dir:-$(git rev-parse --git-dir 2>/dev/null)}"
32}
33
d3d717a4
SP
34__git_ps1 ()
35{
36 local b="$(git symbolic-ref HEAD 2>/dev/null)"
37 if [ -n "$b" ]; then
38 if [ -n "$1" ]; then
39 printf "$1" "${b##refs/heads/}"
40 else
41 printf " (%s)" "${b##refs/heads/}"
42 fi
43 fi
44}
45
5de40f59
SP
46__git_heads ()
47{
48 local cmd i is_hash=y dir="${1:-$(__gitdir)}"
49 if [ -d "$dir" ]; then
50 for i in $(git --git-dir="$dir" \
51 for-each-ref --format='%(refname)' \
52 refs/heads ); do
53 echo "${i#refs/heads/}"
54 done
55 return
56 fi
57 for i in $(git-ls-remote "$dir" 2>/dev/null); do
58 case "$is_hash,$i" in
59 y,*) is_hash=n ;;
60 n,*^{}) is_hash=y ;;
61 n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
62 n,*) is_hash=y; echo "$i" ;;
63 esac
64 done
65}
66
690d8824
JH
67__git_refs ()
68{
873537fa
SP
69 local cmd i is_hash=y dir="${1:-$(__gitdir)}"
70 if [ -d "$dir" ]; then
35e65ecc
SP
71 if [ -e "$dir/HEAD" ]; then echo HEAD; fi
72 for i in $(git --git-dir="$dir" \
73 for-each-ref --format='%(refname)' \
74 refs/tags refs/heads refs/remotes); do
75 case "$i" in
76 refs/tags/*) echo "${i#refs/tags/}" ;;
77 refs/heads/*) echo "${i#refs/heads/}" ;;
78 refs/remotes/*) echo "${i#refs/remotes/}" ;;
79 *) echo "$i" ;;
80 esac
81 done
82 return
690d8824 83 fi
35e65ecc 84 for i in $(git-ls-remote "$dir" 2>/dev/null); do
690d8824
JH
85 case "$is_hash,$i" in
86 y,*) is_hash=n ;;
87 n,*^{}) is_hash=y ;;
88 n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
89 n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
35e65ecc 90 n,refs/remotes/*) is_hash=y; echo "${i#refs/remotes/}" ;;
690d8824
JH
91 n,*) is_hash=y; echo "$i" ;;
92 esac
93 done
94}
95
96__git_refs2 ()
97{
873537fa
SP
98 local cmd i is_hash=y dir="${1:-$(__gitdir)}"
99 if [ -d "$dir" ]; then
690d8824
JH
100 cmd=git-peek-remote
101 else
102 cmd=git-ls-remote
103 fi
873537fa 104 for i in $($cmd "$dir" 2>/dev/null); do
690d8824
JH
105 case "$is_hash,$i" in
106 y,*) is_hash=n ;;
107 n,*^{}) is_hash=y ;;
108 n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}:${i#refs/tags/}" ;;
109 n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}:${i#refs/heads/}" ;;
110 n,*) is_hash=y; echo "$i:$i" ;;
111 esac
112 done
113}
114
5de40f59
SP
115__git_refs_remotes ()
116{
117 local cmd i is_hash=y
118 for i in $(git-ls-remote "$1" 2>/dev/null); do
119 case "$is_hash,$i" in
120 n,refs/heads/*)
121 is_hash=y
122 echo "$i:refs/remotes/$1/${i#refs/heads/}"
123 ;;
124 y,*) is_hash=n ;;
125 n,*^{}) is_hash=y ;;
126 n,refs/tags/*) is_hash=y;;
127 n,*) is_hash=y; ;;
128 esac
129 done
130}
131
690d8824
JH
132__git_remotes ()
133{
873537fa 134 local i ngoff IFS=$'\n' d="$(__gitdir)"
56fc25f2 135 shopt -q nullglob || ngoff=1
690d8824 136 shopt -s nullglob
873537fa
SP
137 for i in "$d/remotes"/*; do
138 echo ${i#$d/remotes/}
690d8824 139 done
56fc25f2 140 [ "$ngoff" ] && shopt -u nullglob
873537fa 141 for i in $(git --git-dir="$d" repo-config --list); do
56fc25f2
SP
142 case "$i" in
143 remote.*.url=*)
144 i="${i#remote.}"
145 echo "${i/.url=*/}"
146 ;;
147 esac
148 done
690d8824
JH
149}
150
4ad91321
SP
151__git_merge_strategies ()
152{
153 sed -n "/^all_strategies='/{
154 s/^all_strategies='//
155 s/'//
156 p
157 q
158 }" "$(git --exec-path)/git-merge"
159}
160
690d8824
JH
161__git_complete_file ()
162{
a79c6551 163 local pfx ls ref cur="${COMP_WORDS[COMP_CWORD]}"
690d8824
JH
164 case "$cur" in
165 ?*:*)
a79c6551
SP
166 ref="${cur%%:*}"
167 cur="${cur#*:}"
690d8824
JH
168 case "$cur" in
169 ?*/*)
a79c6551
SP
170 pfx="${cur%/*}"
171 cur="${cur##*/}"
690d8824
JH
172 ls="$ref:$pfx"
173 pfx="$pfx/"
174 ;;
175 *)
176 ls="$ref"
177 ;;
178 esac
179 COMPREPLY=($(compgen -P "$pfx" \
873537fa 180 -W "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \
690d8824
JH
181 | sed '/^100... blob /s,^.* ,,
182 /^040000 tree /{
183 s,^.* ,,
184 s,$,/,
185 }
186 s/^.* //')" \
187 -- "$cur"))
188 ;;
189 *)
873537fa 190 COMPREPLY=($(compgen -W "$(__git_refs)" -- "$cur"))
690d8824
JH
191 ;;
192 esac
193}
194
f53352fb
SP
195__git_complete_revlist ()
196{
197 local pfx cur="${COMP_WORDS[COMP_CWORD]}"
198 case "$cur" in
199 *...*)
200 pfx="${cur%...*}..."
201 cur="${cur#*...}"
202 COMPREPLY=($(compgen -P "$pfx" -W "$(__git_refs)" -- "$cur"))
203 ;;
204 *..*)
205 pfx="${cur%..*}.."
206 cur="${cur#*..}"
207 COMPREPLY=($(compgen -P "$pfx" -W "$(__git_refs)" -- "$cur"))
208 ;;
209 *)
210 COMPREPLY=($(compgen -W "$(__git_refs)" -- "$cur"))
211 ;;
212 esac
213}
214
f2bb9f88
SP
215__git_commands ()
216{
217 local i IFS=" "$'\n'
218 for i in $(git help -a|egrep '^ ')
219 do
220 case $i in
221 check-ref-format) : plumbing;;
222 commit-tree) : plumbing;;
223 convert-objects) : plumbing;;
224 cvsserver) : daemon;;
225 daemon) : daemon;;
226 fetch-pack) : plumbing;;
227 hash-object) : plumbing;;
228 http-*) : transport;;
229 index-pack) : plumbing;;
230 local-fetch) : plumbing;;
231 mailinfo) : plumbing;;
232 mailsplit) : plumbing;;
233 merge-*) : plumbing;;
234 mktree) : plumbing;;
235 mktag) : plumbing;;
236 pack-objects) : plumbing;;
237 pack-redundant) : plumbing;;
238 pack-refs) : plumbing;;
239 parse-remote) : plumbing;;
240 patch-id) : plumbing;;
241 peek-remote) : plumbing;;
242 read-tree) : plumbing;;
243 receive-pack) : plumbing;;
244 rerere) : plumbing;;
245 rev-list) : plumbing;;
246 rev-parse) : plumbing;;
247 runstatus) : plumbing;;
248 sh-setup) : internal;;
249 shell) : daemon;;
250 send-pack) : plumbing;;
251 show-index) : plumbing;;
252 ssh-*) : transport;;
253 stripspace) : plumbing;;
254 symbolic-ref) : plumbing;;
255 unpack-file) : plumbing;;
256 unpack-objects) : plumbing;;
257 update-ref) : plumbing;;
258 update-server-info) : daemon;;
259 upload-archive) : plumbing;;
260 upload-pack) : plumbing;;
261 write-tree) : plumbing;;
262 *) echo $i;;
263 esac
264 done
265}
266
367dce2a
DS
267__git_aliases ()
268{
56fc25f2 269 local i IFS=$'\n'
873537fa 270 for i in $(git --git-dir="$(__gitdir)" repo-config --list); do
56fc25f2
SP
271 case "$i" in
272 alias.*)
273 i="${i#alias.}"
274 echo "${i/=*/}"
275 ;;
276 esac
277 done
367dce2a
DS
278}
279
280__git_aliased_command ()
281{
873537fa
SP
282 local word cmdline=$(git --git-dir="$(__gitdir)" \
283 repo-config --get "alias.$1")
367dce2a
DS
284 for word in $cmdline; do
285 if [ "${word##-*}" ]; then
286 echo $word
287 return
288 fi
289 done
290}
291
690d8824
JH
292_git_branch ()
293{
294 local cur="${COMP_WORDS[COMP_CWORD]}"
873537fa 295 COMPREPLY=($(compgen -W "-l -f -d -D $(__git_refs)" -- "$cur"))
690d8824
JH
296}
297
298_git_cat_file ()
299{
300 local cur="${COMP_WORDS[COMP_CWORD]}"
301 case "${COMP_WORDS[0]},$COMP_CWORD" in
302 git-cat-file*,1)
303 COMPREPLY=($(compgen -W "-p -t blob tree commit tag" -- "$cur"))
304 ;;
305 git,2)
306 COMPREPLY=($(compgen -W "-p -t blob tree commit tag" -- "$cur"))
307 ;;
308 *)
309 __git_complete_file
310 ;;
311 esac
312}
313
314_git_checkout ()
315{
316 local cur="${COMP_WORDS[COMP_CWORD]}"
873537fa 317 COMPREPLY=($(compgen -W "-l -b $(__git_refs)" -- "$cur"))
690d8824
JH
318}
319
1273231e
SP
320_git_cherry_pick ()
321{
322 local cur="${COMP_WORDS[COMP_CWORD]}"
323 case "$cur" in
324 --*)
325 COMPREPLY=($(compgen -W "
326 --edit --no-commit
327 " -- "$cur"))
328 ;;
329 *)
330 COMPREPLY=($(compgen -W "$(__git_refs)" -- "$cur"))
331 ;;
332 esac
333}
334
690d8824
JH
335_git_diff ()
336{
337 __git_complete_file
338}
339
340_git_diff_tree ()
341{
342 local cur="${COMP_WORDS[COMP_CWORD]}"
873537fa 343 COMPREPLY=($(compgen -W "-r -p -M $(__git_refs)" -- "$cur"))
690d8824
JH
344}
345
346_git_fetch ()
347{
348 local cur="${COMP_WORDS[COMP_CWORD]}"
349
350 case "${COMP_WORDS[0]},$COMP_CWORD" in
351 git-fetch*,1)
352 COMPREPLY=($(compgen -W "$(__git_remotes)" -- "$cur"))
353 ;;
354 git,2)
355 COMPREPLY=($(compgen -W "$(__git_remotes)" -- "$cur"))
356 ;;
357 *)
358 case "$cur" in
359 *:*)
a79c6551 360 cur="${cur#*:}"
873537fa 361 COMPREPLY=($(compgen -W "$(__git_refs)" -- "$cur"))
690d8824
JH
362 ;;
363 *)
364 local remote
365 case "${COMP_WORDS[0]}" in
366 git-fetch) remote="${COMP_WORDS[1]}" ;;
367 git) remote="${COMP_WORDS[2]}" ;;
368 esac
369 COMPREPLY=($(compgen -W "$(__git_refs2 "$remote")" -- "$cur"))
370 ;;
371 esac
372 ;;
373 esac
374}
375
f53352fb
SP
376_git_format_patch ()
377{
378 local cur="${COMP_WORDS[COMP_CWORD]}"
379 case "$cur" in
380 --*)
381 COMPREPLY=($(compgen -W "
382 --stdout --attach --thread
383 --output-directory
384 --numbered --start-number
385 --keep-subject
386 --signoff
387 --in-reply-to=
388 --full-index --binary
389 " -- "$cur"))
390 return
391 ;;
392 esac
393 __git_complete_revlist
394}
395
690d8824
JH
396_git_ls_remote ()
397{
398 local cur="${COMP_WORDS[COMP_CWORD]}"
399 COMPREPLY=($(compgen -W "$(__git_remotes)" -- "$cur"))
400}
401
402_git_ls_tree ()
403{
404 __git_complete_file
405}
406
407_git_log ()
408{
6e31b866
SP
409 local cur="${COMP_WORDS[COMP_CWORD]}"
410 case "$cur" in
411 --pretty=*)
412 COMPREPLY=($(compgen -W "
413 oneline short medium full fuller email raw
414 " -- "${cur##--pretty=}"))
415 return
416 ;;
417 --*)
418 COMPREPLY=($(compgen -W "
419 --max-count= --max-age= --since= --after=
420 --min-age= --before= --until=
421 --root --not --topo-order --date-order
422 --no-merges
423 --abbrev-commit --abbrev=
424 --relative-date
425 --author= --committer= --grep=
426 --all-match
427 --pretty= --name-status --name-only
428 " -- "$cur"))
429 return
430 ;;
431 esac
f53352fb 432 __git_complete_revlist
690d8824
JH
433}
434
4ad91321
SP
435_git_merge ()
436{
437 local cur="${COMP_WORDS[COMP_CWORD]}"
ce1e39d2
SP
438 case "${COMP_WORDS[COMP_CWORD-1]}" in
439 -s|--strategy)
440 COMPREPLY=($(compgen -W "$(__git_merge_strategies)" -- "$cur"))
441 return
442 esac
4ad91321 443 case "$cur" in
ce1e39d2
SP
444 --strategy=*)
445 COMPREPLY=($(compgen -W "$(__git_merge_strategies)" \
446 -- "${cur##--strategy=}"))
447 return
448 ;;
4ad91321
SP
449 --*)
450 COMPREPLY=($(compgen -W "
61d926a3 451 --no-commit --no-summary --squash --strategy
4ad91321
SP
452 " -- "$cur"))
453 return
454 esac
61d926a3 455 COMPREPLY=($(compgen -W "$(__git_refs)" -- "$cur"))
4ad91321
SP
456}
457
690d8824
JH
458_git_merge_base ()
459{
460 local cur="${COMP_WORDS[COMP_CWORD]}"
873537fa 461 COMPREPLY=($(compgen -W "$(__git_refs)" -- "$cur"))
690d8824
JH
462}
463
d33909bf
SP
464_git_name_rev ()
465{
466 local cur="${COMP_WORDS[COMP_CWORD]}"
467 COMPREPLY=($(compgen -W "--tags --all --stdin" -- "$cur"))
468}
469
690d8824
JH
470_git_pull ()
471{
472 local cur="${COMP_WORDS[COMP_CWORD]}"
473
474 case "${COMP_WORDS[0]},$COMP_CWORD" in
475 git-pull*,1)
476 COMPREPLY=($(compgen -W "$(__git_remotes)" -- "$cur"))
477 ;;
478 git,2)
479 COMPREPLY=($(compgen -W "$(__git_remotes)" -- "$cur"))
480 ;;
481 *)
482 local remote
483 case "${COMP_WORDS[0]}" in
484 git-pull) remote="${COMP_WORDS[1]}" ;;
485 git) remote="${COMP_WORDS[2]}" ;;
486 esac
487 COMPREPLY=($(compgen -W "$(__git_refs "$remote")" -- "$cur"))
488 ;;
489 esac
490}
491
492_git_push ()
493{
494 local cur="${COMP_WORDS[COMP_CWORD]}"
495
496 case "${COMP_WORDS[0]},$COMP_CWORD" in
497 git-push*,1)
498 COMPREPLY=($(compgen -W "$(__git_remotes)" -- "$cur"))
499 ;;
500 git,2)
501 COMPREPLY=($(compgen -W "$(__git_remotes)" -- "$cur"))
502 ;;
503 *)
504 case "$cur" in
505 *:*)
506 local remote
507 case "${COMP_WORDS[0]}" in
508 git-push) remote="${COMP_WORDS[1]}" ;;
509 git) remote="${COMP_WORDS[2]}" ;;
510 esac
a79c6551 511 cur="${cur#*:}"
690d8824
JH
512 COMPREPLY=($(compgen -W "$(__git_refs "$remote")" -- "$cur"))
513 ;;
514 *)
873537fa 515 COMPREPLY=($(compgen -W "$(__git_refs2)" -- "$cur"))
690d8824
JH
516 ;;
517 esac
518 ;;
519 esac
520}
521
61d926a3
SP
522_git_rebase ()
523{
524 local cur="${COMP_WORDS[COMP_CWORD]}"
525 if [ -d .dotest ]; then
526 COMPREPLY=($(compgen -W "
527 --continue --skip --abort
528 " -- "$cur"))
529 return
530 fi
ce1e39d2
SP
531 case "${COMP_WORDS[COMP_CWORD-1]}" in
532 -s|--strategy)
533 COMPREPLY=($(compgen -W "$(__git_merge_strategies)" -- "$cur"))
534 return
535 esac
61d926a3 536 case "$cur" in
ce1e39d2
SP
537 --strategy=*)
538 COMPREPLY=($(compgen -W "$(__git_merge_strategies)" \
539 -- "${cur##--strategy=}"))
540 return
541 ;;
61d926a3
SP
542 --*)
543 COMPREPLY=($(compgen -W "
544 --onto --merge --strategy
545 " -- "$cur"))
546 return
547 esac
61d926a3
SP
548 COMPREPLY=($(compgen -W "$(__git_refs)" -- "$cur"))
549}
550
5de40f59
SP
551_git_repo_config ()
552{
553 local cur="${COMP_WORDS[COMP_CWORD]}"
554 local prv="${COMP_WORDS[COMP_CWORD-1]}"
555 case "$prv" in
556 branch.*.remote)
557 COMPREPLY=($(compgen -W "$(__git_remotes)" -- "$cur"))
558 return
559 ;;
560 branch.*.merge)
561 COMPREPLY=($(compgen -W "$(__git_refs)" -- "$cur"))
562 return
563 ;;
564 remote.*.fetch)
565 local remote="${prv#remote.}"
566 remote="${remote%.fetch}"
567 COMPREPLY=($(compgen -W "$(__git_refs_remotes "$remote")" \
568 -- "$cur"))
569 return
570 ;;
571 remote.*.push)
572 local remote="${prv#remote.}"
573 remote="${remote%.push}"
574 COMPREPLY=($(compgen -W "$(git --git-dir="$(__gitdir)" \
575 for-each-ref --format='%(refname):%(refname)' \
576 refs/heads)" -- "$cur"))
577 return
578 ;;
579 *.*)
580 COMPREPLY=()
581 return
582 ;;
583 esac
584 case "$cur" in
585 --*)
586 COMPREPLY=($(compgen -W "
587 --global --list --replace-all
588 --get --get-all --get-regexp
589 --unset --unset-all
590 " -- "$cur"))
591 return
592 ;;
593 branch.*.*)
594 local pfx="${cur%.*}."
595 cur="${cur##*.}"
596 COMPREPLY=($(compgen -P "$pfx" -W "remote merge" -- "$cur"))
597 return
598 ;;
599 branch.*)
600 local pfx="${cur%.*}."
601 cur="${cur#*.}"
602 COMPREPLY=($(compgen -P "$pfx" -S . \
603 -W "$(__git_heads)" -- "$cur"))
604 return
605 ;;
606 remote.*.*)
607 local pfx="${cur%.*}."
608 cur="${cur##*.}"
609 COMPREPLY=($(compgen -P "$pfx" -W "url fetch push" -- "$cur"))
610 return
611 ;;
612 remote.*)
613 local pfx="${cur%.*}."
614 cur="${cur#*.}"
615 COMPREPLY=($(compgen -P "$pfx" -S . \
616 -W "$(__git_remotes)" -- "$cur"))
617 return
618 ;;
619 esac
620 COMPREPLY=($(compgen -W "
621 apply.whitespace
622 core.fileMode
623 core.gitProxy
624 core.ignoreStat
625 core.preferSymlinkRefs
626 core.logAllRefUpdates
627 core.repositoryFormatVersion
628 core.sharedRepository
629 core.warnAmbiguousRefs
630 core.compression
631 core.legacyHeaders
632 i18n.commitEncoding
633 diff.color
634 diff.renameLimit
635 diff.renames
636 pager.color
637 status.color
638 log.showroot
639 show.difftree
640 showbranch.default
641 whatchanged.difftree
642 http.sslVerify
643 http.sslCert
644 http.sslKey
645 http.sslCAInfo
646 http.sslCAPath
647 http.maxRequests
648 http.lowSpeedLimit http.lowSpeedTime
649 http.noEPSV
650 pack.window
651 repack.useDeltaBaseOffset
652 pull.octopus pull.twohead
653 merge.summary
654 receive.unpackLimit
655 receive.denyNonFastForwards
656 user.name user.email
657 tar.umask
658 gitcvs.enabled
659 gitcvs.logfile
660 branch. remote.
661 " -- "$cur"))
662}
663
67e78c3b
SP
664_git_reset ()
665{
666 local cur="${COMP_WORDS[COMP_CWORD]}"
667 local opt="--mixed --hard --soft"
873537fa 668 COMPREPLY=($(compgen -W "$opt $(__git_refs)" -- "$cur"))
67e78c3b
SP
669}
670
690d8824
JH
671_git ()
672{
873537fa
SP
673 local i c=1 command __git_dir
674
675 while [ $c -lt $COMP_CWORD ]; do
676 i="${COMP_WORDS[c]}"
677 case "$i" in
678 --git-dir=*) __git_dir="${i#--git-dir=}" ;;
679 --bare) __git_dir="." ;;
680 --version|--help|-p|--paginate) ;;
681 *) command="$i"; break ;;
682 esac
683 c=$((++c))
684 done
685
686 if [ $c -eq $COMP_CWORD -a -z "$command" ]; then
f2bb9f88
SP
687 COMPREPLY=($(compgen -W "
688 --git-dir= --version --exec-path
689 $(__git_commands)
690 $(__git_aliases)
691 " -- "${COMP_WORDS[COMP_CWORD]}"))
873537fa
SP
692 return;
693 fi
367dce2a 694
873537fa
SP
695 local expansion=$(__git_aliased_command "$command")
696 [ "$expansion" ] && command="$expansion"
367dce2a 697
873537fa
SP
698 case "$command" in
699 branch) _git_branch ;;
700 cat-file) _git_cat_file ;;
701 checkout) _git_checkout ;;
1273231e 702 cherry-pick) _git_cherry_pick ;;
873537fa
SP
703 diff) _git_diff ;;
704 diff-tree) _git_diff_tree ;;
705 fetch) _git_fetch ;;
f53352fb 706 format-patch) _git_format_patch ;;
873537fa
SP
707 log) _git_log ;;
708 ls-remote) _git_ls_remote ;;
709 ls-tree) _git_ls_tree ;;
4ad91321 710 merge) _git_merge;;
873537fa 711 merge-base) _git_merge_base ;;
d33909bf 712 name-rev) _git_name_rev ;;
873537fa
SP
713 pull) _git_pull ;;
714 push) _git_push ;;
61d926a3 715 rebase) _git_rebase ;;
5de40f59 716 repo-config) _git_repo_config ;;
873537fa 717 reset) _git_reset ;;
6e31b866 718 show) _git_log ;;
873537fa
SP
719 show-branch) _git_log ;;
720 whatchanged) _git_log ;;
721 *) COMPREPLY=() ;;
722 esac
690d8824
JH
723}
724
725_gitk ()
726{
727 local cur="${COMP_WORDS[COMP_CWORD]}"
873537fa 728 COMPREPLY=($(compgen -W "--all $(__git_refs)" -- "$cur"))
690d8824
JH
729}
730
731complete -o default -o nospace -F _git git
732complete -o default -F _gitk gitk
733complete -o default -F _git_branch git-branch
734complete -o default -o nospace -F _git_cat_file git-cat-file
735complete -o default -F _git_checkout git-checkout
1273231e 736complete -o default -F _git_cherry_pick git-cherry-pick
690d8824
JH
737complete -o default -o nospace -F _git_diff git-diff
738complete -o default -F _git_diff_tree git-diff-tree
739complete -o default -o nospace -F _git_fetch git-fetch
f53352fb 740complete -o default -o nospace -F _git_format_patch git-format-patch
690d8824
JH
741complete -o default -o nospace -F _git_log git-log
742complete -o default -F _git_ls_remote git-ls-remote
743complete -o default -o nospace -F _git_ls_tree git-ls-tree
4ad91321 744complete -o default -F _git_merge git-merge
690d8824 745complete -o default -F _git_merge_base git-merge-base
d33909bf 746complete -o default -F _git_name_rev git-name-rev
690d8824
JH
747complete -o default -o nospace -F _git_pull git-pull
748complete -o default -o nospace -F _git_push git-push
61d926a3 749complete -o default -F _git_rebase git-rebase
5de40f59 750complete -o default -F _git_repo_config git-repo-config
67e78c3b 751complete -o default -F _git_reset git-reset
6e31b866 752complete -o default -F _git_log git-show
144d33de 753complete -o default -o nospace -F _git_log git-show-branch
690d8824
JH
754complete -o default -o nospace -F _git_log git-whatchanged
755
756# The following are necessary only for Cygwin, and only are needed
757# when the user has tab-completed the executable name and consequently
758# included the '.exe' suffix.
759#
76c3eb51 760if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
144d33de 761complete -o default -o nospace -F _git git.exe
dfb96092 762complete -o default -F _git_branch git-branch.exe
690d8824
JH
763complete -o default -o nospace -F _git_cat_file git-cat-file.exe
764complete -o default -o nospace -F _git_diff git-diff.exe
765complete -o default -o nospace -F _git_diff_tree git-diff-tree.exe
f53352fb 766complete -o default -o nospace -F _git_format_patch git-format-patch.exe
690d8824
JH
767complete -o default -o nospace -F _git_log git-log.exe
768complete -o default -o nospace -F _git_ls_tree git-ls-tree.exe
769complete -o default -F _git_merge_base git-merge-base.exe
d33909bf 770complete -o default -F _git_name_rev git-name-rev.exe
690d8824 771complete -o default -o nospace -F _git_push git-push.exe
5de40f59 772complete -o default -F _git_repo_config git-repo-config
6e31b866 773complete -o default -o nospace -F _git_log git-show.exe
144d33de 774complete -o default -o nospace -F _git_log git-show-branch.exe
690d8824 775complete -o default -o nospace -F _git_log git-whatchanged.exe
76c3eb51 776fi