gitweb (SyntaxHighlighter): interpret #l<line-number>
[git/dscho.git] / contrib / completion / git-completion.bash
blob0d0738a9ee069110540e99d6d89af695e30410ac
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'
265 # ZSH would quote the trailing space added with -S. bash users
266 # will appreciate the extra space to compensate the use of -o nospace.
267 if [ -n "${ZSH_VERSION-}" ] && [ "$suffix" = " " ]; then
268 suffix=""
271 COMPREPLY=($(compgen -P "${2-}" -S "${4- }" -W "$1" -- "${3-$cur}"))
274 __git_heads ()
276 local dir="$(__gitdir)"
277 if [ -d "$dir" ]; then
278 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
279 refs/heads
280 return
284 __git_tags ()
286 local dir="$(__gitdir)"
287 if [ -d "$dir" ]; then
288 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
289 refs/tags
290 return
294 # __git_refs accepts 0, 1 (to pass to __gitdir), or 2 arguments
295 # presence of 2nd argument means use the guess heuristic employed
296 # by checkout for tracking branches
297 __git_refs ()
299 local i hash dir="$(__gitdir "${1-}")" track="${2-}"
300 local format refs
301 if [ -d "$dir" ]; then
302 case "$cur" in
303 refs|refs/*)
304 format="refname"
305 refs="${cur%/*}"
306 track=""
309 for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do
310 if [ -e "$dir/$i" ]; then echo $i; fi
311 done
312 format="refname:short"
313 refs="refs/tags refs/heads refs/remotes"
315 esac
316 git --git-dir="$dir" for-each-ref --format="%($format)" \
317 $refs
318 if [ -n "$track" ]; then
319 # employ the heuristic used by git checkout
320 # Try to find a remote branch that matches the completion word
321 # but only output if the branch name is unique
322 local ref entry
323 git --git-dir="$dir" for-each-ref --shell --format="ref=%(refname:short)" \
324 "refs/remotes/" | \
325 while read -r entry; do
326 eval "$entry"
327 ref="${ref#*/}"
328 if [[ "$ref" == "$cur"* ]]; then
329 echo "$ref"
331 done | uniq -u
333 return
335 case "$cur" in
336 refs|refs/*)
337 git ls-remote "$dir" "$cur*" 2>/dev/null | \
338 while read -r hash i; do
339 case "$i" in
340 *^{}) ;;
341 *) echo "$i" ;;
342 esac
343 done
346 git ls-remote "$dir" HEAD ORIG_HEAD 'refs/tags/*' 'refs/heads/*' 'refs/remotes/*' 2>/dev/null | \
347 while read -r hash i; do
348 case "$i" in
349 *^{}) ;;
350 refs/*) echo "${i#refs/*/}" ;;
351 *) echo "$i" ;;
352 esac
353 done
355 esac
358 # __git_refs2 requires 1 argument (to pass to __git_refs)
359 __git_refs2 ()
361 local i
362 for i in $(__git_refs "$1"); do
363 echo "$i:$i"
364 done
367 # __git_refs_remotes requires 1 argument (to pass to ls-remote)
368 __git_refs_remotes ()
370 local i hash
371 git ls-remote "$1" 'refs/heads/*' 2>/dev/null | \
372 while read -r hash i; do
373 echo "$i:refs/remotes/$1/${i#refs/heads/}"
374 done
377 __git_remotes ()
379 local i IFS=$'\n' d="$(__gitdir)"
380 test -d "$d/remotes" && ls -1 "$d/remotes"
381 for i in $(git --git-dir="$d" config --get-regexp 'remote\..*\.url' 2>/dev/null); do
382 i="${i#remote.}"
383 echo "${i/.url*/}"
384 done
387 __git_list_merge_strategies ()
389 git merge -s help 2>&1 |
390 sed -n -e '/[Aa]vailable strategies are: /,/^$/{
391 s/\.$//
392 s/.*://
393 s/^[ ]*//
394 s/[ ]*$//
399 __git_merge_strategies=
400 # 'git merge -s help' (and thus detection of the merge strategy
401 # list) fails, unfortunately, if run outside of any git working
402 # tree. __git_merge_strategies is set to the empty string in
403 # that case, and the detection will be repeated the next time it
404 # is needed.
405 __git_compute_merge_strategies ()
407 test -n "$__git_merge_strategies" ||
408 __git_merge_strategies=$(__git_list_merge_strategies)
411 __git_complete_revlist_file ()
413 local pfx ls ref cur_="$cur"
414 case "$cur_" in
415 *..?*:*)
416 return
418 ?*:*)
419 ref="${cur_%%:*}"
420 cur_="${cur_#*:}"
421 case "$cur_" in
422 ?*/*)
423 pfx="${cur_%/*}"
424 cur_="${cur_##*/}"
425 ls="$ref:$pfx"
426 pfx="$pfx/"
429 ls="$ref"
431 esac
433 case "$COMP_WORDBREAKS" in
434 *:*) : great ;;
435 *) pfx="$ref:$pfx" ;;
436 esac
438 __gitcomp_nl "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \
439 | sed '/^100... blob /{
440 s,^.* ,,
441 s,$, ,
443 /^120000 blob /{
444 s,^.* ,,
445 s,$, ,
447 /^040000 tree /{
448 s,^.* ,,
449 s,$,/,
451 s/^.* //')" \
452 "$pfx" "$cur_" ""
454 *...*)
455 pfx="${cur_%...*}..."
456 cur_="${cur_#*...}"
457 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
459 *..*)
460 pfx="${cur_%..*}.."
461 cur_="${cur_#*..}"
462 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
465 __gitcomp_nl "$(__git_refs)"
467 esac
471 __git_complete_file ()
473 __git_complete_revlist_file
476 __git_complete_revlist ()
478 __git_complete_revlist_file
481 __git_complete_remote_or_refspec ()
483 local cur_="$cur" cmd="${words[1]}"
484 local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0
485 if [ "$cmd" = "remote" ]; then
486 ((c++))
488 while [ $c -lt $cword ]; do
489 i="${words[c]}"
490 case "$i" in
491 --mirror) [ "$cmd" = "push" ] && no_complete_refspec=1 ;;
492 --all)
493 case "$cmd" in
494 push) no_complete_refspec=1 ;;
495 fetch)
496 COMPREPLY=()
497 return
499 *) ;;
500 esac
502 -*) ;;
503 *) remote="$i"; break ;;
504 esac
505 ((c++))
506 done
507 if [ -z "$remote" ]; then
508 __gitcomp_nl "$(__git_remotes)"
509 return
511 if [ $no_complete_refspec = 1 ]; then
512 COMPREPLY=()
513 return
515 [ "$remote" = "." ] && remote=
516 case "$cur_" in
517 *:*)
518 case "$COMP_WORDBREAKS" in
519 *:*) : great ;;
520 *) pfx="${cur_%%:*}:" ;;
521 esac
522 cur_="${cur_#*:}"
523 lhs=0
526 pfx="+"
527 cur_="${cur_#+}"
529 esac
530 case "$cmd" in
531 fetch)
532 if [ $lhs = 1 ]; then
533 __gitcomp_nl "$(__git_refs2 "$remote")" "$pfx" "$cur_"
534 else
535 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
538 pull|remote)
539 if [ $lhs = 1 ]; then
540 __gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_"
541 else
542 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
545 push)
546 if [ $lhs = 1 ]; then
547 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
548 else
549 __gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_"
552 esac
555 __git_complete_strategy ()
557 __git_compute_merge_strategies
558 case "$prev" in
559 -s|--strategy)
560 __gitcomp "$__git_merge_strategies"
561 return 0
562 esac
563 case "$cur" in
564 --strategy=*)
565 __gitcomp "$__git_merge_strategies" "" "${cur##--strategy=}"
566 return 0
568 esac
569 return 1
572 __git_list_all_commands ()
574 local i IFS=" "$'\n'
575 for i in $(git help -a|egrep '^ [a-zA-Z0-9]')
577 case $i in
578 *--*) : helper pattern;;
579 *) echo $i;;
580 esac
581 done
584 __git_all_commands=
585 __git_compute_all_commands ()
587 test -n "$__git_all_commands" ||
588 __git_all_commands=$(__git_list_all_commands)
591 __git_list_porcelain_commands ()
593 local i IFS=" "$'\n'
594 __git_compute_all_commands
595 for i in "help" $__git_all_commands
597 case $i in
598 *--*) : helper pattern;;
599 applymbox) : ask gittus;;
600 applypatch) : ask gittus;;
601 archimport) : import;;
602 cat-file) : plumbing;;
603 check-attr) : plumbing;;
604 check-ref-format) : plumbing;;
605 checkout-index) : plumbing;;
606 commit-tree) : plumbing;;
607 count-objects) : infrequent;;
608 credential-cache) : credentials helper;;
609 credential-store) : credentials helper;;
610 cvsexportcommit) : export;;
611 cvsimport) : import;;
612 cvsserver) : daemon;;
613 daemon) : daemon;;
614 diff-files) : plumbing;;
615 diff-index) : plumbing;;
616 diff-tree) : plumbing;;
617 fast-import) : import;;
618 fast-export) : export;;
619 fsck-objects) : plumbing;;
620 fetch-pack) : plumbing;;
621 fmt-merge-msg) : plumbing;;
622 for-each-ref) : plumbing;;
623 hash-object) : plumbing;;
624 http-*) : transport;;
625 index-pack) : plumbing;;
626 init-db) : deprecated;;
627 local-fetch) : plumbing;;
628 lost-found) : infrequent;;
629 ls-files) : plumbing;;
630 ls-remote) : plumbing;;
631 ls-tree) : plumbing;;
632 mailinfo) : plumbing;;
633 mailsplit) : plumbing;;
634 merge-*) : plumbing;;
635 mktree) : plumbing;;
636 mktag) : plumbing;;
637 pack-objects) : plumbing;;
638 pack-redundant) : plumbing;;
639 pack-refs) : plumbing;;
640 parse-remote) : plumbing;;
641 patch-id) : plumbing;;
642 peek-remote) : plumbing;;
643 prune) : plumbing;;
644 prune-packed) : plumbing;;
645 quiltimport) : import;;
646 read-tree) : plumbing;;
647 receive-pack) : plumbing;;
648 remote-*) : transport;;
649 repo-config) : deprecated;;
650 rerere) : plumbing;;
651 rev-list) : plumbing;;
652 rev-parse) : plumbing;;
653 runstatus) : plumbing;;
654 sh-setup) : internal;;
655 shell) : daemon;;
656 show-ref) : plumbing;;
657 send-pack) : plumbing;;
658 show-index) : plumbing;;
659 ssh-*) : transport;;
660 stripspace) : plumbing;;
661 symbolic-ref) : plumbing;;
662 tar-tree) : deprecated;;
663 unpack-file) : plumbing;;
664 unpack-objects) : plumbing;;
665 update-index) : plumbing;;
666 update-ref) : plumbing;;
667 update-server-info) : daemon;;
668 upload-archive) : plumbing;;
669 upload-pack) : plumbing;;
670 write-tree) : plumbing;;
671 var) : infrequent;;
672 verify-pack) : infrequent;;
673 verify-tag) : plumbing;;
674 *) echo $i;;
675 esac
676 done
679 __git_porcelain_commands=
680 __git_compute_porcelain_commands ()
682 __git_compute_all_commands
683 test -n "$__git_porcelain_commands" ||
684 __git_porcelain_commands=$(__git_list_porcelain_commands)
687 __git_pretty_aliases ()
689 local i IFS=$'\n'
690 for i in $(git --git-dir="$(__gitdir)" config --get-regexp "pretty\..*" 2>/dev/null); do
691 case "$i" in
692 pretty.*)
693 i="${i#pretty.}"
694 echo "${i/ */}"
696 esac
697 done
700 __git_aliases ()
702 local i IFS=$'\n'
703 for i in $(git --git-dir="$(__gitdir)" config --get-regexp "alias\..*" 2>/dev/null); do
704 case "$i" in
705 alias.*)
706 i="${i#alias.}"
707 echo "${i/ */}"
709 esac
710 done
713 # __git_aliased_command requires 1 argument
714 __git_aliased_command ()
716 local word cmdline=$(git --git-dir="$(__gitdir)" \
717 config --get "alias.$1")
718 for word in $cmdline; do
719 case "$word" in
720 \!gitk|gitk)
721 echo "gitk"
722 return
724 \!*) : shell command alias ;;
725 -*) : option ;;
726 *=*) : setting env ;;
727 git) : git itself ;;
729 echo "$word"
730 return
731 esac
732 done
735 # __git_find_on_cmdline requires 1 argument
736 __git_find_on_cmdline ()
738 local word subcommand c=1
739 while [ $c -lt $cword ]; do
740 word="${words[c]}"
741 for subcommand in $1; do
742 if [ "$subcommand" = "$word" ]; then
743 echo "$subcommand"
744 return
746 done
747 ((c++))
748 done
751 __git_has_doubledash ()
753 local c=1
754 while [ $c -lt $cword ]; do
755 if [ "--" = "${words[c]}" ]; then
756 return 0
758 ((c++))
759 done
760 return 1
763 __git_whitespacelist="nowarn warn error error-all fix"
765 _git_am ()
767 local dir="$(__gitdir)"
768 if [ -d "$dir"/rebase-apply ]; then
769 __gitcomp "--skip --continue --resolved --abort"
770 return
772 case "$cur" in
773 --whitespace=*)
774 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
775 return
777 --*)
778 __gitcomp "
779 --3way --committer-date-is-author-date --ignore-date
780 --ignore-whitespace --ignore-space-change
781 --interactive --keep --no-utf8 --signoff --utf8
782 --whitespace= --scissors
784 return
785 esac
786 COMPREPLY=()
789 _git_apply ()
791 case "$cur" in
792 --whitespace=*)
793 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
794 return
796 --*)
797 __gitcomp "
798 --stat --numstat --summary --check --index
799 --cached --index-info --reverse --reject --unidiff-zero
800 --apply --no-add --exclude=
801 --ignore-whitespace --ignore-space-change
802 --whitespace= --inaccurate-eof --verbose
804 return
805 esac
806 COMPREPLY=()
809 _git_add ()
811 __git_has_doubledash && return
813 case "$cur" in
814 --*)
815 __gitcomp "
816 --interactive --refresh --patch --update --dry-run
817 --ignore-errors --intent-to-add
819 return
820 esac
821 COMPREPLY=()
824 _git_archive ()
826 case "$cur" in
827 --format=*)
828 __gitcomp "$(git archive --list)" "" "${cur##--format=}"
829 return
831 --remote=*)
832 __gitcomp_nl "$(__git_remotes)" "" "${cur##--remote=}"
833 return
835 --*)
836 __gitcomp "
837 --format= --list --verbose
838 --prefix= --remote= --exec=
840 return
842 esac
843 __git_complete_file
846 _git_bisect ()
848 __git_has_doubledash && return
850 local subcommands="start bad good skip reset visualize replay log run"
851 local subcommand="$(__git_find_on_cmdline "$subcommands")"
852 if [ -z "$subcommand" ]; then
853 if [ -f "$(__gitdir)"/BISECT_START ]; then
854 __gitcomp "$subcommands"
855 else
856 __gitcomp "replay start"
858 return
861 case "$subcommand" in
862 bad|good|reset|skip|start)
863 __gitcomp_nl "$(__git_refs)"
866 COMPREPLY=()
868 esac
871 _git_branch ()
873 local i c=1 only_local_ref="n" has_r="n"
875 while [ $c -lt $cword ]; do
876 i="${words[c]}"
877 case "$i" in
878 -d|-m) only_local_ref="y" ;;
879 -r) has_r="y" ;;
880 esac
881 ((c++))
882 done
884 case "$cur" in
885 --set-upstream-to=*)
886 __gitcomp "$(__git_refs)" "" "${cur##--set-upstream-to=}"
888 --*)
889 __gitcomp "
890 --color --no-color --verbose --abbrev= --no-abbrev
891 --track --no-track --contains --merged --no-merged
892 --set-upstream-to= --edit-description --list
893 --unset-upstream
897 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
898 __gitcomp_nl "$(__git_heads)"
899 else
900 __gitcomp_nl "$(__git_refs)"
903 esac
906 _git_bundle ()
908 local cmd="${words[2]}"
909 case "$cword" in
911 __gitcomp "create list-heads verify unbundle"
914 # looking for a file
917 case "$cmd" in
918 create)
919 __git_complete_revlist
921 esac
923 esac
926 _git_checkout ()
928 __git_has_doubledash && return
930 case "$cur" in
931 --conflict=*)
932 __gitcomp "diff3 merge" "" "${cur##--conflict=}"
934 --*)
935 __gitcomp "
936 --quiet --ours --theirs --track --no-track --merge
937 --conflict= --orphan --patch
941 # check if --track, --no-track, or --no-guess was specified
942 # if so, disable DWIM mode
943 local flags="--track --no-track --no-guess" track=1
944 if [ -n "$(__git_find_on_cmdline "$flags")" ]; then
945 track=''
947 __gitcomp_nl "$(__git_refs '' $track)"
949 esac
952 _git_cherry ()
954 __gitcomp "$(__git_refs)"
957 _git_cherry_pick ()
959 case "$cur" in
960 --*)
961 __gitcomp "--edit --no-commit"
964 __gitcomp_nl "$(__git_refs)"
966 esac
969 _git_clean ()
971 __git_has_doubledash && return
973 case "$cur" in
974 --*)
975 __gitcomp "--dry-run --quiet"
976 return
978 esac
979 COMPREPLY=()
982 _git_clone ()
984 case "$cur" in
985 --*)
986 __gitcomp "
987 --local
988 --no-hardlinks
989 --shared
990 --reference
991 --quiet
992 --no-checkout
993 --bare
994 --mirror
995 --origin
996 --upload-pack
997 --template=
998 --depth
1000 return
1002 esac
1003 COMPREPLY=()
1006 _git_commit ()
1008 __git_has_doubledash && return
1010 case "$cur" in
1011 --cleanup=*)
1012 __gitcomp "default strip verbatim whitespace
1013 " "" "${cur##--cleanup=}"
1014 return
1016 --reuse-message=*|--reedit-message=*|\
1017 --fixup=*|--squash=*)
1018 __gitcomp_nl "$(__git_refs)" "" "${cur#*=}"
1019 return
1021 --untracked-files=*)
1022 __gitcomp "all no normal" "" "${cur##--untracked-files=}"
1023 return
1025 --*)
1026 __gitcomp "
1027 --all --author= --signoff --verify --no-verify
1028 --edit --no-edit
1029 --amend --include --only --interactive
1030 --dry-run --reuse-message= --reedit-message=
1031 --reset-author --file= --message= --template=
1032 --cleanup= --untracked-files --untracked-files=
1033 --verbose --quiet --fixup= --squash=
1035 return
1036 esac
1037 COMPREPLY=()
1040 _git_describe ()
1042 case "$cur" in
1043 --*)
1044 __gitcomp "
1045 --all --tags --contains --abbrev= --candidates=
1046 --exact-match --debug --long --match --always
1048 return
1049 esac
1050 __gitcomp_nl "$(__git_refs)"
1053 __git_diff_common_options="--stat --numstat --shortstat --summary
1054 --patch-with-stat --name-only --name-status --color
1055 --no-color --color-words --no-renames --check
1056 --full-index --binary --abbrev --diff-filter=
1057 --find-copies-harder
1058 --text --ignore-space-at-eol --ignore-space-change
1059 --ignore-all-space --exit-code --quiet --ext-diff
1060 --no-ext-diff
1061 --no-prefix --src-prefix= --dst-prefix=
1062 --inter-hunk-context=
1063 --patience
1064 --raw
1065 --dirstat --dirstat= --dirstat-by-file
1066 --dirstat-by-file= --cumulative
1069 _git_diff ()
1071 __git_has_doubledash && return
1073 case "$cur" in
1074 --*)
1075 __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
1076 --base --ours --theirs --no-index
1077 $__git_diff_common_options
1079 return
1081 esac
1082 __git_complete_revlist_file
1085 __git_mergetools_common="diffuse ecmerge emerge kdiff3 meld opendiff
1086 tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc3 codecompare
1089 _git_difftool ()
1091 __git_has_doubledash && return
1093 case "$cur" in
1094 --tool=*)
1095 __gitcomp "$__git_mergetools_common kompare" "" "${cur##--tool=}"
1096 return
1098 --*)
1099 __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
1100 --base --ours --theirs
1101 --no-renames --diff-filter= --find-copies-harder
1102 --relative --ignore-submodules
1103 --tool="
1104 return
1106 esac
1107 __git_complete_file
1110 __git_fetch_options="
1111 --quiet --verbose --append --upload-pack --force --keep --depth=
1112 --tags --no-tags --all --prune --dry-run
1115 _git_fetch ()
1117 case "$cur" in
1118 --*)
1119 __gitcomp "$__git_fetch_options"
1120 return
1122 esac
1123 __git_complete_remote_or_refspec
1126 _git_format_patch ()
1128 case "$cur" in
1129 --thread=*)
1130 __gitcomp "
1131 deep shallow
1132 " "" "${cur##--thread=}"
1133 return
1135 --*)
1136 __gitcomp "
1137 --stdout --attach --no-attach --thread --thread=
1138 --output-directory
1139 --numbered --start-number
1140 --numbered-files
1141 --keep-subject
1142 --signoff --signature --no-signature
1143 --in-reply-to= --cc=
1144 --full-index --binary
1145 --not --all
1146 --cover-letter
1147 --no-prefix --src-prefix= --dst-prefix=
1148 --inline --suffix= --ignore-if-in-upstream
1149 --subject-prefix=
1151 return
1153 esac
1154 __git_complete_revlist
1157 _git_fsck ()
1159 case "$cur" in
1160 --*)
1161 __gitcomp "
1162 --tags --root --unreachable --cache --no-reflogs --full
1163 --strict --verbose --lost-found
1165 return
1167 esac
1168 COMPREPLY=()
1171 _git_gc ()
1173 case "$cur" in
1174 --*)
1175 __gitcomp "--prune --aggressive"
1176 return
1178 esac
1179 COMPREPLY=()
1182 _git_gitk ()
1184 _gitk
1187 __git_match_ctag() {
1188 awk "/^${1////\\/}/ { print \$1 }" "$2"
1191 _git_grep ()
1193 __git_has_doubledash && return
1195 case "$cur" in
1196 --*)
1197 __gitcomp "
1198 --cached
1199 --text --ignore-case --word-regexp --invert-match
1200 --full-name --line-number
1201 --extended-regexp --basic-regexp --fixed-strings
1202 --perl-regexp
1203 --files-with-matches --name-only
1204 --files-without-match
1205 --max-depth
1206 --count
1207 --and --or --not --all-match
1209 return
1211 esac
1213 case "$cword,$prev" in
1214 2,*|*,-*)
1215 if test -r tags; then
1216 __gitcomp_nl "$(__git_match_ctag "$cur" tags)"
1217 return
1220 esac
1222 __gitcomp_nl "$(__git_refs)"
1225 _git_help ()
1227 case "$cur" in
1228 --*)
1229 __gitcomp "--all --info --man --web"
1230 return
1232 esac
1233 __git_compute_all_commands
1234 __gitcomp "$__git_all_commands $(__git_aliases)
1235 attributes cli core-tutorial cvs-migration
1236 diffcore gitk glossary hooks ignore modules
1237 namespaces repository-layout tutorial tutorial-2
1238 workflows
1242 _git_init ()
1244 case "$cur" in
1245 --shared=*)
1246 __gitcomp "
1247 false true umask group all world everybody
1248 " "" "${cur##--shared=}"
1249 return
1251 --*)
1252 __gitcomp "--quiet --bare --template= --shared --shared="
1253 return
1255 esac
1256 COMPREPLY=()
1259 _git_ls_files ()
1261 __git_has_doubledash && return
1263 case "$cur" in
1264 --*)
1265 __gitcomp "--cached --deleted --modified --others --ignored
1266 --stage --directory --no-empty-directory --unmerged
1267 --killed --exclude= --exclude-from=
1268 --exclude-per-directory= --exclude-standard
1269 --error-unmatch --with-tree= --full-name
1270 --abbrev --ignored --exclude-per-directory
1272 return
1274 esac
1275 COMPREPLY=()
1278 _git_ls_remote ()
1280 __gitcomp_nl "$(__git_remotes)"
1283 _git_ls_tree ()
1285 __git_complete_file
1288 # Options that go well for log, shortlog and gitk
1289 __git_log_common_options="
1290 --not --all
1291 --branches --tags --remotes
1292 --first-parent --merges --no-merges
1293 --max-count=
1294 --max-age= --since= --after=
1295 --min-age= --until= --before=
1296 --min-parents= --max-parents=
1297 --no-min-parents --no-max-parents
1299 # Options that go well for log and gitk (not shortlog)
1300 __git_log_gitk_options="
1301 --dense --sparse --full-history
1302 --simplify-merges --simplify-by-decoration
1303 --left-right --notes --no-notes
1305 # Options that go well for log and shortlog (not gitk)
1306 __git_log_shortlog_options="
1307 --author= --committer= --grep=
1308 --all-match
1311 __git_log_pretty_formats="oneline short medium full fuller email raw format:"
1312 __git_log_date_formats="relative iso8601 rfc2822 short local default raw"
1314 _git_log ()
1316 __git_has_doubledash && return
1318 local g="$(git rev-parse --git-dir 2>/dev/null)"
1319 local merge=""
1320 if [ -f "$g/MERGE_HEAD" ]; then
1321 merge="--merge"
1323 case "$cur" in
1324 --pretty=*|--format=*)
1325 __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
1326 " "" "${cur#*=}"
1327 return
1329 --date=*)
1330 __gitcomp "$__git_log_date_formats" "" "${cur##--date=}"
1331 return
1333 --decorate=*)
1334 __gitcomp "long short" "" "${cur##--decorate=}"
1335 return
1337 --*)
1338 __gitcomp "
1339 $__git_log_common_options
1340 $__git_log_shortlog_options
1341 $__git_log_gitk_options
1342 --root --topo-order --date-order --reverse
1343 --follow --full-diff
1344 --abbrev-commit --abbrev=
1345 --relative-date --date=
1346 --pretty= --format= --oneline
1347 --cherry-pick
1348 --graph
1349 --decorate --decorate=
1350 --walk-reflogs
1351 --parents --children
1352 $merge
1353 $__git_diff_common_options
1354 --pickaxe-all --pickaxe-regex
1356 return
1358 esac
1359 __git_complete_revlist
1362 __git_merge_options="
1363 --no-commit --no-stat --log --no-log --squash --strategy
1364 --commit --stat --no-squash --ff --no-ff --ff-only --edit --no-edit
1367 _git_merge ()
1369 __git_complete_strategy && return
1371 case "$cur" in
1372 --*)
1373 __gitcomp "$__git_merge_options"
1374 return
1375 esac
1376 __gitcomp_nl "$(__git_refs)"
1379 _git_mergetool ()
1381 case "$cur" in
1382 --tool=*)
1383 __gitcomp "$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"
1384 return
1386 --*)
1387 __gitcomp "--tool="
1388 return
1390 esac
1391 COMPREPLY=()
1394 _git_merge_base ()
1396 __gitcomp_nl "$(__git_refs)"
1399 _git_mv ()
1401 case "$cur" in
1402 --*)
1403 __gitcomp "--dry-run"
1404 return
1406 esac
1407 COMPREPLY=()
1410 _git_name_rev ()
1412 __gitcomp "--tags --all --stdin"
1415 _git_notes ()
1417 local subcommands='add append copy edit list prune remove show'
1418 local subcommand="$(__git_find_on_cmdline "$subcommands")"
1420 case "$subcommand,$cur" in
1421 ,--*)
1422 __gitcomp '--ref'
1425 case "$prev" in
1426 --ref)
1427 __gitcomp_nl "$(__git_refs)"
1430 __gitcomp "$subcommands --ref"
1432 esac
1434 add,--reuse-message=*|append,--reuse-message=*|\
1435 add,--reedit-message=*|append,--reedit-message=*)
1436 __gitcomp_nl "$(__git_refs)" "" "${cur#*=}"
1438 add,--*|append,--*)
1439 __gitcomp '--file= --message= --reedit-message=
1440 --reuse-message='
1442 copy,--*)
1443 __gitcomp '--stdin'
1445 prune,--*)
1446 __gitcomp '--dry-run --verbose'
1448 prune,*)
1451 case "$prev" in
1452 -m|-F)
1455 __gitcomp_nl "$(__git_refs)"
1457 esac
1459 esac
1462 _git_p4 ()
1464 local subcommands="
1465 clone sync rebase submit
1467 local subcommand="$(__git_find_on_cmdline "$subcommands")"
1468 if [ -z "$subcommand" ]; then
1469 __gitcomp "$subcommands"
1470 else
1471 local common_opts="--git-dir= --verbose"
1472 local sync_opts="
1473 --branch= --detect-branches --changes-file=
1474 --silent --detect-labels --import-labels
1475 --import-local --max-changes= --keep-path
1476 --use-client-spec $common_opts
1478 local clone_opts="
1479 --destination= --bare $sync_opts
1481 local submit_opts="
1482 --origin= -M --preserve-user --export-labels
1483 $common_opts
1486 case "$subcommand,$cur" in
1487 clone,--*)
1488 __gitcomp "$clone_opts"
1490 sync,--*)
1491 __gitcomp "$sync_opts"
1493 rebase,--*)
1494 __gitcomp "$common_opts --import-labels"
1496 submit,--*)
1497 __gitcomp "$submit_opts"
1499 submit,*)
1500 __gitcomp "$(__git_refs)"
1502 esac
1506 _git_pull ()
1508 __git_complete_strategy && return
1510 case "$cur" in
1511 --*)
1512 __gitcomp "
1513 --rebase --no-rebase
1514 $__git_merge_options
1515 $__git_fetch_options
1517 return
1519 esac
1520 __git_complete_remote_or_refspec
1523 _git_push ()
1525 case "$prev" in
1526 --repo)
1527 __gitcomp_nl "$(__git_remotes)"
1528 return
1529 esac
1530 case "$cur" in
1531 --repo=*)
1532 __gitcomp_nl "$(__git_remotes)" "" "${cur##--repo=}"
1533 return
1535 --*)
1536 __gitcomp "
1537 --all --mirror --tags --dry-run --force --verbose
1538 --receive-pack= --repo= --set-upstream
1540 return
1542 esac
1543 __git_complete_remote_or_refspec
1546 _git_rebase ()
1548 local dir="$(__gitdir)"
1549 if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
1550 __gitcomp "--continue --skip --abort"
1551 return
1553 __git_complete_strategy && return
1554 case "$cur" in
1555 --whitespace=*)
1556 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
1557 return
1559 --*)
1560 __gitcomp "
1561 --onto --merge --strategy --interactive
1562 --preserve-merges --stat --no-stat
1563 --committer-date-is-author-date --ignore-date
1564 --ignore-whitespace --whitespace=
1565 --autosquash
1568 return
1569 esac
1570 __gitcomp_nl "$(__git_refs)"
1573 _git_reflog ()
1575 local subcommands="show delete expire"
1576 local subcommand="$(__git_find_on_cmdline "$subcommands")"
1578 if [ -z "$subcommand" ]; then
1579 __gitcomp "$subcommands"
1580 else
1581 __gitcomp_nl "$(__git_refs)"
1585 __git_send_email_confirm_options="always never auto cc compose"
1586 __git_send_email_suppresscc_options="author self cc bodycc sob cccmd body all"
1588 _git_send_email ()
1590 case "$cur" in
1591 --confirm=*)
1592 __gitcomp "
1593 $__git_send_email_confirm_options
1594 " "" "${cur##--confirm=}"
1595 return
1597 --suppress-cc=*)
1598 __gitcomp "
1599 $__git_send_email_suppresscc_options
1600 " "" "${cur##--suppress-cc=}"
1602 return
1604 --smtp-encryption=*)
1605 __gitcomp "ssl tls" "" "${cur##--smtp-encryption=}"
1606 return
1608 --*)
1609 __gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to
1610 --compose --confirm= --dry-run --envelope-sender
1611 --from --identity
1612 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
1613 --no-suppress-from --no-thread --quiet
1614 --signed-off-by-cc --smtp-pass --smtp-server
1615 --smtp-server-port --smtp-encryption= --smtp-user
1616 --subject --suppress-cc= --suppress-from --thread --to
1617 --validate --no-validate"
1618 return
1620 esac
1621 COMPREPLY=()
1624 _git_stage ()
1626 _git_add
1629 __git_config_get_set_variables ()
1631 local prevword word config_file= c=$cword
1632 while [ $c -gt 1 ]; do
1633 word="${words[c]}"
1634 case "$word" in
1635 --global|--system|--file=*)
1636 config_file="$word"
1637 break
1639 -f|--file)
1640 config_file="$word $prevword"
1641 break
1643 esac
1644 prevword=$word
1645 c=$((--c))
1646 done
1648 git --git-dir="$(__gitdir)" config $config_file --list 2>/dev/null |
1649 while read -r line
1651 case "$line" in
1652 *.*=*)
1653 echo "${line/=*/}"
1655 esac
1656 done
1659 _git_config ()
1661 case "$prev" in
1662 branch.*.remote)
1663 __gitcomp_nl "$(__git_remotes)"
1664 return
1666 branch.*.merge)
1667 __gitcomp_nl "$(__git_refs)"
1668 return
1670 remote.*.fetch)
1671 local remote="${prev#remote.}"
1672 remote="${remote%.fetch}"
1673 if [ -z "$cur" ]; then
1674 COMPREPLY=("refs/heads/")
1675 return
1677 __gitcomp_nl "$(__git_refs_remotes "$remote")"
1678 return
1680 remote.*.push)
1681 local remote="${prev#remote.}"
1682 remote="${remote%.push}"
1683 __gitcomp_nl "$(git --git-dir="$(__gitdir)" \
1684 for-each-ref --format='%(refname):%(refname)' \
1685 refs/heads)"
1686 return
1688 pull.twohead|pull.octopus)
1689 __git_compute_merge_strategies
1690 __gitcomp "$__git_merge_strategies"
1691 return
1693 color.branch|color.diff|color.interactive|\
1694 color.showbranch|color.status|color.ui)
1695 __gitcomp "always never auto"
1696 return
1698 color.pager)
1699 __gitcomp "false true"
1700 return
1702 color.*.*)
1703 __gitcomp "
1704 normal black red green yellow blue magenta cyan white
1705 bold dim ul blink reverse
1707 return
1709 help.format)
1710 __gitcomp "man info web html"
1711 return
1713 log.date)
1714 __gitcomp "$__git_log_date_formats"
1715 return
1717 sendemail.aliasesfiletype)
1718 __gitcomp "mutt mailrc pine elm gnus"
1719 return
1721 sendemail.confirm)
1722 __gitcomp "$__git_send_email_confirm_options"
1723 return
1725 sendemail.suppresscc)
1726 __gitcomp "$__git_send_email_suppresscc_options"
1727 return
1729 --get|--get-all|--unset|--unset-all)
1730 __gitcomp_nl "$(__git_config_get_set_variables)"
1731 return
1733 *.*)
1734 COMPREPLY=()
1735 return
1737 esac
1738 case "$cur" in
1739 --*)
1740 __gitcomp "
1741 --global --system --file=
1742 --list --replace-all
1743 --get --get-all --get-regexp
1744 --add --unset --unset-all
1745 --remove-section --rename-section
1747 return
1749 branch.*.*)
1750 local pfx="${cur%.*}." cur_="${cur##*.}"
1751 __gitcomp "remote merge mergeoptions rebase" "$pfx" "$cur_"
1752 return
1754 branch.*)
1755 local pfx="${cur%.*}." cur_="${cur#*.}"
1756 __gitcomp_nl "$(__git_heads)" "$pfx" "$cur_" "."
1757 return
1759 guitool.*.*)
1760 local pfx="${cur%.*}." cur_="${cur##*.}"
1761 __gitcomp "
1762 argprompt cmd confirm needsfile noconsole norescan
1763 prompt revprompt revunmerged title
1764 " "$pfx" "$cur_"
1765 return
1767 difftool.*.*)
1768 local pfx="${cur%.*}." cur_="${cur##*.}"
1769 __gitcomp "cmd path" "$pfx" "$cur_"
1770 return
1772 man.*.*)
1773 local pfx="${cur%.*}." cur_="${cur##*.}"
1774 __gitcomp "cmd path" "$pfx" "$cur_"
1775 return
1777 mergetool.*.*)
1778 local pfx="${cur%.*}." cur_="${cur##*.}"
1779 __gitcomp "cmd path trustExitCode" "$pfx" "$cur_"
1780 return
1782 pager.*)
1783 local pfx="${cur%.*}." cur_="${cur#*.}"
1784 __git_compute_all_commands
1785 __gitcomp_nl "$__git_all_commands" "$pfx" "$cur_"
1786 return
1788 remote.*.*)
1789 local pfx="${cur%.*}." cur_="${cur##*.}"
1790 __gitcomp "
1791 url proxy fetch push mirror skipDefaultUpdate
1792 receivepack uploadpack tagopt pushurl
1793 " "$pfx" "$cur_"
1794 return
1796 remote.*)
1797 local pfx="${cur%.*}." cur_="${cur#*.}"
1798 __gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "."
1799 return
1801 url.*.*)
1802 local pfx="${cur%.*}." cur_="${cur##*.}"
1803 __gitcomp "insteadOf pushInsteadOf" "$pfx" "$cur_"
1804 return
1806 esac
1807 __gitcomp "
1808 add.ignoreErrors
1809 advice.commitBeforeMerge
1810 advice.detachedHead
1811 advice.implicitIdentity
1812 advice.pushNonFastForward
1813 advice.resolveConflict
1814 advice.statusHints
1815 alias.
1816 am.keepcr
1817 apply.ignorewhitespace
1818 apply.whitespace
1819 branch.autosetupmerge
1820 branch.autosetuprebase
1821 browser.
1822 clean.requireForce
1823 color.branch
1824 color.branch.current
1825 color.branch.local
1826 color.branch.plain
1827 color.branch.remote
1828 color.decorate.HEAD
1829 color.decorate.branch
1830 color.decorate.remoteBranch
1831 color.decorate.stash
1832 color.decorate.tag
1833 color.diff
1834 color.diff.commit
1835 color.diff.frag
1836 color.diff.func
1837 color.diff.meta
1838 color.diff.new
1839 color.diff.old
1840 color.diff.plain
1841 color.diff.whitespace
1842 color.grep
1843 color.grep.context
1844 color.grep.filename
1845 color.grep.function
1846 color.grep.linenumber
1847 color.grep.match
1848 color.grep.selected
1849 color.grep.separator
1850 color.interactive
1851 color.interactive.error
1852 color.interactive.header
1853 color.interactive.help
1854 color.interactive.prompt
1855 color.pager
1856 color.showbranch
1857 color.status
1858 color.status.added
1859 color.status.changed
1860 color.status.header
1861 color.status.nobranch
1862 color.status.untracked
1863 color.status.updated
1864 color.ui
1865 commit.status
1866 commit.template
1867 core.abbrev
1868 core.askpass
1869 core.attributesfile
1870 core.autocrlf
1871 core.bare
1872 core.bigFileThreshold
1873 core.compression
1874 core.createObject
1875 core.deltaBaseCacheLimit
1876 core.editor
1877 core.eol
1878 core.excludesfile
1879 core.fileMode
1880 core.fsyncobjectfiles
1881 core.gitProxy
1882 core.ignoreCygwinFSTricks
1883 core.ignoreStat
1884 core.ignorecase
1885 core.logAllRefUpdates
1886 core.loosecompression
1887 core.notesRef
1888 core.packedGitLimit
1889 core.packedGitWindowSize
1890 core.pager
1891 core.preferSymlinkRefs
1892 core.preloadindex
1893 core.quotepath
1894 core.repositoryFormatVersion
1895 core.safecrlf
1896 core.sharedRepository
1897 core.sparseCheckout
1898 core.symlinks
1899 core.trustctime
1900 core.warnAmbiguousRefs
1901 core.whitespace
1902 core.worktree
1903 diff.autorefreshindex
1904 diff.statGraphWidth
1905 diff.external
1906 diff.ignoreSubmodules
1907 diff.mnemonicprefix
1908 diff.noprefix
1909 diff.renameLimit
1910 diff.renames
1911 diff.suppressBlankEmpty
1912 diff.tool
1913 diff.wordRegex
1914 difftool.
1915 difftool.prompt
1916 fetch.recurseSubmodules
1917 fetch.unpackLimit
1918 format.attach
1919 format.cc
1920 format.headers
1921 format.numbered
1922 format.pretty
1923 format.signature
1924 format.signoff
1925 format.subjectprefix
1926 format.suffix
1927 format.thread
1928 format.to
1930 gc.aggressiveWindow
1931 gc.auto
1932 gc.autopacklimit
1933 gc.packrefs
1934 gc.pruneexpire
1935 gc.reflogexpire
1936 gc.reflogexpireunreachable
1937 gc.rerereresolved
1938 gc.rerereunresolved
1939 gitcvs.allbinary
1940 gitcvs.commitmsgannotation
1941 gitcvs.dbTableNamePrefix
1942 gitcvs.dbdriver
1943 gitcvs.dbname
1944 gitcvs.dbpass
1945 gitcvs.dbuser
1946 gitcvs.enabled
1947 gitcvs.logfile
1948 gitcvs.usecrlfattr
1949 guitool.
1950 gui.blamehistoryctx
1951 gui.commitmsgwidth
1952 gui.copyblamethreshold
1953 gui.diffcontext
1954 gui.encoding
1955 gui.fastcopyblame
1956 gui.matchtrackingbranch
1957 gui.newbranchtemplate
1958 gui.pruneduringfetch
1959 gui.spellingdictionary
1960 gui.trustmtime
1961 help.autocorrect
1962 help.browser
1963 help.format
1964 http.lowSpeedLimit
1965 http.lowSpeedTime
1966 http.maxRequests
1967 http.minSessions
1968 http.noEPSV
1969 http.postBuffer
1970 http.proxy
1971 http.sslCAInfo
1972 http.sslCAPath
1973 http.sslCert
1974 http.sslCertPasswordProtected
1975 http.sslKey
1976 http.sslVerify
1977 http.useragent
1978 i18n.commitEncoding
1979 i18n.logOutputEncoding
1980 imap.authMethod
1981 imap.folder
1982 imap.host
1983 imap.pass
1984 imap.port
1985 imap.preformattedHTML
1986 imap.sslverify
1987 imap.tunnel
1988 imap.user
1989 init.templatedir
1990 instaweb.browser
1991 instaweb.httpd
1992 instaweb.local
1993 instaweb.modulepath
1994 instaweb.port
1995 interactive.singlekey
1996 log.date
1997 log.decorate
1998 log.showroot
1999 mailmap.file
2000 man.
2001 man.viewer
2002 merge.
2003 merge.conflictstyle
2004 merge.log
2005 merge.renameLimit
2006 merge.renormalize
2007 merge.stat
2008 merge.tool
2009 merge.verbosity
2010 mergetool.
2011 mergetool.keepBackup
2012 mergetool.keepTemporaries
2013 mergetool.prompt
2014 notes.displayRef
2015 notes.rewrite.
2016 notes.rewrite.amend
2017 notes.rewrite.rebase
2018 notes.rewriteMode
2019 notes.rewriteRef
2020 pack.compression
2021 pack.deltaCacheLimit
2022 pack.deltaCacheSize
2023 pack.depth
2024 pack.indexVersion
2025 pack.packSizeLimit
2026 pack.threads
2027 pack.window
2028 pack.windowMemory
2029 pager.
2030 pretty.
2031 pull.octopus
2032 pull.twohead
2033 push.default
2034 rebase.autosquash
2035 rebase.stat
2036 receive.autogc
2037 receive.denyCurrentBranch
2038 receive.denyDeleteCurrent
2039 receive.denyDeletes
2040 receive.denyNonFastForwards
2041 receive.fsckObjects
2042 receive.unpackLimit
2043 receive.updateserverinfo
2044 remotes.
2045 repack.usedeltabaseoffset
2046 rerere.autoupdate
2047 rerere.enabled
2048 sendemail.
2049 sendemail.aliasesfile
2050 sendemail.aliasfiletype
2051 sendemail.bcc
2052 sendemail.cc
2053 sendemail.cccmd
2054 sendemail.chainreplyto
2055 sendemail.confirm
2056 sendemail.envelopesender
2057 sendemail.from
2058 sendemail.identity
2059 sendemail.multiedit
2060 sendemail.signedoffbycc
2061 sendemail.smtpdomain
2062 sendemail.smtpencryption
2063 sendemail.smtppass
2064 sendemail.smtpserver
2065 sendemail.smtpserveroption
2066 sendemail.smtpserverport
2067 sendemail.smtpuser
2068 sendemail.suppresscc
2069 sendemail.suppressfrom
2070 sendemail.thread
2071 sendemail.to
2072 sendemail.validate
2073 showbranch.default
2074 status.relativePaths
2075 status.showUntrackedFiles
2076 status.submodulesummary
2077 submodule.
2078 tar.umask
2079 transfer.unpackLimit
2080 url.
2081 user.email
2082 user.name
2083 user.signingkey
2084 web.browser
2085 branch. remote.
2089 _git_remote ()
2091 local subcommands="add rename remove set-head set-branches set-url show prune update"
2092 local subcommand="$(__git_find_on_cmdline "$subcommands")"
2093 if [ -z "$subcommand" ]; then
2094 __gitcomp "$subcommands"
2095 return
2098 case "$subcommand" in
2099 rename|remove|set-url|show|prune)
2100 __gitcomp_nl "$(__git_remotes)"
2102 set-head|set-branches)
2103 __git_complete_remote_or_refspec
2105 update)
2106 local i c='' IFS=$'\n'
2107 for i in $(git --git-dir="$(__gitdir)" config --get-regexp "remotes\..*" 2>/dev/null); do
2108 i="${i#remotes.}"
2109 c="$c ${i/ */}"
2110 done
2111 __gitcomp "$c"
2114 COMPREPLY=()
2116 esac
2119 _git_replace ()
2121 __gitcomp_nl "$(__git_refs)"
2124 _git_reset ()
2126 __git_has_doubledash && return
2128 case "$cur" in
2129 --*)
2130 __gitcomp "--merge --mixed --hard --soft --patch"
2131 return
2133 esac
2134 __gitcomp_nl "$(__git_refs)"
2137 _git_revert ()
2139 case "$cur" in
2140 --*)
2141 __gitcomp "--edit --mainline --no-edit --no-commit --signoff"
2142 return
2144 esac
2145 __gitcomp_nl "$(__git_refs)"
2148 _git_rm ()
2150 __git_has_doubledash && return
2152 case "$cur" in
2153 --*)
2154 __gitcomp "--cached --dry-run --ignore-unmatch --quiet"
2155 return
2157 esac
2158 COMPREPLY=()
2161 _git_shortlog ()
2163 __git_has_doubledash && return
2165 case "$cur" in
2166 --*)
2167 __gitcomp "
2168 $__git_log_common_options
2169 $__git_log_shortlog_options
2170 --numbered --summary
2172 return
2174 esac
2175 __git_complete_revlist
2178 _git_show ()
2180 __git_has_doubledash && return
2182 case "$cur" in
2183 --pretty=*|--format=*)
2184 __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
2185 " "" "${cur#*=}"
2186 return
2188 --*)
2189 __gitcomp "--pretty= --format= --abbrev-commit --oneline
2190 $__git_diff_common_options
2192 return
2194 esac
2195 __git_complete_file
2198 _git_show_branch ()
2200 case "$cur" in
2201 --*)
2202 __gitcomp "
2203 --all --remotes --topo-order --current --more=
2204 --list --independent --merge-base --no-name
2205 --color --no-color
2206 --sha1-name --sparse --topics --reflog
2208 return
2210 esac
2211 __git_complete_revlist
2214 _git_stash ()
2216 local save_opts='--keep-index --no-keep-index --quiet --patch'
2217 local subcommands='save list show apply clear drop pop create branch'
2218 local subcommand="$(__git_find_on_cmdline "$subcommands")"
2219 if [ -z "$subcommand" ]; then
2220 case "$cur" in
2221 --*)
2222 __gitcomp "$save_opts"
2225 if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then
2226 __gitcomp "$subcommands"
2227 else
2228 COMPREPLY=()
2231 esac
2232 else
2233 case "$subcommand,$cur" in
2234 save,--*)
2235 __gitcomp "$save_opts"
2237 apply,--*|pop,--*)
2238 __gitcomp "--index --quiet"
2240 show,--*|drop,--*|branch,--*)
2241 COMPREPLY=()
2243 show,*|apply,*|drop,*|pop,*|branch,*)
2244 __gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \
2245 | sed -n -e 's/:.*//p')"
2248 COMPREPLY=()
2250 esac
2254 _git_submodule ()
2256 __git_has_doubledash && return
2258 local subcommands="add status init update summary foreach sync"
2259 if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then
2260 case "$cur" in
2261 --*)
2262 __gitcomp "--quiet --cached"
2265 __gitcomp "$subcommands"
2267 esac
2268 return
2272 _git_svn ()
2274 local subcommands="
2275 init fetch clone rebase dcommit log find-rev
2276 set-tree commit-diff info create-ignore propget
2277 proplist show-ignore show-externals branch tag blame
2278 migrate mkdirs reset gc
2280 local subcommand="$(__git_find_on_cmdline "$subcommands")"
2281 if [ -z "$subcommand" ]; then
2282 __gitcomp "$subcommands"
2283 else
2284 local remote_opts="--username= --config-dir= --no-auth-cache"
2285 local fc_opts="
2286 --follow-parent --authors-file= --repack=
2287 --no-metadata --use-svm-props --use-svnsync-props
2288 --log-window-size= --no-checkout --quiet
2289 --repack-flags --use-log-author --localtime
2290 --ignore-paths= $remote_opts
2292 local init_opts="
2293 --template= --shared= --trunk= --tags=
2294 --branches= --stdlayout --minimize-url
2295 --no-metadata --use-svm-props --use-svnsync-props
2296 --rewrite-root= --prefix= --use-log-author
2297 --add-author-from $remote_opts
2299 local cmt_opts="
2300 --edit --rmdir --find-copies-harder --copy-similarity=
2303 case "$subcommand,$cur" in
2304 fetch,--*)
2305 __gitcomp "--revision= --fetch-all $fc_opts"
2307 clone,--*)
2308 __gitcomp "--revision= $fc_opts $init_opts"
2310 init,--*)
2311 __gitcomp "$init_opts"
2313 dcommit,--*)
2314 __gitcomp "
2315 --merge --strategy= --verbose --dry-run
2316 --fetch-all --no-rebase --commit-url
2317 --revision --interactive $cmt_opts $fc_opts
2320 set-tree,--*)
2321 __gitcomp "--stdin $cmt_opts $fc_opts"
2323 create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\
2324 show-externals,--*|mkdirs,--*)
2325 __gitcomp "--revision="
2327 log,--*)
2328 __gitcomp "
2329 --limit= --revision= --verbose --incremental
2330 --oneline --show-commit --non-recursive
2331 --authors-file= --color
2334 rebase,--*)
2335 __gitcomp "
2336 --merge --verbose --strategy= --local
2337 --fetch-all --dry-run $fc_opts
2340 commit-diff,--*)
2341 __gitcomp "--message= --file= --revision= $cmt_opts"
2343 info,--*)
2344 __gitcomp "--url"
2346 branch,--*)
2347 __gitcomp "--dry-run --message --tag"
2349 tag,--*)
2350 __gitcomp "--dry-run --message"
2352 blame,--*)
2353 __gitcomp "--git-format"
2355 migrate,--*)
2356 __gitcomp "
2357 --config-dir= --ignore-paths= --minimize
2358 --no-auth-cache --username=
2361 reset,--*)
2362 __gitcomp "--revision= --parent"
2365 COMPREPLY=()
2367 esac
2371 _git_tag ()
2373 local i c=1 f=0
2374 while [ $c -lt $cword ]; do
2375 i="${words[c]}"
2376 case "$i" in
2377 -d|-v)
2378 __gitcomp_nl "$(__git_tags)"
2379 return
2384 esac
2385 ((c++))
2386 done
2388 case "$prev" in
2389 -m|-F)
2390 COMPREPLY=()
2392 -*|tag)
2393 if [ $f = 1 ]; then
2394 __gitcomp_nl "$(__git_tags)"
2395 else
2396 COMPREPLY=()
2400 __gitcomp_nl "$(__git_refs)"
2402 esac
2405 _git_whatchanged ()
2407 _git_log
2410 __git_main ()
2412 local i c=1 command __git_dir
2414 while [ $c -lt $cword ]; do
2415 i="${words[c]}"
2416 case "$i" in
2417 --git-dir=*) __git_dir="${i#--git-dir=}" ;;
2418 --bare) __git_dir="." ;;
2419 --help) command="help"; break ;;
2420 -c) c=$((++c)) ;;
2421 -*) ;;
2422 *) command="$i"; break ;;
2423 esac
2424 ((c++))
2425 done
2427 if [ -z "$command" ]; then
2428 case "$cur" in
2429 --*) __gitcomp "
2430 --paginate
2431 --no-pager
2432 --git-dir=
2433 --bare
2434 --version
2435 --exec-path
2436 --exec-path=
2437 --html-path
2438 --info-path
2439 --work-tree=
2440 --namespace=
2441 --no-replace-objects
2442 --help
2445 *) __git_compute_porcelain_commands
2446 __gitcomp "$__git_porcelain_commands $(__git_aliases)" ;;
2447 esac
2448 return
2451 local completion_func="_git_${command//-/_}"
2452 declare -f $completion_func >/dev/null && $completion_func && return
2454 local expansion=$(__git_aliased_command "$command")
2455 if [ -n "$expansion" ]; then
2456 completion_func="_git_${expansion//-/_}"
2457 declare -f $completion_func >/dev/null && $completion_func
2461 __gitk_main ()
2463 __git_has_doubledash && return
2465 local g="$(__gitdir)"
2466 local merge=""
2467 if [ -f "$g/MERGE_HEAD" ]; then
2468 merge="--merge"
2470 case "$cur" in
2471 --*)
2472 __gitcomp "
2473 $__git_log_common_options
2474 $__git_log_gitk_options
2475 $merge
2477 return
2479 esac
2480 __git_complete_revlist
2483 __git_func_wrap ()
2485 if [[ -n ${ZSH_VERSION-} ]]; then
2486 emulate -L bash
2487 setopt KSH_TYPESET
2489 # workaround zsh's bug that leaves 'words' as a special
2490 # variable in versions < 4.3.12
2491 typeset -h words
2493 # workaround zsh's bug that quotes spaces in the COMPREPLY
2494 # array if IFS doesn't contain spaces.
2495 typeset -h IFS
2497 local cur words cword prev
2498 _get_comp_words_by_ref -n =: cur words cword prev
2502 # Setup completion for certain functions defined above by setting common
2503 # variables and workarounds.
2504 # This is NOT a public function; use at your own risk.
2505 __git_complete ()
2507 local wrapper="__git_wrap${2}"
2508 eval "$wrapper () { __git_func_wrap $2 ; }"
2509 complete -o bashdefault -o default -o nospace -F $wrapper $1 2>/dev/null \
2510 || complete -o default -o nospace -F $wrapper $1
2513 # wrapper for backwards compatibility
2514 _git ()
2516 __git_wrap__git_main
2519 # wrapper for backwards compatibility
2520 _gitk ()
2522 __git_wrap__gitk_main
2525 __git_complete git __git_main
2526 __git_complete gitk __gitk_main
2528 # The following are necessary only for Cygwin, and only are needed
2529 # when the user has tab-completed the executable name and consequently
2530 # included the '.exe' suffix.
2532 if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
2533 __git_complete git.exe __git_main