Merge branch 'maint'
[git/dscho.git] / contrib / completion / git-completion.bash
blobf8d4cb2c7d6afd2d4f35572148de06ad3e542647
1 #!bash
3 # bash completion support for core Git.
5 # Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
6 # Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
7 # Distributed under the GNU General Public License, version 2.0.
9 # The contained completion routines provide support for completing:
11 # *) local and remote branch names
12 # *) local and remote tag names
13 # *) .git/remotes file names
14 # *) git 'subcommands'
15 # *) tree paths within 'ref:path/to/file' expressions
16 # *) common --long-options
18 # To use these routines:
20 # 1) Copy this file to somewhere (e.g. ~/.git-completion.sh).
21 # 2) Added the following line to your .bashrc:
22 # source ~/.git-completion.sh
24 # 3) You may want to make sure the git executable is available
25 # in your PATH before this script is sourced, as some caching
26 # is performed while the script loads. If git isn't found
27 # at source time then all lookups will be done on demand,
28 # which may be slightly slower.
30 # 4) Consider changing your PS1 to also show the current branch:
31 # PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
33 # The argument to __git_ps1 will be displayed only if you
34 # are currently in a git repository. The %s token will be
35 # the name of the current branch.
37 # In addition, if you set GIT_PS1_SHOWDIRTYSTATE to a nonempty
38 # value, unstaged (*) and staged (+) changes will be shown next
39 # to the branch name. You can configure this per-repository
40 # with the bash.showDirtyState variable, which defaults to true
41 # once GIT_PS1_SHOWDIRTYSTATE is enabled.
43 # To submit patches:
45 # *) Read Documentation/SubmittingPatches
46 # *) Send all patches to the current maintainer:
48 # "Shawn O. Pearce" <spearce@spearce.org>
50 # *) Always CC the Git mailing list:
52 # git@vger.kernel.org
55 case "$COMP_WORDBREAKS" in
56 *:*) : great ;;
57 *) COMP_WORDBREAKS="$COMP_WORDBREAKS:"
58 esac
60 # __gitdir accepts 0 or 1 arguments (i.e., location)
61 # returns location of .git repo
62 __gitdir ()
64 if [ -z "${1-}" ]; then
65 if [ -n "${__git_dir-}" ]; then
66 echo "$__git_dir"
67 elif [ -d .git ]; then
68 echo .git
69 else
70 git rev-parse --git-dir 2>/dev/null
72 elif [ -d "$1/.git" ]; then
73 echo "$1/.git"
74 else
75 echo "$1"
79 # __git_ps1 accepts 0 or 1 arguments (i.e., format string)
80 # returns text to add to bash PS1 prompt (includes branch name)
81 __git_ps1 ()
83 local g="$(__gitdir)"
84 if [ -n "$g" ]; then
85 local r
86 local b
87 if [ -d "$g/rebase-apply" ]; then
88 if [ -f "$g/rebase-apply/rebasing" ]; then
89 r="|REBASE"
90 elif [ -f "$g/rebase-apply/applying" ]; then
91 r="|AM"
92 else
93 r="|AM/REBASE"
95 b="$(git symbolic-ref HEAD 2>/dev/null)"
96 elif [ -f "$g/rebase-merge/interactive" ]; then
97 r="|REBASE-i"
98 b="$(cat "$g/rebase-merge/head-name")"
99 elif [ -d "$g/rebase-merge" ]; then
100 r="|REBASE-m"
101 b="$(cat "$g/rebase-merge/head-name")"
102 else
103 if [ -f "$g/MERGE_HEAD" ]; then
104 r="|MERGING"
106 if [ -f "$g/BISECT_LOG" ]; then
107 r="|BISECTING"
110 b="$(git symbolic-ref HEAD 2>/dev/null)" || {
112 b="$(
113 case "${GIT_PS1_DESCRIBE_STYLE-}" in
114 (contains)
115 git describe --contains HEAD ;;
116 (branch)
117 git describe --contains --all HEAD ;;
118 (describe)
119 git describe HEAD ;;
120 (* | default)
121 git describe --exact-match HEAD ;;
122 esac 2>/dev/null)" ||
124 b="$(cut -c1-7 "$g/HEAD" 2>/dev/null)..." ||
125 b="unknown"
126 b="($b)"
130 local w
131 local i
132 local c
134 if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then
135 if [ "true" = "$(git config --bool core.bare 2>/dev/null)" ]; then
136 c="BARE:"
137 else
138 b="GIT_DIR!"
140 elif [ "true" = "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
141 if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ]; then
142 if [ "$(git config --bool bash.showDirtyState)" != "false" ]; then
143 git diff --no-ext-diff --ignore-submodules \
144 --quiet --exit-code || w="*"
145 if git rev-parse --quiet --verify HEAD >/dev/null; then
146 git diff-index --cached --quiet \
147 --ignore-submodules HEAD -- || i="+"
148 else
149 i="#"
155 if [ -n "$b" ]; then
156 if [ -n "${1-}" ]; then
157 printf "$1" "$c${b##refs/heads/}$w$i$r"
158 else
159 printf " (%s)" "$c${b##refs/heads/}$w$i$r"
165 # __gitcomp_1 requires 2 arguments
166 __gitcomp_1 ()
168 local c IFS=' '$'\t'$'\n'
169 for c in $1; do
170 case "$c$2" in
171 --*=*) printf %s$'\n' "$c$2" ;;
172 *.) printf %s$'\n' "$c$2" ;;
173 *) printf %s$'\n' "$c$2 " ;;
174 esac
175 done
178 # __gitcomp accepts 1, 2, 3, or 4 arguments
179 # generates completion reply with compgen
180 __gitcomp ()
182 local cur="${COMP_WORDS[COMP_CWORD]}"
183 if [ $# -gt 2 ]; then
184 cur="$3"
186 case "$cur" in
187 --*=)
188 COMPREPLY=()
191 local IFS=$'\n'
192 COMPREPLY=($(compgen -P "${2-}" \
193 -W "$(__gitcomp_1 "${1-}" "${4-}")" \
194 -- "$cur"))
196 esac
199 # __git_heads accepts 0 or 1 arguments (to pass to __gitdir)
200 __git_heads ()
202 local cmd i is_hash=y dir="$(__gitdir "${1-}")"
203 if [ -d "$dir" ]; then
204 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
205 refs/heads
206 return
208 for i in $(git ls-remote "${1-}" 2>/dev/null); do
209 case "$is_hash,$i" in
210 y,*) is_hash=n ;;
211 n,*^{}) is_hash=y ;;
212 n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
213 n,*) is_hash=y; echo "$i" ;;
214 esac
215 done
218 # __git_tags accepts 0 or 1 arguments (to pass to __gitdir)
219 __git_tags ()
221 local cmd i is_hash=y dir="$(__gitdir "${1-}")"
222 if [ -d "$dir" ]; then
223 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
224 refs/tags
225 return
227 for i in $(git ls-remote "${1-}" 2>/dev/null); do
228 case "$is_hash,$i" in
229 y,*) is_hash=n ;;
230 n,*^{}) is_hash=y ;;
231 n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
232 n,*) is_hash=y; echo "$i" ;;
233 esac
234 done
237 # __git_refs accepts 0 or 1 arguments (to pass to __gitdir)
238 __git_refs ()
240 local i is_hash=y dir="$(__gitdir "${1-}")"
241 local cur="${COMP_WORDS[COMP_CWORD]}" format refs
242 if [ -d "$dir" ]; then
243 case "$cur" in
244 refs|refs/*)
245 format="refname"
246 refs="${cur%/*}"
249 if [ -e "$dir/HEAD" ]; then echo HEAD; fi
250 format="refname:short"
251 refs="refs/tags refs/heads refs/remotes"
253 esac
254 git --git-dir="$dir" for-each-ref --format="%($format)" \
255 $refs
256 return
258 for i in $(git ls-remote "$dir" 2>/dev/null); do
259 case "$is_hash,$i" in
260 y,*) is_hash=n ;;
261 n,*^{}) is_hash=y ;;
262 n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
263 n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
264 n,refs/remotes/*) is_hash=y; echo "${i#refs/remotes/}" ;;
265 n,*) is_hash=y; echo "$i" ;;
266 esac
267 done
270 # __git_refs2 requires 1 argument (to pass to __git_refs)
271 __git_refs2 ()
273 local i
274 for i in $(__git_refs "$1"); do
275 echo "$i:$i"
276 done
279 # __git_refs_remotes requires 1 argument (to pass to ls-remote)
280 __git_refs_remotes ()
282 local cmd i is_hash=y
283 for i in $(git ls-remote "$1" 2>/dev/null); do
284 case "$is_hash,$i" in
285 n,refs/heads/*)
286 is_hash=y
287 echo "$i:refs/remotes/$1/${i#refs/heads/}"
289 y,*) is_hash=n ;;
290 n,*^{}) is_hash=y ;;
291 n,refs/tags/*) is_hash=y;;
292 n,*) is_hash=y; ;;
293 esac
294 done
297 __git_remotes ()
299 local i ngoff IFS=$'\n' d="$(__gitdir)"
300 shopt -q nullglob || ngoff=1
301 shopt -s nullglob
302 for i in "$d/remotes"/*; do
303 echo ${i#$d/remotes/}
304 done
305 [ "$ngoff" ] && shopt -u nullglob
306 for i in $(git --git-dir="$d" config --list); do
307 case "$i" in
308 remote.*.url=*)
309 i="${i#remote.}"
310 echo "${i/.url=*/}"
312 esac
313 done
316 __git_merge_strategies ()
318 if [ -n "${__git_merge_strategylist-}" ]; then
319 echo "$__git_merge_strategylist"
320 return
322 git merge -s help 2>&1 |
323 sed -n -e '/[Aa]vailable strategies are: /,/^$/{
324 s/\.$//
325 s/.*://
326 s/^[ ]*//
327 s/[ ]*$//
331 __git_merge_strategylist=
332 __git_merge_strategylist=$(__git_merge_strategies 2>/dev/null)
334 __git_complete_file ()
336 local pfx ls ref cur="${COMP_WORDS[COMP_CWORD]}"
337 case "$cur" in
338 ?*:*)
339 ref="${cur%%:*}"
340 cur="${cur#*:}"
341 case "$cur" in
342 ?*/*)
343 pfx="${cur%/*}"
344 cur="${cur##*/}"
345 ls="$ref:$pfx"
346 pfx="$pfx/"
349 ls="$ref"
351 esac
353 case "$COMP_WORDBREAKS" in
354 *:*) : great ;;
355 *) pfx="$ref:$pfx" ;;
356 esac
358 local IFS=$'\n'
359 COMPREPLY=($(compgen -P "$pfx" \
360 -W "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \
361 | sed '/^100... blob /{
362 s,^.* ,,
363 s,$, ,
365 /^120000 blob /{
366 s,^.* ,,
367 s,$, ,
369 /^040000 tree /{
370 s,^.* ,,
371 s,$,/,
373 s/^.* //')" \
374 -- "$cur"))
377 __gitcomp "$(__git_refs)"
379 esac
382 __git_complete_revlist ()
384 local pfx cur="${COMP_WORDS[COMP_CWORD]}"
385 case "$cur" in
386 *...*)
387 pfx="${cur%...*}..."
388 cur="${cur#*...}"
389 __gitcomp "$(__git_refs)" "$pfx" "$cur"
391 *..*)
392 pfx="${cur%..*}.."
393 cur="${cur#*..}"
394 __gitcomp "$(__git_refs)" "$pfx" "$cur"
397 __gitcomp "$(__git_refs)"
399 esac
402 __git_complete_remote_or_refspec ()
404 local cmd="${COMP_WORDS[1]}"
405 local cur="${COMP_WORDS[COMP_CWORD]}"
406 local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0
407 while [ $c -lt $COMP_CWORD ]; do
408 i="${COMP_WORDS[c]}"
409 case "$i" in
410 --all|--mirror) [ "$cmd" = "push" ] && no_complete_refspec=1 ;;
411 -*) ;;
412 *) remote="$i"; break ;;
413 esac
414 c=$((++c))
415 done
416 if [ -z "$remote" ]; then
417 __gitcomp "$(__git_remotes)"
418 return
420 if [ $no_complete_refspec = 1 ]; then
421 COMPREPLY=()
422 return
424 [ "$remote" = "." ] && remote=
425 case "$cur" in
426 *:*)
427 case "$COMP_WORDBREAKS" in
428 *:*) : great ;;
429 *) pfx="${cur%%:*}:" ;;
430 esac
431 cur="${cur#*:}"
432 lhs=0
435 pfx="+"
436 cur="${cur#+}"
438 esac
439 case "$cmd" in
440 fetch)
441 if [ $lhs = 1 ]; then
442 __gitcomp "$(__git_refs2 "$remote")" "$pfx" "$cur"
443 else
444 __gitcomp "$(__git_refs)" "$pfx" "$cur"
447 pull)
448 if [ $lhs = 1 ]; then
449 __gitcomp "$(__git_refs "$remote")" "$pfx" "$cur"
450 else
451 __gitcomp "$(__git_refs)" "$pfx" "$cur"
454 push)
455 if [ $lhs = 1 ]; then
456 __gitcomp "$(__git_refs)" "$pfx" "$cur"
457 else
458 __gitcomp "$(__git_refs "$remote")" "$pfx" "$cur"
461 esac
464 __git_complete_strategy ()
466 case "${COMP_WORDS[COMP_CWORD-1]}" in
467 -s|--strategy)
468 __gitcomp "$(__git_merge_strategies)"
469 return 0
470 esac
471 local cur="${COMP_WORDS[COMP_CWORD]}"
472 case "$cur" in
473 --strategy=*)
474 __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}"
475 return 0
477 esac
478 return 1
481 __git_all_commands ()
483 if [ -n "${__git_all_commandlist-}" ]; then
484 echo "$__git_all_commandlist"
485 return
487 local i IFS=" "$'\n'
488 for i in $(git help -a|egrep '^ ')
490 case $i in
491 *--*) : helper pattern;;
492 *) echo $i;;
493 esac
494 done
496 __git_all_commandlist=
497 __git_all_commandlist="$(__git_all_commands 2>/dev/null)"
499 __git_porcelain_commands ()
501 if [ -n "${__git_porcelain_commandlist-}" ]; then
502 echo "$__git_porcelain_commandlist"
503 return
505 local i IFS=" "$'\n'
506 for i in "help" $(__git_all_commands)
508 case $i in
509 *--*) : helper pattern;;
510 applymbox) : ask gittus;;
511 applypatch) : ask gittus;;
512 archimport) : import;;
513 cat-file) : plumbing;;
514 check-attr) : plumbing;;
515 check-ref-format) : plumbing;;
516 checkout-index) : plumbing;;
517 commit-tree) : plumbing;;
518 count-objects) : infrequent;;
519 cvsexportcommit) : export;;
520 cvsimport) : import;;
521 cvsserver) : daemon;;
522 daemon) : daemon;;
523 diff-files) : plumbing;;
524 diff-index) : plumbing;;
525 diff-tree) : plumbing;;
526 fast-import) : import;;
527 fast-export) : export;;
528 fsck-objects) : plumbing;;
529 fetch-pack) : plumbing;;
530 fmt-merge-msg) : plumbing;;
531 for-each-ref) : plumbing;;
532 hash-object) : plumbing;;
533 http-*) : transport;;
534 index-pack) : plumbing;;
535 init-db) : deprecated;;
536 local-fetch) : plumbing;;
537 lost-found) : infrequent;;
538 ls-files) : plumbing;;
539 ls-remote) : plumbing;;
540 ls-tree) : plumbing;;
541 mailinfo) : plumbing;;
542 mailsplit) : plumbing;;
543 merge-*) : plumbing;;
544 mktree) : plumbing;;
545 mktag) : plumbing;;
546 pack-objects) : plumbing;;
547 pack-redundant) : plumbing;;
548 pack-refs) : plumbing;;
549 parse-remote) : plumbing;;
550 patch-id) : plumbing;;
551 peek-remote) : plumbing;;
552 prune) : plumbing;;
553 prune-packed) : plumbing;;
554 quiltimport) : import;;
555 read-tree) : plumbing;;
556 receive-pack) : plumbing;;
557 reflog) : plumbing;;
558 repo-config) : deprecated;;
559 rerere) : plumbing;;
560 rev-list) : plumbing;;
561 rev-parse) : plumbing;;
562 runstatus) : plumbing;;
563 sh-setup) : internal;;
564 shell) : daemon;;
565 show-ref) : plumbing;;
566 send-pack) : plumbing;;
567 show-index) : plumbing;;
568 ssh-*) : transport;;
569 stripspace) : plumbing;;
570 symbolic-ref) : plumbing;;
571 tar-tree) : deprecated;;
572 unpack-file) : plumbing;;
573 unpack-objects) : plumbing;;
574 update-index) : plumbing;;
575 update-ref) : plumbing;;
576 update-server-info) : daemon;;
577 upload-archive) : plumbing;;
578 upload-pack) : plumbing;;
579 write-tree) : plumbing;;
580 var) : infrequent;;
581 verify-pack) : infrequent;;
582 verify-tag) : plumbing;;
583 *) echo $i;;
584 esac
585 done
587 __git_porcelain_commandlist=
588 __git_porcelain_commandlist="$(__git_porcelain_commands 2>/dev/null)"
590 __git_aliases ()
592 local i IFS=$'\n'
593 for i in $(git --git-dir="$(__gitdir)" config --list); do
594 case "$i" in
595 alias.*)
596 i="${i#alias.}"
597 echo "${i/=*/}"
599 esac
600 done
603 # __git_aliased_command requires 1 argument
604 __git_aliased_command ()
606 local word cmdline=$(git --git-dir="$(__gitdir)" \
607 config --get "alias.$1")
608 for word in $cmdline; do
609 if [ "${word##-*}" ]; then
610 echo $word
611 return
613 done
616 # __git_find_subcommand requires 1 argument
617 __git_find_subcommand ()
619 local word subcommand c=1
621 while [ $c -lt $COMP_CWORD ]; do
622 word="${COMP_WORDS[c]}"
623 for subcommand in $1; do
624 if [ "$subcommand" = "$word" ]; then
625 echo "$subcommand"
626 return
628 done
629 c=$((++c))
630 done
633 __git_has_doubledash ()
635 local c=1
636 while [ $c -lt $COMP_CWORD ]; do
637 if [ "--" = "${COMP_WORDS[c]}" ]; then
638 return 0
640 c=$((++c))
641 done
642 return 1
645 __git_whitespacelist="nowarn warn error error-all fix"
647 _git_am ()
649 local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)"
650 if [ -d "$dir"/rebase-apply ]; then
651 __gitcomp "--skip --resolved --abort"
652 return
654 case "$cur" in
655 --whitespace=*)
656 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
657 return
659 --*)
660 __gitcomp "
661 --3way --committer-date-is-author-date --ignore-date
662 --interactive --keep --no-utf8 --signoff --utf8
663 --whitespace=
665 return
666 esac
667 COMPREPLY=()
670 _git_apply ()
672 local cur="${COMP_WORDS[COMP_CWORD]}"
673 case "$cur" in
674 --whitespace=*)
675 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
676 return
678 --*)
679 __gitcomp "
680 --stat --numstat --summary --check --index
681 --cached --index-info --reverse --reject --unidiff-zero
682 --apply --no-add --exclude=
683 --whitespace= --inaccurate-eof --verbose
685 return
686 esac
687 COMPREPLY=()
690 _git_add ()
692 __git_has_doubledash && return
694 local cur="${COMP_WORDS[COMP_CWORD]}"
695 case "$cur" in
696 --*)
697 __gitcomp "
698 --interactive --refresh --patch --update --dry-run
699 --ignore-errors --intent-to-add
701 return
702 esac
703 COMPREPLY=()
706 _git_archive ()
708 local cur="${COMP_WORDS[COMP_CWORD]}"
709 case "$cur" in
710 --format=*)
711 __gitcomp "$(git archive --list)" "" "${cur##--format=}"
712 return
714 --remote=*)
715 __gitcomp "$(__git_remotes)" "" "${cur##--remote=}"
716 return
718 --*)
719 __gitcomp "
720 --format= --list --verbose
721 --prefix= --remote= --exec=
723 return
725 esac
726 __git_complete_file
729 _git_bisect ()
731 __git_has_doubledash && return
733 local subcommands="start bad good skip reset visualize replay log run"
734 local subcommand="$(__git_find_subcommand "$subcommands")"
735 if [ -z "$subcommand" ]; then
736 __gitcomp "$subcommands"
737 return
740 case "$subcommand" in
741 bad|good|reset|skip)
742 __gitcomp "$(__git_refs)"
745 COMPREPLY=()
747 esac
750 _git_branch ()
752 local i c=1 only_local_ref="n" has_r="n"
754 while [ $c -lt $COMP_CWORD ]; do
755 i="${COMP_WORDS[c]}"
756 case "$i" in
757 -d|-m) only_local_ref="y" ;;
758 -r) has_r="y" ;;
759 esac
760 c=$((++c))
761 done
763 case "${COMP_WORDS[COMP_CWORD]}" in
764 --*)
765 __gitcomp "
766 --color --no-color --verbose --abbrev= --no-abbrev
767 --track --no-track --contains --merged --no-merged
771 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
772 __gitcomp "$(__git_heads)"
773 else
774 __gitcomp "$(__git_refs)"
777 esac
780 _git_bundle ()
782 local cmd="${COMP_WORDS[2]}"
783 case "$COMP_CWORD" in
785 __gitcomp "create list-heads verify unbundle"
788 # looking for a file
791 case "$cmd" in
792 create)
793 __git_complete_revlist
795 esac
797 esac
800 _git_checkout ()
802 __git_has_doubledash && return
804 __gitcomp "$(__git_refs)"
807 _git_cherry ()
809 __gitcomp "$(__git_refs)"
812 _git_cherry_pick ()
814 local cur="${COMP_WORDS[COMP_CWORD]}"
815 case "$cur" in
816 --*)
817 __gitcomp "--edit --no-commit"
820 __gitcomp "$(__git_refs)"
822 esac
825 _git_clean ()
827 __git_has_doubledash && return
829 local cur="${COMP_WORDS[COMP_CWORD]}"
830 case "$cur" in
831 --*)
832 __gitcomp "--dry-run --quiet"
833 return
835 esac
836 COMPREPLY=()
839 _git_clone ()
841 local cur="${COMP_WORDS[COMP_CWORD]}"
842 case "$cur" in
843 --*)
844 __gitcomp "
845 --local
846 --no-hardlinks
847 --shared
848 --reference
849 --quiet
850 --no-checkout
851 --bare
852 --mirror
853 --origin
854 --upload-pack
855 --template=
856 --depth
858 return
860 esac
861 COMPREPLY=()
864 _git_commit ()
866 __git_has_doubledash && return
868 local cur="${COMP_WORDS[COMP_CWORD]}"
869 case "$cur" in
870 --*)
871 __gitcomp "
872 --all --author= --signoff --verify --no-verify
873 --edit --amend --include --only --interactive
875 return
876 esac
877 COMPREPLY=()
880 _git_describe ()
882 local cur="${COMP_WORDS[COMP_CWORD]}"
883 case "$cur" in
884 --*)
885 __gitcomp "
886 --all --tags --contains --abbrev= --candidates=
887 --exact-match --debug --long --match --always
889 return
890 esac
891 __gitcomp "$(__git_refs)"
894 __git_diff_common_options="--stat --numstat --shortstat --summary
895 --patch-with-stat --name-only --name-status --color
896 --no-color --color-words --no-renames --check
897 --full-index --binary --abbrev --diff-filter=
898 --find-copies-harder
899 --text --ignore-space-at-eol --ignore-space-change
900 --ignore-all-space --exit-code --quiet --ext-diff
901 --no-ext-diff
902 --no-prefix --src-prefix= --dst-prefix=
903 --inter-hunk-context=
904 --patience
905 --raw
908 _git_diff ()
910 __git_has_doubledash && return
912 local cur="${COMP_WORDS[COMP_CWORD]}"
913 case "$cur" in
914 --*)
915 __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
916 --base --ours --theirs
917 $__git_diff_common_options
919 return
921 esac
922 __git_complete_file
925 __git_mergetools_common="diffuse ecmerge emerge kdiff3 meld opendiff
926 tkdiff vimdiff gvimdiff xxdiff
929 _git_difftool ()
931 local cur="${COMP_WORDS[COMP_CWORD]}"
932 case "$cur" in
933 --tool=*)
934 __gitcomp "$__git_mergetools_common kompare" "" "${cur##--tool=}"
935 return
937 --*)
938 __gitcomp "--tool="
939 return
941 esac
942 COMPREPLY=()
945 __git_fetch_options="
946 --quiet --verbose --append --upload-pack --force --keep --depth=
947 --tags --no-tags
950 _git_fetch ()
952 local cur="${COMP_WORDS[COMP_CWORD]}"
953 case "$cur" in
954 --*)
955 __gitcomp "$__git_fetch_options"
956 return
958 esac
959 __git_complete_remote_or_refspec
962 _git_format_patch ()
964 local cur="${COMP_WORDS[COMP_CWORD]}"
965 case "$cur" in
966 --thread=*)
967 __gitcomp "
968 deep shallow
969 " "" "${cur##--thread=}"
970 return
972 --*)
973 __gitcomp "
974 --stdout --attach --no-attach --thread --thread=
975 --output-directory
976 --numbered --start-number
977 --numbered-files
978 --keep-subject
979 --signoff
980 --in-reply-to= --cc=
981 --full-index --binary
982 --not --all
983 --cover-letter
984 --no-prefix --src-prefix= --dst-prefix=
985 --inline --suffix= --ignore-if-in-upstream
986 --subject-prefix=
988 return
990 esac
991 __git_complete_revlist
994 _git_fsck ()
996 local cur="${COMP_WORDS[COMP_CWORD]}"
997 case "$cur" in
998 --*)
999 __gitcomp "
1000 --tags --root --unreachable --cache --no-reflogs --full
1001 --strict --verbose --lost-found
1003 return
1005 esac
1006 COMPREPLY=()
1009 _git_gc ()
1011 local cur="${COMP_WORDS[COMP_CWORD]}"
1012 case "$cur" in
1013 --*)
1014 __gitcomp "--prune --aggressive"
1015 return
1017 esac
1018 COMPREPLY=()
1021 _git_grep ()
1023 __git_has_doubledash && return
1025 local cur="${COMP_WORDS[COMP_CWORD]}"
1026 case "$cur" in
1027 --*)
1028 __gitcomp "
1029 --cached
1030 --text --ignore-case --word-regexp --invert-match
1031 --full-name
1032 --extended-regexp --basic-regexp --fixed-strings
1033 --files-with-matches --name-only
1034 --files-without-match
1035 --count
1036 --and --or --not --all-match
1038 return
1040 esac
1041 COMPREPLY=()
1044 _git_help ()
1046 local cur="${COMP_WORDS[COMP_CWORD]}"
1047 case "$cur" in
1048 --*)
1049 __gitcomp "--all --info --man --web"
1050 return
1052 esac
1053 __gitcomp "$(__git_all_commands)
1054 attributes cli core-tutorial cvs-migration
1055 diffcore gitk glossary hooks ignore modules
1056 repository-layout tutorial tutorial-2
1057 workflows
1061 _git_init ()
1063 local cur="${COMP_WORDS[COMP_CWORD]}"
1064 case "$cur" in
1065 --shared=*)
1066 __gitcomp "
1067 false true umask group all world everybody
1068 " "" "${cur##--shared=}"
1069 return
1071 --*)
1072 __gitcomp "--quiet --bare --template= --shared --shared="
1073 return
1075 esac
1076 COMPREPLY=()
1079 _git_ls_files ()
1081 __git_has_doubledash && return
1083 local cur="${COMP_WORDS[COMP_CWORD]}"
1084 case "$cur" in
1085 --*)
1086 __gitcomp "--cached --deleted --modified --others --ignored
1087 --stage --directory --no-empty-directory --unmerged
1088 --killed --exclude= --exclude-from=
1089 --exclude-per-directory= --exclude-standard
1090 --error-unmatch --with-tree= --full-name
1091 --abbrev --ignored --exclude-per-directory
1093 return
1095 esac
1096 COMPREPLY=()
1099 _git_ls_remote ()
1101 __gitcomp "$(__git_remotes)"
1104 _git_ls_tree ()
1106 __git_complete_file
1109 # Options that go well for log, shortlog and gitk
1110 __git_log_common_options="
1111 --not --all
1112 --branches --tags --remotes
1113 --first-parent --no-merges
1114 --max-count=
1115 --max-age= --since= --after=
1116 --min-age= --until= --before=
1118 # Options that go well for log and gitk (not shortlog)
1119 __git_log_gitk_options="
1120 --dense --sparse --full-history
1121 --simplify-merges --simplify-by-decoration
1122 --left-right
1124 # Options that go well for log and shortlog (not gitk)
1125 __git_log_shortlog_options="
1126 --author= --committer= --grep=
1127 --all-match
1130 __git_log_pretty_formats="oneline short medium full fuller email raw format:"
1131 __git_log_date_formats="relative iso8601 rfc2822 short local default raw"
1133 _git_log ()
1135 __git_has_doubledash && return
1137 local cur="${COMP_WORDS[COMP_CWORD]}"
1138 local g="$(git rev-parse --git-dir 2>/dev/null)"
1139 local merge=""
1140 if [ -f "$g/MERGE_HEAD" ]; then
1141 merge="--merge"
1143 case "$cur" in
1144 --pretty=*)
1145 __gitcomp "$__git_log_pretty_formats
1146 " "" "${cur##--pretty=}"
1147 return
1149 --format=*)
1150 __gitcomp "$__git_log_pretty_formats
1151 " "" "${cur##--format=}"
1152 return
1154 --date=*)
1155 __gitcomp "$__git_log_date_formats" "" "${cur##--date=}"
1156 return
1158 --*)
1159 __gitcomp "
1160 $__git_log_common_options
1161 $__git_log_shortlog_options
1162 $__git_log_gitk_options
1163 --root --topo-order --date-order --reverse
1164 --follow
1165 --abbrev-commit --abbrev=
1166 --relative-date --date=
1167 --pretty= --format= --oneline
1168 --cherry-pick
1169 --graph
1170 --decorate
1171 --walk-reflogs
1172 --parents --children
1173 $merge
1174 $__git_diff_common_options
1175 --pickaxe-all --pickaxe-regex
1177 return
1179 esac
1180 __git_complete_revlist
1183 __git_merge_options="
1184 --no-commit --no-stat --log --no-log --squash --strategy
1185 --commit --stat --no-squash --ff --no-ff
1188 _git_merge ()
1190 __git_complete_strategy && return
1192 local cur="${COMP_WORDS[COMP_CWORD]}"
1193 case "$cur" in
1194 --*)
1195 __gitcomp "$__git_merge_options"
1196 return
1197 esac
1198 __gitcomp "$(__git_refs)"
1201 _git_mergetool ()
1203 local cur="${COMP_WORDS[COMP_CWORD]}"
1204 case "$cur" in
1205 --tool=*)
1206 __gitcomp "$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"
1207 return
1209 --*)
1210 __gitcomp "--tool="
1211 return
1213 esac
1214 COMPREPLY=()
1217 _git_merge_base ()
1219 __gitcomp "$(__git_refs)"
1222 _git_mv ()
1224 local cur="${COMP_WORDS[COMP_CWORD]}"
1225 case "$cur" in
1226 --*)
1227 __gitcomp "--dry-run"
1228 return
1230 esac
1231 COMPREPLY=()
1234 _git_name_rev ()
1236 __gitcomp "--tags --all --stdin"
1239 _git_pull ()
1241 __git_complete_strategy && return
1243 local cur="${COMP_WORDS[COMP_CWORD]}"
1244 case "$cur" in
1245 --*)
1246 __gitcomp "
1247 --rebase --no-rebase
1248 $__git_merge_options
1249 $__git_fetch_options
1251 return
1253 esac
1254 __git_complete_remote_or_refspec
1257 _git_push ()
1259 local cur="${COMP_WORDS[COMP_CWORD]}"
1260 case "${COMP_WORDS[COMP_CWORD-1]}" in
1261 --repo)
1262 __gitcomp "$(__git_remotes)"
1263 return
1264 esac
1265 case "$cur" in
1266 --repo=*)
1267 __gitcomp "$(__git_remotes)" "" "${cur##--repo=}"
1268 return
1270 --*)
1271 __gitcomp "
1272 --all --mirror --tags --dry-run --force --verbose
1273 --receive-pack= --repo=
1275 return
1277 esac
1278 __git_complete_remote_or_refspec
1281 _git_rebase ()
1283 local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)"
1284 if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
1285 __gitcomp "--continue --skip --abort"
1286 return
1288 __git_complete_strategy && return
1289 case "$cur" in
1290 --*)
1291 __gitcomp "--onto --merge --strategy --interactive"
1292 return
1293 esac
1294 __gitcomp "$(__git_refs)"
1297 __git_send_email_confirm_options="always never auto cc compose"
1298 __git_send_email_suppresscc_options="author self cc ccbody sob cccmd body all"
1300 _git_send_email ()
1302 local cur="${COMP_WORDS[COMP_CWORD]}"
1303 case "$cur" in
1304 --confirm=*)
1305 __gitcomp "
1306 $__git_send_email_confirm_options
1307 " "" "${cur##--confirm=}"
1308 return
1310 --suppress-cc=*)
1311 __gitcomp "
1312 $__git_send_email_suppresscc_options
1313 " "" "${cur##--suppress-cc=}"
1315 return
1317 --smtp-encryption=*)
1318 __gitcomp "ssl tls" "" "${cur##--smtp-encryption=}"
1319 return
1321 --*)
1322 __gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to
1323 --compose --confirm= --dry-run --envelope-sender
1324 --from --identity
1325 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
1326 --no-suppress-from --no-thread --quiet
1327 --signed-off-by-cc --smtp-pass --smtp-server
1328 --smtp-server-port --smtp-encryption= --smtp-user
1329 --subject --suppress-cc= --suppress-from --thread --to
1330 --validate --no-validate"
1331 return
1333 esac
1334 COMPREPLY=()
1337 __git_config_get_set_variables ()
1339 local prevword word config_file= c=$COMP_CWORD
1340 while [ $c -gt 1 ]; do
1341 word="${COMP_WORDS[c]}"
1342 case "$word" in
1343 --global|--system|--file=*)
1344 config_file="$word"
1345 break
1347 -f|--file)
1348 config_file="$word $prevword"
1349 break
1351 esac
1352 prevword=$word
1353 c=$((--c))
1354 done
1356 for i in $(git --git-dir="$(__gitdir)" config $config_file --list \
1357 2>/dev/null); do
1358 case "$i" in
1359 *.*)
1360 echo "${i/=*/}"
1362 esac
1363 done
1366 _git_config ()
1368 local cur="${COMP_WORDS[COMP_CWORD]}"
1369 local prv="${COMP_WORDS[COMP_CWORD-1]}"
1370 case "$prv" in
1371 branch.*.remote)
1372 __gitcomp "$(__git_remotes)"
1373 return
1375 branch.*.merge)
1376 __gitcomp "$(__git_refs)"
1377 return
1379 remote.*.fetch)
1380 local remote="${prv#remote.}"
1381 remote="${remote%.fetch}"
1382 __gitcomp "$(__git_refs_remotes "$remote")"
1383 return
1385 remote.*.push)
1386 local remote="${prv#remote.}"
1387 remote="${remote%.push}"
1388 __gitcomp "$(git --git-dir="$(__gitdir)" \
1389 for-each-ref --format='%(refname):%(refname)' \
1390 refs/heads)"
1391 return
1393 pull.twohead|pull.octopus)
1394 __gitcomp "$(__git_merge_strategies)"
1395 return
1397 color.branch|color.diff|color.interactive|color.status|color.ui)
1398 __gitcomp "always never auto"
1399 return
1401 color.pager)
1402 __gitcomp "false true"
1403 return
1405 color.*.*)
1406 __gitcomp "
1407 normal black red green yellow blue magenta cyan white
1408 bold dim ul blink reverse
1410 return
1412 help.format)
1413 __gitcomp "man info web html"
1414 return
1416 log.date)
1417 __gitcomp "$__git_log_date_formats"
1418 return
1420 sendemail.aliasesfiletype)
1421 __gitcomp "mutt mailrc pine elm gnus"
1422 return
1424 sendemail.confirm)
1425 __gitcomp "$__git_send_email_confirm_options"
1426 return
1428 sendemail.suppresscc)
1429 __gitcomp "$__git_send_email_suppresscc_options"
1430 return
1432 --get|--get-all|--unset|--unset-all)
1433 __gitcomp "$(__git_config_get_set_variables)"
1434 return
1436 *.*)
1437 COMPREPLY=()
1438 return
1440 esac
1441 case "$cur" in
1442 --*)
1443 __gitcomp "
1444 --global --system --file=
1445 --list --replace-all
1446 --get --get-all --get-regexp
1447 --add --unset --unset-all
1448 --remove-section --rename-section
1450 return
1452 branch.*.*)
1453 local pfx="${cur%.*}."
1454 cur="${cur##*.}"
1455 __gitcomp "remote merge mergeoptions" "$pfx" "$cur"
1456 return
1458 branch.*)
1459 local pfx="${cur%.*}."
1460 cur="${cur#*.}"
1461 __gitcomp "$(__git_heads)" "$pfx" "$cur" "."
1462 return
1464 guitool.*.*)
1465 local pfx="${cur%.*}."
1466 cur="${cur##*.}"
1467 __gitcomp "
1468 argprompt cmd confirm needsfile noconsole norescan
1469 prompt revprompt revunmerged title
1470 " "$pfx" "$cur"
1471 return
1473 difftool.*.*)
1474 local pfx="${cur%.*}."
1475 cur="${cur##*.}"
1476 __gitcomp "cmd path" "$pfx" "$cur"
1477 return
1479 man.*.*)
1480 local pfx="${cur%.*}."
1481 cur="${cur##*.}"
1482 __gitcomp "cmd path" "$pfx" "$cur"
1483 return
1485 mergetool.*.*)
1486 local pfx="${cur%.*}."
1487 cur="${cur##*.}"
1488 __gitcomp "cmd path trustExitCode" "$pfx" "$cur"
1489 return
1491 pager.*)
1492 local pfx="${cur%.*}."
1493 cur="${cur#*.}"
1494 __gitcomp "$(__git_all_commands)" "$pfx" "$cur"
1495 return
1497 remote.*.*)
1498 local pfx="${cur%.*}."
1499 cur="${cur##*.}"
1500 __gitcomp "
1501 url proxy fetch push mirror skipDefaultUpdate
1502 receivepack uploadpack tagopt
1503 " "$pfx" "$cur"
1504 return
1506 remote.*)
1507 local pfx="${cur%.*}."
1508 cur="${cur#*.}"
1509 __gitcomp "$(__git_remotes)" "$pfx" "$cur" "."
1510 return
1512 url.*.*)
1513 local pfx="${cur%.*}."
1514 cur="${cur##*.}"
1515 __gitcomp "insteadof" "$pfx" "$cur"
1516 return
1518 esac
1519 __gitcomp "
1520 alias.
1521 apply.whitespace
1522 branch.autosetupmerge
1523 branch.autosetuprebase
1524 clean.requireForce
1525 color.branch
1526 color.branch.current
1527 color.branch.local
1528 color.branch.plain
1529 color.branch.remote
1530 color.diff
1531 color.diff.commit
1532 color.diff.frag
1533 color.diff.meta
1534 color.diff.new
1535 color.diff.old
1536 color.diff.plain
1537 color.diff.whitespace
1538 color.grep
1539 color.grep.external
1540 color.grep.match
1541 color.interactive
1542 color.interactive.header
1543 color.interactive.help
1544 color.interactive.prompt
1545 color.pager
1546 color.status
1547 color.status.added
1548 color.status.changed
1549 color.status.header
1550 color.status.nobranch
1551 color.status.untracked
1552 color.status.updated
1553 color.ui
1554 commit.template
1555 core.autocrlf
1556 core.bare
1557 core.compression
1558 core.createObject
1559 core.deltaBaseCacheLimit
1560 core.editor
1561 core.excludesfile
1562 core.fileMode
1563 core.fsyncobjectfiles
1564 core.gitProxy
1565 core.ignoreCygwinFSTricks
1566 core.ignoreStat
1567 core.logAllRefUpdates
1568 core.loosecompression
1569 core.packedGitLimit
1570 core.packedGitWindowSize
1571 core.pager
1572 core.preferSymlinkRefs
1573 core.preloadindex
1574 core.quotepath
1575 core.repositoryFormatVersion
1576 core.safecrlf
1577 core.sharedRepository
1578 core.symlinks
1579 core.trustctime
1580 core.warnAmbiguousRefs
1581 core.whitespace
1582 core.worktree
1583 diff.autorefreshindex
1584 diff.external
1585 diff.mnemonicprefix
1586 diff.renameLimit
1587 diff.renameLimit.
1588 diff.renames
1589 diff.suppressBlankEmpty
1590 diff.tool
1591 diff.wordRegex
1592 difftool.
1593 difftool.prompt
1594 fetch.unpackLimit
1595 format.attach
1596 format.cc
1597 format.headers
1598 format.numbered
1599 format.pretty
1600 format.signoff
1601 format.subjectprefix
1602 format.suffix
1603 format.thread
1604 gc.aggressiveWindow
1605 gc.auto
1606 gc.autopacklimit
1607 gc.packrefs
1608 gc.pruneexpire
1609 gc.reflogexpire
1610 gc.reflogexpireunreachable
1611 gc.rerereresolved
1612 gc.rerereunresolved
1613 gitcvs.allbinary
1614 gitcvs.commitmsgannotation
1615 gitcvs.dbTableNamePrefix
1616 gitcvs.dbdriver
1617 gitcvs.dbname
1618 gitcvs.dbpass
1619 gitcvs.dbuser
1620 gitcvs.enabled
1621 gitcvs.logfile
1622 gitcvs.usecrlfattr
1623 guitool.
1624 gui.blamehistoryctx
1625 gui.commitmsgwidth
1626 gui.copyblamethreshold
1627 gui.diffcontext
1628 gui.encoding
1629 gui.fastcopyblame
1630 gui.matchtrackingbranch
1631 gui.newbranchtemplate
1632 gui.pruneduringfetch
1633 gui.spellingdictionary
1634 gui.trustmtime
1635 help.autocorrect
1636 help.browser
1637 help.format
1638 http.lowSpeedLimit
1639 http.lowSpeedTime
1640 http.maxRequests
1641 http.noEPSV
1642 http.proxy
1643 http.sslCAInfo
1644 http.sslCAPath
1645 http.sslCert
1646 http.sslKey
1647 http.sslVerify
1648 i18n.commitEncoding
1649 i18n.logOutputEncoding
1650 imap.folder
1651 imap.host
1652 imap.pass
1653 imap.port
1654 imap.preformattedHTML
1655 imap.sslverify
1656 imap.tunnel
1657 imap.user
1658 instaweb.browser
1659 instaweb.httpd
1660 instaweb.local
1661 instaweb.modulepath
1662 instaweb.port
1663 interactive.singlekey
1664 log.date
1665 log.showroot
1666 mailmap.file
1667 man.
1668 man.viewer
1669 merge.conflictstyle
1670 merge.log
1671 merge.renameLimit
1672 merge.stat
1673 merge.tool
1674 merge.verbosity
1675 mergetool.
1676 mergetool.keepBackup
1677 mergetool.prompt
1678 pack.compression
1679 pack.deltaCacheLimit
1680 pack.deltaCacheSize
1681 pack.depth
1682 pack.indexVersion
1683 pack.packSizeLimit
1684 pack.threads
1685 pack.window
1686 pack.windowMemory
1687 pager.
1688 pull.octopus
1689 pull.twohead
1690 push.default
1691 rebase.stat
1692 receive.denyCurrentBranch
1693 receive.denyDeletes
1694 receive.denyNonFastForwards
1695 receive.fsckObjects
1696 receive.unpackLimit
1697 repack.usedeltabaseoffset
1698 rerere.autoupdate
1699 rerere.enabled
1700 sendemail.aliasesfile
1701 sendemail.aliasesfiletype
1702 sendemail.bcc
1703 sendemail.cc
1704 sendemail.cccmd
1705 sendemail.chainreplyto
1706 sendemail.confirm
1707 sendemail.envelopesender
1708 sendemail.multiedit
1709 sendemail.signedoffbycc
1710 sendemail.smtpencryption
1711 sendemail.smtppass
1712 sendemail.smtpserver
1713 sendemail.smtpserverport
1714 sendemail.smtpuser
1715 sendemail.suppresscc
1716 sendemail.suppressfrom
1717 sendemail.thread
1718 sendemail.to
1719 sendemail.validate
1720 showbranch.default
1721 status.relativePaths
1722 status.showUntrackedFiles
1723 tar.umask
1724 transfer.unpackLimit
1725 url.
1726 user.email
1727 user.name
1728 user.signingkey
1729 web.browser
1730 branch. remote.
1734 _git_remote ()
1736 local subcommands="add rename rm show prune update set-head"
1737 local subcommand="$(__git_find_subcommand "$subcommands")"
1738 if [ -z "$subcommand" ]; then
1739 __gitcomp "$subcommands"
1740 return
1743 case "$subcommand" in
1744 rename|rm|show|prune)
1745 __gitcomp "$(__git_remotes)"
1747 update)
1748 local i c='' IFS=$'\n'
1749 for i in $(git --git-dir="$(__gitdir)" config --list); do
1750 case "$i" in
1751 remotes.*)
1752 i="${i#remotes.}"
1753 c="$c ${i/=*/}"
1755 esac
1756 done
1757 __gitcomp "$c"
1760 COMPREPLY=()
1762 esac
1765 _git_reset ()
1767 __git_has_doubledash && return
1769 local cur="${COMP_WORDS[COMP_CWORD]}"
1770 case "$cur" in
1771 --*)
1772 __gitcomp "--merge --mixed --hard --soft"
1773 return
1775 esac
1776 __gitcomp "$(__git_refs)"
1779 _git_revert ()
1781 local cur="${COMP_WORDS[COMP_CWORD]}"
1782 case "$cur" in
1783 --*)
1784 __gitcomp "--edit --mainline --no-edit --no-commit --signoff"
1785 return
1787 esac
1788 __gitcomp "$(__git_refs)"
1791 _git_rm ()
1793 __git_has_doubledash && return
1795 local cur="${COMP_WORDS[COMP_CWORD]}"
1796 case "$cur" in
1797 --*)
1798 __gitcomp "--cached --dry-run --ignore-unmatch --quiet"
1799 return
1801 esac
1802 COMPREPLY=()
1805 _git_shortlog ()
1807 __git_has_doubledash && return
1809 local cur="${COMP_WORDS[COMP_CWORD]}"
1810 case "$cur" in
1811 --*)
1812 __gitcomp "
1813 $__git_log_common_options
1814 $__git_log_shortlog_options
1815 --numbered --summary
1817 return
1819 esac
1820 __git_complete_revlist
1823 _git_show ()
1825 __git_has_doubledash && return
1827 local cur="${COMP_WORDS[COMP_CWORD]}"
1828 case "$cur" in
1829 --pretty=*)
1830 __gitcomp "$__git_log_pretty_formats
1831 " "" "${cur##--pretty=}"
1832 return
1834 --format=*)
1835 __gitcomp "$__git_log_pretty_formats
1836 " "" "${cur##--format=}"
1837 return
1839 --*)
1840 __gitcomp "--pretty= --format= --abbrev-commit --oneline
1841 $__git_diff_common_options
1843 return
1845 esac
1846 __git_complete_file
1849 _git_show_branch ()
1851 local cur="${COMP_WORDS[COMP_CWORD]}"
1852 case "$cur" in
1853 --*)
1854 __gitcomp "
1855 --all --remotes --topo-order --current --more=
1856 --list --independent --merge-base --no-name
1857 --sha1-name --sparse --topics --reflog
1859 return
1861 esac
1862 __git_complete_revlist
1865 _git_stash ()
1867 local subcommands='save list show apply clear drop pop create branch'
1868 local subcommand="$(__git_find_subcommand "$subcommands")"
1869 if [ -z "$subcommand" ]; then
1870 __gitcomp "$subcommands"
1871 else
1872 local cur="${COMP_WORDS[COMP_CWORD]}"
1873 case "$subcommand,$cur" in
1874 save,--*)
1875 __gitcomp "--keep-index"
1877 apply,--*)
1878 __gitcomp "--index"
1880 show,--*|drop,--*|pop,--*|branch,--*)
1881 COMPREPLY=()
1883 show,*|apply,*|drop,*|pop,*|branch,*)
1884 __gitcomp "$(git --git-dir="$(__gitdir)" stash list \
1885 | sed -n -e 's/:.*//p')"
1888 COMPREPLY=()
1890 esac
1894 _git_submodule ()
1896 __git_has_doubledash && return
1898 local subcommands="add status init update summary foreach sync"
1899 if [ -z "$(__git_find_subcommand "$subcommands")" ]; then
1900 local cur="${COMP_WORDS[COMP_CWORD]}"
1901 case "$cur" in
1902 --*)
1903 __gitcomp "--quiet --cached"
1906 __gitcomp "$subcommands"
1908 esac
1909 return
1913 _git_svn ()
1915 local subcommands="
1916 init fetch clone rebase dcommit log find-rev
1917 set-tree commit-diff info create-ignore propget
1918 proplist show-ignore show-externals branch tag blame
1919 migrate
1921 local subcommand="$(__git_find_subcommand "$subcommands")"
1922 if [ -z "$subcommand" ]; then
1923 __gitcomp "$subcommands"
1924 else
1925 local remote_opts="--username= --config-dir= --no-auth-cache"
1926 local fc_opts="
1927 --follow-parent --authors-file= --repack=
1928 --no-metadata --use-svm-props --use-svnsync-props
1929 --log-window-size= --no-checkout --quiet
1930 --repack-flags --use-log-author --localtime
1931 --ignore-paths= $remote_opts
1933 local init_opts="
1934 --template= --shared= --trunk= --tags=
1935 --branches= --stdlayout --minimize-url
1936 --no-metadata --use-svm-props --use-svnsync-props
1937 --rewrite-root= --prefix= --use-log-author
1938 --add-author-from $remote_opts
1940 local cmt_opts="
1941 --edit --rmdir --find-copies-harder --copy-similarity=
1944 local cur="${COMP_WORDS[COMP_CWORD]}"
1945 case "$subcommand,$cur" in
1946 fetch,--*)
1947 __gitcomp "--revision= --fetch-all $fc_opts"
1949 clone,--*)
1950 __gitcomp "--revision= $fc_opts $init_opts"
1952 init,--*)
1953 __gitcomp "$init_opts"
1955 dcommit,--*)
1956 __gitcomp "
1957 --merge --strategy= --verbose --dry-run
1958 --fetch-all --no-rebase --commit-url
1959 --revision $cmt_opts $fc_opts
1962 set-tree,--*)
1963 __gitcomp "--stdin $cmt_opts $fc_opts"
1965 create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\
1966 show-externals,--*)
1967 __gitcomp "--revision="
1969 log,--*)
1970 __gitcomp "
1971 --limit= --revision= --verbose --incremental
1972 --oneline --show-commit --non-recursive
1973 --authors-file= --color
1976 rebase,--*)
1977 __gitcomp "
1978 --merge --verbose --strategy= --local
1979 --fetch-all --dry-run $fc_opts
1982 commit-diff,--*)
1983 __gitcomp "--message= --file= --revision= $cmt_opts"
1985 info,--*)
1986 __gitcomp "--url"
1988 branch,--*)
1989 __gitcomp "--dry-run --message --tag"
1991 tag,--*)
1992 __gitcomp "--dry-run --message"
1994 blame,--*)
1995 __gitcomp "--git-format"
1997 migrate,--*)
1998 __gitcomp "
1999 --config-dir= --ignore-paths= --minimize
2000 --no-auth-cache --username=
2004 COMPREPLY=()
2006 esac
2010 _git_tag ()
2012 local i c=1 f=0
2013 while [ $c -lt $COMP_CWORD ]; do
2014 i="${COMP_WORDS[c]}"
2015 case "$i" in
2016 -d|-v)
2017 __gitcomp "$(__git_tags)"
2018 return
2023 esac
2024 c=$((++c))
2025 done
2027 case "${COMP_WORDS[COMP_CWORD-1]}" in
2028 -m|-F)
2029 COMPREPLY=()
2031 -*|tag)
2032 if [ $f = 1 ]; then
2033 __gitcomp "$(__git_tags)"
2034 else
2035 COMPREPLY=()
2039 __gitcomp "$(__git_refs)"
2041 esac
2044 _git ()
2046 local i c=1 command __git_dir
2048 while [ $c -lt $COMP_CWORD ]; do
2049 i="${COMP_WORDS[c]}"
2050 case "$i" in
2051 --git-dir=*) __git_dir="${i#--git-dir=}" ;;
2052 --bare) __git_dir="." ;;
2053 --version|-p|--paginate) ;;
2054 --help) command="help"; break ;;
2055 *) command="$i"; break ;;
2056 esac
2057 c=$((++c))
2058 done
2060 if [ -z "$command" ]; then
2061 case "${COMP_WORDS[COMP_CWORD]}" in
2062 --*) __gitcomp "
2063 --paginate
2064 --no-pager
2065 --git-dir=
2066 --bare
2067 --version
2068 --exec-path
2069 --html-path
2070 --work-tree=
2071 --help
2074 *) __gitcomp "$(__git_porcelain_commands) $(__git_aliases)" ;;
2075 esac
2076 return
2079 local expansion=$(__git_aliased_command "$command")
2080 [ "$expansion" ] && command="$expansion"
2082 case "$command" in
2083 am) _git_am ;;
2084 add) _git_add ;;
2085 apply) _git_apply ;;
2086 archive) _git_archive ;;
2087 bisect) _git_bisect ;;
2088 bundle) _git_bundle ;;
2089 branch) _git_branch ;;
2090 checkout) _git_checkout ;;
2091 cherry) _git_cherry ;;
2092 cherry-pick) _git_cherry_pick ;;
2093 clean) _git_clean ;;
2094 clone) _git_clone ;;
2095 commit) _git_commit ;;
2096 config) _git_config ;;
2097 describe) _git_describe ;;
2098 diff) _git_diff ;;
2099 difftool) _git_difftool ;;
2100 fetch) _git_fetch ;;
2101 format-patch) _git_format_patch ;;
2102 fsck) _git_fsck ;;
2103 gc) _git_gc ;;
2104 grep) _git_grep ;;
2105 help) _git_help ;;
2106 init) _git_init ;;
2107 log) _git_log ;;
2108 ls-files) _git_ls_files ;;
2109 ls-remote) _git_ls_remote ;;
2110 ls-tree) _git_ls_tree ;;
2111 merge) _git_merge;;
2112 mergetool) _git_mergetool;;
2113 merge-base) _git_merge_base ;;
2114 mv) _git_mv ;;
2115 name-rev) _git_name_rev ;;
2116 pull) _git_pull ;;
2117 push) _git_push ;;
2118 rebase) _git_rebase ;;
2119 remote) _git_remote ;;
2120 reset) _git_reset ;;
2121 revert) _git_revert ;;
2122 rm) _git_rm ;;
2123 send-email) _git_send_email ;;
2124 shortlog) _git_shortlog ;;
2125 show) _git_show ;;
2126 show-branch) _git_show_branch ;;
2127 stash) _git_stash ;;
2128 stage) _git_add ;;
2129 submodule) _git_submodule ;;
2130 svn) _git_svn ;;
2131 tag) _git_tag ;;
2132 whatchanged) _git_log ;;
2133 *) COMPREPLY=() ;;
2134 esac
2137 _gitk ()
2139 __git_has_doubledash && return
2141 local cur="${COMP_WORDS[COMP_CWORD]}"
2142 local g="$(__gitdir)"
2143 local merge=""
2144 if [ -f "$g/MERGE_HEAD" ]; then
2145 merge="--merge"
2147 case "$cur" in
2148 --*)
2149 __gitcomp "
2150 $__git_log_common_options
2151 $__git_log_gitk_options
2152 $merge
2154 return
2156 esac
2157 __git_complete_revlist
2160 complete -o bashdefault -o default -o nospace -F _git git 2>/dev/null \
2161 || complete -o default -o nospace -F _git git
2162 complete -o bashdefault -o default -o nospace -F _gitk gitk 2>/dev/null \
2163 || complete -o default -o nospace -F _gitk gitk
2165 # The following are necessary only for Cygwin, and only are needed
2166 # when the user has tab-completed the executable name and consequently
2167 # included the '.exe' suffix.
2169 if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
2170 complete -o bashdefault -o default -o nospace -F _git git.exe 2>/dev/null \
2171 || complete -o default -o nospace -F _git git.exe