Teach bash to complete ref arguments to git-describe
[git/gitweb.git] / contrib / completion / git-completion.bash
blob6ed6a51dc6f425ac1d3111fd818473e37adf22fb
2 # bash completion support for core Git.
4 # Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
5 # Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
6 # Distributed under the GNU General Public License, version 2.0.
8 # The contained completion routines provide support for completing:
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
15 # *) common --long-options
17 # To use these routines:
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
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.
29 # 4) Consider changing your PS1 to also show the current branch:
30 # PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
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.
36 # To submit patches:
38 # *) Read Documentation/SubmittingPatches
39 # *) Send all patches to the current maintainer:
41 # "Shawn O. Pearce" <spearce@spearce.org>
43 # *) Always CC the Git mailing list:
45 # git@vger.kernel.org
48 __gitdir ()
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
58 elif [ -d "$1/.git" ]; then
59 echo "$1/.git"
60 else
61 echo "$1"
65 __git_ps1 ()
67 local b="$(git symbolic-ref HEAD 2>/dev/null)"
68 if [ -n "$b" ]; then
69 if [ -n "$1" ]; then
70 printf "$1" "${b##refs/heads/}"
71 else
72 printf " (%s)" "${b##refs/heads/}"
77 __gitcomp ()
79 local all c s=$'\n' IFS=' '$'\t'$'\n'
80 local cur="${COMP_WORDS[COMP_CWORD]}"
81 if [ $# -gt 2 ]; then
82 cur="$3"
84 for c in $1; do
85 case "$c$4" in
86 --*=*) all="$all$c$4$s" ;;
87 *.) all="$all$c$4$s" ;;
88 *) all="$all$c$4 $s" ;;
89 esac
90 done
91 IFS=$s
92 COMPREPLY=($(compgen -P "$2" -W "$all" -- "$cur"))
93 return
96 __git_heads ()
98 local cmd i is_hash=y dir="$(__gitdir "$1")"
99 if [ -d "$dir" ]; then
100 for i in $(git --git-dir="$dir" \
101 for-each-ref --format='%(refname)' \
102 refs/heads ); do
103 echo "${i#refs/heads/}"
104 done
105 return
107 for i in $(git-ls-remote "$1" 2>/dev/null); do
108 case "$is_hash,$i" in
109 y,*) is_hash=n ;;
110 n,*^{}) is_hash=y ;;
111 n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
112 n,*) is_hash=y; echo "$i" ;;
113 esac
114 done
117 __git_refs ()
119 local cmd i is_hash=y dir="$(__gitdir "$1")"
120 if [ -d "$dir" ]; then
121 if [ -e "$dir/HEAD" ]; then echo HEAD; fi
122 for i in $(git --git-dir="$dir" \
123 for-each-ref --format='%(refname)' \
124 refs/tags refs/heads refs/remotes); do
125 case "$i" in
126 refs/tags/*) echo "${i#refs/tags/}" ;;
127 refs/heads/*) echo "${i#refs/heads/}" ;;
128 refs/remotes/*) echo "${i#refs/remotes/}" ;;
129 *) echo "$i" ;;
130 esac
131 done
132 return
134 for i in $(git-ls-remote "$dir" 2>/dev/null); do
135 case "$is_hash,$i" in
136 y,*) is_hash=n ;;
137 n,*^{}) is_hash=y ;;
138 n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
139 n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
140 n,refs/remotes/*) is_hash=y; echo "${i#refs/remotes/}" ;;
141 n,*) is_hash=y; echo "$i" ;;
142 esac
143 done
146 __git_refs2 ()
148 local i
149 for i in $(__git_refs "$1"); do
150 echo "$i:$i"
151 done
154 __git_refs_remotes ()
156 local cmd i is_hash=y
157 for i in $(git-ls-remote "$1" 2>/dev/null); do
158 case "$is_hash,$i" in
159 n,refs/heads/*)
160 is_hash=y
161 echo "$i:refs/remotes/$1/${i#refs/heads/}"
163 y,*) is_hash=n ;;
164 n,*^{}) is_hash=y ;;
165 n,refs/tags/*) is_hash=y;;
166 n,*) is_hash=y; ;;
167 esac
168 done
171 __git_remotes ()
173 local i ngoff IFS=$'\n' d="$(__gitdir)"
174 shopt -q nullglob || ngoff=1
175 shopt -s nullglob
176 for i in "$d/remotes"/*; do
177 echo ${i#$d/remotes/}
178 done
179 [ "$ngoff" ] && shopt -u nullglob
180 for i in $(git --git-dir="$d" config --list); do
181 case "$i" in
182 remote.*.url=*)
183 i="${i#remote.}"
184 echo "${i/.url=*/}"
186 esac
187 done
190 __git_merge_strategies ()
192 if [ -n "$__git_merge_strategylist" ]; then
193 echo "$__git_merge_strategylist"
194 return
196 sed -n "/^all_strategies='/{
197 s/^all_strategies='//
198 s/'//
201 }" "$(git --exec-path)/git-merge"
203 __git_merge_strategylist=
204 __git_merge_strategylist="$(__git_merge_strategies 2>/dev/null)"
206 __git_complete_file ()
208 local pfx ls ref cur="${COMP_WORDS[COMP_CWORD]}"
209 case "$cur" in
210 ?*:*)
211 ref="${cur%%:*}"
212 cur="${cur#*:}"
213 case "$cur" in
214 ?*/*)
215 pfx="${cur%/*}"
216 cur="${cur##*/}"
217 ls="$ref:$pfx"
218 pfx="$pfx/"
221 ls="$ref"
223 esac
224 COMPREPLY=($(compgen -P "$pfx" \
225 -W "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \
226 | sed '/^100... blob /s,^.* ,,
227 /^040000 tree /{
228 s,^.* ,,
229 s,$,/,
231 s/^.* //')" \
232 -- "$cur"))
235 __gitcomp "$(__git_refs)"
237 esac
240 __git_complete_revlist ()
242 local pfx cur="${COMP_WORDS[COMP_CWORD]}"
243 case "$cur" in
244 *...*)
245 pfx="${cur%...*}..."
246 cur="${cur#*...}"
247 __gitcomp "$(__git_refs)" "$pfx" "$cur"
249 *..*)
250 pfx="${cur%..*}.."
251 cur="${cur#*..}"
252 __gitcomp "$(__git_refs)" "$pfx" "$cur"
255 __gitcomp "$cur."
258 __gitcomp "$(__git_refs)"
260 esac
263 __git_commands ()
265 if [ -n "$__git_commandlist" ]; then
266 echo "$__git_commandlist"
267 return
269 local i IFS=" "$'\n'
270 for i in $(git help -a|egrep '^ ')
272 case $i in
273 add--interactive) : plumbing;;
274 applymbox) : ask gittus;;
275 applypatch) : ask gittus;;
276 archimport) : import;;
277 cat-file) : plumbing;;
278 check-attr) : plumbing;;
279 check-ref-format) : plumbing;;
280 commit-tree) : plumbing;;
281 convert-objects) : plumbing;;
282 cvsexportcommit) : export;;
283 cvsimport) : import;;
284 cvsserver) : daemon;;
285 daemon) : daemon;;
286 diff-files) : plumbing;;
287 diff-index) : plumbing;;
288 diff-tree) : plumbing;;
289 fast-import) : import;;
290 fsck-objects) : plumbing;;
291 fetch--tool) : plumbing;;
292 fetch-pack) : plumbing;;
293 fmt-merge-msg) : plumbing;;
294 for-each-ref) : plumbing;;
295 hash-object) : plumbing;;
296 http-*) : transport;;
297 index-pack) : plumbing;;
298 init-db) : deprecated;;
299 local-fetch) : plumbing;;
300 mailinfo) : plumbing;;
301 mailsplit) : plumbing;;
302 merge-*) : plumbing;;
303 mktree) : plumbing;;
304 mktag) : plumbing;;
305 pack-objects) : plumbing;;
306 pack-redundant) : plumbing;;
307 pack-refs) : plumbing;;
308 parse-remote) : plumbing;;
309 patch-id) : plumbing;;
310 peek-remote) : plumbing;;
311 prune) : plumbing;;
312 prune-packed) : plumbing;;
313 quiltimport) : import;;
314 read-tree) : plumbing;;
315 receive-pack) : plumbing;;
316 reflog) : plumbing;;
317 repo-config) : plumbing;;
318 rerere) : plumbing;;
319 rev-list) : plumbing;;
320 rev-parse) : plumbing;;
321 runstatus) : plumbing;;
322 sh-setup) : internal;;
323 shell) : daemon;;
324 send-pack) : plumbing;;
325 show-index) : plumbing;;
326 ssh-*) : transport;;
327 stripspace) : plumbing;;
328 svn) : import export;;
329 svnimport) : import;;
330 symbolic-ref) : plumbing;;
331 tar-tree) : deprecated;;
332 unpack-file) : plumbing;;
333 unpack-objects) : plumbing;;
334 update-index) : plumbing;;
335 update-ref) : plumbing;;
336 update-server-info) : daemon;;
337 upload-archive) : plumbing;;
338 upload-pack) : plumbing;;
339 write-tree) : plumbing;;
340 verify-tag) : plumbing;;
341 *) echo $i;;
342 esac
343 done
345 __git_commandlist=
346 __git_commandlist="$(__git_commands 2>/dev/null)"
348 __git_aliases ()
350 local i IFS=$'\n'
351 for i in $(git --git-dir="$(__gitdir)" config --list); do
352 case "$i" in
353 alias.*)
354 i="${i#alias.}"
355 echo "${i/=*/}"
357 esac
358 done
361 __git_aliased_command ()
363 local word cmdline=$(git --git-dir="$(__gitdir)" \
364 config --get "alias.$1")
365 for word in $cmdline; do
366 if [ "${word##-*}" ]; then
367 echo $word
368 return
370 done
373 __git_whitespacelist="nowarn warn error error-all strip"
375 _git_am ()
377 local cur="${COMP_WORDS[COMP_CWORD]}"
378 if [ -d .dotest ]; then
379 __gitcomp "--skip --resolved"
380 return
382 case "$cur" in
383 --whitespace=*)
384 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
385 return
387 --*)
388 __gitcomp "
389 --signoff --utf8 --binary --3way --interactive
390 --whitespace=
392 return
393 esac
394 COMPREPLY=()
397 _git_apply ()
399 local cur="${COMP_WORDS[COMP_CWORD]}"
400 case "$cur" in
401 --whitespace=*)
402 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
403 return
405 --*)
406 __gitcomp "
407 --stat --numstat --summary --check --index
408 --cached --index-info --reverse --reject --unidiff-zero
409 --apply --no-add --exclude=
410 --whitespace= --inaccurate-eof --verbose
412 return
413 esac
414 COMPREPLY=()
417 _git_add ()
419 local cur="${COMP_WORDS[COMP_CWORD]}"
420 case "$cur" in
421 --*)
422 __gitcomp "--interactive --refresh"
423 return
424 esac
425 COMPREPLY=()
428 _git_bisect ()
430 local i c=1 command
431 while [ $c -lt $COMP_CWORD ]; do
432 i="${COMP_WORDS[c]}"
433 case "$i" in
434 start|bad|good|reset|visualize|replay|log)
435 command="$i"
436 break
438 esac
439 c=$((++c))
440 done
442 if [ $c -eq $COMP_CWORD -a -z "$command" ]; then
443 __gitcomp "start bad good reset visualize replay log"
444 return
447 case "$command" in
448 bad|good|reset)
449 __gitcomp "$(__git_refs)"
452 COMPREPLY=()
454 esac
457 _git_branch ()
459 __gitcomp "$(__git_refs)"
462 _git_bundle ()
464 local mycword="$COMP_CWORD"
465 case "${COMP_WORDS[0]}" in
466 git)
467 local cmd="${COMP_WORDS[2]}"
468 mycword="$((mycword-1))"
470 git-bundle*)
471 local cmd="${COMP_WORDS[1]}"
473 esac
474 case "$mycword" in
476 __gitcomp "create list-heads verify unbundle"
479 # looking for a file
482 case "$cmd" in
483 create)
484 __git_complete_revlist
486 esac
488 esac
491 _git_checkout ()
493 __gitcomp "$(__git_refs)"
496 _git_cherry ()
498 __gitcomp "$(__git_refs)"
501 _git_cherry_pick ()
503 local cur="${COMP_WORDS[COMP_CWORD]}"
504 case "$cur" in
505 --*)
506 __gitcomp "--edit --no-commit"
509 __gitcomp "$(__git_refs)"
511 esac
514 _git_commit ()
516 local cur="${COMP_WORDS[COMP_CWORD]}"
517 case "$cur" in
518 --*)
519 __gitcomp "
520 --all --author= --signoff --verify --no-verify
521 --edit --amend --include --only
523 return
524 esac
525 COMPREPLY=()
528 _git_describe ()
530 __gitcomp "$(__git_refs)"
533 _git_diff ()
535 __git_complete_file
538 _git_diff_tree ()
540 __gitcomp "$(__git_refs)"
543 _git_fetch ()
545 local cur="${COMP_WORDS[COMP_CWORD]}"
547 case "${COMP_WORDS[0]},$COMP_CWORD" in
548 git-fetch*,1)
549 __gitcomp "$(__git_remotes)"
551 git,2)
552 __gitcomp "$(__git_remotes)"
555 case "$cur" in
556 *:*)
557 __gitcomp "$(__git_refs)" "" "${cur#*:}"
560 local remote
561 case "${COMP_WORDS[0]}" in
562 git-fetch) remote="${COMP_WORDS[1]}" ;;
563 git) remote="${COMP_WORDS[2]}" ;;
564 esac
565 __gitcomp "$(__git_refs2 "$remote")"
567 esac
569 esac
572 _git_format_patch ()
574 local cur="${COMP_WORDS[COMP_CWORD]}"
575 case "$cur" in
576 --*)
577 __gitcomp "
578 --stdout --attach --thread
579 --output-directory
580 --numbered --start-number
581 --numbered-files
582 --keep-subject
583 --signoff
584 --in-reply-to=
585 --full-index --binary
586 --not --all
588 return
590 esac
591 __git_complete_revlist
594 _git_gc ()
596 local cur="${COMP_WORDS[COMP_CWORD]}"
597 case "$cur" in
598 --*)
599 __gitcomp "--prune --aggressive"
600 return
602 esac
603 COMPREPLY=()
606 _git_ls_remote ()
608 __gitcomp "$(__git_remotes)"
611 _git_ls_tree ()
613 __git_complete_file
616 _git_log ()
618 local cur="${COMP_WORDS[COMP_CWORD]}"
619 case "$cur" in
620 --pretty=*)
621 __gitcomp "
622 oneline short medium full fuller email raw
623 " "" "${cur##--pretty=}"
624 return
626 --date=*)
627 __gitcomp "
628 relative iso8601 rfc2822 short local default
629 " "" "${cur##--date=}"
630 return
632 --*)
633 __gitcomp "
634 --max-count= --max-age= --since= --after=
635 --min-age= --before= --until=
636 --root --topo-order --date-order --reverse
637 --no-merges --follow
638 --abbrev-commit --abbrev=
639 --relative-date --date=
640 --author= --committer= --grep=
641 --all-match
642 --pretty= --name-status --name-only --raw
643 --not --all
645 return
647 esac
648 __git_complete_revlist
651 _git_merge ()
653 local cur="${COMP_WORDS[COMP_CWORD]}"
654 case "${COMP_WORDS[COMP_CWORD-1]}" in
655 -s|--strategy)
656 __gitcomp "$(__git_merge_strategies)"
657 return
658 esac
659 case "$cur" in
660 --strategy=*)
661 __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}"
662 return
664 --*)
665 __gitcomp "
666 --no-commit --no-summary --squash --strategy
668 return
669 esac
670 __gitcomp "$(__git_refs)"
673 _git_merge_base ()
675 __gitcomp "$(__git_refs)"
678 _git_name_rev ()
680 __gitcomp "--tags --all --stdin"
683 _git_pull ()
685 local cur="${COMP_WORDS[COMP_CWORD]}"
687 case "${COMP_WORDS[0]},$COMP_CWORD" in
688 git-pull*,1)
689 __gitcomp "$(__git_remotes)"
691 git,2)
692 __gitcomp "$(__git_remotes)"
695 local remote
696 case "${COMP_WORDS[0]}" in
697 git-pull) remote="${COMP_WORDS[1]}" ;;
698 git) remote="${COMP_WORDS[2]}" ;;
699 esac
700 __gitcomp "$(__git_refs "$remote")"
702 esac
705 _git_push ()
707 local cur="${COMP_WORDS[COMP_CWORD]}"
709 case "${COMP_WORDS[0]},$COMP_CWORD" in
710 git-push*,1)
711 __gitcomp "$(__git_remotes)"
713 git,2)
714 __gitcomp "$(__git_remotes)"
717 case "$cur" in
718 *:*)
719 local remote
720 case "${COMP_WORDS[0]}" in
721 git-push) remote="${COMP_WORDS[1]}" ;;
722 git) remote="${COMP_WORDS[2]}" ;;
723 esac
724 __gitcomp "$(__git_refs "$remote")" "" "${cur#*:}"
727 __gitcomp "$(__git_refs)" + "${cur#+}"
730 __gitcomp "$(__git_refs)"
732 esac
734 esac
737 _git_rebase ()
739 local cur="${COMP_WORDS[COMP_CWORD]}"
740 if [ -d .dotest ] || [ -d .git/.dotest-merge ]; then
741 __gitcomp "--continue --skip --abort"
742 return
744 case "${COMP_WORDS[COMP_CWORD-1]}" in
745 -s|--strategy)
746 __gitcomp "$(__git_merge_strategies)"
747 return
748 esac
749 case "$cur" in
750 --strategy=*)
751 __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}"
752 return
754 --*)
755 __gitcomp "--onto --merge --strategy"
756 return
757 esac
758 __gitcomp "$(__git_refs)"
761 _git_config ()
763 local cur="${COMP_WORDS[COMP_CWORD]}"
764 local prv="${COMP_WORDS[COMP_CWORD-1]}"
765 case "$prv" in
766 branch.*.remote)
767 __gitcomp "$(__git_remotes)"
768 return
770 branch.*.merge)
771 __gitcomp "$(__git_refs)"
772 return
774 remote.*.fetch)
775 local remote="${prv#remote.}"
776 remote="${remote%.fetch}"
777 __gitcomp "$(__git_refs_remotes "$remote")"
778 return
780 remote.*.push)
781 local remote="${prv#remote.}"
782 remote="${remote%.push}"
783 __gitcomp "$(git --git-dir="$(__gitdir)" \
784 for-each-ref --format='%(refname):%(refname)' \
785 refs/heads)"
786 return
788 pull.twohead|pull.octopus)
789 __gitcomp "$(__git_merge_strategies)"
790 return
792 color.branch|color.diff|color.status)
793 __gitcomp "always never auto"
794 return
796 color.*.*)
797 __gitcomp "
798 black red green yellow blue magenta cyan white
799 bold dim ul blink reverse
801 return
803 *.*)
804 COMPREPLY=()
805 return
807 esac
808 case "$cur" in
809 --*)
810 __gitcomp "
811 --global --system --file=
812 --list --replace-all
813 --get --get-all --get-regexp
814 --add --unset --unset-all
815 --remove-section --rename-section
817 return
819 branch.*.*)
820 local pfx="${cur%.*}."
821 cur="${cur##*.}"
822 __gitcomp "remote merge" "$pfx" "$cur"
823 return
825 branch.*)
826 local pfx="${cur%.*}."
827 cur="${cur#*.}"
828 __gitcomp "$(__git_heads)" "$pfx" "$cur" "."
829 return
831 remote.*.*)
832 local pfx="${cur%.*}."
833 cur="${cur##*.}"
834 __gitcomp "
835 url fetch push skipDefaultUpdate
836 receivepack uploadpack tagopt
837 " "$pfx" "$cur"
838 return
840 remote.*)
841 local pfx="${cur%.*}."
842 cur="${cur#*.}"
843 __gitcomp "$(__git_remotes)" "$pfx" "$cur" "."
844 return
846 esac
847 __gitcomp "
848 apply.whitespace
849 core.fileMode
850 core.gitProxy
851 core.ignoreStat
852 core.preferSymlinkRefs
853 core.logAllRefUpdates
854 core.loosecompression
855 core.repositoryFormatVersion
856 core.sharedRepository
857 core.warnAmbiguousRefs
858 core.compression
859 core.legacyHeaders
860 core.packedGitWindowSize
861 core.packedGitLimit
862 clean.requireForce
863 color.branch
864 color.branch.current
865 color.branch.local
866 color.branch.remote
867 color.branch.plain
868 color.diff
869 color.diff.plain
870 color.diff.meta
871 color.diff.frag
872 color.diff.old
873 color.diff.new
874 color.diff.commit
875 color.diff.whitespace
876 color.pager
877 color.status
878 color.status.header
879 color.status.added
880 color.status.changed
881 color.status.untracked
882 diff.renameLimit
883 diff.renames
884 fetch.unpackLimit
885 format.headers
886 format.subjectprefix
887 gitcvs.enabled
888 gitcvs.logfile
889 gitcvs.allbinary
890 gitcvs.dbname gitcvs.dbdriver gitcvs.dbuser gitcvs.dvpass
891 gc.packrefs
892 gc.reflogexpire
893 gc.reflogexpireunreachable
894 gc.rerereresolved
895 gc.rerereunresolved
896 http.sslVerify
897 http.sslCert
898 http.sslKey
899 http.sslCAInfo
900 http.sslCAPath
901 http.maxRequests
902 http.lowSpeedLimit
903 http.lowSpeedTime
904 http.noEPSV
905 i18n.commitEncoding
906 i18n.logOutputEncoding
907 log.showroot
908 merge.tool
909 merge.summary
910 merge.verbosity
911 pack.window
912 pack.depth
913 pack.windowMemory
914 pack.compression
915 pack.deltaCacheSize
916 pack.deltaCacheLimit
917 pull.octopus
918 pull.twohead
919 repack.useDeltaBaseOffset
920 show.difftree
921 showbranch.default
922 tar.umask
923 transfer.unpackLimit
924 receive.unpackLimit
925 receive.denyNonFastForwards
926 user.name
927 user.email
928 user.signingkey
929 whatchanged.difftree
930 branch. remote.
934 _git_remote ()
936 local i c=1 command
937 while [ $c -lt $COMP_CWORD ]; do
938 i="${COMP_WORDS[c]}"
939 case "$i" in
940 add|show|prune|update) command="$i"; break ;;
941 esac
942 c=$((++c))
943 done
945 if [ $c -eq $COMP_CWORD -a -z "$command" ]; then
946 __gitcomp "add show prune update"
947 return
950 case "$command" in
951 show|prune)
952 __gitcomp "$(__git_remotes)"
954 update)
955 local i c='' IFS=$'\n'
956 for i in $(git --git-dir="$(__gitdir)" config --list); do
957 case "$i" in
958 remotes.*)
959 i="${i#remotes.}"
960 c="$c ${i/=*/}"
962 esac
963 done
964 __gitcomp "$c"
967 COMPREPLY=()
969 esac
972 _git_reset ()
974 local cur="${COMP_WORDS[COMP_CWORD]}"
975 case "$cur" in
976 --*)
977 __gitcomp "--mixed --hard --soft"
978 return
980 esac
981 __gitcomp "$(__git_refs)"
984 _git_shortlog ()
986 local cur="${COMP_WORDS[COMP_CWORD]}"
987 case "$cur" in
988 --*)
989 __gitcomp "
990 --max-count= --max-age= --since= --after=
991 --min-age= --before= --until=
992 --no-merges
993 --author= --committer= --grep=
994 --all-match
995 --not --all
996 --numbered --summary
998 return
1000 esac
1001 __git_complete_revlist
1004 _git_show ()
1006 local cur="${COMP_WORDS[COMP_CWORD]}"
1007 case "$cur" in
1008 --pretty=*)
1009 __gitcomp "
1010 oneline short medium full fuller email raw
1011 " "" "${cur##--pretty=}"
1012 return
1014 --*)
1015 __gitcomp "--pretty="
1016 return
1018 esac
1019 __git_complete_file
1022 _git_stash ()
1024 __gitcomp 'list show apply clear'
1027 _git ()
1029 local i c=1 command __git_dir
1031 while [ $c -lt $COMP_CWORD ]; do
1032 i="${COMP_WORDS[c]}"
1033 case "$i" in
1034 --git-dir=*) __git_dir="${i#--git-dir=}" ;;
1035 --bare) __git_dir="." ;;
1036 --version|--help|-p|--paginate) ;;
1037 *) command="$i"; break ;;
1038 esac
1039 c=$((++c))
1040 done
1042 if [ $c -eq $COMP_CWORD -a -z "$command" ]; then
1043 case "${COMP_WORDS[COMP_CWORD]}" in
1044 --*=*) COMPREPLY=() ;;
1045 --*) __gitcomp "
1046 --no-pager
1047 --git-dir=
1048 --bare
1049 --version
1050 --exec-path
1053 *) __gitcomp "$(__git_commands) $(__git_aliases)" ;;
1054 esac
1055 return
1058 local expansion=$(__git_aliased_command "$command")
1059 [ "$expansion" ] && command="$expansion"
1061 case "$command" in
1062 am) _git_am ;;
1063 add) _git_add ;;
1064 apply) _git_apply ;;
1065 bisect) _git_bisect ;;
1066 bundle) _git_bundle ;;
1067 branch) _git_branch ;;
1068 checkout) _git_checkout ;;
1069 cherry) _git_cherry ;;
1070 cherry-pick) _git_cherry_pick ;;
1071 commit) _git_commit ;;
1072 config) _git_config ;;
1073 describe) _git_describe ;;
1074 diff) _git_diff ;;
1075 fetch) _git_fetch ;;
1076 format-patch) _git_format_patch ;;
1077 gc) _git_gc ;;
1078 log) _git_log ;;
1079 ls-remote) _git_ls_remote ;;
1080 ls-tree) _git_ls_tree ;;
1081 merge) _git_merge;;
1082 merge-base) _git_merge_base ;;
1083 name-rev) _git_name_rev ;;
1084 pull) _git_pull ;;
1085 push) _git_push ;;
1086 rebase) _git_rebase ;;
1087 remote) _git_remote ;;
1088 reset) _git_reset ;;
1089 shortlog) _git_shortlog ;;
1090 show) _git_show ;;
1091 show-branch) _git_log ;;
1092 stash) _git_stash ;;
1093 whatchanged) _git_log ;;
1094 *) COMPREPLY=() ;;
1095 esac
1098 _gitk ()
1100 local cur="${COMP_WORDS[COMP_CWORD]}"
1101 case "$cur" in
1102 --*)
1103 __gitcomp "--not --all"
1104 return
1106 esac
1107 __git_complete_revlist
1110 complete -o default -o nospace -F _git git
1111 complete -o default -o nospace -F _gitk gitk
1112 complete -o default -o nospace -F _git_am git-am
1113 complete -o default -o nospace -F _git_apply git-apply
1114 complete -o default -o nospace -F _git_bisect git-bisect
1115 complete -o default -o nospace -F _git_branch git-branch
1116 complete -o default -o nospace -F _git_bundle git-bundle
1117 complete -o default -o nospace -F _git_checkout git-checkout
1118 complete -o default -o nospace -F _git_cherry git-cherry
1119 complete -o default -o nospace -F _git_cherry_pick git-cherry-pick
1120 complete -o default -o nospace -F _git_commit git-commit
1121 complete -o default -o nospace -F _git_describe git-describe
1122 complete -o default -o nospace -F _git_diff git-diff
1123 complete -o default -o nospace -F _git_fetch git-fetch
1124 complete -o default -o nospace -F _git_format_patch git-format-patch
1125 complete -o default -o nospace -F _git_gc git-gc
1126 complete -o default -o nospace -F _git_log git-log
1127 complete -o default -o nospace -F _git_ls_remote git-ls-remote
1128 complete -o default -o nospace -F _git_ls_tree git-ls-tree
1129 complete -o default -o nospace -F _git_merge git-merge
1130 complete -o default -o nospace -F _git_merge_base git-merge-base
1131 complete -o default -o nospace -F _git_name_rev git-name-rev
1132 complete -o default -o nospace -F _git_pull git-pull
1133 complete -o default -o nospace -F _git_push git-push
1134 complete -o default -o nospace -F _git_rebase git-rebase
1135 complete -o default -o nospace -F _git_config git-config
1136 complete -o default -o nospace -F _git_remote git-remote
1137 complete -o default -o nospace -F _git_reset git-reset
1138 complete -o default -o nospace -F _git_shortlog git-shortlog
1139 complete -o default -o nospace -F _git_show git-show
1140 complete -o default -o nospace -F _git_stash git-stash
1141 complete -o default -o nospace -F _git_log git-show-branch
1142 complete -o default -o nospace -F _git_log git-whatchanged
1144 # The following are necessary only for Cygwin, and only are needed
1145 # when the user has tab-completed the executable name and consequently
1146 # included the '.exe' suffix.
1148 if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
1149 complete -o default -o nospace -F _git_add git-add.exe
1150 complete -o default -o nospace -F _git_apply git-apply.exe
1151 complete -o default -o nospace -F _git git.exe
1152 complete -o default -o nospace -F _git_branch git-branch.exe
1153 complete -o default -o nospace -F _git_bundle git-bundle.exe
1154 complete -o default -o nospace -F _git_cherry git-cherry.exe
1155 complete -o default -o nospace -F _git_describe git-describe.exe
1156 complete -o default -o nospace -F _git_diff git-diff.exe
1157 complete -o default -o nospace -F _git_format_patch git-format-patch.exe
1158 complete -o default -o nospace -F _git_log git-log.exe
1159 complete -o default -o nospace -F _git_ls_tree git-ls-tree.exe
1160 complete -o default -o nospace -F _git_merge_base git-merge-base.exe
1161 complete -o default -o nospace -F _git_name_rev git-name-rev.exe
1162 complete -o default -o nospace -F _git_push git-push.exe
1163 complete -o default -o nospace -F _git_config git-config
1164 complete -o default -o nospace -F _git_shortlog git-shortlog.exe
1165 complete -o default -o nospace -F _git_show git-show.exe
1166 complete -o default -o nospace -F _git_log git-show-branch.exe
1167 complete -o default -o nospace -F _git_log git-whatchanged.exe