Merge branch 'as/check-ignore'
[git.git] / contrib / completion / git-completion.bash
blob7147d64af20f8db8daa65958d68adb0802605303
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 case "$COMP_WORDBREAKS" in
27 *:*) : great ;;
28 *) COMP_WORDBREAKS="$COMP_WORDBREAKS:"
29 esac
31 # __gitdir accepts 0 or 1 arguments (i.e., location)
32 # returns location of .git repo
33 __gitdir ()
35 # Note: this function is duplicated in git-prompt.sh
36 # When updating it, make sure you update the other one to match.
37 if [ -z "${1-}" ]; then
38 if [ -n "${__git_dir-}" ]; then
39 echo "$__git_dir"
40 elif [ -n "${GIT_DIR-}" ]; then
41 test -d "${GIT_DIR-}" || return 1
42 echo "$GIT_DIR"
43 elif [ -d .git ]; then
44 echo .git
45 else
46 git rev-parse --git-dir 2>/dev/null
48 elif [ -d "$1/.git" ]; then
49 echo "$1/.git"
50 else
51 echo "$1"
55 __gitcomp_1 ()
57 local c IFS=$' \t\n'
58 for c in $1; do
59 c="$c$2"
60 case $c in
61 --*=*|*.) ;;
62 *) c="$c " ;;
63 esac
64 printf '%s\n' "$c"
65 done
68 # The following function is based on code from:
70 # bash_completion - programmable completion functions for bash 3.2+
72 # Copyright © 2006-2008, Ian Macdonald <ian@caliban.org>
73 # © 2009-2010, Bash Completion Maintainers
74 # <bash-completion-devel@lists.alioth.debian.org>
76 # This program is free software; you can redistribute it and/or modify
77 # it under the terms of the GNU General Public License as published by
78 # the Free Software Foundation; either version 2, or (at your option)
79 # any later version.
81 # This program is distributed in the hope that it will be useful,
82 # but WITHOUT ANY WARRANTY; without even the implied warranty of
83 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
84 # GNU General Public License for more details.
86 # You should have received a copy of the GNU General Public License
87 # along with this program; if not, write to the Free Software Foundation,
88 # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
90 # The latest version of this software can be obtained here:
92 # http://bash-completion.alioth.debian.org/
94 # RELEASE: 2.x
96 # This function can be used to access a tokenized list of words
97 # on the command line:
99 # __git_reassemble_comp_words_by_ref '=:'
100 # if test "${words_[cword_-1]}" = -w
101 # then
102 # ...
103 # fi
105 # The argument should be a collection of characters from the list of
106 # word completion separators (COMP_WORDBREAKS) to treat as ordinary
107 # characters.
109 # This is roughly equivalent to going back in time and setting
110 # COMP_WORDBREAKS to exclude those characters. The intent is to
111 # make option types like --date=<type> and <rev>:<path> easy to
112 # recognize by treating each shell word as a single token.
114 # It is best not to set COMP_WORDBREAKS directly because the value is
115 # shared with other completion scripts. By the time the completion
116 # function gets called, COMP_WORDS has already been populated so local
117 # changes to COMP_WORDBREAKS have no effect.
119 # Output: words_, cword_, cur_.
121 __git_reassemble_comp_words_by_ref()
123 local exclude i j first
124 # Which word separators to exclude?
125 exclude="${1//[^$COMP_WORDBREAKS]}"
126 cword_=$COMP_CWORD
127 if [ -z "$exclude" ]; then
128 words_=("${COMP_WORDS[@]}")
129 return
131 # List of word completion separators has shrunk;
132 # re-assemble words to complete.
133 for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)); do
134 # Append each nonempty word consisting of just
135 # word separator characters to the current word.
136 first=t
137 while
138 [ $i -gt 0 ] &&
139 [ -n "${COMP_WORDS[$i]}" ] &&
140 # word consists of excluded word separators
141 [ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ]
143 # Attach to the previous token,
144 # unless the previous token is the command name.
145 if [ $j -ge 2 ] && [ -n "$first" ]; then
146 ((j--))
148 first=
149 words_[$j]=${words_[j]}${COMP_WORDS[i]}
150 if [ $i = $COMP_CWORD ]; then
151 cword_=$j
153 if (($i < ${#COMP_WORDS[@]} - 1)); then
154 ((i++))
155 else
156 # Done.
157 return
159 done
160 words_[$j]=${words_[j]}${COMP_WORDS[i]}
161 if [ $i = $COMP_CWORD ]; then
162 cword_=$j
164 done
167 if ! type _get_comp_words_by_ref >/dev/null 2>&1; 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
197 # Generates completion reply with compgen, appending a space to possible
198 # completion words, if necessary.
199 # It accepts 1 to 4 arguments:
200 # 1: List of possible completion words.
201 # 2: A prefix to be added to each possible completion word (optional).
202 # 3: Generate possible completion matches for this word (optional).
203 # 4: A suffix to be appended to each possible completion word (optional).
204 __gitcomp ()
206 local cur_="${3-$cur}"
208 case "$cur_" in
209 --*=)
210 COMPREPLY=()
213 local IFS=$'\n'
214 COMPREPLY=($(compgen -P "${2-}" \
215 -W "$(__gitcomp_1 "${1-}" "${4-}")" \
216 -- "$cur_"))
218 esac
221 # Generates completion reply with compgen from newline-separated possible
222 # completion words by appending a space to all of them.
223 # It accepts 1 to 4 arguments:
224 # 1: List of possible completion words, separated by a single newline.
225 # 2: A prefix to be added to each possible completion word (optional).
226 # 3: Generate possible completion matches for this word (optional).
227 # 4: A suffix to be appended to each possible completion word instead of
228 # the default space (optional). If specified but empty, nothing is
229 # appended.
230 __gitcomp_nl ()
232 local IFS=$'\n'
233 COMPREPLY=($(compgen -P "${2-}" -S "${4- }" -W "$1" -- "${3-$cur}"))
236 __git_heads ()
238 local dir="$(__gitdir)"
239 if [ -d "$dir" ]; then
240 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
241 refs/heads
242 return
246 __git_tags ()
248 local dir="$(__gitdir)"
249 if [ -d "$dir" ]; then
250 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
251 refs/tags
252 return
256 # __git_refs accepts 0, 1 (to pass to __gitdir), or 2 arguments
257 # presence of 2nd argument means use the guess heuristic employed
258 # by checkout for tracking branches
259 __git_refs ()
261 local i hash dir="$(__gitdir "${1-}")" track="${2-}"
262 local format refs
263 if [ -d "$dir" ]; then
264 case "$cur" in
265 refs|refs/*)
266 format="refname"
267 refs="${cur%/*}"
268 track=""
271 for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do
272 if [ -e "$dir/$i" ]; then echo $i; fi
273 done
274 format="refname:short"
275 refs="refs/tags refs/heads refs/remotes"
277 esac
278 git --git-dir="$dir" for-each-ref --format="%($format)" \
279 $refs
280 if [ -n "$track" ]; then
281 # employ the heuristic used by git checkout
282 # Try to find a remote branch that matches the completion word
283 # but only output if the branch name is unique
284 local ref entry
285 git --git-dir="$dir" for-each-ref --shell --format="ref=%(refname:short)" \
286 "refs/remotes/" | \
287 while read -r entry; do
288 eval "$entry"
289 ref="${ref#*/}"
290 if [[ "$ref" == "$cur"* ]]; then
291 echo "$ref"
293 done | sort | uniq -u
295 return
297 case "$cur" in
298 refs|refs/*)
299 git ls-remote "$dir" "$cur*" 2>/dev/null | \
300 while read -r hash i; do
301 case "$i" in
302 *^{}) ;;
303 *) echo "$i" ;;
304 esac
305 done
308 git ls-remote "$dir" HEAD ORIG_HEAD 'refs/tags/*' 'refs/heads/*' 'refs/remotes/*' 2>/dev/null | \
309 while read -r hash i; do
310 case "$i" in
311 *^{}) ;;
312 refs/*) echo "${i#refs/*/}" ;;
313 *) echo "$i" ;;
314 esac
315 done
317 esac
320 # __git_refs2 requires 1 argument (to pass to __git_refs)
321 __git_refs2 ()
323 local i
324 for i in $(__git_refs "$1"); do
325 echo "$i:$i"
326 done
329 # __git_refs_remotes requires 1 argument (to pass to ls-remote)
330 __git_refs_remotes ()
332 local i hash
333 git ls-remote "$1" 'refs/heads/*' 2>/dev/null | \
334 while read -r hash i; do
335 echo "$i:refs/remotes/$1/${i#refs/heads/}"
336 done
339 __git_remotes ()
341 local i IFS=$'\n' d="$(__gitdir)"
342 test -d "$d/remotes" && ls -1 "$d/remotes"
343 for i in $(git --git-dir="$d" config --get-regexp 'remote\..*\.url' 2>/dev/null); do
344 i="${i#remote.}"
345 echo "${i/.url*/}"
346 done
349 __git_list_merge_strategies ()
351 git merge -s help 2>&1 |
352 sed -n -e '/[Aa]vailable strategies are: /,/^$/{
353 s/\.$//
354 s/.*://
355 s/^[ ]*//
356 s/[ ]*$//
361 __git_merge_strategies=
362 # 'git merge -s help' (and thus detection of the merge strategy
363 # list) fails, unfortunately, if run outside of any git working
364 # tree. __git_merge_strategies is set to the empty string in
365 # that case, and the detection will be repeated the next time it
366 # is needed.
367 __git_compute_merge_strategies ()
369 test -n "$__git_merge_strategies" ||
370 __git_merge_strategies=$(__git_list_merge_strategies)
373 __git_complete_revlist_file ()
375 local pfx ls ref cur_="$cur"
376 case "$cur_" in
377 *..?*:*)
378 return
380 ?*:*)
381 ref="${cur_%%:*}"
382 cur_="${cur_#*:}"
383 case "$cur_" in
384 ?*/*)
385 pfx="${cur_%/*}"
386 cur_="${cur_##*/}"
387 ls="$ref:$pfx"
388 pfx="$pfx/"
391 ls="$ref"
393 esac
395 case "$COMP_WORDBREAKS" in
396 *:*) : great ;;
397 *) pfx="$ref:$pfx" ;;
398 esac
400 __gitcomp_nl "$(git --git-dir="$(__gitdir)" ls-tree "$ls" 2>/dev/null \
401 | sed '/^100... blob /{
402 s,^.* ,,
403 s,$, ,
405 /^120000 blob /{
406 s,^.* ,,
407 s,$, ,
409 /^040000 tree /{
410 s,^.* ,,
411 s,$,/,
413 s/^.* //')" \
414 "$pfx" "$cur_" ""
416 *...*)
417 pfx="${cur_%...*}..."
418 cur_="${cur_#*...}"
419 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
421 *..*)
422 pfx="${cur_%..*}.."
423 cur_="${cur_#*..}"
424 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
427 __gitcomp_nl "$(__git_refs)"
429 esac
433 __git_complete_file ()
435 __git_complete_revlist_file
438 __git_complete_revlist ()
440 __git_complete_revlist_file
443 __git_complete_remote_or_refspec ()
445 local cur_="$cur" cmd="${words[1]}"
446 local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0
447 if [ "$cmd" = "remote" ]; then
448 ((c++))
450 while [ $c -lt $cword ]; do
451 i="${words[c]}"
452 case "$i" in
453 --mirror) [ "$cmd" = "push" ] && no_complete_refspec=1 ;;
454 --all)
455 case "$cmd" in
456 push) no_complete_refspec=1 ;;
457 fetch)
458 COMPREPLY=()
459 return
461 *) ;;
462 esac
464 -*) ;;
465 *) remote="$i"; break ;;
466 esac
467 ((c++))
468 done
469 if [ -z "$remote" ]; then
470 __gitcomp_nl "$(__git_remotes)"
471 return
473 if [ $no_complete_refspec = 1 ]; then
474 COMPREPLY=()
475 return
477 [ "$remote" = "." ] && remote=
478 case "$cur_" in
479 *:*)
480 case "$COMP_WORDBREAKS" in
481 *:*) : great ;;
482 *) pfx="${cur_%%:*}:" ;;
483 esac
484 cur_="${cur_#*:}"
485 lhs=0
488 pfx="+"
489 cur_="${cur_#+}"
491 esac
492 case "$cmd" in
493 fetch)
494 if [ $lhs = 1 ]; then
495 __gitcomp_nl "$(__git_refs2 "$remote")" "$pfx" "$cur_"
496 else
497 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
500 pull|remote)
501 if [ $lhs = 1 ]; then
502 __gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_"
503 else
504 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
507 push)
508 if [ $lhs = 1 ]; then
509 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
510 else
511 __gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_"
514 esac
517 __git_complete_strategy ()
519 __git_compute_merge_strategies
520 case "$prev" in
521 -s|--strategy)
522 __gitcomp "$__git_merge_strategies"
523 return 0
524 esac
525 case "$cur" in
526 --strategy=*)
527 __gitcomp "$__git_merge_strategies" "" "${cur##--strategy=}"
528 return 0
530 esac
531 return 1
534 __git_list_all_commands ()
536 local i IFS=" "$'\n'
537 for i in $(git help -a|egrep '^ [a-zA-Z0-9]')
539 case $i in
540 *--*) : helper pattern;;
541 *) echo $i;;
542 esac
543 done
546 __git_all_commands=
547 __git_compute_all_commands ()
549 test -n "$__git_all_commands" ||
550 __git_all_commands=$(__git_list_all_commands)
553 __git_list_porcelain_commands ()
555 local i IFS=" "$'\n'
556 __git_compute_all_commands
557 for i in $__git_all_commands
559 case $i in
560 *--*) : helper pattern;;
561 applymbox) : ask gittus;;
562 applypatch) : ask gittus;;
563 archimport) : import;;
564 cat-file) : plumbing;;
565 check-attr) : plumbing;;
566 check-ignore) : plumbing;;
567 check-ref-format) : plumbing;;
568 checkout-index) : plumbing;;
569 commit-tree) : plumbing;;
570 count-objects) : infrequent;;
571 credential-cache) : credentials helper;;
572 credential-store) : credentials helper;;
573 cvsexportcommit) : export;;
574 cvsimport) : import;;
575 cvsserver) : daemon;;
576 daemon) : daemon;;
577 diff-files) : plumbing;;
578 diff-index) : plumbing;;
579 diff-tree) : plumbing;;
580 fast-import) : import;;
581 fast-export) : export;;
582 fsck-objects) : plumbing;;
583 fetch-pack) : plumbing;;
584 fmt-merge-msg) : plumbing;;
585 for-each-ref) : plumbing;;
586 hash-object) : plumbing;;
587 http-*) : transport;;
588 index-pack) : plumbing;;
589 init-db) : deprecated;;
590 local-fetch) : plumbing;;
591 lost-found) : infrequent;;
592 ls-files) : plumbing;;
593 ls-remote) : plumbing;;
594 ls-tree) : plumbing;;
595 mailinfo) : plumbing;;
596 mailsplit) : plumbing;;
597 merge-*) : plumbing;;
598 mktree) : plumbing;;
599 mktag) : plumbing;;
600 pack-objects) : plumbing;;
601 pack-redundant) : plumbing;;
602 pack-refs) : plumbing;;
603 parse-remote) : plumbing;;
604 patch-id) : plumbing;;
605 peek-remote) : plumbing;;
606 prune) : plumbing;;
607 prune-packed) : plumbing;;
608 quiltimport) : import;;
609 read-tree) : plumbing;;
610 receive-pack) : plumbing;;
611 remote-*) : transport;;
612 repo-config) : deprecated;;
613 rerere) : plumbing;;
614 rev-list) : plumbing;;
615 rev-parse) : plumbing;;
616 runstatus) : plumbing;;
617 sh-setup) : internal;;
618 shell) : daemon;;
619 show-ref) : plumbing;;
620 send-pack) : plumbing;;
621 show-index) : plumbing;;
622 ssh-*) : transport;;
623 stripspace) : plumbing;;
624 symbolic-ref) : plumbing;;
625 tar-tree) : deprecated;;
626 unpack-file) : plumbing;;
627 unpack-objects) : plumbing;;
628 update-index) : plumbing;;
629 update-ref) : plumbing;;
630 update-server-info) : daemon;;
631 upload-archive) : plumbing;;
632 upload-pack) : plumbing;;
633 write-tree) : plumbing;;
634 var) : infrequent;;
635 verify-pack) : infrequent;;
636 verify-tag) : plumbing;;
637 *) echo $i;;
638 esac
639 done
642 __git_porcelain_commands=
643 __git_compute_porcelain_commands ()
645 __git_compute_all_commands
646 test -n "$__git_porcelain_commands" ||
647 __git_porcelain_commands=$(__git_list_porcelain_commands)
650 __git_pretty_aliases ()
652 local i IFS=$'\n'
653 for i in $(git --git-dir="$(__gitdir)" config --get-regexp "pretty\..*" 2>/dev/null); do
654 case "$i" in
655 pretty.*)
656 i="${i#pretty.}"
657 echo "${i/ */}"
659 esac
660 done
663 __git_aliases ()
665 local i IFS=$'\n'
666 for i in $(git --git-dir="$(__gitdir)" config --get-regexp "alias\..*" 2>/dev/null); do
667 case "$i" in
668 alias.*)
669 i="${i#alias.}"
670 echo "${i/ */}"
672 esac
673 done
676 # __git_aliased_command requires 1 argument
677 __git_aliased_command ()
679 local word cmdline=$(git --git-dir="$(__gitdir)" \
680 config --get "alias.$1")
681 for word in $cmdline; do
682 case "$word" in
683 \!gitk|gitk)
684 echo "gitk"
685 return
687 \!*) : shell command alias ;;
688 -*) : option ;;
689 *=*) : setting env ;;
690 git) : git itself ;;
692 echo "$word"
693 return
694 esac
695 done
698 # __git_find_on_cmdline requires 1 argument
699 __git_find_on_cmdline ()
701 local word subcommand c=1
702 while [ $c -lt $cword ]; do
703 word="${words[c]}"
704 for subcommand in $1; do
705 if [ "$subcommand" = "$word" ]; then
706 echo "$subcommand"
707 return
709 done
710 ((c++))
711 done
714 __git_has_doubledash ()
716 local c=1
717 while [ $c -lt $cword ]; do
718 if [ "--" = "${words[c]}" ]; then
719 return 0
721 ((c++))
722 done
723 return 1
726 __git_whitespacelist="nowarn warn error error-all fix"
728 _git_am ()
730 local dir="$(__gitdir)"
731 if [ -d "$dir"/rebase-apply ]; then
732 __gitcomp "--skip --continue --resolved --abort"
733 return
735 case "$cur" in
736 --whitespace=*)
737 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
738 return
740 --*)
741 __gitcomp "
742 --3way --committer-date-is-author-date --ignore-date
743 --ignore-whitespace --ignore-space-change
744 --interactive --keep --no-utf8 --signoff --utf8
745 --whitespace= --scissors
747 return
748 esac
749 COMPREPLY=()
752 _git_apply ()
754 case "$cur" in
755 --whitespace=*)
756 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
757 return
759 --*)
760 __gitcomp "
761 --stat --numstat --summary --check --index
762 --cached --index-info --reverse --reject --unidiff-zero
763 --apply --no-add --exclude=
764 --ignore-whitespace --ignore-space-change
765 --whitespace= --inaccurate-eof --verbose
767 return
768 esac
769 COMPREPLY=()
772 _git_add ()
774 __git_has_doubledash && return
776 case "$cur" in
777 --*)
778 __gitcomp "
779 --interactive --refresh --patch --update --dry-run
780 --ignore-errors --intent-to-add
782 return
783 esac
784 COMPREPLY=()
787 _git_archive ()
789 case "$cur" in
790 --format=*)
791 __gitcomp "$(git archive --list)" "" "${cur##--format=}"
792 return
794 --remote=*)
795 __gitcomp_nl "$(__git_remotes)" "" "${cur##--remote=}"
796 return
798 --*)
799 __gitcomp "
800 --format= --list --verbose
801 --prefix= --remote= --exec=
803 return
805 esac
806 __git_complete_file
809 _git_bisect ()
811 __git_has_doubledash && return
813 local subcommands="start bad good skip reset visualize replay log run"
814 local subcommand="$(__git_find_on_cmdline "$subcommands")"
815 if [ -z "$subcommand" ]; then
816 if [ -f "$(__gitdir)"/BISECT_START ]; then
817 __gitcomp "$subcommands"
818 else
819 __gitcomp "replay start"
821 return
824 case "$subcommand" in
825 bad|good|reset|skip|start)
826 __gitcomp_nl "$(__git_refs)"
829 COMPREPLY=()
831 esac
834 _git_branch ()
836 local i c=1 only_local_ref="n" has_r="n"
838 while [ $c -lt $cword ]; do
839 i="${words[c]}"
840 case "$i" in
841 -d|-m) only_local_ref="y" ;;
842 -r) has_r="y" ;;
843 esac
844 ((c++))
845 done
847 case "$cur" in
848 --set-upstream-to=*)
849 __gitcomp "$(__git_refs)" "" "${cur##--set-upstream-to=}"
851 --*)
852 __gitcomp "
853 --color --no-color --verbose --abbrev= --no-abbrev
854 --track --no-track --contains --merged --no-merged
855 --set-upstream-to= --edit-description --list
856 --unset-upstream
860 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
861 __gitcomp_nl "$(__git_heads)"
862 else
863 __gitcomp_nl "$(__git_refs)"
866 esac
869 _git_bundle ()
871 local cmd="${words[2]}"
872 case "$cword" in
874 __gitcomp "create list-heads verify unbundle"
877 # looking for a file
880 case "$cmd" in
881 create)
882 __git_complete_revlist
884 esac
886 esac
889 _git_checkout ()
891 __git_has_doubledash && return
893 case "$cur" in
894 --conflict=*)
895 __gitcomp "diff3 merge" "" "${cur##--conflict=}"
897 --*)
898 __gitcomp "
899 --quiet --ours --theirs --track --no-track --merge
900 --conflict= --orphan --patch
904 # check if --track, --no-track, or --no-guess was specified
905 # if so, disable DWIM mode
906 local flags="--track --no-track --no-guess" track=1
907 if [ -n "$(__git_find_on_cmdline "$flags")" ]; then
908 track=''
910 __gitcomp_nl "$(__git_refs '' $track)"
912 esac
915 _git_cherry ()
917 __gitcomp "$(__git_refs)"
920 _git_cherry_pick ()
922 case "$cur" in
923 --*)
924 __gitcomp "--edit --no-commit"
927 __gitcomp_nl "$(__git_refs)"
929 esac
932 _git_clean ()
934 __git_has_doubledash && return
936 case "$cur" in
937 --*)
938 __gitcomp "--dry-run --quiet"
939 return
941 esac
942 COMPREPLY=()
945 _git_clone ()
947 case "$cur" in
948 --*)
949 __gitcomp "
950 --local
951 --no-hardlinks
952 --shared
953 --reference
954 --quiet
955 --no-checkout
956 --bare
957 --mirror
958 --origin
959 --upload-pack
960 --template=
961 --depth
962 --single-branch
963 --branch
965 return
967 esac
968 COMPREPLY=()
971 _git_commit ()
973 __git_has_doubledash && return
975 case "$prev" in
976 -c|-C)
977 __gitcomp_nl "$(__git_refs)" "" "${cur}"
978 return
980 esac
982 case "$cur" in
983 --cleanup=*)
984 __gitcomp "default strip verbatim whitespace
985 " "" "${cur##--cleanup=}"
986 return
988 --reuse-message=*|--reedit-message=*|\
989 --fixup=*|--squash=*)
990 __gitcomp_nl "$(__git_refs)" "" "${cur#*=}"
991 return
993 --untracked-files=*)
994 __gitcomp "all no normal" "" "${cur##--untracked-files=}"
995 return
997 --*)
998 __gitcomp "
999 --all --author= --signoff --verify --no-verify
1000 --edit --no-edit
1001 --amend --include --only --interactive
1002 --dry-run --reuse-message= --reedit-message=
1003 --reset-author --file= --message= --template=
1004 --cleanup= --untracked-files --untracked-files=
1005 --verbose --quiet --fixup= --squash=
1007 return
1008 esac
1009 COMPREPLY=()
1012 _git_describe ()
1014 case "$cur" in
1015 --*)
1016 __gitcomp "
1017 --all --tags --contains --abbrev= --candidates=
1018 --exact-match --debug --long --match --always
1020 return
1021 esac
1022 __gitcomp_nl "$(__git_refs)"
1025 __git_diff_common_options="--stat --numstat --shortstat --summary
1026 --patch-with-stat --name-only --name-status --color
1027 --no-color --color-words --no-renames --check
1028 --full-index --binary --abbrev --diff-filter=
1029 --find-copies-harder
1030 --text --ignore-space-at-eol --ignore-space-change
1031 --ignore-all-space --exit-code --quiet --ext-diff
1032 --no-ext-diff
1033 --no-prefix --src-prefix= --dst-prefix=
1034 --inter-hunk-context=
1035 --patience
1036 --raw
1037 --dirstat --dirstat= --dirstat-by-file
1038 --dirstat-by-file= --cumulative
1041 _git_diff ()
1043 __git_has_doubledash && return
1045 case "$cur" in
1046 --*)
1047 __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
1048 --base --ours --theirs --no-index
1049 $__git_diff_common_options
1051 return
1053 esac
1054 __git_complete_revlist_file
1057 __git_mergetools_common="diffuse ecmerge emerge kdiff3 meld opendiff
1058 tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc3 codecompare
1061 _git_difftool ()
1063 __git_has_doubledash && return
1065 case "$cur" in
1066 --tool=*)
1067 __gitcomp "$__git_mergetools_common kompare" "" "${cur##--tool=}"
1068 return
1070 --*)
1071 __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
1072 --base --ours --theirs
1073 --no-renames --diff-filter= --find-copies-harder
1074 --relative --ignore-submodules
1075 --tool="
1076 return
1078 esac
1079 __git_complete_file
1082 __git_fetch_options="
1083 --quiet --verbose --append --upload-pack --force --keep --depth=
1084 --tags --no-tags --all --prune --dry-run
1087 _git_fetch ()
1089 case "$cur" in
1090 --*)
1091 __gitcomp "$__git_fetch_options"
1092 return
1094 esac
1095 __git_complete_remote_or_refspec
1098 __git_format_patch_options="
1099 --stdout --attach --no-attach --thread --thread= --output-directory
1100 --numbered --start-number --numbered-files --keep-subject --signoff
1101 --signature --no-signature --in-reply-to= --cc= --full-index --binary
1102 --not --all --cover-letter --no-prefix --src-prefix= --dst-prefix=
1103 --inline --suffix= --ignore-if-in-upstream --subject-prefix=
1106 _git_format_patch ()
1108 case "$cur" in
1109 --thread=*)
1110 __gitcomp "
1111 deep shallow
1112 " "" "${cur##--thread=}"
1113 return
1115 --*)
1116 __gitcomp "$__git_format_patch_options"
1117 return
1119 esac
1120 __git_complete_revlist
1123 _git_fsck ()
1125 case "$cur" in
1126 --*)
1127 __gitcomp "
1128 --tags --root --unreachable --cache --no-reflogs --full
1129 --strict --verbose --lost-found
1131 return
1133 esac
1134 COMPREPLY=()
1137 _git_gc ()
1139 case "$cur" in
1140 --*)
1141 __gitcomp "--prune --aggressive"
1142 return
1144 esac
1145 COMPREPLY=()
1148 _git_gitk ()
1150 _gitk
1153 __git_match_ctag() {
1154 awk "/^${1////\\/}/ { print \$1 }" "$2"
1157 _git_grep ()
1159 __git_has_doubledash && return
1161 case "$cur" in
1162 --*)
1163 __gitcomp "
1164 --cached
1165 --text --ignore-case --word-regexp --invert-match
1166 --full-name --line-number
1167 --extended-regexp --basic-regexp --fixed-strings
1168 --perl-regexp
1169 --files-with-matches --name-only
1170 --files-without-match
1171 --max-depth
1172 --count
1173 --and --or --not --all-match
1175 return
1177 esac
1179 case "$cword,$prev" in
1180 2,*|*,-*)
1181 if test -r tags; then
1182 __gitcomp_nl "$(__git_match_ctag "$cur" tags)"
1183 return
1186 esac
1188 __gitcomp_nl "$(__git_refs)"
1191 _git_help ()
1193 case "$cur" in
1194 --*)
1195 __gitcomp "--all --info --man --web"
1196 return
1198 esac
1199 __git_compute_all_commands
1200 __gitcomp "$__git_all_commands $(__git_aliases)
1201 attributes cli core-tutorial cvs-migration
1202 diffcore gitk glossary hooks ignore modules
1203 namespaces repository-layout tutorial tutorial-2
1204 workflows
1208 _git_init ()
1210 case "$cur" in
1211 --shared=*)
1212 __gitcomp "
1213 false true umask group all world everybody
1214 " "" "${cur##--shared=}"
1215 return
1217 --*)
1218 __gitcomp "--quiet --bare --template= --shared --shared="
1219 return
1221 esac
1222 COMPREPLY=()
1225 _git_ls_files ()
1227 __git_has_doubledash && return
1229 case "$cur" in
1230 --*)
1231 __gitcomp "--cached --deleted --modified --others --ignored
1232 --stage --directory --no-empty-directory --unmerged
1233 --killed --exclude= --exclude-from=
1234 --exclude-per-directory= --exclude-standard
1235 --error-unmatch --with-tree= --full-name
1236 --abbrev --ignored --exclude-per-directory
1238 return
1240 esac
1241 COMPREPLY=()
1244 _git_ls_remote ()
1246 __gitcomp_nl "$(__git_remotes)"
1249 _git_ls_tree ()
1251 __git_complete_file
1254 # Options that go well for log, shortlog and gitk
1255 __git_log_common_options="
1256 --not --all
1257 --branches --tags --remotes
1258 --first-parent --merges --no-merges
1259 --max-count=
1260 --max-age= --since= --after=
1261 --min-age= --until= --before=
1262 --min-parents= --max-parents=
1263 --no-min-parents --no-max-parents
1265 # Options that go well for log and gitk (not shortlog)
1266 __git_log_gitk_options="
1267 --dense --sparse --full-history
1268 --simplify-merges --simplify-by-decoration
1269 --left-right --notes --no-notes
1271 # Options that go well for log and shortlog (not gitk)
1272 __git_log_shortlog_options="
1273 --author= --committer= --grep=
1274 --all-match
1277 __git_log_pretty_formats="oneline short medium full fuller email raw format:"
1278 __git_log_date_formats="relative iso8601 rfc2822 short local default raw"
1280 _git_log ()
1282 __git_has_doubledash && return
1284 local g="$(git rev-parse --git-dir 2>/dev/null)"
1285 local merge=""
1286 if [ -f "$g/MERGE_HEAD" ]; then
1287 merge="--merge"
1289 case "$cur" in
1290 --pretty=*|--format=*)
1291 __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
1292 " "" "${cur#*=}"
1293 return
1295 --date=*)
1296 __gitcomp "$__git_log_date_formats" "" "${cur##--date=}"
1297 return
1299 --decorate=*)
1300 __gitcomp "long short" "" "${cur##--decorate=}"
1301 return
1303 --*)
1304 __gitcomp "
1305 $__git_log_common_options
1306 $__git_log_shortlog_options
1307 $__git_log_gitk_options
1308 --root --topo-order --date-order --reverse
1309 --follow --full-diff
1310 --abbrev-commit --abbrev=
1311 --relative-date --date=
1312 --pretty= --format= --oneline
1313 --cherry-pick
1314 --graph
1315 --decorate --decorate=
1316 --walk-reflogs
1317 --parents --children
1318 $merge
1319 $__git_diff_common_options
1320 --pickaxe-all --pickaxe-regex
1322 return
1324 esac
1325 __git_complete_revlist
1328 __git_merge_options="
1329 --no-commit --no-stat --log --no-log --squash --strategy
1330 --commit --stat --no-squash --ff --no-ff --ff-only --edit --no-edit
1333 _git_merge ()
1335 __git_complete_strategy && return
1337 case "$cur" in
1338 --*)
1339 __gitcomp "$__git_merge_options"
1340 return
1341 esac
1342 __gitcomp_nl "$(__git_refs)"
1345 _git_mergetool ()
1347 case "$cur" in
1348 --tool=*)
1349 __gitcomp "$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"
1350 return
1352 --*)
1353 __gitcomp "--tool="
1354 return
1356 esac
1357 COMPREPLY=()
1360 _git_merge_base ()
1362 __gitcomp_nl "$(__git_refs)"
1365 _git_mv ()
1367 case "$cur" in
1368 --*)
1369 __gitcomp "--dry-run"
1370 return
1372 esac
1373 COMPREPLY=()
1376 _git_name_rev ()
1378 __gitcomp "--tags --all --stdin"
1381 _git_notes ()
1383 local subcommands='add append copy edit list prune remove show'
1384 local subcommand="$(__git_find_on_cmdline "$subcommands")"
1386 case "$subcommand,$cur" in
1387 ,--*)
1388 __gitcomp '--ref'
1391 case "$prev" in
1392 --ref)
1393 __gitcomp_nl "$(__git_refs)"
1396 __gitcomp "$subcommands --ref"
1398 esac
1400 add,--reuse-message=*|append,--reuse-message=*|\
1401 add,--reedit-message=*|append,--reedit-message=*)
1402 __gitcomp_nl "$(__git_refs)" "" "${cur#*=}"
1404 add,--*|append,--*)
1405 __gitcomp '--file= --message= --reedit-message=
1406 --reuse-message='
1408 copy,--*)
1409 __gitcomp '--stdin'
1411 prune,--*)
1412 __gitcomp '--dry-run --verbose'
1414 prune,*)
1417 case "$prev" in
1418 -m|-F)
1421 __gitcomp_nl "$(__git_refs)"
1423 esac
1425 esac
1428 _git_pull ()
1430 __git_complete_strategy && return
1432 case "$cur" in
1433 --*)
1434 __gitcomp "
1435 --rebase --no-rebase
1436 $__git_merge_options
1437 $__git_fetch_options
1439 return
1441 esac
1442 __git_complete_remote_or_refspec
1445 _git_push ()
1447 case "$prev" in
1448 --repo)
1449 __gitcomp_nl "$(__git_remotes)"
1450 return
1451 esac
1452 case "$cur" in
1453 --repo=*)
1454 __gitcomp_nl "$(__git_remotes)" "" "${cur##--repo=}"
1455 return
1457 --*)
1458 __gitcomp "
1459 --all --mirror --tags --dry-run --force --verbose
1460 --receive-pack= --repo= --set-upstream
1462 return
1464 esac
1465 __git_complete_remote_or_refspec
1468 _git_rebase ()
1470 local dir="$(__gitdir)"
1471 if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
1472 __gitcomp "--continue --skip --abort"
1473 return
1475 __git_complete_strategy && return
1476 case "$cur" in
1477 --whitespace=*)
1478 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
1479 return
1481 --*)
1482 __gitcomp "
1483 --onto --merge --strategy --interactive
1484 --preserve-merges --stat --no-stat
1485 --committer-date-is-author-date --ignore-date
1486 --ignore-whitespace --whitespace=
1487 --autosquash
1490 return
1491 esac
1492 __gitcomp_nl "$(__git_refs)"
1495 _git_reflog ()
1497 local subcommands="show delete expire"
1498 local subcommand="$(__git_find_on_cmdline "$subcommands")"
1500 if [ -z "$subcommand" ]; then
1501 __gitcomp "$subcommands"
1502 else
1503 __gitcomp_nl "$(__git_refs)"
1507 __git_send_email_confirm_options="always never auto cc compose"
1508 __git_send_email_suppresscc_options="author self cc bodycc sob cccmd body all"
1510 _git_send_email ()
1512 case "$cur" in
1513 --confirm=*)
1514 __gitcomp "
1515 $__git_send_email_confirm_options
1516 " "" "${cur##--confirm=}"
1517 return
1519 --suppress-cc=*)
1520 __gitcomp "
1521 $__git_send_email_suppresscc_options
1522 " "" "${cur##--suppress-cc=}"
1524 return
1526 --smtp-encryption=*)
1527 __gitcomp "ssl tls" "" "${cur##--smtp-encryption=}"
1528 return
1530 --thread=*)
1531 __gitcomp "
1532 deep shallow
1533 " "" "${cur##--thread=}"
1534 return
1536 --*)
1537 __gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to
1538 --compose --confirm= --dry-run --envelope-sender
1539 --from --identity
1540 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
1541 --no-suppress-from --no-thread --quiet
1542 --signed-off-by-cc --smtp-pass --smtp-server
1543 --smtp-server-port --smtp-encryption= --smtp-user
1544 --subject --suppress-cc= --suppress-from --thread --to
1545 --validate --no-validate
1546 $__git_format_patch_options"
1547 return
1549 esac
1550 __git_complete_revlist
1553 _git_stage ()
1555 _git_add
1558 __git_config_get_set_variables ()
1560 local prevword word config_file= c=$cword
1561 while [ $c -gt 1 ]; do
1562 word="${words[c]}"
1563 case "$word" in
1564 --global|--system|--file=*)
1565 config_file="$word"
1566 break
1568 -f|--file)
1569 config_file="$word $prevword"
1570 break
1572 esac
1573 prevword=$word
1574 c=$((--c))
1575 done
1577 git --git-dir="$(__gitdir)" config $config_file --list 2>/dev/null |
1578 while read -r line
1580 case "$line" in
1581 *.*=*)
1582 echo "${line/=*/}"
1584 esac
1585 done
1588 _git_config ()
1590 case "$prev" in
1591 branch.*.remote)
1592 __gitcomp_nl "$(__git_remotes)"
1593 return
1595 branch.*.merge)
1596 __gitcomp_nl "$(__git_refs)"
1597 return
1599 remote.*.fetch)
1600 local remote="${prev#remote.}"
1601 remote="${remote%.fetch}"
1602 if [ -z "$cur" ]; then
1603 COMPREPLY=("refs/heads/")
1604 return
1606 __gitcomp_nl "$(__git_refs_remotes "$remote")"
1607 return
1609 remote.*.push)
1610 local remote="${prev#remote.}"
1611 remote="${remote%.push}"
1612 __gitcomp_nl "$(git --git-dir="$(__gitdir)" \
1613 for-each-ref --format='%(refname):%(refname)' \
1614 refs/heads)"
1615 return
1617 pull.twohead|pull.octopus)
1618 __git_compute_merge_strategies
1619 __gitcomp "$__git_merge_strategies"
1620 return
1622 color.branch|color.diff|color.interactive|\
1623 color.showbranch|color.status|color.ui)
1624 __gitcomp "always never auto"
1625 return
1627 color.pager)
1628 __gitcomp "false true"
1629 return
1631 color.*.*)
1632 __gitcomp "
1633 normal black red green yellow blue magenta cyan white
1634 bold dim ul blink reverse
1636 return
1638 help.format)
1639 __gitcomp "man info web html"
1640 return
1642 log.date)
1643 __gitcomp "$__git_log_date_formats"
1644 return
1646 sendemail.aliasesfiletype)
1647 __gitcomp "mutt mailrc pine elm gnus"
1648 return
1650 sendemail.confirm)
1651 __gitcomp "$__git_send_email_confirm_options"
1652 return
1654 sendemail.suppresscc)
1655 __gitcomp "$__git_send_email_suppresscc_options"
1656 return
1658 --get|--get-all|--unset|--unset-all)
1659 __gitcomp_nl "$(__git_config_get_set_variables)"
1660 return
1662 *.*)
1663 COMPREPLY=()
1664 return
1666 esac
1667 case "$cur" in
1668 --*)
1669 __gitcomp "
1670 --global --system --file=
1671 --list --replace-all
1672 --get --get-all --get-regexp
1673 --add --unset --unset-all
1674 --remove-section --rename-section
1676 return
1678 branch.*.*)
1679 local pfx="${cur%.*}." cur_="${cur##*.}"
1680 __gitcomp "remote merge mergeoptions rebase" "$pfx" "$cur_"
1681 return
1683 branch.*)
1684 local pfx="${cur%.*}." cur_="${cur#*.}"
1685 __gitcomp_nl "$(__git_heads)" "$pfx" "$cur_" "."
1686 return
1688 guitool.*.*)
1689 local pfx="${cur%.*}." cur_="${cur##*.}"
1690 __gitcomp "
1691 argprompt cmd confirm needsfile noconsole norescan
1692 prompt revprompt revunmerged title
1693 " "$pfx" "$cur_"
1694 return
1696 difftool.*.*)
1697 local pfx="${cur%.*}." cur_="${cur##*.}"
1698 __gitcomp "cmd path" "$pfx" "$cur_"
1699 return
1701 man.*.*)
1702 local pfx="${cur%.*}." cur_="${cur##*.}"
1703 __gitcomp "cmd path" "$pfx" "$cur_"
1704 return
1706 mergetool.*.*)
1707 local pfx="${cur%.*}." cur_="${cur##*.}"
1708 __gitcomp "cmd path trustExitCode" "$pfx" "$cur_"
1709 return
1711 pager.*)
1712 local pfx="${cur%.*}." cur_="${cur#*.}"
1713 __git_compute_all_commands
1714 __gitcomp_nl "$__git_all_commands" "$pfx" "$cur_"
1715 return
1717 remote.*.*)
1718 local pfx="${cur%.*}." cur_="${cur##*.}"
1719 __gitcomp "
1720 url proxy fetch push mirror skipDefaultUpdate
1721 receivepack uploadpack tagopt pushurl
1722 " "$pfx" "$cur_"
1723 return
1725 remote.*)
1726 local pfx="${cur%.*}." cur_="${cur#*.}"
1727 __gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "."
1728 return
1730 url.*.*)
1731 local pfx="${cur%.*}." cur_="${cur##*.}"
1732 __gitcomp "insteadOf pushInsteadOf" "$pfx" "$cur_"
1733 return
1735 esac
1736 __gitcomp "
1737 add.ignoreErrors
1738 advice.commitBeforeMerge
1739 advice.detachedHead
1740 advice.implicitIdentity
1741 advice.pushNonFastForward
1742 advice.resolveConflict
1743 advice.statusHints
1744 alias.
1745 am.keepcr
1746 apply.ignorewhitespace
1747 apply.whitespace
1748 branch.autosetupmerge
1749 branch.autosetuprebase
1750 browser.
1751 clean.requireForce
1752 color.branch
1753 color.branch.current
1754 color.branch.local
1755 color.branch.plain
1756 color.branch.remote
1757 color.decorate.HEAD
1758 color.decorate.branch
1759 color.decorate.remoteBranch
1760 color.decorate.stash
1761 color.decorate.tag
1762 color.diff
1763 color.diff.commit
1764 color.diff.frag
1765 color.diff.func
1766 color.diff.meta
1767 color.diff.new
1768 color.diff.old
1769 color.diff.plain
1770 color.diff.whitespace
1771 color.grep
1772 color.grep.context
1773 color.grep.filename
1774 color.grep.function
1775 color.grep.linenumber
1776 color.grep.match
1777 color.grep.selected
1778 color.grep.separator
1779 color.interactive
1780 color.interactive.error
1781 color.interactive.header
1782 color.interactive.help
1783 color.interactive.prompt
1784 color.pager
1785 color.showbranch
1786 color.status
1787 color.status.added
1788 color.status.changed
1789 color.status.header
1790 color.status.nobranch
1791 color.status.untracked
1792 color.status.updated
1793 color.ui
1794 commit.status
1795 commit.template
1796 core.abbrev
1797 core.askpass
1798 core.attributesfile
1799 core.autocrlf
1800 core.bare
1801 core.bigFileThreshold
1802 core.compression
1803 core.createObject
1804 core.deltaBaseCacheLimit
1805 core.editor
1806 core.eol
1807 core.excludesfile
1808 core.fileMode
1809 core.fsyncobjectfiles
1810 core.gitProxy
1811 core.ignoreCygwinFSTricks
1812 core.ignoreStat
1813 core.ignorecase
1814 core.logAllRefUpdates
1815 core.loosecompression
1816 core.notesRef
1817 core.packedGitLimit
1818 core.packedGitWindowSize
1819 core.pager
1820 core.preferSymlinkRefs
1821 core.preloadindex
1822 core.quotepath
1823 core.repositoryFormatVersion
1824 core.safecrlf
1825 core.sharedRepository
1826 core.sparseCheckout
1827 core.symlinks
1828 core.trustctime
1829 core.warnAmbiguousRefs
1830 core.whitespace
1831 core.worktree
1832 diff.autorefreshindex
1833 diff.statGraphWidth
1834 diff.external
1835 diff.ignoreSubmodules
1836 diff.mnemonicprefix
1837 diff.noprefix
1838 diff.renameLimit
1839 diff.renames
1840 diff.suppressBlankEmpty
1841 diff.tool
1842 diff.wordRegex
1843 difftool.
1844 difftool.prompt
1845 fetch.recurseSubmodules
1846 fetch.unpackLimit
1847 format.attach
1848 format.cc
1849 format.headers
1850 format.numbered
1851 format.pretty
1852 format.signature
1853 format.signoff
1854 format.subjectprefix
1855 format.suffix
1856 format.thread
1857 format.to
1859 gc.aggressiveWindow
1860 gc.auto
1861 gc.autopacklimit
1862 gc.packrefs
1863 gc.pruneexpire
1864 gc.reflogexpire
1865 gc.reflogexpireunreachable
1866 gc.rerereresolved
1867 gc.rerereunresolved
1868 gitcvs.allbinary
1869 gitcvs.commitmsgannotation
1870 gitcvs.dbTableNamePrefix
1871 gitcvs.dbdriver
1872 gitcvs.dbname
1873 gitcvs.dbpass
1874 gitcvs.dbuser
1875 gitcvs.enabled
1876 gitcvs.logfile
1877 gitcvs.usecrlfattr
1878 guitool.
1879 gui.blamehistoryctx
1880 gui.commitmsgwidth
1881 gui.copyblamethreshold
1882 gui.diffcontext
1883 gui.encoding
1884 gui.fastcopyblame
1885 gui.matchtrackingbranch
1886 gui.newbranchtemplate
1887 gui.pruneduringfetch
1888 gui.spellingdictionary
1889 gui.trustmtime
1890 help.autocorrect
1891 help.browser
1892 help.format
1893 http.lowSpeedLimit
1894 http.lowSpeedTime
1895 http.maxRequests
1896 http.minSessions
1897 http.noEPSV
1898 http.postBuffer
1899 http.proxy
1900 http.sslCAInfo
1901 http.sslCAPath
1902 http.sslCert
1903 http.sslCertPasswordProtected
1904 http.sslKey
1905 http.sslVerify
1906 http.useragent
1907 i18n.commitEncoding
1908 i18n.logOutputEncoding
1909 imap.authMethod
1910 imap.folder
1911 imap.host
1912 imap.pass
1913 imap.port
1914 imap.preformattedHTML
1915 imap.sslverify
1916 imap.tunnel
1917 imap.user
1918 init.templatedir
1919 instaweb.browser
1920 instaweb.httpd
1921 instaweb.local
1922 instaweb.modulepath
1923 instaweb.port
1924 interactive.singlekey
1925 log.date
1926 log.decorate
1927 log.showroot
1928 mailmap.file
1929 man.
1930 man.viewer
1931 merge.
1932 merge.conflictstyle
1933 merge.log
1934 merge.renameLimit
1935 merge.renormalize
1936 merge.stat
1937 merge.tool
1938 merge.verbosity
1939 mergetool.
1940 mergetool.keepBackup
1941 mergetool.keepTemporaries
1942 mergetool.prompt
1943 notes.displayRef
1944 notes.rewrite.
1945 notes.rewrite.amend
1946 notes.rewrite.rebase
1947 notes.rewriteMode
1948 notes.rewriteRef
1949 pack.compression
1950 pack.deltaCacheLimit
1951 pack.deltaCacheSize
1952 pack.depth
1953 pack.indexVersion
1954 pack.packSizeLimit
1955 pack.threads
1956 pack.window
1957 pack.windowMemory
1958 pager.
1959 pretty.
1960 pull.octopus
1961 pull.twohead
1962 push.default
1963 rebase.autosquash
1964 rebase.stat
1965 receive.autogc
1966 receive.denyCurrentBranch
1967 receive.denyDeleteCurrent
1968 receive.denyDeletes
1969 receive.denyNonFastForwards
1970 receive.fsckObjects
1971 receive.unpackLimit
1972 receive.updateserverinfo
1973 remotes.
1974 repack.usedeltabaseoffset
1975 rerere.autoupdate
1976 rerere.enabled
1977 sendemail.
1978 sendemail.aliasesfile
1979 sendemail.aliasfiletype
1980 sendemail.bcc
1981 sendemail.cc
1982 sendemail.cccmd
1983 sendemail.chainreplyto
1984 sendemail.confirm
1985 sendemail.envelopesender
1986 sendemail.from
1987 sendemail.identity
1988 sendemail.multiedit
1989 sendemail.signedoffbycc
1990 sendemail.smtpdomain
1991 sendemail.smtpencryption
1992 sendemail.smtppass
1993 sendemail.smtpserver
1994 sendemail.smtpserveroption
1995 sendemail.smtpserverport
1996 sendemail.smtpuser
1997 sendemail.suppresscc
1998 sendemail.suppressfrom
1999 sendemail.thread
2000 sendemail.to
2001 sendemail.validate
2002 showbranch.default
2003 status.relativePaths
2004 status.showUntrackedFiles
2005 status.submodulesummary
2006 submodule.
2007 tar.umask
2008 transfer.unpackLimit
2009 url.
2010 user.email
2011 user.name
2012 user.signingkey
2013 web.browser
2014 branch. remote.
2018 _git_remote ()
2020 local subcommands="add rename remove set-head set-branches set-url show prune update"
2021 local subcommand="$(__git_find_on_cmdline "$subcommands")"
2022 if [ -z "$subcommand" ]; then
2023 __gitcomp "$subcommands"
2024 return
2027 case "$subcommand" in
2028 rename|remove|set-url|show|prune)
2029 __gitcomp_nl "$(__git_remotes)"
2031 set-head|set-branches)
2032 __git_complete_remote_or_refspec
2034 update)
2035 local i c='' IFS=$'\n'
2036 for i in $(git --git-dir="$(__gitdir)" config --get-regexp "remotes\..*" 2>/dev/null); do
2037 i="${i#remotes.}"
2038 c="$c ${i/ */}"
2039 done
2040 __gitcomp "$c"
2043 COMPREPLY=()
2045 esac
2048 _git_replace ()
2050 __gitcomp_nl "$(__git_refs)"
2053 _git_reset ()
2055 __git_has_doubledash && return
2057 case "$cur" in
2058 --*)
2059 __gitcomp "--merge --mixed --hard --soft --patch"
2060 return
2062 esac
2063 __gitcomp_nl "$(__git_refs)"
2066 _git_revert ()
2068 case "$cur" in
2069 --*)
2070 __gitcomp "--edit --mainline --no-edit --no-commit --signoff"
2071 return
2073 esac
2074 __gitcomp_nl "$(__git_refs)"
2077 _git_rm ()
2079 __git_has_doubledash && return
2081 case "$cur" in
2082 --*)
2083 __gitcomp "--cached --dry-run --ignore-unmatch --quiet"
2084 return
2086 esac
2087 COMPREPLY=()
2090 _git_shortlog ()
2092 __git_has_doubledash && return
2094 case "$cur" in
2095 --*)
2096 __gitcomp "
2097 $__git_log_common_options
2098 $__git_log_shortlog_options
2099 --numbered --summary
2101 return
2103 esac
2104 __git_complete_revlist
2107 _git_show ()
2109 __git_has_doubledash && return
2111 case "$cur" in
2112 --pretty=*|--format=*)
2113 __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
2114 " "" "${cur#*=}"
2115 return
2117 --*)
2118 __gitcomp "--pretty= --format= --abbrev-commit --oneline
2119 $__git_diff_common_options
2121 return
2123 esac
2124 __git_complete_file
2127 _git_show_branch ()
2129 case "$cur" in
2130 --*)
2131 __gitcomp "
2132 --all --remotes --topo-order --current --more=
2133 --list --independent --merge-base --no-name
2134 --color --no-color
2135 --sha1-name --sparse --topics --reflog
2137 return
2139 esac
2140 __git_complete_revlist
2143 _git_stash ()
2145 local save_opts='--keep-index --no-keep-index --quiet --patch'
2146 local subcommands='save list show apply clear drop pop create branch'
2147 local subcommand="$(__git_find_on_cmdline "$subcommands")"
2148 if [ -z "$subcommand" ]; then
2149 case "$cur" in
2150 --*)
2151 __gitcomp "$save_opts"
2154 if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then
2155 __gitcomp "$subcommands"
2156 else
2157 COMPREPLY=()
2160 esac
2161 else
2162 case "$subcommand,$cur" in
2163 save,--*)
2164 __gitcomp "$save_opts"
2166 apply,--*|pop,--*)
2167 __gitcomp "--index --quiet"
2169 show,--*|drop,--*|branch,--*)
2170 COMPREPLY=()
2172 show,*|apply,*|drop,*|pop,*|branch,*)
2173 __gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \
2174 | sed -n -e 's/:.*//p')"
2177 COMPREPLY=()
2179 esac
2183 _git_submodule ()
2185 __git_has_doubledash && return
2187 local subcommands="add status init update summary foreach sync"
2188 if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then
2189 case "$cur" in
2190 --*)
2191 __gitcomp "--quiet --cached"
2194 __gitcomp "$subcommands"
2196 esac
2197 return
2201 _git_svn ()
2203 local subcommands="
2204 init fetch clone rebase dcommit log find-rev
2205 set-tree commit-diff info create-ignore propget
2206 proplist show-ignore show-externals branch tag blame
2207 migrate mkdirs reset gc
2209 local subcommand="$(__git_find_on_cmdline "$subcommands")"
2210 if [ -z "$subcommand" ]; then
2211 __gitcomp "$subcommands"
2212 else
2213 local remote_opts="--username= --config-dir= --no-auth-cache"
2214 local fc_opts="
2215 --follow-parent --authors-file= --repack=
2216 --no-metadata --use-svm-props --use-svnsync-props
2217 --log-window-size= --no-checkout --quiet
2218 --repack-flags --use-log-author --localtime
2219 --ignore-paths= $remote_opts
2221 local init_opts="
2222 --template= --shared= --trunk= --tags=
2223 --branches= --stdlayout --minimize-url
2224 --no-metadata --use-svm-props --use-svnsync-props
2225 --rewrite-root= --prefix= --use-log-author
2226 --add-author-from $remote_opts
2228 local cmt_opts="
2229 --edit --rmdir --find-copies-harder --copy-similarity=
2232 case "$subcommand,$cur" in
2233 fetch,--*)
2234 __gitcomp "--revision= --fetch-all $fc_opts"
2236 clone,--*)
2237 __gitcomp "--revision= $fc_opts $init_opts"
2239 init,--*)
2240 __gitcomp "$init_opts"
2242 dcommit,--*)
2243 __gitcomp "
2244 --merge --strategy= --verbose --dry-run
2245 --fetch-all --no-rebase --commit-url
2246 --revision --interactive $cmt_opts $fc_opts
2249 set-tree,--*)
2250 __gitcomp "--stdin $cmt_opts $fc_opts"
2252 create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\
2253 show-externals,--*|mkdirs,--*)
2254 __gitcomp "--revision="
2256 log,--*)
2257 __gitcomp "
2258 --limit= --revision= --verbose --incremental
2259 --oneline --show-commit --non-recursive
2260 --authors-file= --color
2263 rebase,--*)
2264 __gitcomp "
2265 --merge --verbose --strategy= --local
2266 --fetch-all --dry-run $fc_opts
2269 commit-diff,--*)
2270 __gitcomp "--message= --file= --revision= $cmt_opts"
2272 info,--*)
2273 __gitcomp "--url"
2275 branch,--*)
2276 __gitcomp "--dry-run --message --tag"
2278 tag,--*)
2279 __gitcomp "--dry-run --message"
2281 blame,--*)
2282 __gitcomp "--git-format"
2284 migrate,--*)
2285 __gitcomp "
2286 --config-dir= --ignore-paths= --minimize
2287 --no-auth-cache --username=
2290 reset,--*)
2291 __gitcomp "--revision= --parent"
2294 COMPREPLY=()
2296 esac
2300 _git_tag ()
2302 local i c=1 f=0
2303 while [ $c -lt $cword ]; do
2304 i="${words[c]}"
2305 case "$i" in
2306 -d|-v)
2307 __gitcomp_nl "$(__git_tags)"
2308 return
2313 esac
2314 ((c++))
2315 done
2317 case "$prev" in
2318 -m|-F)
2319 COMPREPLY=()
2321 -*|tag)
2322 if [ $f = 1 ]; then
2323 __gitcomp_nl "$(__git_tags)"
2324 else
2325 COMPREPLY=()
2329 __gitcomp_nl "$(__git_refs)"
2331 esac
2334 _git_whatchanged ()
2336 _git_log
2339 __git_main ()
2341 local i c=1 command __git_dir
2343 while [ $c -lt $cword ]; do
2344 i="${words[c]}"
2345 case "$i" in
2346 --git-dir=*) __git_dir="${i#--git-dir=}" ;;
2347 --bare) __git_dir="." ;;
2348 --help) command="help"; break ;;
2349 -c) c=$((++c)) ;;
2350 -*) ;;
2351 *) command="$i"; break ;;
2352 esac
2353 ((c++))
2354 done
2356 if [ -z "$command" ]; then
2357 case "$cur" in
2358 --*) __gitcomp "
2359 --paginate
2360 --no-pager
2361 --git-dir=
2362 --bare
2363 --version
2364 --exec-path
2365 --exec-path=
2366 --html-path
2367 --info-path
2368 --work-tree=
2369 --namespace=
2370 --no-replace-objects
2371 --help
2374 *) __git_compute_porcelain_commands
2375 __gitcomp "$__git_porcelain_commands $(__git_aliases)" ;;
2376 esac
2377 return
2380 local completion_func="_git_${command//-/_}"
2381 declare -f $completion_func >/dev/null && $completion_func && return
2383 local expansion=$(__git_aliased_command "$command")
2384 if [ -n "$expansion" ]; then
2385 completion_func="_git_${expansion//-/_}"
2386 declare -f $completion_func >/dev/null && $completion_func
2390 __gitk_main ()
2392 __git_has_doubledash && return
2394 local g="$(__gitdir)"
2395 local merge=""
2396 if [ -f "$g/MERGE_HEAD" ]; then
2397 merge="--merge"
2399 case "$cur" in
2400 --*)
2401 __gitcomp "
2402 $__git_log_common_options
2403 $__git_log_gitk_options
2404 $merge
2406 return
2408 esac
2409 __git_complete_revlist
2412 if [[ -n ${ZSH_VERSION-} ]]; then
2413 echo "WARNING: this script is deprecated, please see git-completion.zsh" 1>&2
2415 autoload -U +X compinit && compinit
2417 __gitcomp ()
2419 emulate -L zsh
2421 local cur_="${3-$cur}"
2423 case "$cur_" in
2424 --*=)
2427 local c IFS=$' \t\n'
2428 local -a array
2429 for c in ${=1}; do
2430 c="$c${4-}"
2431 case $c in
2432 --*=*|*.) ;;
2433 *) c="$c " ;;
2434 esac
2435 array+=("$c")
2436 done
2437 compset -P '*[=:]'
2438 compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
2440 esac
2443 __gitcomp_nl ()
2445 emulate -L zsh
2447 local IFS=$'\n'
2448 compset -P '*[=:]'
2449 compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
2452 __git_zsh_helper ()
2454 emulate -L ksh
2455 local cur cword prev
2456 cur=${words[CURRENT-1]}
2457 prev=${words[CURRENT-2]}
2458 let cword=CURRENT-1
2459 __${service}_main
2462 _git ()
2464 emulate -L zsh
2465 local _ret=1
2466 __git_zsh_helper
2467 let _ret && _default -S '' && _ret=0
2468 return _ret
2471 compdef _git git gitk
2472 return
2475 __git_func_wrap ()
2477 local cur words cword prev
2478 _get_comp_words_by_ref -n =: cur words cword prev
2482 # Setup completion for certain functions defined above by setting common
2483 # variables and workarounds.
2484 # This is NOT a public function; use at your own risk.
2485 __git_complete ()
2487 local wrapper="__git_wrap${2}"
2488 eval "$wrapper () { __git_func_wrap $2 ; }"
2489 complete -o bashdefault -o default -o nospace -F $wrapper $1 2>/dev/null \
2490 || complete -o default -o nospace -F $wrapper $1
2493 # wrapper for backwards compatibility
2494 _git ()
2496 __git_wrap__git_main
2499 # wrapper for backwards compatibility
2500 _gitk ()
2502 __git_wrap__gitk_main
2505 __git_complete git __git_main
2506 __git_complete gitk __gitk_main
2508 # The following are necessary only for Cygwin, and only are needed
2509 # when the user has tab-completed the executable name and consequently
2510 # included the '.exe' suffix.
2512 if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
2513 __git_complete git.exe __git_main