bash: add support for 'git stash pop --index' option
[git.git] / contrib / completion / git-completion.bash
blobcc94ef44b2910e96b60bdf2b184c4adcf89dc2d5
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 # You can also see if currently something is stashed, by setting
44 # GIT_PS1_SHOWSTASHSTATE to a nonempty value. If something is stashed,
45 # then a '$' will be shown next to the branch name.
47 # To submit patches:
49 # *) Read Documentation/SubmittingPatches
50 # *) Send all patches to the current maintainer:
52 # "Shawn O. Pearce" <spearce@spearce.org>
54 # *) Always CC the Git mailing list:
56 # git@vger.kernel.org
59 case "$COMP_WORDBREAKS" in
60 *:*) : great ;;
61 *) COMP_WORDBREAKS="$COMP_WORDBREAKS:"
62 esac
64 # __gitdir accepts 0 or 1 arguments (i.e., location)
65 # returns location of .git repo
66 __gitdir ()
68 if [ -z "${1-}" ]; then
69 if [ -n "${__git_dir-}" ]; then
70 echo "$__git_dir"
71 elif [ -d .git ]; then
72 echo .git
73 else
74 git rev-parse --git-dir 2>/dev/null
76 elif [ -d "$1/.git" ]; then
77 echo "$1/.git"
78 else
79 echo "$1"
83 # __git_ps1 accepts 0 or 1 arguments (i.e., format string)
84 # returns text to add to bash PS1 prompt (includes branch name)
85 __git_ps1 ()
87 local g="$(__gitdir)"
88 if [ -n "$g" ]; then
89 local r
90 local b
91 if [ -f "$g/rebase-merge/interactive" ]; then
92 r="|REBASE-i"
93 b="$(cat "$g/rebase-merge/head-name")"
94 elif [ -d "$g/rebase-merge" ]; then
95 r="|REBASE-m"
96 b="$(cat "$g/rebase-merge/head-name")"
97 else
98 if [ -d "$g/rebase-apply" ]; then
99 if [ -f "$g/rebase-apply/rebasing" ]; then
100 r="|REBASE"
101 elif [ -f "$g/rebase-apply/applying" ]; then
102 r="|AM"
103 else
104 r="|AM/REBASE"
106 elif [ -f "$g/MERGE_HEAD" ]; then
107 r="|MERGING"
108 elif [ -f "$g/BISECT_LOG" ]; then
109 r="|BISECTING"
112 b="$(git symbolic-ref HEAD 2>/dev/null)" || {
114 b="$(
115 case "${GIT_PS1_DESCRIBE_STYLE-}" in
116 (contains)
117 git describe --contains HEAD ;;
118 (branch)
119 git describe --contains --all HEAD ;;
120 (describe)
121 git describe HEAD ;;
122 (* | default)
123 git describe --exact-match HEAD ;;
124 esac 2>/dev/null)" ||
126 b="$(cut -c1-7 "$g/HEAD" 2>/dev/null)..." ||
127 b="unknown"
128 b="($b)"
132 local w
133 local i
134 local s
135 local c
137 if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then
138 if [ "true" = "$(git rev-parse --is-bare-repository 2>/dev/null)" ]; then
139 c="BARE:"
140 else
141 b="GIT_DIR!"
143 elif [ "true" = "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
144 if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ]; then
145 if [ "$(git config --bool bash.showDirtyState)" != "false" ]; then
146 git diff --no-ext-diff --ignore-submodules \
147 --quiet --exit-code || w="*"
148 if git rev-parse --quiet --verify HEAD >/dev/null; then
149 git diff-index --cached --quiet \
150 --ignore-submodules HEAD -- || i="+"
151 else
152 i="#"
156 if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ]; then
157 git rev-parse --verify refs/stash >/dev/null 2>&1 && s="$"
161 if [ -n "${1-}" ]; then
162 printf "$1" "$c${b##refs/heads/}$w$i$s$r"
163 else
164 printf " (%s)" "$c${b##refs/heads/}$w$i$s$r"
169 # __gitcomp_1 requires 2 arguments
170 __gitcomp_1 ()
172 local c IFS=' '$'\t'$'\n'
173 for c in $1; do
174 case "$c$2" in
175 --*=*) printf %s$'\n' "$c$2" ;;
176 *.) printf %s$'\n' "$c$2" ;;
177 *) printf %s$'\n' "$c$2 " ;;
178 esac
179 done
182 # __gitcomp accepts 1, 2, 3, or 4 arguments
183 # generates completion reply with compgen
184 __gitcomp ()
186 local cur="${COMP_WORDS[COMP_CWORD]}"
187 if [ $# -gt 2 ]; then
188 cur="$3"
190 case "$cur" in
191 --*=)
192 COMPREPLY=()
195 local IFS=$'\n'
196 COMPREPLY=($(compgen -P "${2-}" \
197 -W "$(__gitcomp_1 "${1-}" "${4-}")" \
198 -- "$cur"))
200 esac
203 # __git_heads accepts 0 or 1 arguments (to pass to __gitdir)
204 __git_heads ()
206 local cmd i is_hash=y dir="$(__gitdir "${1-}")"
207 if [ -d "$dir" ]; then
208 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
209 refs/heads
210 return
212 for i in $(git ls-remote "${1-}" 2>/dev/null); do
213 case "$is_hash,$i" in
214 y,*) is_hash=n ;;
215 n,*^{}) is_hash=y ;;
216 n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
217 n,*) is_hash=y; echo "$i" ;;
218 esac
219 done
222 # __git_tags accepts 0 or 1 arguments (to pass to __gitdir)
223 __git_tags ()
225 local cmd i is_hash=y dir="$(__gitdir "${1-}")"
226 if [ -d "$dir" ]; then
227 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
228 refs/tags
229 return
231 for i in $(git ls-remote "${1-}" 2>/dev/null); do
232 case "$is_hash,$i" in
233 y,*) is_hash=n ;;
234 n,*^{}) is_hash=y ;;
235 n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
236 n,*) is_hash=y; echo "$i" ;;
237 esac
238 done
241 # __git_refs accepts 0 or 1 arguments (to pass to __gitdir)
242 __git_refs ()
244 local i is_hash=y dir="$(__gitdir "${1-}")"
245 local cur="${COMP_WORDS[COMP_CWORD]}" format refs
246 if [ -d "$dir" ]; then
247 case "$cur" in
248 refs|refs/*)
249 format="refname"
250 refs="${cur%/*}"
253 if [ -e "$dir/HEAD" ]; then echo HEAD; fi
254 format="refname:short"
255 refs="refs/tags refs/heads refs/remotes"
257 esac
258 git --git-dir="$dir" for-each-ref --format="%($format)" \
259 $refs
260 return
262 for i in $(git ls-remote "$dir" 2>/dev/null); do
263 case "$is_hash,$i" in
264 y,*) is_hash=n ;;
265 n,*^{}) is_hash=y ;;
266 n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
267 n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
268 n,refs/remotes/*) is_hash=y; echo "${i#refs/remotes/}" ;;
269 n,*) is_hash=y; echo "$i" ;;
270 esac
271 done
274 # __git_refs2 requires 1 argument (to pass to __git_refs)
275 __git_refs2 ()
277 local i
278 for i in $(__git_refs "$1"); do
279 echo "$i:$i"
280 done
283 # __git_refs_remotes requires 1 argument (to pass to ls-remote)
284 __git_refs_remotes ()
286 local cmd i is_hash=y
287 for i in $(git ls-remote "$1" 2>/dev/null); do
288 case "$is_hash,$i" in
289 n,refs/heads/*)
290 is_hash=y
291 echo "$i:refs/remotes/$1/${i#refs/heads/}"
293 y,*) is_hash=n ;;
294 n,*^{}) is_hash=y ;;
295 n,refs/tags/*) is_hash=y;;
296 n,*) is_hash=y; ;;
297 esac
298 done
301 __git_remotes ()
303 local i ngoff IFS=$'\n' d="$(__gitdir)"
304 shopt -q nullglob || ngoff=1
305 shopt -s nullglob
306 for i in "$d/remotes"/*; do
307 echo ${i#$d/remotes/}
308 done
309 [ "$ngoff" ] && shopt -u nullglob
310 for i in $(git --git-dir="$d" config --list); do
311 case "$i" in
312 remote.*.url=*)
313 i="${i#remote.}"
314 echo "${i/.url=*/}"
316 esac
317 done
320 __git_merge_strategies ()
322 if [ -n "${__git_merge_strategylist-}" ]; then
323 echo "$__git_merge_strategylist"
324 return
326 git merge -s help 2>&1 |
327 sed -n -e '/[Aa]vailable strategies are: /,/^$/{
328 s/\.$//
329 s/.*://
330 s/^[ ]*//
331 s/[ ]*$//
335 __git_merge_strategylist=
336 __git_merge_strategylist=$(__git_merge_strategies 2>/dev/null)
338 __git_complete_file ()
340 local pfx ls ref cur="${COMP_WORDS[COMP_CWORD]}"
341 case "$cur" in
342 ?*:*)
343 ref="${cur%%:*}"
344 cur="${cur#*:}"
345 case "$cur" in
346 ?*/*)
347 pfx="${cur%/*}"
348 cur="${cur##*/}"
349 ls="$ref:$pfx"
350 pfx="$pfx/"
353 ls="$ref"
355 esac
357 case "$COMP_WORDBREAKS" in
358 *:*) : great ;;
359 *) pfx="$ref:$pfx" ;;
360 esac
362 local IFS=$'\n'
363 COMPREPLY=($(compgen -P "$pfx" \
364 -W "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \
365 | sed '/^100... blob /{
366 s,^.* ,,
367 s,$, ,
369 /^120000 blob /{
370 s,^.* ,,
371 s,$, ,
373 /^040000 tree /{
374 s,^.* ,,
375 s,$,/,
377 s/^.* //')" \
378 -- "$cur"))
381 __gitcomp "$(__git_refs)"
383 esac
386 __git_complete_revlist ()
388 local pfx cur="${COMP_WORDS[COMP_CWORD]}"
389 case "$cur" in
390 *...*)
391 pfx="${cur%...*}..."
392 cur="${cur#*...}"
393 __gitcomp "$(__git_refs)" "$pfx" "$cur"
395 *..*)
396 pfx="${cur%..*}.."
397 cur="${cur#*..}"
398 __gitcomp "$(__git_refs)" "$pfx" "$cur"
401 __gitcomp "$(__git_refs)"
403 esac
406 __git_complete_remote_or_refspec ()
408 local cmd="${COMP_WORDS[1]}"
409 local cur="${COMP_WORDS[COMP_CWORD]}"
410 local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0
411 while [ $c -lt $COMP_CWORD ]; do
412 i="${COMP_WORDS[c]}"
413 case "$i" in
414 --all|--mirror) [ "$cmd" = "push" ] && no_complete_refspec=1 ;;
415 -*) ;;
416 *) remote="$i"; break ;;
417 esac
418 c=$((++c))
419 done
420 if [ -z "$remote" ]; then
421 __gitcomp "$(__git_remotes)"
422 return
424 if [ $no_complete_refspec = 1 ]; then
425 COMPREPLY=()
426 return
428 [ "$remote" = "." ] && remote=
429 case "$cur" in
430 *:*)
431 case "$COMP_WORDBREAKS" in
432 *:*) : great ;;
433 *) pfx="${cur%%:*}:" ;;
434 esac
435 cur="${cur#*:}"
436 lhs=0
439 pfx="+"
440 cur="${cur#+}"
442 esac
443 case "$cmd" in
444 fetch)
445 if [ $lhs = 1 ]; then
446 __gitcomp "$(__git_refs2 "$remote")" "$pfx" "$cur"
447 else
448 __gitcomp "$(__git_refs)" "$pfx" "$cur"
451 pull)
452 if [ $lhs = 1 ]; then
453 __gitcomp "$(__git_refs "$remote")" "$pfx" "$cur"
454 else
455 __gitcomp "$(__git_refs)" "$pfx" "$cur"
458 push)
459 if [ $lhs = 1 ]; then
460 __gitcomp "$(__git_refs)" "$pfx" "$cur"
461 else
462 __gitcomp "$(__git_refs "$remote")" "$pfx" "$cur"
465 esac
468 __git_complete_strategy ()
470 case "${COMP_WORDS[COMP_CWORD-1]}" in
471 -s|--strategy)
472 __gitcomp "$(__git_merge_strategies)"
473 return 0
474 esac
475 local cur="${COMP_WORDS[COMP_CWORD]}"
476 case "$cur" in
477 --strategy=*)
478 __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}"
479 return 0
481 esac
482 return 1
485 __git_all_commands ()
487 if [ -n "${__git_all_commandlist-}" ]; then
488 echo "$__git_all_commandlist"
489 return
491 local i IFS=" "$'\n'
492 for i in $(git help -a|egrep '^ ')
494 case $i in
495 *--*) : helper pattern;;
496 *) echo $i;;
497 esac
498 done
500 __git_all_commandlist=
501 __git_all_commandlist="$(__git_all_commands 2>/dev/null)"
503 __git_porcelain_commands ()
505 if [ -n "${__git_porcelain_commandlist-}" ]; then
506 echo "$__git_porcelain_commandlist"
507 return
509 local i IFS=" "$'\n'
510 for i in "help" $(__git_all_commands)
512 case $i in
513 *--*) : helper pattern;;
514 applymbox) : ask gittus;;
515 applypatch) : ask gittus;;
516 archimport) : import;;
517 cat-file) : plumbing;;
518 check-attr) : plumbing;;
519 check-ref-format) : plumbing;;
520 checkout-index) : plumbing;;
521 commit-tree) : plumbing;;
522 count-objects) : infrequent;;
523 cvsexportcommit) : export;;
524 cvsimport) : import;;
525 cvsserver) : daemon;;
526 daemon) : daemon;;
527 diff-files) : plumbing;;
528 diff-index) : plumbing;;
529 diff-tree) : plumbing;;
530 fast-import) : import;;
531 fast-export) : export;;
532 fsck-objects) : plumbing;;
533 fetch-pack) : plumbing;;
534 fmt-merge-msg) : plumbing;;
535 for-each-ref) : plumbing;;
536 hash-object) : plumbing;;
537 http-*) : transport;;
538 index-pack) : plumbing;;
539 init-db) : deprecated;;
540 local-fetch) : plumbing;;
541 lost-found) : infrequent;;
542 ls-files) : plumbing;;
543 ls-remote) : plumbing;;
544 ls-tree) : plumbing;;
545 mailinfo) : plumbing;;
546 mailsplit) : plumbing;;
547 merge-*) : plumbing;;
548 mktree) : plumbing;;
549 mktag) : plumbing;;
550 pack-objects) : plumbing;;
551 pack-redundant) : plumbing;;
552 pack-refs) : plumbing;;
553 parse-remote) : plumbing;;
554 patch-id) : plumbing;;
555 peek-remote) : plumbing;;
556 prune) : plumbing;;
557 prune-packed) : plumbing;;
558 quiltimport) : import;;
559 read-tree) : plumbing;;
560 receive-pack) : plumbing;;
561 reflog) : plumbing;;
562 repo-config) : deprecated;;
563 rerere) : plumbing;;
564 rev-list) : plumbing;;
565 rev-parse) : plumbing;;
566 runstatus) : plumbing;;
567 sh-setup) : internal;;
568 shell) : daemon;;
569 show-ref) : plumbing;;
570 send-pack) : plumbing;;
571 show-index) : plumbing;;
572 ssh-*) : transport;;
573 stripspace) : plumbing;;
574 symbolic-ref) : plumbing;;
575 tar-tree) : deprecated;;
576 unpack-file) : plumbing;;
577 unpack-objects) : plumbing;;
578 update-index) : plumbing;;
579 update-ref) : plumbing;;
580 update-server-info) : daemon;;
581 upload-archive) : plumbing;;
582 upload-pack) : plumbing;;
583 write-tree) : plumbing;;
584 var) : infrequent;;
585 verify-pack) : infrequent;;
586 verify-tag) : plumbing;;
587 *) echo $i;;
588 esac
589 done
591 __git_porcelain_commandlist=
592 __git_porcelain_commandlist="$(__git_porcelain_commands 2>/dev/null)"
594 __git_aliases ()
596 local i IFS=$'\n'
597 for i in $(git --git-dir="$(__gitdir)" config --list); do
598 case "$i" in
599 alias.*)
600 i="${i#alias.}"
601 echo "${i/=*/}"
603 esac
604 done
607 # __git_aliased_command requires 1 argument
608 __git_aliased_command ()
610 local word cmdline=$(git --git-dir="$(__gitdir)" \
611 config --get "alias.$1")
612 for word in $cmdline; do
613 if [ "${word##-*}" ]; then
614 echo $word
615 return
617 done
620 # __git_find_subcommand requires 1 argument
621 __git_find_subcommand ()
623 local word subcommand c=1
625 while [ $c -lt $COMP_CWORD ]; do
626 word="${COMP_WORDS[c]}"
627 for subcommand in $1; do
628 if [ "$subcommand" = "$word" ]; then
629 echo "$subcommand"
630 return
632 done
633 c=$((++c))
634 done
637 __git_has_doubledash ()
639 local c=1
640 while [ $c -lt $COMP_CWORD ]; do
641 if [ "--" = "${COMP_WORDS[c]}" ]; then
642 return 0
644 c=$((++c))
645 done
646 return 1
649 __git_whitespacelist="nowarn warn error error-all fix"
651 _git_am ()
653 local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)"
654 if [ -d "$dir"/rebase-apply ]; then
655 __gitcomp "--skip --resolved --abort"
656 return
658 case "$cur" in
659 --whitespace=*)
660 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
661 return
663 --*)
664 __gitcomp "
665 --3way --committer-date-is-author-date --ignore-date
666 --interactive --keep --no-utf8 --signoff --utf8
667 --whitespace=
669 return
670 esac
671 COMPREPLY=()
674 _git_apply ()
676 local cur="${COMP_WORDS[COMP_CWORD]}"
677 case "$cur" in
678 --whitespace=*)
679 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
680 return
682 --*)
683 __gitcomp "
684 --stat --numstat --summary --check --index
685 --cached --index-info --reverse --reject --unidiff-zero
686 --apply --no-add --exclude=
687 --whitespace= --inaccurate-eof --verbose
689 return
690 esac
691 COMPREPLY=()
694 _git_add ()
696 __git_has_doubledash && return
698 local cur="${COMP_WORDS[COMP_CWORD]}"
699 case "$cur" in
700 --*)
701 __gitcomp "
702 --interactive --refresh --patch --update --dry-run
703 --ignore-errors --intent-to-add
705 return
706 esac
707 COMPREPLY=()
710 _git_archive ()
712 local cur="${COMP_WORDS[COMP_CWORD]}"
713 case "$cur" in
714 --format=*)
715 __gitcomp "$(git archive --list)" "" "${cur##--format=}"
716 return
718 --remote=*)
719 __gitcomp "$(__git_remotes)" "" "${cur##--remote=}"
720 return
722 --*)
723 __gitcomp "
724 --format= --list --verbose
725 --prefix= --remote= --exec=
727 return
729 esac
730 __git_complete_file
733 _git_bisect ()
735 __git_has_doubledash && return
737 local subcommands="start bad good skip reset visualize replay log run"
738 local subcommand="$(__git_find_subcommand "$subcommands")"
739 if [ -z "$subcommand" ]; then
740 __gitcomp "$subcommands"
741 return
744 case "$subcommand" in
745 bad|good|reset|skip)
746 __gitcomp "$(__git_refs)"
749 COMPREPLY=()
751 esac
754 _git_branch ()
756 local i c=1 only_local_ref="n" has_r="n"
758 while [ $c -lt $COMP_CWORD ]; do
759 i="${COMP_WORDS[c]}"
760 case "$i" in
761 -d|-m) only_local_ref="y" ;;
762 -r) has_r="y" ;;
763 esac
764 c=$((++c))
765 done
767 case "${COMP_WORDS[COMP_CWORD]}" in
768 --*)
769 __gitcomp "
770 --color --no-color --verbose --abbrev= --no-abbrev
771 --track --no-track --contains --merged --no-merged
775 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
776 __gitcomp "$(__git_heads)"
777 else
778 __gitcomp "$(__git_refs)"
781 esac
784 _git_bundle ()
786 local cmd="${COMP_WORDS[2]}"
787 case "$COMP_CWORD" in
789 __gitcomp "create list-heads verify unbundle"
792 # looking for a file
795 case "$cmd" in
796 create)
797 __git_complete_revlist
799 esac
801 esac
804 _git_checkout ()
806 __git_has_doubledash && return
808 __gitcomp "$(__git_refs)"
811 _git_cherry ()
813 __gitcomp "$(__git_refs)"
816 _git_cherry_pick ()
818 local cur="${COMP_WORDS[COMP_CWORD]}"
819 case "$cur" in
820 --*)
821 __gitcomp "--edit --no-commit"
824 __gitcomp "$(__git_refs)"
826 esac
829 _git_clean ()
831 __git_has_doubledash && return
833 local cur="${COMP_WORDS[COMP_CWORD]}"
834 case "$cur" in
835 --*)
836 __gitcomp "--dry-run --quiet"
837 return
839 esac
840 COMPREPLY=()
843 _git_clone ()
845 local cur="${COMP_WORDS[COMP_CWORD]}"
846 case "$cur" in
847 --*)
848 __gitcomp "
849 --local
850 --no-hardlinks
851 --shared
852 --reference
853 --quiet
854 --no-checkout
855 --bare
856 --mirror
857 --origin
858 --upload-pack
859 --template=
860 --depth
862 return
864 esac
865 COMPREPLY=()
868 _git_commit ()
870 __git_has_doubledash && return
872 local cur="${COMP_WORDS[COMP_CWORD]}"
873 case "$cur" in
874 --*)
875 __gitcomp "
876 --all --author= --signoff --verify --no-verify
877 --edit --amend --include --only --interactive
879 return
880 esac
881 COMPREPLY=()
884 _git_describe ()
886 local cur="${COMP_WORDS[COMP_CWORD]}"
887 case "$cur" in
888 --*)
889 __gitcomp "
890 --all --tags --contains --abbrev= --candidates=
891 --exact-match --debug --long --match --always
893 return
894 esac
895 __gitcomp "$(__git_refs)"
898 __git_diff_common_options="--stat --numstat --shortstat --summary
899 --patch-with-stat --name-only --name-status --color
900 --no-color --color-words --no-renames --check
901 --full-index --binary --abbrev --diff-filter=
902 --find-copies-harder
903 --text --ignore-space-at-eol --ignore-space-change
904 --ignore-all-space --exit-code --quiet --ext-diff
905 --no-ext-diff
906 --no-prefix --src-prefix= --dst-prefix=
907 --inter-hunk-context=
908 --patience
909 --raw
912 _git_diff ()
914 __git_has_doubledash && return
916 local cur="${COMP_WORDS[COMP_CWORD]}"
917 case "$cur" in
918 --*)
919 __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
920 --base --ours --theirs
921 $__git_diff_common_options
923 return
925 esac
926 __git_complete_file
929 __git_mergetools_common="diffuse ecmerge emerge kdiff3 meld opendiff
930 tkdiff vimdiff gvimdiff xxdiff
933 _git_difftool ()
935 local cur="${COMP_WORDS[COMP_CWORD]}"
936 case "$cur" in
937 --tool=*)
938 __gitcomp "$__git_mergetools_common kompare" "" "${cur##--tool=}"
939 return
941 --*)
942 __gitcomp "--tool="
943 return
945 esac
946 COMPREPLY=()
949 __git_fetch_options="
950 --quiet --verbose --append --upload-pack --force --keep --depth=
951 --tags --no-tags
954 _git_fetch ()
956 local cur="${COMP_WORDS[COMP_CWORD]}"
957 case "$cur" in
958 --*)
959 __gitcomp "$__git_fetch_options"
960 return
962 esac
963 __git_complete_remote_or_refspec
966 _git_format_patch ()
968 local cur="${COMP_WORDS[COMP_CWORD]}"
969 case "$cur" in
970 --thread=*)
971 __gitcomp "
972 deep shallow
973 " "" "${cur##--thread=}"
974 return
976 --*)
977 __gitcomp "
978 --stdout --attach --no-attach --thread --thread=
979 --output-directory
980 --numbered --start-number
981 --numbered-files
982 --keep-subject
983 --signoff
984 --in-reply-to= --cc=
985 --full-index --binary
986 --not --all
987 --cover-letter
988 --no-prefix --src-prefix= --dst-prefix=
989 --inline --suffix= --ignore-if-in-upstream
990 --subject-prefix=
992 return
994 esac
995 __git_complete_revlist
998 _git_fsck ()
1000 local cur="${COMP_WORDS[COMP_CWORD]}"
1001 case "$cur" in
1002 --*)
1003 __gitcomp "
1004 --tags --root --unreachable --cache --no-reflogs --full
1005 --strict --verbose --lost-found
1007 return
1009 esac
1010 COMPREPLY=()
1013 _git_gc ()
1015 local cur="${COMP_WORDS[COMP_CWORD]}"
1016 case "$cur" in
1017 --*)
1018 __gitcomp "--prune --aggressive"
1019 return
1021 esac
1022 COMPREPLY=()
1025 _git_grep ()
1027 __git_has_doubledash && return
1029 local cur="${COMP_WORDS[COMP_CWORD]}"
1030 case "$cur" in
1031 --*)
1032 __gitcomp "
1033 --cached
1034 --text --ignore-case --word-regexp --invert-match
1035 --full-name
1036 --extended-regexp --basic-regexp --fixed-strings
1037 --files-with-matches --name-only
1038 --files-without-match
1039 --count
1040 --and --or --not --all-match
1042 return
1044 esac
1045 COMPREPLY=()
1048 _git_help ()
1050 local cur="${COMP_WORDS[COMP_CWORD]}"
1051 case "$cur" in
1052 --*)
1053 __gitcomp "--all --info --man --web"
1054 return
1056 esac
1057 __gitcomp "$(__git_all_commands)
1058 attributes cli core-tutorial cvs-migration
1059 diffcore gitk glossary hooks ignore modules
1060 repository-layout tutorial tutorial-2
1061 workflows
1065 _git_init ()
1067 local cur="${COMP_WORDS[COMP_CWORD]}"
1068 case "$cur" in
1069 --shared=*)
1070 __gitcomp "
1071 false true umask group all world everybody
1072 " "" "${cur##--shared=}"
1073 return
1075 --*)
1076 __gitcomp "--quiet --bare --template= --shared --shared="
1077 return
1079 esac
1080 COMPREPLY=()
1083 _git_ls_files ()
1085 __git_has_doubledash && return
1087 local cur="${COMP_WORDS[COMP_CWORD]}"
1088 case "$cur" in
1089 --*)
1090 __gitcomp "--cached --deleted --modified --others --ignored
1091 --stage --directory --no-empty-directory --unmerged
1092 --killed --exclude= --exclude-from=
1093 --exclude-per-directory= --exclude-standard
1094 --error-unmatch --with-tree= --full-name
1095 --abbrev --ignored --exclude-per-directory
1097 return
1099 esac
1100 COMPREPLY=()
1103 _git_ls_remote ()
1105 __gitcomp "$(__git_remotes)"
1108 _git_ls_tree ()
1110 __git_complete_file
1113 # Options that go well for log, shortlog and gitk
1114 __git_log_common_options="
1115 --not --all
1116 --branches --tags --remotes
1117 --first-parent --no-merges
1118 --max-count=
1119 --max-age= --since= --after=
1120 --min-age= --until= --before=
1122 # Options that go well for log and gitk (not shortlog)
1123 __git_log_gitk_options="
1124 --dense --sparse --full-history
1125 --simplify-merges --simplify-by-decoration
1126 --left-right
1128 # Options that go well for log and shortlog (not gitk)
1129 __git_log_shortlog_options="
1130 --author= --committer= --grep=
1131 --all-match
1134 __git_log_pretty_formats="oneline short medium full fuller email raw format:"
1135 __git_log_date_formats="relative iso8601 rfc2822 short local default raw"
1137 _git_log ()
1139 __git_has_doubledash && return
1141 local cur="${COMP_WORDS[COMP_CWORD]}"
1142 local g="$(git rev-parse --git-dir 2>/dev/null)"
1143 local merge=""
1144 if [ -f "$g/MERGE_HEAD" ]; then
1145 merge="--merge"
1147 case "$cur" in
1148 --pretty=*)
1149 __gitcomp "$__git_log_pretty_formats
1150 " "" "${cur##--pretty=}"
1151 return
1153 --format=*)
1154 __gitcomp "$__git_log_pretty_formats
1155 " "" "${cur##--format=}"
1156 return
1158 --date=*)
1159 __gitcomp "$__git_log_date_formats" "" "${cur##--date=}"
1160 return
1162 --*)
1163 __gitcomp "
1164 $__git_log_common_options
1165 $__git_log_shortlog_options
1166 $__git_log_gitk_options
1167 --root --topo-order --date-order --reverse
1168 --follow
1169 --abbrev-commit --abbrev=
1170 --relative-date --date=
1171 --pretty= --format= --oneline
1172 --cherry-pick
1173 --graph
1174 --decorate
1175 --walk-reflogs
1176 --parents --children
1177 $merge
1178 $__git_diff_common_options
1179 --pickaxe-all --pickaxe-regex
1181 return
1183 esac
1184 __git_complete_revlist
1187 __git_merge_options="
1188 --no-commit --no-stat --log --no-log --squash --strategy
1189 --commit --stat --no-squash --ff --no-ff
1192 _git_merge ()
1194 __git_complete_strategy && return
1196 local cur="${COMP_WORDS[COMP_CWORD]}"
1197 case "$cur" in
1198 --*)
1199 __gitcomp "$__git_merge_options"
1200 return
1201 esac
1202 __gitcomp "$(__git_refs)"
1205 _git_mergetool ()
1207 local cur="${COMP_WORDS[COMP_CWORD]}"
1208 case "$cur" in
1209 --tool=*)
1210 __gitcomp "$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"
1211 return
1213 --*)
1214 __gitcomp "--tool="
1215 return
1217 esac
1218 COMPREPLY=()
1221 _git_merge_base ()
1223 __gitcomp "$(__git_refs)"
1226 _git_mv ()
1228 local cur="${COMP_WORDS[COMP_CWORD]}"
1229 case "$cur" in
1230 --*)
1231 __gitcomp "--dry-run"
1232 return
1234 esac
1235 COMPREPLY=()
1238 _git_name_rev ()
1240 __gitcomp "--tags --all --stdin"
1243 _git_pull ()
1245 __git_complete_strategy && return
1247 local cur="${COMP_WORDS[COMP_CWORD]}"
1248 case "$cur" in
1249 --*)
1250 __gitcomp "
1251 --rebase --no-rebase
1252 $__git_merge_options
1253 $__git_fetch_options
1255 return
1257 esac
1258 __git_complete_remote_or_refspec
1261 _git_push ()
1263 local cur="${COMP_WORDS[COMP_CWORD]}"
1264 case "${COMP_WORDS[COMP_CWORD-1]}" in
1265 --repo)
1266 __gitcomp "$(__git_remotes)"
1267 return
1268 esac
1269 case "$cur" in
1270 --repo=*)
1271 __gitcomp "$(__git_remotes)" "" "${cur##--repo=}"
1272 return
1274 --*)
1275 __gitcomp "
1276 --all --mirror --tags --dry-run --force --verbose
1277 --receive-pack= --repo=
1279 return
1281 esac
1282 __git_complete_remote_or_refspec
1285 _git_rebase ()
1287 local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)"
1288 if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
1289 __gitcomp "--continue --skip --abort"
1290 return
1292 __git_complete_strategy && return
1293 case "$cur" in
1294 --*)
1295 __gitcomp "--onto --merge --strategy --interactive"
1296 return
1297 esac
1298 __gitcomp "$(__git_refs)"
1301 __git_send_email_confirm_options="always never auto cc compose"
1302 __git_send_email_suppresscc_options="author self cc ccbody sob cccmd body all"
1304 _git_send_email ()
1306 local cur="${COMP_WORDS[COMP_CWORD]}"
1307 case "$cur" in
1308 --confirm=*)
1309 __gitcomp "
1310 $__git_send_email_confirm_options
1311 " "" "${cur##--confirm=}"
1312 return
1314 --suppress-cc=*)
1315 __gitcomp "
1316 $__git_send_email_suppresscc_options
1317 " "" "${cur##--suppress-cc=}"
1319 return
1321 --smtp-encryption=*)
1322 __gitcomp "ssl tls" "" "${cur##--smtp-encryption=}"
1323 return
1325 --*)
1326 __gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to
1327 --compose --confirm= --dry-run --envelope-sender
1328 --from --identity
1329 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
1330 --no-suppress-from --no-thread --quiet
1331 --signed-off-by-cc --smtp-pass --smtp-server
1332 --smtp-server-port --smtp-encryption= --smtp-user
1333 --subject --suppress-cc= --suppress-from --thread --to
1334 --validate --no-validate"
1335 return
1337 esac
1338 COMPREPLY=()
1341 __git_config_get_set_variables ()
1343 local prevword word config_file= c=$COMP_CWORD
1344 while [ $c -gt 1 ]; do
1345 word="${COMP_WORDS[c]}"
1346 case "$word" in
1347 --global|--system|--file=*)
1348 config_file="$word"
1349 break
1351 -f|--file)
1352 config_file="$word $prevword"
1353 break
1355 esac
1356 prevword=$word
1357 c=$((--c))
1358 done
1360 for i in $(git --git-dir="$(__gitdir)" config $config_file --list \
1361 2>/dev/null); do
1362 case "$i" in
1363 *.*)
1364 echo "${i/=*/}"
1366 esac
1367 done
1370 _git_config ()
1372 local cur="${COMP_WORDS[COMP_CWORD]}"
1373 local prv="${COMP_WORDS[COMP_CWORD-1]}"
1374 case "$prv" in
1375 branch.*.remote)
1376 __gitcomp "$(__git_remotes)"
1377 return
1379 branch.*.merge)
1380 __gitcomp "$(__git_refs)"
1381 return
1383 remote.*.fetch)
1384 local remote="${prv#remote.}"
1385 remote="${remote%.fetch}"
1386 __gitcomp "$(__git_refs_remotes "$remote")"
1387 return
1389 remote.*.push)
1390 local remote="${prv#remote.}"
1391 remote="${remote%.push}"
1392 __gitcomp "$(git --git-dir="$(__gitdir)" \
1393 for-each-ref --format='%(refname):%(refname)' \
1394 refs/heads)"
1395 return
1397 pull.twohead|pull.octopus)
1398 __gitcomp "$(__git_merge_strategies)"
1399 return
1401 color.branch|color.diff|color.interactive|\
1402 color.showbranch|color.status|color.ui)
1403 __gitcomp "always never auto"
1404 return
1406 color.pager)
1407 __gitcomp "false true"
1408 return
1410 color.*.*)
1411 __gitcomp "
1412 normal black red green yellow blue magenta cyan white
1413 bold dim ul blink reverse
1415 return
1417 help.format)
1418 __gitcomp "man info web html"
1419 return
1421 log.date)
1422 __gitcomp "$__git_log_date_formats"
1423 return
1425 sendemail.aliasesfiletype)
1426 __gitcomp "mutt mailrc pine elm gnus"
1427 return
1429 sendemail.confirm)
1430 __gitcomp "$__git_send_email_confirm_options"
1431 return
1433 sendemail.suppresscc)
1434 __gitcomp "$__git_send_email_suppresscc_options"
1435 return
1437 --get|--get-all|--unset|--unset-all)
1438 __gitcomp "$(__git_config_get_set_variables)"
1439 return
1441 *.*)
1442 COMPREPLY=()
1443 return
1445 esac
1446 case "$cur" in
1447 --*)
1448 __gitcomp "
1449 --global --system --file=
1450 --list --replace-all
1451 --get --get-all --get-regexp
1452 --add --unset --unset-all
1453 --remove-section --rename-section
1455 return
1457 branch.*.*)
1458 local pfx="${cur%.*}."
1459 cur="${cur##*.}"
1460 __gitcomp "remote merge mergeoptions" "$pfx" "$cur"
1461 return
1463 branch.*)
1464 local pfx="${cur%.*}."
1465 cur="${cur#*.}"
1466 __gitcomp "$(__git_heads)" "$pfx" "$cur" "."
1467 return
1469 guitool.*.*)
1470 local pfx="${cur%.*}."
1471 cur="${cur##*.}"
1472 __gitcomp "
1473 argprompt cmd confirm needsfile noconsole norescan
1474 prompt revprompt revunmerged title
1475 " "$pfx" "$cur"
1476 return
1478 difftool.*.*)
1479 local pfx="${cur%.*}."
1480 cur="${cur##*.}"
1481 __gitcomp "cmd path" "$pfx" "$cur"
1482 return
1484 man.*.*)
1485 local pfx="${cur%.*}."
1486 cur="${cur##*.}"
1487 __gitcomp "cmd path" "$pfx" "$cur"
1488 return
1490 mergetool.*.*)
1491 local pfx="${cur%.*}."
1492 cur="${cur##*.}"
1493 __gitcomp "cmd path trustExitCode" "$pfx" "$cur"
1494 return
1496 pager.*)
1497 local pfx="${cur%.*}."
1498 cur="${cur#*.}"
1499 __gitcomp "$(__git_all_commands)" "$pfx" "$cur"
1500 return
1502 remote.*.*)
1503 local pfx="${cur%.*}."
1504 cur="${cur##*.}"
1505 __gitcomp "
1506 url proxy fetch push mirror skipDefaultUpdate
1507 receivepack uploadpack tagopt
1508 " "$pfx" "$cur"
1509 return
1511 remote.*)
1512 local pfx="${cur%.*}."
1513 cur="${cur#*.}"
1514 __gitcomp "$(__git_remotes)" "$pfx" "$cur" "."
1515 return
1517 url.*.*)
1518 local pfx="${cur%.*}."
1519 cur="${cur##*.}"
1520 __gitcomp "insteadof" "$pfx" "$cur"
1521 return
1523 esac
1524 __gitcomp "
1525 alias.
1526 apply.whitespace
1527 branch.autosetupmerge
1528 branch.autosetuprebase
1529 clean.requireForce
1530 color.branch
1531 color.branch.current
1532 color.branch.local
1533 color.branch.plain
1534 color.branch.remote
1535 color.diff
1536 color.diff.commit
1537 color.diff.frag
1538 color.diff.meta
1539 color.diff.new
1540 color.diff.old
1541 color.diff.plain
1542 color.diff.whitespace
1543 color.grep
1544 color.grep.external
1545 color.grep.match
1546 color.interactive
1547 color.interactive.header
1548 color.interactive.help
1549 color.interactive.prompt
1550 color.pager
1551 color.showbranch
1552 color.status
1553 color.status.added
1554 color.status.changed
1555 color.status.header
1556 color.status.nobranch
1557 color.status.untracked
1558 color.status.updated
1559 color.ui
1560 commit.template
1561 core.autocrlf
1562 core.bare
1563 core.compression
1564 core.createObject
1565 core.deltaBaseCacheLimit
1566 core.editor
1567 core.excludesfile
1568 core.fileMode
1569 core.fsyncobjectfiles
1570 core.gitProxy
1571 core.ignoreCygwinFSTricks
1572 core.ignoreStat
1573 core.logAllRefUpdates
1574 core.loosecompression
1575 core.packedGitLimit
1576 core.packedGitWindowSize
1577 core.pager
1578 core.preferSymlinkRefs
1579 core.preloadindex
1580 core.quotepath
1581 core.repositoryFormatVersion
1582 core.safecrlf
1583 core.sharedRepository
1584 core.symlinks
1585 core.trustctime
1586 core.warnAmbiguousRefs
1587 core.whitespace
1588 core.worktree
1589 diff.autorefreshindex
1590 diff.external
1591 diff.mnemonicprefix
1592 diff.renameLimit
1593 diff.renameLimit.
1594 diff.renames
1595 diff.suppressBlankEmpty
1596 diff.tool
1597 diff.wordRegex
1598 difftool.
1599 difftool.prompt
1600 fetch.unpackLimit
1601 format.attach
1602 format.cc
1603 format.headers
1604 format.numbered
1605 format.pretty
1606 format.signoff
1607 format.subjectprefix
1608 format.suffix
1609 format.thread
1610 gc.aggressiveWindow
1611 gc.auto
1612 gc.autopacklimit
1613 gc.packrefs
1614 gc.pruneexpire
1615 gc.reflogexpire
1616 gc.reflogexpireunreachable
1617 gc.rerereresolved
1618 gc.rerereunresolved
1619 gitcvs.allbinary
1620 gitcvs.commitmsgannotation
1621 gitcvs.dbTableNamePrefix
1622 gitcvs.dbdriver
1623 gitcvs.dbname
1624 gitcvs.dbpass
1625 gitcvs.dbuser
1626 gitcvs.enabled
1627 gitcvs.logfile
1628 gitcvs.usecrlfattr
1629 guitool.
1630 gui.blamehistoryctx
1631 gui.commitmsgwidth
1632 gui.copyblamethreshold
1633 gui.diffcontext
1634 gui.encoding
1635 gui.fastcopyblame
1636 gui.matchtrackingbranch
1637 gui.newbranchtemplate
1638 gui.pruneduringfetch
1639 gui.spellingdictionary
1640 gui.trustmtime
1641 help.autocorrect
1642 help.browser
1643 help.format
1644 http.lowSpeedLimit
1645 http.lowSpeedTime
1646 http.maxRequests
1647 http.noEPSV
1648 http.proxy
1649 http.sslCAInfo
1650 http.sslCAPath
1651 http.sslCert
1652 http.sslKey
1653 http.sslVerify
1654 i18n.commitEncoding
1655 i18n.logOutputEncoding
1656 imap.folder
1657 imap.host
1658 imap.pass
1659 imap.port
1660 imap.preformattedHTML
1661 imap.sslverify
1662 imap.tunnel
1663 imap.user
1664 instaweb.browser
1665 instaweb.httpd
1666 instaweb.local
1667 instaweb.modulepath
1668 instaweb.port
1669 interactive.singlekey
1670 log.date
1671 log.showroot
1672 mailmap.file
1673 man.
1674 man.viewer
1675 merge.conflictstyle
1676 merge.log
1677 merge.renameLimit
1678 merge.stat
1679 merge.tool
1680 merge.verbosity
1681 mergetool.
1682 mergetool.keepBackup
1683 mergetool.prompt
1684 pack.compression
1685 pack.deltaCacheLimit
1686 pack.deltaCacheSize
1687 pack.depth
1688 pack.indexVersion
1689 pack.packSizeLimit
1690 pack.threads
1691 pack.window
1692 pack.windowMemory
1693 pager.
1694 pull.octopus
1695 pull.twohead
1696 push.default
1697 rebase.stat
1698 receive.denyCurrentBranch
1699 receive.denyDeletes
1700 receive.denyNonFastForwards
1701 receive.fsckObjects
1702 receive.unpackLimit
1703 repack.usedeltabaseoffset
1704 rerere.autoupdate
1705 rerere.enabled
1706 sendemail.aliasesfile
1707 sendemail.aliasesfiletype
1708 sendemail.bcc
1709 sendemail.cc
1710 sendemail.cccmd
1711 sendemail.chainreplyto
1712 sendemail.confirm
1713 sendemail.envelopesender
1714 sendemail.multiedit
1715 sendemail.signedoffbycc
1716 sendemail.smtpencryption
1717 sendemail.smtppass
1718 sendemail.smtpserver
1719 sendemail.smtpserverport
1720 sendemail.smtpuser
1721 sendemail.suppresscc
1722 sendemail.suppressfrom
1723 sendemail.thread
1724 sendemail.to
1725 sendemail.validate
1726 showbranch.default
1727 status.relativePaths
1728 status.showUntrackedFiles
1729 tar.umask
1730 transfer.unpackLimit
1731 url.
1732 user.email
1733 user.name
1734 user.signingkey
1735 web.browser
1736 branch. remote.
1740 _git_remote ()
1742 local subcommands="add rename rm show prune update set-head"
1743 local subcommand="$(__git_find_subcommand "$subcommands")"
1744 if [ -z "$subcommand" ]; then
1745 __gitcomp "$subcommands"
1746 return
1749 case "$subcommand" in
1750 rename|rm|show|prune)
1751 __gitcomp "$(__git_remotes)"
1753 update)
1754 local i c='' IFS=$'\n'
1755 for i in $(git --git-dir="$(__gitdir)" config --list); do
1756 case "$i" in
1757 remotes.*)
1758 i="${i#remotes.}"
1759 c="$c ${i/=*/}"
1761 esac
1762 done
1763 __gitcomp "$c"
1766 COMPREPLY=()
1768 esac
1771 _git_reset ()
1773 __git_has_doubledash && return
1775 local cur="${COMP_WORDS[COMP_CWORD]}"
1776 case "$cur" in
1777 --*)
1778 __gitcomp "--merge --mixed --hard --soft"
1779 return
1781 esac
1782 __gitcomp "$(__git_refs)"
1785 _git_revert ()
1787 local cur="${COMP_WORDS[COMP_CWORD]}"
1788 case "$cur" in
1789 --*)
1790 __gitcomp "--edit --mainline --no-edit --no-commit --signoff"
1791 return
1793 esac
1794 __gitcomp "$(__git_refs)"
1797 _git_rm ()
1799 __git_has_doubledash && return
1801 local cur="${COMP_WORDS[COMP_CWORD]}"
1802 case "$cur" in
1803 --*)
1804 __gitcomp "--cached --dry-run --ignore-unmatch --quiet"
1805 return
1807 esac
1808 COMPREPLY=()
1811 _git_shortlog ()
1813 __git_has_doubledash && return
1815 local cur="${COMP_WORDS[COMP_CWORD]}"
1816 case "$cur" in
1817 --*)
1818 __gitcomp "
1819 $__git_log_common_options
1820 $__git_log_shortlog_options
1821 --numbered --summary
1823 return
1825 esac
1826 __git_complete_revlist
1829 _git_show ()
1831 __git_has_doubledash && return
1833 local cur="${COMP_WORDS[COMP_CWORD]}"
1834 case "$cur" in
1835 --pretty=*)
1836 __gitcomp "$__git_log_pretty_formats
1837 " "" "${cur##--pretty=}"
1838 return
1840 --format=*)
1841 __gitcomp "$__git_log_pretty_formats
1842 " "" "${cur##--format=}"
1843 return
1845 --*)
1846 __gitcomp "--pretty= --format= --abbrev-commit --oneline
1847 $__git_diff_common_options
1849 return
1851 esac
1852 __git_complete_file
1855 _git_show_branch ()
1857 local cur="${COMP_WORDS[COMP_CWORD]}"
1858 case "$cur" in
1859 --*)
1860 __gitcomp "
1861 --all --remotes --topo-order --current --more=
1862 --list --independent --merge-base --no-name
1863 --color --no-color
1864 --sha1-name --sparse --topics --reflog
1866 return
1868 esac
1869 __git_complete_revlist
1872 _git_stash ()
1874 local subcommands='save list show apply clear drop pop create branch'
1875 local subcommand="$(__git_find_subcommand "$subcommands")"
1876 if [ -z "$subcommand" ]; then
1877 __gitcomp "$subcommands"
1878 else
1879 local cur="${COMP_WORDS[COMP_CWORD]}"
1880 case "$subcommand,$cur" in
1881 save,--*)
1882 __gitcomp "--keep-index"
1884 apply,--*|pop,--*)
1885 __gitcomp "--index"
1887 show,--*|drop,--*|branch,--*)
1888 COMPREPLY=()
1890 show,*|apply,*|drop,*|pop,*|branch,*)
1891 __gitcomp "$(git --git-dir="$(__gitdir)" stash list \
1892 | sed -n -e 's/:.*//p')"
1895 COMPREPLY=()
1897 esac
1901 _git_submodule ()
1903 __git_has_doubledash && return
1905 local subcommands="add status init update summary foreach sync"
1906 if [ -z "$(__git_find_subcommand "$subcommands")" ]; then
1907 local cur="${COMP_WORDS[COMP_CWORD]}"
1908 case "$cur" in
1909 --*)
1910 __gitcomp "--quiet --cached"
1913 __gitcomp "$subcommands"
1915 esac
1916 return
1920 _git_svn ()
1922 local subcommands="
1923 init fetch clone rebase dcommit log find-rev
1924 set-tree commit-diff info create-ignore propget
1925 proplist show-ignore show-externals branch tag blame
1926 migrate
1928 local subcommand="$(__git_find_subcommand "$subcommands")"
1929 if [ -z "$subcommand" ]; then
1930 __gitcomp "$subcommands"
1931 else
1932 local remote_opts="--username= --config-dir= --no-auth-cache"
1933 local fc_opts="
1934 --follow-parent --authors-file= --repack=
1935 --no-metadata --use-svm-props --use-svnsync-props
1936 --log-window-size= --no-checkout --quiet
1937 --repack-flags --use-log-author --localtime
1938 --ignore-paths= $remote_opts
1940 local init_opts="
1941 --template= --shared= --trunk= --tags=
1942 --branches= --stdlayout --minimize-url
1943 --no-metadata --use-svm-props --use-svnsync-props
1944 --rewrite-root= --prefix= --use-log-author
1945 --add-author-from $remote_opts
1947 local cmt_opts="
1948 --edit --rmdir --find-copies-harder --copy-similarity=
1951 local cur="${COMP_WORDS[COMP_CWORD]}"
1952 case "$subcommand,$cur" in
1953 fetch,--*)
1954 __gitcomp "--revision= --fetch-all $fc_opts"
1956 clone,--*)
1957 __gitcomp "--revision= $fc_opts $init_opts"
1959 init,--*)
1960 __gitcomp "$init_opts"
1962 dcommit,--*)
1963 __gitcomp "
1964 --merge --strategy= --verbose --dry-run
1965 --fetch-all --no-rebase --commit-url
1966 --revision $cmt_opts $fc_opts
1969 set-tree,--*)
1970 __gitcomp "--stdin $cmt_opts $fc_opts"
1972 create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\
1973 show-externals,--*)
1974 __gitcomp "--revision="
1976 log,--*)
1977 __gitcomp "
1978 --limit= --revision= --verbose --incremental
1979 --oneline --show-commit --non-recursive
1980 --authors-file= --color
1983 rebase,--*)
1984 __gitcomp "
1985 --merge --verbose --strategy= --local
1986 --fetch-all --dry-run $fc_opts
1989 commit-diff,--*)
1990 __gitcomp "--message= --file= --revision= $cmt_opts"
1992 info,--*)
1993 __gitcomp "--url"
1995 branch,--*)
1996 __gitcomp "--dry-run --message --tag"
1998 tag,--*)
1999 __gitcomp "--dry-run --message"
2001 blame,--*)
2002 __gitcomp "--git-format"
2004 migrate,--*)
2005 __gitcomp "
2006 --config-dir= --ignore-paths= --minimize
2007 --no-auth-cache --username=
2011 COMPREPLY=()
2013 esac
2017 _git_tag ()
2019 local i c=1 f=0
2020 while [ $c -lt $COMP_CWORD ]; do
2021 i="${COMP_WORDS[c]}"
2022 case "$i" in
2023 -d|-v)
2024 __gitcomp "$(__git_tags)"
2025 return
2030 esac
2031 c=$((++c))
2032 done
2034 case "${COMP_WORDS[COMP_CWORD-1]}" in
2035 -m|-F)
2036 COMPREPLY=()
2038 -*|tag)
2039 if [ $f = 1 ]; then
2040 __gitcomp "$(__git_tags)"
2041 else
2042 COMPREPLY=()
2046 __gitcomp "$(__git_refs)"
2048 esac
2051 _git ()
2053 local i c=1 command __git_dir
2055 while [ $c -lt $COMP_CWORD ]; do
2056 i="${COMP_WORDS[c]}"
2057 case "$i" in
2058 --git-dir=*) __git_dir="${i#--git-dir=}" ;;
2059 --bare) __git_dir="." ;;
2060 --version|-p|--paginate) ;;
2061 --help) command="help"; break ;;
2062 *) command="$i"; break ;;
2063 esac
2064 c=$((++c))
2065 done
2067 if [ -z "$command" ]; then
2068 case "${COMP_WORDS[COMP_CWORD]}" in
2069 --*) __gitcomp "
2070 --paginate
2071 --no-pager
2072 --git-dir=
2073 --bare
2074 --version
2075 --exec-path
2076 --html-path
2077 --work-tree=
2078 --help
2081 *) __gitcomp "$(__git_porcelain_commands) $(__git_aliases)" ;;
2082 esac
2083 return
2086 local expansion=$(__git_aliased_command "$command")
2087 [ "$expansion" ] && command="$expansion"
2089 case "$command" in
2090 am) _git_am ;;
2091 add) _git_add ;;
2092 apply) _git_apply ;;
2093 archive) _git_archive ;;
2094 bisect) _git_bisect ;;
2095 bundle) _git_bundle ;;
2096 branch) _git_branch ;;
2097 checkout) _git_checkout ;;
2098 cherry) _git_cherry ;;
2099 cherry-pick) _git_cherry_pick ;;
2100 clean) _git_clean ;;
2101 clone) _git_clone ;;
2102 commit) _git_commit ;;
2103 config) _git_config ;;
2104 describe) _git_describe ;;
2105 diff) _git_diff ;;
2106 difftool) _git_difftool ;;
2107 fetch) _git_fetch ;;
2108 format-patch) _git_format_patch ;;
2109 fsck) _git_fsck ;;
2110 gc) _git_gc ;;
2111 grep) _git_grep ;;
2112 help) _git_help ;;
2113 init) _git_init ;;
2114 log) _git_log ;;
2115 ls-files) _git_ls_files ;;
2116 ls-remote) _git_ls_remote ;;
2117 ls-tree) _git_ls_tree ;;
2118 merge) _git_merge;;
2119 mergetool) _git_mergetool;;
2120 merge-base) _git_merge_base ;;
2121 mv) _git_mv ;;
2122 name-rev) _git_name_rev ;;
2123 pull) _git_pull ;;
2124 push) _git_push ;;
2125 rebase) _git_rebase ;;
2126 remote) _git_remote ;;
2127 reset) _git_reset ;;
2128 revert) _git_revert ;;
2129 rm) _git_rm ;;
2130 send-email) _git_send_email ;;
2131 shortlog) _git_shortlog ;;
2132 show) _git_show ;;
2133 show-branch) _git_show_branch ;;
2134 stash) _git_stash ;;
2135 stage) _git_add ;;
2136 submodule) _git_submodule ;;
2137 svn) _git_svn ;;
2138 tag) _git_tag ;;
2139 whatchanged) _git_log ;;
2140 *) COMPREPLY=() ;;
2141 esac
2144 _gitk ()
2146 __git_has_doubledash && return
2148 local cur="${COMP_WORDS[COMP_CWORD]}"
2149 local g="$(__gitdir)"
2150 local merge=""
2151 if [ -f "$g/MERGE_HEAD" ]; then
2152 merge="--merge"
2154 case "$cur" in
2155 --*)
2156 __gitcomp "
2157 $__git_log_common_options
2158 $__git_log_gitk_options
2159 $merge
2161 return
2163 esac
2164 __git_complete_revlist
2167 complete -o bashdefault -o default -o nospace -F _git git 2>/dev/null \
2168 || complete -o default -o nospace -F _git git
2169 complete -o bashdefault -o default -o nospace -F _gitk gitk 2>/dev/null \
2170 || complete -o default -o nospace -F _gitk gitk
2172 # The following are necessary only for Cygwin, and only are needed
2173 # when the user has tab-completed the executable name and consequently
2174 # included the '.exe' suffix.
2176 if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
2177 complete -o bashdefault -o default -o nospace -F _git git.exe 2>/dev/null \
2178 || complete -o default -o nospace -F _git git.exe