Code

82b9ed40d84dbb72c72e282392ca8eb247ab527e
[git.git] / contrib / completion / git-completion.bash
1 #
2 # bash completion support for core Git.
3 #
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.
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
15 #    *) common --long-options
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 #
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:
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 #
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 #
48 __gitdir ()
49 {
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
63 }
65 __git_ps1 ()
66 {
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/}"
73                 fi
74         fi
75 }
77 __gitcomp ()
78 {
79         local all c s=$'\n' IFS=' '$'\t'$'\n'
80         local cur="${COMP_WORDS[COMP_CWORD]}"
81         if [ $# -gt 2 ]; then
82                 cur="$3"
83         fi
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
94 }
96 __git_heads ()
97 {
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
106         fi
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
133         fi
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/}"
162                         ;;
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=*/}"
185                         ;;
186                 esac
187         done
190 __git_merge_strategies ()
192         if [ -n "$__git_merge_strategylist" ]; then
193                 echo "$__git_merge_strategylist"
194                 return
195         fi
196         sed -n "/^all_strategies='/{
197                 s/^all_strategies='//
198                 s/'//
199                 p
200                 q
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/"
219                         ;;
220                 *)
221                         ls="$ref"
222                         ;;
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,$,/,
230                                        }
231                                        s/^.*    //')" \
232                         -- "$cur"))
233                 ;;
234         *)
235                 __gitcomp "$(__git_refs)"
236                 ;;
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"
248                 ;;
249         *..*)
250                 pfx="${cur%..*}.."
251                 cur="${cur#*..}"
252                 __gitcomp "$(__git_refs)" "$pfx" "$cur"
253                 ;;
254         *.)
255                 __gitcomp "$cur."
256                 ;;
257         *)
258                 __gitcomp "$(__git_refs)"
259                 ;;
260         esac
263 __git_commands ()
265         if [ -n "$__git_commandlist" ]; then
266                 echo "$__git_commandlist"
267                 return
268         fi
269         local i IFS=" "$'\n'
270         for i in $(git help -a|egrep '^ ')
271         do
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/=*/}"
356                         ;;
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
369                 fi
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
381         fi
382         case "$cur" in
383         --whitespace=*)
384                 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
385                 return
386                 ;;
387         --*)
388                 __gitcomp "
389                         --signoff --utf8 --binary --3way --interactive
390                         --whitespace=
391                         "
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
404                 ;;
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
411                         "
412                 return
413         esac
414         COMPREPLY=()
417 _git_add ()
419         local cur="${COMP_WORDS[COMP_CWORD]}"
420         case "$cur" in
421         --*)
422                 __gitcomp "--interactive"
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
437                         ;;
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
445         fi
447         case "$command" in
448         bad|good|reset)
449                 __gitcomp "$(__git_refs)"
450                 ;;
451         *)
452                 COMPREPLY=()
453                 ;;
454         esac
457 _git_branch ()
459         __gitcomp "$(__git_refs)"
462 _git_checkout ()
464         __gitcomp "$(__git_refs)"
467 _git_cherry ()
469         __gitcomp "$(__git_refs)"
472 _git_cherry_pick ()
474         local cur="${COMP_WORDS[COMP_CWORD]}"
475         case "$cur" in
476         --*)
477                 __gitcomp "--edit --no-commit"
478                 ;;
479         *)
480                 __gitcomp "$(__git_refs)"
481                 ;;
482         esac
485 _git_commit ()
487         local cur="${COMP_WORDS[COMP_CWORD]}"
488         case "$cur" in
489         --*)
490                 __gitcomp "
491                         --all --author= --signoff --verify --no-verify
492                         --edit --amend --include --only
493                         "
494                 return
495         esac
496         COMPREPLY=()
499 _git_diff ()
501         __git_complete_file
504 _git_diff_tree ()
506         __gitcomp "$(__git_refs)"
509 _git_fetch ()
511         local cur="${COMP_WORDS[COMP_CWORD]}"
513         case "${COMP_WORDS[0]},$COMP_CWORD" in
514         git-fetch*,1)
515                 __gitcomp "$(__git_remotes)"
516                 ;;
517         git,2)
518                 __gitcomp "$(__git_remotes)"
519                 ;;
520         *)
521                 case "$cur" in
522                 *:*)
523                         __gitcomp "$(__git_refs)" "" "${cur#*:}"
524                         ;;
525                 *)
526                         local remote
527                         case "${COMP_WORDS[0]}" in
528                         git-fetch) remote="${COMP_WORDS[1]}" ;;
529                         git)       remote="${COMP_WORDS[2]}" ;;
530                         esac
531                         __gitcomp "$(__git_refs2 "$remote")"
532                         ;;
533                 esac
534                 ;;
535         esac
538 _git_format_patch ()
540         local cur="${COMP_WORDS[COMP_CWORD]}"
541         case "$cur" in
542         --*)
543                 __gitcomp "
544                         --stdout --attach --thread
545                         --output-directory
546                         --numbered --start-number
547                         --keep-subject
548                         --signoff
549                         --in-reply-to=
550                         --full-index --binary
551                         --not --all
552                         "
553                 return
554                 ;;
555         esac
556         __git_complete_revlist
559 _git_gc ()
561         local cur="${COMP_WORDS[COMP_CWORD]}"
562         case "$cur" in
563         --*)
564                 __gitcomp "--prune"
565                 return
566                 ;;
567         esac
568         COMPREPLY=()
571 _git_ls_remote ()
573         __gitcomp "$(__git_remotes)"
576 _git_ls_tree ()
578         __git_complete_file
581 _git_log ()
583         local cur="${COMP_WORDS[COMP_CWORD]}"
584         case "$cur" in
585         --pretty=*)
586                 __gitcomp "
587                         oneline short medium full fuller email raw
588                         " "" "${cur##--pretty=}"
589                 return
590                 ;;
591         --*)
592                 __gitcomp "
593                         --max-count= --max-age= --since= --after=
594                         --min-age= --before= --until=
595                         --root --topo-order --date-order --reverse
596                         --no-merges
597                         --abbrev-commit --abbrev=
598                         --relative-date
599                         --author= --committer= --grep=
600                         --all-match
601                         --pretty= --name-status --name-only --raw
602                         --not --all
603                         "
604                 return
605                 ;;
606         esac
607         __git_complete_revlist
610 _git_merge ()
612         local cur="${COMP_WORDS[COMP_CWORD]}"
613         case "${COMP_WORDS[COMP_CWORD-1]}" in
614         -s|--strategy)
615                 __gitcomp "$(__git_merge_strategies)"
616                 return
617         esac
618         case "$cur" in
619         --strategy=*)
620                 __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}"
621                 return
622                 ;;
623         --*)
624                 __gitcomp "
625                         --no-commit --no-summary --squash --strategy
626                         "
627                 return
628         esac
629         __gitcomp "$(__git_refs)"
632 _git_merge_base ()
634         __gitcomp "$(__git_refs)"
637 _git_name_rev ()
639         __gitcomp "--tags --all --stdin"
642 _git_pull ()
644         local cur="${COMP_WORDS[COMP_CWORD]}"
646         case "${COMP_WORDS[0]},$COMP_CWORD" in
647         git-pull*,1)
648                 __gitcomp "$(__git_remotes)"
649                 ;;
650         git,2)
651                 __gitcomp "$(__git_remotes)"
652                 ;;
653         *)
654                 local remote
655                 case "${COMP_WORDS[0]}" in
656                 git-pull)  remote="${COMP_WORDS[1]}" ;;
657                 git)       remote="${COMP_WORDS[2]}" ;;
658                 esac
659                 __gitcomp "$(__git_refs "$remote")"
660                 ;;
661         esac
664 _git_push ()
666         local cur="${COMP_WORDS[COMP_CWORD]}"
668         case "${COMP_WORDS[0]},$COMP_CWORD" in
669         git-push*,1)
670                 __gitcomp "$(__git_remotes)"
671                 ;;
672         git,2)
673                 __gitcomp "$(__git_remotes)"
674                 ;;
675         *)
676                 case "$cur" in
677                 *:*)
678                         local remote
679                         case "${COMP_WORDS[0]}" in
680                         git-push)  remote="${COMP_WORDS[1]}" ;;
681                         git)       remote="${COMP_WORDS[2]}" ;;
682                         esac
683                         __gitcomp "$(__git_refs "$remote")" "" "${cur#*:}"
684                         ;;
685                 +*)
686                         __gitcomp "$(__git_refs)" + "${cur#+}"
687                         ;;
688                 *)
689                         __gitcomp "$(__git_refs)"
690                         ;;
691                 esac
692                 ;;
693         esac
696 _git_rebase ()
698         local cur="${COMP_WORDS[COMP_CWORD]}"
699         if [ -d .dotest ] || [ -d .git/.dotest-merge ]; then
700                 __gitcomp "--continue --skip --abort"
701                 return
702         fi
703         case "${COMP_WORDS[COMP_CWORD-1]}" in
704         -s|--strategy)
705                 __gitcomp "$(__git_merge_strategies)"
706                 return
707         esac
708         case "$cur" in
709         --strategy=*)
710                 __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}"
711                 return
712                 ;;
713         --*)
714                 __gitcomp "--onto --merge --strategy"
715                 return
716         esac
717         __gitcomp "$(__git_refs)"
720 _git_config ()
722         local cur="${COMP_WORDS[COMP_CWORD]}"
723         local prv="${COMP_WORDS[COMP_CWORD-1]}"
724         case "$prv" in
725         branch.*.remote)
726                 __gitcomp "$(__git_remotes)"
727                 return
728                 ;;
729         branch.*.merge)
730                 __gitcomp "$(__git_refs)"
731                 return
732                 ;;
733         remote.*.fetch)
734                 local remote="${prv#remote.}"
735                 remote="${remote%.fetch}"
736                 __gitcomp "$(__git_refs_remotes "$remote")"
737                 return
738                 ;;
739         remote.*.push)
740                 local remote="${prv#remote.}"
741                 remote="${remote%.push}"
742                 __gitcomp "$(git --git-dir="$(__gitdir)" \
743                         for-each-ref --format='%(refname):%(refname)' \
744                         refs/heads)"
745                 return
746                 ;;
747         pull.twohead|pull.octopus)
748                 __gitcomp "$(__git_merge_strategies)"
749                 return
750                 ;;
751         color.branch|color.diff|color.status)
752                 __gitcomp "always never auto"
753                 return
754                 ;;
755         color.*.*)
756                 __gitcomp "
757                         black red green yellow blue magenta cyan white
758                         bold dim ul blink reverse
759                         "
760                 return
761                 ;;
762         *.*)
763                 COMPREPLY=()
764                 return
765                 ;;
766         esac
767         case "$cur" in
768         --*)
769                 __gitcomp "
770                         --global --system
771                         --list --replace-all
772                         --get --get-all --get-regexp
773                         --add --unset --unset-all
774                         --remove-section --rename-section
775                         "
776                 return
777                 ;;
778         branch.*.*)
779                 local pfx="${cur%.*}."
780                 cur="${cur##*.}"
781                 __gitcomp "remote merge" "$pfx" "$cur"
782                 return
783                 ;;
784         branch.*)
785                 local pfx="${cur%.*}."
786                 cur="${cur#*.}"
787                 __gitcomp "$(__git_heads)" "$pfx" "$cur" "."
788                 return
789                 ;;
790         remote.*.*)
791                 local pfx="${cur%.*}."
792                 cur="${cur##*.}"
793                 __gitcomp "
794                         url fetch push skipDefaultUpdate
795                         receivepack uploadpack tagopt
796                         " "$pfx" "$cur"
797                 return
798                 ;;
799         remote.*)
800                 local pfx="${cur%.*}."
801                 cur="${cur#*.}"
802                 __gitcomp "$(__git_remotes)" "$pfx" "$cur" "."
803                 return
804                 ;;
805         esac
806         __gitcomp "
807                 apply.whitespace
808                 core.fileMode
809                 core.gitProxy
810                 core.ignoreStat
811                 core.preferSymlinkRefs
812                 core.logAllRefUpdates
813                 core.repositoryFormatVersion
814                 core.sharedRepository
815                 core.warnAmbiguousRefs
816                 core.compression
817                 core.legacyHeaders
818                 core.packedGitWindowSize
819                 core.packedGitLimit
820                 clean.requireForce
821                 color.branch
822                 color.branch.current
823                 color.branch.local
824                 color.branch.remote
825                 color.branch.plain
826                 color.diff
827                 color.diff.plain
828                 color.diff.meta
829                 color.diff.frag
830                 color.diff.old
831                 color.diff.new
832                 color.diff.commit
833                 color.diff.whitespace
834                 color.pager
835                 color.status
836                 color.status.header
837                 color.status.added
838                 color.status.changed
839                 color.status.untracked
840                 diff.renameLimit
841                 diff.renames
842                 fetch.unpackLimit
843                 format.headers
844                 gitcvs.enabled
845                 gitcvs.logfile
846                 gitcvs.allbinary
847                 gitcvs.dbname gitcvs.dbdriver gitcvs.dbuser gitcvs.dvpass
848                 gc.packrefs
849                 gc.reflogexpire
850                 gc.reflogexpireunreachable
851                 gc.rerereresolved
852                 gc.rerereunresolved
853                 http.sslVerify
854                 http.sslCert
855                 http.sslKey
856                 http.sslCAInfo
857                 http.sslCAPath
858                 http.maxRequests
859                 http.lowSpeedLimit
860                 http.lowSpeedTime
861                 http.noEPSV
862                 i18n.commitEncoding
863                 i18n.logOutputEncoding
864                 log.showroot
865                 merge.tool
866                 merge.summary
867                 merge.verbosity
868                 pack.window
869                 pack.depth
870                 pull.octopus
871                 pull.twohead
872                 repack.useDeltaBaseOffset
873                 show.difftree
874                 showbranch.default
875                 tar.umask
876                 transfer.unpackLimit
877                 receive.unpackLimit
878                 receive.denyNonFastForwards
879                 user.name
880                 user.email
881                 user.signingkey
882                 whatchanged.difftree
883                 branch. remote.
884         "
887 _git_remote ()
889         local i c=1 command
890         while [ $c -lt $COMP_CWORD ]; do
891                 i="${COMP_WORDS[c]}"
892                 case "$i" in
893                 add|show|prune|update) command="$i"; break ;;
894                 esac
895                 c=$((++c))
896         done
898         if [ $c -eq $COMP_CWORD -a -z "$command" ]; then
899                 __gitcomp "add show prune update"
900                 return
901         fi
903         case "$command" in
904         show|prune)
905                 __gitcomp "$(__git_remotes)"
906                 ;;
907         update)
908                 local i c='' IFS=$'\n'
909                 for i in $(git --git-dir="$(__gitdir)" config --list); do
910                         case "$i" in
911                         remotes.*)
912                                 i="${i#remotes.}"
913                                 c="$c ${i/=*/}"
914                                 ;;
915                         esac
916                 done
917                 __gitcomp "$c"
918                 ;;
919         *)
920                 COMPREPLY=()
921                 ;;
922         esac
925 _git_reset ()
927         local cur="${COMP_WORDS[COMP_CWORD]}"
928         case "$cur" in
929         --*)
930                 __gitcomp "--mixed --hard --soft"
931                 return
932                 ;;
933         esac
934         __gitcomp "$(__git_refs)"
937 _git_shortlog ()
939         local cur="${COMP_WORDS[COMP_CWORD]}"
940         case "$cur" in
941         --*)
942                 __gitcomp "
943                         --max-count= --max-age= --since= --after=
944                         --min-age= --before= --until=
945                         --no-merges
946                         --author= --committer= --grep=
947                         --all-match
948                         --not --all
949                         --numbered --summary
950                         "
951                 return
952                 ;;
953         esac
954         __git_complete_revlist
957 _git_show ()
959         local cur="${COMP_WORDS[COMP_CWORD]}"
960         case "$cur" in
961         --pretty=*)
962                 __gitcomp "
963                         oneline short medium full fuller email raw
964                         " "" "${cur##--pretty=}"
965                 return
966                 ;;
967         --*)
968                 __gitcomp "--pretty="
969                 return
970                 ;;
971         esac
972         __git_complete_file
975 _git_stash ()
977         __gitcomp 'list show apply clear'
980 _git ()
982         local i c=1 command __git_dir
984         while [ $c -lt $COMP_CWORD ]; do
985                 i="${COMP_WORDS[c]}"
986                 case "$i" in
987                 --git-dir=*) __git_dir="${i#--git-dir=}" ;;
988                 --bare)      __git_dir="." ;;
989                 --version|--help|-p|--paginate) ;;
990                 *) command="$i"; break ;;
991                 esac
992                 c=$((++c))
993         done
995         if [ $c -eq $COMP_CWORD -a -z "$command" ]; then
996                 case "${COMP_WORDS[COMP_CWORD]}" in
997                 --*=*) COMPREPLY=() ;;
998                 --*)   __gitcomp "--git-dir= --bare --version --exec-path" ;;
999                 *)     __gitcomp "$(__git_commands) $(__git_aliases)" ;;
1000                 esac
1001                 return
1002         fi
1004         local expansion=$(__git_aliased_command "$command")
1005         [ "$expansion" ] && command="$expansion"
1007         case "$command" in
1008         am)          _git_am ;;
1009         add)         _git_add ;;
1010         apply)       _git_apply ;;
1011         bisect)      _git_bisect ;;
1012         branch)      _git_branch ;;
1013         checkout)    _git_checkout ;;
1014         cherry)      _git_cherry ;;
1015         cherry-pick) _git_cherry_pick ;;
1016         commit)      _git_commit ;;
1017         config)      _git_config ;;
1018         diff)        _git_diff ;;
1019         fetch)       _git_fetch ;;
1020         format-patch) _git_format_patch ;;
1021         gc)          _git_gc ;;
1022         log)         _git_log ;;
1023         ls-remote)   _git_ls_remote ;;
1024         ls-tree)     _git_ls_tree ;;
1025         merge)       _git_merge;;
1026         merge-base)  _git_merge_base ;;
1027         name-rev)    _git_name_rev ;;
1028         pull)        _git_pull ;;
1029         push)        _git_push ;;
1030         rebase)      _git_rebase ;;
1031         remote)      _git_remote ;;
1032         reset)       _git_reset ;;
1033         shortlog)    _git_shortlog ;;
1034         show)        _git_show ;;
1035         show-branch) _git_log ;;
1036         stash)       _git_stash ;;
1037         whatchanged) _git_log ;;
1038         *)           COMPREPLY=() ;;
1039         esac
1042 _gitk ()
1044         local cur="${COMP_WORDS[COMP_CWORD]}"
1045         case "$cur" in
1046         --*)
1047                 __gitcomp "--not --all"
1048                 return
1049                 ;;
1050         esac
1051         __git_complete_revlist
1054 complete -o default -o nospace -F _git git
1055 complete -o default -o nospace -F _gitk gitk
1056 complete -o default -o nospace -F _git_am git-am
1057 complete -o default -o nospace -F _git_apply git-apply
1058 complete -o default -o nospace -F _git_bisect git-bisect
1059 complete -o default -o nospace -F _git_branch git-branch
1060 complete -o default -o nospace -F _git_checkout git-checkout
1061 complete -o default -o nospace -F _git_cherry git-cherry
1062 complete -o default -o nospace -F _git_cherry_pick git-cherry-pick
1063 complete -o default -o nospace -F _git_commit git-commit
1064 complete -o default -o nospace -F _git_diff git-diff
1065 complete -o default -o nospace -F _git_fetch git-fetch
1066 complete -o default -o nospace -F _git_format_patch git-format-patch
1067 complete -o default -o nospace -F _git_gc git-gc
1068 complete -o default -o nospace -F _git_log git-log
1069 complete -o default -o nospace -F _git_ls_remote git-ls-remote
1070 complete -o default -o nospace -F _git_ls_tree git-ls-tree
1071 complete -o default -o nospace -F _git_merge git-merge
1072 complete -o default -o nospace -F _git_merge_base git-merge-base
1073 complete -o default -o nospace -F _git_name_rev git-name-rev
1074 complete -o default -o nospace -F _git_pull git-pull
1075 complete -o default -o nospace -F _git_push git-push
1076 complete -o default -o nospace -F _git_rebase git-rebase
1077 complete -o default -o nospace -F _git_config git-config
1078 complete -o default -o nospace -F _git_remote git-remote
1079 complete -o default -o nospace -F _git_reset git-reset
1080 complete -o default -o nospace -F _git_shortlog git-shortlog
1081 complete -o default -o nospace -F _git_show git-show
1082 complete -o default -o nospace -F _git_stash git-stash
1083 complete -o default -o nospace -F _git_log git-show-branch
1084 complete -o default -o nospace -F _git_log git-whatchanged
1086 # The following are necessary only for Cygwin, and only are needed
1087 # when the user has tab-completed the executable name and consequently
1088 # included the '.exe' suffix.
1090 if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
1091 complete -o default -o nospace -F _git_add git-add.exe
1092 complete -o default -o nospace -F _git_apply git-apply.exe
1093 complete -o default -o nospace -F _git git.exe
1094 complete -o default -o nospace -F _git_branch git-branch.exe
1095 complete -o default -o nospace -F _git_cherry git-cherry.exe
1096 complete -o default -o nospace -F _git_diff git-diff.exe
1097 complete -o default -o nospace -F _git_format_patch git-format-patch.exe
1098 complete -o default -o nospace -F _git_log git-log.exe
1099 complete -o default -o nospace -F _git_ls_tree git-ls-tree.exe
1100 complete -o default -o nospace -F _git_merge_base git-merge-base.exe
1101 complete -o default -o nospace -F _git_name_rev git-name-rev.exe
1102 complete -o default -o nospace -F _git_push git-push.exe
1103 complete -o default -o nospace -F _git_config git-config
1104 complete -o default -o nospace -F _git_shortlog git-shortlog.exe
1105 complete -o default -o nospace -F _git_show git-show.exe
1106 complete -o default -o nospace -F _git_log git-show-branch.exe
1107 complete -o default -o nospace -F _git_log git-whatchanged.exe
1108 fi