Merge branch 'fc/zsh-completion'
[git/mingw.git] / contrib / completion / git-completion.bash
blob98f390ae46a6359d3a9d5f42fc2cce2186efd242
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" \
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-ref-format) : plumbing;;
567 checkout-index) : plumbing;;
568 commit-tree) : plumbing;;
569 count-objects) : infrequent;;
570 credential-cache) : credentials helper;;
571 credential-store) : credentials helper;;
572 cvsexportcommit) : export;;
573 cvsimport) : import;;
574 cvsserver) : daemon;;
575 daemon) : daemon;;
576 diff-files) : plumbing;;
577 diff-index) : plumbing;;
578 diff-tree) : plumbing;;
579 fast-import) : import;;
580 fast-export) : export;;
581 fsck-objects) : plumbing;;
582 fetch-pack) : plumbing;;
583 fmt-merge-msg) : plumbing;;
584 for-each-ref) : plumbing;;
585 hash-object) : plumbing;;
586 http-*) : transport;;
587 index-pack) : plumbing;;
588 init-db) : deprecated;;
589 local-fetch) : plumbing;;
590 lost-found) : infrequent;;
591 ls-files) : plumbing;;
592 ls-remote) : plumbing;;
593 ls-tree) : plumbing;;
594 mailinfo) : plumbing;;
595 mailsplit) : plumbing;;
596 merge-*) : plumbing;;
597 mktree) : plumbing;;
598 mktag) : plumbing;;
599 pack-objects) : plumbing;;
600 pack-redundant) : plumbing;;
601 pack-refs) : plumbing;;
602 parse-remote) : plumbing;;
603 patch-id) : plumbing;;
604 peek-remote) : plumbing;;
605 prune) : plumbing;;
606 prune-packed) : plumbing;;
607 quiltimport) : import;;
608 read-tree) : plumbing;;
609 receive-pack) : plumbing;;
610 remote-*) : transport;;
611 repo-config) : deprecated;;
612 rerere) : plumbing;;
613 rev-list) : plumbing;;
614 rev-parse) : plumbing;;
615 runstatus) : plumbing;;
616 sh-setup) : internal;;
617 shell) : daemon;;
618 show-ref) : plumbing;;
619 send-pack) : plumbing;;
620 show-index) : plumbing;;
621 ssh-*) : transport;;
622 stripspace) : plumbing;;
623 symbolic-ref) : plumbing;;
624 tar-tree) : deprecated;;
625 unpack-file) : plumbing;;
626 unpack-objects) : plumbing;;
627 update-index) : plumbing;;
628 update-ref) : plumbing;;
629 update-server-info) : daemon;;
630 upload-archive) : plumbing;;
631 upload-pack) : plumbing;;
632 write-tree) : plumbing;;
633 var) : infrequent;;
634 verify-pack) : infrequent;;
635 verify-tag) : plumbing;;
636 *) echo $i;;
637 esac
638 done
641 __git_porcelain_commands=
642 __git_compute_porcelain_commands ()
644 __git_compute_all_commands
645 test -n "$__git_porcelain_commands" ||
646 __git_porcelain_commands=$(__git_list_porcelain_commands)
649 __git_pretty_aliases ()
651 local i IFS=$'\n'
652 for i in $(git --git-dir="$(__gitdir)" config --get-regexp "pretty\..*" 2>/dev/null); do
653 case "$i" in
654 pretty.*)
655 i="${i#pretty.}"
656 echo "${i/ */}"
658 esac
659 done
662 __git_aliases ()
664 local i IFS=$'\n'
665 for i in $(git --git-dir="$(__gitdir)" config --get-regexp "alias\..*" 2>/dev/null); do
666 case "$i" in
667 alias.*)
668 i="${i#alias.}"
669 echo "${i/ */}"
671 esac
672 done
675 # __git_aliased_command requires 1 argument
676 __git_aliased_command ()
678 local word cmdline=$(git --git-dir="$(__gitdir)" \
679 config --get "alias.$1")
680 for word in $cmdline; do
681 case "$word" in
682 \!gitk|gitk)
683 echo "gitk"
684 return
686 \!*) : shell command alias ;;
687 -*) : option ;;
688 *=*) : setting env ;;
689 git) : git itself ;;
691 echo "$word"
692 return
693 esac
694 done
697 # __git_find_on_cmdline requires 1 argument
698 __git_find_on_cmdline ()
700 local word subcommand c=1
701 while [ $c -lt $cword ]; do
702 word="${words[c]}"
703 for subcommand in $1; do
704 if [ "$subcommand" = "$word" ]; then
705 echo "$subcommand"
706 return
708 done
709 ((c++))
710 done
713 __git_has_doubledash ()
715 local c=1
716 while [ $c -lt $cword ]; do
717 if [ "--" = "${words[c]}" ]; then
718 return 0
720 ((c++))
721 done
722 return 1
725 __git_whitespacelist="nowarn warn error error-all fix"
727 _git_am ()
729 local dir="$(__gitdir)"
730 if [ -d "$dir"/rebase-apply ]; then
731 __gitcomp "--skip --continue --resolved --abort"
732 return
734 case "$cur" in
735 --whitespace=*)
736 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
737 return
739 --*)
740 __gitcomp "
741 --3way --committer-date-is-author-date --ignore-date
742 --ignore-whitespace --ignore-space-change
743 --interactive --keep --no-utf8 --signoff --utf8
744 --whitespace= --scissors
746 return
747 esac
748 COMPREPLY=()
751 _git_apply ()
753 case "$cur" in
754 --whitespace=*)
755 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
756 return
758 --*)
759 __gitcomp "
760 --stat --numstat --summary --check --index
761 --cached --index-info --reverse --reject --unidiff-zero
762 --apply --no-add --exclude=
763 --ignore-whitespace --ignore-space-change
764 --whitespace= --inaccurate-eof --verbose
766 return
767 esac
768 COMPREPLY=()
771 _git_add ()
773 __git_has_doubledash && return
775 case "$cur" in
776 --*)
777 __gitcomp "
778 --interactive --refresh --patch --update --dry-run
779 --ignore-errors --intent-to-add
781 return
782 esac
783 COMPREPLY=()
786 _git_archive ()
788 case "$cur" in
789 --format=*)
790 __gitcomp "$(git archive --list)" "" "${cur##--format=}"
791 return
793 --remote=*)
794 __gitcomp_nl "$(__git_remotes)" "" "${cur##--remote=}"
795 return
797 --*)
798 __gitcomp "
799 --format= --list --verbose
800 --prefix= --remote= --exec=
802 return
804 esac
805 __git_complete_file
808 _git_bisect ()
810 __git_has_doubledash && return
812 local subcommands="start bad good skip reset visualize replay log run"
813 local subcommand="$(__git_find_on_cmdline "$subcommands")"
814 if [ -z "$subcommand" ]; then
815 if [ -f "$(__gitdir)"/BISECT_START ]; then
816 __gitcomp "$subcommands"
817 else
818 __gitcomp "replay start"
820 return
823 case "$subcommand" in
824 bad|good|reset|skip|start)
825 __gitcomp_nl "$(__git_refs)"
828 COMPREPLY=()
830 esac
833 _git_branch ()
835 local i c=1 only_local_ref="n" has_r="n"
837 while [ $c -lt $cword ]; do
838 i="${words[c]}"
839 case "$i" in
840 -d|-m) only_local_ref="y" ;;
841 -r) has_r="y" ;;
842 esac
843 ((c++))
844 done
846 case "$cur" in
847 --set-upstream-to=*)
848 __gitcomp "$(__git_refs)" "" "${cur##--set-upstream-to=}"
850 --*)
851 __gitcomp "
852 --color --no-color --verbose --abbrev= --no-abbrev
853 --track --no-track --contains --merged --no-merged
854 --set-upstream-to= --edit-description --list
855 --unset-upstream
859 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
860 __gitcomp_nl "$(__git_heads)"
861 else
862 __gitcomp_nl "$(__git_refs)"
865 esac
868 _git_bundle ()
870 local cmd="${words[2]}"
871 case "$cword" in
873 __gitcomp "create list-heads verify unbundle"
876 # looking for a file
879 case "$cmd" in
880 create)
881 __git_complete_revlist
883 esac
885 esac
888 _git_checkout ()
890 __git_has_doubledash && return
892 case "$cur" in
893 --conflict=*)
894 __gitcomp "diff3 merge" "" "${cur##--conflict=}"
896 --*)
897 __gitcomp "
898 --quiet --ours --theirs --track --no-track --merge
899 --conflict= --orphan --patch
903 # check if --track, --no-track, or --no-guess was specified
904 # if so, disable DWIM mode
905 local flags="--track --no-track --no-guess" track=1
906 if [ -n "$(__git_find_on_cmdline "$flags")" ]; then
907 track=''
909 __gitcomp_nl "$(__git_refs '' $track)"
911 esac
914 _git_cherry ()
916 __gitcomp "$(__git_refs)"
919 _git_cherry_pick ()
921 case "$cur" in
922 --*)
923 __gitcomp "--edit --no-commit"
926 __gitcomp_nl "$(__git_refs)"
928 esac
931 _git_clean ()
933 __git_has_doubledash && return
935 case "$cur" in
936 --*)
937 __gitcomp "--dry-run --quiet"
938 return
940 esac
941 COMPREPLY=()
944 _git_clone ()
946 case "$cur" in
947 --*)
948 __gitcomp "
949 --local
950 --no-hardlinks
951 --shared
952 --reference
953 --quiet
954 --no-checkout
955 --bare
956 --mirror
957 --origin
958 --upload-pack
959 --template=
960 --depth
962 return
964 esac
965 COMPREPLY=()
968 _git_commit ()
970 __git_has_doubledash && return
972 case "$cur" in
973 --cleanup=*)
974 __gitcomp "default strip verbatim whitespace
975 " "" "${cur##--cleanup=}"
976 return
978 --reuse-message=*|--reedit-message=*|\
979 --fixup=*|--squash=*)
980 __gitcomp_nl "$(__git_refs)" "" "${cur#*=}"
981 return
983 --untracked-files=*)
984 __gitcomp "all no normal" "" "${cur##--untracked-files=}"
985 return
987 --*)
988 __gitcomp "
989 --all --author= --signoff --verify --no-verify
990 --edit --no-edit
991 --amend --include --only --interactive
992 --dry-run --reuse-message= --reedit-message=
993 --reset-author --file= --message= --template=
994 --cleanup= --untracked-files --untracked-files=
995 --verbose --quiet --fixup= --squash=
997 return
998 esac
999 COMPREPLY=()
1002 _git_describe ()
1004 case "$cur" in
1005 --*)
1006 __gitcomp "
1007 --all --tags --contains --abbrev= --candidates=
1008 --exact-match --debug --long --match --always
1010 return
1011 esac
1012 __gitcomp_nl "$(__git_refs)"
1015 __git_diff_common_options="--stat --numstat --shortstat --summary
1016 --patch-with-stat --name-only --name-status --color
1017 --no-color --color-words --no-renames --check
1018 --full-index --binary --abbrev --diff-filter=
1019 --find-copies-harder
1020 --text --ignore-space-at-eol --ignore-space-change
1021 --ignore-all-space --exit-code --quiet --ext-diff
1022 --no-ext-diff
1023 --no-prefix --src-prefix= --dst-prefix=
1024 --inter-hunk-context=
1025 --patience
1026 --raw
1027 --dirstat --dirstat= --dirstat-by-file
1028 --dirstat-by-file= --cumulative
1031 _git_diff ()
1033 __git_has_doubledash && return
1035 case "$cur" in
1036 --*)
1037 __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
1038 --base --ours --theirs --no-index
1039 $__git_diff_common_options
1041 return
1043 esac
1044 __git_complete_revlist_file
1047 __git_mergetools_common="diffuse ecmerge emerge kdiff3 meld opendiff
1048 tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc3 codecompare
1051 _git_difftool ()
1053 __git_has_doubledash && return
1055 case "$cur" in
1056 --tool=*)
1057 __gitcomp "$__git_mergetools_common kompare" "" "${cur##--tool=}"
1058 return
1060 --*)
1061 __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
1062 --base --ours --theirs
1063 --no-renames --diff-filter= --find-copies-harder
1064 --relative --ignore-submodules
1065 --tool="
1066 return
1068 esac
1069 __git_complete_file
1072 __git_fetch_options="
1073 --quiet --verbose --append --upload-pack --force --keep --depth=
1074 --tags --no-tags --all --prune --dry-run
1077 _git_fetch ()
1079 case "$cur" in
1080 --*)
1081 __gitcomp "$__git_fetch_options"
1082 return
1084 esac
1085 __git_complete_remote_or_refspec
1088 __git_format_patch_options="
1089 --stdout --attach --no-attach --thread --thread= --output-directory
1090 --numbered --start-number --numbered-files --keep-subject --signoff
1091 --signature --no-signature --in-reply-to= --cc= --full-index --binary
1092 --not --all --cover-letter --no-prefix --src-prefix= --dst-prefix=
1093 --inline --suffix= --ignore-if-in-upstream --subject-prefix=
1096 _git_format_patch ()
1098 case "$cur" in
1099 --thread=*)
1100 __gitcomp "
1101 deep shallow
1102 " "" "${cur##--thread=}"
1103 return
1105 --*)
1106 __gitcomp "$__git_format_patch_options"
1107 return
1109 esac
1110 __git_complete_revlist
1113 _git_fsck ()
1115 case "$cur" in
1116 --*)
1117 __gitcomp "
1118 --tags --root --unreachable --cache --no-reflogs --full
1119 --strict --verbose --lost-found
1121 return
1123 esac
1124 COMPREPLY=()
1127 _git_gc ()
1129 case "$cur" in
1130 --*)
1131 __gitcomp "--prune --aggressive"
1132 return
1134 esac
1135 COMPREPLY=()
1138 _git_gitk ()
1140 _gitk
1143 __git_match_ctag() {
1144 awk "/^${1////\\/}/ { print \$1 }" "$2"
1147 _git_grep ()
1149 __git_has_doubledash && return
1151 case "$cur" in
1152 --*)
1153 __gitcomp "
1154 --cached
1155 --text --ignore-case --word-regexp --invert-match
1156 --full-name --line-number
1157 --extended-regexp --basic-regexp --fixed-strings
1158 --perl-regexp
1159 --files-with-matches --name-only
1160 --files-without-match
1161 --max-depth
1162 --count
1163 --and --or --not --all-match
1165 return
1167 esac
1169 case "$cword,$prev" in
1170 2,*|*,-*)
1171 if test -r tags; then
1172 __gitcomp_nl "$(__git_match_ctag "$cur" tags)"
1173 return
1176 esac
1178 __gitcomp_nl "$(__git_refs)"
1181 _git_help ()
1183 case "$cur" in
1184 --*)
1185 __gitcomp "--all --info --man --web"
1186 return
1188 esac
1189 __git_compute_all_commands
1190 __gitcomp "$__git_all_commands $(__git_aliases)
1191 attributes cli core-tutorial cvs-migration
1192 diffcore gitk glossary hooks ignore modules
1193 namespaces repository-layout tutorial tutorial-2
1194 workflows
1198 _git_init ()
1200 case "$cur" in
1201 --shared=*)
1202 __gitcomp "
1203 false true umask group all world everybody
1204 " "" "${cur##--shared=}"
1205 return
1207 --*)
1208 __gitcomp "--quiet --bare --template= --shared --shared="
1209 return
1211 esac
1212 COMPREPLY=()
1215 _git_ls_files ()
1217 __git_has_doubledash && return
1219 case "$cur" in
1220 --*)
1221 __gitcomp "--cached --deleted --modified --others --ignored
1222 --stage --directory --no-empty-directory --unmerged
1223 --killed --exclude= --exclude-from=
1224 --exclude-per-directory= --exclude-standard
1225 --error-unmatch --with-tree= --full-name
1226 --abbrev --ignored --exclude-per-directory
1228 return
1230 esac
1231 COMPREPLY=()
1234 _git_ls_remote ()
1236 __gitcomp_nl "$(__git_remotes)"
1239 _git_ls_tree ()
1241 __git_complete_file
1244 # Options that go well for log, shortlog and gitk
1245 __git_log_common_options="
1246 --not --all
1247 --branches --tags --remotes
1248 --first-parent --merges --no-merges
1249 --max-count=
1250 --max-age= --since= --after=
1251 --min-age= --until= --before=
1252 --min-parents= --max-parents=
1253 --no-min-parents --no-max-parents
1255 # Options that go well for log and gitk (not shortlog)
1256 __git_log_gitk_options="
1257 --dense --sparse --full-history
1258 --simplify-merges --simplify-by-decoration
1259 --left-right --notes --no-notes
1261 # Options that go well for log and shortlog (not gitk)
1262 __git_log_shortlog_options="
1263 --author= --committer= --grep=
1264 --all-match
1267 __git_log_pretty_formats="oneline short medium full fuller email raw format:"
1268 __git_log_date_formats="relative iso8601 rfc2822 short local default raw"
1270 _git_log ()
1272 __git_has_doubledash && return
1274 local g="$(git rev-parse --git-dir 2>/dev/null)"
1275 local merge=""
1276 if [ -f "$g/MERGE_HEAD" ]; then
1277 merge="--merge"
1279 case "$cur" in
1280 --pretty=*|--format=*)
1281 __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
1282 " "" "${cur#*=}"
1283 return
1285 --date=*)
1286 __gitcomp "$__git_log_date_formats" "" "${cur##--date=}"
1287 return
1289 --decorate=*)
1290 __gitcomp "long short" "" "${cur##--decorate=}"
1291 return
1293 --*)
1294 __gitcomp "
1295 $__git_log_common_options
1296 $__git_log_shortlog_options
1297 $__git_log_gitk_options
1298 --root --topo-order --date-order --reverse
1299 --follow --full-diff
1300 --abbrev-commit --abbrev=
1301 --relative-date --date=
1302 --pretty= --format= --oneline
1303 --cherry-pick
1304 --graph
1305 --decorate --decorate=
1306 --walk-reflogs
1307 --parents --children
1308 $merge
1309 $__git_diff_common_options
1310 --pickaxe-all --pickaxe-regex
1312 return
1314 esac
1315 __git_complete_revlist
1318 __git_merge_options="
1319 --no-commit --no-stat --log --no-log --squash --strategy
1320 --commit --stat --no-squash --ff --no-ff --ff-only --edit --no-edit
1323 _git_merge ()
1325 __git_complete_strategy && return
1327 case "$cur" in
1328 --*)
1329 __gitcomp "$__git_merge_options"
1330 return
1331 esac
1332 __gitcomp_nl "$(__git_refs)"
1335 _git_mergetool ()
1337 case "$cur" in
1338 --tool=*)
1339 __gitcomp "$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"
1340 return
1342 --*)
1343 __gitcomp "--tool="
1344 return
1346 esac
1347 COMPREPLY=()
1350 _git_merge_base ()
1352 __gitcomp_nl "$(__git_refs)"
1355 _git_mv ()
1357 case "$cur" in
1358 --*)
1359 __gitcomp "--dry-run"
1360 return
1362 esac
1363 COMPREPLY=()
1366 _git_name_rev ()
1368 __gitcomp "--tags --all --stdin"
1371 _git_notes ()
1373 local subcommands='add append copy edit list prune remove show'
1374 local subcommand="$(__git_find_on_cmdline "$subcommands")"
1376 case "$subcommand,$cur" in
1377 ,--*)
1378 __gitcomp '--ref'
1381 case "$prev" in
1382 --ref)
1383 __gitcomp_nl "$(__git_refs)"
1386 __gitcomp "$subcommands --ref"
1388 esac
1390 add,--reuse-message=*|append,--reuse-message=*|\
1391 add,--reedit-message=*|append,--reedit-message=*)
1392 __gitcomp_nl "$(__git_refs)" "" "${cur#*=}"
1394 add,--*|append,--*)
1395 __gitcomp '--file= --message= --reedit-message=
1396 --reuse-message='
1398 copy,--*)
1399 __gitcomp '--stdin'
1401 prune,--*)
1402 __gitcomp '--dry-run --verbose'
1404 prune,*)
1407 case "$prev" in
1408 -m|-F)
1411 __gitcomp_nl "$(__git_refs)"
1413 esac
1415 esac
1418 _git_pull ()
1420 __git_complete_strategy && return
1422 case "$cur" in
1423 --*)
1424 __gitcomp "
1425 --rebase --no-rebase
1426 $__git_merge_options
1427 $__git_fetch_options
1429 return
1431 esac
1432 __git_complete_remote_or_refspec
1435 _git_push ()
1437 case "$prev" in
1438 --repo)
1439 __gitcomp_nl "$(__git_remotes)"
1440 return
1441 esac
1442 case "$cur" in
1443 --repo=*)
1444 __gitcomp_nl "$(__git_remotes)" "" "${cur##--repo=}"
1445 return
1447 --*)
1448 __gitcomp "
1449 --all --mirror --tags --dry-run --force --verbose
1450 --receive-pack= --repo= --set-upstream
1452 return
1454 esac
1455 __git_complete_remote_or_refspec
1458 _git_rebase ()
1460 local dir="$(__gitdir)"
1461 if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
1462 __gitcomp "--continue --skip --abort"
1463 return
1465 __git_complete_strategy && return
1466 case "$cur" in
1467 --whitespace=*)
1468 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
1469 return
1471 --*)
1472 __gitcomp "
1473 --onto --merge --strategy --interactive
1474 --preserve-merges --stat --no-stat
1475 --committer-date-is-author-date --ignore-date
1476 --ignore-whitespace --whitespace=
1477 --autosquash
1480 return
1481 esac
1482 __gitcomp_nl "$(__git_refs)"
1485 _git_reflog ()
1487 local subcommands="show delete expire"
1488 local subcommand="$(__git_find_on_cmdline "$subcommands")"
1490 if [ -z "$subcommand" ]; then
1491 __gitcomp "$subcommands"
1492 else
1493 __gitcomp_nl "$(__git_refs)"
1497 __git_send_email_confirm_options="always never auto cc compose"
1498 __git_send_email_suppresscc_options="author self cc bodycc sob cccmd body all"
1500 _git_send_email ()
1502 case "$cur" in
1503 --confirm=*)
1504 __gitcomp "
1505 $__git_send_email_confirm_options
1506 " "" "${cur##--confirm=}"
1507 return
1509 --suppress-cc=*)
1510 __gitcomp "
1511 $__git_send_email_suppresscc_options
1512 " "" "${cur##--suppress-cc=}"
1514 return
1516 --smtp-encryption=*)
1517 __gitcomp "ssl tls" "" "${cur##--smtp-encryption=}"
1518 return
1520 --thread=*)
1521 __gitcomp "
1522 deep shallow
1523 " "" "${cur##--thread=}"
1524 return
1526 --*)
1527 __gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to
1528 --compose --confirm= --dry-run --envelope-sender
1529 --from --identity
1530 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
1531 --no-suppress-from --no-thread --quiet
1532 --signed-off-by-cc --smtp-pass --smtp-server
1533 --smtp-server-port --smtp-encryption= --smtp-user
1534 --subject --suppress-cc= --suppress-from --thread --to
1535 --validate --no-validate
1536 $__git_format_patch_options"
1537 return
1539 esac
1540 __git_complete_revlist
1543 _git_stage ()
1545 _git_add
1548 __git_config_get_set_variables ()
1550 local prevword word config_file= c=$cword
1551 while [ $c -gt 1 ]; do
1552 word="${words[c]}"
1553 case "$word" in
1554 --global|--system|--file=*)
1555 config_file="$word"
1556 break
1558 -f|--file)
1559 config_file="$word $prevword"
1560 break
1562 esac
1563 prevword=$word
1564 c=$((--c))
1565 done
1567 git --git-dir="$(__gitdir)" config $config_file --list 2>/dev/null |
1568 while read -r line
1570 case "$line" in
1571 *.*=*)
1572 echo "${line/=*/}"
1574 esac
1575 done
1578 _git_config ()
1580 case "$prev" in
1581 branch.*.remote)
1582 __gitcomp_nl "$(__git_remotes)"
1583 return
1585 branch.*.merge)
1586 __gitcomp_nl "$(__git_refs)"
1587 return
1589 remote.*.fetch)
1590 local remote="${prev#remote.}"
1591 remote="${remote%.fetch}"
1592 if [ -z "$cur" ]; then
1593 COMPREPLY=("refs/heads/")
1594 return
1596 __gitcomp_nl "$(__git_refs_remotes "$remote")"
1597 return
1599 remote.*.push)
1600 local remote="${prev#remote.}"
1601 remote="${remote%.push}"
1602 __gitcomp_nl "$(git --git-dir="$(__gitdir)" \
1603 for-each-ref --format='%(refname):%(refname)' \
1604 refs/heads)"
1605 return
1607 pull.twohead|pull.octopus)
1608 __git_compute_merge_strategies
1609 __gitcomp "$__git_merge_strategies"
1610 return
1612 color.branch|color.diff|color.interactive|\
1613 color.showbranch|color.status|color.ui)
1614 __gitcomp "always never auto"
1615 return
1617 color.pager)
1618 __gitcomp "false true"
1619 return
1621 color.*.*)
1622 __gitcomp "
1623 normal black red green yellow blue magenta cyan white
1624 bold dim ul blink reverse
1626 return
1628 help.format)
1629 __gitcomp "man info web html"
1630 return
1632 log.date)
1633 __gitcomp "$__git_log_date_formats"
1634 return
1636 sendemail.aliasesfiletype)
1637 __gitcomp "mutt mailrc pine elm gnus"
1638 return
1640 sendemail.confirm)
1641 __gitcomp "$__git_send_email_confirm_options"
1642 return
1644 sendemail.suppresscc)
1645 __gitcomp "$__git_send_email_suppresscc_options"
1646 return
1648 --get|--get-all|--unset|--unset-all)
1649 __gitcomp_nl "$(__git_config_get_set_variables)"
1650 return
1652 *.*)
1653 COMPREPLY=()
1654 return
1656 esac
1657 case "$cur" in
1658 --*)
1659 __gitcomp "
1660 --global --system --file=
1661 --list --replace-all
1662 --get --get-all --get-regexp
1663 --add --unset --unset-all
1664 --remove-section --rename-section
1666 return
1668 branch.*.*)
1669 local pfx="${cur%.*}." cur_="${cur##*.}"
1670 __gitcomp "remote merge mergeoptions rebase" "$pfx" "$cur_"
1671 return
1673 branch.*)
1674 local pfx="${cur%.*}." cur_="${cur#*.}"
1675 __gitcomp_nl "$(__git_heads)" "$pfx" "$cur_" "."
1676 return
1678 guitool.*.*)
1679 local pfx="${cur%.*}." cur_="${cur##*.}"
1680 __gitcomp "
1681 argprompt cmd confirm needsfile noconsole norescan
1682 prompt revprompt revunmerged title
1683 " "$pfx" "$cur_"
1684 return
1686 difftool.*.*)
1687 local pfx="${cur%.*}." cur_="${cur##*.}"
1688 __gitcomp "cmd path" "$pfx" "$cur_"
1689 return
1691 man.*.*)
1692 local pfx="${cur%.*}." cur_="${cur##*.}"
1693 __gitcomp "cmd path" "$pfx" "$cur_"
1694 return
1696 mergetool.*.*)
1697 local pfx="${cur%.*}." cur_="${cur##*.}"
1698 __gitcomp "cmd path trustExitCode" "$pfx" "$cur_"
1699 return
1701 pager.*)
1702 local pfx="${cur%.*}." cur_="${cur#*.}"
1703 __git_compute_all_commands
1704 __gitcomp_nl "$__git_all_commands" "$pfx" "$cur_"
1705 return
1707 remote.*.*)
1708 local pfx="${cur%.*}." cur_="${cur##*.}"
1709 __gitcomp "
1710 url proxy fetch push mirror skipDefaultUpdate
1711 receivepack uploadpack tagopt pushurl
1712 " "$pfx" "$cur_"
1713 return
1715 remote.*)
1716 local pfx="${cur%.*}." cur_="${cur#*.}"
1717 __gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "."
1718 return
1720 url.*.*)
1721 local pfx="${cur%.*}." cur_="${cur##*.}"
1722 __gitcomp "insteadOf pushInsteadOf" "$pfx" "$cur_"
1723 return
1725 esac
1726 __gitcomp "
1727 add.ignoreErrors
1728 advice.commitBeforeMerge
1729 advice.detachedHead
1730 advice.implicitIdentity
1731 advice.pushNonFastForward
1732 advice.resolveConflict
1733 advice.statusHints
1734 alias.
1735 am.keepcr
1736 apply.ignorewhitespace
1737 apply.whitespace
1738 branch.autosetupmerge
1739 branch.autosetuprebase
1740 browser.
1741 clean.requireForce
1742 color.branch
1743 color.branch.current
1744 color.branch.local
1745 color.branch.plain
1746 color.branch.remote
1747 color.decorate.HEAD
1748 color.decorate.branch
1749 color.decorate.remoteBranch
1750 color.decorate.stash
1751 color.decorate.tag
1752 color.diff
1753 color.diff.commit
1754 color.diff.frag
1755 color.diff.func
1756 color.diff.meta
1757 color.diff.new
1758 color.diff.old
1759 color.diff.plain
1760 color.diff.whitespace
1761 color.grep
1762 color.grep.context
1763 color.grep.filename
1764 color.grep.function
1765 color.grep.linenumber
1766 color.grep.match
1767 color.grep.selected
1768 color.grep.separator
1769 color.interactive
1770 color.interactive.error
1771 color.interactive.header
1772 color.interactive.help
1773 color.interactive.prompt
1774 color.pager
1775 color.showbranch
1776 color.status
1777 color.status.added
1778 color.status.changed
1779 color.status.header
1780 color.status.nobranch
1781 color.status.untracked
1782 color.status.updated
1783 color.ui
1784 commit.status
1785 commit.template
1786 core.abbrev
1787 core.askpass
1788 core.attributesfile
1789 core.autocrlf
1790 core.bare
1791 core.bigFileThreshold
1792 core.compression
1793 core.createObject
1794 core.deltaBaseCacheLimit
1795 core.editor
1796 core.eol
1797 core.excludesfile
1798 core.fileMode
1799 core.fsyncobjectfiles
1800 core.gitProxy
1801 core.ignoreCygwinFSTricks
1802 core.ignoreStat
1803 core.ignorecase
1804 core.logAllRefUpdates
1805 core.loosecompression
1806 core.notesRef
1807 core.packedGitLimit
1808 core.packedGitWindowSize
1809 core.pager
1810 core.preferSymlinkRefs
1811 core.preloadindex
1812 core.quotepath
1813 core.repositoryFormatVersion
1814 core.safecrlf
1815 core.sharedRepository
1816 core.sparseCheckout
1817 core.symlinks
1818 core.trustctime
1819 core.warnAmbiguousRefs
1820 core.whitespace
1821 core.worktree
1822 diff.autorefreshindex
1823 diff.statGraphWidth
1824 diff.external
1825 diff.ignoreSubmodules
1826 diff.mnemonicprefix
1827 diff.noprefix
1828 diff.renameLimit
1829 diff.renames
1830 diff.suppressBlankEmpty
1831 diff.tool
1832 diff.wordRegex
1833 difftool.
1834 difftool.prompt
1835 fetch.recurseSubmodules
1836 fetch.unpackLimit
1837 format.attach
1838 format.cc
1839 format.headers
1840 format.numbered
1841 format.pretty
1842 format.signature
1843 format.signoff
1844 format.subjectprefix
1845 format.suffix
1846 format.thread
1847 format.to
1849 gc.aggressiveWindow
1850 gc.auto
1851 gc.autopacklimit
1852 gc.packrefs
1853 gc.pruneexpire
1854 gc.reflogexpire
1855 gc.reflogexpireunreachable
1856 gc.rerereresolved
1857 gc.rerereunresolved
1858 gitcvs.allbinary
1859 gitcvs.commitmsgannotation
1860 gitcvs.dbTableNamePrefix
1861 gitcvs.dbdriver
1862 gitcvs.dbname
1863 gitcvs.dbpass
1864 gitcvs.dbuser
1865 gitcvs.enabled
1866 gitcvs.logfile
1867 gitcvs.usecrlfattr
1868 guitool.
1869 gui.blamehistoryctx
1870 gui.commitmsgwidth
1871 gui.copyblamethreshold
1872 gui.diffcontext
1873 gui.encoding
1874 gui.fastcopyblame
1875 gui.matchtrackingbranch
1876 gui.newbranchtemplate
1877 gui.pruneduringfetch
1878 gui.spellingdictionary
1879 gui.trustmtime
1880 help.autocorrect
1881 help.browser
1882 help.format
1883 http.lowSpeedLimit
1884 http.lowSpeedTime
1885 http.maxRequests
1886 http.minSessions
1887 http.noEPSV
1888 http.postBuffer
1889 http.proxy
1890 http.sslCAInfo
1891 http.sslCAPath
1892 http.sslCert
1893 http.sslCertPasswordProtected
1894 http.sslKey
1895 http.sslVerify
1896 http.useragent
1897 i18n.commitEncoding
1898 i18n.logOutputEncoding
1899 imap.authMethod
1900 imap.folder
1901 imap.host
1902 imap.pass
1903 imap.port
1904 imap.preformattedHTML
1905 imap.sslverify
1906 imap.tunnel
1907 imap.user
1908 init.templatedir
1909 instaweb.browser
1910 instaweb.httpd
1911 instaweb.local
1912 instaweb.modulepath
1913 instaweb.port
1914 interactive.singlekey
1915 log.date
1916 log.decorate
1917 log.showroot
1918 mailmap.file
1919 man.
1920 man.viewer
1921 merge.
1922 merge.conflictstyle
1923 merge.log
1924 merge.renameLimit
1925 merge.renormalize
1926 merge.stat
1927 merge.tool
1928 merge.verbosity
1929 mergetool.
1930 mergetool.keepBackup
1931 mergetool.keepTemporaries
1932 mergetool.prompt
1933 notes.displayRef
1934 notes.rewrite.
1935 notes.rewrite.amend
1936 notes.rewrite.rebase
1937 notes.rewriteMode
1938 notes.rewriteRef
1939 pack.compression
1940 pack.deltaCacheLimit
1941 pack.deltaCacheSize
1942 pack.depth
1943 pack.indexVersion
1944 pack.packSizeLimit
1945 pack.threads
1946 pack.window
1947 pack.windowMemory
1948 pager.
1949 pretty.
1950 pull.octopus
1951 pull.twohead
1952 push.default
1953 rebase.autosquash
1954 rebase.stat
1955 receive.autogc
1956 receive.denyCurrentBranch
1957 receive.denyDeleteCurrent
1958 receive.denyDeletes
1959 receive.denyNonFastForwards
1960 receive.fsckObjects
1961 receive.unpackLimit
1962 receive.updateserverinfo
1963 remotes.
1964 repack.usedeltabaseoffset
1965 rerere.autoupdate
1966 rerere.enabled
1967 sendemail.
1968 sendemail.aliasesfile
1969 sendemail.aliasfiletype
1970 sendemail.bcc
1971 sendemail.cc
1972 sendemail.cccmd
1973 sendemail.chainreplyto
1974 sendemail.confirm
1975 sendemail.envelopesender
1976 sendemail.from
1977 sendemail.identity
1978 sendemail.multiedit
1979 sendemail.signedoffbycc
1980 sendemail.smtpdomain
1981 sendemail.smtpencryption
1982 sendemail.smtppass
1983 sendemail.smtpserver
1984 sendemail.smtpserveroption
1985 sendemail.smtpserverport
1986 sendemail.smtpuser
1987 sendemail.suppresscc
1988 sendemail.suppressfrom
1989 sendemail.thread
1990 sendemail.to
1991 sendemail.validate
1992 showbranch.default
1993 status.relativePaths
1994 status.showUntrackedFiles
1995 status.submodulesummary
1996 submodule.
1997 tar.umask
1998 transfer.unpackLimit
1999 url.
2000 user.email
2001 user.name
2002 user.signingkey
2003 web.browser
2004 branch. remote.
2008 _git_remote ()
2010 local subcommands="add rename remove set-head set-branches set-url show prune update"
2011 local subcommand="$(__git_find_on_cmdline "$subcommands")"
2012 if [ -z "$subcommand" ]; then
2013 __gitcomp "$subcommands"
2014 return
2017 case "$subcommand" in
2018 rename|remove|set-url|show|prune)
2019 __gitcomp_nl "$(__git_remotes)"
2021 set-head|set-branches)
2022 __git_complete_remote_or_refspec
2024 update)
2025 local i c='' IFS=$'\n'
2026 for i in $(git --git-dir="$(__gitdir)" config --get-regexp "remotes\..*" 2>/dev/null); do
2027 i="${i#remotes.}"
2028 c="$c ${i/ */}"
2029 done
2030 __gitcomp "$c"
2033 COMPREPLY=()
2035 esac
2038 _git_replace ()
2040 __gitcomp_nl "$(__git_refs)"
2043 _git_reset ()
2045 __git_has_doubledash && return
2047 case "$cur" in
2048 --*)
2049 __gitcomp "--merge --mixed --hard --soft --patch"
2050 return
2052 esac
2053 __gitcomp_nl "$(__git_refs)"
2056 _git_revert ()
2058 case "$cur" in
2059 --*)
2060 __gitcomp "--edit --mainline --no-edit --no-commit --signoff"
2061 return
2063 esac
2064 __gitcomp_nl "$(__git_refs)"
2067 _git_rm ()
2069 __git_has_doubledash && return
2071 case "$cur" in
2072 --*)
2073 __gitcomp "--cached --dry-run --ignore-unmatch --quiet"
2074 return
2076 esac
2077 COMPREPLY=()
2080 _git_shortlog ()
2082 __git_has_doubledash && return
2084 case "$cur" in
2085 --*)
2086 __gitcomp "
2087 $__git_log_common_options
2088 $__git_log_shortlog_options
2089 --numbered --summary
2091 return
2093 esac
2094 __git_complete_revlist
2097 _git_show ()
2099 __git_has_doubledash && return
2101 case "$cur" in
2102 --pretty=*|--format=*)
2103 __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
2104 " "" "${cur#*=}"
2105 return
2107 --*)
2108 __gitcomp "--pretty= --format= --abbrev-commit --oneline
2109 $__git_diff_common_options
2111 return
2113 esac
2114 __git_complete_file
2117 _git_show_branch ()
2119 case "$cur" in
2120 --*)
2121 __gitcomp "
2122 --all --remotes --topo-order --current --more=
2123 --list --independent --merge-base --no-name
2124 --color --no-color
2125 --sha1-name --sparse --topics --reflog
2127 return
2129 esac
2130 __git_complete_revlist
2133 _git_stash ()
2135 local save_opts='--keep-index --no-keep-index --quiet --patch'
2136 local subcommands='save list show apply clear drop pop create branch'
2137 local subcommand="$(__git_find_on_cmdline "$subcommands")"
2138 if [ -z "$subcommand" ]; then
2139 case "$cur" in
2140 --*)
2141 __gitcomp "$save_opts"
2144 if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then
2145 __gitcomp "$subcommands"
2146 else
2147 COMPREPLY=()
2150 esac
2151 else
2152 case "$subcommand,$cur" in
2153 save,--*)
2154 __gitcomp "$save_opts"
2156 apply,--*|pop,--*)
2157 __gitcomp "--index --quiet"
2159 show,--*|drop,--*|branch,--*)
2160 COMPREPLY=()
2162 show,*|apply,*|drop,*|pop,*|branch,*)
2163 __gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \
2164 | sed -n -e 's/:.*//p')"
2167 COMPREPLY=()
2169 esac
2173 _git_submodule ()
2175 __git_has_doubledash && return
2177 local subcommands="add status init update summary foreach sync"
2178 if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then
2179 case "$cur" in
2180 --*)
2181 __gitcomp "--quiet --cached"
2184 __gitcomp "$subcommands"
2186 esac
2187 return
2191 _git_svn ()
2193 local subcommands="
2194 init fetch clone rebase dcommit log find-rev
2195 set-tree commit-diff info create-ignore propget
2196 proplist show-ignore show-externals branch tag blame
2197 migrate mkdirs reset gc
2199 local subcommand="$(__git_find_on_cmdline "$subcommands")"
2200 if [ -z "$subcommand" ]; then
2201 __gitcomp "$subcommands"
2202 else
2203 local remote_opts="--username= --config-dir= --no-auth-cache"
2204 local fc_opts="
2205 --follow-parent --authors-file= --repack=
2206 --no-metadata --use-svm-props --use-svnsync-props
2207 --log-window-size= --no-checkout --quiet
2208 --repack-flags --use-log-author --localtime
2209 --ignore-paths= $remote_opts
2211 local init_opts="
2212 --template= --shared= --trunk= --tags=
2213 --branches= --stdlayout --minimize-url
2214 --no-metadata --use-svm-props --use-svnsync-props
2215 --rewrite-root= --prefix= --use-log-author
2216 --add-author-from $remote_opts
2218 local cmt_opts="
2219 --edit --rmdir --find-copies-harder --copy-similarity=
2222 case "$subcommand,$cur" in
2223 fetch,--*)
2224 __gitcomp "--revision= --fetch-all $fc_opts"
2226 clone,--*)
2227 __gitcomp "--revision= $fc_opts $init_opts"
2229 init,--*)
2230 __gitcomp "$init_opts"
2232 dcommit,--*)
2233 __gitcomp "
2234 --merge --strategy= --verbose --dry-run
2235 --fetch-all --no-rebase --commit-url
2236 --revision --interactive $cmt_opts $fc_opts
2239 set-tree,--*)
2240 __gitcomp "--stdin $cmt_opts $fc_opts"
2242 create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\
2243 show-externals,--*|mkdirs,--*)
2244 __gitcomp "--revision="
2246 log,--*)
2247 __gitcomp "
2248 --limit= --revision= --verbose --incremental
2249 --oneline --show-commit --non-recursive
2250 --authors-file= --color
2253 rebase,--*)
2254 __gitcomp "
2255 --merge --verbose --strategy= --local
2256 --fetch-all --dry-run $fc_opts
2259 commit-diff,--*)
2260 __gitcomp "--message= --file= --revision= $cmt_opts"
2262 info,--*)
2263 __gitcomp "--url"
2265 branch,--*)
2266 __gitcomp "--dry-run --message --tag"
2268 tag,--*)
2269 __gitcomp "--dry-run --message"
2271 blame,--*)
2272 __gitcomp "--git-format"
2274 migrate,--*)
2275 __gitcomp "
2276 --config-dir= --ignore-paths= --minimize
2277 --no-auth-cache --username=
2280 reset,--*)
2281 __gitcomp "--revision= --parent"
2284 COMPREPLY=()
2286 esac
2290 _git_tag ()
2292 local i c=1 f=0
2293 while [ $c -lt $cword ]; do
2294 i="${words[c]}"
2295 case "$i" in
2296 -d|-v)
2297 __gitcomp_nl "$(__git_tags)"
2298 return
2303 esac
2304 ((c++))
2305 done
2307 case "$prev" in
2308 -m|-F)
2309 COMPREPLY=()
2311 -*|tag)
2312 if [ $f = 1 ]; then
2313 __gitcomp_nl "$(__git_tags)"
2314 else
2315 COMPREPLY=()
2319 __gitcomp_nl "$(__git_refs)"
2321 esac
2324 _git_whatchanged ()
2326 _git_log
2329 __git_main ()
2331 local i c=1 command __git_dir
2333 while [ $c -lt $cword ]; do
2334 i="${words[c]}"
2335 case "$i" in
2336 --git-dir=*) __git_dir="${i#--git-dir=}" ;;
2337 --bare) __git_dir="." ;;
2338 --help) command="help"; break ;;
2339 -c) c=$((++c)) ;;
2340 -*) ;;
2341 *) command="$i"; break ;;
2342 esac
2343 ((c++))
2344 done
2346 if [ -z "$command" ]; then
2347 case "$cur" in
2348 --*) __gitcomp "
2349 --paginate
2350 --no-pager
2351 --git-dir=
2352 --bare
2353 --version
2354 --exec-path
2355 --exec-path=
2356 --html-path
2357 --info-path
2358 --work-tree=
2359 --namespace=
2360 --no-replace-objects
2361 --help
2364 *) __git_compute_porcelain_commands
2365 __gitcomp "$__git_porcelain_commands $(__git_aliases)" ;;
2366 esac
2367 return
2370 local completion_func="_git_${command//-/_}"
2371 declare -f $completion_func >/dev/null && $completion_func && return
2373 local expansion=$(__git_aliased_command "$command")
2374 if [ -n "$expansion" ]; then
2375 completion_func="_git_${expansion//-/_}"
2376 declare -f $completion_func >/dev/null && $completion_func
2380 __gitk_main ()
2382 __git_has_doubledash && return
2384 local g="$(__gitdir)"
2385 local merge=""
2386 if [ -f "$g/MERGE_HEAD" ]; then
2387 merge="--merge"
2389 case "$cur" in
2390 --*)
2391 __gitcomp "
2392 $__git_log_common_options
2393 $__git_log_gitk_options
2394 $merge
2396 return
2398 esac
2399 __git_complete_revlist
2402 if [[ -n ${ZSH_VERSION-} ]]; then
2403 echo "WARNING: this script is deprecated, please see git-completion.zsh" 1>&2
2405 __gitcomp ()
2407 emulate -L zsh
2409 local cur_="${3-$cur}"
2411 case "$cur_" in
2412 --*=)
2415 local c IFS=$' \t\n'
2416 local -a array
2417 for c in ${=1}; do
2418 c="$c${4-}"
2419 case $c in
2420 --*=*|*.) ;;
2421 *) c="$c " ;;
2422 esac
2423 array+=("$c")
2424 done
2425 compset -P '*[=:]'
2426 compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
2428 esac
2431 __gitcomp_nl ()
2433 emulate -L zsh
2435 local IFS=$'\n'
2436 compset -P '*[=:]'
2437 compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
2440 __git_zsh_helper ()
2442 emulate -L ksh
2443 local cur cword prev
2444 cur=${words[CURRENT-1]}
2445 prev=${words[CURRENT-2]}
2446 let cword=CURRENT-1
2447 __${service}_main
2450 _git ()
2452 emulate -L zsh
2453 local _ret=1
2454 __git_zsh_helper
2455 let _ret && _default -S '' && _ret=0
2456 return _ret
2459 compdef _git git gitk
2460 return
2463 __git_func_wrap ()
2465 local cur words cword prev
2466 _get_comp_words_by_ref -n =: cur words cword prev
2470 # Setup completion for certain functions defined above by setting common
2471 # variables and workarounds.
2472 # This is NOT a public function; use at your own risk.
2473 __git_complete ()
2475 local wrapper="__git_wrap${2}"
2476 eval "$wrapper () { __git_func_wrap $2 ; }"
2477 complete -o bashdefault -o default -o nospace -F $wrapper $1 2>/dev/null \
2478 || complete -o default -o nospace -F $wrapper $1
2481 # wrapper for backwards compatibility
2482 _git ()
2484 __git_wrap__git_main
2487 # wrapper for backwards compatibility
2488 _gitk ()
2490 __git_wrap__gitk_main
2493 __git_complete git __git_main
2494 __git_complete gitk __gitk_main
2496 # The following are necessary only for Cygwin, and only are needed
2497 # when the user has tab-completed the executable name and consequently
2498 # included the '.exe' suffix.
2500 if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
2501 __git_complete git.exe __git_main