am: --rebasing
[git.git] / contrib / completion / git-completion.bash
blob5ae87998e6cc434ee5de8413426429fd891b0ac1
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 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 if test -f "$g/../.dotest/rebasing"
74 then
75 r="|REBASE"
76 elif test -f "$g/../.dotest/applying"
77 then
78 r="|AM"
79 else
80 r="|AM/REBASE"
82 b="$(git symbolic-ref HEAD 2>/dev/null)"
83 elif [ -f "$g/.dotest-merge/interactive" ]
84 then
85 r="|REBASE-i"
86 b="$(cat $g/.dotest-merge/head-name)"
87 elif [ -d "$g/.dotest-merge" ]
88 then
89 r="|REBASE-m"
90 b="$(cat $g/.dotest-merge/head-name)"
91 elif [ -f "$g/MERGE_HEAD" ]
92 then
93 r="|MERGING"
94 b="$(git symbolic-ref HEAD 2>/dev/null)"
95 else
96 if [ -f $g/BISECT_LOG ]
97 then
98 r="|BISECTING"
100 if ! b="$(git symbolic-ref HEAD 2>/dev/null)"
101 then
102 if ! b="$(git describe --exact-match HEAD 2>/dev/null)"
103 then
104 b="$(cut -c1-7 $g/HEAD)..."
109 if [ -n "$1" ]; then
110 printf "$1" "${b##refs/heads/}$r"
111 else
112 printf " (%s)" "${b##refs/heads/}$r"
117 __gitcomp ()
119 local all c s=$'\n' IFS=' '$'\t'$'\n'
120 local cur="${COMP_WORDS[COMP_CWORD]}"
121 if [ $# -gt 2 ]; then
122 cur="$3"
124 for c in $1; do
125 case "$c$4" in
126 --*=*) all="$all$c$4$s" ;;
127 *.) all="$all$c$4$s" ;;
128 *) all="$all$c$4 $s" ;;
129 esac
130 done
131 IFS=$s
132 COMPREPLY=($(compgen -P "$2" -W "$all" -- "$cur"))
133 return
136 __git_heads ()
138 local cmd i is_hash=y dir="$(__gitdir "$1")"
139 if [ -d "$dir" ]; then
140 for i in $(git --git-dir="$dir" \
141 for-each-ref --format='%(refname)' \
142 refs/heads ); do
143 echo "${i#refs/heads/}"
144 done
145 return
147 for i in $(git-ls-remote "$1" 2>/dev/null); do
148 case "$is_hash,$i" in
149 y,*) is_hash=n ;;
150 n,*^{}) is_hash=y ;;
151 n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
152 n,*) is_hash=y; echo "$i" ;;
153 esac
154 done
157 __git_tags ()
159 local cmd i is_hash=y dir="$(__gitdir "$1")"
160 if [ -d "$dir" ]; then
161 for i in $(git --git-dir="$dir" \
162 for-each-ref --format='%(refname)' \
163 refs/tags ); do
164 echo "${i#refs/tags/}"
165 done
166 return
168 for i in $(git-ls-remote "$1" 2>/dev/null); do
169 case "$is_hash,$i" in
170 y,*) is_hash=n ;;
171 n,*^{}) is_hash=y ;;
172 n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
173 n,*) is_hash=y; echo "$i" ;;
174 esac
175 done
178 __git_refs ()
180 local cmd i is_hash=y dir="$(__gitdir "$1")"
181 if [ -d "$dir" ]; then
182 if [ -e "$dir/HEAD" ]; then echo HEAD; fi
183 for i in $(git --git-dir="$dir" \
184 for-each-ref --format='%(refname)' \
185 refs/tags refs/heads refs/remotes); do
186 case "$i" in
187 refs/tags/*) echo "${i#refs/tags/}" ;;
188 refs/heads/*) echo "${i#refs/heads/}" ;;
189 refs/remotes/*) echo "${i#refs/remotes/}" ;;
190 *) echo "$i" ;;
191 esac
192 done
193 return
195 for i in $(git-ls-remote "$dir" 2>/dev/null); do
196 case "$is_hash,$i" in
197 y,*) is_hash=n ;;
198 n,*^{}) is_hash=y ;;
199 n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
200 n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
201 n,refs/remotes/*) is_hash=y; echo "${i#refs/remotes/}" ;;
202 n,*) is_hash=y; echo "$i" ;;
203 esac
204 done
207 __git_refs2 ()
209 local i
210 for i in $(__git_refs "$1"); do
211 echo "$i:$i"
212 done
215 __git_refs_remotes ()
217 local cmd i is_hash=y
218 for i in $(git-ls-remote "$1" 2>/dev/null); do
219 case "$is_hash,$i" in
220 n,refs/heads/*)
221 is_hash=y
222 echo "$i:refs/remotes/$1/${i#refs/heads/}"
224 y,*) is_hash=n ;;
225 n,*^{}) is_hash=y ;;
226 n,refs/tags/*) is_hash=y;;
227 n,*) is_hash=y; ;;
228 esac
229 done
232 __git_remotes ()
234 local i ngoff IFS=$'\n' d="$(__gitdir)"
235 shopt -q nullglob || ngoff=1
236 shopt -s nullglob
237 for i in "$d/remotes"/*; do
238 echo ${i#$d/remotes/}
239 done
240 [ "$ngoff" ] && shopt -u nullglob
241 for i in $(git --git-dir="$d" config --list); do
242 case "$i" in
243 remote.*.url=*)
244 i="${i#remote.}"
245 echo "${i/.url=*/}"
247 esac
248 done
251 __git_merge_strategies ()
253 if [ -n "$__git_merge_strategylist" ]; then
254 echo "$__git_merge_strategylist"
255 return
257 sed -n "/^all_strategies='/{
258 s/^all_strategies='//
259 s/'//
262 }" "$(git --exec-path)/git-merge"
264 __git_merge_strategylist=
265 __git_merge_strategylist="$(__git_merge_strategies 2>/dev/null)"
267 __git_complete_file ()
269 local pfx ls ref cur="${COMP_WORDS[COMP_CWORD]}"
270 case "$cur" in
271 ?*:*)
272 ref="${cur%%:*}"
273 cur="${cur#*:}"
274 case "$cur" in
275 ?*/*)
276 pfx="${cur%/*}"
277 cur="${cur##*/}"
278 ls="$ref:$pfx"
279 pfx="$pfx/"
282 ls="$ref"
284 esac
285 COMPREPLY=($(compgen -P "$pfx" \
286 -W "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \
287 | sed '/^100... blob /s,^.* ,,
288 /^040000 tree /{
289 s,^.* ,,
290 s,$,/,
292 s/^.* //')" \
293 -- "$cur"))
296 __gitcomp "$(__git_refs)"
298 esac
301 __git_complete_revlist ()
303 local pfx cur="${COMP_WORDS[COMP_CWORD]}"
304 case "$cur" in
305 *...*)
306 pfx="${cur%...*}..."
307 cur="${cur#*...}"
308 __gitcomp "$(__git_refs)" "$pfx" "$cur"
310 *..*)
311 pfx="${cur%..*}.."
312 cur="${cur#*..}"
313 __gitcomp "$(__git_refs)" "$pfx" "$cur"
316 __gitcomp "$cur."
319 __gitcomp "$(__git_refs)"
321 esac
324 __git_commands ()
326 if [ -n "$__git_commandlist" ]; then
327 echo "$__git_commandlist"
328 return
330 local i IFS=" "$'\n'
331 for i in $(git help -a|egrep '^ ')
333 case $i in
334 *--*) : helper pattern;;
335 applymbox) : ask gittus;;
336 applypatch) : ask gittus;;
337 archimport) : import;;
338 cat-file) : plumbing;;
339 check-attr) : plumbing;;
340 check-ref-format) : plumbing;;
341 commit-tree) : plumbing;;
342 cvsexportcommit) : export;;
343 cvsimport) : import;;
344 cvsserver) : daemon;;
345 daemon) : daemon;;
346 diff-files) : plumbing;;
347 diff-index) : plumbing;;
348 diff-tree) : plumbing;;
349 fast-import) : import;;
350 fsck-objects) : plumbing;;
351 fetch-pack) : plumbing;;
352 fmt-merge-msg) : plumbing;;
353 for-each-ref) : plumbing;;
354 hash-object) : plumbing;;
355 http-*) : transport;;
356 index-pack) : plumbing;;
357 init-db) : deprecated;;
358 local-fetch) : plumbing;;
359 mailinfo) : plumbing;;
360 mailsplit) : plumbing;;
361 merge-*) : plumbing;;
362 mktree) : plumbing;;
363 mktag) : plumbing;;
364 pack-objects) : plumbing;;
365 pack-redundant) : plumbing;;
366 pack-refs) : plumbing;;
367 parse-remote) : plumbing;;
368 patch-id) : plumbing;;
369 peek-remote) : plumbing;;
370 prune) : plumbing;;
371 prune-packed) : plumbing;;
372 quiltimport) : import;;
373 read-tree) : plumbing;;
374 receive-pack) : plumbing;;
375 reflog) : plumbing;;
376 repo-config) : deprecated;;
377 rerere) : plumbing;;
378 rev-list) : plumbing;;
379 rev-parse) : plumbing;;
380 runstatus) : plumbing;;
381 sh-setup) : internal;;
382 shell) : daemon;;
383 send-pack) : plumbing;;
384 show-index) : plumbing;;
385 ssh-*) : transport;;
386 stripspace) : plumbing;;
387 svn) : import export;;
388 symbolic-ref) : plumbing;;
389 tar-tree) : deprecated;;
390 unpack-file) : plumbing;;
391 unpack-objects) : plumbing;;
392 update-index) : plumbing;;
393 update-ref) : plumbing;;
394 update-server-info) : daemon;;
395 upload-archive) : plumbing;;
396 upload-pack) : plumbing;;
397 write-tree) : plumbing;;
398 verify-tag) : plumbing;;
399 *) echo $i;;
400 esac
401 done
403 __git_commandlist=
404 __git_commandlist="$(__git_commands 2>/dev/null)"
406 __git_aliases ()
408 local i IFS=$'\n'
409 for i in $(git --git-dir="$(__gitdir)" config --list); do
410 case "$i" in
411 alias.*)
412 i="${i#alias.}"
413 echo "${i/=*/}"
415 esac
416 done
419 __git_aliased_command ()
421 local word cmdline=$(git --git-dir="$(__gitdir)" \
422 config --get "alias.$1")
423 for word in $cmdline; do
424 if [ "${word##-*}" ]; then
425 echo $word
426 return
428 done
431 __git_whitespacelist="nowarn warn error error-all strip"
433 _git_am ()
435 local cur="${COMP_WORDS[COMP_CWORD]}"
436 if [ -d .dotest ]; then
437 __gitcomp "--skip --resolved"
438 return
440 case "$cur" in
441 --whitespace=*)
442 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
443 return
445 --*)
446 __gitcomp "
447 --signoff --utf8 --binary --3way --interactive
448 --whitespace=
450 return
451 esac
452 COMPREPLY=()
455 _git_apply ()
457 local cur="${COMP_WORDS[COMP_CWORD]}"
458 case "$cur" in
459 --whitespace=*)
460 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
461 return
463 --*)
464 __gitcomp "
465 --stat --numstat --summary --check --index
466 --cached --index-info --reverse --reject --unidiff-zero
467 --apply --no-add --exclude=
468 --whitespace= --inaccurate-eof --verbose
470 return
471 esac
472 COMPREPLY=()
475 _git_add ()
477 local cur="${COMP_WORDS[COMP_CWORD]}"
478 case "$cur" in
479 --*)
480 __gitcomp "--interactive --refresh"
481 return
482 esac
483 COMPREPLY=()
486 _git_bisect ()
488 local i c=1 command
489 while [ $c -lt $COMP_CWORD ]; do
490 i="${COMP_WORDS[c]}"
491 case "$i" in
492 start|bad|good|reset|visualize|replay|log)
493 command="$i"
494 break
496 esac
497 c=$((++c))
498 done
500 if [ $c -eq $COMP_CWORD -a -z "$command" ]; then
501 __gitcomp "start bad good reset visualize replay log"
502 return
505 case "$command" in
506 bad|good|reset)
507 __gitcomp "$(__git_refs)"
510 COMPREPLY=()
512 esac
515 _git_branch ()
517 __gitcomp "$(__git_refs)"
520 _git_bundle ()
522 local mycword="$COMP_CWORD"
523 case "${COMP_WORDS[0]}" in
524 git)
525 local cmd="${COMP_WORDS[2]}"
526 mycword="$((mycword-1))"
528 git-bundle*)
529 local cmd="${COMP_WORDS[1]}"
531 esac
532 case "$mycword" in
534 __gitcomp "create list-heads verify unbundle"
537 # looking for a file
540 case "$cmd" in
541 create)
542 __git_complete_revlist
544 esac
546 esac
549 _git_checkout ()
551 __gitcomp "$(__git_refs)"
554 _git_cherry ()
556 __gitcomp "$(__git_refs)"
559 _git_cherry_pick ()
561 local cur="${COMP_WORDS[COMP_CWORD]}"
562 case "$cur" in
563 --*)
564 __gitcomp "--edit --no-commit"
567 __gitcomp "$(__git_refs)"
569 esac
572 _git_commit ()
574 local cur="${COMP_WORDS[COMP_CWORD]}"
575 case "$cur" in
576 --*)
577 __gitcomp "
578 --all --author= --signoff --verify --no-verify
579 --edit --amend --include --only
581 return
582 esac
583 COMPREPLY=()
586 _git_describe ()
588 __gitcomp "$(__git_refs)"
591 _git_diff ()
593 local cur="${COMP_WORDS[COMP_CWORD]}"
594 case "$cur" in
595 --*)
596 __gitcomp "--cached --stat --numstat --shortstat --summary
597 --patch-with-stat --name-only --name-status --color
598 --no-color --color-words --no-renames --check
599 --full-index --binary --abbrev --diff-filter
600 --find-copies-harder --pickaxe-all --pickaxe-regex
601 --text --ignore-space-at-eol --ignore-space-change
602 --ignore-all-space --exit-code --quiet --ext-diff
603 --no-ext-diff"
604 return
606 esac
607 __git_complete_file
610 _git_diff_tree ()
612 __gitcomp "$(__git_refs)"
615 _git_fetch ()
617 local cur="${COMP_WORDS[COMP_CWORD]}"
619 case "${COMP_WORDS[0]},$COMP_CWORD" in
620 git-fetch*,1)
621 __gitcomp "$(__git_remotes)"
623 git,2)
624 __gitcomp "$(__git_remotes)"
627 case "$cur" in
628 *:*)
629 __gitcomp "$(__git_refs)" "" "${cur#*:}"
632 local remote
633 case "${COMP_WORDS[0]}" in
634 git-fetch) remote="${COMP_WORDS[1]}" ;;
635 git) remote="${COMP_WORDS[2]}" ;;
636 esac
637 __gitcomp "$(__git_refs2 "$remote")"
639 esac
641 esac
644 _git_format_patch ()
646 local cur="${COMP_WORDS[COMP_CWORD]}"
647 case "$cur" in
648 --*)
649 __gitcomp "
650 --stdout --attach --thread
651 --output-directory
652 --numbered --start-number
653 --numbered-files
654 --keep-subject
655 --signoff
656 --in-reply-to=
657 --full-index --binary
658 --not --all
659 --cover-letter
661 return
663 esac
664 __git_complete_revlist
667 _git_gc ()
669 local cur="${COMP_WORDS[COMP_CWORD]}"
670 case "$cur" in
671 --*)
672 __gitcomp "--prune --aggressive"
673 return
675 esac
676 COMPREPLY=()
679 _git_ls_remote ()
681 __gitcomp "$(__git_remotes)"
684 _git_ls_tree ()
686 __git_complete_file
689 _git_log ()
691 local cur="${COMP_WORDS[COMP_CWORD]}"
692 case "$cur" in
693 --pretty=*)
694 __gitcomp "
695 oneline short medium full fuller email raw
696 " "" "${cur##--pretty=}"
697 return
699 --date=*)
700 __gitcomp "
701 relative iso8601 rfc2822 short local default
702 " "" "${cur##--date=}"
703 return
705 --*)
706 __gitcomp "
707 --max-count= --max-age= --since= --after=
708 --min-age= --before= --until=
709 --root --topo-order --date-order --reverse
710 --no-merges --follow
711 --abbrev-commit --abbrev=
712 --relative-date --date=
713 --author= --committer= --grep=
714 --all-match
715 --pretty= --name-status --name-only --raw
716 --not --all
717 --left-right --cherry-pick
719 return
721 esac
722 __git_complete_revlist
725 _git_merge ()
727 local cur="${COMP_WORDS[COMP_CWORD]}"
728 case "${COMP_WORDS[COMP_CWORD-1]}" in
729 -s|--strategy)
730 __gitcomp "$(__git_merge_strategies)"
731 return
732 esac
733 case "$cur" in
734 --strategy=*)
735 __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}"
736 return
738 --*)
739 __gitcomp "
740 --no-commit --no-summary --squash --strategy
742 return
743 esac
744 __gitcomp "$(__git_refs)"
747 _git_merge_base ()
749 __gitcomp "$(__git_refs)"
752 _git_name_rev ()
754 __gitcomp "--tags --all --stdin"
757 _git_pull ()
759 local cur="${COMP_WORDS[COMP_CWORD]}"
761 case "${COMP_WORDS[0]},$COMP_CWORD" in
762 git-pull*,1)
763 __gitcomp "$(__git_remotes)"
765 git,2)
766 __gitcomp "$(__git_remotes)"
769 local remote
770 case "${COMP_WORDS[0]}" in
771 git-pull) remote="${COMP_WORDS[1]}" ;;
772 git) remote="${COMP_WORDS[2]}" ;;
773 esac
774 __gitcomp "$(__git_refs "$remote")"
776 esac
779 _git_push ()
781 local cur="${COMP_WORDS[COMP_CWORD]}"
783 case "${COMP_WORDS[0]},$COMP_CWORD" in
784 git-push*,1)
785 __gitcomp "$(__git_remotes)"
787 git,2)
788 __gitcomp "$(__git_remotes)"
791 case "$cur" in
792 *:*)
793 local remote
794 case "${COMP_WORDS[0]}" in
795 git-push) remote="${COMP_WORDS[1]}" ;;
796 git) remote="${COMP_WORDS[2]}" ;;
797 esac
798 __gitcomp "$(__git_refs "$remote")" "" "${cur#*:}"
801 __gitcomp "$(__git_refs)" + "${cur#+}"
804 __gitcomp "$(__git_refs)"
806 esac
808 esac
811 _git_rebase ()
813 local cur="${COMP_WORDS[COMP_CWORD]}"
814 if [ -d .dotest ] || [ -d .git/.dotest-merge ]; then
815 __gitcomp "--continue --skip --abort"
816 return
818 case "${COMP_WORDS[COMP_CWORD-1]}" in
819 -s|--strategy)
820 __gitcomp "$(__git_merge_strategies)"
821 return
822 esac
823 case "$cur" in
824 --strategy=*)
825 __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}"
826 return
828 --*)
829 __gitcomp "--onto --merge --strategy"
830 return
831 esac
832 __gitcomp "$(__git_refs)"
835 _git_config ()
837 local cur="${COMP_WORDS[COMP_CWORD]}"
838 local prv="${COMP_WORDS[COMP_CWORD-1]}"
839 case "$prv" in
840 branch.*.remote)
841 __gitcomp "$(__git_remotes)"
842 return
844 branch.*.merge)
845 __gitcomp "$(__git_refs)"
846 return
848 remote.*.fetch)
849 local remote="${prv#remote.}"
850 remote="${remote%.fetch}"
851 __gitcomp "$(__git_refs_remotes "$remote")"
852 return
854 remote.*.push)
855 local remote="${prv#remote.}"
856 remote="${remote%.push}"
857 __gitcomp "$(git --git-dir="$(__gitdir)" \
858 for-each-ref --format='%(refname):%(refname)' \
859 refs/heads)"
860 return
862 pull.twohead|pull.octopus)
863 __gitcomp "$(__git_merge_strategies)"
864 return
866 color.branch|color.diff|color.status)
867 __gitcomp "always never auto"
868 return
870 color.*.*)
871 __gitcomp "
872 black red green yellow blue magenta cyan white
873 bold dim ul blink reverse
875 return
877 *.*)
878 COMPREPLY=()
879 return
881 esac
882 case "$cur" in
883 --*)
884 __gitcomp "
885 --global --system --file=
886 --list --replace-all
887 --get --get-all --get-regexp
888 --add --unset --unset-all
889 --remove-section --rename-section
891 return
893 branch.*.*)
894 local pfx="${cur%.*}."
895 cur="${cur##*.}"
896 __gitcomp "remote merge" "$pfx" "$cur"
897 return
899 branch.*)
900 local pfx="${cur%.*}."
901 cur="${cur#*.}"
902 __gitcomp "$(__git_heads)" "$pfx" "$cur" "."
903 return
905 remote.*.*)
906 local pfx="${cur%.*}."
907 cur="${cur##*.}"
908 __gitcomp "
909 url fetch push skipDefaultUpdate
910 receivepack uploadpack tagopt
911 " "$pfx" "$cur"
912 return
914 remote.*)
915 local pfx="${cur%.*}."
916 cur="${cur#*.}"
917 __gitcomp "$(__git_remotes)" "$pfx" "$cur" "."
918 return
920 esac
921 __gitcomp "
922 apply.whitespace
923 core.fileMode
924 core.gitProxy
925 core.ignoreStat
926 core.preferSymlinkRefs
927 core.logAllRefUpdates
928 core.loosecompression
929 core.repositoryFormatVersion
930 core.sharedRepository
931 core.warnAmbiguousRefs
932 core.compression
933 core.legacyHeaders
934 core.packedGitWindowSize
935 core.packedGitLimit
936 clean.requireForce
937 color.branch
938 color.branch.current
939 color.branch.local
940 color.branch.remote
941 color.branch.plain
942 color.diff
943 color.diff.plain
944 color.diff.meta
945 color.diff.frag
946 color.diff.old
947 color.diff.new
948 color.diff.commit
949 color.diff.whitespace
950 color.pager
951 color.status
952 color.status.header
953 color.status.added
954 color.status.changed
955 color.status.untracked
956 diff.renameLimit
957 diff.renames
958 fetch.unpackLimit
959 format.headers
960 format.subjectprefix
961 gitcvs.enabled
962 gitcvs.logfile
963 gitcvs.allbinary
964 gitcvs.dbname gitcvs.dbdriver gitcvs.dbuser gitcvs.dvpass
965 gc.packrefs
966 gc.reflogexpire
967 gc.reflogexpireunreachable
968 gc.rerereresolved
969 gc.rerereunresolved
970 http.sslVerify
971 http.sslCert
972 http.sslKey
973 http.sslCAInfo
974 http.sslCAPath
975 http.maxRequests
976 http.lowSpeedLimit
977 http.lowSpeedTime
978 http.noEPSV
979 i18n.commitEncoding
980 i18n.logOutputEncoding
981 log.showroot
982 merge.tool
983 merge.summary
984 merge.verbosity
985 pack.window
986 pack.depth
987 pack.windowMemory
988 pack.compression
989 pack.deltaCacheSize
990 pack.deltaCacheLimit
991 pull.octopus
992 pull.twohead
993 repack.useDeltaBaseOffset
994 show.difftree
995 showbranch.default
996 tar.umask
997 transfer.unpackLimit
998 receive.unpackLimit
999 receive.denyNonFastForwards
1000 user.name
1001 user.email
1002 user.signingkey
1003 whatchanged.difftree
1004 branch. remote.
1008 _git_remote ()
1010 local i c=1 command
1011 while [ $c -lt $COMP_CWORD ]; do
1012 i="${COMP_WORDS[c]}"
1013 case "$i" in
1014 add|rm|show|prune|update) command="$i"; break ;;
1015 esac
1016 c=$((++c))
1017 done
1019 if [ $c -eq $COMP_CWORD -a -z "$command" ]; then
1020 __gitcomp "add rm show prune update"
1021 return
1024 case "$command" in
1025 rm|show|prune)
1026 __gitcomp "$(__git_remotes)"
1028 update)
1029 local i c='' IFS=$'\n'
1030 for i in $(git --git-dir="$(__gitdir)" config --list); do
1031 case "$i" in
1032 remotes.*)
1033 i="${i#remotes.}"
1034 c="$c ${i/=*/}"
1036 esac
1037 done
1038 __gitcomp "$c"
1041 COMPREPLY=()
1043 esac
1046 _git_reset ()
1048 local cur="${COMP_WORDS[COMP_CWORD]}"
1049 case "$cur" in
1050 --*)
1051 __gitcomp "--mixed --hard --soft"
1052 return
1054 esac
1055 __gitcomp "$(__git_refs)"
1058 _git_shortlog ()
1060 local cur="${COMP_WORDS[COMP_CWORD]}"
1061 case "$cur" in
1062 --*)
1063 __gitcomp "
1064 --max-count= --max-age= --since= --after=
1065 --min-age= --before= --until=
1066 --no-merges
1067 --author= --committer= --grep=
1068 --all-match
1069 --not --all
1070 --numbered --summary
1072 return
1074 esac
1075 __git_complete_revlist
1078 _git_show ()
1080 local cur="${COMP_WORDS[COMP_CWORD]}"
1081 case "$cur" in
1082 --pretty=*)
1083 __gitcomp "
1084 oneline short medium full fuller email raw
1085 " "" "${cur##--pretty=}"
1086 return
1088 --*)
1089 __gitcomp "--pretty="
1090 return
1092 esac
1093 __git_complete_file
1096 _git_stash ()
1098 __gitcomp 'list show apply clear'
1101 _git_submodule ()
1103 local i c=1 command
1104 while [ $c -lt $COMP_CWORD ]; do
1105 i="${COMP_WORDS[c]}"
1106 case "$i" in
1107 add|status|init|update) command="$i"; break ;;
1108 esac
1109 c=$((++c))
1110 done
1112 if [ $c -eq $COMP_CWORD -a -z "$command" ]; then
1113 local cur="${COMP_WORDS[COMP_CWORD]}"
1114 case "$cur" in
1115 --*)
1116 __gitcomp "--quiet --cached"
1119 __gitcomp "add status init update"
1121 esac
1122 return
1126 _git_tag ()
1128 local i c=1 f=0
1129 while [ $c -lt $COMP_CWORD ]; do
1130 i="${COMP_WORDS[c]}"
1131 case "$i" in
1132 -d|-v)
1133 __gitcomp "$(__git_tags)"
1134 return
1139 esac
1140 c=$((++c))
1141 done
1143 case "${COMP_WORDS[COMP_CWORD-1]}" in
1144 -m|-F)
1145 COMPREPLY=()
1147 -*|tag|git-tag)
1148 if [ $f = 1 ]; then
1149 __gitcomp "$(__git_tags)"
1150 else
1151 COMPREPLY=()
1155 __gitcomp "$(__git_refs)"
1157 esac
1160 _git ()
1162 local i c=1 command __git_dir
1164 while [ $c -lt $COMP_CWORD ]; do
1165 i="${COMP_WORDS[c]}"
1166 case "$i" in
1167 --git-dir=*) __git_dir="${i#--git-dir=}" ;;
1168 --bare) __git_dir="." ;;
1169 --version|--help|-p|--paginate) ;;
1170 *) command="$i"; break ;;
1171 esac
1172 c=$((++c))
1173 done
1175 if [ $c -eq $COMP_CWORD -a -z "$command" ]; then
1176 case "${COMP_WORDS[COMP_CWORD]}" in
1177 --*=*) COMPREPLY=() ;;
1178 --*) __gitcomp "
1179 --no-pager
1180 --git-dir=
1181 --bare
1182 --version
1183 --exec-path
1186 *) __gitcomp "$(__git_commands) $(__git_aliases)" ;;
1187 esac
1188 return
1191 local expansion=$(__git_aliased_command "$command")
1192 [ "$expansion" ] && command="$expansion"
1194 case "$command" in
1195 am) _git_am ;;
1196 add) _git_add ;;
1197 apply) _git_apply ;;
1198 bisect) _git_bisect ;;
1199 bundle) _git_bundle ;;
1200 branch) _git_branch ;;
1201 checkout) _git_checkout ;;
1202 cherry) _git_cherry ;;
1203 cherry-pick) _git_cherry_pick ;;
1204 commit) _git_commit ;;
1205 config) _git_config ;;
1206 describe) _git_describe ;;
1207 diff) _git_diff ;;
1208 fetch) _git_fetch ;;
1209 format-patch) _git_format_patch ;;
1210 gc) _git_gc ;;
1211 log) _git_log ;;
1212 ls-remote) _git_ls_remote ;;
1213 ls-tree) _git_ls_tree ;;
1214 merge) _git_merge;;
1215 merge-base) _git_merge_base ;;
1216 name-rev) _git_name_rev ;;
1217 pull) _git_pull ;;
1218 push) _git_push ;;
1219 rebase) _git_rebase ;;
1220 remote) _git_remote ;;
1221 reset) _git_reset ;;
1222 shortlog) _git_shortlog ;;
1223 show) _git_show ;;
1224 show-branch) _git_log ;;
1225 stash) _git_stash ;;
1226 submodule) _git_submodule ;;
1227 tag) _git_tag ;;
1228 whatchanged) _git_log ;;
1229 *) COMPREPLY=() ;;
1230 esac
1233 _gitk ()
1235 local cur="${COMP_WORDS[COMP_CWORD]}"
1236 case "$cur" in
1237 --*)
1238 __gitcomp "--not --all"
1239 return
1241 esac
1242 __git_complete_revlist
1245 complete -o default -o nospace -F _git git
1246 complete -o default -o nospace -F _gitk gitk
1247 complete -o default -o nospace -F _git_am git-am
1248 complete -o default -o nospace -F _git_apply git-apply
1249 complete -o default -o nospace -F _git_bisect git-bisect
1250 complete -o default -o nospace -F _git_branch git-branch
1251 complete -o default -o nospace -F _git_bundle git-bundle
1252 complete -o default -o nospace -F _git_checkout git-checkout
1253 complete -o default -o nospace -F _git_cherry git-cherry
1254 complete -o default -o nospace -F _git_cherry_pick git-cherry-pick
1255 complete -o default -o nospace -F _git_commit git-commit
1256 complete -o default -o nospace -F _git_describe git-describe
1257 complete -o default -o nospace -F _git_diff git-diff
1258 complete -o default -o nospace -F _git_fetch git-fetch
1259 complete -o default -o nospace -F _git_format_patch git-format-patch
1260 complete -o default -o nospace -F _git_gc git-gc
1261 complete -o default -o nospace -F _git_log git-log
1262 complete -o default -o nospace -F _git_ls_remote git-ls-remote
1263 complete -o default -o nospace -F _git_ls_tree git-ls-tree
1264 complete -o default -o nospace -F _git_merge git-merge
1265 complete -o default -o nospace -F _git_merge_base git-merge-base
1266 complete -o default -o nospace -F _git_name_rev git-name-rev
1267 complete -o default -o nospace -F _git_pull git-pull
1268 complete -o default -o nospace -F _git_push git-push
1269 complete -o default -o nospace -F _git_rebase git-rebase
1270 complete -o default -o nospace -F _git_config git-config
1271 complete -o default -o nospace -F _git_remote git-remote
1272 complete -o default -o nospace -F _git_reset git-reset
1273 complete -o default -o nospace -F _git_shortlog git-shortlog
1274 complete -o default -o nospace -F _git_show git-show
1275 complete -o default -o nospace -F _git_stash git-stash
1276 complete -o default -o nospace -F _git_submodule git-submodule
1277 complete -o default -o nospace -F _git_log git-show-branch
1278 complete -o default -o nospace -F _git_tag git-tag
1279 complete -o default -o nospace -F _git_log git-whatchanged
1281 # The following are necessary only for Cygwin, and only are needed
1282 # when the user has tab-completed the executable name and consequently
1283 # included the '.exe' suffix.
1285 if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
1286 complete -o default -o nospace -F _git_add git-add.exe
1287 complete -o default -o nospace -F _git_apply git-apply.exe
1288 complete -o default -o nospace -F _git git.exe
1289 complete -o default -o nospace -F _git_branch git-branch.exe
1290 complete -o default -o nospace -F _git_bundle git-bundle.exe
1291 complete -o default -o nospace -F _git_cherry git-cherry.exe
1292 complete -o default -o nospace -F _git_describe git-describe.exe
1293 complete -o default -o nospace -F _git_diff git-diff.exe
1294 complete -o default -o nospace -F _git_format_patch git-format-patch.exe
1295 complete -o default -o nospace -F _git_log git-log.exe
1296 complete -o default -o nospace -F _git_ls_tree git-ls-tree.exe
1297 complete -o default -o nospace -F _git_merge_base git-merge-base.exe
1298 complete -o default -o nospace -F _git_name_rev git-name-rev.exe
1299 complete -o default -o nospace -F _git_push git-push.exe
1300 complete -o default -o nospace -F _git_config git-config
1301 complete -o default -o nospace -F _git_shortlog git-shortlog.exe
1302 complete -o default -o nospace -F _git_show git-show.exe
1303 complete -o default -o nospace -F _git_log git-show-branch.exe
1304 complete -o default -o nospace -F _git_tag git-tag.exe
1305 complete -o default -o nospace -F _git_log git-whatchanged.exe