Merge branch 'jc/maint-add-p-coalesce-fix'
[git.git] / contrib / completion / git-completion.bash
blobc84d765ff9e5adb9636755591719ff9cd561e19c
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 [ -f "$g/rebase-merge/interactive" ]; then
88 r="|REBASE-i"
89 b="$(cat "$g/rebase-merge/head-name")"
90 elif [ -d "$g/rebase-merge" ]; then
91 r="|REBASE-m"
92 b="$(cat "$g/rebase-merge/head-name")"
93 else
94 if [ -d "$g/rebase-apply" ]; then
95 if [ -f "$g/rebase-apply/rebasing" ]; then
96 r="|REBASE"
97 elif [ -f "$g/rebase-apply/applying" ]; then
98 r="|AM"
99 else
100 r="|AM/REBASE"
102 elif [ -f "$g/MERGE_HEAD" ]; then
103 r="|MERGING"
104 elif [ -f "$g/BISECT_LOG" ]; then
105 r="|BISECTING"
108 b="$(git symbolic-ref HEAD 2>/dev/null)" || {
110 b="$(
111 case "${GIT_PS1_DESCRIBE_STYLE-}" in
112 (contains)
113 git describe --contains HEAD ;;
114 (branch)
115 git describe --contains --all HEAD ;;
116 (describe)
117 git describe HEAD ;;
118 (* | default)
119 git describe --exact-match HEAD ;;
120 esac 2>/dev/null)" ||
122 b="$(cut -c1-7 "$g/HEAD" 2>/dev/null)..." ||
123 b="unknown"
124 b="($b)"
128 local w
129 local i
130 local c
132 if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then
133 if [ "true" = "$(git rev-parse --is-bare-repository 2>/dev/null)" ]; then
134 c="BARE:"
135 else
136 b="GIT_DIR!"
138 elif [ "true" = "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
139 if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ]; then
140 if [ "$(git config --bool bash.showDirtyState)" != "false" ]; then
141 git diff --no-ext-diff --ignore-submodules \
142 --quiet --exit-code || w="*"
143 if git rev-parse --quiet --verify HEAD >/dev/null; then
144 git diff-index --cached --quiet \
145 --ignore-submodules HEAD -- || i="+"
146 else
147 i="#"
153 if [ -n "$b" ]; then
154 if [ -n "${1-}" ]; then
155 printf "$1" "$c${b##refs/heads/}$w$i$r"
156 else
157 printf " (%s)" "$c${b##refs/heads/}$w$i$r"
163 # __gitcomp_1 requires 2 arguments
164 __gitcomp_1 ()
166 local c IFS=' '$'\t'$'\n'
167 for c in $1; do
168 case "$c$2" in
169 --*=*) printf %s$'\n' "$c$2" ;;
170 *.) printf %s$'\n' "$c$2" ;;
171 *) printf %s$'\n' "$c$2 " ;;
172 esac
173 done
176 # __gitcomp accepts 1, 2, 3, or 4 arguments
177 # generates completion reply with compgen
178 __gitcomp ()
180 local cur="${COMP_WORDS[COMP_CWORD]}"
181 if [ $# -gt 2 ]; then
182 cur="$3"
184 case "$cur" in
185 --*=)
186 COMPREPLY=()
189 local IFS=$'\n'
190 COMPREPLY=($(compgen -P "${2-}" \
191 -W "$(__gitcomp_1 "${1-}" "${4-}")" \
192 -- "$cur"))
194 esac
197 # __git_heads accepts 0 or 1 arguments (to pass to __gitdir)
198 __git_heads ()
200 local cmd i is_hash=y dir="$(__gitdir "${1-}")"
201 if [ -d "$dir" ]; then
202 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
203 refs/heads
204 return
206 for i in $(git ls-remote "${1-}" 2>/dev/null); do
207 case "$is_hash,$i" in
208 y,*) is_hash=n ;;
209 n,*^{}) is_hash=y ;;
210 n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
211 n,*) is_hash=y; echo "$i" ;;
212 esac
213 done
216 # __git_tags accepts 0 or 1 arguments (to pass to __gitdir)
217 __git_tags ()
219 local cmd i is_hash=y dir="$(__gitdir "${1-}")"
220 if [ -d "$dir" ]; then
221 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
222 refs/tags
223 return
225 for i in $(git ls-remote "${1-}" 2>/dev/null); do
226 case "$is_hash,$i" in
227 y,*) is_hash=n ;;
228 n,*^{}) is_hash=y ;;
229 n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
230 n,*) is_hash=y; echo "$i" ;;
231 esac
232 done
235 # __git_refs accepts 0 or 1 arguments (to pass to __gitdir)
236 __git_refs ()
238 local i is_hash=y dir="$(__gitdir "${1-}")"
239 local cur="${COMP_WORDS[COMP_CWORD]}" format refs
240 if [ -d "$dir" ]; then
241 case "$cur" in
242 refs|refs/*)
243 format="refname"
244 refs="${cur%/*}"
247 if [ -e "$dir/HEAD" ]; then echo HEAD; fi
248 format="refname:short"
249 refs="refs/tags refs/heads refs/remotes"
251 esac
252 git --git-dir="$dir" for-each-ref --format="%($format)" \
253 $refs
254 return
256 for i in $(git ls-remote "$dir" 2>/dev/null); do
257 case "$is_hash,$i" in
258 y,*) is_hash=n ;;
259 n,*^{}) is_hash=y ;;
260 n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
261 n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
262 n,refs/remotes/*) is_hash=y; echo "${i#refs/remotes/}" ;;
263 n,*) is_hash=y; echo "$i" ;;
264 esac
265 done
268 # __git_refs2 requires 1 argument (to pass to __git_refs)
269 __git_refs2 ()
271 local i
272 for i in $(__git_refs "$1"); do
273 echo "$i:$i"
274 done
277 # __git_refs_remotes requires 1 argument (to pass to ls-remote)
278 __git_refs_remotes ()
280 local cmd i is_hash=y
281 for i in $(git ls-remote "$1" 2>/dev/null); do
282 case "$is_hash,$i" in
283 n,refs/heads/*)
284 is_hash=y
285 echo "$i:refs/remotes/$1/${i#refs/heads/}"
287 y,*) is_hash=n ;;
288 n,*^{}) is_hash=y ;;
289 n,refs/tags/*) is_hash=y;;
290 n,*) is_hash=y; ;;
291 esac
292 done
295 __git_remotes ()
297 local i ngoff IFS=$'\n' d="$(__gitdir)"
298 shopt -q nullglob || ngoff=1
299 shopt -s nullglob
300 for i in "$d/remotes"/*; do
301 echo ${i#$d/remotes/}
302 done
303 [ "$ngoff" ] && shopt -u nullglob
304 for i in $(git --git-dir="$d" config --list); do
305 case "$i" in
306 remote.*.url=*)
307 i="${i#remote.}"
308 echo "${i/.url=*/}"
310 esac
311 done
314 __git_merge_strategies ()
316 if [ -n "${__git_merge_strategylist-}" ]; then
317 echo "$__git_merge_strategylist"
318 return
320 git merge -s help 2>&1 |
321 sed -n -e '/[Aa]vailable strategies are: /,/^$/{
322 s/\.$//
323 s/.*://
324 s/^[ ]*//
325 s/[ ]*$//
329 __git_merge_strategylist=
330 __git_merge_strategylist=$(__git_merge_strategies 2>/dev/null)
332 __git_complete_file ()
334 local pfx ls ref cur="${COMP_WORDS[COMP_CWORD]}"
335 case "$cur" in
336 ?*:*)
337 ref="${cur%%:*}"
338 cur="${cur#*:}"
339 case "$cur" in
340 ?*/*)
341 pfx="${cur%/*}"
342 cur="${cur##*/}"
343 ls="$ref:$pfx"
344 pfx="$pfx/"
347 ls="$ref"
349 esac
351 case "$COMP_WORDBREAKS" in
352 *:*) : great ;;
353 *) pfx="$ref:$pfx" ;;
354 esac
356 local IFS=$'\n'
357 COMPREPLY=($(compgen -P "$pfx" \
358 -W "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \
359 | sed '/^100... blob /{
360 s,^.* ,,
361 s,$, ,
363 /^120000 blob /{
364 s,^.* ,,
365 s,$, ,
367 /^040000 tree /{
368 s,^.* ,,
369 s,$,/,
371 s/^.* //')" \
372 -- "$cur"))
375 __gitcomp "$(__git_refs)"
377 esac
380 __git_complete_revlist ()
382 local pfx cur="${COMP_WORDS[COMP_CWORD]}"
383 case "$cur" in
384 *...*)
385 pfx="${cur%...*}..."
386 cur="${cur#*...}"
387 __gitcomp "$(__git_refs)" "$pfx" "$cur"
389 *..*)
390 pfx="${cur%..*}.."
391 cur="${cur#*..}"
392 __gitcomp "$(__git_refs)" "$pfx" "$cur"
395 __gitcomp "$(__git_refs)"
397 esac
400 __git_complete_remote_or_refspec ()
402 local cmd="${COMP_WORDS[1]}"
403 local cur="${COMP_WORDS[COMP_CWORD]}"
404 local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0
405 while [ $c -lt $COMP_CWORD ]; do
406 i="${COMP_WORDS[c]}"
407 case "$i" in
408 --all|--mirror) [ "$cmd" = "push" ] && no_complete_refspec=1 ;;
409 -*) ;;
410 *) remote="$i"; break ;;
411 esac
412 c=$((++c))
413 done
414 if [ -z "$remote" ]; then
415 __gitcomp "$(__git_remotes)"
416 return
418 if [ $no_complete_refspec = 1 ]; then
419 COMPREPLY=()
420 return
422 [ "$remote" = "." ] && remote=
423 case "$cur" in
424 *:*)
425 case "$COMP_WORDBREAKS" in
426 *:*) : great ;;
427 *) pfx="${cur%%:*}:" ;;
428 esac
429 cur="${cur#*:}"
430 lhs=0
433 pfx="+"
434 cur="${cur#+}"
436 esac
437 case "$cmd" in
438 fetch)
439 if [ $lhs = 1 ]; then
440 __gitcomp "$(__git_refs2 "$remote")" "$pfx" "$cur"
441 else
442 __gitcomp "$(__git_refs)" "$pfx" "$cur"
445 pull)
446 if [ $lhs = 1 ]; then
447 __gitcomp "$(__git_refs "$remote")" "$pfx" "$cur"
448 else
449 __gitcomp "$(__git_refs)" "$pfx" "$cur"
452 push)
453 if [ $lhs = 1 ]; then
454 __gitcomp "$(__git_refs)" "$pfx" "$cur"
455 else
456 __gitcomp "$(__git_refs "$remote")" "$pfx" "$cur"
459 esac
462 __git_complete_strategy ()
464 case "${COMP_WORDS[COMP_CWORD-1]}" in
465 -s|--strategy)
466 __gitcomp "$(__git_merge_strategies)"
467 return 0
468 esac
469 local cur="${COMP_WORDS[COMP_CWORD]}"
470 case "$cur" in
471 --strategy=*)
472 __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}"
473 return 0
475 esac
476 return 1
479 __git_all_commands ()
481 if [ -n "${__git_all_commandlist-}" ]; then
482 echo "$__git_all_commandlist"
483 return
485 local i IFS=" "$'\n'
486 for i in $(git help -a|egrep '^ ')
488 case $i in
489 *--*) : helper pattern;;
490 *) echo $i;;
491 esac
492 done
494 __git_all_commandlist=
495 __git_all_commandlist="$(__git_all_commands 2>/dev/null)"
497 __git_porcelain_commands ()
499 if [ -n "${__git_porcelain_commandlist-}" ]; then
500 echo "$__git_porcelain_commandlist"
501 return
503 local i IFS=" "$'\n'
504 for i in "help" $(__git_all_commands)
506 case $i in
507 *--*) : helper pattern;;
508 applymbox) : ask gittus;;
509 applypatch) : ask gittus;;
510 archimport) : import;;
511 cat-file) : plumbing;;
512 check-attr) : plumbing;;
513 check-ref-format) : plumbing;;
514 checkout-index) : plumbing;;
515 commit-tree) : plumbing;;
516 count-objects) : infrequent;;
517 cvsexportcommit) : export;;
518 cvsimport) : import;;
519 cvsserver) : daemon;;
520 daemon) : daemon;;
521 diff-files) : plumbing;;
522 diff-index) : plumbing;;
523 diff-tree) : plumbing;;
524 fast-import) : import;;
525 fast-export) : export;;
526 fsck-objects) : plumbing;;
527 fetch-pack) : plumbing;;
528 fmt-merge-msg) : plumbing;;
529 for-each-ref) : plumbing;;
530 hash-object) : plumbing;;
531 http-*) : transport;;
532 index-pack) : plumbing;;
533 init-db) : deprecated;;
534 local-fetch) : plumbing;;
535 lost-found) : infrequent;;
536 ls-files) : plumbing;;
537 ls-remote) : plumbing;;
538 ls-tree) : plumbing;;
539 mailinfo) : plumbing;;
540 mailsplit) : plumbing;;
541 merge-*) : plumbing;;
542 mktree) : plumbing;;
543 mktag) : plumbing;;
544 pack-objects) : plumbing;;
545 pack-redundant) : plumbing;;
546 pack-refs) : plumbing;;
547 parse-remote) : plumbing;;
548 patch-id) : plumbing;;
549 peek-remote) : plumbing;;
550 prune) : plumbing;;
551 prune-packed) : plumbing;;
552 quiltimport) : import;;
553 read-tree) : plumbing;;
554 receive-pack) : plumbing;;
555 reflog) : plumbing;;
556 repo-config) : deprecated;;
557 rerere) : plumbing;;
558 rev-list) : plumbing;;
559 rev-parse) : plumbing;;
560 runstatus) : plumbing;;
561 sh-setup) : internal;;
562 shell) : daemon;;
563 show-ref) : plumbing;;
564 send-pack) : plumbing;;
565 show-index) : plumbing;;
566 ssh-*) : transport;;
567 stripspace) : plumbing;;
568 symbolic-ref) : plumbing;;
569 tar-tree) : deprecated;;
570 unpack-file) : plumbing;;
571 unpack-objects) : plumbing;;
572 update-index) : plumbing;;
573 update-ref) : plumbing;;
574 update-server-info) : daemon;;
575 upload-archive) : plumbing;;
576 upload-pack) : plumbing;;
577 write-tree) : plumbing;;
578 var) : infrequent;;
579 verify-pack) : infrequent;;
580 verify-tag) : plumbing;;
581 *) echo $i;;
582 esac
583 done
585 __git_porcelain_commandlist=
586 __git_porcelain_commandlist="$(__git_porcelain_commands 2>/dev/null)"
588 __git_aliases ()
590 local i IFS=$'\n'
591 for i in $(git --git-dir="$(__gitdir)" config --list); do
592 case "$i" in
593 alias.*)
594 i="${i#alias.}"
595 echo "${i/=*/}"
597 esac
598 done
601 # __git_aliased_command requires 1 argument
602 __git_aliased_command ()
604 local word cmdline=$(git --git-dir="$(__gitdir)" \
605 config --get "alias.$1")
606 for word in $cmdline; do
607 if [ "${word##-*}" ]; then
608 echo $word
609 return
611 done
614 # __git_find_subcommand requires 1 argument
615 __git_find_subcommand ()
617 local word subcommand c=1
619 while [ $c -lt $COMP_CWORD ]; do
620 word="${COMP_WORDS[c]}"
621 for subcommand in $1; do
622 if [ "$subcommand" = "$word" ]; then
623 echo "$subcommand"
624 return
626 done
627 c=$((++c))
628 done
631 __git_has_doubledash ()
633 local c=1
634 while [ $c -lt $COMP_CWORD ]; do
635 if [ "--" = "${COMP_WORDS[c]}" ]; then
636 return 0
638 c=$((++c))
639 done
640 return 1
643 __git_whitespacelist="nowarn warn error error-all fix"
645 _git_am ()
647 local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)"
648 if [ -d "$dir"/rebase-apply ]; then
649 __gitcomp "--skip --resolved --abort"
650 return
652 case "$cur" in
653 --whitespace=*)
654 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
655 return
657 --*)
658 __gitcomp "
659 --3way --committer-date-is-author-date --ignore-date
660 --interactive --keep --no-utf8 --signoff --utf8
661 --whitespace=
663 return
664 esac
665 COMPREPLY=()
668 _git_apply ()
670 local cur="${COMP_WORDS[COMP_CWORD]}"
671 case "$cur" in
672 --whitespace=*)
673 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
674 return
676 --*)
677 __gitcomp "
678 --stat --numstat --summary --check --index
679 --cached --index-info --reverse --reject --unidiff-zero
680 --apply --no-add --exclude=
681 --whitespace= --inaccurate-eof --verbose
683 return
684 esac
685 COMPREPLY=()
688 _git_add ()
690 __git_has_doubledash && return
692 local cur="${COMP_WORDS[COMP_CWORD]}"
693 case "$cur" in
694 --*)
695 __gitcomp "
696 --interactive --refresh --patch --update --dry-run
697 --ignore-errors --intent-to-add
699 return
700 esac
701 COMPREPLY=()
704 _git_archive ()
706 local cur="${COMP_WORDS[COMP_CWORD]}"
707 case "$cur" in
708 --format=*)
709 __gitcomp "$(git archive --list)" "" "${cur##--format=}"
710 return
712 --remote=*)
713 __gitcomp "$(__git_remotes)" "" "${cur##--remote=}"
714 return
716 --*)
717 __gitcomp "
718 --format= --list --verbose
719 --prefix= --remote= --exec=
721 return
723 esac
724 __git_complete_file
727 _git_bisect ()
729 __git_has_doubledash && return
731 local subcommands="start bad good skip reset visualize replay log run"
732 local subcommand="$(__git_find_subcommand "$subcommands")"
733 if [ -z "$subcommand" ]; then
734 __gitcomp "$subcommands"
735 return
738 case "$subcommand" in
739 bad|good|reset|skip)
740 __gitcomp "$(__git_refs)"
743 COMPREPLY=()
745 esac
748 _git_branch ()
750 local i c=1 only_local_ref="n" has_r="n"
752 while [ $c -lt $COMP_CWORD ]; do
753 i="${COMP_WORDS[c]}"
754 case "$i" in
755 -d|-m) only_local_ref="y" ;;
756 -r) has_r="y" ;;
757 esac
758 c=$((++c))
759 done
761 case "${COMP_WORDS[COMP_CWORD]}" in
762 --*)
763 __gitcomp "
764 --color --no-color --verbose --abbrev= --no-abbrev
765 --track --no-track --contains --merged --no-merged
769 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
770 __gitcomp "$(__git_heads)"
771 else
772 __gitcomp "$(__git_refs)"
775 esac
778 _git_bundle ()
780 local cmd="${COMP_WORDS[2]}"
781 case "$COMP_CWORD" in
783 __gitcomp "create list-heads verify unbundle"
786 # looking for a file
789 case "$cmd" in
790 create)
791 __git_complete_revlist
793 esac
795 esac
798 _git_checkout ()
800 __git_has_doubledash && return
802 __gitcomp "$(__git_refs)"
805 _git_cherry ()
807 __gitcomp "$(__git_refs)"
810 _git_cherry_pick ()
812 local cur="${COMP_WORDS[COMP_CWORD]}"
813 case "$cur" in
814 --*)
815 __gitcomp "--edit --no-commit"
818 __gitcomp "$(__git_refs)"
820 esac
823 _git_clean ()
825 __git_has_doubledash && return
827 local cur="${COMP_WORDS[COMP_CWORD]}"
828 case "$cur" in
829 --*)
830 __gitcomp "--dry-run --quiet"
831 return
833 esac
834 COMPREPLY=()
837 _git_clone ()
839 local cur="${COMP_WORDS[COMP_CWORD]}"
840 case "$cur" in
841 --*)
842 __gitcomp "
843 --local
844 --no-hardlinks
845 --shared
846 --reference
847 --quiet
848 --no-checkout
849 --bare
850 --mirror
851 --origin
852 --upload-pack
853 --template=
854 --depth
856 return
858 esac
859 COMPREPLY=()
862 _git_commit ()
864 __git_has_doubledash && return
866 local cur="${COMP_WORDS[COMP_CWORD]}"
867 case "$cur" in
868 --*)
869 __gitcomp "
870 --all --author= --signoff --verify --no-verify
871 --edit --amend --include --only --interactive
873 return
874 esac
875 COMPREPLY=()
878 _git_describe ()
880 local cur="${COMP_WORDS[COMP_CWORD]}"
881 case "$cur" in
882 --*)
883 __gitcomp "
884 --all --tags --contains --abbrev= --candidates=
885 --exact-match --debug --long --match --always
887 return
888 esac
889 __gitcomp "$(__git_refs)"
892 __git_diff_common_options="--stat --numstat --shortstat --summary
893 --patch-with-stat --name-only --name-status --color
894 --no-color --color-words --no-renames --check
895 --full-index --binary --abbrev --diff-filter=
896 --find-copies-harder
897 --text --ignore-space-at-eol --ignore-space-change
898 --ignore-all-space --exit-code --quiet --ext-diff
899 --no-ext-diff
900 --no-prefix --src-prefix= --dst-prefix=
901 --inter-hunk-context=
902 --patience
903 --raw
906 _git_diff ()
908 __git_has_doubledash && return
910 local cur="${COMP_WORDS[COMP_CWORD]}"
911 case "$cur" in
912 --*)
913 __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
914 --base --ours --theirs
915 $__git_diff_common_options
917 return
919 esac
920 __git_complete_file
923 __git_mergetools_common="diffuse ecmerge emerge kdiff3 meld opendiff
924 tkdiff vimdiff gvimdiff xxdiff
927 _git_difftool ()
929 local cur="${COMP_WORDS[COMP_CWORD]}"
930 case "$cur" in
931 --tool=*)
932 __gitcomp "$__git_mergetools_common kompare" "" "${cur##--tool=}"
933 return
935 --*)
936 __gitcomp "--tool="
937 return
939 esac
940 COMPREPLY=()
943 __git_fetch_options="
944 --quiet --verbose --append --upload-pack --force --keep --depth=
945 --tags --no-tags
948 _git_fetch ()
950 local cur="${COMP_WORDS[COMP_CWORD]}"
951 case "$cur" in
952 --*)
953 __gitcomp "$__git_fetch_options"
954 return
956 esac
957 __git_complete_remote_or_refspec
960 _git_format_patch ()
962 local cur="${COMP_WORDS[COMP_CWORD]}"
963 case "$cur" in
964 --thread=*)
965 __gitcomp "
966 deep shallow
967 " "" "${cur##--thread=}"
968 return
970 --*)
971 __gitcomp "
972 --stdout --attach --no-attach --thread --thread=
973 --output-directory
974 --numbered --start-number
975 --numbered-files
976 --keep-subject
977 --signoff
978 --in-reply-to= --cc=
979 --full-index --binary
980 --not --all
981 --cover-letter
982 --no-prefix --src-prefix= --dst-prefix=
983 --inline --suffix= --ignore-if-in-upstream
984 --subject-prefix=
986 return
988 esac
989 __git_complete_revlist
992 _git_fsck ()
994 local cur="${COMP_WORDS[COMP_CWORD]}"
995 case "$cur" in
996 --*)
997 __gitcomp "
998 --tags --root --unreachable --cache --no-reflogs --full
999 --strict --verbose --lost-found
1001 return
1003 esac
1004 COMPREPLY=()
1007 _git_gc ()
1009 local cur="${COMP_WORDS[COMP_CWORD]}"
1010 case "$cur" in
1011 --*)
1012 __gitcomp "--prune --aggressive"
1013 return
1015 esac
1016 COMPREPLY=()
1019 _git_grep ()
1021 __git_has_doubledash && return
1023 local cur="${COMP_WORDS[COMP_CWORD]}"
1024 case "$cur" in
1025 --*)
1026 __gitcomp "
1027 --cached
1028 --text --ignore-case --word-regexp --invert-match
1029 --full-name
1030 --extended-regexp --basic-regexp --fixed-strings
1031 --files-with-matches --name-only
1032 --files-without-match
1033 --count
1034 --and --or --not --all-match
1036 return
1038 esac
1039 COMPREPLY=()
1042 _git_help ()
1044 local cur="${COMP_WORDS[COMP_CWORD]}"
1045 case "$cur" in
1046 --*)
1047 __gitcomp "--all --info --man --web"
1048 return
1050 esac
1051 __gitcomp "$(__git_all_commands)
1052 attributes cli core-tutorial cvs-migration
1053 diffcore gitk glossary hooks ignore modules
1054 repository-layout tutorial tutorial-2
1055 workflows
1059 _git_init ()
1061 local cur="${COMP_WORDS[COMP_CWORD]}"
1062 case "$cur" in
1063 --shared=*)
1064 __gitcomp "
1065 false true umask group all world everybody
1066 " "" "${cur##--shared=}"
1067 return
1069 --*)
1070 __gitcomp "--quiet --bare --template= --shared --shared="
1071 return
1073 esac
1074 COMPREPLY=()
1077 _git_ls_files ()
1079 __git_has_doubledash && return
1081 local cur="${COMP_WORDS[COMP_CWORD]}"
1082 case "$cur" in
1083 --*)
1084 __gitcomp "--cached --deleted --modified --others --ignored
1085 --stage --directory --no-empty-directory --unmerged
1086 --killed --exclude= --exclude-from=
1087 --exclude-per-directory= --exclude-standard
1088 --error-unmatch --with-tree= --full-name
1089 --abbrev --ignored --exclude-per-directory
1091 return
1093 esac
1094 COMPREPLY=()
1097 _git_ls_remote ()
1099 __gitcomp "$(__git_remotes)"
1102 _git_ls_tree ()
1104 __git_complete_file
1107 # Options that go well for log, shortlog and gitk
1108 __git_log_common_options="
1109 --not --all
1110 --branches --tags --remotes
1111 --first-parent --no-merges
1112 --max-count=
1113 --max-age= --since= --after=
1114 --min-age= --until= --before=
1116 # Options that go well for log and gitk (not shortlog)
1117 __git_log_gitk_options="
1118 --dense --sparse --full-history
1119 --simplify-merges --simplify-by-decoration
1120 --left-right
1122 # Options that go well for log and shortlog (not gitk)
1123 __git_log_shortlog_options="
1124 --author= --committer= --grep=
1125 --all-match
1128 __git_log_pretty_formats="oneline short medium full fuller email raw format:"
1129 __git_log_date_formats="relative iso8601 rfc2822 short local default raw"
1131 _git_log ()
1133 __git_has_doubledash && return
1135 local cur="${COMP_WORDS[COMP_CWORD]}"
1136 local g="$(git rev-parse --git-dir 2>/dev/null)"
1137 local merge=""
1138 if [ -f "$g/MERGE_HEAD" ]; then
1139 merge="--merge"
1141 case "$cur" in
1142 --pretty=*)
1143 __gitcomp "$__git_log_pretty_formats
1144 " "" "${cur##--pretty=}"
1145 return
1147 --format=*)
1148 __gitcomp "$__git_log_pretty_formats
1149 " "" "${cur##--format=}"
1150 return
1152 --date=*)
1153 __gitcomp "$__git_log_date_formats" "" "${cur##--date=}"
1154 return
1156 --*)
1157 __gitcomp "
1158 $__git_log_common_options
1159 $__git_log_shortlog_options
1160 $__git_log_gitk_options
1161 --root --topo-order --date-order --reverse
1162 --follow
1163 --abbrev-commit --abbrev=
1164 --relative-date --date=
1165 --pretty= --format= --oneline
1166 --cherry-pick
1167 --graph
1168 --decorate
1169 --walk-reflogs
1170 --parents --children
1171 $merge
1172 $__git_diff_common_options
1173 --pickaxe-all --pickaxe-regex
1175 return
1177 esac
1178 __git_complete_revlist
1181 __git_merge_options="
1182 --no-commit --no-stat --log --no-log --squash --strategy
1183 --commit --stat --no-squash --ff --no-ff
1186 _git_merge ()
1188 __git_complete_strategy && return
1190 local cur="${COMP_WORDS[COMP_CWORD]}"
1191 case "$cur" in
1192 --*)
1193 __gitcomp "$__git_merge_options"
1194 return
1195 esac
1196 __gitcomp "$(__git_refs)"
1199 _git_mergetool ()
1201 local cur="${COMP_WORDS[COMP_CWORD]}"
1202 case "$cur" in
1203 --tool=*)
1204 __gitcomp "$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"
1205 return
1207 --*)
1208 __gitcomp "--tool="
1209 return
1211 esac
1212 COMPREPLY=()
1215 _git_merge_base ()
1217 __gitcomp "$(__git_refs)"
1220 _git_mv ()
1222 local cur="${COMP_WORDS[COMP_CWORD]}"
1223 case "$cur" in
1224 --*)
1225 __gitcomp "--dry-run"
1226 return
1228 esac
1229 COMPREPLY=()
1232 _git_name_rev ()
1234 __gitcomp "--tags --all --stdin"
1237 _git_pull ()
1239 __git_complete_strategy && return
1241 local cur="${COMP_WORDS[COMP_CWORD]}"
1242 case "$cur" in
1243 --*)
1244 __gitcomp "
1245 --rebase --no-rebase
1246 $__git_merge_options
1247 $__git_fetch_options
1249 return
1251 esac
1252 __git_complete_remote_or_refspec
1255 _git_push ()
1257 local cur="${COMP_WORDS[COMP_CWORD]}"
1258 case "${COMP_WORDS[COMP_CWORD-1]}" in
1259 --repo)
1260 __gitcomp "$(__git_remotes)"
1261 return
1262 esac
1263 case "$cur" in
1264 --repo=*)
1265 __gitcomp "$(__git_remotes)" "" "${cur##--repo=}"
1266 return
1268 --*)
1269 __gitcomp "
1270 --all --mirror --tags --dry-run --force --verbose
1271 --receive-pack= --repo=
1273 return
1275 esac
1276 __git_complete_remote_or_refspec
1279 _git_rebase ()
1281 local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)"
1282 if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
1283 __gitcomp "--continue --skip --abort"
1284 return
1286 __git_complete_strategy && return
1287 case "$cur" in
1288 --*)
1289 __gitcomp "--onto --merge --strategy --interactive"
1290 return
1291 esac
1292 __gitcomp "$(__git_refs)"
1295 __git_send_email_confirm_options="always never auto cc compose"
1296 __git_send_email_suppresscc_options="author self cc ccbody sob cccmd body all"
1298 _git_send_email ()
1300 local cur="${COMP_WORDS[COMP_CWORD]}"
1301 case "$cur" in
1302 --confirm=*)
1303 __gitcomp "
1304 $__git_send_email_confirm_options
1305 " "" "${cur##--confirm=}"
1306 return
1308 --suppress-cc=*)
1309 __gitcomp "
1310 $__git_send_email_suppresscc_options
1311 " "" "${cur##--suppress-cc=}"
1313 return
1315 --smtp-encryption=*)
1316 __gitcomp "ssl tls" "" "${cur##--smtp-encryption=}"
1317 return
1319 --*)
1320 __gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to
1321 --compose --confirm= --dry-run --envelope-sender
1322 --from --identity
1323 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
1324 --no-suppress-from --no-thread --quiet
1325 --signed-off-by-cc --smtp-pass --smtp-server
1326 --smtp-server-port --smtp-encryption= --smtp-user
1327 --subject --suppress-cc= --suppress-from --thread --to
1328 --validate --no-validate"
1329 return
1331 esac
1332 COMPREPLY=()
1335 __git_config_get_set_variables ()
1337 local prevword word config_file= c=$COMP_CWORD
1338 while [ $c -gt 1 ]; do
1339 word="${COMP_WORDS[c]}"
1340 case "$word" in
1341 --global|--system|--file=*)
1342 config_file="$word"
1343 break
1345 -f|--file)
1346 config_file="$word $prevword"
1347 break
1349 esac
1350 prevword=$word
1351 c=$((--c))
1352 done
1354 for i in $(git --git-dir="$(__gitdir)" config $config_file --list \
1355 2>/dev/null); do
1356 case "$i" in
1357 *.*)
1358 echo "${i/=*/}"
1360 esac
1361 done
1364 _git_config ()
1366 local cur="${COMP_WORDS[COMP_CWORD]}"
1367 local prv="${COMP_WORDS[COMP_CWORD-1]}"
1368 case "$prv" in
1369 branch.*.remote)
1370 __gitcomp "$(__git_remotes)"
1371 return
1373 branch.*.merge)
1374 __gitcomp "$(__git_refs)"
1375 return
1377 remote.*.fetch)
1378 local remote="${prv#remote.}"
1379 remote="${remote%.fetch}"
1380 __gitcomp "$(__git_refs_remotes "$remote")"
1381 return
1383 remote.*.push)
1384 local remote="${prv#remote.}"
1385 remote="${remote%.push}"
1386 __gitcomp "$(git --git-dir="$(__gitdir)" \
1387 for-each-ref --format='%(refname):%(refname)' \
1388 refs/heads)"
1389 return
1391 pull.twohead|pull.octopus)
1392 __gitcomp "$(__git_merge_strategies)"
1393 return
1395 color.branch|color.diff|color.interactive|\
1396 color.showbranch|color.status|color.ui)
1397 __gitcomp "always never auto"
1398 return
1400 color.pager)
1401 __gitcomp "false true"
1402 return
1404 color.*.*)
1405 __gitcomp "
1406 normal black red green yellow blue magenta cyan white
1407 bold dim ul blink reverse
1409 return
1411 help.format)
1412 __gitcomp "man info web html"
1413 return
1415 log.date)
1416 __gitcomp "$__git_log_date_formats"
1417 return
1419 sendemail.aliasesfiletype)
1420 __gitcomp "mutt mailrc pine elm gnus"
1421 return
1423 sendemail.confirm)
1424 __gitcomp "$__git_send_email_confirm_options"
1425 return
1427 sendemail.suppresscc)
1428 __gitcomp "$__git_send_email_suppresscc_options"
1429 return
1431 --get|--get-all|--unset|--unset-all)
1432 __gitcomp "$(__git_config_get_set_variables)"
1433 return
1435 *.*)
1436 COMPREPLY=()
1437 return
1439 esac
1440 case "$cur" in
1441 --*)
1442 __gitcomp "
1443 --global --system --file=
1444 --list --replace-all
1445 --get --get-all --get-regexp
1446 --add --unset --unset-all
1447 --remove-section --rename-section
1449 return
1451 branch.*.*)
1452 local pfx="${cur%.*}."
1453 cur="${cur##*.}"
1454 __gitcomp "remote merge mergeoptions" "$pfx" "$cur"
1455 return
1457 branch.*)
1458 local pfx="${cur%.*}."
1459 cur="${cur#*.}"
1460 __gitcomp "$(__git_heads)" "$pfx" "$cur" "."
1461 return
1463 guitool.*.*)
1464 local pfx="${cur%.*}."
1465 cur="${cur##*.}"
1466 __gitcomp "
1467 argprompt cmd confirm needsfile noconsole norescan
1468 prompt revprompt revunmerged title
1469 " "$pfx" "$cur"
1470 return
1472 difftool.*.*)
1473 local pfx="${cur%.*}."
1474 cur="${cur##*.}"
1475 __gitcomp "cmd path" "$pfx" "$cur"
1476 return
1478 man.*.*)
1479 local pfx="${cur%.*}."
1480 cur="${cur##*.}"
1481 __gitcomp "cmd path" "$pfx" "$cur"
1482 return
1484 mergetool.*.*)
1485 local pfx="${cur%.*}."
1486 cur="${cur##*.}"
1487 __gitcomp "cmd path trustExitCode" "$pfx" "$cur"
1488 return
1490 pager.*)
1491 local pfx="${cur%.*}."
1492 cur="${cur#*.}"
1493 __gitcomp "$(__git_all_commands)" "$pfx" "$cur"
1494 return
1496 remote.*.*)
1497 local pfx="${cur%.*}."
1498 cur="${cur##*.}"
1499 __gitcomp "
1500 url proxy fetch push mirror skipDefaultUpdate
1501 receivepack uploadpack tagopt
1502 " "$pfx" "$cur"
1503 return
1505 remote.*)
1506 local pfx="${cur%.*}."
1507 cur="${cur#*.}"
1508 __gitcomp "$(__git_remotes)" "$pfx" "$cur" "."
1509 return
1511 url.*.*)
1512 local pfx="${cur%.*}."
1513 cur="${cur##*.}"
1514 __gitcomp "insteadof" "$pfx" "$cur"
1515 return
1517 esac
1518 __gitcomp "
1519 alias.
1520 apply.whitespace
1521 branch.autosetupmerge
1522 branch.autosetuprebase
1523 clean.requireForce
1524 color.branch
1525 color.branch.current
1526 color.branch.local
1527 color.branch.plain
1528 color.branch.remote
1529 color.diff
1530 color.diff.commit
1531 color.diff.frag
1532 color.diff.meta
1533 color.diff.new
1534 color.diff.old
1535 color.diff.plain
1536 color.diff.whitespace
1537 color.grep
1538 color.grep.external
1539 color.grep.match
1540 color.interactive
1541 color.interactive.header
1542 color.interactive.help
1543 color.interactive.prompt
1544 color.pager
1545 color.showbranch
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 --color --no-color
1858 --sha1-name --sparse --topics --reflog
1860 return
1862 esac
1863 __git_complete_revlist
1866 _git_stash ()
1868 local subcommands='save list show apply clear drop pop create branch'
1869 local subcommand="$(__git_find_subcommand "$subcommands")"
1870 if [ -z "$subcommand" ]; then
1871 __gitcomp "$subcommands"
1872 else
1873 local cur="${COMP_WORDS[COMP_CWORD]}"
1874 case "$subcommand,$cur" in
1875 save,--*)
1876 __gitcomp "--keep-index"
1878 apply,--*)
1879 __gitcomp "--index"
1881 show,--*|drop,--*|pop,--*|branch,--*)
1882 COMPREPLY=()
1884 show,*|apply,*|drop,*|pop,*|branch,*)
1885 __gitcomp "$(git --git-dir="$(__gitdir)" stash list \
1886 | sed -n -e 's/:.*//p')"
1889 COMPREPLY=()
1891 esac
1895 _git_submodule ()
1897 __git_has_doubledash && return
1899 local subcommands="add status init update summary foreach sync"
1900 if [ -z "$(__git_find_subcommand "$subcommands")" ]; then
1901 local cur="${COMP_WORDS[COMP_CWORD]}"
1902 case "$cur" in
1903 --*)
1904 __gitcomp "--quiet --cached"
1907 __gitcomp "$subcommands"
1909 esac
1910 return
1914 _git_svn ()
1916 local subcommands="
1917 init fetch clone rebase dcommit log find-rev
1918 set-tree commit-diff info create-ignore propget
1919 proplist show-ignore show-externals branch tag blame
1920 migrate
1922 local subcommand="$(__git_find_subcommand "$subcommands")"
1923 if [ -z "$subcommand" ]; then
1924 __gitcomp "$subcommands"
1925 else
1926 local remote_opts="--username= --config-dir= --no-auth-cache"
1927 local fc_opts="
1928 --follow-parent --authors-file= --repack=
1929 --no-metadata --use-svm-props --use-svnsync-props
1930 --log-window-size= --no-checkout --quiet
1931 --repack-flags --use-log-author --localtime
1932 --ignore-paths= $remote_opts
1934 local init_opts="
1935 --template= --shared= --trunk= --tags=
1936 --branches= --stdlayout --minimize-url
1937 --no-metadata --use-svm-props --use-svnsync-props
1938 --rewrite-root= --prefix= --use-log-author
1939 --add-author-from $remote_opts
1941 local cmt_opts="
1942 --edit --rmdir --find-copies-harder --copy-similarity=
1945 local cur="${COMP_WORDS[COMP_CWORD]}"
1946 case "$subcommand,$cur" in
1947 fetch,--*)
1948 __gitcomp "--revision= --fetch-all $fc_opts"
1950 clone,--*)
1951 __gitcomp "--revision= $fc_opts $init_opts"
1953 init,--*)
1954 __gitcomp "$init_opts"
1956 dcommit,--*)
1957 __gitcomp "
1958 --merge --strategy= --verbose --dry-run
1959 --fetch-all --no-rebase --commit-url
1960 --revision $cmt_opts $fc_opts
1963 set-tree,--*)
1964 __gitcomp "--stdin $cmt_opts $fc_opts"
1966 create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\
1967 show-externals,--*)
1968 __gitcomp "--revision="
1970 log,--*)
1971 __gitcomp "
1972 --limit= --revision= --verbose --incremental
1973 --oneline --show-commit --non-recursive
1974 --authors-file= --color
1977 rebase,--*)
1978 __gitcomp "
1979 --merge --verbose --strategy= --local
1980 --fetch-all --dry-run $fc_opts
1983 commit-diff,--*)
1984 __gitcomp "--message= --file= --revision= $cmt_opts"
1986 info,--*)
1987 __gitcomp "--url"
1989 branch,--*)
1990 __gitcomp "--dry-run --message --tag"
1992 tag,--*)
1993 __gitcomp "--dry-run --message"
1995 blame,--*)
1996 __gitcomp "--git-format"
1998 migrate,--*)
1999 __gitcomp "
2000 --config-dir= --ignore-paths= --minimize
2001 --no-auth-cache --username=
2005 COMPREPLY=()
2007 esac
2011 _git_tag ()
2013 local i c=1 f=0
2014 while [ $c -lt $COMP_CWORD ]; do
2015 i="${COMP_WORDS[c]}"
2016 case "$i" in
2017 -d|-v)
2018 __gitcomp "$(__git_tags)"
2019 return
2024 esac
2025 c=$((++c))
2026 done
2028 case "${COMP_WORDS[COMP_CWORD-1]}" in
2029 -m|-F)
2030 COMPREPLY=()
2032 -*|tag)
2033 if [ $f = 1 ]; then
2034 __gitcomp "$(__git_tags)"
2035 else
2036 COMPREPLY=()
2040 __gitcomp "$(__git_refs)"
2042 esac
2045 _git ()
2047 local i c=1 command __git_dir
2049 while [ $c -lt $COMP_CWORD ]; do
2050 i="${COMP_WORDS[c]}"
2051 case "$i" in
2052 --git-dir=*) __git_dir="${i#--git-dir=}" ;;
2053 --bare) __git_dir="." ;;
2054 --version|-p|--paginate) ;;
2055 --help) command="help"; break ;;
2056 *) command="$i"; break ;;
2057 esac
2058 c=$((++c))
2059 done
2061 if [ -z "$command" ]; then
2062 case "${COMP_WORDS[COMP_CWORD]}" in
2063 --*) __gitcomp "
2064 --paginate
2065 --no-pager
2066 --git-dir=
2067 --bare
2068 --version
2069 --exec-path
2070 --html-path
2071 --work-tree=
2072 --help
2075 *) __gitcomp "$(__git_porcelain_commands) $(__git_aliases)" ;;
2076 esac
2077 return
2080 local expansion=$(__git_aliased_command "$command")
2081 [ "$expansion" ] && command="$expansion"
2083 case "$command" in
2084 am) _git_am ;;
2085 add) _git_add ;;
2086 apply) _git_apply ;;
2087 archive) _git_archive ;;
2088 bisect) _git_bisect ;;
2089 bundle) _git_bundle ;;
2090 branch) _git_branch ;;
2091 checkout) _git_checkout ;;
2092 cherry) _git_cherry ;;
2093 cherry-pick) _git_cherry_pick ;;
2094 clean) _git_clean ;;
2095 clone) _git_clone ;;
2096 commit) _git_commit ;;
2097 config) _git_config ;;
2098 describe) _git_describe ;;
2099 diff) _git_diff ;;
2100 difftool) _git_difftool ;;
2101 fetch) _git_fetch ;;
2102 format-patch) _git_format_patch ;;
2103 fsck) _git_fsck ;;
2104 gc) _git_gc ;;
2105 grep) _git_grep ;;
2106 help) _git_help ;;
2107 init) _git_init ;;
2108 log) _git_log ;;
2109 ls-files) _git_ls_files ;;
2110 ls-remote) _git_ls_remote ;;
2111 ls-tree) _git_ls_tree ;;
2112 merge) _git_merge;;
2113 mergetool) _git_mergetool;;
2114 merge-base) _git_merge_base ;;
2115 mv) _git_mv ;;
2116 name-rev) _git_name_rev ;;
2117 pull) _git_pull ;;
2118 push) _git_push ;;
2119 rebase) _git_rebase ;;
2120 remote) _git_remote ;;
2121 reset) _git_reset ;;
2122 revert) _git_revert ;;
2123 rm) _git_rm ;;
2124 send-email) _git_send_email ;;
2125 shortlog) _git_shortlog ;;
2126 show) _git_show ;;
2127 show-branch) _git_show_branch ;;
2128 stash) _git_stash ;;
2129 stage) _git_add ;;
2130 submodule) _git_submodule ;;
2131 svn) _git_svn ;;
2132 tag) _git_tag ;;
2133 whatchanged) _git_log ;;
2134 *) COMPREPLY=() ;;
2135 esac
2138 _gitk ()
2140 __git_has_doubledash && return
2142 local cur="${COMP_WORDS[COMP_CWORD]}"
2143 local g="$(__gitdir)"
2144 local merge=""
2145 if [ -f "$g/MERGE_HEAD" ]; then
2146 merge="--merge"
2148 case "$cur" in
2149 --*)
2150 __gitcomp "
2151 $__git_log_common_options
2152 $__git_log_gitk_options
2153 $merge
2155 return
2157 esac
2158 __git_complete_revlist
2161 complete -o bashdefault -o default -o nospace -F _git git 2>/dev/null \
2162 || complete -o default -o nospace -F _git git
2163 complete -o bashdefault -o default -o nospace -F _gitk gitk 2>/dev/null \
2164 || complete -o default -o nospace -F _gitk gitk
2166 # The following are necessary only for Cygwin, and only are needed
2167 # when the user has tab-completed the executable name and consequently
2168 # included the '.exe' suffix.
2170 if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
2171 complete -o bashdefault -o default -o nospace -F _git git.exe 2>/dev/null \
2172 || complete -o default -o nospace -F _git git.exe