bash: remove always true if statement from __git_ps1()
[git/mingw.git] / contrib / completion / git-completion.bash
blob98b9cbedc2bcae32491fc69641740b186a64ab26
1 #!bash
3 # bash completion support for core Git.
5 # Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
6 # Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
7 # Distributed under the GNU General Public License, version 2.0.
9 # The contained completion routines provide support for completing:
11 # *) local and remote branch names
12 # *) local and remote tag names
13 # *) .git/remotes file names
14 # *) git 'subcommands'
15 # *) tree paths within 'ref:path/to/file' expressions
16 # *) common --long-options
18 # To use these routines:
20 # 1) Copy this file to somewhere (e.g. ~/.git-completion.sh).
21 # 2) Added the following line to your .bashrc:
22 # source ~/.git-completion.sh
24 # 3) You may want to make sure the git executable is available
25 # in your PATH before this script is sourced, as some caching
26 # is performed while the script loads. If git isn't found
27 # at source time then all lookups will be done on demand,
28 # which may be slightly slower.
30 # 4) Consider changing your PS1 to also show the current branch:
31 # PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
33 # The argument to __git_ps1 will be displayed only if you
34 # are currently in a git repository. The %s token will be
35 # the name of the current branch.
37 # In addition, if you set GIT_PS1_SHOWDIRTYSTATE to a nonempty
38 # value, unstaged (*) and staged (+) changes will be shown next
39 # to the branch name. You can configure this per-repository
40 # with the bash.showDirtyState variable, which defaults to true
41 # once GIT_PS1_SHOWDIRTYSTATE is enabled.
43 # To submit patches:
45 # *) Read Documentation/SubmittingPatches
46 # *) Send all patches to the current maintainer:
48 # "Shawn O. Pearce" <spearce@spearce.org>
50 # *) Always CC the Git mailing list:
52 # git@vger.kernel.org
55 case "$COMP_WORDBREAKS" in
56 *:*) : great ;;
57 *) COMP_WORDBREAKS="$COMP_WORDBREAKS:"
58 esac
60 # __gitdir accepts 0 or 1 arguments (i.e., location)
61 # returns location of .git repo
62 __gitdir ()
64 if [ -z "${1-}" ]; then
65 if [ -n "${__git_dir-}" ]; then
66 echo "$__git_dir"
67 elif [ -d .git ]; then
68 echo .git
69 else
70 git rev-parse --git-dir 2>/dev/null
72 elif [ -d "$1/.git" ]; then
73 echo "$1/.git"
74 else
75 echo "$1"
79 # __git_ps1 accepts 0 or 1 arguments (i.e., format string)
80 # returns text to add to bash PS1 prompt (includes branch name)
81 __git_ps1 ()
83 local g="$(__gitdir)"
84 if [ -n "$g" ]; then
85 local r
86 local b
87 if [ -f "$g/rebase-merge/interactive" ]; then
88 r="|REBASE-i"
89 b="$(cat "$g/rebase-merge/head-name")"
90 elif [ -d "$g/rebase-merge" ]; then
91 r="|REBASE-m"
92 b="$(cat "$g/rebase-merge/head-name")"
93 else
94 if [ -d "$g/rebase-apply" ]; then
95 if [ -f "$g/rebase-apply/rebasing" ]; then
96 r="|REBASE"
97 elif [ -f "$g/rebase-apply/applying" ]; then
98 r="|AM"
99 else
100 r="|AM/REBASE"
102 elif [ -f "$g/MERGE_HEAD" ]; then
103 r="|MERGING"
104 elif [ -f "$g/BISECT_LOG" ]; then
105 r="|BISECTING"
108 b="$(git symbolic-ref HEAD 2>/dev/null)" || {
110 b="$(
111 case "${GIT_PS1_DESCRIBE_STYLE-}" in
112 (contains)
113 git describe --contains HEAD ;;
114 (branch)
115 git describe --contains --all HEAD ;;
116 (describe)
117 git describe HEAD ;;
118 (* | default)
119 git describe --exact-match HEAD ;;
120 esac 2>/dev/null)" ||
122 b="$(cut -c1-7 "$g/HEAD" 2>/dev/null)..." ||
123 b="unknown"
124 b="($b)"
128 local w
129 local i
130 local c
132 if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then
133 if [ "true" = "$(git rev-parse --is-bare-repository 2>/dev/null)" ]; then
134 c="BARE:"
135 else
136 b="GIT_DIR!"
138 elif [ "true" = "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
139 if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ]; then
140 if [ "$(git config --bool bash.showDirtyState)" != "false" ]; then
141 git diff --no-ext-diff --ignore-submodules \
142 --quiet --exit-code || w="*"
143 if git rev-parse --quiet --verify HEAD >/dev/null; then
144 git diff-index --cached --quiet \
145 --ignore-submodules HEAD -- || i="+"
146 else
147 i="#"
153 if [ -n "${1-}" ]; then
154 printf "$1" "$c${b##refs/heads/}$w$i$r"
155 else
156 printf " (%s)" "$c${b##refs/heads/}$w$i$r"
161 # __gitcomp_1 requires 2 arguments
162 __gitcomp_1 ()
164 local c IFS=' '$'\t'$'\n'
165 for c in $1; do
166 case "$c$2" in
167 --*=*) printf %s$'\n' "$c$2" ;;
168 *.) printf %s$'\n' "$c$2" ;;
169 *) printf %s$'\n' "$c$2 " ;;
170 esac
171 done
174 # __gitcomp accepts 1, 2, 3, or 4 arguments
175 # generates completion reply with compgen
176 __gitcomp ()
178 local cur="${COMP_WORDS[COMP_CWORD]}"
179 if [ $# -gt 2 ]; then
180 cur="$3"
182 case "$cur" in
183 --*=)
184 COMPREPLY=()
187 local IFS=$'\n'
188 COMPREPLY=($(compgen -P "${2-}" \
189 -W "$(__gitcomp_1 "${1-}" "${4-}")" \
190 -- "$cur"))
192 esac
195 # __git_heads accepts 0 or 1 arguments (to pass to __gitdir)
196 __git_heads ()
198 local cmd i is_hash=y dir="$(__gitdir "${1-}")"
199 if [ -d "$dir" ]; then
200 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
201 refs/heads
202 return
204 for i in $(git ls-remote "${1-}" 2>/dev/null); do
205 case "$is_hash,$i" in
206 y,*) is_hash=n ;;
207 n,*^{}) is_hash=y ;;
208 n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
209 n,*) is_hash=y; echo "$i" ;;
210 esac
211 done
214 # __git_tags accepts 0 or 1 arguments (to pass to __gitdir)
215 __git_tags ()
217 local cmd i is_hash=y dir="$(__gitdir "${1-}")"
218 if [ -d "$dir" ]; then
219 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
220 refs/tags
221 return
223 for i in $(git ls-remote "${1-}" 2>/dev/null); do
224 case "$is_hash,$i" in
225 y,*) is_hash=n ;;
226 n,*^{}) is_hash=y ;;
227 n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
228 n,*) is_hash=y; echo "$i" ;;
229 esac
230 done
233 # __git_refs accepts 0 or 1 arguments (to pass to __gitdir)
234 __git_refs ()
236 local i is_hash=y dir="$(__gitdir "${1-}")"
237 local cur="${COMP_WORDS[COMP_CWORD]}" format refs
238 if [ -d "$dir" ]; then
239 case "$cur" in
240 refs|refs/*)
241 format="refname"
242 refs="${cur%/*}"
245 if [ -e "$dir/HEAD" ]; then echo HEAD; fi
246 format="refname:short"
247 refs="refs/tags refs/heads refs/remotes"
249 esac
250 git --git-dir="$dir" for-each-ref --format="%($format)" \
251 $refs
252 return
254 for i in $(git ls-remote "$dir" 2>/dev/null); do
255 case "$is_hash,$i" in
256 y,*) is_hash=n ;;
257 n,*^{}) is_hash=y ;;
258 n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
259 n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
260 n,refs/remotes/*) is_hash=y; echo "${i#refs/remotes/}" ;;
261 n,*) is_hash=y; echo "$i" ;;
262 esac
263 done
266 # __git_refs2 requires 1 argument (to pass to __git_refs)
267 __git_refs2 ()
269 local i
270 for i in $(__git_refs "$1"); do
271 echo "$i:$i"
272 done
275 # __git_refs_remotes requires 1 argument (to pass to ls-remote)
276 __git_refs_remotes ()
278 local cmd i is_hash=y
279 for i in $(git ls-remote "$1" 2>/dev/null); do
280 case "$is_hash,$i" in
281 n,refs/heads/*)
282 is_hash=y
283 echo "$i:refs/remotes/$1/${i#refs/heads/}"
285 y,*) is_hash=n ;;
286 n,*^{}) is_hash=y ;;
287 n,refs/tags/*) is_hash=y;;
288 n,*) is_hash=y; ;;
289 esac
290 done
293 __git_remotes ()
295 local i ngoff IFS=$'\n' d="$(__gitdir)"
296 shopt -q nullglob || ngoff=1
297 shopt -s nullglob
298 for i in "$d/remotes"/*; do
299 echo ${i#$d/remotes/}
300 done
301 [ "$ngoff" ] && shopt -u nullglob
302 for i in $(git --git-dir="$d" config --list); do
303 case "$i" in
304 remote.*.url=*)
305 i="${i#remote.}"
306 echo "${i/.url=*/}"
308 esac
309 done
312 __git_merge_strategies ()
314 if [ -n "${__git_merge_strategylist-}" ]; then
315 echo "$__git_merge_strategylist"
316 return
318 git merge -s help 2>&1 |
319 sed -n -e '/[Aa]vailable strategies are: /,/^$/{
320 s/\.$//
321 s/.*://
322 s/^[ ]*//
323 s/[ ]*$//
327 __git_merge_strategylist=
328 __git_merge_strategylist=$(__git_merge_strategies 2>/dev/null)
330 __git_complete_file ()
332 local pfx ls ref cur="${COMP_WORDS[COMP_CWORD]}"
333 case "$cur" in
334 ?*:*)
335 ref="${cur%%:*}"
336 cur="${cur#*:}"
337 case "$cur" in
338 ?*/*)
339 pfx="${cur%/*}"
340 cur="${cur##*/}"
341 ls="$ref:$pfx"
342 pfx="$pfx/"
345 ls="$ref"
347 esac
349 case "$COMP_WORDBREAKS" in
350 *:*) : great ;;
351 *) pfx="$ref:$pfx" ;;
352 esac
354 local IFS=$'\n'
355 COMPREPLY=($(compgen -P "$pfx" \
356 -W "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \
357 | sed '/^100... blob /{
358 s,^.* ,,
359 s,$, ,
361 /^120000 blob /{
362 s,^.* ,,
363 s,$, ,
365 /^040000 tree /{
366 s,^.* ,,
367 s,$,/,
369 s/^.* //')" \
370 -- "$cur"))
373 __gitcomp "$(__git_refs)"
375 esac
378 __git_complete_revlist ()
380 local pfx cur="${COMP_WORDS[COMP_CWORD]}"
381 case "$cur" in
382 *...*)
383 pfx="${cur%...*}..."
384 cur="${cur#*...}"
385 __gitcomp "$(__git_refs)" "$pfx" "$cur"
387 *..*)
388 pfx="${cur%..*}.."
389 cur="${cur#*..}"
390 __gitcomp "$(__git_refs)" "$pfx" "$cur"
393 __gitcomp "$(__git_refs)"
395 esac
398 __git_complete_remote_or_refspec ()
400 local cmd="${COMP_WORDS[1]}"
401 local cur="${COMP_WORDS[COMP_CWORD]}"
402 local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0
403 while [ $c -lt $COMP_CWORD ]; do
404 i="${COMP_WORDS[c]}"
405 case "$i" in
406 --all|--mirror) [ "$cmd" = "push" ] && no_complete_refspec=1 ;;
407 -*) ;;
408 *) remote="$i"; break ;;
409 esac
410 c=$((++c))
411 done
412 if [ -z "$remote" ]; then
413 __gitcomp "$(__git_remotes)"
414 return
416 if [ $no_complete_refspec = 1 ]; then
417 COMPREPLY=()
418 return
420 [ "$remote" = "." ] && remote=
421 case "$cur" in
422 *:*)
423 case "$COMP_WORDBREAKS" in
424 *:*) : great ;;
425 *) pfx="${cur%%:*}:" ;;
426 esac
427 cur="${cur#*:}"
428 lhs=0
431 pfx="+"
432 cur="${cur#+}"
434 esac
435 case "$cmd" in
436 fetch)
437 if [ $lhs = 1 ]; then
438 __gitcomp "$(__git_refs2 "$remote")" "$pfx" "$cur"
439 else
440 __gitcomp "$(__git_refs)" "$pfx" "$cur"
443 pull)
444 if [ $lhs = 1 ]; then
445 __gitcomp "$(__git_refs "$remote")" "$pfx" "$cur"
446 else
447 __gitcomp "$(__git_refs)" "$pfx" "$cur"
450 push)
451 if [ $lhs = 1 ]; then
452 __gitcomp "$(__git_refs)" "$pfx" "$cur"
453 else
454 __gitcomp "$(__git_refs "$remote")" "$pfx" "$cur"
457 esac
460 __git_complete_strategy ()
462 case "${COMP_WORDS[COMP_CWORD-1]}" in
463 -s|--strategy)
464 __gitcomp "$(__git_merge_strategies)"
465 return 0
466 esac
467 local cur="${COMP_WORDS[COMP_CWORD]}"
468 case "$cur" in
469 --strategy=*)
470 __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}"
471 return 0
473 esac
474 return 1
477 __git_all_commands ()
479 if [ -n "${__git_all_commandlist-}" ]; then
480 echo "$__git_all_commandlist"
481 return
483 local i IFS=" "$'\n'
484 for i in $(git help -a|egrep '^ ')
486 case $i in
487 *--*) : helper pattern;;
488 *) echo $i;;
489 esac
490 done
492 __git_all_commandlist=
493 __git_all_commandlist="$(__git_all_commands 2>/dev/null)"
495 __git_porcelain_commands ()
497 if [ -n "${__git_porcelain_commandlist-}" ]; then
498 echo "$__git_porcelain_commandlist"
499 return
501 local i IFS=" "$'\n'
502 for i in "help" $(__git_all_commands)
504 case $i in
505 *--*) : helper pattern;;
506 applymbox) : ask gittus;;
507 applypatch) : ask gittus;;
508 archimport) : import;;
509 cat-file) : plumbing;;
510 check-attr) : plumbing;;
511 check-ref-format) : plumbing;;
512 checkout-index) : plumbing;;
513 commit-tree) : plumbing;;
514 count-objects) : infrequent;;
515 cvsexportcommit) : export;;
516 cvsimport) : import;;
517 cvsserver) : daemon;;
518 daemon) : daemon;;
519 diff-files) : plumbing;;
520 diff-index) : plumbing;;
521 diff-tree) : plumbing;;
522 fast-import) : import;;
523 fast-export) : export;;
524 fsck-objects) : plumbing;;
525 fetch-pack) : plumbing;;
526 fmt-merge-msg) : plumbing;;
527 for-each-ref) : plumbing;;
528 hash-object) : plumbing;;
529 http-*) : transport;;
530 index-pack) : plumbing;;
531 init-db) : deprecated;;
532 local-fetch) : plumbing;;
533 lost-found) : infrequent;;
534 ls-files) : plumbing;;
535 ls-remote) : plumbing;;
536 ls-tree) : plumbing;;
537 mailinfo) : plumbing;;
538 mailsplit) : plumbing;;
539 merge-*) : plumbing;;
540 mktree) : plumbing;;
541 mktag) : plumbing;;
542 pack-objects) : plumbing;;
543 pack-redundant) : plumbing;;
544 pack-refs) : plumbing;;
545 parse-remote) : plumbing;;
546 patch-id) : plumbing;;
547 peek-remote) : plumbing;;
548 prune) : plumbing;;
549 prune-packed) : plumbing;;
550 quiltimport) : import;;
551 read-tree) : plumbing;;
552 receive-pack) : plumbing;;
553 reflog) : plumbing;;
554 repo-config) : deprecated;;
555 rerere) : plumbing;;
556 rev-list) : plumbing;;
557 rev-parse) : plumbing;;
558 runstatus) : plumbing;;
559 sh-setup) : internal;;
560 shell) : daemon;;
561 show-ref) : plumbing;;
562 send-pack) : plumbing;;
563 show-index) : plumbing;;
564 ssh-*) : transport;;
565 stripspace) : plumbing;;
566 symbolic-ref) : plumbing;;
567 tar-tree) : deprecated;;
568 unpack-file) : plumbing;;
569 unpack-objects) : plumbing;;
570 update-index) : plumbing;;
571 update-ref) : plumbing;;
572 update-server-info) : daemon;;
573 upload-archive) : plumbing;;
574 upload-pack) : plumbing;;
575 write-tree) : plumbing;;
576 var) : infrequent;;
577 verify-pack) : infrequent;;
578 verify-tag) : plumbing;;
579 *) echo $i;;
580 esac
581 done
583 __git_porcelain_commandlist=
584 __git_porcelain_commandlist="$(__git_porcelain_commands 2>/dev/null)"
586 __git_aliases ()
588 local i IFS=$'\n'
589 for i in $(git --git-dir="$(__gitdir)" config --list); do
590 case "$i" in
591 alias.*)
592 i="${i#alias.}"
593 echo "${i/=*/}"
595 esac
596 done
599 # __git_aliased_command requires 1 argument
600 __git_aliased_command ()
602 local word cmdline=$(git --git-dir="$(__gitdir)" \
603 config --get "alias.$1")
604 for word in $cmdline; do
605 if [ "${word##-*}" ]; then
606 echo $word
607 return
609 done
612 # __git_find_subcommand requires 1 argument
613 __git_find_subcommand ()
615 local word subcommand c=1
617 while [ $c -lt $COMP_CWORD ]; do
618 word="${COMP_WORDS[c]}"
619 for subcommand in $1; do
620 if [ "$subcommand" = "$word" ]; then
621 echo "$subcommand"
622 return
624 done
625 c=$((++c))
626 done
629 __git_has_doubledash ()
631 local c=1
632 while [ $c -lt $COMP_CWORD ]; do
633 if [ "--" = "${COMP_WORDS[c]}" ]; then
634 return 0
636 c=$((++c))
637 done
638 return 1
641 __git_whitespacelist="nowarn warn error error-all fix"
643 _git_am ()
645 local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)"
646 if [ -d "$dir"/rebase-apply ]; then
647 __gitcomp "--skip --resolved --abort"
648 return
650 case "$cur" in
651 --whitespace=*)
652 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
653 return
655 --*)
656 __gitcomp "
657 --3way --committer-date-is-author-date --ignore-date
658 --interactive --keep --no-utf8 --signoff --utf8
659 --whitespace=
661 return
662 esac
663 COMPREPLY=()
666 _git_apply ()
668 local cur="${COMP_WORDS[COMP_CWORD]}"
669 case "$cur" in
670 --whitespace=*)
671 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
672 return
674 --*)
675 __gitcomp "
676 --stat --numstat --summary --check --index
677 --cached --index-info --reverse --reject --unidiff-zero
678 --apply --no-add --exclude=
679 --whitespace= --inaccurate-eof --verbose
681 return
682 esac
683 COMPREPLY=()
686 _git_add ()
688 __git_has_doubledash && return
690 local cur="${COMP_WORDS[COMP_CWORD]}"
691 case "$cur" in
692 --*)
693 __gitcomp "
694 --interactive --refresh --patch --update --dry-run
695 --ignore-errors --intent-to-add
697 return
698 esac
699 COMPREPLY=()
702 _git_archive ()
704 local cur="${COMP_WORDS[COMP_CWORD]}"
705 case "$cur" in
706 --format=*)
707 __gitcomp "$(git archive --list)" "" "${cur##--format=}"
708 return
710 --remote=*)
711 __gitcomp "$(__git_remotes)" "" "${cur##--remote=}"
712 return
714 --*)
715 __gitcomp "
716 --format= --list --verbose
717 --prefix= --remote= --exec=
719 return
721 esac
722 __git_complete_file
725 _git_bisect ()
727 __git_has_doubledash && return
729 local subcommands="start bad good skip reset visualize replay log run"
730 local subcommand="$(__git_find_subcommand "$subcommands")"
731 if [ -z "$subcommand" ]; then
732 __gitcomp "$subcommands"
733 return
736 case "$subcommand" in
737 bad|good|reset|skip)
738 __gitcomp "$(__git_refs)"
741 COMPREPLY=()
743 esac
746 _git_branch ()
748 local i c=1 only_local_ref="n" has_r="n"
750 while [ $c -lt $COMP_CWORD ]; do
751 i="${COMP_WORDS[c]}"
752 case "$i" in
753 -d|-m) only_local_ref="y" ;;
754 -r) has_r="y" ;;
755 esac
756 c=$((++c))
757 done
759 case "${COMP_WORDS[COMP_CWORD]}" in
760 --*)
761 __gitcomp "
762 --color --no-color --verbose --abbrev= --no-abbrev
763 --track --no-track --contains --merged --no-merged
767 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
768 __gitcomp "$(__git_heads)"
769 else
770 __gitcomp "$(__git_refs)"
773 esac
776 _git_bundle ()
778 local cmd="${COMP_WORDS[2]}"
779 case "$COMP_CWORD" in
781 __gitcomp "create list-heads verify unbundle"
784 # looking for a file
787 case "$cmd" in
788 create)
789 __git_complete_revlist
791 esac
793 esac
796 _git_checkout ()
798 __git_has_doubledash && return
800 __gitcomp "$(__git_refs)"
803 _git_cherry ()
805 __gitcomp "$(__git_refs)"
808 _git_cherry_pick ()
810 local cur="${COMP_WORDS[COMP_CWORD]}"
811 case "$cur" in
812 --*)
813 __gitcomp "--edit --no-commit"
816 __gitcomp "$(__git_refs)"
818 esac
821 _git_clean ()
823 __git_has_doubledash && return
825 local cur="${COMP_WORDS[COMP_CWORD]}"
826 case "$cur" in
827 --*)
828 __gitcomp "--dry-run --quiet"
829 return
831 esac
832 COMPREPLY=()
835 _git_clone ()
837 local cur="${COMP_WORDS[COMP_CWORD]}"
838 case "$cur" in
839 --*)
840 __gitcomp "
841 --local
842 --no-hardlinks
843 --shared
844 --reference
845 --quiet
846 --no-checkout
847 --bare
848 --mirror
849 --origin
850 --upload-pack
851 --template=
852 --depth
854 return
856 esac
857 COMPREPLY=()
860 _git_commit ()
862 __git_has_doubledash && return
864 local cur="${COMP_WORDS[COMP_CWORD]}"
865 case "$cur" in
866 --*)
867 __gitcomp "
868 --all --author= --signoff --verify --no-verify
869 --edit --amend --include --only --interactive
871 return
872 esac
873 COMPREPLY=()
876 _git_describe ()
878 local cur="${COMP_WORDS[COMP_CWORD]}"
879 case "$cur" in
880 --*)
881 __gitcomp "
882 --all --tags --contains --abbrev= --candidates=
883 --exact-match --debug --long --match --always
885 return
886 esac
887 __gitcomp "$(__git_refs)"
890 __git_diff_common_options="--stat --numstat --shortstat --summary
891 --patch-with-stat --name-only --name-status --color
892 --no-color --color-words --no-renames --check
893 --full-index --binary --abbrev --diff-filter=
894 --find-copies-harder
895 --text --ignore-space-at-eol --ignore-space-change
896 --ignore-all-space --exit-code --quiet --ext-diff
897 --no-ext-diff
898 --no-prefix --src-prefix= --dst-prefix=
899 --inter-hunk-context=
900 --patience
901 --raw
904 _git_diff ()
906 __git_has_doubledash && return
908 local cur="${COMP_WORDS[COMP_CWORD]}"
909 case "$cur" in
910 --*)
911 __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
912 --base --ours --theirs
913 $__git_diff_common_options
915 return
917 esac
918 __git_complete_file
921 __git_mergetools_common="diffuse ecmerge emerge kdiff3 meld opendiff
922 tkdiff vimdiff gvimdiff xxdiff
925 _git_difftool ()
927 local cur="${COMP_WORDS[COMP_CWORD]}"
928 case "$cur" in
929 --tool=*)
930 __gitcomp "$__git_mergetools_common kompare" "" "${cur##--tool=}"
931 return
933 --*)
934 __gitcomp "--tool="
935 return
937 esac
938 COMPREPLY=()
941 __git_fetch_options="
942 --quiet --verbose --append --upload-pack --force --keep --depth=
943 --tags --no-tags
946 _git_fetch ()
948 local cur="${COMP_WORDS[COMP_CWORD]}"
949 case "$cur" in
950 --*)
951 __gitcomp "$__git_fetch_options"
952 return
954 esac
955 __git_complete_remote_or_refspec
958 _git_format_patch ()
960 local cur="${COMP_WORDS[COMP_CWORD]}"
961 case "$cur" in
962 --thread=*)
963 __gitcomp "
964 deep shallow
965 " "" "${cur##--thread=}"
966 return
968 --*)
969 __gitcomp "
970 --stdout --attach --no-attach --thread --thread=
971 --output-directory
972 --numbered --start-number
973 --numbered-files
974 --keep-subject
975 --signoff
976 --in-reply-to= --cc=
977 --full-index --binary
978 --not --all
979 --cover-letter
980 --no-prefix --src-prefix= --dst-prefix=
981 --inline --suffix= --ignore-if-in-upstream
982 --subject-prefix=
984 return
986 esac
987 __git_complete_revlist
990 _git_fsck ()
992 local cur="${COMP_WORDS[COMP_CWORD]}"
993 case "$cur" in
994 --*)
995 __gitcomp "
996 --tags --root --unreachable --cache --no-reflogs --full
997 --strict --verbose --lost-found
999 return
1001 esac
1002 COMPREPLY=()
1005 _git_gc ()
1007 local cur="${COMP_WORDS[COMP_CWORD]}"
1008 case "$cur" in
1009 --*)
1010 __gitcomp "--prune --aggressive"
1011 return
1013 esac
1014 COMPREPLY=()
1017 _git_grep ()
1019 __git_has_doubledash && return
1021 local cur="${COMP_WORDS[COMP_CWORD]}"
1022 case "$cur" in
1023 --*)
1024 __gitcomp "
1025 --cached
1026 --text --ignore-case --word-regexp --invert-match
1027 --full-name
1028 --extended-regexp --basic-regexp --fixed-strings
1029 --files-with-matches --name-only
1030 --files-without-match
1031 --count
1032 --and --or --not --all-match
1034 return
1036 esac
1037 COMPREPLY=()
1040 _git_help ()
1042 local cur="${COMP_WORDS[COMP_CWORD]}"
1043 case "$cur" in
1044 --*)
1045 __gitcomp "--all --info --man --web"
1046 return
1048 esac
1049 __gitcomp "$(__git_all_commands)
1050 attributes cli core-tutorial cvs-migration
1051 diffcore gitk glossary hooks ignore modules
1052 repository-layout tutorial tutorial-2
1053 workflows
1057 _git_init ()
1059 local cur="${COMP_WORDS[COMP_CWORD]}"
1060 case "$cur" in
1061 --shared=*)
1062 __gitcomp "
1063 false true umask group all world everybody
1064 " "" "${cur##--shared=}"
1065 return
1067 --*)
1068 __gitcomp "--quiet --bare --template= --shared --shared="
1069 return
1071 esac
1072 COMPREPLY=()
1075 _git_ls_files ()
1077 __git_has_doubledash && return
1079 local cur="${COMP_WORDS[COMP_CWORD]}"
1080 case "$cur" in
1081 --*)
1082 __gitcomp "--cached --deleted --modified --others --ignored
1083 --stage --directory --no-empty-directory --unmerged
1084 --killed --exclude= --exclude-from=
1085 --exclude-per-directory= --exclude-standard
1086 --error-unmatch --with-tree= --full-name
1087 --abbrev --ignored --exclude-per-directory
1089 return
1091 esac
1092 COMPREPLY=()
1095 _git_ls_remote ()
1097 __gitcomp "$(__git_remotes)"
1100 _git_ls_tree ()
1102 __git_complete_file
1105 # Options that go well for log, shortlog and gitk
1106 __git_log_common_options="
1107 --not --all
1108 --branches --tags --remotes
1109 --first-parent --no-merges
1110 --max-count=
1111 --max-age= --since= --after=
1112 --min-age= --until= --before=
1114 # Options that go well for log and gitk (not shortlog)
1115 __git_log_gitk_options="
1116 --dense --sparse --full-history
1117 --simplify-merges --simplify-by-decoration
1118 --left-right
1120 # Options that go well for log and shortlog (not gitk)
1121 __git_log_shortlog_options="
1122 --author= --committer= --grep=
1123 --all-match
1126 __git_log_pretty_formats="oneline short medium full fuller email raw format:"
1127 __git_log_date_formats="relative iso8601 rfc2822 short local default raw"
1129 _git_log ()
1131 __git_has_doubledash && return
1133 local cur="${COMP_WORDS[COMP_CWORD]}"
1134 local g="$(git rev-parse --git-dir 2>/dev/null)"
1135 local merge=""
1136 if [ -f "$g/MERGE_HEAD" ]; then
1137 merge="--merge"
1139 case "$cur" in
1140 --pretty=*)
1141 __gitcomp "$__git_log_pretty_formats
1142 " "" "${cur##--pretty=}"
1143 return
1145 --format=*)
1146 __gitcomp "$__git_log_pretty_formats
1147 " "" "${cur##--format=}"
1148 return
1150 --date=*)
1151 __gitcomp "$__git_log_date_formats" "" "${cur##--date=}"
1152 return
1154 --*)
1155 __gitcomp "
1156 $__git_log_common_options
1157 $__git_log_shortlog_options
1158 $__git_log_gitk_options
1159 --root --topo-order --date-order --reverse
1160 --follow
1161 --abbrev-commit --abbrev=
1162 --relative-date --date=
1163 --pretty= --format= --oneline
1164 --cherry-pick
1165 --graph
1166 --decorate
1167 --walk-reflogs
1168 --parents --children
1169 $merge
1170 $__git_diff_common_options
1171 --pickaxe-all --pickaxe-regex
1173 return
1175 esac
1176 __git_complete_revlist
1179 __git_merge_options="
1180 --no-commit --no-stat --log --no-log --squash --strategy
1181 --commit --stat --no-squash --ff --no-ff
1184 _git_merge ()
1186 __git_complete_strategy && return
1188 local cur="${COMP_WORDS[COMP_CWORD]}"
1189 case "$cur" in
1190 --*)
1191 __gitcomp "$__git_merge_options"
1192 return
1193 esac
1194 __gitcomp "$(__git_refs)"
1197 _git_mergetool ()
1199 local cur="${COMP_WORDS[COMP_CWORD]}"
1200 case "$cur" in
1201 --tool=*)
1202 __gitcomp "$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"
1203 return
1205 --*)
1206 __gitcomp "--tool="
1207 return
1209 esac
1210 COMPREPLY=()
1213 _git_merge_base ()
1215 __gitcomp "$(__git_refs)"
1218 _git_mv ()
1220 local cur="${COMP_WORDS[COMP_CWORD]}"
1221 case "$cur" in
1222 --*)
1223 __gitcomp "--dry-run"
1224 return
1226 esac
1227 COMPREPLY=()
1230 _git_name_rev ()
1232 __gitcomp "--tags --all --stdin"
1235 _git_pull ()
1237 __git_complete_strategy && return
1239 local cur="${COMP_WORDS[COMP_CWORD]}"
1240 case "$cur" in
1241 --*)
1242 __gitcomp "
1243 --rebase --no-rebase
1244 $__git_merge_options
1245 $__git_fetch_options
1247 return
1249 esac
1250 __git_complete_remote_or_refspec
1253 _git_push ()
1255 local cur="${COMP_WORDS[COMP_CWORD]}"
1256 case "${COMP_WORDS[COMP_CWORD-1]}" in
1257 --repo)
1258 __gitcomp "$(__git_remotes)"
1259 return
1260 esac
1261 case "$cur" in
1262 --repo=*)
1263 __gitcomp "$(__git_remotes)" "" "${cur##--repo=}"
1264 return
1266 --*)
1267 __gitcomp "
1268 --all --mirror --tags --dry-run --force --verbose
1269 --receive-pack= --repo=
1271 return
1273 esac
1274 __git_complete_remote_or_refspec
1277 _git_rebase ()
1279 local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)"
1280 if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
1281 __gitcomp "--continue --skip --abort"
1282 return
1284 __git_complete_strategy && return
1285 case "$cur" in
1286 --*)
1287 __gitcomp "--onto --merge --strategy --interactive"
1288 return
1289 esac
1290 __gitcomp "$(__git_refs)"
1293 __git_send_email_confirm_options="always never auto cc compose"
1294 __git_send_email_suppresscc_options="author self cc ccbody sob cccmd body all"
1296 _git_send_email ()
1298 local cur="${COMP_WORDS[COMP_CWORD]}"
1299 case "$cur" in
1300 --confirm=*)
1301 __gitcomp "
1302 $__git_send_email_confirm_options
1303 " "" "${cur##--confirm=}"
1304 return
1306 --suppress-cc=*)
1307 __gitcomp "
1308 $__git_send_email_suppresscc_options
1309 " "" "${cur##--suppress-cc=}"
1311 return
1313 --smtp-encryption=*)
1314 __gitcomp "ssl tls" "" "${cur##--smtp-encryption=}"
1315 return
1317 --*)
1318 __gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to
1319 --compose --confirm= --dry-run --envelope-sender
1320 --from --identity
1321 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
1322 --no-suppress-from --no-thread --quiet
1323 --signed-off-by-cc --smtp-pass --smtp-server
1324 --smtp-server-port --smtp-encryption= --smtp-user
1325 --subject --suppress-cc= --suppress-from --thread --to
1326 --validate --no-validate"
1327 return
1329 esac
1330 COMPREPLY=()
1333 __git_config_get_set_variables ()
1335 local prevword word config_file= c=$COMP_CWORD
1336 while [ $c -gt 1 ]; do
1337 word="${COMP_WORDS[c]}"
1338 case "$word" in
1339 --global|--system|--file=*)
1340 config_file="$word"
1341 break
1343 -f|--file)
1344 config_file="$word $prevword"
1345 break
1347 esac
1348 prevword=$word
1349 c=$((--c))
1350 done
1352 for i in $(git --git-dir="$(__gitdir)" config $config_file --list \
1353 2>/dev/null); do
1354 case "$i" in
1355 *.*)
1356 echo "${i/=*/}"
1358 esac
1359 done
1362 _git_config ()
1364 local cur="${COMP_WORDS[COMP_CWORD]}"
1365 local prv="${COMP_WORDS[COMP_CWORD-1]}"
1366 case "$prv" in
1367 branch.*.remote)
1368 __gitcomp "$(__git_remotes)"
1369 return
1371 branch.*.merge)
1372 __gitcomp "$(__git_refs)"
1373 return
1375 remote.*.fetch)
1376 local remote="${prv#remote.}"
1377 remote="${remote%.fetch}"
1378 __gitcomp "$(__git_refs_remotes "$remote")"
1379 return
1381 remote.*.push)
1382 local remote="${prv#remote.}"
1383 remote="${remote%.push}"
1384 __gitcomp "$(git --git-dir="$(__gitdir)" \
1385 for-each-ref --format='%(refname):%(refname)' \
1386 refs/heads)"
1387 return
1389 pull.twohead|pull.octopus)
1390 __gitcomp "$(__git_merge_strategies)"
1391 return
1393 color.branch|color.diff|color.interactive|\
1394 color.showbranch|color.status|color.ui)
1395 __gitcomp "always never auto"
1396 return
1398 color.pager)
1399 __gitcomp "false true"
1400 return
1402 color.*.*)
1403 __gitcomp "
1404 normal black red green yellow blue magenta cyan white
1405 bold dim ul blink reverse
1407 return
1409 help.format)
1410 __gitcomp "man info web html"
1411 return
1413 log.date)
1414 __gitcomp "$__git_log_date_formats"
1415 return
1417 sendemail.aliasesfiletype)
1418 __gitcomp "mutt mailrc pine elm gnus"
1419 return
1421 sendemail.confirm)
1422 __gitcomp "$__git_send_email_confirm_options"
1423 return
1425 sendemail.suppresscc)
1426 __gitcomp "$__git_send_email_suppresscc_options"
1427 return
1429 --get|--get-all|--unset|--unset-all)
1430 __gitcomp "$(__git_config_get_set_variables)"
1431 return
1433 *.*)
1434 COMPREPLY=()
1435 return
1437 esac
1438 case "$cur" in
1439 --*)
1440 __gitcomp "
1441 --global --system --file=
1442 --list --replace-all
1443 --get --get-all --get-regexp
1444 --add --unset --unset-all
1445 --remove-section --rename-section
1447 return
1449 branch.*.*)
1450 local pfx="${cur%.*}."
1451 cur="${cur##*.}"
1452 __gitcomp "remote merge mergeoptions" "$pfx" "$cur"
1453 return
1455 branch.*)
1456 local pfx="${cur%.*}."
1457 cur="${cur#*.}"
1458 __gitcomp "$(__git_heads)" "$pfx" "$cur" "."
1459 return
1461 guitool.*.*)
1462 local pfx="${cur%.*}."
1463 cur="${cur##*.}"
1464 __gitcomp "
1465 argprompt cmd confirm needsfile noconsole norescan
1466 prompt revprompt revunmerged title
1467 " "$pfx" "$cur"
1468 return
1470 difftool.*.*)
1471 local pfx="${cur%.*}."
1472 cur="${cur##*.}"
1473 __gitcomp "cmd path" "$pfx" "$cur"
1474 return
1476 man.*.*)
1477 local pfx="${cur%.*}."
1478 cur="${cur##*.}"
1479 __gitcomp "cmd path" "$pfx" "$cur"
1480 return
1482 mergetool.*.*)
1483 local pfx="${cur%.*}."
1484 cur="${cur##*.}"
1485 __gitcomp "cmd path trustExitCode" "$pfx" "$cur"
1486 return
1488 pager.*)
1489 local pfx="${cur%.*}."
1490 cur="${cur#*.}"
1491 __gitcomp "$(__git_all_commands)" "$pfx" "$cur"
1492 return
1494 remote.*.*)
1495 local pfx="${cur%.*}."
1496 cur="${cur##*.}"
1497 __gitcomp "
1498 url proxy fetch push mirror skipDefaultUpdate
1499 receivepack uploadpack tagopt
1500 " "$pfx" "$cur"
1501 return
1503 remote.*)
1504 local pfx="${cur%.*}."
1505 cur="${cur#*.}"
1506 __gitcomp "$(__git_remotes)" "$pfx" "$cur" "."
1507 return
1509 url.*.*)
1510 local pfx="${cur%.*}."
1511 cur="${cur##*.}"
1512 __gitcomp "insteadof" "$pfx" "$cur"
1513 return
1515 esac
1516 __gitcomp "
1517 alias.
1518 apply.whitespace
1519 branch.autosetupmerge
1520 branch.autosetuprebase
1521 clean.requireForce
1522 color.branch
1523 color.branch.current
1524 color.branch.local
1525 color.branch.plain
1526 color.branch.remote
1527 color.diff
1528 color.diff.commit
1529 color.diff.frag
1530 color.diff.meta
1531 color.diff.new
1532 color.diff.old
1533 color.diff.plain
1534 color.diff.whitespace
1535 color.grep
1536 color.grep.external
1537 color.grep.match
1538 color.interactive
1539 color.interactive.header
1540 color.interactive.help
1541 color.interactive.prompt
1542 color.pager
1543 color.showbranch
1544 color.status
1545 color.status.added
1546 color.status.changed
1547 color.status.header
1548 color.status.nobranch
1549 color.status.untracked
1550 color.status.updated
1551 color.ui
1552 commit.template
1553 core.autocrlf
1554 core.bare
1555 core.compression
1556 core.createObject
1557 core.deltaBaseCacheLimit
1558 core.editor
1559 core.excludesfile
1560 core.fileMode
1561 core.fsyncobjectfiles
1562 core.gitProxy
1563 core.ignoreCygwinFSTricks
1564 core.ignoreStat
1565 core.logAllRefUpdates
1566 core.loosecompression
1567 core.packedGitLimit
1568 core.packedGitWindowSize
1569 core.pager
1570 core.preferSymlinkRefs
1571 core.preloadindex
1572 core.quotepath
1573 core.repositoryFormatVersion
1574 core.safecrlf
1575 core.sharedRepository
1576 core.symlinks
1577 core.trustctime
1578 core.warnAmbiguousRefs
1579 core.whitespace
1580 core.worktree
1581 diff.autorefreshindex
1582 diff.external
1583 diff.mnemonicprefix
1584 diff.renameLimit
1585 diff.renameLimit.
1586 diff.renames
1587 diff.suppressBlankEmpty
1588 diff.tool
1589 diff.wordRegex
1590 difftool.
1591 difftool.prompt
1592 fetch.unpackLimit
1593 format.attach
1594 format.cc
1595 format.headers
1596 format.numbered
1597 format.pretty
1598 format.signoff
1599 format.subjectprefix
1600 format.suffix
1601 format.thread
1602 gc.aggressiveWindow
1603 gc.auto
1604 gc.autopacklimit
1605 gc.packrefs
1606 gc.pruneexpire
1607 gc.reflogexpire
1608 gc.reflogexpireunreachable
1609 gc.rerereresolved
1610 gc.rerereunresolved
1611 gitcvs.allbinary
1612 gitcvs.commitmsgannotation
1613 gitcvs.dbTableNamePrefix
1614 gitcvs.dbdriver
1615 gitcvs.dbname
1616 gitcvs.dbpass
1617 gitcvs.dbuser
1618 gitcvs.enabled
1619 gitcvs.logfile
1620 gitcvs.usecrlfattr
1621 guitool.
1622 gui.blamehistoryctx
1623 gui.commitmsgwidth
1624 gui.copyblamethreshold
1625 gui.diffcontext
1626 gui.encoding
1627 gui.fastcopyblame
1628 gui.matchtrackingbranch
1629 gui.newbranchtemplate
1630 gui.pruneduringfetch
1631 gui.spellingdictionary
1632 gui.trustmtime
1633 help.autocorrect
1634 help.browser
1635 help.format
1636 http.lowSpeedLimit
1637 http.lowSpeedTime
1638 http.maxRequests
1639 http.noEPSV
1640 http.proxy
1641 http.sslCAInfo
1642 http.sslCAPath
1643 http.sslCert
1644 http.sslKey
1645 http.sslVerify
1646 i18n.commitEncoding
1647 i18n.logOutputEncoding
1648 imap.folder
1649 imap.host
1650 imap.pass
1651 imap.port
1652 imap.preformattedHTML
1653 imap.sslverify
1654 imap.tunnel
1655 imap.user
1656 instaweb.browser
1657 instaweb.httpd
1658 instaweb.local
1659 instaweb.modulepath
1660 instaweb.port
1661 interactive.singlekey
1662 log.date
1663 log.showroot
1664 mailmap.file
1665 man.
1666 man.viewer
1667 merge.conflictstyle
1668 merge.log
1669 merge.renameLimit
1670 merge.stat
1671 merge.tool
1672 merge.verbosity
1673 mergetool.
1674 mergetool.keepBackup
1675 mergetool.prompt
1676 pack.compression
1677 pack.deltaCacheLimit
1678 pack.deltaCacheSize
1679 pack.depth
1680 pack.indexVersion
1681 pack.packSizeLimit
1682 pack.threads
1683 pack.window
1684 pack.windowMemory
1685 pager.
1686 pull.octopus
1687 pull.twohead
1688 push.default
1689 rebase.stat
1690 receive.denyCurrentBranch
1691 receive.denyDeletes
1692 receive.denyNonFastForwards
1693 receive.fsckObjects
1694 receive.unpackLimit
1695 repack.usedeltabaseoffset
1696 rerere.autoupdate
1697 rerere.enabled
1698 sendemail.aliasesfile
1699 sendemail.aliasesfiletype
1700 sendemail.bcc
1701 sendemail.cc
1702 sendemail.cccmd
1703 sendemail.chainreplyto
1704 sendemail.confirm
1705 sendemail.envelopesender
1706 sendemail.multiedit
1707 sendemail.signedoffbycc
1708 sendemail.smtpencryption
1709 sendemail.smtppass
1710 sendemail.smtpserver
1711 sendemail.smtpserverport
1712 sendemail.smtpuser
1713 sendemail.suppresscc
1714 sendemail.suppressfrom
1715 sendemail.thread
1716 sendemail.to
1717 sendemail.validate
1718 showbranch.default
1719 status.relativePaths
1720 status.showUntrackedFiles
1721 tar.umask
1722 transfer.unpackLimit
1723 url.
1724 user.email
1725 user.name
1726 user.signingkey
1727 web.browser
1728 branch. remote.
1732 _git_remote ()
1734 local subcommands="add rename rm show prune update set-head"
1735 local subcommand="$(__git_find_subcommand "$subcommands")"
1736 if [ -z "$subcommand" ]; then
1737 __gitcomp "$subcommands"
1738 return
1741 case "$subcommand" in
1742 rename|rm|show|prune)
1743 __gitcomp "$(__git_remotes)"
1745 update)
1746 local i c='' IFS=$'\n'
1747 for i in $(git --git-dir="$(__gitdir)" config --list); do
1748 case "$i" in
1749 remotes.*)
1750 i="${i#remotes.}"
1751 c="$c ${i/=*/}"
1753 esac
1754 done
1755 __gitcomp "$c"
1758 COMPREPLY=()
1760 esac
1763 _git_reset ()
1765 __git_has_doubledash && return
1767 local cur="${COMP_WORDS[COMP_CWORD]}"
1768 case "$cur" in
1769 --*)
1770 __gitcomp "--merge --mixed --hard --soft"
1771 return
1773 esac
1774 __gitcomp "$(__git_refs)"
1777 _git_revert ()
1779 local cur="${COMP_WORDS[COMP_CWORD]}"
1780 case "$cur" in
1781 --*)
1782 __gitcomp "--edit --mainline --no-edit --no-commit --signoff"
1783 return
1785 esac
1786 __gitcomp "$(__git_refs)"
1789 _git_rm ()
1791 __git_has_doubledash && return
1793 local cur="${COMP_WORDS[COMP_CWORD]}"
1794 case "$cur" in
1795 --*)
1796 __gitcomp "--cached --dry-run --ignore-unmatch --quiet"
1797 return
1799 esac
1800 COMPREPLY=()
1803 _git_shortlog ()
1805 __git_has_doubledash && return
1807 local cur="${COMP_WORDS[COMP_CWORD]}"
1808 case "$cur" in
1809 --*)
1810 __gitcomp "
1811 $__git_log_common_options
1812 $__git_log_shortlog_options
1813 --numbered --summary
1815 return
1817 esac
1818 __git_complete_revlist
1821 _git_show ()
1823 __git_has_doubledash && return
1825 local cur="${COMP_WORDS[COMP_CWORD]}"
1826 case "$cur" in
1827 --pretty=*)
1828 __gitcomp "$__git_log_pretty_formats
1829 " "" "${cur##--pretty=}"
1830 return
1832 --format=*)
1833 __gitcomp "$__git_log_pretty_formats
1834 " "" "${cur##--format=}"
1835 return
1837 --*)
1838 __gitcomp "--pretty= --format= --abbrev-commit --oneline
1839 $__git_diff_common_options
1841 return
1843 esac
1844 __git_complete_file
1847 _git_show_branch ()
1849 local cur="${COMP_WORDS[COMP_CWORD]}"
1850 case "$cur" in
1851 --*)
1852 __gitcomp "
1853 --all --remotes --topo-order --current --more=
1854 --list --independent --merge-base --no-name
1855 --color --no-color
1856 --sha1-name --sparse --topics --reflog
1858 return
1860 esac
1861 __git_complete_revlist
1864 _git_stash ()
1866 local subcommands='save list show apply clear drop pop create branch'
1867 local subcommand="$(__git_find_subcommand "$subcommands")"
1868 if [ -z "$subcommand" ]; then
1869 __gitcomp "$subcommands"
1870 else
1871 local cur="${COMP_WORDS[COMP_CWORD]}"
1872 case "$subcommand,$cur" in
1873 save,--*)
1874 __gitcomp "--keep-index"
1876 apply,--*)
1877 __gitcomp "--index"
1879 show,--*|drop,--*|pop,--*|branch,--*)
1880 COMPREPLY=()
1882 show,*|apply,*|drop,*|pop,*|branch,*)
1883 __gitcomp "$(git --git-dir="$(__gitdir)" stash list \
1884 | sed -n -e 's/:.*//p')"
1887 COMPREPLY=()
1889 esac
1893 _git_submodule ()
1895 __git_has_doubledash && return
1897 local subcommands="add status init update summary foreach sync"
1898 if [ -z "$(__git_find_subcommand "$subcommands")" ]; then
1899 local cur="${COMP_WORDS[COMP_CWORD]}"
1900 case "$cur" in
1901 --*)
1902 __gitcomp "--quiet --cached"
1905 __gitcomp "$subcommands"
1907 esac
1908 return
1912 _git_svn ()
1914 local subcommands="
1915 init fetch clone rebase dcommit log find-rev
1916 set-tree commit-diff info create-ignore propget
1917 proplist show-ignore show-externals branch tag blame
1918 migrate
1920 local subcommand="$(__git_find_subcommand "$subcommands")"
1921 if [ -z "$subcommand" ]; then
1922 __gitcomp "$subcommands"
1923 else
1924 local remote_opts="--username= --config-dir= --no-auth-cache"
1925 local fc_opts="
1926 --follow-parent --authors-file= --repack=
1927 --no-metadata --use-svm-props --use-svnsync-props
1928 --log-window-size= --no-checkout --quiet
1929 --repack-flags --use-log-author --localtime
1930 --ignore-paths= $remote_opts
1932 local init_opts="
1933 --template= --shared= --trunk= --tags=
1934 --branches= --stdlayout --minimize-url
1935 --no-metadata --use-svm-props --use-svnsync-props
1936 --rewrite-root= --prefix= --use-log-author
1937 --add-author-from $remote_opts
1939 local cmt_opts="
1940 --edit --rmdir --find-copies-harder --copy-similarity=
1943 local cur="${COMP_WORDS[COMP_CWORD]}"
1944 case "$subcommand,$cur" in
1945 fetch,--*)
1946 __gitcomp "--revision= --fetch-all $fc_opts"
1948 clone,--*)
1949 __gitcomp "--revision= $fc_opts $init_opts"
1951 init,--*)
1952 __gitcomp "$init_opts"
1954 dcommit,--*)
1955 __gitcomp "
1956 --merge --strategy= --verbose --dry-run
1957 --fetch-all --no-rebase --commit-url
1958 --revision $cmt_opts $fc_opts
1961 set-tree,--*)
1962 __gitcomp "--stdin $cmt_opts $fc_opts"
1964 create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\
1965 show-externals,--*)
1966 __gitcomp "--revision="
1968 log,--*)
1969 __gitcomp "
1970 --limit= --revision= --verbose --incremental
1971 --oneline --show-commit --non-recursive
1972 --authors-file= --color
1975 rebase,--*)
1976 __gitcomp "
1977 --merge --verbose --strategy= --local
1978 --fetch-all --dry-run $fc_opts
1981 commit-diff,--*)
1982 __gitcomp "--message= --file= --revision= $cmt_opts"
1984 info,--*)
1985 __gitcomp "--url"
1987 branch,--*)
1988 __gitcomp "--dry-run --message --tag"
1990 tag,--*)
1991 __gitcomp "--dry-run --message"
1993 blame,--*)
1994 __gitcomp "--git-format"
1996 migrate,--*)
1997 __gitcomp "
1998 --config-dir= --ignore-paths= --minimize
1999 --no-auth-cache --username=
2003 COMPREPLY=()
2005 esac
2009 _git_tag ()
2011 local i c=1 f=0
2012 while [ $c -lt $COMP_CWORD ]; do
2013 i="${COMP_WORDS[c]}"
2014 case "$i" in
2015 -d|-v)
2016 __gitcomp "$(__git_tags)"
2017 return
2022 esac
2023 c=$((++c))
2024 done
2026 case "${COMP_WORDS[COMP_CWORD-1]}" in
2027 -m|-F)
2028 COMPREPLY=()
2030 -*|tag)
2031 if [ $f = 1 ]; then
2032 __gitcomp "$(__git_tags)"
2033 else
2034 COMPREPLY=()
2038 __gitcomp "$(__git_refs)"
2040 esac
2043 _git ()
2045 local i c=1 command __git_dir
2047 while [ $c -lt $COMP_CWORD ]; do
2048 i="${COMP_WORDS[c]}"
2049 case "$i" in
2050 --git-dir=*) __git_dir="${i#--git-dir=}" ;;
2051 --bare) __git_dir="." ;;
2052 --version|-p|--paginate) ;;
2053 --help) command="help"; break ;;
2054 *) command="$i"; break ;;
2055 esac
2056 c=$((++c))
2057 done
2059 if [ -z "$command" ]; then
2060 case "${COMP_WORDS[COMP_CWORD]}" in
2061 --*) __gitcomp "
2062 --paginate
2063 --no-pager
2064 --git-dir=
2065 --bare
2066 --version
2067 --exec-path
2068 --html-path
2069 --work-tree=
2070 --help
2073 *) __gitcomp "$(__git_porcelain_commands) $(__git_aliases)" ;;
2074 esac
2075 return
2078 local expansion=$(__git_aliased_command "$command")
2079 [ "$expansion" ] && command="$expansion"
2081 case "$command" in
2082 am) _git_am ;;
2083 add) _git_add ;;
2084 apply) _git_apply ;;
2085 archive) _git_archive ;;
2086 bisect) _git_bisect ;;
2087 bundle) _git_bundle ;;
2088 branch) _git_branch ;;
2089 checkout) _git_checkout ;;
2090 cherry) _git_cherry ;;
2091 cherry-pick) _git_cherry_pick ;;
2092 clean) _git_clean ;;
2093 clone) _git_clone ;;
2094 commit) _git_commit ;;
2095 config) _git_config ;;
2096 describe) _git_describe ;;
2097 diff) _git_diff ;;
2098 difftool) _git_difftool ;;
2099 fetch) _git_fetch ;;
2100 format-patch) _git_format_patch ;;
2101 fsck) _git_fsck ;;
2102 gc) _git_gc ;;
2103 grep) _git_grep ;;
2104 help) _git_help ;;
2105 init) _git_init ;;
2106 log) _git_log ;;
2107 ls-files) _git_ls_files ;;
2108 ls-remote) _git_ls_remote ;;
2109 ls-tree) _git_ls_tree ;;
2110 merge) _git_merge;;
2111 mergetool) _git_mergetool;;
2112 merge-base) _git_merge_base ;;
2113 mv) _git_mv ;;
2114 name-rev) _git_name_rev ;;
2115 pull) _git_pull ;;
2116 push) _git_push ;;
2117 rebase) _git_rebase ;;
2118 remote) _git_remote ;;
2119 reset) _git_reset ;;
2120 revert) _git_revert ;;
2121 rm) _git_rm ;;
2122 send-email) _git_send_email ;;
2123 shortlog) _git_shortlog ;;
2124 show) _git_show ;;
2125 show-branch) _git_show_branch ;;
2126 stash) _git_stash ;;
2127 stage) _git_add ;;
2128 submodule) _git_submodule ;;
2129 svn) _git_svn ;;
2130 tag) _git_tag ;;
2131 whatchanged) _git_log ;;
2132 *) COMPREPLY=() ;;
2133 esac
2136 _gitk ()
2138 __git_has_doubledash && return
2140 local cur="${COMP_WORDS[COMP_CWORD]}"
2141 local g="$(__gitdir)"
2142 local merge=""
2143 if [ -f "$g/MERGE_HEAD" ]; then
2144 merge="--merge"
2146 case "$cur" in
2147 --*)
2148 __gitcomp "
2149 $__git_log_common_options
2150 $__git_log_gitk_options
2151 $merge
2153 return
2155 esac
2156 __git_complete_revlist
2159 complete -o bashdefault -o default -o nospace -F _git git 2>/dev/null \
2160 || complete -o default -o nospace -F _git git
2161 complete -o bashdefault -o default -o nospace -F _gitk gitk 2>/dev/null \
2162 || complete -o default -o nospace -F _gitk gitk
2164 # The following are necessary only for Cygwin, and only are needed
2165 # when the user has tab-completed the executable name and consequently
2166 # included the '.exe' suffix.
2168 if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
2169 complete -o bashdefault -o default -o nospace -F _git git.exe 2>/dev/null \
2170 || complete -o default -o nospace -F _git git.exe