completion: split __git_ps1 into a separate script
[git.git] / contrib / completion / git-completion.bash
blobabf8215ddce18bf595879e4366a72a4eb8827ba6
1 #!bash
3 # bash/zsh 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) Add the following line to your .bashrc/.zshrc:
22 # source ~/.git-completion.sh
23 # 3) Consider changing your PS1 to also show the current branch,
24 # see git-prompt.sh for details.
26 if [[ -n ${ZSH_VERSION-} ]]; then
27 autoload -U +X bashcompinit && bashcompinit
30 case "$COMP_WORDBREAKS" in
31 *:*) : great ;;
32 *) COMP_WORDBREAKS="$COMP_WORDBREAKS:"
33 esac
35 # __gitdir accepts 0 or 1 arguments (i.e., location)
36 # returns location of .git repo
37 __gitdir ()
39 if [ -z "${1-}" ]; then
40 if [ -n "${__git_dir-}" ]; then
41 echo "$__git_dir"
42 elif [ -d .git ]; then
43 echo .git
44 else
45 git rev-parse --git-dir 2>/dev/null
47 elif [ -d "$1/.git" ]; then
48 echo "$1/.git"
49 else
50 echo "$1"
54 __gitcomp_1 ()
56 local c IFS=$' \t\n'
57 for c in $1; do
58 c="$c$2"
59 case $c in
60 --*=*|*.) ;;
61 *) c="$c " ;;
62 esac
63 printf '%s\n' "$c"
64 done
67 # The following function is based on code from:
69 # bash_completion - programmable completion functions for bash 3.2+
71 # Copyright © 2006-2008, Ian Macdonald <ian@caliban.org>
72 # © 2009-2010, Bash Completion Maintainers
73 # <bash-completion-devel@lists.alioth.debian.org>
75 # This program is free software; you can redistribute it and/or modify
76 # it under the terms of the GNU General Public License as published by
77 # the Free Software Foundation; either version 2, or (at your option)
78 # any later version.
80 # This program is distributed in the hope that it will be useful,
81 # but WITHOUT ANY WARRANTY; without even the implied warranty of
82 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
83 # GNU General Public License for more details.
85 # You should have received a copy of the GNU General Public License
86 # along with this program; if not, write to the Free Software Foundation,
87 # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
89 # The latest version of this software can be obtained here:
91 # http://bash-completion.alioth.debian.org/
93 # RELEASE: 2.x
95 # This function can be used to access a tokenized list of words
96 # on the command line:
98 # __git_reassemble_comp_words_by_ref '=:'
99 # if test "${words_[cword_-1]}" = -w
100 # then
101 # ...
102 # fi
104 # The argument should be a collection of characters from the list of
105 # word completion separators (COMP_WORDBREAKS) to treat as ordinary
106 # characters.
108 # This is roughly equivalent to going back in time and setting
109 # COMP_WORDBREAKS to exclude those characters. The intent is to
110 # make option types like --date=<type> and <rev>:<path> easy to
111 # recognize by treating each shell word as a single token.
113 # It is best not to set COMP_WORDBREAKS directly because the value is
114 # shared with other completion scripts. By the time the completion
115 # function gets called, COMP_WORDS has already been populated so local
116 # changes to COMP_WORDBREAKS have no effect.
118 # Output: words_, cword_, cur_.
120 __git_reassemble_comp_words_by_ref()
122 local exclude i j first
123 # Which word separators to exclude?
124 exclude="${1//[^$COMP_WORDBREAKS]}"
125 cword_=$COMP_CWORD
126 if [ -z "$exclude" ]; then
127 words_=("${COMP_WORDS[@]}")
128 return
130 # List of word completion separators has shrunk;
131 # re-assemble words to complete.
132 for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)); do
133 # Append each nonempty word consisting of just
134 # word separator characters to the current word.
135 first=t
136 while
137 [ $i -gt 0 ] &&
138 [ -n "${COMP_WORDS[$i]}" ] &&
139 # word consists of excluded word separators
140 [ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ]
142 # Attach to the previous token,
143 # unless the previous token is the command name.
144 if [ $j -ge 2 ] && [ -n "$first" ]; then
145 ((j--))
147 first=
148 words_[$j]=${words_[j]}${COMP_WORDS[i]}
149 if [ $i = $COMP_CWORD ]; then
150 cword_=$j
152 if (($i < ${#COMP_WORDS[@]} - 1)); then
153 ((i++))
154 else
155 # Done.
156 return
158 done
159 words_[$j]=${words_[j]}${COMP_WORDS[i]}
160 if [ $i = $COMP_CWORD ]; then
161 cword_=$j
163 done
166 if ! type _get_comp_words_by_ref >/dev/null 2>&1; then
167 if [[ -z ${ZSH_VERSION:+set} ]]; then
168 _get_comp_words_by_ref ()
170 local exclude cur_ words_ cword_
171 if [ "$1" = "-n" ]; then
172 exclude=$2
173 shift 2
175 __git_reassemble_comp_words_by_ref "$exclude"
176 cur_=${words_[cword_]}
177 while [ $# -gt 0 ]; do
178 case "$1" in
179 cur)
180 cur=$cur_
182 prev)
183 prev=${words_[$cword_-1]}
185 words)
186 words=("${words_[@]}")
188 cword)
189 cword=$cword_
191 esac
192 shift
193 done
195 else
196 _get_comp_words_by_ref ()
198 while [ $# -gt 0 ]; do
199 case "$1" in
200 cur)
201 cur=${COMP_WORDS[COMP_CWORD]}
203 prev)
204 prev=${COMP_WORDS[COMP_CWORD-1]}
206 words)
207 words=("${COMP_WORDS[@]}")
209 cword)
210 cword=$COMP_CWORD
213 # assume COMP_WORDBREAKS is already set sanely
214 shift
216 esac
217 shift
218 done
223 # Generates completion reply with compgen, appending a space to possible
224 # completion words, if necessary.
225 # It accepts 1 to 4 arguments:
226 # 1: List of possible completion words.
227 # 2: A prefix to be added to each possible completion word (optional).
228 # 3: Generate possible completion matches for this word (optional).
229 # 4: A suffix to be appended to each possible completion word (optional).
230 __gitcomp ()
232 local cur_="${3-$cur}"
234 case "$cur_" in
235 --*=)
236 COMPREPLY=()
239 local IFS=$'\n'
240 COMPREPLY=($(compgen -P "${2-}" \
241 -W "$(__gitcomp_1 "${1-}" "${4-}")" \
242 -- "$cur_"))
244 esac
247 # Generates completion reply with compgen from newline-separated possible
248 # completion words by appending a space to all of them.
249 # It accepts 1 to 4 arguments:
250 # 1: List of possible completion words, separated by a single newline.
251 # 2: A prefix to be added to each possible completion word (optional).
252 # 3: Generate possible completion matches for this word (optional).
253 # 4: A suffix to be appended to each possible completion word instead of
254 # the default space (optional). If specified but empty, nothing is
255 # appended.
256 __gitcomp_nl ()
258 local IFS=$'\n'
259 COMPREPLY=($(compgen -P "${2-}" -S "${4- }" -W "$1" -- "${3-$cur}"))
262 __git_heads ()
264 local dir="$(__gitdir)"
265 if [ -d "$dir" ]; then
266 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
267 refs/heads
268 return
272 __git_tags ()
274 local dir="$(__gitdir)"
275 if [ -d "$dir" ]; then
276 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
277 refs/tags
278 return
282 # __git_refs accepts 0, 1 (to pass to __gitdir), or 2 arguments
283 # presence of 2nd argument means use the guess heuristic employed
284 # by checkout for tracking branches
285 __git_refs ()
287 local i hash dir="$(__gitdir "${1-}")" track="${2-}"
288 local format refs
289 if [ -d "$dir" ]; then
290 case "$cur" in
291 refs|refs/*)
292 format="refname"
293 refs="${cur%/*}"
294 track=""
297 for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do
298 if [ -e "$dir/$i" ]; then echo $i; fi
299 done
300 format="refname:short"
301 refs="refs/tags refs/heads refs/remotes"
303 esac
304 git --git-dir="$dir" for-each-ref --format="%($format)" \
305 $refs
306 if [ -n "$track" ]; then
307 # employ the heuristic used by git checkout
308 # Try to find a remote branch that matches the completion word
309 # but only output if the branch name is unique
310 local ref entry
311 git --git-dir="$dir" for-each-ref --shell --format="ref=%(refname:short)" \
312 "refs/remotes/" | \
313 while read -r entry; do
314 eval "$entry"
315 ref="${ref#*/}"
316 if [[ "$ref" == "$cur"* ]]; then
317 echo "$ref"
319 done | uniq -u
321 return
323 case "$cur" in
324 refs|refs/*)
325 git ls-remote "$dir" "$cur*" 2>/dev/null | \
326 while read -r hash i; do
327 case "$i" in
328 *^{}) ;;
329 *) echo "$i" ;;
330 esac
331 done
334 git ls-remote "$dir" HEAD ORIG_HEAD 'refs/tags/*' 'refs/heads/*' 'refs/remotes/*' 2>/dev/null | \
335 while read -r hash i; do
336 case "$i" in
337 *^{}) ;;
338 refs/*) echo "${i#refs/*/}" ;;
339 *) echo "$i" ;;
340 esac
341 done
343 esac
346 # __git_refs2 requires 1 argument (to pass to __git_refs)
347 __git_refs2 ()
349 local i
350 for i in $(__git_refs "$1"); do
351 echo "$i:$i"
352 done
355 # __git_refs_remotes requires 1 argument (to pass to ls-remote)
356 __git_refs_remotes ()
358 local i hash
359 git ls-remote "$1" 'refs/heads/*' 2>/dev/null | \
360 while read -r hash i; do
361 echo "$i:refs/remotes/$1/${i#refs/heads/}"
362 done
365 __git_remotes ()
367 local i IFS=$'\n' d="$(__gitdir)"
368 test -d "$d/remotes" && ls -1 "$d/remotes"
369 for i in $(git --git-dir="$d" config --get-regexp 'remote\..*\.url' 2>/dev/null); do
370 i="${i#remote.}"
371 echo "${i/.url*/}"
372 done
375 __git_list_merge_strategies ()
377 git merge -s help 2>&1 |
378 sed -n -e '/[Aa]vailable strategies are: /,/^$/{
379 s/\.$//
380 s/.*://
381 s/^[ ]*//
382 s/[ ]*$//
387 __git_merge_strategies=
388 # 'git merge -s help' (and thus detection of the merge strategy
389 # list) fails, unfortunately, if run outside of any git working
390 # tree. __git_merge_strategies is set to the empty string in
391 # that case, and the detection will be repeated the next time it
392 # is needed.
393 __git_compute_merge_strategies ()
395 test -n "$__git_merge_strategies" ||
396 __git_merge_strategies=$(__git_list_merge_strategies)
399 __git_complete_revlist_file ()
401 local pfx ls ref cur_="$cur"
402 case "$cur_" in
403 *..?*:*)
404 return
406 ?*:*)
407 ref="${cur_%%:*}"
408 cur_="${cur_#*:}"
409 case "$cur_" in
410 ?*/*)
411 pfx="${cur_%/*}"
412 cur_="${cur_##*/}"
413 ls="$ref:$pfx"
414 pfx="$pfx/"
417 ls="$ref"
419 esac
421 case "$COMP_WORDBREAKS" in
422 *:*) : great ;;
423 *) pfx="$ref:$pfx" ;;
424 esac
426 local IFS=$'\n'
427 COMPREPLY=($(compgen -P "$pfx" \
428 -W "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \
429 | sed '/^100... blob /{
430 s,^.* ,,
431 s,$, ,
433 /^120000 blob /{
434 s,^.* ,,
435 s,$, ,
437 /^040000 tree /{
438 s,^.* ,,
439 s,$,/,
441 s/^.* //')" \
442 -- "$cur_"))
444 *...*)
445 pfx="${cur_%...*}..."
446 cur_="${cur_#*...}"
447 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
449 *..*)
450 pfx="${cur_%..*}.."
451 cur_="${cur_#*..}"
452 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
455 __gitcomp_nl "$(__git_refs)"
457 esac
461 __git_complete_file ()
463 __git_complete_revlist_file
466 __git_complete_revlist ()
468 __git_complete_revlist_file
471 __git_complete_remote_or_refspec ()
473 local cur_="$cur" cmd="${words[1]}"
474 local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0
475 if [ "$cmd" = "remote" ]; then
476 ((c++))
478 while [ $c -lt $cword ]; do
479 i="${words[c]}"
480 case "$i" in
481 --mirror) [ "$cmd" = "push" ] && no_complete_refspec=1 ;;
482 --all)
483 case "$cmd" in
484 push) no_complete_refspec=1 ;;
485 fetch)
486 COMPREPLY=()
487 return
489 *) ;;
490 esac
492 -*) ;;
493 *) remote="$i"; break ;;
494 esac
495 ((c++))
496 done
497 if [ -z "$remote" ]; then
498 __gitcomp_nl "$(__git_remotes)"
499 return
501 if [ $no_complete_refspec = 1 ]; then
502 COMPREPLY=()
503 return
505 [ "$remote" = "." ] && remote=
506 case "$cur_" in
507 *:*)
508 case "$COMP_WORDBREAKS" in
509 *:*) : great ;;
510 *) pfx="${cur_%%:*}:" ;;
511 esac
512 cur_="${cur_#*:}"
513 lhs=0
516 pfx="+"
517 cur_="${cur_#+}"
519 esac
520 case "$cmd" in
521 fetch)
522 if [ $lhs = 1 ]; then
523 __gitcomp_nl "$(__git_refs2 "$remote")" "$pfx" "$cur_"
524 else
525 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
528 pull|remote)
529 if [ $lhs = 1 ]; then
530 __gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_"
531 else
532 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
535 push)
536 if [ $lhs = 1 ]; then
537 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
538 else
539 __gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_"
542 esac
545 __git_complete_strategy ()
547 __git_compute_merge_strategies
548 case "$prev" in
549 -s|--strategy)
550 __gitcomp "$__git_merge_strategies"
551 return 0
552 esac
553 case "$cur" in
554 --strategy=*)
555 __gitcomp "$__git_merge_strategies" "" "${cur##--strategy=}"
556 return 0
558 esac
559 return 1
562 __git_list_all_commands ()
564 local i IFS=" "$'\n'
565 for i in $(git help -a|egrep '^ [a-zA-Z0-9]')
567 case $i in
568 *--*) : helper pattern;;
569 *) echo $i;;
570 esac
571 done
574 __git_all_commands=
575 __git_compute_all_commands ()
577 test -n "$__git_all_commands" ||
578 __git_all_commands=$(__git_list_all_commands)
581 __git_list_porcelain_commands ()
583 local i IFS=" "$'\n'
584 __git_compute_all_commands
585 for i in "help" $__git_all_commands
587 case $i in
588 *--*) : helper pattern;;
589 applymbox) : ask gittus;;
590 applypatch) : ask gittus;;
591 archimport) : import;;
592 cat-file) : plumbing;;
593 check-attr) : plumbing;;
594 check-ref-format) : plumbing;;
595 checkout-index) : plumbing;;
596 commit-tree) : plumbing;;
597 count-objects) : infrequent;;
598 cvsexportcommit) : export;;
599 cvsimport) : import;;
600 cvsserver) : daemon;;
601 daemon) : daemon;;
602 diff-files) : plumbing;;
603 diff-index) : plumbing;;
604 diff-tree) : plumbing;;
605 fast-import) : import;;
606 fast-export) : export;;
607 fsck-objects) : plumbing;;
608 fetch-pack) : plumbing;;
609 fmt-merge-msg) : plumbing;;
610 for-each-ref) : plumbing;;
611 hash-object) : plumbing;;
612 http-*) : transport;;
613 index-pack) : plumbing;;
614 init-db) : deprecated;;
615 local-fetch) : plumbing;;
616 lost-found) : infrequent;;
617 ls-files) : plumbing;;
618 ls-remote) : plumbing;;
619 ls-tree) : plumbing;;
620 mailinfo) : plumbing;;
621 mailsplit) : plumbing;;
622 merge-*) : plumbing;;
623 mktree) : plumbing;;
624 mktag) : plumbing;;
625 pack-objects) : plumbing;;
626 pack-redundant) : plumbing;;
627 pack-refs) : plumbing;;
628 parse-remote) : plumbing;;
629 patch-id) : plumbing;;
630 peek-remote) : plumbing;;
631 prune) : plumbing;;
632 prune-packed) : plumbing;;
633 quiltimport) : import;;
634 read-tree) : plumbing;;
635 receive-pack) : plumbing;;
636 remote-*) : transport;;
637 repo-config) : deprecated;;
638 rerere) : plumbing;;
639 rev-list) : plumbing;;
640 rev-parse) : plumbing;;
641 runstatus) : plumbing;;
642 sh-setup) : internal;;
643 shell) : daemon;;
644 show-ref) : plumbing;;
645 send-pack) : plumbing;;
646 show-index) : plumbing;;
647 ssh-*) : transport;;
648 stripspace) : plumbing;;
649 symbolic-ref) : plumbing;;
650 tar-tree) : deprecated;;
651 unpack-file) : plumbing;;
652 unpack-objects) : plumbing;;
653 update-index) : plumbing;;
654 update-ref) : plumbing;;
655 update-server-info) : daemon;;
656 upload-archive) : plumbing;;
657 upload-pack) : plumbing;;
658 write-tree) : plumbing;;
659 var) : infrequent;;
660 verify-pack) : infrequent;;
661 verify-tag) : plumbing;;
662 *) echo $i;;
663 esac
664 done
667 __git_porcelain_commands=
668 __git_compute_porcelain_commands ()
670 __git_compute_all_commands
671 test -n "$__git_porcelain_commands" ||
672 __git_porcelain_commands=$(__git_list_porcelain_commands)
675 __git_pretty_aliases ()
677 local i IFS=$'\n'
678 for i in $(git --git-dir="$(__gitdir)" config --get-regexp "pretty\..*" 2>/dev/null); do
679 case "$i" in
680 pretty.*)
681 i="${i#pretty.}"
682 echo "${i/ */}"
684 esac
685 done
688 __git_aliases ()
690 local i IFS=$'\n'
691 for i in $(git --git-dir="$(__gitdir)" config --get-regexp "alias\..*" 2>/dev/null); do
692 case "$i" in
693 alias.*)
694 i="${i#alias.}"
695 echo "${i/ */}"
697 esac
698 done
701 # __git_aliased_command requires 1 argument
702 __git_aliased_command ()
704 local word cmdline=$(git --git-dir="$(__gitdir)" \
705 config --get "alias.$1")
706 for word in $cmdline; do
707 case "$word" in
708 \!gitk|gitk)
709 echo "gitk"
710 return
712 \!*) : shell command alias ;;
713 -*) : option ;;
714 *=*) : setting env ;;
715 git) : git itself ;;
717 echo "$word"
718 return
719 esac
720 done
723 # __git_find_on_cmdline requires 1 argument
724 __git_find_on_cmdline ()
726 local word subcommand c=1
727 while [ $c -lt $cword ]; do
728 word="${words[c]}"
729 for subcommand in $1; do
730 if [ "$subcommand" = "$word" ]; then
731 echo "$subcommand"
732 return
734 done
735 ((c++))
736 done
739 __git_has_doubledash ()
741 local c=1
742 while [ $c -lt $cword ]; do
743 if [ "--" = "${words[c]}" ]; then
744 return 0
746 ((c++))
747 done
748 return 1
751 __git_whitespacelist="nowarn warn error error-all fix"
753 _git_am ()
755 local dir="$(__gitdir)"
756 if [ -d "$dir"/rebase-apply ]; then
757 __gitcomp "--skip --continue --resolved --abort"
758 return
760 case "$cur" in
761 --whitespace=*)
762 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
763 return
765 --*)
766 __gitcomp "
767 --3way --committer-date-is-author-date --ignore-date
768 --ignore-whitespace --ignore-space-change
769 --interactive --keep --no-utf8 --signoff --utf8
770 --whitespace= --scissors
772 return
773 esac
774 COMPREPLY=()
777 _git_apply ()
779 case "$cur" in
780 --whitespace=*)
781 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
782 return
784 --*)
785 __gitcomp "
786 --stat --numstat --summary --check --index
787 --cached --index-info --reverse --reject --unidiff-zero
788 --apply --no-add --exclude=
789 --ignore-whitespace --ignore-space-change
790 --whitespace= --inaccurate-eof --verbose
792 return
793 esac
794 COMPREPLY=()
797 _git_add ()
799 __git_has_doubledash && return
801 case "$cur" in
802 --*)
803 __gitcomp "
804 --interactive --refresh --patch --update --dry-run
805 --ignore-errors --intent-to-add
807 return
808 esac
809 COMPREPLY=()
812 _git_archive ()
814 case "$cur" in
815 --format=*)
816 __gitcomp "$(git archive --list)" "" "${cur##--format=}"
817 return
819 --remote=*)
820 __gitcomp_nl "$(__git_remotes)" "" "${cur##--remote=}"
821 return
823 --*)
824 __gitcomp "
825 --format= --list --verbose
826 --prefix= --remote= --exec=
828 return
830 esac
831 __git_complete_file
834 _git_bisect ()
836 __git_has_doubledash && return
838 local subcommands="start bad good skip reset visualize replay log run"
839 local subcommand="$(__git_find_on_cmdline "$subcommands")"
840 if [ -z "$subcommand" ]; then
841 if [ -f "$(__gitdir)"/BISECT_START ]; then
842 __gitcomp "$subcommands"
843 else
844 __gitcomp "replay start"
846 return
849 case "$subcommand" in
850 bad|good|reset|skip|start)
851 __gitcomp_nl "$(__git_refs)"
854 COMPREPLY=()
856 esac
859 _git_branch ()
861 local i c=1 only_local_ref="n" has_r="n"
863 while [ $c -lt $cword ]; do
864 i="${words[c]}"
865 case "$i" in
866 -d|-m) only_local_ref="y" ;;
867 -r) has_r="y" ;;
868 esac
869 ((c++))
870 done
872 case "$cur" in
873 --*)
874 __gitcomp "
875 --color --no-color --verbose --abbrev= --no-abbrev
876 --track --no-track --contains --merged --no-merged
877 --set-upstream --edit-description --list
881 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
882 __gitcomp_nl "$(__git_heads)"
883 else
884 __gitcomp_nl "$(__git_refs)"
887 esac
890 _git_bundle ()
892 local cmd="${words[2]}"
893 case "$cword" in
895 __gitcomp "create list-heads verify unbundle"
898 # looking for a file
901 case "$cmd" in
902 create)
903 __git_complete_revlist
905 esac
907 esac
910 _git_checkout ()
912 __git_has_doubledash && return
914 case "$cur" in
915 --conflict=*)
916 __gitcomp "diff3 merge" "" "${cur##--conflict=}"
918 --*)
919 __gitcomp "
920 --quiet --ours --theirs --track --no-track --merge
921 --conflict= --orphan --patch
925 # check if --track, --no-track, or --no-guess was specified
926 # if so, disable DWIM mode
927 local flags="--track --no-track --no-guess" track=1
928 if [ -n "$(__git_find_on_cmdline "$flags")" ]; then
929 track=''
931 __gitcomp_nl "$(__git_refs '' $track)"
933 esac
936 _git_cherry ()
938 __gitcomp "$(__git_refs)"
941 _git_cherry_pick ()
943 case "$cur" in
944 --*)
945 __gitcomp "--edit --no-commit"
948 __gitcomp_nl "$(__git_refs)"
950 esac
953 _git_clean ()
955 __git_has_doubledash && return
957 case "$cur" in
958 --*)
959 __gitcomp "--dry-run --quiet"
960 return
962 esac
963 COMPREPLY=()
966 _git_clone ()
968 case "$cur" in
969 --*)
970 __gitcomp "
971 --local
972 --no-hardlinks
973 --shared
974 --reference
975 --quiet
976 --no-checkout
977 --bare
978 --mirror
979 --origin
980 --upload-pack
981 --template=
982 --depth
984 return
986 esac
987 COMPREPLY=()
990 _git_commit ()
992 __git_has_doubledash && return
994 case "$cur" in
995 --cleanup=*)
996 __gitcomp "default strip verbatim whitespace
997 " "" "${cur##--cleanup=}"
998 return
1000 --reuse-message=*|--reedit-message=*|\
1001 --fixup=*|--squash=*)
1002 __gitcomp_nl "$(__git_refs)" "" "${cur#*=}"
1003 return
1005 --untracked-files=*)
1006 __gitcomp "all no normal" "" "${cur##--untracked-files=}"
1007 return
1009 --*)
1010 __gitcomp "
1011 --all --author= --signoff --verify --no-verify
1012 --edit --amend --include --only --interactive
1013 --dry-run --reuse-message= --reedit-message=
1014 --reset-author --file= --message= --template=
1015 --cleanup= --untracked-files --untracked-files=
1016 --verbose --quiet --fixup= --squash=
1018 return
1019 esac
1020 COMPREPLY=()
1023 _git_describe ()
1025 case "$cur" in
1026 --*)
1027 __gitcomp "
1028 --all --tags --contains --abbrev= --candidates=
1029 --exact-match --debug --long --match --always
1031 return
1032 esac
1033 __gitcomp_nl "$(__git_refs)"
1036 __git_diff_common_options="--stat --numstat --shortstat --summary
1037 --patch-with-stat --name-only --name-status --color
1038 --no-color --color-words --no-renames --check
1039 --full-index --binary --abbrev --diff-filter=
1040 --find-copies-harder
1041 --text --ignore-space-at-eol --ignore-space-change
1042 --ignore-all-space --exit-code --quiet --ext-diff
1043 --no-ext-diff
1044 --no-prefix --src-prefix= --dst-prefix=
1045 --inter-hunk-context=
1046 --patience
1047 --raw
1048 --dirstat --dirstat= --dirstat-by-file
1049 --dirstat-by-file= --cumulative
1052 _git_diff ()
1054 __git_has_doubledash && return
1056 case "$cur" in
1057 --*)
1058 __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
1059 --base --ours --theirs --no-index
1060 $__git_diff_common_options
1062 return
1064 esac
1065 __git_complete_revlist_file
1068 __git_mergetools_common="diffuse ecmerge emerge kdiff3 meld opendiff
1069 tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc3
1072 _git_difftool ()
1074 __git_has_doubledash && return
1076 case "$cur" in
1077 --tool=*)
1078 __gitcomp "$__git_mergetools_common kompare" "" "${cur##--tool=}"
1079 return
1081 --*)
1082 __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
1083 --base --ours --theirs
1084 --no-renames --diff-filter= --find-copies-harder
1085 --relative --ignore-submodules
1086 --tool="
1087 return
1089 esac
1090 __git_complete_file
1093 __git_fetch_options="
1094 --quiet --verbose --append --upload-pack --force --keep --depth=
1095 --tags --no-tags --all --prune --dry-run
1098 _git_fetch ()
1100 case "$cur" in
1101 --*)
1102 __gitcomp "$__git_fetch_options"
1103 return
1105 esac
1106 __git_complete_remote_or_refspec
1109 _git_format_patch ()
1111 case "$cur" in
1112 --thread=*)
1113 __gitcomp "
1114 deep shallow
1115 " "" "${cur##--thread=}"
1116 return
1118 --*)
1119 __gitcomp "
1120 --stdout --attach --no-attach --thread --thread=
1121 --output-directory
1122 --numbered --start-number
1123 --numbered-files
1124 --keep-subject
1125 --signoff --signature --no-signature
1126 --in-reply-to= --cc=
1127 --full-index --binary
1128 --not --all
1129 --cover-letter
1130 --no-prefix --src-prefix= --dst-prefix=
1131 --inline --suffix= --ignore-if-in-upstream
1132 --subject-prefix=
1134 return
1136 esac
1137 __git_complete_revlist
1140 _git_fsck ()
1142 case "$cur" in
1143 --*)
1144 __gitcomp "
1145 --tags --root --unreachable --cache --no-reflogs --full
1146 --strict --verbose --lost-found
1148 return
1150 esac
1151 COMPREPLY=()
1154 _git_gc ()
1156 case "$cur" in
1157 --*)
1158 __gitcomp "--prune --aggressive"
1159 return
1161 esac
1162 COMPREPLY=()
1165 _git_gitk ()
1167 _gitk
1170 __git_match_ctag() {
1171 awk "/^${1////\\/}/ { print \$1 }" "$2"
1174 _git_grep ()
1176 __git_has_doubledash && return
1178 case "$cur" in
1179 --*)
1180 __gitcomp "
1181 --cached
1182 --text --ignore-case --word-regexp --invert-match
1183 --full-name --line-number
1184 --extended-regexp --basic-regexp --fixed-strings
1185 --perl-regexp
1186 --files-with-matches --name-only
1187 --files-without-match
1188 --max-depth
1189 --count
1190 --and --or --not --all-match
1192 return
1194 esac
1196 case "$cword,$prev" in
1197 2,*|*,-*)
1198 if test -r tags; then
1199 __gitcomp_nl "$(__git_match_ctag "$cur" tags)"
1200 return
1203 esac
1205 __gitcomp_nl "$(__git_refs)"
1208 _git_help ()
1210 case "$cur" in
1211 --*)
1212 __gitcomp "--all --info --man --web"
1213 return
1215 esac
1216 __git_compute_all_commands
1217 __gitcomp "$__git_all_commands $(__git_aliases)
1218 attributes cli core-tutorial cvs-migration
1219 diffcore gitk glossary hooks ignore modules
1220 namespaces repository-layout tutorial tutorial-2
1221 workflows
1225 _git_init ()
1227 case "$cur" in
1228 --shared=*)
1229 __gitcomp "
1230 false true umask group all world everybody
1231 " "" "${cur##--shared=}"
1232 return
1234 --*)
1235 __gitcomp "--quiet --bare --template= --shared --shared="
1236 return
1238 esac
1239 COMPREPLY=()
1242 _git_ls_files ()
1244 __git_has_doubledash && return
1246 case "$cur" in
1247 --*)
1248 __gitcomp "--cached --deleted --modified --others --ignored
1249 --stage --directory --no-empty-directory --unmerged
1250 --killed --exclude= --exclude-from=
1251 --exclude-per-directory= --exclude-standard
1252 --error-unmatch --with-tree= --full-name
1253 --abbrev --ignored --exclude-per-directory
1255 return
1257 esac
1258 COMPREPLY=()
1261 _git_ls_remote ()
1263 __gitcomp_nl "$(__git_remotes)"
1266 _git_ls_tree ()
1268 __git_complete_file
1271 # Options that go well for log, shortlog and gitk
1272 __git_log_common_options="
1273 --not --all
1274 --branches --tags --remotes
1275 --first-parent --merges --no-merges
1276 --max-count=
1277 --max-age= --since= --after=
1278 --min-age= --until= --before=
1279 --min-parents= --max-parents=
1280 --no-min-parents --no-max-parents
1282 # Options that go well for log and gitk (not shortlog)
1283 __git_log_gitk_options="
1284 --dense --sparse --full-history
1285 --simplify-merges --simplify-by-decoration
1286 --left-right --notes --no-notes
1288 # Options that go well for log and shortlog (not gitk)
1289 __git_log_shortlog_options="
1290 --author= --committer= --grep=
1291 --all-match
1294 __git_log_pretty_formats="oneline short medium full fuller email raw format:"
1295 __git_log_date_formats="relative iso8601 rfc2822 short local default raw"
1297 _git_log ()
1299 __git_has_doubledash && return
1301 local g="$(git rev-parse --git-dir 2>/dev/null)"
1302 local merge=""
1303 if [ -f "$g/MERGE_HEAD" ]; then
1304 merge="--merge"
1306 case "$cur" in
1307 --pretty=*|--format=*)
1308 __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
1309 " "" "${cur#*=}"
1310 return
1312 --date=*)
1313 __gitcomp "$__git_log_date_formats" "" "${cur##--date=}"
1314 return
1316 --decorate=*)
1317 __gitcomp "long short" "" "${cur##--decorate=}"
1318 return
1320 --*)
1321 __gitcomp "
1322 $__git_log_common_options
1323 $__git_log_shortlog_options
1324 $__git_log_gitk_options
1325 --root --topo-order --date-order --reverse
1326 --follow --full-diff
1327 --abbrev-commit --abbrev=
1328 --relative-date --date=
1329 --pretty= --format= --oneline
1330 --cherry-pick
1331 --graph
1332 --decorate --decorate=
1333 --walk-reflogs
1334 --parents --children
1335 $merge
1336 $__git_diff_common_options
1337 --pickaxe-all --pickaxe-regex
1339 return
1341 esac
1342 __git_complete_revlist
1345 __git_merge_options="
1346 --no-commit --no-stat --log --no-log --squash --strategy
1347 --commit --stat --no-squash --ff --no-ff --ff-only --edit --no-edit
1350 _git_merge ()
1352 __git_complete_strategy && return
1354 case "$cur" in
1355 --*)
1356 __gitcomp "$__git_merge_options"
1357 return
1358 esac
1359 __gitcomp_nl "$(__git_refs)"
1362 _git_mergetool ()
1364 case "$cur" in
1365 --tool=*)
1366 __gitcomp "$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"
1367 return
1369 --*)
1370 __gitcomp "--tool="
1371 return
1373 esac
1374 COMPREPLY=()
1377 _git_merge_base ()
1379 __gitcomp_nl "$(__git_refs)"
1382 _git_mv ()
1384 case "$cur" in
1385 --*)
1386 __gitcomp "--dry-run"
1387 return
1389 esac
1390 COMPREPLY=()
1393 _git_name_rev ()
1395 __gitcomp "--tags --all --stdin"
1398 _git_notes ()
1400 local subcommands='add append copy edit list prune remove show'
1401 local subcommand="$(__git_find_on_cmdline "$subcommands")"
1403 case "$subcommand,$cur" in
1404 ,--*)
1405 __gitcomp '--ref'
1408 case "$prev" in
1409 --ref)
1410 __gitcomp_nl "$(__git_refs)"
1413 __gitcomp "$subcommands --ref"
1415 esac
1417 add,--reuse-message=*|append,--reuse-message=*|\
1418 add,--reedit-message=*|append,--reedit-message=*)
1419 __gitcomp_nl "$(__git_refs)" "" "${cur#*=}"
1421 add,--*|append,--*)
1422 __gitcomp '--file= --message= --reedit-message=
1423 --reuse-message='
1425 copy,--*)
1426 __gitcomp '--stdin'
1428 prune,--*)
1429 __gitcomp '--dry-run --verbose'
1431 prune,*)
1434 case "$prev" in
1435 -m|-F)
1438 __gitcomp_nl "$(__git_refs)"
1440 esac
1442 esac
1445 _git_pull ()
1447 __git_complete_strategy && return
1449 case "$cur" in
1450 --*)
1451 __gitcomp "
1452 --rebase --no-rebase
1453 $__git_merge_options
1454 $__git_fetch_options
1456 return
1458 esac
1459 __git_complete_remote_or_refspec
1462 _git_push ()
1464 case "$prev" in
1465 --repo)
1466 __gitcomp_nl "$(__git_remotes)"
1467 return
1468 esac
1469 case "$cur" in
1470 --repo=*)
1471 __gitcomp_nl "$(__git_remotes)" "" "${cur##--repo=}"
1472 return
1474 --*)
1475 __gitcomp "
1476 --all --mirror --tags --dry-run --force --verbose
1477 --receive-pack= --repo= --set-upstream
1479 return
1481 esac
1482 __git_complete_remote_or_refspec
1485 _git_rebase ()
1487 local dir="$(__gitdir)"
1488 if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
1489 __gitcomp "--continue --skip --abort"
1490 return
1492 __git_complete_strategy && return
1493 case "$cur" in
1494 --whitespace=*)
1495 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
1496 return
1498 --*)
1499 __gitcomp "
1500 --onto --merge --strategy --interactive
1501 --preserve-merges --stat --no-stat
1502 --committer-date-is-author-date --ignore-date
1503 --ignore-whitespace --whitespace=
1504 --autosquash
1507 return
1508 esac
1509 __gitcomp_nl "$(__git_refs)"
1512 _git_reflog ()
1514 local subcommands="show delete expire"
1515 local subcommand="$(__git_find_on_cmdline "$subcommands")"
1517 if [ -z "$subcommand" ]; then
1518 __gitcomp "$subcommands"
1519 else
1520 __gitcomp_nl "$(__git_refs)"
1524 __git_send_email_confirm_options="always never auto cc compose"
1525 __git_send_email_suppresscc_options="author self cc bodycc sob cccmd body all"
1527 _git_send_email ()
1529 case "$cur" in
1530 --confirm=*)
1531 __gitcomp "
1532 $__git_send_email_confirm_options
1533 " "" "${cur##--confirm=}"
1534 return
1536 --suppress-cc=*)
1537 __gitcomp "
1538 $__git_send_email_suppresscc_options
1539 " "" "${cur##--suppress-cc=}"
1541 return
1543 --smtp-encryption=*)
1544 __gitcomp "ssl tls" "" "${cur##--smtp-encryption=}"
1545 return
1547 --*)
1548 __gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to
1549 --compose --confirm= --dry-run --envelope-sender
1550 --from --identity
1551 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
1552 --no-suppress-from --no-thread --quiet
1553 --signed-off-by-cc --smtp-pass --smtp-server
1554 --smtp-server-port --smtp-encryption= --smtp-user
1555 --subject --suppress-cc= --suppress-from --thread --to
1556 --validate --no-validate"
1557 return
1559 esac
1560 COMPREPLY=()
1563 _git_stage ()
1565 _git_add
1568 __git_config_get_set_variables ()
1570 local prevword word config_file= c=$cword
1571 while [ $c -gt 1 ]; do
1572 word="${words[c]}"
1573 case "$word" in
1574 --global|--system|--file=*)
1575 config_file="$word"
1576 break
1578 -f|--file)
1579 config_file="$word $prevword"
1580 break
1582 esac
1583 prevword=$word
1584 c=$((--c))
1585 done
1587 git --git-dir="$(__gitdir)" config $config_file --list 2>/dev/null |
1588 while read -r line
1590 case "$line" in
1591 *.*=*)
1592 echo "${line/=*/}"
1594 esac
1595 done
1598 _git_config ()
1600 case "$prev" in
1601 branch.*.remote)
1602 __gitcomp_nl "$(__git_remotes)"
1603 return
1605 branch.*.merge)
1606 __gitcomp_nl "$(__git_refs)"
1607 return
1609 remote.*.fetch)
1610 local remote="${prev#remote.}"
1611 remote="${remote%.fetch}"
1612 if [ -z "$cur" ]; then
1613 COMPREPLY=("refs/heads/")
1614 return
1616 __gitcomp_nl "$(__git_refs_remotes "$remote")"
1617 return
1619 remote.*.push)
1620 local remote="${prev#remote.}"
1621 remote="${remote%.push}"
1622 __gitcomp_nl "$(git --git-dir="$(__gitdir)" \
1623 for-each-ref --format='%(refname):%(refname)' \
1624 refs/heads)"
1625 return
1627 pull.twohead|pull.octopus)
1628 __git_compute_merge_strategies
1629 __gitcomp "$__git_merge_strategies"
1630 return
1632 color.branch|color.diff|color.interactive|\
1633 color.showbranch|color.status|color.ui)
1634 __gitcomp "always never auto"
1635 return
1637 color.pager)
1638 __gitcomp "false true"
1639 return
1641 color.*.*)
1642 __gitcomp "
1643 normal black red green yellow blue magenta cyan white
1644 bold dim ul blink reverse
1646 return
1648 help.format)
1649 __gitcomp "man info web html"
1650 return
1652 log.date)
1653 __gitcomp "$__git_log_date_formats"
1654 return
1656 sendemail.aliasesfiletype)
1657 __gitcomp "mutt mailrc pine elm gnus"
1658 return
1660 sendemail.confirm)
1661 __gitcomp "$__git_send_email_confirm_options"
1662 return
1664 sendemail.suppresscc)
1665 __gitcomp "$__git_send_email_suppresscc_options"
1666 return
1668 --get|--get-all|--unset|--unset-all)
1669 __gitcomp_nl "$(__git_config_get_set_variables)"
1670 return
1672 *.*)
1673 COMPREPLY=()
1674 return
1676 esac
1677 case "$cur" in
1678 --*)
1679 __gitcomp "
1680 --global --system --file=
1681 --list --replace-all
1682 --get --get-all --get-regexp
1683 --add --unset --unset-all
1684 --remove-section --rename-section
1686 return
1688 branch.*.*)
1689 local pfx="${cur%.*}." cur_="${cur##*.}"
1690 __gitcomp "remote merge mergeoptions rebase" "$pfx" "$cur_"
1691 return
1693 branch.*)
1694 local pfx="${cur%.*}." cur_="${cur#*.}"
1695 __gitcomp_nl "$(__git_heads)" "$pfx" "$cur_" "."
1696 return
1698 guitool.*.*)
1699 local pfx="${cur%.*}." cur_="${cur##*.}"
1700 __gitcomp "
1701 argprompt cmd confirm needsfile noconsole norescan
1702 prompt revprompt revunmerged title
1703 " "$pfx" "$cur_"
1704 return
1706 difftool.*.*)
1707 local pfx="${cur%.*}." cur_="${cur##*.}"
1708 __gitcomp "cmd path" "$pfx" "$cur_"
1709 return
1711 man.*.*)
1712 local pfx="${cur%.*}." cur_="${cur##*.}"
1713 __gitcomp "cmd path" "$pfx" "$cur_"
1714 return
1716 mergetool.*.*)
1717 local pfx="${cur%.*}." cur_="${cur##*.}"
1718 __gitcomp "cmd path trustExitCode" "$pfx" "$cur_"
1719 return
1721 pager.*)
1722 local pfx="${cur%.*}." cur_="${cur#*.}"
1723 __git_compute_all_commands
1724 __gitcomp_nl "$__git_all_commands" "$pfx" "$cur_"
1725 return
1727 remote.*.*)
1728 local pfx="${cur%.*}." cur_="${cur##*.}"
1729 __gitcomp "
1730 url proxy fetch push mirror skipDefaultUpdate
1731 receivepack uploadpack tagopt pushurl
1732 " "$pfx" "$cur_"
1733 return
1735 remote.*)
1736 local pfx="${cur%.*}." cur_="${cur#*.}"
1737 __gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "."
1738 return
1740 url.*.*)
1741 local pfx="${cur%.*}." cur_="${cur##*.}"
1742 __gitcomp "insteadOf pushInsteadOf" "$pfx" "$cur_"
1743 return
1745 esac
1746 __gitcomp "
1747 add.ignoreErrors
1748 advice.commitBeforeMerge
1749 advice.detachedHead
1750 advice.implicitIdentity
1751 advice.pushNonFastForward
1752 advice.resolveConflict
1753 advice.statusHints
1754 alias.
1755 am.keepcr
1756 apply.ignorewhitespace
1757 apply.whitespace
1758 branch.autosetupmerge
1759 branch.autosetuprebase
1760 browser.
1761 clean.requireForce
1762 color.branch
1763 color.branch.current
1764 color.branch.local
1765 color.branch.plain
1766 color.branch.remote
1767 color.decorate.HEAD
1768 color.decorate.branch
1769 color.decorate.remoteBranch
1770 color.decorate.stash
1771 color.decorate.tag
1772 color.diff
1773 color.diff.commit
1774 color.diff.frag
1775 color.diff.func
1776 color.diff.meta
1777 color.diff.new
1778 color.diff.old
1779 color.diff.plain
1780 color.diff.whitespace
1781 color.grep
1782 color.grep.context
1783 color.grep.filename
1784 color.grep.function
1785 color.grep.linenumber
1786 color.grep.match
1787 color.grep.selected
1788 color.grep.separator
1789 color.interactive
1790 color.interactive.error
1791 color.interactive.header
1792 color.interactive.help
1793 color.interactive.prompt
1794 color.pager
1795 color.showbranch
1796 color.status
1797 color.status.added
1798 color.status.changed
1799 color.status.header
1800 color.status.nobranch
1801 color.status.untracked
1802 color.status.updated
1803 color.ui
1804 commit.status
1805 commit.template
1806 core.abbrev
1807 core.askpass
1808 core.attributesfile
1809 core.autocrlf
1810 core.bare
1811 core.bigFileThreshold
1812 core.compression
1813 core.createObject
1814 core.deltaBaseCacheLimit
1815 core.editor
1816 core.eol
1817 core.excludesfile
1818 core.fileMode
1819 core.fsyncobjectfiles
1820 core.gitProxy
1821 core.ignoreCygwinFSTricks
1822 core.ignoreStat
1823 core.ignorecase
1824 core.logAllRefUpdates
1825 core.loosecompression
1826 core.notesRef
1827 core.packedGitLimit
1828 core.packedGitWindowSize
1829 core.pager
1830 core.preferSymlinkRefs
1831 core.preloadindex
1832 core.quotepath
1833 core.repositoryFormatVersion
1834 core.safecrlf
1835 core.sharedRepository
1836 core.sparseCheckout
1837 core.symlinks
1838 core.trustctime
1839 core.warnAmbiguousRefs
1840 core.whitespace
1841 core.worktree
1842 diff.autorefreshindex
1843 diff.statGraphWidth
1844 diff.external
1845 diff.ignoreSubmodules
1846 diff.mnemonicprefix
1847 diff.noprefix
1848 diff.renameLimit
1849 diff.renames
1850 diff.suppressBlankEmpty
1851 diff.tool
1852 diff.wordRegex
1853 difftool.
1854 difftool.prompt
1855 fetch.recurseSubmodules
1856 fetch.unpackLimit
1857 format.attach
1858 format.cc
1859 format.headers
1860 format.numbered
1861 format.pretty
1862 format.signature
1863 format.signoff
1864 format.subjectprefix
1865 format.suffix
1866 format.thread
1867 format.to
1869 gc.aggressiveWindow
1870 gc.auto
1871 gc.autopacklimit
1872 gc.packrefs
1873 gc.pruneexpire
1874 gc.reflogexpire
1875 gc.reflogexpireunreachable
1876 gc.rerereresolved
1877 gc.rerereunresolved
1878 gitcvs.allbinary
1879 gitcvs.commitmsgannotation
1880 gitcvs.dbTableNamePrefix
1881 gitcvs.dbdriver
1882 gitcvs.dbname
1883 gitcvs.dbpass
1884 gitcvs.dbuser
1885 gitcvs.enabled
1886 gitcvs.logfile
1887 gitcvs.usecrlfattr
1888 guitool.
1889 gui.blamehistoryctx
1890 gui.commitmsgwidth
1891 gui.copyblamethreshold
1892 gui.diffcontext
1893 gui.encoding
1894 gui.fastcopyblame
1895 gui.matchtrackingbranch
1896 gui.newbranchtemplate
1897 gui.pruneduringfetch
1898 gui.spellingdictionary
1899 gui.trustmtime
1900 help.autocorrect
1901 help.browser
1902 help.format
1903 http.lowSpeedLimit
1904 http.lowSpeedTime
1905 http.maxRequests
1906 http.minSessions
1907 http.noEPSV
1908 http.postBuffer
1909 http.proxy
1910 http.sslCAInfo
1911 http.sslCAPath
1912 http.sslCert
1913 http.sslCertPasswordProtected
1914 http.sslKey
1915 http.sslVerify
1916 http.useragent
1917 i18n.commitEncoding
1918 i18n.logOutputEncoding
1919 imap.authMethod
1920 imap.folder
1921 imap.host
1922 imap.pass
1923 imap.port
1924 imap.preformattedHTML
1925 imap.sslverify
1926 imap.tunnel
1927 imap.user
1928 init.templatedir
1929 instaweb.browser
1930 instaweb.httpd
1931 instaweb.local
1932 instaweb.modulepath
1933 instaweb.port
1934 interactive.singlekey
1935 log.date
1936 log.decorate
1937 log.showroot
1938 mailmap.file
1939 man.
1940 man.viewer
1941 merge.
1942 merge.conflictstyle
1943 merge.log
1944 merge.renameLimit
1945 merge.renormalize
1946 merge.stat
1947 merge.tool
1948 merge.verbosity
1949 mergetool.
1950 mergetool.keepBackup
1951 mergetool.keepTemporaries
1952 mergetool.prompt
1953 notes.displayRef
1954 notes.rewrite.
1955 notes.rewrite.amend
1956 notes.rewrite.rebase
1957 notes.rewriteMode
1958 notes.rewriteRef
1959 pack.compression
1960 pack.deltaCacheLimit
1961 pack.deltaCacheSize
1962 pack.depth
1963 pack.indexVersion
1964 pack.packSizeLimit
1965 pack.threads
1966 pack.window
1967 pack.windowMemory
1968 pager.
1969 pretty.
1970 pull.octopus
1971 pull.twohead
1972 push.default
1973 rebase.autosquash
1974 rebase.stat
1975 receive.autogc
1976 receive.denyCurrentBranch
1977 receive.denyDeleteCurrent
1978 receive.denyDeletes
1979 receive.denyNonFastForwards
1980 receive.fsckObjects
1981 receive.unpackLimit
1982 receive.updateserverinfo
1983 remotes.
1984 repack.usedeltabaseoffset
1985 rerere.autoupdate
1986 rerere.enabled
1987 sendemail.
1988 sendemail.aliasesfile
1989 sendemail.aliasfiletype
1990 sendemail.bcc
1991 sendemail.cc
1992 sendemail.cccmd
1993 sendemail.chainreplyto
1994 sendemail.confirm
1995 sendemail.envelopesender
1996 sendemail.from
1997 sendemail.identity
1998 sendemail.multiedit
1999 sendemail.signedoffbycc
2000 sendemail.smtpdomain
2001 sendemail.smtpencryption
2002 sendemail.smtppass
2003 sendemail.smtpserver
2004 sendemail.smtpserveroption
2005 sendemail.smtpserverport
2006 sendemail.smtpuser
2007 sendemail.suppresscc
2008 sendemail.suppressfrom
2009 sendemail.thread
2010 sendemail.to
2011 sendemail.validate
2012 showbranch.default
2013 status.relativePaths
2014 status.showUntrackedFiles
2015 status.submodulesummary
2016 submodule.
2017 tar.umask
2018 transfer.unpackLimit
2019 url.
2020 user.email
2021 user.name
2022 user.signingkey
2023 web.browser
2024 branch. remote.
2028 _git_remote ()
2030 local subcommands="add rename rm set-head set-branches set-url show prune update"
2031 local subcommand="$(__git_find_on_cmdline "$subcommands")"
2032 if [ -z "$subcommand" ]; then
2033 __gitcomp "$subcommands"
2034 return
2037 case "$subcommand" in
2038 rename|rm|set-url|show|prune)
2039 __gitcomp_nl "$(__git_remotes)"
2041 set-head|set-branches)
2042 __git_complete_remote_or_refspec
2044 update)
2045 local i c='' IFS=$'\n'
2046 for i in $(git --git-dir="$(__gitdir)" config --get-regexp "remotes\..*" 2>/dev/null); do
2047 i="${i#remotes.}"
2048 c="$c ${i/ */}"
2049 done
2050 __gitcomp "$c"
2053 COMPREPLY=()
2055 esac
2058 _git_replace ()
2060 __gitcomp_nl "$(__git_refs)"
2063 _git_reset ()
2065 __git_has_doubledash && return
2067 case "$cur" in
2068 --*)
2069 __gitcomp "--merge --mixed --hard --soft --patch"
2070 return
2072 esac
2073 __gitcomp_nl "$(__git_refs)"
2076 _git_revert ()
2078 case "$cur" in
2079 --*)
2080 __gitcomp "--edit --mainline --no-edit --no-commit --signoff"
2081 return
2083 esac
2084 __gitcomp_nl "$(__git_refs)"
2087 _git_rm ()
2089 __git_has_doubledash && return
2091 case "$cur" in
2092 --*)
2093 __gitcomp "--cached --dry-run --ignore-unmatch --quiet"
2094 return
2096 esac
2097 COMPREPLY=()
2100 _git_shortlog ()
2102 __git_has_doubledash && return
2104 case "$cur" in
2105 --*)
2106 __gitcomp "
2107 $__git_log_common_options
2108 $__git_log_shortlog_options
2109 --numbered --summary
2111 return
2113 esac
2114 __git_complete_revlist
2117 _git_show ()
2119 __git_has_doubledash && return
2121 case "$cur" in
2122 --pretty=*|--format=*)
2123 __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
2124 " "" "${cur#*=}"
2125 return
2127 --*)
2128 __gitcomp "--pretty= --format= --abbrev-commit --oneline
2129 $__git_diff_common_options
2131 return
2133 esac
2134 __git_complete_file
2137 _git_show_branch ()
2139 case "$cur" in
2140 --*)
2141 __gitcomp "
2142 --all --remotes --topo-order --current --more=
2143 --list --independent --merge-base --no-name
2144 --color --no-color
2145 --sha1-name --sparse --topics --reflog
2147 return
2149 esac
2150 __git_complete_revlist
2153 _git_stash ()
2155 local save_opts='--keep-index --no-keep-index --quiet --patch'
2156 local subcommands='save list show apply clear drop pop create branch'
2157 local subcommand="$(__git_find_on_cmdline "$subcommands")"
2158 if [ -z "$subcommand" ]; then
2159 case "$cur" in
2160 --*)
2161 __gitcomp "$save_opts"
2164 if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then
2165 __gitcomp "$subcommands"
2166 else
2167 COMPREPLY=()
2170 esac
2171 else
2172 case "$subcommand,$cur" in
2173 save,--*)
2174 __gitcomp "$save_opts"
2176 apply,--*|pop,--*)
2177 __gitcomp "--index --quiet"
2179 show,--*|drop,--*|branch,--*)
2180 COMPREPLY=()
2182 show,*|apply,*|drop,*|pop,*|branch,*)
2183 __gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \
2184 | sed -n -e 's/:.*//p')"
2187 COMPREPLY=()
2189 esac
2193 _git_submodule ()
2195 __git_has_doubledash && return
2197 local subcommands="add status init update summary foreach sync"
2198 if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then
2199 case "$cur" in
2200 --*)
2201 __gitcomp "--quiet --cached"
2204 __gitcomp "$subcommands"
2206 esac
2207 return
2211 _git_svn ()
2213 local subcommands="
2214 init fetch clone rebase dcommit log find-rev
2215 set-tree commit-diff info create-ignore propget
2216 proplist show-ignore show-externals branch tag blame
2217 migrate mkdirs reset gc
2219 local subcommand="$(__git_find_on_cmdline "$subcommands")"
2220 if [ -z "$subcommand" ]; then
2221 __gitcomp "$subcommands"
2222 else
2223 local remote_opts="--username= --config-dir= --no-auth-cache"
2224 local fc_opts="
2225 --follow-parent --authors-file= --repack=
2226 --no-metadata --use-svm-props --use-svnsync-props
2227 --log-window-size= --no-checkout --quiet
2228 --repack-flags --use-log-author --localtime
2229 --ignore-paths= $remote_opts
2231 local init_opts="
2232 --template= --shared= --trunk= --tags=
2233 --branches= --stdlayout --minimize-url
2234 --no-metadata --use-svm-props --use-svnsync-props
2235 --rewrite-root= --prefix= --use-log-author
2236 --add-author-from $remote_opts
2238 local cmt_opts="
2239 --edit --rmdir --find-copies-harder --copy-similarity=
2242 case "$subcommand,$cur" in
2243 fetch,--*)
2244 __gitcomp "--revision= --fetch-all $fc_opts"
2246 clone,--*)
2247 __gitcomp "--revision= $fc_opts $init_opts"
2249 init,--*)
2250 __gitcomp "$init_opts"
2252 dcommit,--*)
2253 __gitcomp "
2254 --merge --strategy= --verbose --dry-run
2255 --fetch-all --no-rebase --commit-url
2256 --revision --interactive $cmt_opts $fc_opts
2259 set-tree,--*)
2260 __gitcomp "--stdin $cmt_opts $fc_opts"
2262 create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\
2263 show-externals,--*|mkdirs,--*)
2264 __gitcomp "--revision="
2266 log,--*)
2267 __gitcomp "
2268 --limit= --revision= --verbose --incremental
2269 --oneline --show-commit --non-recursive
2270 --authors-file= --color
2273 rebase,--*)
2274 __gitcomp "
2275 --merge --verbose --strategy= --local
2276 --fetch-all --dry-run $fc_opts
2279 commit-diff,--*)
2280 __gitcomp "--message= --file= --revision= $cmt_opts"
2282 info,--*)
2283 __gitcomp "--url"
2285 branch,--*)
2286 __gitcomp "--dry-run --message --tag"
2288 tag,--*)
2289 __gitcomp "--dry-run --message"
2291 blame,--*)
2292 __gitcomp "--git-format"
2294 migrate,--*)
2295 __gitcomp "
2296 --config-dir= --ignore-paths= --minimize
2297 --no-auth-cache --username=
2300 reset,--*)
2301 __gitcomp "--revision= --parent"
2304 COMPREPLY=()
2306 esac
2310 _git_tag ()
2312 local i c=1 f=0
2313 while [ $c -lt $cword ]; do
2314 i="${words[c]}"
2315 case "$i" in
2316 -d|-v)
2317 __gitcomp_nl "$(__git_tags)"
2318 return
2323 esac
2324 ((c++))
2325 done
2327 case "$prev" in
2328 -m|-F)
2329 COMPREPLY=()
2331 -*|tag)
2332 if [ $f = 1 ]; then
2333 __gitcomp_nl "$(__git_tags)"
2334 else
2335 COMPREPLY=()
2339 __gitcomp_nl "$(__git_refs)"
2341 esac
2344 _git_whatchanged ()
2346 _git_log
2349 _git ()
2351 local i c=1 command __git_dir
2353 while [ $c -lt $cword ]; do
2354 i="${words[c]}"
2355 case "$i" in
2356 --git-dir=*) __git_dir="${i#--git-dir=}" ;;
2357 --bare) __git_dir="." ;;
2358 --help) command="help"; break ;;
2359 -c) c=$((++c)) ;;
2360 -*) ;;
2361 *) command="$i"; break ;;
2362 esac
2363 ((c++))
2364 done
2366 if [ -z "$command" ]; then
2367 case "$cur" in
2368 --*) __gitcomp "
2369 --paginate
2370 --no-pager
2371 --git-dir=
2372 --bare
2373 --version
2374 --exec-path
2375 --exec-path=
2376 --html-path
2377 --info-path
2378 --work-tree=
2379 --namespace=
2380 --no-replace-objects
2381 --help
2384 *) __git_compute_porcelain_commands
2385 __gitcomp "$__git_porcelain_commands $(__git_aliases)" ;;
2386 esac
2387 return
2390 local completion_func="_git_${command//-/_}"
2391 declare -f $completion_func >/dev/null && $completion_func && return
2393 local expansion=$(__git_aliased_command "$command")
2394 if [ -n "$expansion" ]; then
2395 completion_func="_git_${expansion//-/_}"
2396 declare -f $completion_func >/dev/null && $completion_func
2400 _gitk ()
2402 __git_has_doubledash && return
2404 local g="$(__gitdir)"
2405 local merge=""
2406 if [ -f "$g/MERGE_HEAD" ]; then
2407 merge="--merge"
2409 case "$cur" in
2410 --*)
2411 __gitcomp "
2412 $__git_log_common_options
2413 $__git_log_gitk_options
2414 $merge
2416 return
2418 esac
2419 __git_complete_revlist
2422 __git_func_wrap ()
2424 if [[ -n ${ZSH_VERSION-} ]]; then
2425 emulate -L bash
2426 setopt KSH_TYPESET
2428 # workaround zsh's bug that leaves 'words' as a special
2429 # variable in versions < 4.3.12
2430 typeset -h words
2432 # workaround zsh's bug that quotes spaces in the COMPREPLY
2433 # array if IFS doesn't contain spaces.
2434 typeset -h IFS
2436 local cur words cword prev
2437 _get_comp_words_by_ref -n =: cur words cword prev
2441 # Setup completion for certain functions defined above by setting common
2442 # variables and workarounds.
2443 # This is NOT a public function; use at your own risk.
2444 __git_complete ()
2446 local wrapper="__git_wrap${2}"
2447 eval "$wrapper () { __git_func_wrap $2 ; }"
2448 complete -o bashdefault -o default -o nospace -F $wrapper $1 2>/dev/null \
2449 || complete -o default -o nospace -F $wrapper $1
2452 __git_complete git _git
2453 __git_complete gitk _gitk
2455 # The following are necessary only for Cygwin, and only are needed
2456 # when the user has tab-completed the executable name and consequently
2457 # included the '.exe' suffix.
2459 if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
2460 __git_complete git.exe _git