bash: Support new 'git fetch' options
[git/dscho.git] / contrib / completion / git-completion.bash
blobfbfa5f25c1b2c75943464757d571d3fa89e209aa
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) Consider changing your PS1 to also show the current branch:
25 # PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
27 # The argument to __git_ps1 will be displayed only if you
28 # are currently in a git repository. The %s token will be
29 # the name of the current branch.
31 # In addition, if you set GIT_PS1_SHOWDIRTYSTATE to a nonempty
32 # value, unstaged (*) and staged (+) changes will be shown next
33 # to the branch name. You can configure this per-repository
34 # with the bash.showDirtyState variable, which defaults to true
35 # once GIT_PS1_SHOWDIRTYSTATE is enabled.
37 # You can also see if currently something is stashed, by setting
38 # GIT_PS1_SHOWSTASHSTATE to a nonempty value. If something is stashed,
39 # then a '$' will be shown next to the branch name.
41 # If you would like to see if there're untracked files, then you can
42 # set GIT_PS1_SHOWUNTRACKEDFILES to a nonempty value. If there're
43 # untracked files, then a '%' will be shown next to the branch name.
45 # To submit patches:
47 # *) Read Documentation/SubmittingPatches
48 # *) Send all patches to the current maintainer:
50 # "Shawn O. Pearce" <spearce@spearce.org>
52 # *) Always CC the Git mailing list:
54 # git@vger.kernel.org
57 case "$COMP_WORDBREAKS" in
58 *:*) : great ;;
59 *) COMP_WORDBREAKS="$COMP_WORDBREAKS:"
60 esac
62 # __gitdir accepts 0 or 1 arguments (i.e., location)
63 # returns location of .git repo
64 __gitdir ()
66 if [ -z "${1-}" ]; then
67 if [ -n "${__git_dir-}" ]; then
68 echo "$__git_dir"
69 elif [ -d .git ]; then
70 echo .git
71 else
72 git rev-parse --git-dir 2>/dev/null
74 elif [ -d "$1/.git" ]; then
75 echo "$1/.git"
76 else
77 echo "$1"
81 # __git_ps1 accepts 0 or 1 arguments (i.e., format string)
82 # returns text to add to bash PS1 prompt (includes branch name)
83 __git_ps1 ()
85 local g="$(__gitdir)"
86 if [ -n "$g" ]; then
87 local r
88 local b
89 if [ -f "$g/rebase-merge/interactive" ]; then
90 r="|REBASE-i"
91 b="$(cat "$g/rebase-merge/head-name")"
92 elif [ -d "$g/rebase-merge" ]; then
93 r="|REBASE-m"
94 b="$(cat "$g/rebase-merge/head-name")"
95 else
96 if [ -d "$g/rebase-apply" ]; then
97 if [ -f "$g/rebase-apply/rebasing" ]; then
98 r="|REBASE"
99 elif [ -f "$g/rebase-apply/applying" ]; then
100 r="|AM"
101 else
102 r="|AM/REBASE"
104 elif [ -f "$g/MERGE_HEAD" ]; then
105 r="|MERGING"
106 elif [ -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 s
133 local u
134 local c
136 if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then
137 if [ "true" = "$(git rev-parse --is-bare-repository 2>/dev/null)" ]; then
138 c="BARE:"
139 else
140 b="GIT_DIR!"
142 elif [ "true" = "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
143 if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ]; then
144 if [ "$(git config --bool bash.showDirtyState)" != "false" ]; then
145 git diff --no-ext-diff --ignore-submodules \
146 --quiet --exit-code || w="*"
147 if git rev-parse --quiet --verify HEAD >/dev/null; then
148 git diff-index --cached --quiet \
149 --ignore-submodules HEAD -- || i="+"
150 else
151 i="#"
155 if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ]; then
156 git rev-parse --verify refs/stash >/dev/null 2>&1 && s="$"
159 if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ]; then
160 if [ -n "$(git ls-files --others --exclude-standard)" ]; then
161 u="%"
166 if [ -n "${1-}" ]; then
167 printf "$1" "$c${b##refs/heads/}$w$i$s$u$r"
168 else
169 printf " (%s)" "$c${b##refs/heads/}$w$i$s$u$r"
174 # __gitcomp_1 requires 2 arguments
175 __gitcomp_1 ()
177 local c IFS=' '$'\t'$'\n'
178 for c in $1; do
179 case "$c$2" in
180 --*=*) printf %s$'\n' "$c$2" ;;
181 *.) printf %s$'\n' "$c$2" ;;
182 *) printf %s$'\n' "$c$2 " ;;
183 esac
184 done
187 # __gitcomp accepts 1, 2, 3, or 4 arguments
188 # generates completion reply with compgen
189 __gitcomp ()
191 local cur="${COMP_WORDS[COMP_CWORD]}"
192 if [ $# -gt 2 ]; then
193 cur="$3"
195 case "$cur" in
196 --*=)
197 COMPREPLY=()
200 local IFS=$'\n'
201 COMPREPLY=($(compgen -P "${2-}" \
202 -W "$(__gitcomp_1 "${1-}" "${4-}")" \
203 -- "$cur"))
205 esac
208 # __git_heads accepts 0 or 1 arguments (to pass to __gitdir)
209 __git_heads ()
211 local cmd i is_hash=y dir="$(__gitdir "${1-}")"
212 if [ -d "$dir" ]; then
213 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
214 refs/heads
215 return
217 for i in $(git ls-remote "${1-}" 2>/dev/null); do
218 case "$is_hash,$i" in
219 y,*) is_hash=n ;;
220 n,*^{}) is_hash=y ;;
221 n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
222 n,*) is_hash=y; echo "$i" ;;
223 esac
224 done
227 # __git_tags accepts 0 or 1 arguments (to pass to __gitdir)
228 __git_tags ()
230 local cmd i is_hash=y dir="$(__gitdir "${1-}")"
231 if [ -d "$dir" ]; then
232 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
233 refs/tags
234 return
236 for i in $(git ls-remote "${1-}" 2>/dev/null); do
237 case "$is_hash,$i" in
238 y,*) is_hash=n ;;
239 n,*^{}) is_hash=y ;;
240 n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
241 n,*) is_hash=y; echo "$i" ;;
242 esac
243 done
246 # __git_refs accepts 0 or 1 arguments (to pass to __gitdir)
247 __git_refs ()
249 local i is_hash=y dir="$(__gitdir "${1-}")"
250 local cur="${COMP_WORDS[COMP_CWORD]}" format refs
251 if [ -d "$dir" ]; then
252 case "$cur" in
253 refs|refs/*)
254 format="refname"
255 refs="${cur%/*}"
258 if [ -e "$dir/HEAD" ]; then echo HEAD; fi
259 format="refname:short"
260 refs="refs/tags refs/heads refs/remotes"
262 esac
263 git --git-dir="$dir" for-each-ref --format="%($format)" \
264 $refs
265 return
267 for i in $(git ls-remote "$dir" 2>/dev/null); do
268 case "$is_hash,$i" in
269 y,*) is_hash=n ;;
270 n,*^{}) is_hash=y ;;
271 n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
272 n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
273 n,refs/remotes/*) is_hash=y; echo "${i#refs/remotes/}" ;;
274 n,*) is_hash=y; echo "$i" ;;
275 esac
276 done
279 # __git_refs2 requires 1 argument (to pass to __git_refs)
280 __git_refs2 ()
282 local i
283 for i in $(__git_refs "$1"); do
284 echo "$i:$i"
285 done
288 # __git_refs_remotes requires 1 argument (to pass to ls-remote)
289 __git_refs_remotes ()
291 local cmd i is_hash=y
292 for i in $(git ls-remote "$1" 2>/dev/null); do
293 case "$is_hash,$i" in
294 n,refs/heads/*)
295 is_hash=y
296 echo "$i:refs/remotes/$1/${i#refs/heads/}"
298 y,*) is_hash=n ;;
299 n,*^{}) is_hash=y ;;
300 n,refs/tags/*) is_hash=y;;
301 n,*) is_hash=y; ;;
302 esac
303 done
306 __git_remotes ()
308 local i ngoff IFS=$'\n' d="$(__gitdir)"
309 shopt -q nullglob || ngoff=1
310 shopt -s nullglob
311 for i in "$d/remotes"/*; do
312 echo ${i#$d/remotes/}
313 done
314 [ "$ngoff" ] && shopt -u nullglob
315 for i in $(git --git-dir="$d" config --get-regexp 'remote\..*\.url' 2>/dev/null); do
316 i="${i#remote.}"
317 echo "${i/.url*/}"
318 done
321 __git_list_merge_strategies ()
323 git merge -s help 2>&1 |
324 sed -n -e '/[Aa]vailable strategies are: /,/^$/{
325 s/\.$//
326 s/.*://
327 s/^[ ]*//
328 s/[ ]*$//
333 __git_merge_strategies=
334 # 'git merge -s help' (and thus detection of the merge strategy
335 # list) fails, unfortunately, if run outside of any git working
336 # tree. __git_merge_strategies is set to the empty string in
337 # that case, and the detection will be repeated the next time it
338 # is needed.
339 __git_compute_merge_strategies ()
341 : ${__git_merge_strategies:=$(__git_list_merge_strategies)}
344 __git_complete_file ()
346 local pfx ls ref cur="${COMP_WORDS[COMP_CWORD]}"
347 case "$cur" in
348 ?*:*)
349 ref="${cur%%:*}"
350 cur="${cur#*:}"
351 case "$cur" in
352 ?*/*)
353 pfx="${cur%/*}"
354 cur="${cur##*/}"
355 ls="$ref:$pfx"
356 pfx="$pfx/"
359 ls="$ref"
361 esac
363 case "$COMP_WORDBREAKS" in
364 *:*) : great ;;
365 *) pfx="$ref:$pfx" ;;
366 esac
368 local IFS=$'\n'
369 COMPREPLY=($(compgen -P "$pfx" \
370 -W "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \
371 | sed '/^100... blob /{
372 s,^.* ,,
373 s,$, ,
375 /^120000 blob /{
376 s,^.* ,,
377 s,$, ,
379 /^040000 tree /{
380 s,^.* ,,
381 s,$,/,
383 s/^.* //')" \
384 -- "$cur"))
387 __gitcomp "$(__git_refs)"
389 esac
392 __git_complete_revlist ()
394 local pfx cur="${COMP_WORDS[COMP_CWORD]}"
395 case "$cur" in
396 *...*)
397 pfx="${cur%...*}..."
398 cur="${cur#*...}"
399 __gitcomp "$(__git_refs)" "$pfx" "$cur"
401 *..*)
402 pfx="${cur%..*}.."
403 cur="${cur#*..}"
404 __gitcomp "$(__git_refs)" "$pfx" "$cur"
407 __gitcomp "$(__git_refs)"
409 esac
412 __git_complete_remote_or_refspec ()
414 local cmd="${COMP_WORDS[1]}"
415 local cur="${COMP_WORDS[COMP_CWORD]}"
416 local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0
417 while [ $c -lt $COMP_CWORD ]; do
418 i="${COMP_WORDS[c]}"
419 case "$i" in
420 --mirror) [ "$cmd" = "push" ] && no_complete_refspec=1 ;;
421 --all)
422 case "$cmd" in
423 push) no_complete_refspec=1 ;;
424 fetch)
425 COMPREPLY=()
426 return
428 *) ;;
429 esac
431 -*) ;;
432 *) remote="$i"; break ;;
433 esac
434 c=$((++c))
435 done
436 if [ -z "$remote" ]; then
437 __gitcomp "$(__git_remotes)"
438 return
440 if [ $no_complete_refspec = 1 ]; then
441 COMPREPLY=()
442 return
444 [ "$remote" = "." ] && remote=
445 case "$cur" in
446 *:*)
447 case "$COMP_WORDBREAKS" in
448 *:*) : great ;;
449 *) pfx="${cur%%:*}:" ;;
450 esac
451 cur="${cur#*:}"
452 lhs=0
455 pfx="+"
456 cur="${cur#+}"
458 esac
459 case "$cmd" in
460 fetch)
461 if [ $lhs = 1 ]; then
462 __gitcomp "$(__git_refs2 "$remote")" "$pfx" "$cur"
463 else
464 __gitcomp "$(__git_refs)" "$pfx" "$cur"
467 pull)
468 if [ $lhs = 1 ]; then
469 __gitcomp "$(__git_refs "$remote")" "$pfx" "$cur"
470 else
471 __gitcomp "$(__git_refs)" "$pfx" "$cur"
474 push)
475 if [ $lhs = 1 ]; then
476 __gitcomp "$(__git_refs)" "$pfx" "$cur"
477 else
478 __gitcomp "$(__git_refs "$remote")" "$pfx" "$cur"
481 esac
484 __git_complete_strategy ()
486 __git_compute_merge_strategies
487 case "${COMP_WORDS[COMP_CWORD-1]}" in
488 -s|--strategy)
489 __gitcomp "$__git_merge_strategies"
490 return 0
491 esac
492 local cur="${COMP_WORDS[COMP_CWORD]}"
493 case "$cur" in
494 --strategy=*)
495 __gitcomp "$__git_merge_strategies" "" "${cur##--strategy=}"
496 return 0
498 esac
499 return 1
502 __git_list_all_commands ()
504 local i IFS=" "$'\n'
505 for i in $(git help -a|egrep '^ [a-zA-Z0-9]')
507 case $i in
508 *--*) : helper pattern;;
509 *) echo $i;;
510 esac
511 done
514 __git_all_commands=
515 __git_compute_all_commands ()
517 : ${__git_all_commands:=$(__git_list_all_commands)}
520 __git_list_porcelain_commands ()
522 local i IFS=" "$'\n'
523 __git_compute_all_commands
524 for i in "help" $__git_all_commands
526 case $i in
527 *--*) : helper pattern;;
528 applymbox) : ask gittus;;
529 applypatch) : ask gittus;;
530 archimport) : import;;
531 cat-file) : plumbing;;
532 check-attr) : plumbing;;
533 check-ref-format) : plumbing;;
534 checkout-index) : plumbing;;
535 commit-tree) : plumbing;;
536 count-objects) : infrequent;;
537 cvsexportcommit) : export;;
538 cvsimport) : import;;
539 cvsserver) : daemon;;
540 daemon) : daemon;;
541 diff-files) : plumbing;;
542 diff-index) : plumbing;;
543 diff-tree) : plumbing;;
544 fast-import) : import;;
545 fast-export) : export;;
546 fsck-objects) : plumbing;;
547 fetch-pack) : plumbing;;
548 fmt-merge-msg) : plumbing;;
549 for-each-ref) : plumbing;;
550 hash-object) : plumbing;;
551 http-*) : transport;;
552 index-pack) : plumbing;;
553 init-db) : deprecated;;
554 local-fetch) : plumbing;;
555 lost-found) : infrequent;;
556 ls-files) : plumbing;;
557 ls-remote) : plumbing;;
558 ls-tree) : plumbing;;
559 mailinfo) : plumbing;;
560 mailsplit) : plumbing;;
561 merge-*) : plumbing;;
562 mktree) : plumbing;;
563 mktag) : plumbing;;
564 pack-objects) : plumbing;;
565 pack-redundant) : plumbing;;
566 pack-refs) : plumbing;;
567 parse-remote) : plumbing;;
568 patch-id) : plumbing;;
569 peek-remote) : plumbing;;
570 prune) : plumbing;;
571 prune-packed) : plumbing;;
572 quiltimport) : import;;
573 read-tree) : plumbing;;
574 receive-pack) : plumbing;;
575 reflog) : plumbing;;
576 repo-config) : deprecated;;
577 rerere) : plumbing;;
578 rev-list) : plumbing;;
579 rev-parse) : plumbing;;
580 runstatus) : plumbing;;
581 sh-setup) : internal;;
582 shell) : daemon;;
583 show-ref) : plumbing;;
584 send-pack) : plumbing;;
585 show-index) : plumbing;;
586 ssh-*) : transport;;
587 stripspace) : plumbing;;
588 symbolic-ref) : plumbing;;
589 tar-tree) : deprecated;;
590 unpack-file) : plumbing;;
591 unpack-objects) : plumbing;;
592 update-index) : plumbing;;
593 update-ref) : plumbing;;
594 update-server-info) : daemon;;
595 upload-archive) : plumbing;;
596 upload-pack) : plumbing;;
597 write-tree) : plumbing;;
598 var) : infrequent;;
599 verify-pack) : infrequent;;
600 verify-tag) : plumbing;;
601 *) echo $i;;
602 esac
603 done
606 __git_porcelain_commands=
607 __git_compute_porcelain_commands ()
609 __git_compute_all_commands
610 : ${__git_porcelain_commands:=$(__git_list_porcelain_commands)}
613 __git_aliases ()
615 local i IFS=$'\n'
616 for i in $(git --git-dir="$(__gitdir)" config --get-regexp "alias\..*" 2>/dev/null); do
617 case "$i" in
618 alias.*)
619 i="${i#alias.}"
620 echo "${i/ */}"
622 esac
623 done
626 # __git_aliased_command requires 1 argument
627 __git_aliased_command ()
629 local word cmdline=$(git --git-dir="$(__gitdir)" \
630 config --get "alias.$1")
631 for word in $cmdline; do
632 if [ "${word##-*}" ]; then
633 echo $word
634 return
636 done
639 # __git_find_on_cmdline requires 1 argument
640 __git_find_on_cmdline ()
642 local word subcommand c=1
644 while [ $c -lt $COMP_CWORD ]; do
645 word="${COMP_WORDS[c]}"
646 for subcommand in $1; do
647 if [ "$subcommand" = "$word" ]; then
648 echo "$subcommand"
649 return
651 done
652 c=$((++c))
653 done
656 __git_has_doubledash ()
658 local c=1
659 while [ $c -lt $COMP_CWORD ]; do
660 if [ "--" = "${COMP_WORDS[c]}" ]; then
661 return 0
663 c=$((++c))
664 done
665 return 1
668 __git_whitespacelist="nowarn warn error error-all fix"
670 _git_am ()
672 local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)"
673 if [ -d "$dir"/rebase-apply ]; then
674 __gitcomp "--skip --resolved --abort"
675 return
677 case "$cur" in
678 --whitespace=*)
679 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
680 return
682 --*)
683 __gitcomp "
684 --3way --committer-date-is-author-date --ignore-date
685 --ignore-whitespace --ignore-space-change
686 --interactive --keep --no-utf8 --signoff --utf8
687 --whitespace= --scissors
689 return
690 esac
691 COMPREPLY=()
694 _git_apply ()
696 local cur="${COMP_WORDS[COMP_CWORD]}"
697 case "$cur" in
698 --whitespace=*)
699 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
700 return
702 --*)
703 __gitcomp "
704 --stat --numstat --summary --check --index
705 --cached --index-info --reverse --reject --unidiff-zero
706 --apply --no-add --exclude=
707 --ignore-whitespace --ignore-space-change
708 --whitespace= --inaccurate-eof --verbose
710 return
711 esac
712 COMPREPLY=()
715 _git_add ()
717 __git_has_doubledash && return
719 local cur="${COMP_WORDS[COMP_CWORD]}"
720 case "$cur" in
721 --*)
722 __gitcomp "
723 --interactive --refresh --patch --update --dry-run
724 --ignore-errors --intent-to-add
726 return
727 esac
728 COMPREPLY=()
731 _git_archive ()
733 local cur="${COMP_WORDS[COMP_CWORD]}"
734 case "$cur" in
735 --format=*)
736 __gitcomp "$(git archive --list)" "" "${cur##--format=}"
737 return
739 --remote=*)
740 __gitcomp "$(__git_remotes)" "" "${cur##--remote=}"
741 return
743 --*)
744 __gitcomp "
745 --format= --list --verbose
746 --prefix= --remote= --exec=
748 return
750 esac
751 __git_complete_file
754 _git_bisect ()
756 __git_has_doubledash && return
758 local subcommands="start bad good skip reset visualize replay log run"
759 local subcommand="$(__git_find_on_cmdline "$subcommands")"
760 if [ -z "$subcommand" ]; then
761 __gitcomp "$subcommands"
762 return
765 case "$subcommand" in
766 bad|good|reset|skip)
767 __gitcomp "$(__git_refs)"
770 COMPREPLY=()
772 esac
775 _git_branch ()
777 local i c=1 only_local_ref="n" has_r="n"
779 while [ $c -lt $COMP_CWORD ]; do
780 i="${COMP_WORDS[c]}"
781 case "$i" in
782 -d|-m) only_local_ref="y" ;;
783 -r) has_r="y" ;;
784 esac
785 c=$((++c))
786 done
788 case "${COMP_WORDS[COMP_CWORD]}" in
789 --*)
790 __gitcomp "
791 --color --no-color --verbose --abbrev= --no-abbrev
792 --track --no-track --contains --merged --no-merged
796 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
797 __gitcomp "$(__git_heads)"
798 else
799 __gitcomp "$(__git_refs)"
802 esac
805 _git_bundle ()
807 local cmd="${COMP_WORDS[2]}"
808 case "$COMP_CWORD" in
810 __gitcomp "create list-heads verify unbundle"
813 # looking for a file
816 case "$cmd" in
817 create)
818 __git_complete_revlist
820 esac
822 esac
825 _git_checkout ()
827 __git_has_doubledash && return
829 local cur="${COMP_WORDS[COMP_CWORD]}"
830 case "$cur" in
831 --conflict=*)
832 __gitcomp "diff3 merge" "" "${cur##--conflict=}"
834 --*)
835 __gitcomp "
836 --quiet --ours --theirs --track --no-track --merge
837 --conflict= --patch
841 __gitcomp "$(__git_refs)"
843 esac
846 _git_cherry ()
848 __gitcomp "$(__git_refs)"
851 _git_cherry_pick ()
853 local cur="${COMP_WORDS[COMP_CWORD]}"
854 case "$cur" in
855 --*)
856 __gitcomp "--edit --no-commit"
859 __gitcomp "$(__git_refs)"
861 esac
864 _git_clean ()
866 __git_has_doubledash && return
868 local cur="${COMP_WORDS[COMP_CWORD]}"
869 case "$cur" in
870 --*)
871 __gitcomp "--dry-run --quiet"
872 return
874 esac
875 COMPREPLY=()
878 _git_clone ()
880 local cur="${COMP_WORDS[COMP_CWORD]}"
881 case "$cur" in
882 --*)
883 __gitcomp "
884 --local
885 --no-hardlinks
886 --shared
887 --reference
888 --quiet
889 --no-checkout
890 --bare
891 --mirror
892 --origin
893 --upload-pack
894 --template=
895 --depth
897 return
899 esac
900 COMPREPLY=()
903 _git_commit ()
905 __git_has_doubledash && return
907 local cur="${COMP_WORDS[COMP_CWORD]}"
908 case "$cur" in
909 --cleanup=*)
910 __gitcomp "default strip verbatim whitespace
911 " "" "${cur##--cleanup=}"
912 return
914 --reuse-message=*)
915 __gitcomp "$(__git_refs)" "" "${cur##--reuse-message=}"
916 return
918 --reedit-message=*)
919 __gitcomp "$(__git_refs)" "" "${cur##--reedit-message=}"
920 return
922 --untracked-files=*)
923 __gitcomp "all no normal" "" "${cur##--untracked-files=}"
924 return
926 --*)
927 __gitcomp "
928 --all --author= --signoff --verify --no-verify
929 --edit --amend --include --only --interactive
930 --dry-run --reuse-message= --reedit-message=
931 --reset-author --file= --message= --template=
932 --cleanup= --untracked-files --untracked-files=
933 --verbose --quiet
935 return
936 esac
937 COMPREPLY=()
940 _git_describe ()
942 local cur="${COMP_WORDS[COMP_CWORD]}"
943 case "$cur" in
944 --*)
945 __gitcomp "
946 --all --tags --contains --abbrev= --candidates=
947 --exact-match --debug --long --match --always
949 return
950 esac
951 __gitcomp "$(__git_refs)"
954 __git_diff_common_options="--stat --numstat --shortstat --summary
955 --patch-with-stat --name-only --name-status --color
956 --no-color --color-words --no-renames --check
957 --full-index --binary --abbrev --diff-filter=
958 --find-copies-harder
959 --text --ignore-space-at-eol --ignore-space-change
960 --ignore-all-space --exit-code --quiet --ext-diff
961 --no-ext-diff
962 --no-prefix --src-prefix= --dst-prefix=
963 --inter-hunk-context=
964 --patience
965 --raw
966 --dirstat --dirstat= --dirstat-by-file
967 --dirstat-by-file= --cumulative
970 _git_diff ()
972 __git_has_doubledash && return
974 local cur="${COMP_WORDS[COMP_CWORD]}"
975 case "$cur" in
976 --*)
977 __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
978 --base --ours --theirs
979 $__git_diff_common_options
981 return
983 esac
984 __git_complete_file
987 __git_mergetools_common="diffuse ecmerge emerge kdiff3 meld opendiff
988 tkdiff vimdiff gvimdiff xxdiff araxis p4merge
991 _git_difftool ()
993 __git_has_doubledash && return
995 local cur="${COMP_WORDS[COMP_CWORD]}"
996 case "$cur" in
997 --tool=*)
998 __gitcomp "$__git_mergetools_common kompare" "" "${cur##--tool=}"
999 return
1001 --*)
1002 __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
1003 --base --ours --theirs
1004 --no-renames --diff-filter= --find-copies-harder
1005 --relative --ignore-submodules
1006 --tool="
1007 return
1009 esac
1010 __git_complete_file
1013 __git_fetch_options="
1014 --quiet --verbose --append --upload-pack --force --keep --depth=
1015 --tags --no-tags --all --prune --dry-run
1018 _git_fetch ()
1020 local cur="${COMP_WORDS[COMP_CWORD]}"
1021 case "$cur" in
1022 --*)
1023 __gitcomp "$__git_fetch_options"
1024 return
1026 esac
1027 __git_complete_remote_or_refspec
1030 _git_format_patch ()
1032 local cur="${COMP_WORDS[COMP_CWORD]}"
1033 case "$cur" in
1034 --thread=*)
1035 __gitcomp "
1036 deep shallow
1037 " "" "${cur##--thread=}"
1038 return
1040 --*)
1041 __gitcomp "
1042 --stdout --attach --no-attach --thread --thread=
1043 --output-directory
1044 --numbered --start-number
1045 --numbered-files
1046 --keep-subject
1047 --signoff
1048 --in-reply-to= --cc=
1049 --full-index --binary
1050 --not --all
1051 --cover-letter
1052 --no-prefix --src-prefix= --dst-prefix=
1053 --inline --suffix= --ignore-if-in-upstream
1054 --subject-prefix=
1056 return
1058 esac
1059 __git_complete_revlist
1062 _git_fsck ()
1064 local cur="${COMP_WORDS[COMP_CWORD]}"
1065 case "$cur" in
1066 --*)
1067 __gitcomp "
1068 --tags --root --unreachable --cache --no-reflogs --full
1069 --strict --verbose --lost-found
1071 return
1073 esac
1074 COMPREPLY=()
1077 _git_gc ()
1079 local cur="${COMP_WORDS[COMP_CWORD]}"
1080 case "$cur" in
1081 --*)
1082 __gitcomp "--prune --aggressive"
1083 return
1085 esac
1086 COMPREPLY=()
1089 _git_grep ()
1091 __git_has_doubledash && return
1093 local cur="${COMP_WORDS[COMP_CWORD]}"
1094 case "$cur" in
1095 --*)
1096 __gitcomp "
1097 --cached
1098 --text --ignore-case --word-regexp --invert-match
1099 --full-name
1100 --extended-regexp --basic-regexp --fixed-strings
1101 --files-with-matches --name-only
1102 --files-without-match
1103 --max-depth
1104 --count
1105 --and --or --not --all-match
1107 return
1109 esac
1111 __gitcomp "$(__git_refs)"
1114 _git_help ()
1116 local cur="${COMP_WORDS[COMP_CWORD]}"
1117 case "$cur" in
1118 --*)
1119 __gitcomp "--all --info --man --web"
1120 return
1122 esac
1123 __git_compute_all_commands
1124 __gitcomp "$__git_all_commands
1125 attributes cli core-tutorial cvs-migration
1126 diffcore gitk glossary hooks ignore modules
1127 repository-layout tutorial tutorial-2
1128 workflows
1132 _git_init ()
1134 local cur="${COMP_WORDS[COMP_CWORD]}"
1135 case "$cur" in
1136 --shared=*)
1137 __gitcomp "
1138 false true umask group all world everybody
1139 " "" "${cur##--shared=}"
1140 return
1142 --*)
1143 __gitcomp "--quiet --bare --template= --shared --shared="
1144 return
1146 esac
1147 COMPREPLY=()
1150 _git_ls_files ()
1152 __git_has_doubledash && return
1154 local cur="${COMP_WORDS[COMP_CWORD]}"
1155 case "$cur" in
1156 --*)
1157 __gitcomp "--cached --deleted --modified --others --ignored
1158 --stage --directory --no-empty-directory --unmerged
1159 --killed --exclude= --exclude-from=
1160 --exclude-per-directory= --exclude-standard
1161 --error-unmatch --with-tree= --full-name
1162 --abbrev --ignored --exclude-per-directory
1164 return
1166 esac
1167 COMPREPLY=()
1170 _git_ls_remote ()
1172 __gitcomp "$(__git_remotes)"
1175 _git_ls_tree ()
1177 __git_complete_file
1180 # Options that go well for log, shortlog and gitk
1181 __git_log_common_options="
1182 --not --all
1183 --branches --tags --remotes
1184 --first-parent --merges --no-merges
1185 --max-count=
1186 --max-age= --since= --after=
1187 --min-age= --until= --before=
1189 # Options that go well for log and gitk (not shortlog)
1190 __git_log_gitk_options="
1191 --dense --sparse --full-history
1192 --simplify-merges --simplify-by-decoration
1193 --left-right
1195 # Options that go well for log and shortlog (not gitk)
1196 __git_log_shortlog_options="
1197 --author= --committer= --grep=
1198 --all-match
1201 __git_log_pretty_formats="oneline short medium full fuller email raw format:"
1202 __git_log_date_formats="relative iso8601 rfc2822 short local default raw"
1204 _git_log ()
1206 __git_has_doubledash && return
1208 local cur="${COMP_WORDS[COMP_CWORD]}"
1209 local g="$(git rev-parse --git-dir 2>/dev/null)"
1210 local merge=""
1211 if [ -f "$g/MERGE_HEAD" ]; then
1212 merge="--merge"
1214 case "$cur" in
1215 --pretty=*)
1216 __gitcomp "$__git_log_pretty_formats
1217 " "" "${cur##--pretty=}"
1218 return
1220 --format=*)
1221 __gitcomp "$__git_log_pretty_formats
1222 " "" "${cur##--format=}"
1223 return
1225 --date=*)
1226 __gitcomp "$__git_log_date_formats" "" "${cur##--date=}"
1227 return
1229 --decorate=*)
1230 __gitcomp "long short" "" "${cur##--decorate=}"
1231 return
1233 --*)
1234 __gitcomp "
1235 $__git_log_common_options
1236 $__git_log_shortlog_options
1237 $__git_log_gitk_options
1238 --root --topo-order --date-order --reverse
1239 --follow --full-diff
1240 --abbrev-commit --abbrev=
1241 --relative-date --date=
1242 --pretty= --format= --oneline
1243 --cherry-pick
1244 --graph
1245 --decorate --decorate=
1246 --walk-reflogs
1247 --parents --children
1248 $merge
1249 $__git_diff_common_options
1250 --pickaxe-all --pickaxe-regex
1252 return
1254 esac
1255 __git_complete_revlist
1258 __git_merge_options="
1259 --no-commit --no-stat --log --no-log --squash --strategy
1260 --commit --stat --no-squash --ff --no-ff --ff-only
1263 _git_merge ()
1265 __git_complete_strategy && return
1267 local cur="${COMP_WORDS[COMP_CWORD]}"
1268 case "$cur" in
1269 --*)
1270 __gitcomp "$__git_merge_options"
1271 return
1272 esac
1273 __gitcomp "$(__git_refs)"
1276 _git_mergetool ()
1278 local cur="${COMP_WORDS[COMP_CWORD]}"
1279 case "$cur" in
1280 --tool=*)
1281 __gitcomp "$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"
1282 return
1284 --*)
1285 __gitcomp "--tool="
1286 return
1288 esac
1289 COMPREPLY=()
1292 _git_merge_base ()
1294 __gitcomp "$(__git_refs)"
1297 _git_mv ()
1299 local cur="${COMP_WORDS[COMP_CWORD]}"
1300 case "$cur" in
1301 --*)
1302 __gitcomp "--dry-run"
1303 return
1305 esac
1306 COMPREPLY=()
1309 _git_name_rev ()
1311 __gitcomp "--tags --all --stdin"
1314 _git_pull ()
1316 __git_complete_strategy && return
1318 local cur="${COMP_WORDS[COMP_CWORD]}"
1319 case "$cur" in
1320 --*)
1321 __gitcomp "
1322 --rebase --no-rebase
1323 $__git_merge_options
1324 $__git_fetch_options
1326 return
1328 esac
1329 __git_complete_remote_or_refspec
1332 _git_push ()
1334 local cur="${COMP_WORDS[COMP_CWORD]}"
1335 case "${COMP_WORDS[COMP_CWORD-1]}" in
1336 --repo)
1337 __gitcomp "$(__git_remotes)"
1338 return
1339 esac
1340 case "$cur" in
1341 --repo=*)
1342 __gitcomp "$(__git_remotes)" "" "${cur##--repo=}"
1343 return
1345 --*)
1346 __gitcomp "
1347 --all --mirror --tags --dry-run --force --verbose
1348 --receive-pack= --repo=
1350 return
1352 esac
1353 __git_complete_remote_or_refspec
1356 _git_rebase ()
1358 local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)"
1359 if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
1360 __gitcomp "--continue --skip --abort"
1361 return
1363 __git_complete_strategy && return
1364 case "$cur" in
1365 --whitespace=*)
1366 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
1367 return
1369 --*)
1370 __gitcomp "
1371 --onto --merge --strategy --interactive
1372 --preserve-merges --stat --no-stat
1373 --committer-date-is-author-date --ignore-date
1374 --ignore-whitespace --whitespace=
1377 return
1378 esac
1379 __gitcomp "$(__git_refs)"
1382 __git_send_email_confirm_options="always never auto cc compose"
1383 __git_send_email_suppresscc_options="author self cc bodycc sob cccmd body all"
1385 _git_send_email ()
1387 local cur="${COMP_WORDS[COMP_CWORD]}"
1388 case "$cur" in
1389 --confirm=*)
1390 __gitcomp "
1391 $__git_send_email_confirm_options
1392 " "" "${cur##--confirm=}"
1393 return
1395 --suppress-cc=*)
1396 __gitcomp "
1397 $__git_send_email_suppresscc_options
1398 " "" "${cur##--suppress-cc=}"
1400 return
1402 --smtp-encryption=*)
1403 __gitcomp "ssl tls" "" "${cur##--smtp-encryption=}"
1404 return
1406 --*)
1407 __gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to
1408 --compose --confirm= --dry-run --envelope-sender
1409 --from --identity
1410 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
1411 --no-suppress-from --no-thread --quiet
1412 --signed-off-by-cc --smtp-pass --smtp-server
1413 --smtp-server-port --smtp-encryption= --smtp-user
1414 --subject --suppress-cc= --suppress-from --thread --to
1415 --validate --no-validate"
1416 return
1418 esac
1419 COMPREPLY=()
1422 __git_config_get_set_variables ()
1424 local prevword word config_file= c=$COMP_CWORD
1425 while [ $c -gt 1 ]; do
1426 word="${COMP_WORDS[c]}"
1427 case "$word" in
1428 --global|--system|--file=*)
1429 config_file="$word"
1430 break
1432 -f|--file)
1433 config_file="$word $prevword"
1434 break
1436 esac
1437 prevword=$word
1438 c=$((--c))
1439 done
1441 git --git-dir="$(__gitdir)" config $config_file --list 2>/dev/null |
1442 while read line
1444 case "$line" in
1445 *.*=*)
1446 echo "${line/=*/}"
1448 esac
1449 done
1452 _git_config ()
1454 local cur="${COMP_WORDS[COMP_CWORD]}"
1455 local prv="${COMP_WORDS[COMP_CWORD-1]}"
1456 case "$prv" in
1457 branch.*.remote)
1458 __gitcomp "$(__git_remotes)"
1459 return
1461 branch.*.merge)
1462 __gitcomp "$(__git_refs)"
1463 return
1465 remote.*.fetch)
1466 local remote="${prv#remote.}"
1467 remote="${remote%.fetch}"
1468 __gitcomp "$(__git_refs_remotes "$remote")"
1469 return
1471 remote.*.push)
1472 local remote="${prv#remote.}"
1473 remote="${remote%.push}"
1474 __gitcomp "$(git --git-dir="$(__gitdir)" \
1475 for-each-ref --format='%(refname):%(refname)' \
1476 refs/heads)"
1477 return
1479 pull.twohead|pull.octopus)
1480 __git_compute_merge_strategies
1481 __gitcomp "$__git_merge_strategies"
1482 return
1484 color.branch|color.diff|color.interactive|\
1485 color.showbranch|color.status|color.ui)
1486 __gitcomp "always never auto"
1487 return
1489 color.pager)
1490 __gitcomp "false true"
1491 return
1493 color.*.*)
1494 __gitcomp "
1495 normal black red green yellow blue magenta cyan white
1496 bold dim ul blink reverse
1498 return
1500 help.format)
1501 __gitcomp "man info web html"
1502 return
1504 log.date)
1505 __gitcomp "$__git_log_date_formats"
1506 return
1508 sendemail.aliasesfiletype)
1509 __gitcomp "mutt mailrc pine elm gnus"
1510 return
1512 sendemail.confirm)
1513 __gitcomp "$__git_send_email_confirm_options"
1514 return
1516 sendemail.suppresscc)
1517 __gitcomp "$__git_send_email_suppresscc_options"
1518 return
1520 --get|--get-all|--unset|--unset-all)
1521 __gitcomp "$(__git_config_get_set_variables)"
1522 return
1524 *.*)
1525 COMPREPLY=()
1526 return
1528 esac
1529 case "$cur" in
1530 --*)
1531 __gitcomp "
1532 --global --system --file=
1533 --list --replace-all
1534 --get --get-all --get-regexp
1535 --add --unset --unset-all
1536 --remove-section --rename-section
1538 return
1540 branch.*.*)
1541 local pfx="${cur%.*}."
1542 cur="${cur##*.}"
1543 __gitcomp "remote merge mergeoptions rebase" "$pfx" "$cur"
1544 return
1546 branch.*)
1547 local pfx="${cur%.*}."
1548 cur="${cur#*.}"
1549 __gitcomp "$(__git_heads)" "$pfx" "$cur" "."
1550 return
1552 guitool.*.*)
1553 local pfx="${cur%.*}."
1554 cur="${cur##*.}"
1555 __gitcomp "
1556 argprompt cmd confirm needsfile noconsole norescan
1557 prompt revprompt revunmerged title
1558 " "$pfx" "$cur"
1559 return
1561 difftool.*.*)
1562 local pfx="${cur%.*}."
1563 cur="${cur##*.}"
1564 __gitcomp "cmd path" "$pfx" "$cur"
1565 return
1567 man.*.*)
1568 local pfx="${cur%.*}."
1569 cur="${cur##*.}"
1570 __gitcomp "cmd path" "$pfx" "$cur"
1571 return
1573 mergetool.*.*)
1574 local pfx="${cur%.*}."
1575 cur="${cur##*.}"
1576 __gitcomp "cmd path trustExitCode" "$pfx" "$cur"
1577 return
1579 pager.*)
1580 local pfx="${cur%.*}."
1581 cur="${cur#*.}"
1582 __git_compute_all_commands
1583 __gitcomp "$__git_all_commands" "$pfx" "$cur"
1584 return
1586 remote.*.*)
1587 local pfx="${cur%.*}."
1588 cur="${cur##*.}"
1589 __gitcomp "
1590 url proxy fetch push mirror skipDefaultUpdate
1591 receivepack uploadpack tagopt pushurl
1592 " "$pfx" "$cur"
1593 return
1595 remote.*)
1596 local pfx="${cur%.*}."
1597 cur="${cur#*.}"
1598 __gitcomp "$(__git_remotes)" "$pfx" "$cur" "."
1599 return
1601 url.*.*)
1602 local pfx="${cur%.*}."
1603 cur="${cur##*.}"
1604 __gitcomp "insteadOf pushInsteadOf" "$pfx" "$cur"
1605 return
1607 esac
1608 __gitcomp "
1609 add.ignore-errors
1610 alias.
1611 apply.ignorewhitespace
1612 apply.whitespace
1613 branch.autosetupmerge
1614 branch.autosetuprebase
1615 clean.requireForce
1616 color.branch
1617 color.branch.current
1618 color.branch.local
1619 color.branch.plain
1620 color.branch.remote
1621 color.diff
1622 color.diff.commit
1623 color.diff.frag
1624 color.diff.meta
1625 color.diff.new
1626 color.diff.old
1627 color.diff.plain
1628 color.diff.whitespace
1629 color.grep
1630 color.grep.external
1631 color.grep.match
1632 color.interactive
1633 color.interactive.header
1634 color.interactive.help
1635 color.interactive.prompt
1636 color.pager
1637 color.showbranch
1638 color.status
1639 color.status.added
1640 color.status.changed
1641 color.status.header
1642 color.status.nobranch
1643 color.status.untracked
1644 color.status.updated
1645 color.ui
1646 commit.template
1647 core.autocrlf
1648 core.bare
1649 core.compression
1650 core.createObject
1651 core.deltaBaseCacheLimit
1652 core.editor
1653 core.excludesfile
1654 core.fileMode
1655 core.fsyncobjectfiles
1656 core.gitProxy
1657 core.ignoreCygwinFSTricks
1658 core.ignoreStat
1659 core.logAllRefUpdates
1660 core.loosecompression
1661 core.packedGitLimit
1662 core.packedGitWindowSize
1663 core.pager
1664 core.preferSymlinkRefs
1665 core.preloadindex
1666 core.quotepath
1667 core.repositoryFormatVersion
1668 core.safecrlf
1669 core.sharedRepository
1670 core.symlinks
1671 core.trustctime
1672 core.warnAmbiguousRefs
1673 core.whitespace
1674 core.worktree
1675 diff.autorefreshindex
1676 diff.external
1677 diff.mnemonicprefix
1678 diff.renameLimit
1679 diff.renameLimit.
1680 diff.renames
1681 diff.suppressBlankEmpty
1682 diff.tool
1683 diff.wordRegex
1684 difftool.
1685 difftool.prompt
1686 fetch.unpackLimit
1687 format.attach
1688 format.cc
1689 format.headers
1690 format.numbered
1691 format.pretty
1692 format.signoff
1693 format.subjectprefix
1694 format.suffix
1695 format.thread
1696 gc.aggressiveWindow
1697 gc.auto
1698 gc.autopacklimit
1699 gc.packrefs
1700 gc.pruneexpire
1701 gc.reflogexpire
1702 gc.reflogexpireunreachable
1703 gc.rerereresolved
1704 gc.rerereunresolved
1705 gitcvs.allbinary
1706 gitcvs.commitmsgannotation
1707 gitcvs.dbTableNamePrefix
1708 gitcvs.dbdriver
1709 gitcvs.dbname
1710 gitcvs.dbpass
1711 gitcvs.dbuser
1712 gitcvs.enabled
1713 gitcvs.logfile
1714 gitcvs.usecrlfattr
1715 guitool.
1716 gui.blamehistoryctx
1717 gui.commitmsgwidth
1718 gui.copyblamethreshold
1719 gui.diffcontext
1720 gui.encoding
1721 gui.fastcopyblame
1722 gui.matchtrackingbranch
1723 gui.newbranchtemplate
1724 gui.pruneduringfetch
1725 gui.spellingdictionary
1726 gui.trustmtime
1727 help.autocorrect
1728 help.browser
1729 help.format
1730 http.lowSpeedLimit
1731 http.lowSpeedTime
1732 http.maxRequests
1733 http.noEPSV
1734 http.proxy
1735 http.sslCAInfo
1736 http.sslCAPath
1737 http.sslCert
1738 http.sslKey
1739 http.sslVerify
1740 i18n.commitEncoding
1741 i18n.logOutputEncoding
1742 imap.folder
1743 imap.host
1744 imap.pass
1745 imap.port
1746 imap.preformattedHTML
1747 imap.sslverify
1748 imap.tunnel
1749 imap.user
1750 instaweb.browser
1751 instaweb.httpd
1752 instaweb.local
1753 instaweb.modulepath
1754 instaweb.port
1755 interactive.singlekey
1756 log.date
1757 log.showroot
1758 mailmap.file
1759 man.
1760 man.viewer
1761 merge.conflictstyle
1762 merge.log
1763 merge.renameLimit
1764 merge.stat
1765 merge.tool
1766 merge.verbosity
1767 mergetool.
1768 mergetool.keepBackup
1769 mergetool.prompt
1770 pack.compression
1771 pack.deltaCacheLimit
1772 pack.deltaCacheSize
1773 pack.depth
1774 pack.indexVersion
1775 pack.packSizeLimit
1776 pack.threads
1777 pack.window
1778 pack.windowMemory
1779 pager.
1780 pull.octopus
1781 pull.twohead
1782 push.default
1783 rebase.stat
1784 receive.denyCurrentBranch
1785 receive.denyDeletes
1786 receive.denyNonFastForwards
1787 receive.fsckObjects
1788 receive.unpackLimit
1789 repack.usedeltabaseoffset
1790 rerere.autoupdate
1791 rerere.enabled
1792 sendemail.aliasesfile
1793 sendemail.aliasesfiletype
1794 sendemail.bcc
1795 sendemail.cc
1796 sendemail.cccmd
1797 sendemail.chainreplyto
1798 sendemail.confirm
1799 sendemail.envelopesender
1800 sendemail.multiedit
1801 sendemail.signedoffbycc
1802 sendemail.smtpencryption
1803 sendemail.smtppass
1804 sendemail.smtpserver
1805 sendemail.smtpserverport
1806 sendemail.smtpuser
1807 sendemail.suppresscc
1808 sendemail.suppressfrom
1809 sendemail.thread
1810 sendemail.to
1811 sendemail.validate
1812 showbranch.default
1813 status.relativePaths
1814 status.showUntrackedFiles
1815 tar.umask
1816 transfer.unpackLimit
1817 url.
1818 user.email
1819 user.name
1820 user.signingkey
1821 web.browser
1822 branch. remote.
1826 _git_remote ()
1828 local subcommands="add rename rm show prune update set-head"
1829 local subcommand="$(__git_find_on_cmdline "$subcommands")"
1830 if [ -z "$subcommand" ]; then
1831 __gitcomp "$subcommands"
1832 return
1835 case "$subcommand" in
1836 rename|rm|show|prune)
1837 __gitcomp "$(__git_remotes)"
1839 update)
1840 local i c='' IFS=$'\n'
1841 for i in $(git --git-dir="$(__gitdir)" config --get-regexp "remotes\..*" 2>/dev/null); do
1842 i="${i#remotes.}"
1843 c="$c ${i/ */}"
1844 done
1845 __gitcomp "$c"
1848 COMPREPLY=()
1850 esac
1853 _git_replace ()
1855 __gitcomp "$(__git_refs)"
1858 _git_reset ()
1860 __git_has_doubledash && return
1862 local cur="${COMP_WORDS[COMP_CWORD]}"
1863 case "$cur" in
1864 --*)
1865 __gitcomp "--merge --mixed --hard --soft --patch"
1866 return
1868 esac
1869 __gitcomp "$(__git_refs)"
1872 _git_revert ()
1874 local cur="${COMP_WORDS[COMP_CWORD]}"
1875 case "$cur" in
1876 --*)
1877 __gitcomp "--edit --mainline --no-edit --no-commit --signoff"
1878 return
1880 esac
1881 __gitcomp "$(__git_refs)"
1884 _git_rm ()
1886 __git_has_doubledash && return
1888 local cur="${COMP_WORDS[COMP_CWORD]}"
1889 case "$cur" in
1890 --*)
1891 __gitcomp "--cached --dry-run --ignore-unmatch --quiet"
1892 return
1894 esac
1895 COMPREPLY=()
1898 _git_shortlog ()
1900 __git_has_doubledash && return
1902 local cur="${COMP_WORDS[COMP_CWORD]}"
1903 case "$cur" in
1904 --*)
1905 __gitcomp "
1906 $__git_log_common_options
1907 $__git_log_shortlog_options
1908 --numbered --summary
1910 return
1912 esac
1913 __git_complete_revlist
1916 _git_show ()
1918 __git_has_doubledash && return
1920 local cur="${COMP_WORDS[COMP_CWORD]}"
1921 case "$cur" in
1922 --pretty=*)
1923 __gitcomp "$__git_log_pretty_formats
1924 " "" "${cur##--pretty=}"
1925 return
1927 --format=*)
1928 __gitcomp "$__git_log_pretty_formats
1929 " "" "${cur##--format=}"
1930 return
1932 --*)
1933 __gitcomp "--pretty= --format= --abbrev-commit --oneline
1934 $__git_diff_common_options
1936 return
1938 esac
1939 __git_complete_file
1942 _git_show_branch ()
1944 local cur="${COMP_WORDS[COMP_CWORD]}"
1945 case "$cur" in
1946 --*)
1947 __gitcomp "
1948 --all --remotes --topo-order --current --more=
1949 --list --independent --merge-base --no-name
1950 --color --no-color
1951 --sha1-name --sparse --topics --reflog
1953 return
1955 esac
1956 __git_complete_revlist
1959 _git_stash ()
1961 local cur="${COMP_WORDS[COMP_CWORD]}"
1962 local save_opts='--keep-index --no-keep-index --quiet --patch'
1963 local subcommands='save list show apply clear drop pop create branch'
1964 local subcommand="$(__git_find_on_cmdline "$subcommands")"
1965 if [ -z "$subcommand" ]; then
1966 case "$cur" in
1967 --*)
1968 __gitcomp "$save_opts"
1971 if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then
1972 __gitcomp "$subcommands"
1973 else
1974 COMPREPLY=()
1977 esac
1978 else
1979 case "$subcommand,$cur" in
1980 save,--*)
1981 __gitcomp "$save_opts"
1983 apply,--*|pop,--*)
1984 __gitcomp "--index --quiet"
1986 show,--*|drop,--*|branch,--*)
1987 COMPREPLY=()
1989 show,*|apply,*|drop,*|pop,*|branch,*)
1990 __gitcomp "$(git --git-dir="$(__gitdir)" stash list \
1991 | sed -n -e 's/:.*//p')"
1994 COMPREPLY=()
1996 esac
2000 _git_submodule ()
2002 __git_has_doubledash && return
2004 local subcommands="add status init update summary foreach sync"
2005 if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then
2006 local cur="${COMP_WORDS[COMP_CWORD]}"
2007 case "$cur" in
2008 --*)
2009 __gitcomp "--quiet --cached"
2012 __gitcomp "$subcommands"
2014 esac
2015 return
2019 _git_svn ()
2021 local subcommands="
2022 init fetch clone rebase dcommit log find-rev
2023 set-tree commit-diff info create-ignore propget
2024 proplist show-ignore show-externals branch tag blame
2025 migrate
2027 local subcommand="$(__git_find_on_cmdline "$subcommands")"
2028 if [ -z "$subcommand" ]; then
2029 __gitcomp "$subcommands"
2030 else
2031 local remote_opts="--username= --config-dir= --no-auth-cache"
2032 local fc_opts="
2033 --follow-parent --authors-file= --repack=
2034 --no-metadata --use-svm-props --use-svnsync-props
2035 --log-window-size= --no-checkout --quiet
2036 --repack-flags --use-log-author --localtime
2037 --ignore-paths= $remote_opts
2039 local init_opts="
2040 --template= --shared= --trunk= --tags=
2041 --branches= --stdlayout --minimize-url
2042 --no-metadata --use-svm-props --use-svnsync-props
2043 --rewrite-root= --prefix= --use-log-author
2044 --add-author-from $remote_opts
2046 local cmt_opts="
2047 --edit --rmdir --find-copies-harder --copy-similarity=
2050 local cur="${COMP_WORDS[COMP_CWORD]}"
2051 case "$subcommand,$cur" in
2052 fetch,--*)
2053 __gitcomp "--revision= --fetch-all $fc_opts"
2055 clone,--*)
2056 __gitcomp "--revision= $fc_opts $init_opts"
2058 init,--*)
2059 __gitcomp "$init_opts"
2061 dcommit,--*)
2062 __gitcomp "
2063 --merge --strategy= --verbose --dry-run
2064 --fetch-all --no-rebase --commit-url
2065 --revision $cmt_opts $fc_opts
2068 set-tree,--*)
2069 __gitcomp "--stdin $cmt_opts $fc_opts"
2071 create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\
2072 show-externals,--*)
2073 __gitcomp "--revision="
2075 log,--*)
2076 __gitcomp "
2077 --limit= --revision= --verbose --incremental
2078 --oneline --show-commit --non-recursive
2079 --authors-file= --color
2082 rebase,--*)
2083 __gitcomp "
2084 --merge --verbose --strategy= --local
2085 --fetch-all --dry-run $fc_opts
2088 commit-diff,--*)
2089 __gitcomp "--message= --file= --revision= $cmt_opts"
2091 info,--*)
2092 __gitcomp "--url"
2094 branch,--*)
2095 __gitcomp "--dry-run --message --tag"
2097 tag,--*)
2098 __gitcomp "--dry-run --message"
2100 blame,--*)
2101 __gitcomp "--git-format"
2103 migrate,--*)
2104 __gitcomp "
2105 --config-dir= --ignore-paths= --minimize
2106 --no-auth-cache --username=
2110 COMPREPLY=()
2112 esac
2116 _git_tag ()
2118 local i c=1 f=0
2119 while [ $c -lt $COMP_CWORD ]; do
2120 i="${COMP_WORDS[c]}"
2121 case "$i" in
2122 -d|-v)
2123 __gitcomp "$(__git_tags)"
2124 return
2129 esac
2130 c=$((++c))
2131 done
2133 case "${COMP_WORDS[COMP_CWORD-1]}" in
2134 -m|-F)
2135 COMPREPLY=()
2137 -*|tag)
2138 if [ $f = 1 ]; then
2139 __gitcomp "$(__git_tags)"
2140 else
2141 COMPREPLY=()
2145 __gitcomp "$(__git_refs)"
2147 esac
2150 _git ()
2152 local i c=1 command __git_dir
2154 while [ $c -lt $COMP_CWORD ]; do
2155 i="${COMP_WORDS[c]}"
2156 case "$i" in
2157 --git-dir=*) __git_dir="${i#--git-dir=}" ;;
2158 --bare) __git_dir="." ;;
2159 --version|-p|--paginate) ;;
2160 --help) command="help"; break ;;
2161 *) command="$i"; break ;;
2162 esac
2163 c=$((++c))
2164 done
2166 if [ -z "$command" ]; then
2167 case "${COMP_WORDS[COMP_CWORD]}" in
2168 --*) __gitcomp "
2169 --paginate
2170 --no-pager
2171 --git-dir=
2172 --bare
2173 --version
2174 --exec-path
2175 --html-path
2176 --work-tree=
2177 --help
2180 *) __git_compute_porcelain_commands
2181 __gitcomp "$__git_porcelain_commands $(__git_aliases)" ;;
2182 esac
2183 return
2186 local expansion=$(__git_aliased_command "$command")
2187 [ "$expansion" ] && command="$expansion"
2189 case "$command" in
2190 am) _git_am ;;
2191 add) _git_add ;;
2192 apply) _git_apply ;;
2193 archive) _git_archive ;;
2194 bisect) _git_bisect ;;
2195 bundle) _git_bundle ;;
2196 branch) _git_branch ;;
2197 checkout) _git_checkout ;;
2198 cherry) _git_cherry ;;
2199 cherry-pick) _git_cherry_pick ;;
2200 clean) _git_clean ;;
2201 clone) _git_clone ;;
2202 commit) _git_commit ;;
2203 config) _git_config ;;
2204 describe) _git_describe ;;
2205 diff) _git_diff ;;
2206 difftool) _git_difftool ;;
2207 fetch) _git_fetch ;;
2208 format-patch) _git_format_patch ;;
2209 fsck) _git_fsck ;;
2210 gc) _git_gc ;;
2211 grep) _git_grep ;;
2212 help) _git_help ;;
2213 init) _git_init ;;
2214 log) _git_log ;;
2215 ls-files) _git_ls_files ;;
2216 ls-remote) _git_ls_remote ;;
2217 ls-tree) _git_ls_tree ;;
2218 merge) _git_merge;;
2219 mergetool) _git_mergetool;;
2220 merge-base) _git_merge_base ;;
2221 mv) _git_mv ;;
2222 name-rev) _git_name_rev ;;
2223 pull) _git_pull ;;
2224 push) _git_push ;;
2225 rebase) _git_rebase ;;
2226 remote) _git_remote ;;
2227 replace) _git_replace ;;
2228 reset) _git_reset ;;
2229 revert) _git_revert ;;
2230 rm) _git_rm ;;
2231 send-email) _git_send_email ;;
2232 shortlog) _git_shortlog ;;
2233 show) _git_show ;;
2234 show-branch) _git_show_branch ;;
2235 stash) _git_stash ;;
2236 stage) _git_add ;;
2237 submodule) _git_submodule ;;
2238 svn) _git_svn ;;
2239 tag) _git_tag ;;
2240 whatchanged) _git_log ;;
2241 *) COMPREPLY=() ;;
2242 esac
2245 _gitk ()
2247 __git_has_doubledash && return
2249 local cur="${COMP_WORDS[COMP_CWORD]}"
2250 local g="$(__gitdir)"
2251 local merge=""
2252 if [ -f "$g/MERGE_HEAD" ]; then
2253 merge="--merge"
2255 case "$cur" in
2256 --*)
2257 __gitcomp "
2258 $__git_log_common_options
2259 $__git_log_gitk_options
2260 $merge
2262 return
2264 esac
2265 __git_complete_revlist
2268 complete -o bashdefault -o default -o nospace -F _git git 2>/dev/null \
2269 || complete -o default -o nospace -F _git git
2270 complete -o bashdefault -o default -o nospace -F _gitk gitk 2>/dev/null \
2271 || complete -o default -o nospace -F _gitk gitk
2273 # The following are necessary only for Cygwin, and only are needed
2274 # when the user has tab-completed the executable name and consequently
2275 # included the '.exe' suffix.
2277 if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
2278 complete -o bashdefault -o default -o nospace -F _git git.exe 2>/dev/null \
2279 || complete -o default -o nospace -F _git git.exe