Add interactive option in rebase command completion list.
[git.git] / contrib / completion / git-completion.bash
blob96a712b5ea24f83cebf7f7e465168bdce5db6673
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 case "$cur" in
125 --*=)
126 COMPREPLY=()
127 return
130 for c in $1; do
131 case "$c$4" in
132 --*=*) all="$all$c$4$s" ;;
133 *.) all="$all$c$4$s" ;;
134 *) all="$all$c$4 $s" ;;
135 esac
136 done
138 esac
139 IFS=$s
140 COMPREPLY=($(compgen -P "$2" -W "$all" -- "$cur"))
141 return
144 __git_heads ()
146 local cmd i is_hash=y dir="$(__gitdir "$1")"
147 if [ -d "$dir" ]; then
148 for i in $(git --git-dir="$dir" \
149 for-each-ref --format='%(refname)' \
150 refs/heads ); do
151 echo "${i#refs/heads/}"
152 done
153 return
155 for i in $(git-ls-remote "$1" 2>/dev/null); do
156 case "$is_hash,$i" in
157 y,*) is_hash=n ;;
158 n,*^{}) is_hash=y ;;
159 n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
160 n,*) is_hash=y; echo "$i" ;;
161 esac
162 done
165 __git_tags ()
167 local cmd i is_hash=y dir="$(__gitdir "$1")"
168 if [ -d "$dir" ]; then
169 for i in $(git --git-dir="$dir" \
170 for-each-ref --format='%(refname)' \
171 refs/tags ); do
172 echo "${i#refs/tags/}"
173 done
174 return
176 for i in $(git-ls-remote "$1" 2>/dev/null); do
177 case "$is_hash,$i" in
178 y,*) is_hash=n ;;
179 n,*^{}) is_hash=y ;;
180 n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
181 n,*) is_hash=y; echo "$i" ;;
182 esac
183 done
186 __git_refs ()
188 local cmd i is_hash=y dir="$(__gitdir "$1")"
189 if [ -d "$dir" ]; then
190 if [ -e "$dir/HEAD" ]; then echo HEAD; fi
191 for i in $(git --git-dir="$dir" \
192 for-each-ref --format='%(refname)' \
193 refs/tags refs/heads refs/remotes); do
194 case "$i" in
195 refs/tags/*) echo "${i#refs/tags/}" ;;
196 refs/heads/*) echo "${i#refs/heads/}" ;;
197 refs/remotes/*) echo "${i#refs/remotes/}" ;;
198 *) echo "$i" ;;
199 esac
200 done
201 return
203 for i in $(git-ls-remote "$dir" 2>/dev/null); do
204 case "$is_hash,$i" in
205 y,*) is_hash=n ;;
206 n,*^{}) is_hash=y ;;
207 n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
208 n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
209 n,refs/remotes/*) is_hash=y; echo "${i#refs/remotes/}" ;;
210 n,*) is_hash=y; echo "$i" ;;
211 esac
212 done
215 __git_refs2 ()
217 local i
218 for i in $(__git_refs "$1"); do
219 echo "$i:$i"
220 done
223 __git_refs_remotes ()
225 local cmd i is_hash=y
226 for i in $(git-ls-remote "$1" 2>/dev/null); do
227 case "$is_hash,$i" in
228 n,refs/heads/*)
229 is_hash=y
230 echo "$i:refs/remotes/$1/${i#refs/heads/}"
232 y,*) is_hash=n ;;
233 n,*^{}) is_hash=y ;;
234 n,refs/tags/*) is_hash=y;;
235 n,*) is_hash=y; ;;
236 esac
237 done
240 __git_remotes ()
242 local i ngoff IFS=$'\n' d="$(__gitdir)"
243 shopt -q nullglob || ngoff=1
244 shopt -s nullglob
245 for i in "$d/remotes"/*; do
246 echo ${i#$d/remotes/}
247 done
248 [ "$ngoff" ] && shopt -u nullglob
249 for i in $(git --git-dir="$d" config --list); do
250 case "$i" in
251 remote.*.url=*)
252 i="${i#remote.}"
253 echo "${i/.url=*/}"
255 esac
256 done
259 __git_merge_strategies ()
261 if [ -n "$__git_merge_strategylist" ]; then
262 echo "$__git_merge_strategylist"
263 return
265 sed -n "/^all_strategies='/{
266 s/^all_strategies='//
267 s/'//
270 }" "$(git --exec-path)/git-merge"
272 __git_merge_strategylist=
273 __git_merge_strategylist="$(__git_merge_strategies 2>/dev/null)"
275 __git_complete_file ()
277 local pfx ls ref cur="${COMP_WORDS[COMP_CWORD]}"
278 case "$cur" in
279 ?*:*)
280 ref="${cur%%:*}"
281 cur="${cur#*:}"
282 case "$cur" in
283 ?*/*)
284 pfx="${cur%/*}"
285 cur="${cur##*/}"
286 ls="$ref:$pfx"
287 pfx="$pfx/"
290 ls="$ref"
292 esac
293 COMPREPLY=($(compgen -P "$pfx" \
294 -W "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \
295 | sed '/^100... blob /s,^.* ,,
296 /^040000 tree /{
297 s,^.* ,,
298 s,$,/,
300 s/^.* //')" \
301 -- "$cur"))
304 __gitcomp "$(__git_refs)"
306 esac
309 __git_complete_revlist ()
311 local pfx cur="${COMP_WORDS[COMP_CWORD]}"
312 case "$cur" in
313 *...*)
314 pfx="${cur%...*}..."
315 cur="${cur#*...}"
316 __gitcomp "$(__git_refs)" "$pfx" "$cur"
318 *..*)
319 pfx="${cur%..*}.."
320 cur="${cur#*..}"
321 __gitcomp "$(__git_refs)" "$pfx" "$cur"
324 __gitcomp "$cur."
327 __gitcomp "$(__git_refs)"
329 esac
332 __git_commands ()
334 if [ -n "$__git_commandlist" ]; then
335 echo "$__git_commandlist"
336 return
338 local i IFS=" "$'\n'
339 for i in $(git help -a|egrep '^ ')
341 case $i in
342 *--*) : helper pattern;;
343 applymbox) : ask gittus;;
344 applypatch) : ask gittus;;
345 archimport) : import;;
346 cat-file) : plumbing;;
347 check-attr) : plumbing;;
348 check-ref-format) : plumbing;;
349 commit-tree) : plumbing;;
350 cvsexportcommit) : export;;
351 cvsimport) : import;;
352 cvsserver) : daemon;;
353 daemon) : daemon;;
354 diff-files) : plumbing;;
355 diff-index) : plumbing;;
356 diff-tree) : plumbing;;
357 fast-import) : import;;
358 fsck-objects) : plumbing;;
359 fetch-pack) : plumbing;;
360 fmt-merge-msg) : plumbing;;
361 for-each-ref) : plumbing;;
362 hash-object) : plumbing;;
363 http-*) : transport;;
364 index-pack) : plumbing;;
365 init-db) : deprecated;;
366 local-fetch) : plumbing;;
367 mailinfo) : plumbing;;
368 mailsplit) : plumbing;;
369 merge-*) : plumbing;;
370 mktree) : plumbing;;
371 mktag) : plumbing;;
372 pack-objects) : plumbing;;
373 pack-redundant) : plumbing;;
374 pack-refs) : plumbing;;
375 parse-remote) : plumbing;;
376 patch-id) : plumbing;;
377 peek-remote) : plumbing;;
378 prune) : plumbing;;
379 prune-packed) : plumbing;;
380 quiltimport) : import;;
381 read-tree) : plumbing;;
382 receive-pack) : plumbing;;
383 reflog) : plumbing;;
384 repo-config) : deprecated;;
385 rerere) : plumbing;;
386 rev-list) : plumbing;;
387 rev-parse) : plumbing;;
388 runstatus) : plumbing;;
389 sh-setup) : internal;;
390 shell) : daemon;;
391 send-pack) : plumbing;;
392 show-index) : plumbing;;
393 ssh-*) : transport;;
394 stripspace) : plumbing;;
395 symbolic-ref) : plumbing;;
396 tar-tree) : deprecated;;
397 unpack-file) : plumbing;;
398 unpack-objects) : plumbing;;
399 update-index) : plumbing;;
400 update-ref) : plumbing;;
401 update-server-info) : daemon;;
402 upload-archive) : plumbing;;
403 upload-pack) : plumbing;;
404 write-tree) : plumbing;;
405 verify-tag) : plumbing;;
406 *) echo $i;;
407 esac
408 done
410 __git_commandlist=
411 __git_commandlist="$(__git_commands 2>/dev/null)"
413 __git_aliases ()
415 local i IFS=$'\n'
416 for i in $(git --git-dir="$(__gitdir)" config --list); do
417 case "$i" in
418 alias.*)
419 i="${i#alias.}"
420 echo "${i/=*/}"
422 esac
423 done
426 __git_aliased_command ()
428 local word cmdline=$(git --git-dir="$(__gitdir)" \
429 config --get "alias.$1")
430 for word in $cmdline; do
431 if [ "${word##-*}" ]; then
432 echo $word
433 return
435 done
438 __git_find_subcommand ()
440 local word subcommand c=1
442 while [ $c -lt $COMP_CWORD ]; do
443 word="${COMP_WORDS[c]}"
444 for subcommand in $1; do
445 if [ "$subcommand" = "$word" ]; then
446 echo "$subcommand"
447 return
449 done
450 c=$((++c))
451 done
454 __git_whitespacelist="nowarn warn error error-all strip"
456 _git_am ()
458 local cur="${COMP_WORDS[COMP_CWORD]}"
459 if [ -d .dotest ]; then
460 __gitcomp "--skip --resolved"
461 return
463 case "$cur" in
464 --whitespace=*)
465 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
466 return
468 --*)
469 __gitcomp "
470 --signoff --utf8 --binary --3way --interactive
471 --whitespace=
473 return
474 esac
475 COMPREPLY=()
478 _git_apply ()
480 local cur="${COMP_WORDS[COMP_CWORD]}"
481 case "$cur" in
482 --whitespace=*)
483 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
484 return
486 --*)
487 __gitcomp "
488 --stat --numstat --summary --check --index
489 --cached --index-info --reverse --reject --unidiff-zero
490 --apply --no-add --exclude=
491 --whitespace= --inaccurate-eof --verbose
493 return
494 esac
495 COMPREPLY=()
498 _git_add ()
500 local cur="${COMP_WORDS[COMP_CWORD]}"
501 case "$cur" in
502 --*)
503 __gitcomp "--interactive --refresh"
504 return
505 esac
506 COMPREPLY=()
509 _git_bisect ()
511 local subcommands="start bad good reset visualize replay log"
512 local subcommand="$(__git_find_subcommand "$subcommands")"
513 if [ -z "$subcommand" ]; then
514 __gitcomp "$subcommands"
515 return
518 case "$subcommand" in
519 bad|good|reset)
520 __gitcomp "$(__git_refs)"
523 COMPREPLY=()
525 esac
528 _git_branch ()
530 local i c=1 only_local_ref="n" has_r="n"
532 while [ $c -lt $COMP_CWORD ]; do
533 i="${COMP_WORDS[c]}"
534 case "$i" in
535 -d|-m) only_local_ref="y" ;;
536 -r) has_r="y" ;;
537 esac
538 c=$((++c))
539 done
541 case "${COMP_WORDS[COMP_CWORD]}" in
542 --*=*) COMPREPLY=() ;;
543 --*)
544 __gitcomp "
545 --color --no-color --verbose --abbrev= --no-abbrev
546 --track --no-track
550 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
551 __gitcomp "$(__git_heads)"
552 else
553 __gitcomp "$(__git_refs)"
556 esac
559 _git_bundle ()
561 local mycword="$COMP_CWORD"
562 case "${COMP_WORDS[0]}" in
563 git)
564 local cmd="${COMP_WORDS[2]}"
565 mycword="$((mycword-1))"
567 git-bundle*)
568 local cmd="${COMP_WORDS[1]}"
570 esac
571 case "$mycword" in
573 __gitcomp "create list-heads verify unbundle"
576 # looking for a file
579 case "$cmd" in
580 create)
581 __git_complete_revlist
583 esac
585 esac
588 _git_checkout ()
590 __gitcomp "$(__git_refs)"
593 _git_cherry ()
595 __gitcomp "$(__git_refs)"
598 _git_cherry_pick ()
600 local cur="${COMP_WORDS[COMP_CWORD]}"
601 case "$cur" in
602 --*)
603 __gitcomp "--edit --no-commit"
606 __gitcomp "$(__git_refs)"
608 esac
611 _git_commit ()
613 local cur="${COMP_WORDS[COMP_CWORD]}"
614 case "$cur" in
615 --*)
616 __gitcomp "
617 --all --author= --signoff --verify --no-verify
618 --edit --amend --include --only
620 return
621 esac
622 COMPREPLY=()
625 _git_describe ()
627 __gitcomp "$(__git_refs)"
630 _git_diff ()
632 local cur="${COMP_WORDS[COMP_CWORD]}"
633 case "$cur" in
634 --*)
635 __gitcomp "--cached --stat --numstat --shortstat --summary
636 --patch-with-stat --name-only --name-status --color
637 --no-color --color-words --no-renames --check
638 --full-index --binary --abbrev --diff-filter
639 --find-copies-harder --pickaxe-all --pickaxe-regex
640 --text --ignore-space-at-eol --ignore-space-change
641 --ignore-all-space --exit-code --quiet --ext-diff
642 --no-ext-diff"
643 return
645 esac
646 __git_complete_file
649 _git_diff_tree ()
651 __gitcomp "$(__git_refs)"
654 _git_fetch ()
656 local cur="${COMP_WORDS[COMP_CWORD]}"
658 case "${COMP_WORDS[0]},$COMP_CWORD" in
659 git-fetch*,1)
660 __gitcomp "$(__git_remotes)"
662 git,2)
663 __gitcomp "$(__git_remotes)"
666 case "$cur" in
667 *:*)
668 __gitcomp "$(__git_refs)" "" "${cur#*:}"
671 local remote
672 case "${COMP_WORDS[0]}" in
673 git-fetch) remote="${COMP_WORDS[1]}" ;;
674 git) remote="${COMP_WORDS[2]}" ;;
675 esac
676 __gitcomp "$(__git_refs2 "$remote")"
678 esac
680 esac
683 _git_format_patch ()
685 local cur="${COMP_WORDS[COMP_CWORD]}"
686 case "$cur" in
687 --*)
688 __gitcomp "
689 --stdout --attach --thread
690 --output-directory
691 --numbered --start-number
692 --numbered-files
693 --keep-subject
694 --signoff
695 --in-reply-to=
696 --full-index --binary
697 --not --all
698 --cover-letter
700 return
702 esac
703 __git_complete_revlist
706 _git_gc ()
708 local cur="${COMP_WORDS[COMP_CWORD]}"
709 case "$cur" in
710 --*)
711 __gitcomp "--prune --aggressive"
712 return
714 esac
715 COMPREPLY=()
718 _git_ls_remote ()
720 __gitcomp "$(__git_remotes)"
723 _git_ls_tree ()
725 __git_complete_file
728 _git_log ()
730 local cur="${COMP_WORDS[COMP_CWORD]}"
731 case "$cur" in
732 --pretty=*)
733 __gitcomp "
734 oneline short medium full fuller email raw
735 " "" "${cur##--pretty=}"
736 return
738 --date=*)
739 __gitcomp "
740 relative iso8601 rfc2822 short local default
741 " "" "${cur##--date=}"
742 return
744 --*)
745 __gitcomp "
746 --max-count= --max-age= --since= --after=
747 --min-age= --before= --until=
748 --root --topo-order --date-order --reverse
749 --no-merges --follow
750 --abbrev-commit --abbrev=
751 --relative-date --date=
752 --author= --committer= --grep=
753 --all-match
754 --pretty= --name-status --name-only --raw
755 --not --all
756 --left-right --cherry-pick
758 return
760 esac
761 __git_complete_revlist
764 _git_merge ()
766 local cur="${COMP_WORDS[COMP_CWORD]}"
767 case "${COMP_WORDS[COMP_CWORD-1]}" in
768 -s|--strategy)
769 __gitcomp "$(__git_merge_strategies)"
770 return
771 esac
772 case "$cur" in
773 --strategy=*)
774 __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}"
775 return
777 --*)
778 __gitcomp "
779 --no-commit --no-summary --squash --strategy
781 return
782 esac
783 __gitcomp "$(__git_refs)"
786 _git_merge_base ()
788 __gitcomp "$(__git_refs)"
791 _git_name_rev ()
793 __gitcomp "--tags --all --stdin"
796 _git_pull ()
798 local cur="${COMP_WORDS[COMP_CWORD]}"
800 case "${COMP_WORDS[0]},$COMP_CWORD" in
801 git-pull*,1)
802 __gitcomp "$(__git_remotes)"
804 git,2)
805 __gitcomp "$(__git_remotes)"
808 local remote
809 case "${COMP_WORDS[0]}" in
810 git-pull) remote="${COMP_WORDS[1]}" ;;
811 git) remote="${COMP_WORDS[2]}" ;;
812 esac
813 __gitcomp "$(__git_refs "$remote")"
815 esac
818 _git_push ()
820 local cur="${COMP_WORDS[COMP_CWORD]}"
822 case "${COMP_WORDS[0]},$COMP_CWORD" in
823 git-push*,1)
824 __gitcomp "$(__git_remotes)"
826 git,2)
827 __gitcomp "$(__git_remotes)"
830 case "$cur" in
831 *:*)
832 local remote
833 case "${COMP_WORDS[0]}" in
834 git-push) remote="${COMP_WORDS[1]}" ;;
835 git) remote="${COMP_WORDS[2]}" ;;
836 esac
837 __gitcomp "$(__git_refs "$remote")" "" "${cur#*:}"
840 __gitcomp "$(__git_refs)" + "${cur#+}"
843 __gitcomp "$(__git_refs)"
845 esac
847 esac
850 _git_rebase ()
852 local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)"
853 if [ -d .dotest ] || [ -d "$dir"/.dotest-merge ]; then
854 __gitcomp "--continue --skip --abort"
855 return
857 case "${COMP_WORDS[COMP_CWORD-1]}" in
858 -s|--strategy)
859 __gitcomp "$(__git_merge_strategies)"
860 return
861 esac
862 case "$cur" in
863 --strategy=*)
864 __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}"
865 return
867 --*)
868 __gitcomp "--onto --merge --strategy --interactive"
869 return
870 esac
871 __gitcomp "$(__git_refs)"
874 _git_config ()
876 local cur="${COMP_WORDS[COMP_CWORD]}"
877 local prv="${COMP_WORDS[COMP_CWORD-1]}"
878 case "$prv" in
879 branch.*.remote)
880 __gitcomp "$(__git_remotes)"
881 return
883 branch.*.merge)
884 __gitcomp "$(__git_refs)"
885 return
887 remote.*.fetch)
888 local remote="${prv#remote.}"
889 remote="${remote%.fetch}"
890 __gitcomp "$(__git_refs_remotes "$remote")"
891 return
893 remote.*.push)
894 local remote="${prv#remote.}"
895 remote="${remote%.push}"
896 __gitcomp "$(git --git-dir="$(__gitdir)" \
897 for-each-ref --format='%(refname):%(refname)' \
898 refs/heads)"
899 return
901 pull.twohead|pull.octopus)
902 __gitcomp "$(__git_merge_strategies)"
903 return
905 color.branch|color.diff|color.status)
906 __gitcomp "always never auto"
907 return
909 color.*.*)
910 __gitcomp "
911 black red green yellow blue magenta cyan white
912 bold dim ul blink reverse
914 return
916 *.*)
917 COMPREPLY=()
918 return
920 esac
921 case "$cur" in
922 --*)
923 __gitcomp "
924 --global --system --file=
925 --list --replace-all
926 --get --get-all --get-regexp
927 --add --unset --unset-all
928 --remove-section --rename-section
930 return
932 branch.*.*)
933 local pfx="${cur%.*}."
934 cur="${cur##*.}"
935 __gitcomp "remote merge" "$pfx" "$cur"
936 return
938 branch.*)
939 local pfx="${cur%.*}."
940 cur="${cur#*.}"
941 __gitcomp "$(__git_heads)" "$pfx" "$cur" "."
942 return
944 remote.*.*)
945 local pfx="${cur%.*}."
946 cur="${cur##*.}"
947 __gitcomp "
948 url fetch push skipDefaultUpdate
949 receivepack uploadpack tagopt
950 " "$pfx" "$cur"
951 return
953 remote.*)
954 local pfx="${cur%.*}."
955 cur="${cur#*.}"
956 __gitcomp "$(__git_remotes)" "$pfx" "$cur" "."
957 return
959 esac
960 __gitcomp "
961 apply.whitespace
962 core.fileMode
963 core.gitProxy
964 core.ignoreStat
965 core.preferSymlinkRefs
966 core.logAllRefUpdates
967 core.loosecompression
968 core.repositoryFormatVersion
969 core.sharedRepository
970 core.warnAmbiguousRefs
971 core.compression
972 core.packedGitWindowSize
973 core.packedGitLimit
974 clean.requireForce
975 color.branch
976 color.branch.current
977 color.branch.local
978 color.branch.remote
979 color.branch.plain
980 color.diff
981 color.diff.plain
982 color.diff.meta
983 color.diff.frag
984 color.diff.old
985 color.diff.new
986 color.diff.commit
987 color.diff.whitespace
988 color.pager
989 color.status
990 color.status.header
991 color.status.added
992 color.status.changed
993 color.status.untracked
994 diff.renameLimit
995 diff.renames
996 fetch.unpackLimit
997 format.headers
998 format.subjectprefix
999 gitcvs.enabled
1000 gitcvs.logfile
1001 gitcvs.allbinary
1002 gitcvs.dbname gitcvs.dbdriver gitcvs.dbuser gitcvs.dbpass
1003 gitcvs.dbtablenameprefix
1004 gc.packrefs
1005 gc.reflogexpire
1006 gc.reflogexpireunreachable
1007 gc.rerereresolved
1008 gc.rerereunresolved
1009 http.sslVerify
1010 http.sslCert
1011 http.sslKey
1012 http.sslCAInfo
1013 http.sslCAPath
1014 http.maxRequests
1015 http.lowSpeedLimit
1016 http.lowSpeedTime
1017 http.noEPSV
1018 i18n.commitEncoding
1019 i18n.logOutputEncoding
1020 log.showroot
1021 merge.tool
1022 merge.summary
1023 merge.verbosity
1024 pack.window
1025 pack.depth
1026 pack.windowMemory
1027 pack.compression
1028 pack.deltaCacheSize
1029 pack.deltaCacheLimit
1030 pull.octopus
1031 pull.twohead
1032 repack.useDeltaBaseOffset
1033 show.difftree
1034 showbranch.default
1035 tar.umask
1036 transfer.unpackLimit
1037 receive.unpackLimit
1038 receive.denyNonFastForwards
1039 user.name
1040 user.email
1041 user.signingkey
1042 whatchanged.difftree
1043 branch. remote.
1047 _git_remote ()
1049 local subcommands="add rm show prune update"
1050 local subcommand="$(__git_find_subcommand "$subcommands")"
1051 if [ -z "$subcommand" ]; then
1052 return
1055 case "$subcommand" in
1056 rm|show|prune)
1057 __gitcomp "$(__git_remotes)"
1059 update)
1060 local i c='' IFS=$'\n'
1061 for i in $(git --git-dir="$(__gitdir)" config --list); do
1062 case "$i" in
1063 remotes.*)
1064 i="${i#remotes.}"
1065 c="$c ${i/=*/}"
1067 esac
1068 done
1069 __gitcomp "$c"
1072 COMPREPLY=()
1074 esac
1077 _git_reset ()
1079 local cur="${COMP_WORDS[COMP_CWORD]}"
1080 case "$cur" in
1081 --*)
1082 __gitcomp "--mixed --hard --soft"
1083 return
1085 esac
1086 __gitcomp "$(__git_refs)"
1089 _git_shortlog ()
1091 local cur="${COMP_WORDS[COMP_CWORD]}"
1092 case "$cur" in
1093 --*)
1094 __gitcomp "
1095 --max-count= --max-age= --since= --after=
1096 --min-age= --before= --until=
1097 --no-merges
1098 --author= --committer= --grep=
1099 --all-match
1100 --not --all
1101 --numbered --summary
1103 return
1105 esac
1106 __git_complete_revlist
1109 _git_show ()
1111 local cur="${COMP_WORDS[COMP_CWORD]}"
1112 case "$cur" in
1113 --pretty=*)
1114 __gitcomp "
1115 oneline short medium full fuller email raw
1116 " "" "${cur##--pretty=}"
1117 return
1119 --*)
1120 __gitcomp "--pretty="
1121 return
1123 esac
1124 __git_complete_file
1127 _git_stash ()
1129 local subcommands='save list show apply clear drop pop create'
1130 if [ -z "$(__git_find_subcommand "$subcommands")" ]; then
1131 __gitcomp "$subcommands"
1135 _git_submodule ()
1137 local subcommands="add status init update"
1138 if [ -z "$(__git_find_subcommand "$subcommands")" ]; then
1139 local cur="${COMP_WORDS[COMP_CWORD]}"
1140 case "$cur" in
1141 --*)
1142 __gitcomp "--quiet --cached"
1145 __gitcomp "$subcommands"
1147 esac
1148 return
1152 _git_svn ()
1154 local subcommands="
1155 init fetch clone rebase dcommit log find-rev
1156 set-tree commit-diff info create-ignore propget
1157 proplist show-ignore show-externals
1159 local subcommand="$(__git_find_subcommand "$subcommands")"
1160 if [ -z "$subcommand" ]; then
1161 __gitcomp "$subcommands"
1162 else
1163 local remote_opts="--username= --config-dir= --no-auth-cache"
1164 local fc_opts="
1165 --follow-parent --authors-file= --repack=
1166 --no-metadata --use-svm-props --use-svnsync-props
1167 --log-window-size= --no-checkout --quiet
1168 --repack-flags --user-log-author $remote_opts
1170 local init_opts="
1171 --template= --shared= --trunk= --tags=
1172 --branches= --stdlayout --minimize-url
1173 --no-metadata --use-svm-props --use-svnsync-props
1174 --rewrite-root= $remote_opts
1176 local cmt_opts="
1177 --edit --rmdir --find-copies-harder --copy-similarity=
1180 local cur="${COMP_WORDS[COMP_CWORD]}"
1181 case "$subcommand,$cur" in
1182 fetch,--*)
1183 __gitcomp "--revision= --fetch-all $fc_opts"
1185 clone,--*)
1186 __gitcomp "--revision= $fc_opts $init_opts"
1188 init,--*)
1189 __gitcomp "$init_opts"
1191 dcommit,--*)
1192 __gitcomp "
1193 --merge --strategy= --verbose --dry-run
1194 --fetch-all --no-rebase $cmt_opts $fc_opts
1197 set-tree,--*)
1198 __gitcomp "--stdin $cmt_opts $fc_opts"
1200 create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\
1201 show-externals,--*)
1202 __gitcomp "--revision="
1204 log,--*)
1205 __gitcomp "
1206 --limit= --revision= --verbose --incremental
1207 --oneline --show-commit --non-recursive
1208 --authors-file=
1211 rebase,--*)
1212 __gitcomp "
1213 --merge --verbose --strategy= --local
1214 --fetch-all $fc_opts
1217 commit-diff,--*)
1218 __gitcomp "--message= --file= --revision= $cmt_opts"
1220 info,--*)
1221 __gitcomp "--url"
1224 COMPREPLY=()
1226 esac
1230 _git_tag ()
1232 local i c=1 f=0
1233 while [ $c -lt $COMP_CWORD ]; do
1234 i="${COMP_WORDS[c]}"
1235 case "$i" in
1236 -d|-v)
1237 __gitcomp "$(__git_tags)"
1238 return
1243 esac
1244 c=$((++c))
1245 done
1247 case "${COMP_WORDS[COMP_CWORD-1]}" in
1248 -m|-F)
1249 COMPREPLY=()
1251 -*|tag|git-tag)
1252 if [ $f = 1 ]; then
1253 __gitcomp "$(__git_tags)"
1254 else
1255 COMPREPLY=()
1259 __gitcomp "$(__git_refs)"
1261 esac
1264 _git ()
1266 local i c=1 command __git_dir
1268 while [ $c -lt $COMP_CWORD ]; do
1269 i="${COMP_WORDS[c]}"
1270 case "$i" in
1271 --git-dir=*) __git_dir="${i#--git-dir=}" ;;
1272 --bare) __git_dir="." ;;
1273 --version|--help|-p|--paginate) ;;
1274 *) command="$i"; break ;;
1275 esac
1276 c=$((++c))
1277 done
1279 if [ -z "$command" ]; then
1280 case "${COMP_WORDS[COMP_CWORD]}" in
1281 --*=*) COMPREPLY=() ;;
1282 --*) __gitcomp "
1283 --paginate
1284 --no-pager
1285 --git-dir=
1286 --bare
1287 --version
1288 --exec-path
1289 --work-tree=
1290 --help
1293 *) __gitcomp "$(__git_commands) $(__git_aliases)" ;;
1294 esac
1295 return
1298 local expansion=$(__git_aliased_command "$command")
1299 [ "$expansion" ] && command="$expansion"
1301 case "$command" in
1302 am) _git_am ;;
1303 add) _git_add ;;
1304 apply) _git_apply ;;
1305 bisect) _git_bisect ;;
1306 bundle) _git_bundle ;;
1307 branch) _git_branch ;;
1308 checkout) _git_checkout ;;
1309 cherry) _git_cherry ;;
1310 cherry-pick) _git_cherry_pick ;;
1311 commit) _git_commit ;;
1312 config) _git_config ;;
1313 describe) _git_describe ;;
1314 diff) _git_diff ;;
1315 fetch) _git_fetch ;;
1316 format-patch) _git_format_patch ;;
1317 gc) _git_gc ;;
1318 log) _git_log ;;
1319 ls-remote) _git_ls_remote ;;
1320 ls-tree) _git_ls_tree ;;
1321 merge) _git_merge;;
1322 merge-base) _git_merge_base ;;
1323 name-rev) _git_name_rev ;;
1324 pull) _git_pull ;;
1325 push) _git_push ;;
1326 rebase) _git_rebase ;;
1327 remote) _git_remote ;;
1328 reset) _git_reset ;;
1329 shortlog) _git_shortlog ;;
1330 show) _git_show ;;
1331 show-branch) _git_log ;;
1332 stash) _git_stash ;;
1333 submodule) _git_submodule ;;
1334 svn) _git_svn ;;
1335 tag) _git_tag ;;
1336 whatchanged) _git_log ;;
1337 *) COMPREPLY=() ;;
1338 esac
1341 _gitk ()
1343 local cur="${COMP_WORDS[COMP_CWORD]}"
1344 case "$cur" in
1345 --*)
1346 __gitcomp "--not --all"
1347 return
1349 esac
1350 __git_complete_revlist
1353 complete -o default -o nospace -F _git git
1354 complete -o default -o nospace -F _gitk gitk
1355 complete -o default -o nospace -F _git_am git-am
1356 complete -o default -o nospace -F _git_apply git-apply
1357 complete -o default -o nospace -F _git_bisect git-bisect
1358 complete -o default -o nospace -F _git_branch git-branch
1359 complete -o default -o nospace -F _git_bundle git-bundle
1360 complete -o default -o nospace -F _git_checkout git-checkout
1361 complete -o default -o nospace -F _git_cherry git-cherry
1362 complete -o default -o nospace -F _git_cherry_pick git-cherry-pick
1363 complete -o default -o nospace -F _git_commit git-commit
1364 complete -o default -o nospace -F _git_describe git-describe
1365 complete -o default -o nospace -F _git_diff git-diff
1366 complete -o default -o nospace -F _git_fetch git-fetch
1367 complete -o default -o nospace -F _git_format_patch git-format-patch
1368 complete -o default -o nospace -F _git_gc git-gc
1369 complete -o default -o nospace -F _git_log git-log
1370 complete -o default -o nospace -F _git_ls_remote git-ls-remote
1371 complete -o default -o nospace -F _git_ls_tree git-ls-tree
1372 complete -o default -o nospace -F _git_merge git-merge
1373 complete -o default -o nospace -F _git_merge_base git-merge-base
1374 complete -o default -o nospace -F _git_name_rev git-name-rev
1375 complete -o default -o nospace -F _git_pull git-pull
1376 complete -o default -o nospace -F _git_push git-push
1377 complete -o default -o nospace -F _git_rebase git-rebase
1378 complete -o default -o nospace -F _git_config git-config
1379 complete -o default -o nospace -F _git_remote git-remote
1380 complete -o default -o nospace -F _git_reset git-reset
1381 complete -o default -o nospace -F _git_shortlog git-shortlog
1382 complete -o default -o nospace -F _git_show git-show
1383 complete -o default -o nospace -F _git_stash git-stash
1384 complete -o default -o nospace -F _git_submodule git-submodule
1385 complete -o default -o nospace -F _git_svn git-svn
1386 complete -o default -o nospace -F _git_log git-show-branch
1387 complete -o default -o nospace -F _git_tag git-tag
1388 complete -o default -o nospace -F _git_log git-whatchanged
1390 # The following are necessary only for Cygwin, and only are needed
1391 # when the user has tab-completed the executable name and consequently
1392 # included the '.exe' suffix.
1394 if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
1395 complete -o default -o nospace -F _git_add git-add.exe
1396 complete -o default -o nospace -F _git_apply git-apply.exe
1397 complete -o default -o nospace -F _git git.exe
1398 complete -o default -o nospace -F _git_branch git-branch.exe
1399 complete -o default -o nospace -F _git_bundle git-bundle.exe
1400 complete -o default -o nospace -F _git_cherry git-cherry.exe
1401 complete -o default -o nospace -F _git_describe git-describe.exe
1402 complete -o default -o nospace -F _git_diff git-diff.exe
1403 complete -o default -o nospace -F _git_format_patch git-format-patch.exe
1404 complete -o default -o nospace -F _git_log git-log.exe
1405 complete -o default -o nospace -F _git_ls_tree git-ls-tree.exe
1406 complete -o default -o nospace -F _git_merge_base git-merge-base.exe
1407 complete -o default -o nospace -F _git_name_rev git-name-rev.exe
1408 complete -o default -o nospace -F _git_push git-push.exe
1409 complete -o default -o nospace -F _git_config git-config
1410 complete -o default -o nospace -F _git_shortlog git-shortlog.exe
1411 complete -o default -o nospace -F _git_show git-show.exe
1412 complete -o default -o nospace -F _git_log git-show-branch.exe
1413 complete -o default -o nospace -F _git_tag git-tag.exe
1414 complete -o default -o nospace -F _git_log git-whatchanged.exe