diff: Introduce --diff-algorithm command line option
[git.git] / contrib / completion / git-completion.bash
blobd592cf9be95c35dd7df64bd21214d1f24afc242e
1 #!bash
3 # bash/zsh completion support for core Git.
5 # Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
6 # Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
7 # Distributed under the GNU General Public License, version 2.0.
9 # The contained completion routines provide support for completing:
11 # *) local and remote branch names
12 # *) local and remote tag names
13 # *) .git/remotes file names
14 # *) git 'subcommands'
15 # *) tree paths within 'ref:path/to/file' expressions
16 # *) common --long-options
18 # To use these routines:
20 # 1) Copy this file to somewhere (e.g. ~/.git-completion.sh).
21 # 2) Add the following line to your .bashrc/.zshrc:
22 # source ~/.git-completion.sh
23 # 3) Consider changing your PS1 to also show the current branch,
24 # see git-prompt.sh for details.
26 case "$COMP_WORDBREAKS" in
27 *:*) : great ;;
28 *) COMP_WORDBREAKS="$COMP_WORDBREAKS:"
29 esac
31 # __gitdir accepts 0 or 1 arguments (i.e., location)
32 # returns location of .git repo
33 __gitdir ()
35 # Note: this function is duplicated in git-prompt.sh
36 # When updating it, make sure you update the other one to match.
37 if [ -z "${1-}" ]; then
38 if [ -n "${__git_dir-}" ]; then
39 echo "$__git_dir"
40 elif [ -n "${GIT_DIR-}" ]; then
41 test -d "${GIT_DIR-}" || return 1
42 echo "$GIT_DIR"
43 elif [ -d .git ]; then
44 echo .git
45 else
46 git rev-parse --git-dir 2>/dev/null
48 elif [ -d "$1/.git" ]; then
49 echo "$1/.git"
50 else
51 echo "$1"
55 __gitcomp_1 ()
57 local c IFS=$' \t\n'
58 for c in $1; do
59 c="$c$2"
60 case $c in
61 --*=*|*.) ;;
62 *) c="$c " ;;
63 esac
64 printf '%s\n' "$c"
65 done
68 # The following function is based on code from:
70 # bash_completion - programmable completion functions for bash 3.2+
72 # Copyright © 2006-2008, Ian Macdonald <ian@caliban.org>
73 # © 2009-2010, Bash Completion Maintainers
74 # <bash-completion-devel@lists.alioth.debian.org>
76 # This program is free software; you can redistribute it and/or modify
77 # it under the terms of the GNU General Public License as published by
78 # the Free Software Foundation; either version 2, or (at your option)
79 # any later version.
81 # This program is distributed in the hope that it will be useful,
82 # but WITHOUT ANY WARRANTY; without even the implied warranty of
83 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
84 # GNU General Public License for more details.
86 # You should have received a copy of the GNU General Public License
87 # along with this program; if not, write to the Free Software Foundation,
88 # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
90 # The latest version of this software can be obtained here:
92 # http://bash-completion.alioth.debian.org/
94 # RELEASE: 2.x
96 # This function can be used to access a tokenized list of words
97 # on the command line:
99 # __git_reassemble_comp_words_by_ref '=:'
100 # if test "${words_[cword_-1]}" = -w
101 # then
102 # ...
103 # fi
105 # The argument should be a collection of characters from the list of
106 # word completion separators (COMP_WORDBREAKS) to treat as ordinary
107 # characters.
109 # This is roughly equivalent to going back in time and setting
110 # COMP_WORDBREAKS to exclude those characters. The intent is to
111 # make option types like --date=<type> and <rev>:<path> easy to
112 # recognize by treating each shell word as a single token.
114 # It is best not to set COMP_WORDBREAKS directly because the value is
115 # shared with other completion scripts. By the time the completion
116 # function gets called, COMP_WORDS has already been populated so local
117 # changes to COMP_WORDBREAKS have no effect.
119 # Output: words_, cword_, cur_.
121 __git_reassemble_comp_words_by_ref()
123 local exclude i j first
124 # Which word separators to exclude?
125 exclude="${1//[^$COMP_WORDBREAKS]}"
126 cword_=$COMP_CWORD
127 if [ -z "$exclude" ]; then
128 words_=("${COMP_WORDS[@]}")
129 return
131 # List of word completion separators has shrunk;
132 # re-assemble words to complete.
133 for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)); do
134 # Append each nonempty word consisting of just
135 # word separator characters to the current word.
136 first=t
137 while
138 [ $i -gt 0 ] &&
139 [ -n "${COMP_WORDS[$i]}" ] &&
140 # word consists of excluded word separators
141 [ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ]
143 # Attach to the previous token,
144 # unless the previous token is the command name.
145 if [ $j -ge 2 ] && [ -n "$first" ]; then
146 ((j--))
148 first=
149 words_[$j]=${words_[j]}${COMP_WORDS[i]}
150 if [ $i = $COMP_CWORD ]; then
151 cword_=$j
153 if (($i < ${#COMP_WORDS[@]} - 1)); then
154 ((i++))
155 else
156 # Done.
157 return
159 done
160 words_[$j]=${words_[j]}${COMP_WORDS[i]}
161 if [ $i = $COMP_CWORD ]; then
162 cword_=$j
164 done
167 if ! type _get_comp_words_by_ref >/dev/null 2>&1; then
168 _get_comp_words_by_ref ()
170 local exclude cur_ words_ cword_
171 if [ "$1" = "-n" ]; then
172 exclude=$2
173 shift 2
175 __git_reassemble_comp_words_by_ref "$exclude"
176 cur_=${words_[cword_]}
177 while [ $# -gt 0 ]; do
178 case "$1" in
179 cur)
180 cur=$cur_
182 prev)
183 prev=${words_[$cword_-1]}
185 words)
186 words=("${words_[@]}")
188 cword)
189 cword=$cword_
191 esac
192 shift
193 done
197 # Generates completion reply with compgen, appending a space to possible
198 # completion words, if necessary.
199 # It accepts 1 to 4 arguments:
200 # 1: List of possible completion words.
201 # 2: A prefix to be added to each possible completion word (optional).
202 # 3: Generate possible completion matches for this word (optional).
203 # 4: A suffix to be appended to each possible completion word (optional).
204 __gitcomp ()
206 local cur_="${3-$cur}"
208 case "$cur_" in
209 --*=)
210 COMPREPLY=()
213 local IFS=$'\n'
214 COMPREPLY=($(compgen -P "${2-}" \
215 -W "$(__gitcomp_1 "${1-}" "${4-}")" \
216 -- "$cur_"))
218 esac
221 # Generates completion reply with compgen from newline-separated possible
222 # completion words by appending a space to all of them.
223 # It accepts 1 to 4 arguments:
224 # 1: List of possible completion words, separated by a single newline.
225 # 2: A prefix to be added to each possible completion word (optional).
226 # 3: Generate possible completion matches for this word (optional).
227 # 4: A suffix to be appended to each possible completion word instead of
228 # the default space (optional). If specified but empty, nothing is
229 # appended.
230 __gitcomp_nl ()
232 local IFS=$'\n'
233 COMPREPLY=($(compgen -P "${2-}" -S "${4- }" -W "$1" -- "${3-$cur}"))
236 __git_heads ()
238 local dir="$(__gitdir)"
239 if [ -d "$dir" ]; then
240 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
241 refs/heads
242 return
246 __git_tags ()
248 local dir="$(__gitdir)"
249 if [ -d "$dir" ]; then
250 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
251 refs/tags
252 return
256 # __git_refs accepts 0, 1 (to pass to __gitdir), or 2 arguments
257 # presence of 2nd argument means use the guess heuristic employed
258 # by checkout for tracking branches
259 __git_refs ()
261 local i hash dir="$(__gitdir "${1-}")" track="${2-}"
262 local format refs
263 if [ -d "$dir" ]; then
264 case "$cur" in
265 refs|refs/*)
266 format="refname"
267 refs="${cur%/*}"
268 track=""
271 for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do
272 if [ -e "$dir/$i" ]; then echo $i; fi
273 done
274 format="refname:short"
275 refs="refs/tags refs/heads refs/remotes"
277 esac
278 git --git-dir="$dir" for-each-ref --format="%($format)" \
279 $refs
280 if [ -n "$track" ]; then
281 # employ the heuristic used by git checkout
282 # Try to find a remote branch that matches the completion word
283 # but only output if the branch name is unique
284 local ref entry
285 git --git-dir="$dir" for-each-ref --shell --format="ref=%(refname:short)" \
286 "refs/remotes/" | \
287 while read -r entry; do
288 eval "$entry"
289 ref="${ref#*/}"
290 if [[ "$ref" == "$cur"* ]]; then
291 echo "$ref"
293 done | sort | uniq -u
295 return
297 case "$cur" in
298 refs|refs/*)
299 git ls-remote "$dir" "$cur*" 2>/dev/null | \
300 while read -r hash i; do
301 case "$i" in
302 *^{}) ;;
303 *) echo "$i" ;;
304 esac
305 done
308 git ls-remote "$dir" HEAD ORIG_HEAD 'refs/tags/*' 'refs/heads/*' 'refs/remotes/*' 2>/dev/null | \
309 while read -r hash i; do
310 case "$i" in
311 *^{}) ;;
312 refs/*) echo "${i#refs/*/}" ;;
313 *) echo "$i" ;;
314 esac
315 done
317 esac
320 # __git_refs2 requires 1 argument (to pass to __git_refs)
321 __git_refs2 ()
323 local i
324 for i in $(__git_refs "$1"); do
325 echo "$i:$i"
326 done
329 # __git_refs_remotes requires 1 argument (to pass to ls-remote)
330 __git_refs_remotes ()
332 local i hash
333 git ls-remote "$1" 'refs/heads/*' 2>/dev/null | \
334 while read -r hash i; do
335 echo "$i:refs/remotes/$1/${i#refs/heads/}"
336 done
339 __git_remotes ()
341 local i IFS=$'\n' d="$(__gitdir)"
342 test -d "$d/remotes" && ls -1 "$d/remotes"
343 for i in $(git --git-dir="$d" config --get-regexp 'remote\..*\.url' 2>/dev/null); do
344 i="${i#remote.}"
345 echo "${i/.url*/}"
346 done
349 __git_list_merge_strategies ()
351 git merge -s help 2>&1 |
352 sed -n -e '/[Aa]vailable strategies are: /,/^$/{
353 s/\.$//
354 s/.*://
355 s/^[ ]*//
356 s/[ ]*$//
361 __git_merge_strategies=
362 # 'git merge -s help' (and thus detection of the merge strategy
363 # list) fails, unfortunately, if run outside of any git working
364 # tree. __git_merge_strategies is set to the empty string in
365 # that case, and the detection will be repeated the next time it
366 # is needed.
367 __git_compute_merge_strategies ()
369 test -n "$__git_merge_strategies" ||
370 __git_merge_strategies=$(__git_list_merge_strategies)
373 __git_complete_revlist_file ()
375 local pfx ls ref cur_="$cur"
376 case "$cur_" in
377 *..?*:*)
378 return
380 ?*:*)
381 ref="${cur_%%:*}"
382 cur_="${cur_#*:}"
383 case "$cur_" in
384 ?*/*)
385 pfx="${cur_%/*}"
386 cur_="${cur_##*/}"
387 ls="$ref:$pfx"
388 pfx="$pfx/"
391 ls="$ref"
393 esac
395 case "$COMP_WORDBREAKS" in
396 *:*) : great ;;
397 *) pfx="$ref:$pfx" ;;
398 esac
400 __gitcomp_nl "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \
401 | sed '/^100... blob /{
402 s,^.* ,,
403 s,$, ,
405 /^120000 blob /{
406 s,^.* ,,
407 s,$, ,
409 /^040000 tree /{
410 s,^.* ,,
411 s,$,/,
413 s/^.* //')" \
414 "$pfx" "$cur_" ""
416 *...*)
417 pfx="${cur_%...*}..."
418 cur_="${cur_#*...}"
419 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
421 *..*)
422 pfx="${cur_%..*}.."
423 cur_="${cur_#*..}"
424 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
427 __gitcomp_nl "$(__git_refs)"
429 esac
433 __git_complete_file ()
435 __git_complete_revlist_file
438 __git_complete_revlist ()
440 __git_complete_revlist_file
443 __git_complete_remote_or_refspec ()
445 local cur_="$cur" cmd="${words[1]}"
446 local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0
447 if [ "$cmd" = "remote" ]; then
448 ((c++))
450 while [ $c -lt $cword ]; do
451 i="${words[c]}"
452 case "$i" in
453 --mirror) [ "$cmd" = "push" ] && no_complete_refspec=1 ;;
454 --all)
455 case "$cmd" in
456 push) no_complete_refspec=1 ;;
457 fetch)
458 COMPREPLY=()
459 return
461 *) ;;
462 esac
464 -*) ;;
465 *) remote="$i"; break ;;
466 esac
467 ((c++))
468 done
469 if [ -z "$remote" ]; then
470 __gitcomp_nl "$(__git_remotes)"
471 return
473 if [ $no_complete_refspec = 1 ]; then
474 COMPREPLY=()
475 return
477 [ "$remote" = "." ] && remote=
478 case "$cur_" in
479 *:*)
480 case "$COMP_WORDBREAKS" in
481 *:*) : great ;;
482 *) pfx="${cur_%%:*}:" ;;
483 esac
484 cur_="${cur_#*:}"
485 lhs=0
488 pfx="+"
489 cur_="${cur_#+}"
491 esac
492 case "$cmd" in
493 fetch)
494 if [ $lhs = 1 ]; then
495 __gitcomp_nl "$(__git_refs2 "$remote")" "$pfx" "$cur_"
496 else
497 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
500 pull|remote)
501 if [ $lhs = 1 ]; then
502 __gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_"
503 else
504 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
507 push)
508 if [ $lhs = 1 ]; then
509 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
510 else
511 __gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_"
514 esac
517 __git_complete_strategy ()
519 __git_compute_merge_strategies
520 case "$prev" in
521 -s|--strategy)
522 __gitcomp "$__git_merge_strategies"
523 return 0
524 esac
525 case "$cur" in
526 --strategy=*)
527 __gitcomp "$__git_merge_strategies" "" "${cur##--strategy=}"
528 return 0
530 esac
531 return 1
534 __git_list_all_commands ()
536 local i IFS=" "$'\n'
537 for i in $(git help -a|egrep '^ [a-zA-Z0-9]')
539 case $i in
540 *--*) : helper pattern;;
541 *) echo $i;;
542 esac
543 done
546 __git_all_commands=
547 __git_compute_all_commands ()
549 test -n "$__git_all_commands" ||
550 __git_all_commands=$(__git_list_all_commands)
553 __git_list_porcelain_commands ()
555 local i IFS=" "$'\n'
556 __git_compute_all_commands
557 for i in $__git_all_commands
559 case $i in
560 *--*) : helper pattern;;
561 applymbox) : ask gittus;;
562 applypatch) : ask gittus;;
563 archimport) : import;;
564 cat-file) : plumbing;;
565 check-attr) : plumbing;;
566 check-ref-format) : plumbing;;
567 checkout-index) : plumbing;;
568 commit-tree) : plumbing;;
569 count-objects) : infrequent;;
570 credential-cache) : credentials helper;;
571 credential-store) : credentials helper;;
572 cvsexportcommit) : export;;
573 cvsimport) : import;;
574 cvsserver) : daemon;;
575 daemon) : daemon;;
576 diff-files) : plumbing;;
577 diff-index) : plumbing;;
578 diff-tree) : plumbing;;
579 fast-import) : import;;
580 fast-export) : export;;
581 fsck-objects) : plumbing;;
582 fetch-pack) : plumbing;;
583 fmt-merge-msg) : plumbing;;
584 for-each-ref) : plumbing;;
585 hash-object) : plumbing;;
586 http-*) : transport;;
587 index-pack) : plumbing;;
588 init-db) : deprecated;;
589 local-fetch) : plumbing;;
590 lost-found) : infrequent;;
591 ls-files) : plumbing;;
592 ls-remote) : plumbing;;
593 ls-tree) : plumbing;;
594 mailinfo) : plumbing;;
595 mailsplit) : plumbing;;
596 merge-*) : plumbing;;
597 mktree) : plumbing;;
598 mktag) : plumbing;;
599 pack-objects) : plumbing;;
600 pack-redundant) : plumbing;;
601 pack-refs) : plumbing;;
602 parse-remote) : plumbing;;
603 patch-id) : plumbing;;
604 peek-remote) : plumbing;;
605 prune) : plumbing;;
606 prune-packed) : plumbing;;
607 quiltimport) : import;;
608 read-tree) : plumbing;;
609 receive-pack) : plumbing;;
610 remote-*) : transport;;
611 repo-config) : deprecated;;
612 rerere) : plumbing;;
613 rev-list) : plumbing;;
614 rev-parse) : plumbing;;
615 runstatus) : plumbing;;
616 sh-setup) : internal;;
617 shell) : daemon;;
618 show-ref) : plumbing;;
619 send-pack) : plumbing;;
620 show-index) : plumbing;;
621 ssh-*) : transport;;
622 stripspace) : plumbing;;
623 symbolic-ref) : plumbing;;
624 tar-tree) : deprecated;;
625 unpack-file) : plumbing;;
626 unpack-objects) : plumbing;;
627 update-index) : plumbing;;
628 update-ref) : plumbing;;
629 update-server-info) : daemon;;
630 upload-archive) : plumbing;;
631 upload-pack) : plumbing;;
632 write-tree) : plumbing;;
633 var) : infrequent;;
634 verify-pack) : infrequent;;
635 verify-tag) : plumbing;;
636 *) echo $i;;
637 esac
638 done
641 __git_porcelain_commands=
642 __git_compute_porcelain_commands ()
644 __git_compute_all_commands
645 test -n "$__git_porcelain_commands" ||
646 __git_porcelain_commands=$(__git_list_porcelain_commands)
649 __git_pretty_aliases ()
651 local i IFS=$'\n'
652 for i in $(git --git-dir="$(__gitdir)" config --get-regexp "pretty\..*" 2>/dev/null); do
653 case "$i" in
654 pretty.*)
655 i="${i#pretty.}"
656 echo "${i/ */}"
658 esac
659 done
662 __git_aliases ()
664 local i IFS=$'\n'
665 for i in $(git --git-dir="$(__gitdir)" config --get-regexp "alias\..*" 2>/dev/null); do
666 case "$i" in
667 alias.*)
668 i="${i#alias.}"
669 echo "${i/ */}"
671 esac
672 done
675 # __git_aliased_command requires 1 argument
676 __git_aliased_command ()
678 local word cmdline=$(git --git-dir="$(__gitdir)" \
679 config --get "alias.$1")
680 for word in $cmdline; do
681 case "$word" in
682 \!gitk|gitk)
683 echo "gitk"
684 return
686 \!*) : shell command alias ;;
687 -*) : option ;;
688 *=*) : setting env ;;
689 git) : git itself ;;
691 echo "$word"
692 return
693 esac
694 done
697 # __git_find_on_cmdline requires 1 argument
698 __git_find_on_cmdline ()
700 local word subcommand c=1
701 while [ $c -lt $cword ]; do
702 word="${words[c]}"
703 for subcommand in $1; do
704 if [ "$subcommand" = "$word" ]; then
705 echo "$subcommand"
706 return
708 done
709 ((c++))
710 done
713 __git_has_doubledash ()
715 local c=1
716 while [ $c -lt $cword ]; do
717 if [ "--" = "${words[c]}" ]; then
718 return 0
720 ((c++))
721 done
722 return 1
725 __git_whitespacelist="nowarn warn error error-all fix"
727 _git_am ()
729 local dir="$(__gitdir)"
730 if [ -d "$dir"/rebase-apply ]; then
731 __gitcomp "--skip --continue --resolved --abort"
732 return
734 case "$cur" in
735 --whitespace=*)
736 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
737 return
739 --*)
740 __gitcomp "
741 --3way --committer-date-is-author-date --ignore-date
742 --ignore-whitespace --ignore-space-change
743 --interactive --keep --no-utf8 --signoff --utf8
744 --whitespace= --scissors
746 return
747 esac
748 COMPREPLY=()
751 _git_apply ()
753 case "$cur" in
754 --whitespace=*)
755 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
756 return
758 --*)
759 __gitcomp "
760 --stat --numstat --summary --check --index
761 --cached --index-info --reverse --reject --unidiff-zero
762 --apply --no-add --exclude=
763 --ignore-whitespace --ignore-space-change
764 --whitespace= --inaccurate-eof --verbose
766 return
767 esac
768 COMPREPLY=()
771 _git_add ()
773 __git_has_doubledash && return
775 case "$cur" in
776 --*)
777 __gitcomp "
778 --interactive --refresh --patch --update --dry-run
779 --ignore-errors --intent-to-add
781 return
782 esac
783 COMPREPLY=()
786 _git_archive ()
788 case "$cur" in
789 --format=*)
790 __gitcomp "$(git archive --list)" "" "${cur##--format=}"
791 return
793 --remote=*)
794 __gitcomp_nl "$(__git_remotes)" "" "${cur##--remote=}"
795 return
797 --*)
798 __gitcomp "
799 --format= --list --verbose
800 --prefix= --remote= --exec=
802 return
804 esac
805 __git_complete_file
808 _git_bisect ()
810 __git_has_doubledash && return
812 local subcommands="start bad good skip reset visualize replay log run"
813 local subcommand="$(__git_find_on_cmdline "$subcommands")"
814 if [ -z "$subcommand" ]; then
815 if [ -f "$(__gitdir)"/BISECT_START ]; then
816 __gitcomp "$subcommands"
817 else
818 __gitcomp "replay start"
820 return
823 case "$subcommand" in
824 bad|good|reset|skip|start)
825 __gitcomp_nl "$(__git_refs)"
828 COMPREPLY=()
830 esac
833 _git_branch ()
835 local i c=1 only_local_ref="n" has_r="n"
837 while [ $c -lt $cword ]; do
838 i="${words[c]}"
839 case "$i" in
840 -d|-m) only_local_ref="y" ;;
841 -r) has_r="y" ;;
842 esac
843 ((c++))
844 done
846 case "$cur" in
847 --set-upstream-to=*)
848 __gitcomp "$(__git_refs)" "" "${cur##--set-upstream-to=}"
850 --*)
851 __gitcomp "
852 --color --no-color --verbose --abbrev= --no-abbrev
853 --track --no-track --contains --merged --no-merged
854 --set-upstream-to= --edit-description --list
855 --unset-upstream
859 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
860 __gitcomp_nl "$(__git_heads)"
861 else
862 __gitcomp_nl "$(__git_refs)"
865 esac
868 _git_bundle ()
870 local cmd="${words[2]}"
871 case "$cword" in
873 __gitcomp "create list-heads verify unbundle"
876 # looking for a file
879 case "$cmd" in
880 create)
881 __git_complete_revlist
883 esac
885 esac
888 _git_checkout ()
890 __git_has_doubledash && return
892 case "$cur" in
893 --conflict=*)
894 __gitcomp "diff3 merge" "" "${cur##--conflict=}"
896 --*)
897 __gitcomp "
898 --quiet --ours --theirs --track --no-track --merge
899 --conflict= --orphan --patch
903 # check if --track, --no-track, or --no-guess was specified
904 # if so, disable DWIM mode
905 local flags="--track --no-track --no-guess" track=1
906 if [ -n "$(__git_find_on_cmdline "$flags")" ]; then
907 track=''
909 __gitcomp_nl "$(__git_refs '' $track)"
911 esac
914 _git_cherry ()
916 __gitcomp "$(__git_refs)"
919 _git_cherry_pick ()
921 case "$cur" in
922 --*)
923 __gitcomp "--edit --no-commit"
926 __gitcomp_nl "$(__git_refs)"
928 esac
931 _git_clean ()
933 __git_has_doubledash && return
935 case "$cur" in
936 --*)
937 __gitcomp "--dry-run --quiet"
938 return
940 esac
941 COMPREPLY=()
944 _git_clone ()
946 case "$cur" in
947 --*)
948 __gitcomp "
949 --local
950 --no-hardlinks
951 --shared
952 --reference
953 --quiet
954 --no-checkout
955 --bare
956 --mirror
957 --origin
958 --upload-pack
959 --template=
960 --depth
961 --single-branch
962 --branch
964 return
966 esac
967 COMPREPLY=()
970 _git_commit ()
972 __git_has_doubledash && return
974 case "$prev" in
975 -c|-C)
976 __gitcomp_nl "$(__git_refs)" "" "${cur}"
977 return
979 esac
981 case "$cur" in
982 --cleanup=*)
983 __gitcomp "default strip verbatim whitespace
984 " "" "${cur##--cleanup=}"
985 return
987 --reuse-message=*|--reedit-message=*|\
988 --fixup=*|--squash=*)
989 __gitcomp_nl "$(__git_refs)" "" "${cur#*=}"
990 return
992 --untracked-files=*)
993 __gitcomp "all no normal" "" "${cur##--untracked-files=}"
994 return
996 --*)
997 __gitcomp "
998 --all --author= --signoff --verify --no-verify
999 --edit --no-edit
1000 --amend --include --only --interactive
1001 --dry-run --reuse-message= --reedit-message=
1002 --reset-author --file= --message= --template=
1003 --cleanup= --untracked-files --untracked-files=
1004 --verbose --quiet --fixup= --squash=
1006 return
1007 esac
1008 COMPREPLY=()
1011 _git_describe ()
1013 case "$cur" in
1014 --*)
1015 __gitcomp "
1016 --all --tags --contains --abbrev= --candidates=
1017 --exact-match --debug --long --match --always
1019 return
1020 esac
1021 __gitcomp_nl "$(__git_refs)"
1024 __git_diff_algorithms="myers minimal patience histogram"
1026 __git_diff_common_options="--stat --numstat --shortstat --summary
1027 --patch-with-stat --name-only --name-status --color
1028 --no-color --color-words --no-renames --check
1029 --full-index --binary --abbrev --diff-filter=
1030 --find-copies-harder
1031 --text --ignore-space-at-eol --ignore-space-change
1032 --ignore-all-space --exit-code --quiet --ext-diff
1033 --no-ext-diff
1034 --no-prefix --src-prefix= --dst-prefix=
1035 --inter-hunk-context=
1036 --patience --histogram --minimal
1037 --raw
1038 --dirstat --dirstat= --dirstat-by-file
1039 --dirstat-by-file= --cumulative
1040 --diff-algorithm=
1043 _git_diff ()
1045 __git_has_doubledash && return
1047 case "$cur" in
1048 --diff-algorithm=*)
1049 __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
1050 return
1052 --*)
1053 __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
1054 --base --ours --theirs --no-index
1055 $__git_diff_common_options
1057 return
1059 esac
1060 __git_complete_revlist_file
1063 __git_mergetools_common="diffuse ecmerge emerge kdiff3 meld opendiff
1064 tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc3 codecompare
1067 _git_difftool ()
1069 __git_has_doubledash && return
1071 case "$cur" in
1072 --tool=*)
1073 __gitcomp "$__git_mergetools_common kompare" "" "${cur##--tool=}"
1074 return
1076 --*)
1077 __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
1078 --base --ours --theirs
1079 --no-renames --diff-filter= --find-copies-harder
1080 --relative --ignore-submodules
1081 --tool="
1082 return
1084 esac
1085 __git_complete_file
1088 __git_fetch_options="
1089 --quiet --verbose --append --upload-pack --force --keep --depth=
1090 --tags --no-tags --all --prune --dry-run
1093 _git_fetch ()
1095 case "$cur" in
1096 --*)
1097 __gitcomp "$__git_fetch_options"
1098 return
1100 esac
1101 __git_complete_remote_or_refspec
1104 __git_format_patch_options="
1105 --stdout --attach --no-attach --thread --thread= --output-directory
1106 --numbered --start-number --numbered-files --keep-subject --signoff
1107 --signature --no-signature --in-reply-to= --cc= --full-index --binary
1108 --not --all --cover-letter --no-prefix --src-prefix= --dst-prefix=
1109 --inline --suffix= --ignore-if-in-upstream --subject-prefix=
1112 _git_format_patch ()
1114 case "$cur" in
1115 --thread=*)
1116 __gitcomp "
1117 deep shallow
1118 " "" "${cur##--thread=}"
1119 return
1121 --*)
1122 __gitcomp "$__git_format_patch_options"
1123 return
1125 esac
1126 __git_complete_revlist
1129 _git_fsck ()
1131 case "$cur" in
1132 --*)
1133 __gitcomp "
1134 --tags --root --unreachable --cache --no-reflogs --full
1135 --strict --verbose --lost-found
1137 return
1139 esac
1140 COMPREPLY=()
1143 _git_gc ()
1145 case "$cur" in
1146 --*)
1147 __gitcomp "--prune --aggressive"
1148 return
1150 esac
1151 COMPREPLY=()
1154 _git_gitk ()
1156 _gitk
1159 __git_match_ctag() {
1160 awk "/^${1////\\/}/ { print \$1 }" "$2"
1163 _git_grep ()
1165 __git_has_doubledash && return
1167 case "$cur" in
1168 --*)
1169 __gitcomp "
1170 --cached
1171 --text --ignore-case --word-regexp --invert-match
1172 --full-name --line-number
1173 --extended-regexp --basic-regexp --fixed-strings
1174 --perl-regexp
1175 --files-with-matches --name-only
1176 --files-without-match
1177 --max-depth
1178 --count
1179 --and --or --not --all-match
1181 return
1183 esac
1185 case "$cword,$prev" in
1186 2,*|*,-*)
1187 if test -r tags; then
1188 __gitcomp_nl "$(__git_match_ctag "$cur" tags)"
1189 return
1192 esac
1194 __gitcomp_nl "$(__git_refs)"
1197 _git_help ()
1199 case "$cur" in
1200 --*)
1201 __gitcomp "--all --info --man --web"
1202 return
1204 esac
1205 __git_compute_all_commands
1206 __gitcomp "$__git_all_commands $(__git_aliases)
1207 attributes cli core-tutorial cvs-migration
1208 diffcore gitk glossary hooks ignore modules
1209 namespaces repository-layout tutorial tutorial-2
1210 workflows
1214 _git_init ()
1216 case "$cur" in
1217 --shared=*)
1218 __gitcomp "
1219 false true umask group all world everybody
1220 " "" "${cur##--shared=}"
1221 return
1223 --*)
1224 __gitcomp "--quiet --bare --template= --shared --shared="
1225 return
1227 esac
1228 COMPREPLY=()
1231 _git_ls_files ()
1233 __git_has_doubledash && return
1235 case "$cur" in
1236 --*)
1237 __gitcomp "--cached --deleted --modified --others --ignored
1238 --stage --directory --no-empty-directory --unmerged
1239 --killed --exclude= --exclude-from=
1240 --exclude-per-directory= --exclude-standard
1241 --error-unmatch --with-tree= --full-name
1242 --abbrev --ignored --exclude-per-directory
1244 return
1246 esac
1247 COMPREPLY=()
1250 _git_ls_remote ()
1252 __gitcomp_nl "$(__git_remotes)"
1255 _git_ls_tree ()
1257 __git_complete_file
1260 # Options that go well for log, shortlog and gitk
1261 __git_log_common_options="
1262 --not --all
1263 --branches --tags --remotes
1264 --first-parent --merges --no-merges
1265 --max-count=
1266 --max-age= --since= --after=
1267 --min-age= --until= --before=
1268 --min-parents= --max-parents=
1269 --no-min-parents --no-max-parents
1271 # Options that go well for log and gitk (not shortlog)
1272 __git_log_gitk_options="
1273 --dense --sparse --full-history
1274 --simplify-merges --simplify-by-decoration
1275 --left-right --notes --no-notes
1277 # Options that go well for log and shortlog (not gitk)
1278 __git_log_shortlog_options="
1279 --author= --committer= --grep=
1280 --all-match
1283 __git_log_pretty_formats="oneline short medium full fuller email raw format:"
1284 __git_log_date_formats="relative iso8601 rfc2822 short local default raw"
1286 _git_log ()
1288 __git_has_doubledash && return
1290 local g="$(git rev-parse --git-dir 2>/dev/null)"
1291 local merge=""
1292 if [ -f "$g/MERGE_HEAD" ]; then
1293 merge="--merge"
1295 case "$cur" in
1296 --pretty=*|--format=*)
1297 __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
1298 " "" "${cur#*=}"
1299 return
1301 --date=*)
1302 __gitcomp "$__git_log_date_formats" "" "${cur##--date=}"
1303 return
1305 --decorate=*)
1306 __gitcomp "long short" "" "${cur##--decorate=}"
1307 return
1309 --*)
1310 __gitcomp "
1311 $__git_log_common_options
1312 $__git_log_shortlog_options
1313 $__git_log_gitk_options
1314 --root --topo-order --date-order --reverse
1315 --follow --full-diff
1316 --abbrev-commit --abbrev=
1317 --relative-date --date=
1318 --pretty= --format= --oneline
1319 --cherry-pick
1320 --graph
1321 --decorate --decorate=
1322 --walk-reflogs
1323 --parents --children
1324 $merge
1325 $__git_diff_common_options
1326 --pickaxe-all --pickaxe-regex
1328 return
1330 esac
1331 __git_complete_revlist
1334 __git_merge_options="
1335 --no-commit --no-stat --log --no-log --squash --strategy
1336 --commit --stat --no-squash --ff --no-ff --ff-only --edit --no-edit
1339 _git_merge ()
1341 __git_complete_strategy && return
1343 case "$cur" in
1344 --*)
1345 __gitcomp "$__git_merge_options"
1346 return
1347 esac
1348 __gitcomp_nl "$(__git_refs)"
1351 _git_mergetool ()
1353 case "$cur" in
1354 --tool=*)
1355 __gitcomp "$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"
1356 return
1358 --*)
1359 __gitcomp "--tool="
1360 return
1362 esac
1363 COMPREPLY=()
1366 _git_merge_base ()
1368 __gitcomp_nl "$(__git_refs)"
1371 _git_mv ()
1373 case "$cur" in
1374 --*)
1375 __gitcomp "--dry-run"
1376 return
1378 esac
1379 COMPREPLY=()
1382 _git_name_rev ()
1384 __gitcomp "--tags --all --stdin"
1387 _git_notes ()
1389 local subcommands='add append copy edit list prune remove show'
1390 local subcommand="$(__git_find_on_cmdline "$subcommands")"
1392 case "$subcommand,$cur" in
1393 ,--*)
1394 __gitcomp '--ref'
1397 case "$prev" in
1398 --ref)
1399 __gitcomp_nl "$(__git_refs)"
1402 __gitcomp "$subcommands --ref"
1404 esac
1406 add,--reuse-message=*|append,--reuse-message=*|\
1407 add,--reedit-message=*|append,--reedit-message=*)
1408 __gitcomp_nl "$(__git_refs)" "" "${cur#*=}"
1410 add,--*|append,--*)
1411 __gitcomp '--file= --message= --reedit-message=
1412 --reuse-message='
1414 copy,--*)
1415 __gitcomp '--stdin'
1417 prune,--*)
1418 __gitcomp '--dry-run --verbose'
1420 prune,*)
1423 case "$prev" in
1424 -m|-F)
1427 __gitcomp_nl "$(__git_refs)"
1429 esac
1431 esac
1434 _git_pull ()
1436 __git_complete_strategy && return
1438 case "$cur" in
1439 --*)
1440 __gitcomp "
1441 --rebase --no-rebase
1442 $__git_merge_options
1443 $__git_fetch_options
1445 return
1447 esac
1448 __git_complete_remote_or_refspec
1451 _git_push ()
1453 case "$prev" in
1454 --repo)
1455 __gitcomp_nl "$(__git_remotes)"
1456 return
1457 esac
1458 case "$cur" in
1459 --repo=*)
1460 __gitcomp_nl "$(__git_remotes)" "" "${cur##--repo=}"
1461 return
1463 --*)
1464 __gitcomp "
1465 --all --mirror --tags --dry-run --force --verbose
1466 --receive-pack= --repo= --set-upstream
1468 return
1470 esac
1471 __git_complete_remote_or_refspec
1474 _git_rebase ()
1476 local dir="$(__gitdir)"
1477 if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
1478 __gitcomp "--continue --skip --abort"
1479 return
1481 __git_complete_strategy && return
1482 case "$cur" in
1483 --whitespace=*)
1484 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
1485 return
1487 --*)
1488 __gitcomp "
1489 --onto --merge --strategy --interactive
1490 --preserve-merges --stat --no-stat
1491 --committer-date-is-author-date --ignore-date
1492 --ignore-whitespace --whitespace=
1493 --autosquash
1496 return
1497 esac
1498 __gitcomp_nl "$(__git_refs)"
1501 _git_reflog ()
1503 local subcommands="show delete expire"
1504 local subcommand="$(__git_find_on_cmdline "$subcommands")"
1506 if [ -z "$subcommand" ]; then
1507 __gitcomp "$subcommands"
1508 else
1509 __gitcomp_nl "$(__git_refs)"
1513 __git_send_email_confirm_options="always never auto cc compose"
1514 __git_send_email_suppresscc_options="author self cc bodycc sob cccmd body all"
1516 _git_send_email ()
1518 case "$cur" in
1519 --confirm=*)
1520 __gitcomp "
1521 $__git_send_email_confirm_options
1522 " "" "${cur##--confirm=}"
1523 return
1525 --suppress-cc=*)
1526 __gitcomp "
1527 $__git_send_email_suppresscc_options
1528 " "" "${cur##--suppress-cc=}"
1530 return
1532 --smtp-encryption=*)
1533 __gitcomp "ssl tls" "" "${cur##--smtp-encryption=}"
1534 return
1536 --thread=*)
1537 __gitcomp "
1538 deep shallow
1539 " "" "${cur##--thread=}"
1540 return
1542 --*)
1543 __gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to
1544 --compose --confirm= --dry-run --envelope-sender
1545 --from --identity
1546 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
1547 --no-suppress-from --no-thread --quiet
1548 --signed-off-by-cc --smtp-pass --smtp-server
1549 --smtp-server-port --smtp-encryption= --smtp-user
1550 --subject --suppress-cc= --suppress-from --thread --to
1551 --validate --no-validate
1552 $__git_format_patch_options"
1553 return
1555 esac
1556 __git_complete_revlist
1559 _git_stage ()
1561 _git_add
1564 __git_config_get_set_variables ()
1566 local prevword word config_file= c=$cword
1567 while [ $c -gt 1 ]; do
1568 word="${words[c]}"
1569 case "$word" in
1570 --global|--system|--file=*)
1571 config_file="$word"
1572 break
1574 -f|--file)
1575 config_file="$word $prevword"
1576 break
1578 esac
1579 prevword=$word
1580 c=$((--c))
1581 done
1583 git --git-dir="$(__gitdir)" config $config_file --list 2>/dev/null |
1584 while read -r line
1586 case "$line" in
1587 *.*=*)
1588 echo "${line/=*/}"
1590 esac
1591 done
1594 _git_config ()
1596 case "$prev" in
1597 branch.*.remote)
1598 __gitcomp_nl "$(__git_remotes)"
1599 return
1601 branch.*.merge)
1602 __gitcomp_nl "$(__git_refs)"
1603 return
1605 remote.*.fetch)
1606 local remote="${prev#remote.}"
1607 remote="${remote%.fetch}"
1608 if [ -z "$cur" ]; then
1609 COMPREPLY=("refs/heads/")
1610 return
1612 __gitcomp_nl "$(__git_refs_remotes "$remote")"
1613 return
1615 remote.*.push)
1616 local remote="${prev#remote.}"
1617 remote="${remote%.push}"
1618 __gitcomp_nl "$(git --git-dir="$(__gitdir)" \
1619 for-each-ref --format='%(refname):%(refname)' \
1620 refs/heads)"
1621 return
1623 pull.twohead|pull.octopus)
1624 __git_compute_merge_strategies
1625 __gitcomp "$__git_merge_strategies"
1626 return
1628 color.branch|color.diff|color.interactive|\
1629 color.showbranch|color.status|color.ui)
1630 __gitcomp "always never auto"
1631 return
1633 color.pager)
1634 __gitcomp "false true"
1635 return
1637 color.*.*)
1638 __gitcomp "
1639 normal black red green yellow blue magenta cyan white
1640 bold dim ul blink reverse
1642 return
1644 help.format)
1645 __gitcomp "man info web html"
1646 return
1648 log.date)
1649 __gitcomp "$__git_log_date_formats"
1650 return
1652 sendemail.aliasesfiletype)
1653 __gitcomp "mutt mailrc pine elm gnus"
1654 return
1656 sendemail.confirm)
1657 __gitcomp "$__git_send_email_confirm_options"
1658 return
1660 sendemail.suppresscc)
1661 __gitcomp "$__git_send_email_suppresscc_options"
1662 return
1664 --get|--get-all|--unset|--unset-all)
1665 __gitcomp_nl "$(__git_config_get_set_variables)"
1666 return
1668 *.*)
1669 COMPREPLY=()
1670 return
1672 esac
1673 case "$cur" in
1674 --*)
1675 __gitcomp "
1676 --global --system --file=
1677 --list --replace-all
1678 --get --get-all --get-regexp
1679 --add --unset --unset-all
1680 --remove-section --rename-section
1682 return
1684 branch.*.*)
1685 local pfx="${cur%.*}." cur_="${cur##*.}"
1686 __gitcomp "remote merge mergeoptions rebase" "$pfx" "$cur_"
1687 return
1689 branch.*)
1690 local pfx="${cur%.*}." cur_="${cur#*.}"
1691 __gitcomp_nl "$(__git_heads)" "$pfx" "$cur_" "."
1692 return
1694 guitool.*.*)
1695 local pfx="${cur%.*}." cur_="${cur##*.}"
1696 __gitcomp "
1697 argprompt cmd confirm needsfile noconsole norescan
1698 prompt revprompt revunmerged title
1699 " "$pfx" "$cur_"
1700 return
1702 difftool.*.*)
1703 local pfx="${cur%.*}." cur_="${cur##*.}"
1704 __gitcomp "cmd path" "$pfx" "$cur_"
1705 return
1707 man.*.*)
1708 local pfx="${cur%.*}." cur_="${cur##*.}"
1709 __gitcomp "cmd path" "$pfx" "$cur_"
1710 return
1712 mergetool.*.*)
1713 local pfx="${cur%.*}." cur_="${cur##*.}"
1714 __gitcomp "cmd path trustExitCode" "$pfx" "$cur_"
1715 return
1717 pager.*)
1718 local pfx="${cur%.*}." cur_="${cur#*.}"
1719 __git_compute_all_commands
1720 __gitcomp_nl "$__git_all_commands" "$pfx" "$cur_"
1721 return
1723 remote.*.*)
1724 local pfx="${cur%.*}." cur_="${cur##*.}"
1725 __gitcomp "
1726 url proxy fetch push mirror skipDefaultUpdate
1727 receivepack uploadpack tagopt pushurl
1728 " "$pfx" "$cur_"
1729 return
1731 remote.*)
1732 local pfx="${cur%.*}." cur_="${cur#*.}"
1733 __gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "."
1734 return
1736 url.*.*)
1737 local pfx="${cur%.*}." cur_="${cur##*.}"
1738 __gitcomp "insteadOf pushInsteadOf" "$pfx" "$cur_"
1739 return
1741 esac
1742 __gitcomp "
1743 add.ignoreErrors
1744 advice.commitBeforeMerge
1745 advice.detachedHead
1746 advice.implicitIdentity
1747 advice.pushNonFastForward
1748 advice.resolveConflict
1749 advice.statusHints
1750 alias.
1751 am.keepcr
1752 apply.ignorewhitespace
1753 apply.whitespace
1754 branch.autosetupmerge
1755 branch.autosetuprebase
1756 browser.
1757 clean.requireForce
1758 color.branch
1759 color.branch.current
1760 color.branch.local
1761 color.branch.plain
1762 color.branch.remote
1763 color.decorate.HEAD
1764 color.decorate.branch
1765 color.decorate.remoteBranch
1766 color.decorate.stash
1767 color.decorate.tag
1768 color.diff
1769 color.diff.commit
1770 color.diff.frag
1771 color.diff.func
1772 color.diff.meta
1773 color.diff.new
1774 color.diff.old
1775 color.diff.plain
1776 color.diff.whitespace
1777 color.grep
1778 color.grep.context
1779 color.grep.filename
1780 color.grep.function
1781 color.grep.linenumber
1782 color.grep.match
1783 color.grep.selected
1784 color.grep.separator
1785 color.interactive
1786 color.interactive.error
1787 color.interactive.header
1788 color.interactive.help
1789 color.interactive.prompt
1790 color.pager
1791 color.showbranch
1792 color.status
1793 color.status.added
1794 color.status.changed
1795 color.status.header
1796 color.status.nobranch
1797 color.status.untracked
1798 color.status.updated
1799 color.ui
1800 commit.status
1801 commit.template
1802 core.abbrev
1803 core.askpass
1804 core.attributesfile
1805 core.autocrlf
1806 core.bare
1807 core.bigFileThreshold
1808 core.compression
1809 core.createObject
1810 core.deltaBaseCacheLimit
1811 core.editor
1812 core.eol
1813 core.excludesfile
1814 core.fileMode
1815 core.fsyncobjectfiles
1816 core.gitProxy
1817 core.ignoreCygwinFSTricks
1818 core.ignoreStat
1819 core.ignorecase
1820 core.logAllRefUpdates
1821 core.loosecompression
1822 core.notesRef
1823 core.packedGitLimit
1824 core.packedGitWindowSize
1825 core.pager
1826 core.preferSymlinkRefs
1827 core.preloadindex
1828 core.quotepath
1829 core.repositoryFormatVersion
1830 core.safecrlf
1831 core.sharedRepository
1832 core.sparseCheckout
1833 core.symlinks
1834 core.trustctime
1835 core.warnAmbiguousRefs
1836 core.whitespace
1837 core.worktree
1838 diff.autorefreshindex
1839 diff.statGraphWidth
1840 diff.external
1841 diff.ignoreSubmodules
1842 diff.mnemonicprefix
1843 diff.noprefix
1844 diff.renameLimit
1845 diff.renames
1846 diff.suppressBlankEmpty
1847 diff.tool
1848 diff.wordRegex
1849 diff.algorithm
1850 difftool.
1851 difftool.prompt
1852 fetch.recurseSubmodules
1853 fetch.unpackLimit
1854 format.attach
1855 format.cc
1856 format.headers
1857 format.numbered
1858 format.pretty
1859 format.signature
1860 format.signoff
1861 format.subjectprefix
1862 format.suffix
1863 format.thread
1864 format.to
1866 gc.aggressiveWindow
1867 gc.auto
1868 gc.autopacklimit
1869 gc.packrefs
1870 gc.pruneexpire
1871 gc.reflogexpire
1872 gc.reflogexpireunreachable
1873 gc.rerereresolved
1874 gc.rerereunresolved
1875 gitcvs.allbinary
1876 gitcvs.commitmsgannotation
1877 gitcvs.dbTableNamePrefix
1878 gitcvs.dbdriver
1879 gitcvs.dbname
1880 gitcvs.dbpass
1881 gitcvs.dbuser
1882 gitcvs.enabled
1883 gitcvs.logfile
1884 gitcvs.usecrlfattr
1885 guitool.
1886 gui.blamehistoryctx
1887 gui.commitmsgwidth
1888 gui.copyblamethreshold
1889 gui.diffcontext
1890 gui.encoding
1891 gui.fastcopyblame
1892 gui.matchtrackingbranch
1893 gui.newbranchtemplate
1894 gui.pruneduringfetch
1895 gui.spellingdictionary
1896 gui.trustmtime
1897 help.autocorrect
1898 help.browser
1899 help.format
1900 http.lowSpeedLimit
1901 http.lowSpeedTime
1902 http.maxRequests
1903 http.minSessions
1904 http.noEPSV
1905 http.postBuffer
1906 http.proxy
1907 http.sslCAInfo
1908 http.sslCAPath
1909 http.sslCert
1910 http.sslCertPasswordProtected
1911 http.sslKey
1912 http.sslVerify
1913 http.useragent
1914 i18n.commitEncoding
1915 i18n.logOutputEncoding
1916 imap.authMethod
1917 imap.folder
1918 imap.host
1919 imap.pass
1920 imap.port
1921 imap.preformattedHTML
1922 imap.sslverify
1923 imap.tunnel
1924 imap.user
1925 init.templatedir
1926 instaweb.browser
1927 instaweb.httpd
1928 instaweb.local
1929 instaweb.modulepath
1930 instaweb.port
1931 interactive.singlekey
1932 log.date
1933 log.decorate
1934 log.showroot
1935 mailmap.file
1936 man.
1937 man.viewer
1938 merge.
1939 merge.conflictstyle
1940 merge.log
1941 merge.renameLimit
1942 merge.renormalize
1943 merge.stat
1944 merge.tool
1945 merge.verbosity
1946 mergetool.
1947 mergetool.keepBackup
1948 mergetool.keepTemporaries
1949 mergetool.prompt
1950 notes.displayRef
1951 notes.rewrite.
1952 notes.rewrite.amend
1953 notes.rewrite.rebase
1954 notes.rewriteMode
1955 notes.rewriteRef
1956 pack.compression
1957 pack.deltaCacheLimit
1958 pack.deltaCacheSize
1959 pack.depth
1960 pack.indexVersion
1961 pack.packSizeLimit
1962 pack.threads
1963 pack.window
1964 pack.windowMemory
1965 pager.
1966 pretty.
1967 pull.octopus
1968 pull.twohead
1969 push.default
1970 rebase.autosquash
1971 rebase.stat
1972 receive.autogc
1973 receive.denyCurrentBranch
1974 receive.denyDeleteCurrent
1975 receive.denyDeletes
1976 receive.denyNonFastForwards
1977 receive.fsckObjects
1978 receive.unpackLimit
1979 receive.updateserverinfo
1980 remotes.
1981 repack.usedeltabaseoffset
1982 rerere.autoupdate
1983 rerere.enabled
1984 sendemail.
1985 sendemail.aliasesfile
1986 sendemail.aliasfiletype
1987 sendemail.bcc
1988 sendemail.cc
1989 sendemail.cccmd
1990 sendemail.chainreplyto
1991 sendemail.confirm
1992 sendemail.envelopesender
1993 sendemail.from
1994 sendemail.identity
1995 sendemail.multiedit
1996 sendemail.signedoffbycc
1997 sendemail.smtpdomain
1998 sendemail.smtpencryption
1999 sendemail.smtppass
2000 sendemail.smtpserver
2001 sendemail.smtpserveroption
2002 sendemail.smtpserverport
2003 sendemail.smtpuser
2004 sendemail.suppresscc
2005 sendemail.suppressfrom
2006 sendemail.thread
2007 sendemail.to
2008 sendemail.validate
2009 showbranch.default
2010 status.relativePaths
2011 status.showUntrackedFiles
2012 status.submodulesummary
2013 submodule.
2014 tar.umask
2015 transfer.unpackLimit
2016 url.
2017 user.email
2018 user.name
2019 user.signingkey
2020 web.browser
2021 branch. remote.
2025 _git_remote ()
2027 local subcommands="add rename remove set-head set-branches set-url show prune update"
2028 local subcommand="$(__git_find_on_cmdline "$subcommands")"
2029 if [ -z "$subcommand" ]; then
2030 __gitcomp "$subcommands"
2031 return
2034 case "$subcommand" in
2035 rename|remove|set-url|show|prune)
2036 __gitcomp_nl "$(__git_remotes)"
2038 set-head|set-branches)
2039 __git_complete_remote_or_refspec
2041 update)
2042 local i c='' IFS=$'\n'
2043 for i in $(git --git-dir="$(__gitdir)" config --get-regexp "remotes\..*" 2>/dev/null); do
2044 i="${i#remotes.}"
2045 c="$c ${i/ */}"
2046 done
2047 __gitcomp "$c"
2050 COMPREPLY=()
2052 esac
2055 _git_replace ()
2057 __gitcomp_nl "$(__git_refs)"
2060 _git_reset ()
2062 __git_has_doubledash && return
2064 case "$cur" in
2065 --*)
2066 __gitcomp "--merge --mixed --hard --soft --patch"
2067 return
2069 esac
2070 __gitcomp_nl "$(__git_refs)"
2073 _git_revert ()
2075 case "$cur" in
2076 --*)
2077 __gitcomp "--edit --mainline --no-edit --no-commit --signoff"
2078 return
2080 esac
2081 __gitcomp_nl "$(__git_refs)"
2084 _git_rm ()
2086 __git_has_doubledash && return
2088 case "$cur" in
2089 --*)
2090 __gitcomp "--cached --dry-run --ignore-unmatch --quiet"
2091 return
2093 esac
2094 COMPREPLY=()
2097 _git_shortlog ()
2099 __git_has_doubledash && return
2101 case "$cur" in
2102 --*)
2103 __gitcomp "
2104 $__git_log_common_options
2105 $__git_log_shortlog_options
2106 --numbered --summary
2108 return
2110 esac
2111 __git_complete_revlist
2114 _git_show ()
2116 __git_has_doubledash && return
2118 case "$cur" in
2119 --pretty=*|--format=*)
2120 __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
2121 " "" "${cur#*=}"
2122 return
2124 --diff-algorithm=*)
2125 __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
2126 return
2128 --*)
2129 __gitcomp "--pretty= --format= --abbrev-commit --oneline
2130 $__git_diff_common_options
2132 return
2134 esac
2135 __git_complete_file
2138 _git_show_branch ()
2140 case "$cur" in
2141 --*)
2142 __gitcomp "
2143 --all --remotes --topo-order --current --more=
2144 --list --independent --merge-base --no-name
2145 --color --no-color
2146 --sha1-name --sparse --topics --reflog
2148 return
2150 esac
2151 __git_complete_revlist
2154 _git_stash ()
2156 local save_opts='--keep-index --no-keep-index --quiet --patch'
2157 local subcommands='save list show apply clear drop pop create branch'
2158 local subcommand="$(__git_find_on_cmdline "$subcommands")"
2159 if [ -z "$subcommand" ]; then
2160 case "$cur" in
2161 --*)
2162 __gitcomp "$save_opts"
2165 if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then
2166 __gitcomp "$subcommands"
2167 else
2168 COMPREPLY=()
2171 esac
2172 else
2173 case "$subcommand,$cur" in
2174 save,--*)
2175 __gitcomp "$save_opts"
2177 apply,--*|pop,--*)
2178 __gitcomp "--index --quiet"
2180 show,--*|drop,--*|branch,--*)
2181 COMPREPLY=()
2183 show,*|apply,*|drop,*|pop,*|branch,*)
2184 __gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \
2185 | sed -n -e 's/:.*//p')"
2188 COMPREPLY=()
2190 esac
2194 _git_submodule ()
2196 __git_has_doubledash && return
2198 local subcommands="add status init update summary foreach sync"
2199 if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then
2200 case "$cur" in
2201 --*)
2202 __gitcomp "--quiet --cached"
2205 __gitcomp "$subcommands"
2207 esac
2208 return
2212 _git_svn ()
2214 local subcommands="
2215 init fetch clone rebase dcommit log find-rev
2216 set-tree commit-diff info create-ignore propget
2217 proplist show-ignore show-externals branch tag blame
2218 migrate mkdirs reset gc
2220 local subcommand="$(__git_find_on_cmdline "$subcommands")"
2221 if [ -z "$subcommand" ]; then
2222 __gitcomp "$subcommands"
2223 else
2224 local remote_opts="--username= --config-dir= --no-auth-cache"
2225 local fc_opts="
2226 --follow-parent --authors-file= --repack=
2227 --no-metadata --use-svm-props --use-svnsync-props
2228 --log-window-size= --no-checkout --quiet
2229 --repack-flags --use-log-author --localtime
2230 --ignore-paths= $remote_opts
2232 local init_opts="
2233 --template= --shared= --trunk= --tags=
2234 --branches= --stdlayout --minimize-url
2235 --no-metadata --use-svm-props --use-svnsync-props
2236 --rewrite-root= --prefix= --use-log-author
2237 --add-author-from $remote_opts
2239 local cmt_opts="
2240 --edit --rmdir --find-copies-harder --copy-similarity=
2243 case "$subcommand,$cur" in
2244 fetch,--*)
2245 __gitcomp "--revision= --fetch-all $fc_opts"
2247 clone,--*)
2248 __gitcomp "--revision= $fc_opts $init_opts"
2250 init,--*)
2251 __gitcomp "$init_opts"
2253 dcommit,--*)
2254 __gitcomp "
2255 --merge --strategy= --verbose --dry-run
2256 --fetch-all --no-rebase --commit-url
2257 --revision --interactive $cmt_opts $fc_opts
2260 set-tree,--*)
2261 __gitcomp "--stdin $cmt_opts $fc_opts"
2263 create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\
2264 show-externals,--*|mkdirs,--*)
2265 __gitcomp "--revision="
2267 log,--*)
2268 __gitcomp "
2269 --limit= --revision= --verbose --incremental
2270 --oneline --show-commit --non-recursive
2271 --authors-file= --color
2274 rebase,--*)
2275 __gitcomp "
2276 --merge --verbose --strategy= --local
2277 --fetch-all --dry-run $fc_opts
2280 commit-diff,--*)
2281 __gitcomp "--message= --file= --revision= $cmt_opts"
2283 info,--*)
2284 __gitcomp "--url"
2286 branch,--*)
2287 __gitcomp "--dry-run --message --tag"
2289 tag,--*)
2290 __gitcomp "--dry-run --message"
2292 blame,--*)
2293 __gitcomp "--git-format"
2295 migrate,--*)
2296 __gitcomp "
2297 --config-dir= --ignore-paths= --minimize
2298 --no-auth-cache --username=
2301 reset,--*)
2302 __gitcomp "--revision= --parent"
2305 COMPREPLY=()
2307 esac
2311 _git_tag ()
2313 local i c=1 f=0
2314 while [ $c -lt $cword ]; do
2315 i="${words[c]}"
2316 case "$i" in
2317 -d|-v)
2318 __gitcomp_nl "$(__git_tags)"
2319 return
2324 esac
2325 ((c++))
2326 done
2328 case "$prev" in
2329 -m|-F)
2330 COMPREPLY=()
2332 -*|tag)
2333 if [ $f = 1 ]; then
2334 __gitcomp_nl "$(__git_tags)"
2335 else
2336 COMPREPLY=()
2340 __gitcomp_nl "$(__git_refs)"
2342 esac
2345 _git_whatchanged ()
2347 _git_log
2350 __git_main ()
2352 local i c=1 command __git_dir
2354 while [ $c -lt $cword ]; do
2355 i="${words[c]}"
2356 case "$i" in
2357 --git-dir=*) __git_dir="${i#--git-dir=}" ;;
2358 --bare) __git_dir="." ;;
2359 --help) command="help"; break ;;
2360 -c) c=$((++c)) ;;
2361 -*) ;;
2362 *) command="$i"; break ;;
2363 esac
2364 ((c++))
2365 done
2367 if [ -z "$command" ]; then
2368 case "$cur" in
2369 --*) __gitcomp "
2370 --paginate
2371 --no-pager
2372 --git-dir=
2373 --bare
2374 --version
2375 --exec-path
2376 --exec-path=
2377 --html-path
2378 --info-path
2379 --work-tree=
2380 --namespace=
2381 --no-replace-objects
2382 --help
2385 *) __git_compute_porcelain_commands
2386 __gitcomp "$__git_porcelain_commands $(__git_aliases)" ;;
2387 esac
2388 return
2391 local completion_func="_git_${command//-/_}"
2392 declare -f $completion_func >/dev/null && $completion_func && return
2394 local expansion=$(__git_aliased_command "$command")
2395 if [ -n "$expansion" ]; then
2396 completion_func="_git_${expansion//-/_}"
2397 declare -f $completion_func >/dev/null && $completion_func
2401 __gitk_main ()
2403 __git_has_doubledash && return
2405 local g="$(__gitdir)"
2406 local merge=""
2407 if [ -f "$g/MERGE_HEAD" ]; then
2408 merge="--merge"
2410 case "$cur" in
2411 --*)
2412 __gitcomp "
2413 $__git_log_common_options
2414 $__git_log_gitk_options
2415 $merge
2417 return
2419 esac
2420 __git_complete_revlist
2423 if [[ -n ${ZSH_VERSION-} ]]; then
2424 echo "WARNING: this script is deprecated, please see git-completion.zsh" 1>&2
2426 autoload -U +X compinit && compinit
2428 __gitcomp ()
2430 emulate -L zsh
2432 local cur_="${3-$cur}"
2434 case "$cur_" in
2435 --*=)
2438 local c IFS=$' \t\n'
2439 local -a array
2440 for c in ${=1}; do
2441 c="$c${4-}"
2442 case $c in
2443 --*=*|*.) ;;
2444 *) c="$c " ;;
2445 esac
2446 array+=("$c")
2447 done
2448 compset -P '*[=:]'
2449 compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
2451 esac
2454 __gitcomp_nl ()
2456 emulate -L zsh
2458 local IFS=$'\n'
2459 compset -P '*[=:]'
2460 compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
2463 __git_zsh_helper ()
2465 emulate -L ksh
2466 local cur cword prev
2467 cur=${words[CURRENT-1]}
2468 prev=${words[CURRENT-2]}
2469 let cword=CURRENT-1
2470 __${service}_main
2473 _git ()
2475 emulate -L zsh
2476 local _ret=1
2477 __git_zsh_helper
2478 let _ret && _default -S '' && _ret=0
2479 return _ret
2482 compdef _git git gitk
2483 return
2486 __git_func_wrap ()
2488 local cur words cword prev
2489 _get_comp_words_by_ref -n =: cur words cword prev
2493 # Setup completion for certain functions defined above by setting common
2494 # variables and workarounds.
2495 # This is NOT a public function; use at your own risk.
2496 __git_complete ()
2498 local wrapper="__git_wrap${2}"
2499 eval "$wrapper () { __git_func_wrap $2 ; }"
2500 complete -o bashdefault -o default -o nospace -F $wrapper $1 2>/dev/null \
2501 || complete -o default -o nospace -F $wrapper $1
2504 # wrapper for backwards compatibility
2505 _git ()
2507 __git_wrap__git_main
2510 # wrapper for backwards compatibility
2511 _gitk ()
2513 __git_wrap__gitk_main
2516 __git_complete git __git_main
2517 __git_complete gitk __gitk_main
2519 # The following are necessary only for Cygwin, and only are needed
2520 # when the user has tab-completed the executable name and consequently
2521 # included the '.exe' suffix.
2523 if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
2524 __git_complete git.exe __git_main