completion: complete branch name for "branch --set-upstream-to="
[git/dscho.git] / contrib / completion / git-completion.bash
blobe48cf8001241502e9dc4310895b136f8c7534e6b
1 #!bash
3 # bash/zsh completion support for core Git.
5 # Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
6 # Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
7 # Distributed under the GNU General Public License, version 2.0.
9 # The contained completion routines provide support for completing:
11 # *) local and remote branch names
12 # *) local and remote tag names
13 # *) .git/remotes file names
14 # *) git 'subcommands'
15 # *) tree paths within 'ref:path/to/file' expressions
16 # *) common --long-options
18 # To use these routines:
20 # 1) Copy this file to somewhere (e.g. ~/.git-completion.sh).
21 # 2) Add the following line to your .bashrc/.zshrc:
22 # source ~/.git-completion.sh
23 # 3) Consider changing your PS1 to also show the current branch,
24 # see git-prompt.sh for details.
26 if [[ -n ${ZSH_VERSION-} ]]; then
27 autoload -U +X bashcompinit && bashcompinit
30 case "$COMP_WORDBREAKS" in
31 *:*) : great ;;
32 *) COMP_WORDBREAKS="$COMP_WORDBREAKS:"
33 esac
35 # __gitdir accepts 0 or 1 arguments (i.e., location)
36 # returns location of .git repo
37 __gitdir ()
39 # Note: this function is duplicated in git-prompt.sh
40 # When updating it, make sure you update the other one to match.
41 if [ -z "${1-}" ]; then
42 if [ -n "${__git_dir-}" ]; then
43 echo "$__git_dir"
44 elif [ -n "${GIT_DIR-}" ]; then
45 test -d "${GIT_DIR-}" || return 1
46 echo "$GIT_DIR"
47 elif [ -d .git ]; then
48 echo .git
49 else
50 git rev-parse --git-dir 2>/dev/null
52 elif [ -d "$1/.git" ]; then
53 echo "$1/.git"
54 else
55 echo "$1"
59 __gitcomp_1 ()
61 local c IFS=$' \t\n'
62 for c in $1; do
63 c="$c$2"
64 case $c in
65 --*=*|*.) ;;
66 *) c="$c " ;;
67 esac
68 printf '%s\n' "$c"
69 done
72 # The following function is based on code from:
74 # bash_completion - programmable completion functions for bash 3.2+
76 # Copyright © 2006-2008, Ian Macdonald <ian@caliban.org>
77 # © 2009-2010, Bash Completion Maintainers
78 # <bash-completion-devel@lists.alioth.debian.org>
80 # This program is free software; you can redistribute it and/or modify
81 # it under the terms of the GNU General Public License as published by
82 # the Free Software Foundation; either version 2, or (at your option)
83 # any later version.
85 # This program is distributed in the hope that it will be useful,
86 # but WITHOUT ANY WARRANTY; without even the implied warranty of
87 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
88 # GNU General Public License for more details.
90 # You should have received a copy of the GNU General Public License
91 # along with this program; if not, write to the Free Software Foundation,
92 # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
94 # The latest version of this software can be obtained here:
96 # http://bash-completion.alioth.debian.org/
98 # RELEASE: 2.x
100 # This function can be used to access a tokenized list of words
101 # on the command line:
103 # __git_reassemble_comp_words_by_ref '=:'
104 # if test "${words_[cword_-1]}" = -w
105 # then
106 # ...
107 # fi
109 # The argument should be a collection of characters from the list of
110 # word completion separators (COMP_WORDBREAKS) to treat as ordinary
111 # characters.
113 # This is roughly equivalent to going back in time and setting
114 # COMP_WORDBREAKS to exclude those characters. The intent is to
115 # make option types like --date=<type> and <rev>:<path> easy to
116 # recognize by treating each shell word as a single token.
118 # It is best not to set COMP_WORDBREAKS directly because the value is
119 # shared with other completion scripts. By the time the completion
120 # function gets called, COMP_WORDS has already been populated so local
121 # changes to COMP_WORDBREAKS have no effect.
123 # Output: words_, cword_, cur_.
125 __git_reassemble_comp_words_by_ref()
127 local exclude i j first
128 # Which word separators to exclude?
129 exclude="${1//[^$COMP_WORDBREAKS]}"
130 cword_=$COMP_CWORD
131 if [ -z "$exclude" ]; then
132 words_=("${COMP_WORDS[@]}")
133 return
135 # List of word completion separators has shrunk;
136 # re-assemble words to complete.
137 for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)); do
138 # Append each nonempty word consisting of just
139 # word separator characters to the current word.
140 first=t
141 while
142 [ $i -gt 0 ] &&
143 [ -n "${COMP_WORDS[$i]}" ] &&
144 # word consists of excluded word separators
145 [ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ]
147 # Attach to the previous token,
148 # unless the previous token is the command name.
149 if [ $j -ge 2 ] && [ -n "$first" ]; then
150 ((j--))
152 first=
153 words_[$j]=${words_[j]}${COMP_WORDS[i]}
154 if [ $i = $COMP_CWORD ]; then
155 cword_=$j
157 if (($i < ${#COMP_WORDS[@]} - 1)); then
158 ((i++))
159 else
160 # Done.
161 return
163 done
164 words_[$j]=${words_[j]}${COMP_WORDS[i]}
165 if [ $i = $COMP_CWORD ]; then
166 cword_=$j
168 done
171 if ! type _get_comp_words_by_ref >/dev/null 2>&1; then
172 if [[ -z ${ZSH_VERSION:+set} ]]; then
173 _get_comp_words_by_ref ()
175 local exclude cur_ words_ cword_
176 if [ "$1" = "-n" ]; then
177 exclude=$2
178 shift 2
180 __git_reassemble_comp_words_by_ref "$exclude"
181 cur_=${words_[cword_]}
182 while [ $# -gt 0 ]; do
183 case "$1" in
184 cur)
185 cur=$cur_
187 prev)
188 prev=${words_[$cword_-1]}
190 words)
191 words=("${words_[@]}")
193 cword)
194 cword=$cword_
196 esac
197 shift
198 done
200 else
201 _get_comp_words_by_ref ()
203 while [ $# -gt 0 ]; do
204 case "$1" in
205 cur)
206 cur=${COMP_WORDS[COMP_CWORD]}
208 prev)
209 prev=${COMP_WORDS[COMP_CWORD-1]}
211 words)
212 words=("${COMP_WORDS[@]}")
214 cword)
215 cword=$COMP_CWORD
218 # assume COMP_WORDBREAKS is already set sanely
219 shift
221 esac
222 shift
223 done
228 # Generates completion reply with compgen, appending a space to possible
229 # completion words, if necessary.
230 # It accepts 1 to 4 arguments:
231 # 1: List of possible completion words.
232 # 2: A prefix to be added to each possible completion word (optional).
233 # 3: Generate possible completion matches for this word (optional).
234 # 4: A suffix to be appended to each possible completion word (optional).
235 __gitcomp ()
237 local cur_="${3-$cur}"
239 case "$cur_" in
240 --*=)
241 COMPREPLY=()
244 local IFS=$'\n'
245 COMPREPLY=($(compgen -P "${2-}" \
246 -W "$(__gitcomp_1 "${1-}" "${4-}")" \
247 -- "$cur_"))
249 esac
252 # Generates completion reply with compgen from newline-separated possible
253 # completion words by appending a space to all of them.
254 # It accepts 1 to 4 arguments:
255 # 1: List of possible completion words, separated by a single newline.
256 # 2: A prefix to be added to each possible completion word (optional).
257 # 3: Generate possible completion matches for this word (optional).
258 # 4: A suffix to be appended to each possible completion word instead of
259 # the default space (optional). If specified but empty, nothing is
260 # appended.
261 __gitcomp_nl ()
263 local IFS=$'\n'
264 COMPREPLY=($(compgen -P "${2-}" -S "${4- }" -W "$1" -- "${3-$cur}"))
267 __git_heads ()
269 local dir="$(__gitdir)"
270 if [ -d "$dir" ]; then
271 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
272 refs/heads
273 return
277 __git_tags ()
279 local dir="$(__gitdir)"
280 if [ -d "$dir" ]; then
281 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
282 refs/tags
283 return
287 # __git_refs accepts 0, 1 (to pass to __gitdir), or 2 arguments
288 # presence of 2nd argument means use the guess heuristic employed
289 # by checkout for tracking branches
290 __git_refs ()
292 local i hash dir="$(__gitdir "${1-}")" track="${2-}"
293 local format refs
294 if [ -d "$dir" ]; then
295 case "$cur" in
296 refs|refs/*)
297 format="refname"
298 refs="${cur%/*}"
299 track=""
302 for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do
303 if [ -e "$dir/$i" ]; then echo $i; fi
304 done
305 format="refname:short"
306 refs="refs/tags refs/heads refs/remotes"
308 esac
309 git --git-dir="$dir" for-each-ref --format="%($format)" \
310 $refs
311 if [ -n "$track" ]; then
312 # employ the heuristic used by git checkout
313 # Try to find a remote branch that matches the completion word
314 # but only output if the branch name is unique
315 local ref entry
316 git --git-dir="$dir" for-each-ref --shell --format="ref=%(refname:short)" \
317 "refs/remotes/" | \
318 while read -r entry; do
319 eval "$entry"
320 ref="${ref#*/}"
321 if [[ "$ref" == "$cur"* ]]; then
322 echo "$ref"
324 done | uniq -u
326 return
328 case "$cur" in
329 refs|refs/*)
330 git ls-remote "$dir" "$cur*" 2>/dev/null | \
331 while read -r hash i; do
332 case "$i" in
333 *^{}) ;;
334 *) echo "$i" ;;
335 esac
336 done
339 git ls-remote "$dir" HEAD ORIG_HEAD 'refs/tags/*' 'refs/heads/*' 'refs/remotes/*' 2>/dev/null | \
340 while read -r hash i; do
341 case "$i" in
342 *^{}) ;;
343 refs/*) echo "${i#refs/*/}" ;;
344 *) echo "$i" ;;
345 esac
346 done
348 esac
351 # __git_refs2 requires 1 argument (to pass to __git_refs)
352 __git_refs2 ()
354 local i
355 for i in $(__git_refs "$1"); do
356 echo "$i:$i"
357 done
360 # __git_refs_remotes requires 1 argument (to pass to ls-remote)
361 __git_refs_remotes ()
363 local i hash
364 git ls-remote "$1" 'refs/heads/*' 2>/dev/null | \
365 while read -r hash i; do
366 echo "$i:refs/remotes/$1/${i#refs/heads/}"
367 done
370 __git_remotes ()
372 local i IFS=$'\n' d="$(__gitdir)"
373 test -d "$d/remotes" && ls -1 "$d/remotes"
374 for i in $(git --git-dir="$d" config --get-regexp 'remote\..*\.url' 2>/dev/null); do
375 i="${i#remote.}"
376 echo "${i/.url*/}"
377 done
380 __git_list_merge_strategies ()
382 git merge -s help 2>&1 |
383 sed -n -e '/[Aa]vailable strategies are: /,/^$/{
384 s/\.$//
385 s/.*://
386 s/^[ ]*//
387 s/[ ]*$//
392 __git_merge_strategies=
393 # 'git merge -s help' (and thus detection of the merge strategy
394 # list) fails, unfortunately, if run outside of any git working
395 # tree. __git_merge_strategies is set to the empty string in
396 # that case, and the detection will be repeated the next time it
397 # is needed.
398 __git_compute_merge_strategies ()
400 test -n "$__git_merge_strategies" ||
401 __git_merge_strategies=$(__git_list_merge_strategies)
404 __git_complete_revlist_file ()
406 local pfx ls ref cur_="$cur"
407 case "$cur_" in
408 *..?*:*)
409 return
411 ?*:*)
412 ref="${cur_%%:*}"
413 cur_="${cur_#*:}"
414 case "$cur_" in
415 ?*/*)
416 pfx="${cur_%/*}"
417 cur_="${cur_##*/}"
418 ls="$ref:$pfx"
419 pfx="$pfx/"
422 ls="$ref"
424 esac
426 case "$COMP_WORDBREAKS" in
427 *:*) : great ;;
428 *) pfx="$ref:$pfx" ;;
429 esac
431 __gitcomp_nl "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \
432 | sed '/^100... blob /{
433 s,^.* ,,
434 s,$, ,
436 /^120000 blob /{
437 s,^.* ,,
438 s,$, ,
440 /^040000 tree /{
441 s,^.* ,,
442 s,$,/,
444 s/^.* //')" \
445 "$pfx" "$cur_" ""
447 *...*)
448 pfx="${cur_%...*}..."
449 cur_="${cur_#*...}"
450 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
452 *..*)
453 pfx="${cur_%..*}.."
454 cur_="${cur_#*..}"
455 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
458 __gitcomp_nl "$(__git_refs)"
460 esac
464 __git_complete_file ()
466 __git_complete_revlist_file
469 __git_complete_revlist ()
471 __git_complete_revlist_file
474 __git_complete_remote_or_refspec ()
476 local cur_="$cur" cmd="${words[1]}"
477 local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0
478 if [ "$cmd" = "remote" ]; then
479 ((c++))
481 while [ $c -lt $cword ]; do
482 i="${words[c]}"
483 case "$i" in
484 --mirror) [ "$cmd" = "push" ] && no_complete_refspec=1 ;;
485 --all)
486 case "$cmd" in
487 push) no_complete_refspec=1 ;;
488 fetch)
489 COMPREPLY=()
490 return
492 *) ;;
493 esac
495 -*) ;;
496 *) remote="$i"; break ;;
497 esac
498 ((c++))
499 done
500 if [ -z "$remote" ]; then
501 __gitcomp_nl "$(__git_remotes)"
502 return
504 if [ $no_complete_refspec = 1 ]; then
505 COMPREPLY=()
506 return
508 [ "$remote" = "." ] && remote=
509 case "$cur_" in
510 *:*)
511 case "$COMP_WORDBREAKS" in
512 *:*) : great ;;
513 *) pfx="${cur_%%:*}:" ;;
514 esac
515 cur_="${cur_#*:}"
516 lhs=0
519 pfx="+"
520 cur_="${cur_#+}"
522 esac
523 case "$cmd" in
524 fetch)
525 if [ $lhs = 1 ]; then
526 __gitcomp_nl "$(__git_refs2 "$remote")" "$pfx" "$cur_"
527 else
528 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
531 pull|remote)
532 if [ $lhs = 1 ]; then
533 __gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_"
534 else
535 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
538 push)
539 if [ $lhs = 1 ]; then
540 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
541 else
542 __gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_"
545 esac
548 __git_complete_strategy ()
550 __git_compute_merge_strategies
551 case "$prev" in
552 -s|--strategy)
553 __gitcomp "$__git_merge_strategies"
554 return 0
555 esac
556 case "$cur" in
557 --strategy=*)
558 __gitcomp "$__git_merge_strategies" "" "${cur##--strategy=}"
559 return 0
561 esac
562 return 1
565 __git_list_all_commands ()
567 local i IFS=" "$'\n'
568 for i in $(git help -a|egrep '^ [a-zA-Z0-9]')
570 case $i in
571 *--*) : helper pattern;;
572 *) echo $i;;
573 esac
574 done
577 __git_all_commands=
578 __git_compute_all_commands ()
580 test -n "$__git_all_commands" ||
581 __git_all_commands=$(__git_list_all_commands)
584 __git_list_porcelain_commands ()
586 local i IFS=" "$'\n'
587 __git_compute_all_commands
588 for i in "help" $__git_all_commands
590 case $i in
591 *--*) : helper pattern;;
592 applymbox) : ask gittus;;
593 applypatch) : ask gittus;;
594 archimport) : import;;
595 cat-file) : plumbing;;
596 check-attr) : plumbing;;
597 check-ref-format) : plumbing;;
598 checkout-index) : plumbing;;
599 commit-tree) : plumbing;;
600 count-objects) : infrequent;;
601 credential-cache) : credentials helper;;
602 credential-store) : credentials helper;;
603 cvsexportcommit) : export;;
604 cvsimport) : import;;
605 cvsserver) : daemon;;
606 daemon) : daemon;;
607 diff-files) : plumbing;;
608 diff-index) : plumbing;;
609 diff-tree) : plumbing;;
610 fast-import) : import;;
611 fast-export) : export;;
612 fsck-objects) : plumbing;;
613 fetch-pack) : plumbing;;
614 fmt-merge-msg) : plumbing;;
615 for-each-ref) : plumbing;;
616 hash-object) : plumbing;;
617 http-*) : transport;;
618 index-pack) : plumbing;;
619 init-db) : deprecated;;
620 local-fetch) : plumbing;;
621 lost-found) : infrequent;;
622 ls-files) : plumbing;;
623 ls-remote) : plumbing;;
624 ls-tree) : plumbing;;
625 mailinfo) : plumbing;;
626 mailsplit) : plumbing;;
627 merge-*) : plumbing;;
628 mktree) : plumbing;;
629 mktag) : plumbing;;
630 pack-objects) : plumbing;;
631 pack-redundant) : plumbing;;
632 pack-refs) : plumbing;;
633 parse-remote) : plumbing;;
634 patch-id) : plumbing;;
635 peek-remote) : plumbing;;
636 prune) : plumbing;;
637 prune-packed) : plumbing;;
638 quiltimport) : import;;
639 read-tree) : plumbing;;
640 receive-pack) : plumbing;;
641 remote-*) : transport;;
642 repo-config) : deprecated;;
643 rerere) : plumbing;;
644 rev-list) : plumbing;;
645 rev-parse) : plumbing;;
646 runstatus) : plumbing;;
647 sh-setup) : internal;;
648 shell) : daemon;;
649 show-ref) : plumbing;;
650 send-pack) : plumbing;;
651 show-index) : plumbing;;
652 ssh-*) : transport;;
653 stripspace) : plumbing;;
654 symbolic-ref) : plumbing;;
655 tar-tree) : deprecated;;
656 unpack-file) : plumbing;;
657 unpack-objects) : plumbing;;
658 update-index) : plumbing;;
659 update-ref) : plumbing;;
660 update-server-info) : daemon;;
661 upload-archive) : plumbing;;
662 upload-pack) : plumbing;;
663 write-tree) : plumbing;;
664 var) : infrequent;;
665 verify-pack) : infrequent;;
666 verify-tag) : plumbing;;
667 *) echo $i;;
668 esac
669 done
672 __git_porcelain_commands=
673 __git_compute_porcelain_commands ()
675 __git_compute_all_commands
676 test -n "$__git_porcelain_commands" ||
677 __git_porcelain_commands=$(__git_list_porcelain_commands)
680 __git_pretty_aliases ()
682 local i IFS=$'\n'
683 for i in $(git --git-dir="$(__gitdir)" config --get-regexp "pretty\..*" 2>/dev/null); do
684 case "$i" in
685 pretty.*)
686 i="${i#pretty.}"
687 echo "${i/ */}"
689 esac
690 done
693 __git_aliases ()
695 local i IFS=$'\n'
696 for i in $(git --git-dir="$(__gitdir)" config --get-regexp "alias\..*" 2>/dev/null); do
697 case "$i" in
698 alias.*)
699 i="${i#alias.}"
700 echo "${i/ */}"
702 esac
703 done
706 # __git_aliased_command requires 1 argument
707 __git_aliased_command ()
709 local word cmdline=$(git --git-dir="$(__gitdir)" \
710 config --get "alias.$1")
711 for word in $cmdline; do
712 case "$word" in
713 \!gitk|gitk)
714 echo "gitk"
715 return
717 \!*) : shell command alias ;;
718 -*) : option ;;
719 *=*) : setting env ;;
720 git) : git itself ;;
722 echo "$word"
723 return
724 esac
725 done
728 # __git_find_on_cmdline requires 1 argument
729 __git_find_on_cmdline ()
731 local word subcommand c=1
732 while [ $c -lt $cword ]; do
733 word="${words[c]}"
734 for subcommand in $1; do
735 if [ "$subcommand" = "$word" ]; then
736 echo "$subcommand"
737 return
739 done
740 ((c++))
741 done
744 __git_has_doubledash ()
746 local c=1
747 while [ $c -lt $cword ]; do
748 if [ "--" = "${words[c]}" ]; then
749 return 0
751 ((c++))
752 done
753 return 1
756 __git_whitespacelist="nowarn warn error error-all fix"
758 _git_am ()
760 local dir="$(__gitdir)"
761 if [ -d "$dir"/rebase-apply ]; then
762 __gitcomp "--skip --continue --resolved --abort"
763 return
765 case "$cur" in
766 --whitespace=*)
767 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
768 return
770 --*)
771 __gitcomp "
772 --3way --committer-date-is-author-date --ignore-date
773 --ignore-whitespace --ignore-space-change
774 --interactive --keep --no-utf8 --signoff --utf8
775 --whitespace= --scissors
777 return
778 esac
779 COMPREPLY=()
782 _git_apply ()
784 case "$cur" in
785 --whitespace=*)
786 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
787 return
789 --*)
790 __gitcomp "
791 --stat --numstat --summary --check --index
792 --cached --index-info --reverse --reject --unidiff-zero
793 --apply --no-add --exclude=
794 --ignore-whitespace --ignore-space-change
795 --whitespace= --inaccurate-eof --verbose
797 return
798 esac
799 COMPREPLY=()
802 _git_add ()
804 __git_has_doubledash && return
806 case "$cur" in
807 --*)
808 __gitcomp "
809 --interactive --refresh --patch --update --dry-run
810 --ignore-errors --intent-to-add
812 return
813 esac
814 COMPREPLY=()
817 _git_archive ()
819 case "$cur" in
820 --format=*)
821 __gitcomp "$(git archive --list)" "" "${cur##--format=}"
822 return
824 --remote=*)
825 __gitcomp_nl "$(__git_remotes)" "" "${cur##--remote=}"
826 return
828 --*)
829 __gitcomp "
830 --format= --list --verbose
831 --prefix= --remote= --exec=
833 return
835 esac
836 __git_complete_file
839 _git_bisect ()
841 __git_has_doubledash && return
843 local subcommands="start bad good skip reset visualize replay log run"
844 local subcommand="$(__git_find_on_cmdline "$subcommands")"
845 if [ -z "$subcommand" ]; then
846 if [ -f "$(__gitdir)"/BISECT_START ]; then
847 __gitcomp "$subcommands"
848 else
849 __gitcomp "replay start"
851 return
854 case "$subcommand" in
855 bad|good|reset|skip|start)
856 __gitcomp_nl "$(__git_refs)"
859 COMPREPLY=()
861 esac
864 _git_branch ()
866 local i c=1 only_local_ref="n" has_r="n"
868 while [ $c -lt $cword ]; do
869 i="${words[c]}"
870 case "$i" in
871 -d|-m) only_local_ref="y" ;;
872 -r) has_r="y" ;;
873 esac
874 ((c++))
875 done
877 case "$cur" in
878 --set-upstream-to=*)
879 __gitcomp "$(__git_refs)" "" "${cur##--set-upstream-to=}"
881 --*)
882 __gitcomp "
883 --color --no-color --verbose --abbrev= --no-abbrev
884 --track --no-track --contains --merged --no-merged
885 --set-upstream-to= --edit-description --list
886 --unset-upstream
890 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
891 __gitcomp_nl "$(__git_heads)"
892 else
893 __gitcomp_nl "$(__git_refs)"
896 esac
899 _git_bundle ()
901 local cmd="${words[2]}"
902 case "$cword" in
904 __gitcomp "create list-heads verify unbundle"
907 # looking for a file
910 case "$cmd" in
911 create)
912 __git_complete_revlist
914 esac
916 esac
919 _git_checkout ()
921 __git_has_doubledash && return
923 case "$cur" in
924 --conflict=*)
925 __gitcomp "diff3 merge" "" "${cur##--conflict=}"
927 --*)
928 __gitcomp "
929 --quiet --ours --theirs --track --no-track --merge
930 --conflict= --orphan --patch
934 # check if --track, --no-track, or --no-guess was specified
935 # if so, disable DWIM mode
936 local flags="--track --no-track --no-guess" track=1
937 if [ -n "$(__git_find_on_cmdline "$flags")" ]; then
938 track=''
940 __gitcomp_nl "$(__git_refs '' $track)"
942 esac
945 _git_cherry ()
947 __gitcomp "$(__git_refs)"
950 _git_cherry_pick ()
952 case "$cur" in
953 --*)
954 __gitcomp "--edit --no-commit"
957 __gitcomp_nl "$(__git_refs)"
959 esac
962 _git_clean ()
964 __git_has_doubledash && return
966 case "$cur" in
967 --*)
968 __gitcomp "--dry-run --quiet"
969 return
971 esac
972 COMPREPLY=()
975 _git_clone ()
977 case "$cur" in
978 --*)
979 __gitcomp "
980 --local
981 --no-hardlinks
982 --shared
983 --reference
984 --quiet
985 --no-checkout
986 --bare
987 --mirror
988 --origin
989 --upload-pack
990 --template=
991 --depth
993 return
995 esac
996 COMPREPLY=()
999 _git_commit ()
1001 __git_has_doubledash && return
1003 case "$cur" in
1004 --cleanup=*)
1005 __gitcomp "default strip verbatim whitespace
1006 " "" "${cur##--cleanup=}"
1007 return
1009 --reuse-message=*|--reedit-message=*|\
1010 --fixup=*|--squash=*)
1011 __gitcomp_nl "$(__git_refs)" "" "${cur#*=}"
1012 return
1014 --untracked-files=*)
1015 __gitcomp "all no normal" "" "${cur##--untracked-files=}"
1016 return
1018 --*)
1019 __gitcomp "
1020 --all --author= --signoff --verify --no-verify
1021 --edit --amend --include --only --interactive
1022 --dry-run --reuse-message= --reedit-message=
1023 --reset-author --file= --message= --template=
1024 --cleanup= --untracked-files --untracked-files=
1025 --verbose --quiet --fixup= --squash=
1027 return
1028 esac
1029 COMPREPLY=()
1032 _git_describe ()
1034 case "$cur" in
1035 --*)
1036 __gitcomp "
1037 --all --tags --contains --abbrev= --candidates=
1038 --exact-match --debug --long --match --always
1040 return
1041 esac
1042 __gitcomp_nl "$(__git_refs)"
1045 __git_diff_common_options="--stat --numstat --shortstat --summary
1046 --patch-with-stat --name-only --name-status --color
1047 --no-color --color-words --no-renames --check
1048 --full-index --binary --abbrev --diff-filter=
1049 --find-copies-harder
1050 --text --ignore-space-at-eol --ignore-space-change
1051 --ignore-all-space --exit-code --quiet --ext-diff
1052 --no-ext-diff
1053 --no-prefix --src-prefix= --dst-prefix=
1054 --inter-hunk-context=
1055 --patience
1056 --raw
1057 --dirstat --dirstat= --dirstat-by-file
1058 --dirstat-by-file= --cumulative
1061 _git_diff ()
1063 __git_has_doubledash && return
1065 case "$cur" in
1066 --*)
1067 __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
1068 --base --ours --theirs --no-index
1069 $__git_diff_common_options
1071 return
1073 esac
1074 __git_complete_revlist_file
1077 __git_mergetools_common="diffuse ecmerge emerge kdiff3 meld opendiff
1078 tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc3
1081 _git_difftool ()
1083 __git_has_doubledash && return
1085 case "$cur" in
1086 --tool=*)
1087 __gitcomp "$__git_mergetools_common kompare" "" "${cur##--tool=}"
1088 return
1090 --*)
1091 __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
1092 --base --ours --theirs
1093 --no-renames --diff-filter= --find-copies-harder
1094 --relative --ignore-submodules
1095 --tool="
1096 return
1098 esac
1099 __git_complete_file
1102 __git_fetch_options="
1103 --quiet --verbose --append --upload-pack --force --keep --depth=
1104 --tags --no-tags --all --prune --dry-run
1107 _git_fetch ()
1109 case "$cur" in
1110 --*)
1111 __gitcomp "$__git_fetch_options"
1112 return
1114 esac
1115 __git_complete_remote_or_refspec
1118 _git_format_patch ()
1120 case "$cur" in
1121 --thread=*)
1122 __gitcomp "
1123 deep shallow
1124 " "" "${cur##--thread=}"
1125 return
1127 --*)
1128 __gitcomp "
1129 --stdout --attach --no-attach --thread --thread=
1130 --output-directory
1131 --numbered --start-number
1132 --numbered-files
1133 --keep-subject
1134 --signoff --signature --no-signature
1135 --in-reply-to= --cc=
1136 --full-index --binary
1137 --not --all
1138 --cover-letter
1139 --no-prefix --src-prefix= --dst-prefix=
1140 --inline --suffix= --ignore-if-in-upstream
1141 --subject-prefix=
1143 return
1145 esac
1146 __git_complete_revlist
1149 _git_fsck ()
1151 case "$cur" in
1152 --*)
1153 __gitcomp "
1154 --tags --root --unreachable --cache --no-reflogs --full
1155 --strict --verbose --lost-found
1157 return
1159 esac
1160 COMPREPLY=()
1163 _git_gc ()
1165 case "$cur" in
1166 --*)
1167 __gitcomp "--prune --aggressive"
1168 return
1170 esac
1171 COMPREPLY=()
1174 _git_gitk ()
1176 _gitk
1179 __git_match_ctag() {
1180 awk "/^${1////\\/}/ { print \$1 }" "$2"
1183 _git_grep ()
1185 __git_has_doubledash && return
1187 case "$cur" in
1188 --*)
1189 __gitcomp "
1190 --cached
1191 --text --ignore-case --word-regexp --invert-match
1192 --full-name --line-number
1193 --extended-regexp --basic-regexp --fixed-strings
1194 --perl-regexp
1195 --files-with-matches --name-only
1196 --files-without-match
1197 --max-depth
1198 --count
1199 --and --or --not --all-match
1201 return
1203 esac
1205 case "$cword,$prev" in
1206 2,*|*,-*)
1207 if test -r tags; then
1208 __gitcomp_nl "$(__git_match_ctag "$cur" tags)"
1209 return
1212 esac
1214 __gitcomp_nl "$(__git_refs)"
1217 _git_help ()
1219 case "$cur" in
1220 --*)
1221 __gitcomp "--all --info --man --web"
1222 return
1224 esac
1225 __git_compute_all_commands
1226 __gitcomp "$__git_all_commands $(__git_aliases)
1227 attributes cli core-tutorial cvs-migration
1228 diffcore gitk glossary hooks ignore modules
1229 namespaces repository-layout tutorial tutorial-2
1230 workflows
1234 _git_init ()
1236 case "$cur" in
1237 --shared=*)
1238 __gitcomp "
1239 false true umask group all world everybody
1240 " "" "${cur##--shared=}"
1241 return
1243 --*)
1244 __gitcomp "--quiet --bare --template= --shared --shared="
1245 return
1247 esac
1248 COMPREPLY=()
1251 _git_ls_files ()
1253 __git_has_doubledash && return
1255 case "$cur" in
1256 --*)
1257 __gitcomp "--cached --deleted --modified --others --ignored
1258 --stage --directory --no-empty-directory --unmerged
1259 --killed --exclude= --exclude-from=
1260 --exclude-per-directory= --exclude-standard
1261 --error-unmatch --with-tree= --full-name
1262 --abbrev --ignored --exclude-per-directory
1264 return
1266 esac
1267 COMPREPLY=()
1270 _git_ls_remote ()
1272 __gitcomp_nl "$(__git_remotes)"
1275 _git_ls_tree ()
1277 __git_complete_file
1280 # Options that go well for log, shortlog and gitk
1281 __git_log_common_options="
1282 --not --all
1283 --branches --tags --remotes
1284 --first-parent --merges --no-merges
1285 --max-count=
1286 --max-age= --since= --after=
1287 --min-age= --until= --before=
1288 --min-parents= --max-parents=
1289 --no-min-parents --no-max-parents
1291 # Options that go well for log and gitk (not shortlog)
1292 __git_log_gitk_options="
1293 --dense --sparse --full-history
1294 --simplify-merges --simplify-by-decoration
1295 --left-right --notes --no-notes
1297 # Options that go well for log and shortlog (not gitk)
1298 __git_log_shortlog_options="
1299 --author= --committer= --grep=
1300 --all-match
1303 __git_log_pretty_formats="oneline short medium full fuller email raw format:"
1304 __git_log_date_formats="relative iso8601 rfc2822 short local default raw"
1306 _git_log ()
1308 __git_has_doubledash && return
1310 local g="$(git rev-parse --git-dir 2>/dev/null)"
1311 local merge=""
1312 if [ -f "$g/MERGE_HEAD" ]; then
1313 merge="--merge"
1315 case "$cur" in
1316 --pretty=*|--format=*)
1317 __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
1318 " "" "${cur#*=}"
1319 return
1321 --date=*)
1322 __gitcomp "$__git_log_date_formats" "" "${cur##--date=}"
1323 return
1325 --decorate=*)
1326 __gitcomp "long short" "" "${cur##--decorate=}"
1327 return
1329 --*)
1330 __gitcomp "
1331 $__git_log_common_options
1332 $__git_log_shortlog_options
1333 $__git_log_gitk_options
1334 --root --topo-order --date-order --reverse
1335 --follow --full-diff
1336 --abbrev-commit --abbrev=
1337 --relative-date --date=
1338 --pretty= --format= --oneline
1339 --cherry-pick
1340 --graph
1341 --decorate --decorate=
1342 --walk-reflogs
1343 --parents --children
1344 $merge
1345 $__git_diff_common_options
1346 --pickaxe-all --pickaxe-regex
1348 return
1350 esac
1351 __git_complete_revlist
1354 __git_merge_options="
1355 --no-commit --no-stat --log --no-log --squash --strategy
1356 --commit --stat --no-squash --ff --no-ff --ff-only --edit --no-edit
1359 _git_merge ()
1361 __git_complete_strategy && return
1363 case "$cur" in
1364 --*)
1365 __gitcomp "$__git_merge_options"
1366 return
1367 esac
1368 __gitcomp_nl "$(__git_refs)"
1371 _git_mergetool ()
1373 case "$cur" in
1374 --tool=*)
1375 __gitcomp "$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"
1376 return
1378 --*)
1379 __gitcomp "--tool="
1380 return
1382 esac
1383 COMPREPLY=()
1386 _git_merge_base ()
1388 __gitcomp_nl "$(__git_refs)"
1391 _git_mv ()
1393 case "$cur" in
1394 --*)
1395 __gitcomp "--dry-run"
1396 return
1398 esac
1399 COMPREPLY=()
1402 _git_name_rev ()
1404 __gitcomp "--tags --all --stdin"
1407 _git_notes ()
1409 local subcommands='add append copy edit list prune remove show'
1410 local subcommand="$(__git_find_on_cmdline "$subcommands")"
1412 case "$subcommand,$cur" in
1413 ,--*)
1414 __gitcomp '--ref'
1417 case "$prev" in
1418 --ref)
1419 __gitcomp_nl "$(__git_refs)"
1422 __gitcomp "$subcommands --ref"
1424 esac
1426 add,--reuse-message=*|append,--reuse-message=*|\
1427 add,--reedit-message=*|append,--reedit-message=*)
1428 __gitcomp_nl "$(__git_refs)" "" "${cur#*=}"
1430 add,--*|append,--*)
1431 __gitcomp '--file= --message= --reedit-message=
1432 --reuse-message='
1434 copy,--*)
1435 __gitcomp '--stdin'
1437 prune,--*)
1438 __gitcomp '--dry-run --verbose'
1440 prune,*)
1443 case "$prev" in
1444 -m|-F)
1447 __gitcomp_nl "$(__git_refs)"
1449 esac
1451 esac
1454 _git_pull ()
1456 __git_complete_strategy && return
1458 case "$cur" in
1459 --*)
1460 __gitcomp "
1461 --rebase --no-rebase
1462 $__git_merge_options
1463 $__git_fetch_options
1465 return
1467 esac
1468 __git_complete_remote_or_refspec
1471 _git_push ()
1473 case "$prev" in
1474 --repo)
1475 __gitcomp_nl "$(__git_remotes)"
1476 return
1477 esac
1478 case "$cur" in
1479 --repo=*)
1480 __gitcomp_nl "$(__git_remotes)" "" "${cur##--repo=}"
1481 return
1483 --*)
1484 __gitcomp "
1485 --all --mirror --tags --dry-run --force --verbose
1486 --receive-pack= --repo= --set-upstream
1488 return
1490 esac
1491 __git_complete_remote_or_refspec
1494 _git_rebase ()
1496 local dir="$(__gitdir)"
1497 if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
1498 __gitcomp "--continue --skip --abort"
1499 return
1501 __git_complete_strategy && return
1502 case "$cur" in
1503 --whitespace=*)
1504 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
1505 return
1507 --*)
1508 __gitcomp "
1509 --onto --merge --strategy --interactive
1510 --preserve-merges --stat --no-stat
1511 --committer-date-is-author-date --ignore-date
1512 --ignore-whitespace --whitespace=
1513 --autosquash
1516 return
1517 esac
1518 __gitcomp_nl "$(__git_refs)"
1521 _git_reflog ()
1523 local subcommands="show delete expire"
1524 local subcommand="$(__git_find_on_cmdline "$subcommands")"
1526 if [ -z "$subcommand" ]; then
1527 __gitcomp "$subcommands"
1528 else
1529 __gitcomp_nl "$(__git_refs)"
1533 __git_send_email_confirm_options="always never auto cc compose"
1534 __git_send_email_suppresscc_options="author self cc bodycc sob cccmd body all"
1536 _git_send_email ()
1538 case "$cur" in
1539 --confirm=*)
1540 __gitcomp "
1541 $__git_send_email_confirm_options
1542 " "" "${cur##--confirm=}"
1543 return
1545 --suppress-cc=*)
1546 __gitcomp "
1547 $__git_send_email_suppresscc_options
1548 " "" "${cur##--suppress-cc=}"
1550 return
1552 --smtp-encryption=*)
1553 __gitcomp "ssl tls" "" "${cur##--smtp-encryption=}"
1554 return
1556 --*)
1557 __gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to
1558 --compose --confirm= --dry-run --envelope-sender
1559 --from --identity
1560 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
1561 --no-suppress-from --no-thread --quiet
1562 --signed-off-by-cc --smtp-pass --smtp-server
1563 --smtp-server-port --smtp-encryption= --smtp-user
1564 --subject --suppress-cc= --suppress-from --thread --to
1565 --validate --no-validate"
1566 return
1568 esac
1569 COMPREPLY=()
1572 _git_stage ()
1574 _git_add
1577 __git_config_get_set_variables ()
1579 local prevword word config_file= c=$cword
1580 while [ $c -gt 1 ]; do
1581 word="${words[c]}"
1582 case "$word" in
1583 --global|--system|--file=*)
1584 config_file="$word"
1585 break
1587 -f|--file)
1588 config_file="$word $prevword"
1589 break
1591 esac
1592 prevword=$word
1593 c=$((--c))
1594 done
1596 git --git-dir="$(__gitdir)" config $config_file --list 2>/dev/null |
1597 while read -r line
1599 case "$line" in
1600 *.*=*)
1601 echo "${line/=*/}"
1603 esac
1604 done
1607 _git_config ()
1609 case "$prev" in
1610 branch.*.remote)
1611 __gitcomp_nl "$(__git_remotes)"
1612 return
1614 branch.*.merge)
1615 __gitcomp_nl "$(__git_refs)"
1616 return
1618 remote.*.fetch)
1619 local remote="${prev#remote.}"
1620 remote="${remote%.fetch}"
1621 if [ -z "$cur" ]; then
1622 COMPREPLY=("refs/heads/")
1623 return
1625 __gitcomp_nl "$(__git_refs_remotes "$remote")"
1626 return
1628 remote.*.push)
1629 local remote="${prev#remote.}"
1630 remote="${remote%.push}"
1631 __gitcomp_nl "$(git --git-dir="$(__gitdir)" \
1632 for-each-ref --format='%(refname):%(refname)' \
1633 refs/heads)"
1634 return
1636 pull.twohead|pull.octopus)
1637 __git_compute_merge_strategies
1638 __gitcomp "$__git_merge_strategies"
1639 return
1641 color.branch|color.diff|color.interactive|\
1642 color.showbranch|color.status|color.ui)
1643 __gitcomp "always never auto"
1644 return
1646 color.pager)
1647 __gitcomp "false true"
1648 return
1650 color.*.*)
1651 __gitcomp "
1652 normal black red green yellow blue magenta cyan white
1653 bold dim ul blink reverse
1655 return
1657 help.format)
1658 __gitcomp "man info web html"
1659 return
1661 log.date)
1662 __gitcomp "$__git_log_date_formats"
1663 return
1665 sendemail.aliasesfiletype)
1666 __gitcomp "mutt mailrc pine elm gnus"
1667 return
1669 sendemail.confirm)
1670 __gitcomp "$__git_send_email_confirm_options"
1671 return
1673 sendemail.suppresscc)
1674 __gitcomp "$__git_send_email_suppresscc_options"
1675 return
1677 --get|--get-all|--unset|--unset-all)
1678 __gitcomp_nl "$(__git_config_get_set_variables)"
1679 return
1681 *.*)
1682 COMPREPLY=()
1683 return
1685 esac
1686 case "$cur" in
1687 --*)
1688 __gitcomp "
1689 --global --system --file=
1690 --list --replace-all
1691 --get --get-all --get-regexp
1692 --add --unset --unset-all
1693 --remove-section --rename-section
1695 return
1697 branch.*.*)
1698 local pfx="${cur%.*}." cur_="${cur##*.}"
1699 __gitcomp "remote merge mergeoptions rebase" "$pfx" "$cur_"
1700 return
1702 branch.*)
1703 local pfx="${cur%.*}." cur_="${cur#*.}"
1704 __gitcomp_nl "$(__git_heads)" "$pfx" "$cur_" "."
1705 return
1707 guitool.*.*)
1708 local pfx="${cur%.*}." cur_="${cur##*.}"
1709 __gitcomp "
1710 argprompt cmd confirm needsfile noconsole norescan
1711 prompt revprompt revunmerged title
1712 " "$pfx" "$cur_"
1713 return
1715 difftool.*.*)
1716 local pfx="${cur%.*}." cur_="${cur##*.}"
1717 __gitcomp "cmd path" "$pfx" "$cur_"
1718 return
1720 man.*.*)
1721 local pfx="${cur%.*}." cur_="${cur##*.}"
1722 __gitcomp "cmd path" "$pfx" "$cur_"
1723 return
1725 mergetool.*.*)
1726 local pfx="${cur%.*}." cur_="${cur##*.}"
1727 __gitcomp "cmd path trustExitCode" "$pfx" "$cur_"
1728 return
1730 pager.*)
1731 local pfx="${cur%.*}." cur_="${cur#*.}"
1732 __git_compute_all_commands
1733 __gitcomp_nl "$__git_all_commands" "$pfx" "$cur_"
1734 return
1736 remote.*.*)
1737 local pfx="${cur%.*}." cur_="${cur##*.}"
1738 __gitcomp "
1739 url proxy fetch push mirror skipDefaultUpdate
1740 receivepack uploadpack tagopt pushurl
1741 " "$pfx" "$cur_"
1742 return
1744 remote.*)
1745 local pfx="${cur%.*}." cur_="${cur#*.}"
1746 __gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "."
1747 return
1749 url.*.*)
1750 local pfx="${cur%.*}." cur_="${cur##*.}"
1751 __gitcomp "insteadOf pushInsteadOf" "$pfx" "$cur_"
1752 return
1754 esac
1755 __gitcomp "
1756 add.ignoreErrors
1757 advice.commitBeforeMerge
1758 advice.detachedHead
1759 advice.implicitIdentity
1760 advice.pushNonFastForward
1761 advice.resolveConflict
1762 advice.statusHints
1763 alias.
1764 am.keepcr
1765 apply.ignorewhitespace
1766 apply.whitespace
1767 branch.autosetupmerge
1768 branch.autosetuprebase
1769 browser.
1770 clean.requireForce
1771 color.branch
1772 color.branch.current
1773 color.branch.local
1774 color.branch.plain
1775 color.branch.remote
1776 color.decorate.HEAD
1777 color.decorate.branch
1778 color.decorate.remoteBranch
1779 color.decorate.stash
1780 color.decorate.tag
1781 color.diff
1782 color.diff.commit
1783 color.diff.frag
1784 color.diff.func
1785 color.diff.meta
1786 color.diff.new
1787 color.diff.old
1788 color.diff.plain
1789 color.diff.whitespace
1790 color.grep
1791 color.grep.context
1792 color.grep.filename
1793 color.grep.function
1794 color.grep.linenumber
1795 color.grep.match
1796 color.grep.selected
1797 color.grep.separator
1798 color.interactive
1799 color.interactive.error
1800 color.interactive.header
1801 color.interactive.help
1802 color.interactive.prompt
1803 color.pager
1804 color.showbranch
1805 color.status
1806 color.status.added
1807 color.status.changed
1808 color.status.header
1809 color.status.nobranch
1810 color.status.untracked
1811 color.status.updated
1812 color.ui
1813 commit.status
1814 commit.template
1815 core.abbrev
1816 core.askpass
1817 core.attributesfile
1818 core.autocrlf
1819 core.bare
1820 core.bigFileThreshold
1821 core.compression
1822 core.createObject
1823 core.deltaBaseCacheLimit
1824 core.editor
1825 core.eol
1826 core.excludesfile
1827 core.fileMode
1828 core.fsyncobjectfiles
1829 core.gitProxy
1830 core.ignoreCygwinFSTricks
1831 core.ignoreStat
1832 core.ignorecase
1833 core.logAllRefUpdates
1834 core.loosecompression
1835 core.notesRef
1836 core.packedGitLimit
1837 core.packedGitWindowSize
1838 core.pager
1839 core.preferSymlinkRefs
1840 core.preloadindex
1841 core.quotepath
1842 core.repositoryFormatVersion
1843 core.safecrlf
1844 core.sharedRepository
1845 core.sparseCheckout
1846 core.symlinks
1847 core.trustctime
1848 core.warnAmbiguousRefs
1849 core.whitespace
1850 core.worktree
1851 diff.autorefreshindex
1852 diff.statGraphWidth
1853 diff.external
1854 diff.ignoreSubmodules
1855 diff.mnemonicprefix
1856 diff.noprefix
1857 diff.renameLimit
1858 diff.renames
1859 diff.suppressBlankEmpty
1860 diff.tool
1861 diff.wordRegex
1862 difftool.
1863 difftool.prompt
1864 fetch.recurseSubmodules
1865 fetch.unpackLimit
1866 format.attach
1867 format.cc
1868 format.headers
1869 format.numbered
1870 format.pretty
1871 format.signature
1872 format.signoff
1873 format.subjectprefix
1874 format.suffix
1875 format.thread
1876 format.to
1878 gc.aggressiveWindow
1879 gc.auto
1880 gc.autopacklimit
1881 gc.packrefs
1882 gc.pruneexpire
1883 gc.reflogexpire
1884 gc.reflogexpireunreachable
1885 gc.rerereresolved
1886 gc.rerereunresolved
1887 gitcvs.allbinary
1888 gitcvs.commitmsgannotation
1889 gitcvs.dbTableNamePrefix
1890 gitcvs.dbdriver
1891 gitcvs.dbname
1892 gitcvs.dbpass
1893 gitcvs.dbuser
1894 gitcvs.enabled
1895 gitcvs.logfile
1896 gitcvs.usecrlfattr
1897 guitool.
1898 gui.blamehistoryctx
1899 gui.commitmsgwidth
1900 gui.copyblamethreshold
1901 gui.diffcontext
1902 gui.encoding
1903 gui.fastcopyblame
1904 gui.matchtrackingbranch
1905 gui.newbranchtemplate
1906 gui.pruneduringfetch
1907 gui.spellingdictionary
1908 gui.trustmtime
1909 help.autocorrect
1910 help.browser
1911 help.format
1912 http.lowSpeedLimit
1913 http.lowSpeedTime
1914 http.maxRequests
1915 http.minSessions
1916 http.noEPSV
1917 http.postBuffer
1918 http.proxy
1919 http.sslCAInfo
1920 http.sslCAPath
1921 http.sslCert
1922 http.sslCertPasswordProtected
1923 http.sslKey
1924 http.sslVerify
1925 http.useragent
1926 i18n.commitEncoding
1927 i18n.logOutputEncoding
1928 imap.authMethod
1929 imap.folder
1930 imap.host
1931 imap.pass
1932 imap.port
1933 imap.preformattedHTML
1934 imap.sslverify
1935 imap.tunnel
1936 imap.user
1937 init.templatedir
1938 instaweb.browser
1939 instaweb.httpd
1940 instaweb.local
1941 instaweb.modulepath
1942 instaweb.port
1943 interactive.singlekey
1944 log.date
1945 log.decorate
1946 log.showroot
1947 mailmap.file
1948 man.
1949 man.viewer
1950 merge.
1951 merge.conflictstyle
1952 merge.log
1953 merge.renameLimit
1954 merge.renormalize
1955 merge.stat
1956 merge.tool
1957 merge.verbosity
1958 mergetool.
1959 mergetool.keepBackup
1960 mergetool.keepTemporaries
1961 mergetool.prompt
1962 notes.displayRef
1963 notes.rewrite.
1964 notes.rewrite.amend
1965 notes.rewrite.rebase
1966 notes.rewriteMode
1967 notes.rewriteRef
1968 pack.compression
1969 pack.deltaCacheLimit
1970 pack.deltaCacheSize
1971 pack.depth
1972 pack.indexVersion
1973 pack.packSizeLimit
1974 pack.threads
1975 pack.window
1976 pack.windowMemory
1977 pager.
1978 pretty.
1979 pull.octopus
1980 pull.twohead
1981 push.default
1982 rebase.autosquash
1983 rebase.stat
1984 receive.autogc
1985 receive.denyCurrentBranch
1986 receive.denyDeleteCurrent
1987 receive.denyDeletes
1988 receive.denyNonFastForwards
1989 receive.fsckObjects
1990 receive.unpackLimit
1991 receive.updateserverinfo
1992 remotes.
1993 repack.usedeltabaseoffset
1994 rerere.autoupdate
1995 rerere.enabled
1996 sendemail.
1997 sendemail.aliasesfile
1998 sendemail.aliasfiletype
1999 sendemail.bcc
2000 sendemail.cc
2001 sendemail.cccmd
2002 sendemail.chainreplyto
2003 sendemail.confirm
2004 sendemail.envelopesender
2005 sendemail.from
2006 sendemail.identity
2007 sendemail.multiedit
2008 sendemail.signedoffbycc
2009 sendemail.smtpdomain
2010 sendemail.smtpencryption
2011 sendemail.smtppass
2012 sendemail.smtpserver
2013 sendemail.smtpserveroption
2014 sendemail.smtpserverport
2015 sendemail.smtpuser
2016 sendemail.suppresscc
2017 sendemail.suppressfrom
2018 sendemail.thread
2019 sendemail.to
2020 sendemail.validate
2021 showbranch.default
2022 status.relativePaths
2023 status.showUntrackedFiles
2024 status.submodulesummary
2025 submodule.
2026 tar.umask
2027 transfer.unpackLimit
2028 url.
2029 user.email
2030 user.name
2031 user.signingkey
2032 web.browser
2033 branch. remote.
2037 _git_remote ()
2039 local subcommands="add rename rm set-head set-branches set-url show prune update"
2040 local subcommand="$(__git_find_on_cmdline "$subcommands")"
2041 if [ -z "$subcommand" ]; then
2042 __gitcomp "$subcommands"
2043 return
2046 case "$subcommand" in
2047 rename|rm|set-url|show|prune)
2048 __gitcomp_nl "$(__git_remotes)"
2050 set-head|set-branches)
2051 __git_complete_remote_or_refspec
2053 update)
2054 local i c='' IFS=$'\n'
2055 for i in $(git --git-dir="$(__gitdir)" config --get-regexp "remotes\..*" 2>/dev/null); do
2056 i="${i#remotes.}"
2057 c="$c ${i/ */}"
2058 done
2059 __gitcomp "$c"
2062 COMPREPLY=()
2064 esac
2067 _git_replace ()
2069 __gitcomp_nl "$(__git_refs)"
2072 _git_reset ()
2074 __git_has_doubledash && return
2076 case "$cur" in
2077 --*)
2078 __gitcomp "--merge --mixed --hard --soft --patch"
2079 return
2081 esac
2082 __gitcomp_nl "$(__git_refs)"
2085 _git_revert ()
2087 case "$cur" in
2088 --*)
2089 __gitcomp "--edit --mainline --no-edit --no-commit --signoff"
2090 return
2092 esac
2093 __gitcomp_nl "$(__git_refs)"
2096 _git_rm ()
2098 __git_has_doubledash && return
2100 case "$cur" in
2101 --*)
2102 __gitcomp "--cached --dry-run --ignore-unmatch --quiet"
2103 return
2105 esac
2106 COMPREPLY=()
2109 _git_shortlog ()
2111 __git_has_doubledash && return
2113 case "$cur" in
2114 --*)
2115 __gitcomp "
2116 $__git_log_common_options
2117 $__git_log_shortlog_options
2118 --numbered --summary
2120 return
2122 esac
2123 __git_complete_revlist
2126 _git_show ()
2128 __git_has_doubledash && return
2130 case "$cur" in
2131 --pretty=*|--format=*)
2132 __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
2133 " "" "${cur#*=}"
2134 return
2136 --*)
2137 __gitcomp "--pretty= --format= --abbrev-commit --oneline
2138 $__git_diff_common_options
2140 return
2142 esac
2143 __git_complete_file
2146 _git_show_branch ()
2148 case "$cur" in
2149 --*)
2150 __gitcomp "
2151 --all --remotes --topo-order --current --more=
2152 --list --independent --merge-base --no-name
2153 --color --no-color
2154 --sha1-name --sparse --topics --reflog
2156 return
2158 esac
2159 __git_complete_revlist
2162 _git_stash ()
2164 local save_opts='--keep-index --no-keep-index --quiet --patch'
2165 local subcommands='save list show apply clear drop pop create branch'
2166 local subcommand="$(__git_find_on_cmdline "$subcommands")"
2167 if [ -z "$subcommand" ]; then
2168 case "$cur" in
2169 --*)
2170 __gitcomp "$save_opts"
2173 if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then
2174 __gitcomp "$subcommands"
2175 else
2176 COMPREPLY=()
2179 esac
2180 else
2181 case "$subcommand,$cur" in
2182 save,--*)
2183 __gitcomp "$save_opts"
2185 apply,--*|pop,--*)
2186 __gitcomp "--index --quiet"
2188 show,--*|drop,--*|branch,--*)
2189 COMPREPLY=()
2191 show,*|apply,*|drop,*|pop,*|branch,*)
2192 __gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \
2193 | sed -n -e 's/:.*//p')"
2196 COMPREPLY=()
2198 esac
2202 _git_submodule ()
2204 __git_has_doubledash && return
2206 local subcommands="add status init update summary foreach sync"
2207 if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then
2208 case "$cur" in
2209 --*)
2210 __gitcomp "--quiet --cached"
2213 __gitcomp "$subcommands"
2215 esac
2216 return
2220 _git_svn ()
2222 local subcommands="
2223 init fetch clone rebase dcommit log find-rev
2224 set-tree commit-diff info create-ignore propget
2225 proplist show-ignore show-externals branch tag blame
2226 migrate mkdirs reset gc
2228 local subcommand="$(__git_find_on_cmdline "$subcommands")"
2229 if [ -z "$subcommand" ]; then
2230 __gitcomp "$subcommands"
2231 else
2232 local remote_opts="--username= --config-dir= --no-auth-cache"
2233 local fc_opts="
2234 --follow-parent --authors-file= --repack=
2235 --no-metadata --use-svm-props --use-svnsync-props
2236 --log-window-size= --no-checkout --quiet
2237 --repack-flags --use-log-author --localtime
2238 --ignore-paths= $remote_opts
2240 local init_opts="
2241 --template= --shared= --trunk= --tags=
2242 --branches= --stdlayout --minimize-url
2243 --no-metadata --use-svm-props --use-svnsync-props
2244 --rewrite-root= --prefix= --use-log-author
2245 --add-author-from $remote_opts
2247 local cmt_opts="
2248 --edit --rmdir --find-copies-harder --copy-similarity=
2251 case "$subcommand,$cur" in
2252 fetch,--*)
2253 __gitcomp "--revision= --fetch-all $fc_opts"
2255 clone,--*)
2256 __gitcomp "--revision= $fc_opts $init_opts"
2258 init,--*)
2259 __gitcomp "$init_opts"
2261 dcommit,--*)
2262 __gitcomp "
2263 --merge --strategy= --verbose --dry-run
2264 --fetch-all --no-rebase --commit-url
2265 --revision --interactive $cmt_opts $fc_opts
2268 set-tree,--*)
2269 __gitcomp "--stdin $cmt_opts $fc_opts"
2271 create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\
2272 show-externals,--*|mkdirs,--*)
2273 __gitcomp "--revision="
2275 log,--*)
2276 __gitcomp "
2277 --limit= --revision= --verbose --incremental
2278 --oneline --show-commit --non-recursive
2279 --authors-file= --color
2282 rebase,--*)
2283 __gitcomp "
2284 --merge --verbose --strategy= --local
2285 --fetch-all --dry-run $fc_opts
2288 commit-diff,--*)
2289 __gitcomp "--message= --file= --revision= $cmt_opts"
2291 info,--*)
2292 __gitcomp "--url"
2294 branch,--*)
2295 __gitcomp "--dry-run --message --tag"
2297 tag,--*)
2298 __gitcomp "--dry-run --message"
2300 blame,--*)
2301 __gitcomp "--git-format"
2303 migrate,--*)
2304 __gitcomp "
2305 --config-dir= --ignore-paths= --minimize
2306 --no-auth-cache --username=
2309 reset,--*)
2310 __gitcomp "--revision= --parent"
2313 COMPREPLY=()
2315 esac
2319 _git_tag ()
2321 local i c=1 f=0
2322 while [ $c -lt $cword ]; do
2323 i="${words[c]}"
2324 case "$i" in
2325 -d|-v)
2326 __gitcomp_nl "$(__git_tags)"
2327 return
2332 esac
2333 ((c++))
2334 done
2336 case "$prev" in
2337 -m|-F)
2338 COMPREPLY=()
2340 -*|tag)
2341 if [ $f = 1 ]; then
2342 __gitcomp_nl "$(__git_tags)"
2343 else
2344 COMPREPLY=()
2348 __gitcomp_nl "$(__git_refs)"
2350 esac
2353 _git_whatchanged ()
2355 _git_log
2358 __git_main ()
2360 local i c=1 command __git_dir
2362 while [ $c -lt $cword ]; do
2363 i="${words[c]}"
2364 case "$i" in
2365 --git-dir=*) __git_dir="${i#--git-dir=}" ;;
2366 --bare) __git_dir="." ;;
2367 --help) command="help"; break ;;
2368 -c) c=$((++c)) ;;
2369 -*) ;;
2370 *) command="$i"; break ;;
2371 esac
2372 ((c++))
2373 done
2375 if [ -z "$command" ]; then
2376 case "$cur" in
2377 --*) __gitcomp "
2378 --paginate
2379 --no-pager
2380 --git-dir=
2381 --bare
2382 --version
2383 --exec-path
2384 --exec-path=
2385 --html-path
2386 --info-path
2387 --work-tree=
2388 --namespace=
2389 --no-replace-objects
2390 --help
2393 *) __git_compute_porcelain_commands
2394 __gitcomp "$__git_porcelain_commands $(__git_aliases)" ;;
2395 esac
2396 return
2399 local completion_func="_git_${command//-/_}"
2400 declare -f $completion_func >/dev/null && $completion_func && return
2402 local expansion=$(__git_aliased_command "$command")
2403 if [ -n "$expansion" ]; then
2404 completion_func="_git_${expansion//-/_}"
2405 declare -f $completion_func >/dev/null && $completion_func
2409 __gitk_main ()
2411 __git_has_doubledash && return
2413 local g="$(__gitdir)"
2414 local merge=""
2415 if [ -f "$g/MERGE_HEAD" ]; then
2416 merge="--merge"
2418 case "$cur" in
2419 --*)
2420 __gitcomp "
2421 $__git_log_common_options
2422 $__git_log_gitk_options
2423 $merge
2425 return
2427 esac
2428 __git_complete_revlist
2431 __git_func_wrap ()
2433 if [[ -n ${ZSH_VERSION-} ]]; then
2434 emulate -L bash
2435 setopt KSH_TYPESET
2437 # workaround zsh's bug that leaves 'words' as a special
2438 # variable in versions < 4.3.12
2439 typeset -h words
2441 # workaround zsh's bug that quotes spaces in the COMPREPLY
2442 # array if IFS doesn't contain spaces.
2443 typeset -h IFS
2445 local cur words cword prev
2446 _get_comp_words_by_ref -n =: cur words cword prev
2450 # Setup completion for certain functions defined above by setting common
2451 # variables and workarounds.
2452 # This is NOT a public function; use at your own risk.
2453 __git_complete ()
2455 local wrapper="__git_wrap${2}"
2456 eval "$wrapper () { __git_func_wrap $2 ; }"
2457 complete -o bashdefault -o default -o nospace -F $wrapper $1 2>/dev/null \
2458 || complete -o default -o nospace -F $wrapper $1
2461 # wrapper for backwards compatibility
2462 _git ()
2464 __git_wrap__git_main
2467 # wrapper for backwards compatibility
2468 _gitk ()
2470 __git_wrap__gitk_main
2473 __git_complete git __git_main
2474 __git_complete gitk __gitk_main
2476 # The following are necessary only for Cygwin, and only are needed
2477 # when the user has tab-completed the executable name and consequently
2478 # included the '.exe' suffix.
2480 if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
2481 __git_complete git.exe __git_main