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
24 # 3) Consider changing your PS1 to also show the current branch:
25 # Bash: PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
26 # ZSH: PS1='[%n@%m %c$(__git_ps1 " (%s)")]\$ '
28 # The argument to __git_ps1 will be displayed only if you
29 # are currently in a git repository. The %s token will be
30 # the name of the current branch.
32 # In addition, if you set GIT_PS1_SHOWDIRTYSTATE to a nonempty
33 # value, unstaged (*) and staged (+) changes will be shown next
34 # to the branch name. You can configure this per-repository
35 # with the bash.showDirtyState variable, which defaults to true
36 # once GIT_PS1_SHOWDIRTYSTATE is enabled.
38 # You can also see if currently something is stashed, by setting
39 # GIT_PS1_SHOWSTASHSTATE to a nonempty value. If something is stashed,
40 # then a '$' will be shown next to the branch name.
42 # If you would like to see if there're untracked files, then you can
43 # set GIT_PS1_SHOWUNTRACKEDFILES to a nonempty value. If there're
44 # untracked files, then a '%' will be shown next to the branch name.
46 # If you would like to see the difference between HEAD and its
47 # upstream, set GIT_PS1_SHOWUPSTREAM="auto". A "<" indicates
48 # you are behind, ">" indicates you are ahead, and "<>"
49 # indicates you have diverged. You can further control
50 # behaviour by setting GIT_PS1_SHOWUPSTREAM to a space-separated
52 # verbose show number of commits ahead/behind (+/-) upstream
53 # legacy don't use the '--count' option available in recent
54 # versions of git-rev-list
55 # git always compare HEAD to @{upstream}
56 # svn always compare HEAD to your SVN upstream
57 # By default, __git_ps1 will compare HEAD to your SVN upstream
58 # if it can find one, or @{upstream} otherwise. Once you have
59 # set GIT_PS1_SHOWUPSTREAM, you can override it on a
60 # per-repository basis by setting the bash.showUpstream config
64 if [[ -n ${ZSH_VERSION-} ]]; then
65 autoload
-U +X bashcompinit
&& bashcompinit
68 case "$COMP_WORDBREAKS" in
70 *) COMP_WORDBREAKS
="$COMP_WORDBREAKS:"
73 # __gitdir accepts 0 or 1 arguments (i.e., location)
74 # returns location of .git repo
77 if [ -z "${1-}" ]; then
78 if [ -n "${__git_dir-}" ]; then
80 elif [ -d .git
]; then
83 git rev-parse
--git-dir 2>/dev
/null
85 elif [ -d "$1/.git" ]; then
92 # stores the divergence from upstream in $p
93 # used by GIT_PS1_SHOWUPSTREAM
94 __git_ps1_show_upstream
()
97 local svn_remote
=() svn_url_pattern count n
98 local upstream
=git legacy
="" verbose
=""
100 # get some config options from git-config
101 local output
="$(git config -z --get-regexp '^(svn-remote\..*\.url|bash\.showupstream)$' 2>/dev/null | tr '\0\n' '\n ')"
102 while read -r key value
; do
105 GIT_PS1_SHOWUPSTREAM
="$value"
106 if [[ -z "${GIT_PS1_SHOWUPSTREAM}" ]]; then
112 svn_remote
[ $
((${#svn_remote[@]} + 1)) ]="$value"
113 svn_url_pattern
+="\\|$value"
114 upstream
=svn
+git
# default upstream is SVN if available, else git
119 # parse configuration values
120 for option
in ${GIT_PS1_SHOWUPSTREAM}; do
122 git|svn
) upstream
="$option" ;;
123 verbose
) verbose
=1 ;;
130 git
) upstream
="@{upstream}" ;;
132 # get the upstream from the "git-svn-id: ..." in a commit message
133 # (git-svn uses essentially the same procedure internally)
134 local svn_upstream
=($
(git log
--first-parent -1 \
135 --grep="^git-svn-id: \(${svn_url_pattern#??}\)" 2>/dev
/null
))
136 if [[ 0 -ne ${#svn_upstream[@]} ]]; then
137 svn_upstream
=${svn_upstream[ ${#svn_upstream[@]} - 2 ]}
138 svn_upstream
=${svn_upstream%@*}
139 local n_stop
="${#svn_remote[@]}"
140 for ((n
=1; n
<= n_stop
; n
++)); do
141 svn_upstream
=${svn_upstream#${svn_remote[$n]}}
144 if [[ -z "$svn_upstream" ]]; then
145 # default branch name for checkouts with no layout:
146 upstream
=${GIT_SVN_ID:-git-svn}
148 upstream
=${svn_upstream#/}
150 elif [[ "svn+git" = "$upstream" ]]; then
151 upstream
="@{upstream}"
156 # Find how many commits we are ahead/behind our upstream
157 if [[ -z "$legacy" ]]; then
158 count
="$(git rev-list --count --left-right \
159 "$upstream"...HEAD 2>/dev/null)"
161 # produce equivalent output to --count for older versions of git
163 if commits
="$(git rev-list --left-right "$upstream"...HEAD 2>/dev/null)"
165 local commit behind
=0 ahead
=0
166 for commit
in $commits
169 "<"*) ((behind
++)) ;;
173 count
="$behind $ahead"
179 # calculate the result
180 if [[ -z "$verbose" ]]; then
184 "0 0") # equal to upstream
186 "0 "*) # ahead of upstream
188 *" 0") # behind upstream
190 *) # diverged from upstream
197 "0 0") # equal to upstream
199 "0 "*) # ahead of upstream
200 p
=" u+${count#0 }" ;;
201 *" 0") # behind upstream
202 p
=" u-${count% 0}" ;;
203 *) # diverged from upstream
204 p
=" u+${count#* }-${count% *}" ;;
211 # __git_ps1 accepts 0 or 1 arguments (i.e., format string)
212 # returns text to add to bash PS1 prompt (includes branch name)
215 local g
="$(__gitdir)"
219 if [ -f "$g/rebase-merge/interactive" ]; then
221 b
="$(cat "$g/rebase-merge
/head-name
")"
222 elif [ -d "$g/rebase-merge" ]; then
224 b
="$(cat "$g/rebase-merge
/head-name
")"
226 if [ -d "$g/rebase-apply" ]; then
227 if [ -f "$g/rebase-apply/rebasing" ]; then
229 elif [ -f "$g/rebase-apply/applying" ]; then
234 elif [ -f "$g/MERGE_HEAD" ]; then
236 elif [ -f "$g/CHERRY_PICK_HEAD" ]; then
238 elif [ -f "$g/BISECT_LOG" ]; then
242 b
="$(git symbolic-ref HEAD 2>/dev/null)" ||
{
245 case "${GIT_PS1_DESCRIBE_STYLE-}" in
247 git describe --contains HEAD ;;
249 git describe --contains --all HEAD ;;
253 git describe --tags --exact-match HEAD ;;
254 esac 2>/dev/null)" ||
256 b
="$(cut -c1-7 "$g/HEAD
" 2>/dev/null)..." ||
269 if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then
270 if [ "true" = "$(git rev-parse --is-bare-repository 2>/dev/null)" ]; then
275 elif [ "true" = "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
276 if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ]; then
277 if [ "$(git config --bool bash.showDirtyState)" != "false" ]; then
278 git
diff --no-ext-diff --quiet --exit-code || w
="*"
279 if git rev-parse
--quiet --verify HEAD
>/dev
/null
; then
280 git diff-index
--cached --quiet HEAD
-- || i
="+"
286 if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ]; then
287 git rev-parse
--verify refs
/stash
>/dev
/null
2>&1 && s
="$"
290 if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ]; then
291 if [ -n "$(git ls-files --others --exclude-standard)" ]; then
296 if [ -n "${GIT_PS1_SHOWUPSTREAM-}" ]; then
297 __git_ps1_show_upstream
302 printf -- "${1:- (%s)}" "$c${b##refs/heads/}${f:+ $f}$r$p"
306 # __gitcomp_1 requires 2 arguments
309 local c IFS
=' '$
'\t'$
'\n'
312 --*=*) printf %s$
'\n' "$c$2" ;;
313 *.
) printf %s$
'\n' "$c$2" ;;
314 *) printf %s$
'\n' "$c$2 " ;;
319 # The following function is based on code from:
321 # bash_completion - programmable completion functions for bash 3.2+
323 # Copyright © 2006-2008, Ian Macdonald <ian@caliban.org>
324 # © 2009-2010, Bash Completion Maintainers
325 # <bash-completion-devel@lists.alioth.debian.org>
327 # This program is free software; you can redistribute it and/or modify
328 # it under the terms of the GNU General Public License as published by
329 # the Free Software Foundation; either version 2, or (at your option)
332 # This program is distributed in the hope that it will be useful,
333 # but WITHOUT ANY WARRANTY; without even the implied warranty of
334 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
335 # GNU General Public License for more details.
337 # You should have received a copy of the GNU General Public License
338 # along with this program; if not, write to the Free Software Foundation,
339 # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
341 # The latest version of this software can be obtained here:
343 # http://bash-completion.alioth.debian.org/
347 # This function can be used to access a tokenized list of words
348 # on the command line:
350 # __git_reassemble_comp_words_by_ref '=:'
351 # if test "${words_[cword_-1]}" = -w
356 # The argument should be a collection of characters from the list of
357 # word completion separators (COMP_WORDBREAKS) to treat as ordinary
360 # This is roughly equivalent to going back in time and setting
361 # COMP_WORDBREAKS to exclude those characters. The intent is to
362 # make option types like --date=<type> and <rev>:<path> easy to
363 # recognize by treating each shell word as a single token.
365 # It is best not to set COMP_WORDBREAKS directly because the value is
366 # shared with other completion scripts. By the time the completion
367 # function gets called, COMP_WORDS has already been populated so local
368 # changes to COMP_WORDBREAKS have no effect.
370 # Output: words_, cword_, cur_.
372 __git_reassemble_comp_words_by_ref
()
374 local exclude i j first
375 # Which word separators to exclude?
376 exclude
="${1//[^$COMP_WORDBREAKS]}"
378 if [ -z "$exclude" ]; then
379 words_
=("${COMP_WORDS[@]}")
382 # List of word completion separators has shrunk;
383 # re-assemble words to complete.
384 for ((i
=0, j
=0; i
< ${#COMP_WORDS[@]}; i
++, j
++)); do
385 # Append each nonempty word consisting of just
386 # word separator characters to the current word.
390 [ -n "${COMP_WORDS[$i]}" ] &&
391 # word consists of excluded word separators
392 [ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ]
394 # Attach to the previous token,
395 # unless the previous token is the command name.
396 if [ $j -ge 2 ] && [ -n "$first" ]; then
400 words_
[$j]=${words_[j]}${COMP_WORDS[i]}
401 if [ $i = $COMP_CWORD ]; then
404 if (($i < ${#COMP_WORDS[@]} - 1)); then
411 words_
[$j]=${words_[j]}${COMP_WORDS[i]}
412 if [ $i = $COMP_CWORD ]; then
418 if ! type _get_comp_words_by_ref
>/dev
/null
2>&1; then
419 if [[ -z ${ZSH_VERSION:+set} ]]; then
420 _get_comp_words_by_ref
()
422 local exclude cur_ words_ cword_
423 if [ "$1" = "-n" ]; then
427 __git_reassemble_comp_words_by_ref
"$exclude"
428 cur_
=${words_[cword_]}
429 while [ $# -gt 0 ]; do
435 prev
=${words_[$cword_-1]}
438 words
=("${words_[@]}")
448 _get_comp_words_by_ref
()
450 while [ $# -gt 0 ]; do
453 cur
=${COMP_WORDS[COMP_CWORD]}
456 prev
=${COMP_WORDS[COMP_CWORD-1]}
459 words
=("${COMP_WORDS[@]}")
465 # assume COMP_WORDBREAKS is already set sanely
475 # Generates completion reply with compgen, appending a space to possible
476 # completion words, if necessary.
477 # It accepts 1 to 4 arguments:
478 # 1: List of possible completion words.
479 # 2: A prefix to be added to each possible completion word (optional).
480 # 3: Generate possible completion matches for this word (optional).
481 # 4: A suffix to be appended to each possible completion word (optional).
484 local cur_
="${3-$cur}"
492 COMPREPLY
=($
(compgen
-P "${2-}" \
493 -W "$(__gitcomp_1 "${1-}" "${4-}")" \
499 # Generates completion reply with compgen from newline-separated possible
500 # completion words by appending a space to all of them.
501 # It accepts 1 to 4 arguments:
502 # 1: List of possible completion words, separated by a single newline.
503 # 2: A prefix to be added to each possible completion word (optional).
504 # 3: Generate possible completion matches for this word (optional).
505 # 4: A suffix to be appended to each possible completion word instead of
506 # the default space (optional). If specified but empty, nothing is
511 COMPREPLY
=($
(compgen
-P "${2-}" -S "${4- }" -W "$1" -- "${3-$cur}"))
516 local dir
="$(__gitdir)"
517 if [ -d "$dir" ]; then
518 git
--git-dir="$dir" for-each-ref
--format='%(refname:short)' \
526 local dir
="$(__gitdir)"
527 if [ -d "$dir" ]; then
528 git
--git-dir="$dir" for-each-ref
--format='%(refname:short)' \
534 # __git_refs accepts 0, 1 (to pass to __gitdir), or 2 arguments
535 # presence of 2nd argument means use the guess heuristic employed
536 # by checkout for tracking branches
539 local i
hash dir
="$(__gitdir "${1-}")" track
="${2-}"
541 if [ -d "$dir" ]; then
549 for i
in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD
; do
550 if [ -e "$dir/$i" ]; then echo $i; fi
552 format
="refname:short"
553 refs
="refs/tags refs/heads refs/remotes"
556 git
--git-dir="$dir" for-each-ref
--format="%($format)" \
558 if [ -n "$track" ]; then
559 # employ the heuristic used by git checkout
560 # Try to find a remote branch that matches the completion word
561 # but only output if the branch name is unique
563 git
--git-dir="$dir" for-each-ref
--shell --format="ref=%(refname:short)" \
565 while read -r entry
; do
568 if [[ "$ref" == "$cur"* ]]; then
577 git ls-remote
"$dir" "$cur*" 2>/dev
/null | \
578 while read -r hash i
; do
586 git ls-remote
"$dir" HEAD ORIG_HEAD
'refs/tags/*' 'refs/heads/*' 'refs/remotes/*' 2>/dev
/null | \
587 while read -r hash i
; do
590 refs
/*) echo "${i#refs/*/}" ;;
598 # __git_refs2 requires 1 argument (to pass to __git_refs)
602 for i
in $
(__git_refs
"$1"); do
607 # __git_refs_remotes requires 1 argument (to pass to ls-remote)
608 __git_refs_remotes
()
611 git ls-remote
"$1" 'refs/heads/*' 2>/dev
/null | \
612 while read -r hash i
; do
613 echo "$i:refs/remotes/$1/${i#refs/heads/}"
619 local i IFS
=$
'\n' d
="$(__gitdir)"
620 test -d "$d/remotes" && ls -1 "$d/remotes"
621 for i
in $
(git
--git-dir="$d" config
--get-regexp 'remote\..*\.url' 2>/dev
/null
); do
627 __git_list_merge_strategies
()
629 git merge
-s help 2>&1 |
630 sed -n -e '/[Aa]vailable strategies are: /,/^$/{
639 __git_merge_strategies
=
640 # 'git merge -s help' (and thus detection of the merge strategy
641 # list) fails, unfortunately, if run outside of any git working
642 # tree. __git_merge_strategies is set to the empty string in
643 # that case, and the detection will be repeated the next time it
645 __git_compute_merge_strategies
()
647 test -n "$__git_merge_strategies" ||
648 __git_merge_strategies
=$
(__git_list_merge_strategies
)
651 __git_complete_revlist_file
()
653 local pfx
ls ref cur_
="$cur"
673 case "$COMP_WORDBREAKS" in
675 *) pfx
="$ref:$pfx" ;;
679 COMPREPLY
=($
(compgen
-P "$pfx" \
680 -W "$(git --git-dir="$
(__gitdir
)" ls-tree "$ls" \
681 | sed '/^100... blob /{
697 pfx
="${cur_%...*}..."
699 __gitcomp_nl
"$(__git_refs)" "$pfx" "$cur_"
704 __gitcomp_nl
"$(__git_refs)" "$pfx" "$cur_"
707 __gitcomp_nl
"$(__git_refs)"
713 __git_complete_file
()
715 __git_complete_revlist_file
718 __git_complete_revlist
()
720 __git_complete_revlist_file
723 __git_complete_remote_or_refspec
()
725 local cur_
="$cur" cmd
="${words[1]}"
726 local i c
=2 remote
="" pfx
="" lhs
=1 no_complete_refspec
=0
727 if [ "$cmd" = "remote" ]; then
730 while [ $c -lt $cword ]; do
733 --mirror) [ "$cmd" = "push" ] && no_complete_refspec
=1 ;;
736 push
) no_complete_refspec
=1 ;;
745 *) remote
="$i"; break ;;
749 if [ -z "$remote" ]; then
750 __gitcomp_nl
"$(__git_remotes)"
753 if [ $no_complete_refspec = 1 ]; then
757 [ "$remote" = "." ] && remote
=
760 case "$COMP_WORDBREAKS" in
762 *) pfx
="${cur_%%:*}:" ;;
774 if [ $lhs = 1 ]; then
775 __gitcomp_nl
"$(__git_refs2 "$remote")" "$pfx" "$cur_"
777 __gitcomp_nl
"$(__git_refs)" "$pfx" "$cur_"
781 if [ $lhs = 1 ]; then
782 __gitcomp_nl
"$(__git_refs "$remote")" "$pfx" "$cur_"
784 __gitcomp_nl
"$(__git_refs)" "$pfx" "$cur_"
788 if [ $lhs = 1 ]; then
789 __gitcomp_nl
"$(__git_refs)" "$pfx" "$cur_"
791 __gitcomp_nl
"$(__git_refs "$remote")" "$pfx" "$cur_"
797 __git_complete_strategy
()
799 __git_compute_merge_strategies
802 __gitcomp
"$__git_merge_strategies"
807 __gitcomp
"$__git_merge_strategies" "" "${cur##--strategy=}"
814 __git_list_all_commands
()
817 for i
in $
(git
help -a|
egrep '^ [a-zA-Z0-9]')
820 *--*) : helper pattern
;;
827 __git_compute_all_commands
()
829 test -n "$__git_all_commands" ||
830 __git_all_commands
=$
(__git_list_all_commands
)
833 __git_list_porcelain_commands
()
836 __git_compute_all_commands
837 for i
in "help" $__git_all_commands
840 *--*) : helper pattern
;;
841 applymbox
) : ask gittus
;;
842 applypatch
) : ask gittus
;;
843 archimport
) : import
;;
844 cat-file
) : plumbing
;;
845 check-attr
) : plumbing
;;
846 check-ref-format
) : plumbing
;;
847 checkout-index
) : plumbing
;;
848 commit-tree
) : plumbing
;;
849 count-objects
) : infrequent
;;
850 cvsexportcommit
) : export;;
851 cvsimport
) : import
;;
852 cvsserver
) : daemon
;;
854 diff-files
) : plumbing
;;
855 diff-index
) : plumbing
;;
856 diff-tree
) : plumbing
;;
857 fast-import
) : import
;;
858 fast-export
) : export;;
859 fsck-objects
) : plumbing
;;
860 fetch-pack
) : plumbing
;;
861 fmt-merge-msg
) : plumbing
;;
862 for-each-ref
) : plumbing
;;
863 hash-object
) : plumbing
;;
864 http-
*) : transport
;;
865 index-pack
) : plumbing
;;
866 init-db
) : deprecated
;;
867 local-fetch
) : plumbing
;;
868 lost-found
) : infrequent
;;
869 ls-files
) : plumbing
;;
870 ls-remote
) : plumbing
;;
871 ls-tree
) : plumbing
;;
872 mailinfo
) : plumbing
;;
873 mailsplit
) : plumbing
;;
874 merge-
*) : plumbing
;;
877 pack-objects
) : plumbing
;;
878 pack-redundant
) : plumbing
;;
879 pack-refs
) : plumbing
;;
880 parse-remote
) : plumbing
;;
881 patch-id
) : plumbing
;;
882 peek-remote
) : plumbing
;;
884 prune-packed
) : plumbing
;;
885 quiltimport
) : import
;;
886 read-tree
) : plumbing
;;
887 receive-pack
) : plumbing
;;
888 remote-
*) : transport
;;
889 repo-config
) : deprecated
;;
891 rev-list
) : plumbing
;;
892 rev-parse
) : plumbing
;;
893 runstatus
) : plumbing
;;
894 sh-setup
) : internal
;;
896 show-ref
) : plumbing
;;
897 send-pack
) : plumbing
;;
898 show-index
) : plumbing
;;
900 stripspace
) : plumbing
;;
901 symbolic-ref
) : plumbing
;;
902 tar-tree
) : deprecated
;;
903 unpack-file
) : plumbing
;;
904 unpack-objects
) : plumbing
;;
905 update-index
) : plumbing
;;
906 update-ref
) : plumbing
;;
907 update-server-info
) : daemon
;;
908 upload-archive
) : plumbing
;;
909 upload-pack
) : plumbing
;;
910 write-tree
) : plumbing
;;
912 verify-pack
) : infrequent
;;
913 verify-tag
) : plumbing
;;
919 __git_porcelain_commands
=
920 __git_compute_porcelain_commands
()
922 __git_compute_all_commands
923 test -n "$__git_porcelain_commands" ||
924 __git_porcelain_commands
=$
(__git_list_porcelain_commands
)
927 __git_pretty_aliases
()
930 for i
in $
(git
--git-dir="$(__gitdir)" config
--get-regexp "pretty\..*" 2>/dev
/null
); do
943 for i
in $
(git
--git-dir="$(__gitdir)" config
--get-regexp "alias\..*" 2>/dev
/null
); do
953 # __git_aliased_command requires 1 argument
954 __git_aliased_command
()
956 local word cmdline
=$
(git
--git-dir="$(__gitdir)" \
957 config
--get "alias.$1")
958 for word
in $cmdline; do
964 \
!*) : shell
command alias ;;
966 *=*) : setting env
;;
975 # __git_find_on_cmdline requires 1 argument
976 __git_find_on_cmdline
()
978 local word subcommand c
=1
979 while [ $c -lt $cword ]; do
981 for subcommand
in $1; do
982 if [ "$subcommand" = "$word" ]; then
991 __git_has_doubledash
()
994 while [ $c -lt $cword ]; do
995 if [ "--" = "${words[c]}" ]; then
1003 __git_whitespacelist
="nowarn warn error error-all fix"
1007 local dir
="$(__gitdir)"
1008 if [ -d "$dir"/rebase-apply
]; then
1009 __gitcomp
"--skip --continue --resolved --abort"
1014 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
1019 --3way --committer-date-is-author-date --ignore-date
1020 --ignore-whitespace --ignore-space-change
1021 --interactive --keep --no-utf8 --signoff --utf8
1022 --whitespace= --scissors
1033 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
1038 --stat --numstat --summary --check --index
1039 --cached --index-info --reverse --reject --unidiff-zero
1040 --apply --no-add --exclude=
1041 --ignore-whitespace --ignore-space-change
1042 --whitespace= --inaccurate-eof --verbose
1051 __git_has_doubledash
&& return
1056 --interactive --refresh --patch --update --dry-run
1057 --ignore-errors --intent-to-add
1068 __gitcomp
"$(git archive --list)" "" "${cur##--format=}"
1072 __gitcomp_nl
"$(__git_remotes)" "" "${cur##--remote=}"
1077 --format= --list --verbose
1078 --prefix= --remote= --exec=
1088 __git_has_doubledash
&& return
1090 local subcommands
="start bad good skip reset visualize replay log run"
1091 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
1092 if [ -z "$subcommand" ]; then
1093 if [ -f "$(__gitdir)"/BISECT_START
]; then
1094 __gitcomp
"$subcommands"
1096 __gitcomp
"replay start"
1101 case "$subcommand" in
1102 bad|good|
reset|skip|start
)
1103 __gitcomp_nl
"$(__git_refs)"
1113 local i c
=1 only_local_ref
="n" has_r
="n"
1115 while [ $c -lt $cword ]; do
1118 -d|
-m) only_local_ref
="y" ;;
1127 --color --no-color --verbose --abbrev= --no-abbrev
1128 --track --no-track --contains --merged --no-merged
1129 --set-upstream --edit-description --list
1133 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
1134 __gitcomp_nl
"$(__git_heads)"
1136 __gitcomp_nl
"$(__git_refs)"
1144 local cmd
="${words[2]}"
1147 __gitcomp
"create list-heads verify unbundle"
1150 # looking for a file
1155 __git_complete_revlist
1164 __git_has_doubledash
&& return
1168 __gitcomp
"diff3 merge" "" "${cur##--conflict=}"
1172 --quiet --ours --theirs --track --no-track --merge
1173 --conflict= --orphan --patch
1177 # check if --track, --no-track, or --no-guess was specified
1178 # if so, disable DWIM mode
1179 local flags
="--track --no-track --no-guess" track
=1
1180 if [ -n "$(__git_find_on_cmdline "$flags")" ]; then
1183 __gitcomp_nl
"$(__git_refs '' $track)"
1190 __gitcomp
"$(__git_refs)"
1197 __gitcomp
"--edit --no-commit"
1200 __gitcomp_nl
"$(__git_refs)"
1207 __git_has_doubledash
&& return
1211 __gitcomp
"--dry-run --quiet"
1244 __git_has_doubledash
&& return
1248 __gitcomp
"default strip verbatim whitespace
1249 " "" "${cur##--cleanup=}"
1252 --reuse-message=*|
--reedit-message=*|\
1253 --fixup=*|
--squash=*)
1254 __gitcomp_nl
"$(__git_refs)" "" "${cur#*=}"
1257 --untracked-files=*)
1258 __gitcomp
"all no normal" "" "${cur##--untracked-files=}"
1263 --all --author= --signoff --verify --no-verify
1264 --edit --amend --include --only --interactive
1265 --dry-run --reuse-message= --reedit-message=
1266 --reset-author --file= --message= --template=
1267 --cleanup= --untracked-files --untracked-files=
1268 --verbose --quiet --fixup= --squash=
1280 --all --tags --contains --abbrev= --candidates=
1281 --exact-match --debug --long --match --always
1285 __gitcomp_nl
"$(__git_refs)"
1288 __git_diff_common_options
="--stat --numstat --shortstat --summary
1289 --patch-with-stat --name-only --name-status --color
1290 --no-color --color-words --no-renames --check
1291 --full-index --binary --abbrev --diff-filter=
1292 --find-copies-harder
1293 --text --ignore-space-at-eol --ignore-space-change
1294 --ignore-all-space --exit-code --quiet --ext-diff
1296 --no-prefix --src-prefix= --dst-prefix=
1297 --inter-hunk-context=
1300 --dirstat --dirstat= --dirstat-by-file
1301 --dirstat-by-file= --cumulative
1306 __git_has_doubledash
&& return
1310 __gitcomp
"--cached --staged --pickaxe-all --pickaxe-regex
1311 --base --ours --theirs --no-index
1312 $__git_diff_common_options
1317 __git_complete_revlist_file
1320 __git_mergetools_common
="diffuse ecmerge emerge kdiff3 meld opendiff
1321 tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc3
1326 __git_has_doubledash
&& return
1330 __gitcomp
"$__git_mergetools_common kompare" "" "${cur##--tool=}"
1334 __gitcomp
"--cached --staged --pickaxe-all --pickaxe-regex
1335 --base --ours --theirs
1336 --no-renames --diff-filter= --find-copies-harder
1337 --relative --ignore-submodules
1345 __git_fetch_options
="
1346 --quiet --verbose --append --upload-pack --force --keep --depth=
1347 --tags --no-tags --all --prune --dry-run
1354 __gitcomp
"$__git_fetch_options"
1358 __git_complete_remote_or_refspec
1361 _git_format_patch
()
1367 " "" "${cur##--thread=}"
1372 --stdout --attach --no-attach --thread --thread=
1374 --numbered --start-number
1377 --signoff --signature --no-signature
1378 --in-reply-to= --cc=
1379 --full-index --binary
1382 --no-prefix --src-prefix= --dst-prefix=
1383 --inline --suffix= --ignore-if-in-upstream
1389 __git_complete_revlist
1397 --tags --root --unreachable --cache --no-reflogs --full
1398 --strict --verbose --lost-found
1410 __gitcomp
"--prune --aggressive"
1422 __git_match_ctag
() {
1423 awk "/^${1////\\/}/ { print \$1 }" "$2"
1428 __git_has_doubledash
&& return
1434 --text --ignore-case --word-regexp --invert-match
1435 --full-name --line-number
1436 --extended-regexp --basic-regexp --fixed-strings
1438 --files-with-matches --name-only
1439 --files-without-match
1442 --and --or --not --all-match
1448 case "$cword,$prev" in
1450 if test -r tags
; then
1451 __gitcomp_nl
"$(__git_match_ctag "$cur" tags)"
1457 __gitcomp_nl
"$(__git_refs)"
1464 __gitcomp
"--all --info --man --web"
1468 __git_compute_all_commands
1469 __gitcomp
"$__git_all_commands $(__git_aliases)
1470 attributes cli core-tutorial cvs-migration
1471 diffcore gitk glossary hooks ignore modules
1472 namespaces repository-layout tutorial tutorial-2
1482 false true umask group all world everybody
1483 " "" "${cur##--shared=}"
1487 __gitcomp
"--quiet --bare --template= --shared --shared="
1496 __git_has_doubledash
&& return
1500 __gitcomp
"--cached --deleted --modified --others --ignored
1501 --stage --directory --no-empty-directory --unmerged
1502 --killed --exclude= --exclude-from=
1503 --exclude-per-directory= --exclude-standard
1504 --error-unmatch --with-tree= --full-name
1505 --abbrev --ignored --exclude-per-directory
1515 __gitcomp_nl
"$(__git_remotes)"
1523 # Options that go well for log, shortlog and gitk
1524 __git_log_common_options
="
1526 --branches --tags --remotes
1527 --first-parent --merges --no-merges
1529 --max-age= --since= --after=
1530 --min-age= --until= --before=
1531 --min-parents= --max-parents=
1532 --no-min-parents --no-max-parents
1534 # Options that go well for log and gitk (not shortlog)
1535 __git_log_gitk_options
="
1536 --dense --sparse --full-history
1537 --simplify-merges --simplify-by-decoration
1538 --left-right --notes --no-notes
1540 # Options that go well for log and shortlog (not gitk)
1541 __git_log_shortlog_options
="
1542 --author= --committer= --grep=
1546 __git_log_pretty_formats
="oneline short medium full fuller email raw format:"
1547 __git_log_date_formats
="relative iso8601 rfc2822 short local default raw"
1551 __git_has_doubledash
&& return
1553 local g
="$(git rev-parse --git-dir 2>/dev/null)"
1555 if [ -f "$g/MERGE_HEAD" ]; then
1559 --pretty=*|
--format=*)
1560 __gitcomp
"$__git_log_pretty_formats $(__git_pretty_aliases)
1565 __gitcomp
"$__git_log_date_formats" "" "${cur##--date=}"
1569 __gitcomp
"long short" "" "${cur##--decorate=}"
1574 $__git_log_common_options
1575 $__git_log_shortlog_options
1576 $__git_log_gitk_options
1577 --root --topo-order --date-order --reverse
1578 --follow --full-diff
1579 --abbrev-commit --abbrev=
1580 --relative-date --date=
1581 --pretty= --format= --oneline
1584 --decorate --decorate=
1586 --parents --children
1588 $__git_diff_common_options
1589 --pickaxe-all --pickaxe-regex
1594 __git_complete_revlist
1597 __git_merge_options
="
1598 --no-commit --no-stat --log --no-log --squash --strategy
1599 --commit --stat --no-squash --ff --no-ff --ff-only --edit --no-edit
1604 __git_complete_strategy
&& return
1608 __gitcomp
"$__git_merge_options"
1611 __gitcomp_nl
"$(__git_refs)"
1618 __gitcomp
"$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"
1631 __gitcomp_nl
"$(__git_refs)"
1638 __gitcomp
"--dry-run"
1647 __gitcomp
"--tags --all --stdin"
1652 local subcommands
='add append copy edit list prune remove show'
1653 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
1655 case "$subcommand,$cur" in
1660 case "${words[cword-1]}" in
1662 __gitcomp_nl
"$(__git_refs)"
1665 __gitcomp
"$subcommands --ref"
1669 add
,--reuse-message=*|append
,--reuse-message=*|\
1670 add
,--reedit-message=*|append
,--reedit-message=*)
1671 __gitcomp_nl
"$(__git_refs)" "" "${cur#*=}"
1674 __gitcomp
'--file= --message= --reedit-message=
1681 __gitcomp
'--dry-run --verbose'
1686 case "${words[cword-1]}" in
1690 __gitcomp_nl
"$(__git_refs)"
1699 __git_complete_strategy
&& return
1704 --rebase --no-rebase
1705 $__git_merge_options
1706 $__git_fetch_options
1711 __git_complete_remote_or_refspec
1718 __gitcomp_nl
"$(__git_remotes)"
1723 __gitcomp_nl
"$(__git_remotes)" "" "${cur##--repo=}"
1728 --all --mirror --tags --dry-run --force --verbose
1729 --receive-pack= --repo= --set-upstream
1734 __git_complete_remote_or_refspec
1739 local dir
="$(__gitdir)"
1740 if [ -d "$dir"/rebase-apply
] ||
[ -d "$dir"/rebase-merge
]; then
1741 __gitcomp
"--continue --skip --abort"
1744 __git_complete_strategy
&& return
1747 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
1752 --onto --merge --strategy --interactive
1753 --preserve-merges --stat --no-stat
1754 --committer-date-is-author-date --ignore-date
1755 --ignore-whitespace --whitespace=
1761 __gitcomp_nl
"$(__git_refs)"
1766 local subcommands
="show delete expire"
1767 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
1769 if [ -z "$subcommand" ]; then
1770 __gitcomp
"$subcommands"
1772 __gitcomp_nl
"$(__git_refs)"
1776 __git_send_email_confirm_options
="always never auto cc compose"
1777 __git_send_email_suppresscc_options
="author self cc bodycc sob cccmd body all"
1784 $__git_send_email_confirm_options
1785 " "" "${cur##--confirm=}"
1790 $__git_send_email_suppresscc_options
1791 " "" "${cur##--suppress-cc=}"
1795 --smtp-encryption=*)
1796 __gitcomp
"ssl tls" "" "${cur##--smtp-encryption=}"
1800 __gitcomp
"--annotate --bcc --cc --cc-cmd --chain-reply-to
1801 --compose --confirm= --dry-run --envelope-sender
1803 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
1804 --no-suppress-from --no-thread --quiet
1805 --signed-off-by-cc --smtp-pass --smtp-server
1806 --smtp-server-port --smtp-encryption= --smtp-user
1807 --subject --suppress-cc= --suppress-from --thread --to
1808 --validate --no-validate"
1820 __git_config_get_set_variables
()
1822 local prevword word config_file
= c
=$cword
1823 while [ $c -gt 1 ]; do
1826 --global|
--system|
--file=*)
1831 config_file
="$word $prevword"
1839 git
--git-dir="$(__gitdir)" config
$config_file --list 2>/dev
/null |
1854 __gitcomp_nl
"$(__git_remotes)"
1858 __gitcomp_nl
"$(__git_refs)"
1862 local remote
="${prev#remote.}"
1863 remote
="${remote%.fetch}"
1864 if [ -z "$cur" ]; then
1865 COMPREPLY
=("refs/heads/")
1868 __gitcomp_nl
"$(__git_refs_remotes "$remote")"
1872 local remote
="${prev#remote.}"
1873 remote
="${remote%.push}"
1874 __gitcomp_nl
"$(git --git-dir="$
(__gitdir
)" \
1875 for-each-ref --format='%(refname):%(refname)' \
1879 pull.twohead|pull.octopus
)
1880 __git_compute_merge_strategies
1881 __gitcomp
"$__git_merge_strategies"
1884 color.branch|color.
diff|color.interactive|\
1885 color.showbranch|color.status|color.ui
)
1886 __gitcomp
"always never auto"
1890 __gitcomp
"false true"
1895 normal black red green yellow blue magenta cyan white
1896 bold dim ul blink reverse
1901 __gitcomp
"man info web html"
1905 __gitcomp
"$__git_log_date_formats"
1908 sendemail.aliasesfiletype
)
1909 __gitcomp
"mutt mailrc pine elm gnus"
1913 __gitcomp
"$__git_send_email_confirm_options"
1916 sendemail.suppresscc
)
1917 __gitcomp
"$__git_send_email_suppresscc_options"
1920 --get|
--get-all|
--unset|
--unset-all)
1921 __gitcomp_nl
"$(__git_config_get_set_variables)"
1932 --global --system --file=
1933 --list --replace-all
1934 --get --get-all --get-regexp
1935 --add --unset --unset-all
1936 --remove-section --rename-section
1941 local pfx
="${cur%.*}." cur_
="${cur##*.}"
1942 __gitcomp
"remote merge mergeoptions rebase" "$pfx" "$cur_"
1946 local pfx
="${cur%.*}." cur_
="${cur#*.}"
1947 __gitcomp_nl
"$(__git_heads)" "$pfx" "$cur_" "."
1951 local pfx
="${cur%.*}." cur_
="${cur##*.}"
1953 argprompt cmd confirm needsfile noconsole norescan
1954 prompt revprompt revunmerged title
1959 local pfx
="${cur%.*}." cur_
="${cur##*.}"
1960 __gitcomp
"cmd path" "$pfx" "$cur_"
1964 local pfx
="${cur%.*}." cur_
="${cur##*.}"
1965 __gitcomp
"cmd path" "$pfx" "$cur_"
1969 local pfx
="${cur%.*}." cur_
="${cur##*.}"
1970 __gitcomp
"cmd path trustExitCode" "$pfx" "$cur_"
1974 local pfx
="${cur%.*}." cur_
="${cur#*.}"
1975 __git_compute_all_commands
1976 __gitcomp_nl
"$__git_all_commands" "$pfx" "$cur_"
1980 local pfx
="${cur%.*}." cur_
="${cur##*.}"
1982 url proxy fetch push mirror skipDefaultUpdate
1983 receivepack uploadpack tagopt pushurl
1988 local pfx
="${cur%.*}." cur_
="${cur#*.}"
1989 __gitcomp_nl
"$(__git_remotes)" "$pfx" "$cur_" "."
1993 local pfx
="${cur%.*}." cur_
="${cur##*.}"
1994 __gitcomp
"insteadOf pushInsteadOf" "$pfx" "$cur_"
2000 advice.commitBeforeMerge
2002 advice.implicitIdentity
2003 advice.pushNonFastForward
2004 advice.resolveConflict
2008 apply.ignorewhitespace
2010 branch.autosetupmerge
2011 branch.autosetuprebase
2015 color.branch.current
2020 color.decorate.branch
2021 color.decorate.remoteBranch
2022 color.decorate.stash
2032 color.diff.whitespace
2037 color.grep.linenumber
2040 color.grep.separator
2042 color.interactive.error
2043 color.interactive.header
2044 color.interactive.help
2045 color.interactive.prompt
2050 color.status.changed
2052 color.status.nobranch
2053 color.status.untracked
2054 color.status.updated
2063 core.bigFileThreshold
2066 core.deltaBaseCacheLimit
2071 core.fsyncobjectfiles
2073 core.ignoreCygwinFSTricks
2076 core.logAllRefUpdates
2077 core.loosecompression
2080 core.packedGitWindowSize
2082 core.preferSymlinkRefs
2085 core.repositoryFormatVersion
2087 core.sharedRepository
2091 core.warnAmbiguousRefs
2094 diff.autorefreshindex
2096 diff.ignoreSubmodules
2101 diff.suppressBlankEmpty
2106 fetch.recurseSubmodules
2115 format.subjectprefix
2126 gc.reflogexpireunreachable
2130 gitcvs.commitmsgannotation
2131 gitcvs.dbTableNamePrefix
2142 gui.copyblamethreshold
2146 gui.matchtrackingbranch
2147 gui.newbranchtemplate
2148 gui.pruneduringfetch
2149 gui.spellingdictionary
2164 http.sslCertPasswordProtected
2169 i18n.logOutputEncoding
2175 imap.preformattedHTML
2185 interactive.singlekey
2201 mergetool.keepBackup
2202 mergetool.keepTemporaries
2207 notes.rewrite.rebase
2211 pack.deltaCacheLimit
2227 receive.denyCurrentBranch
2228 receive.denyDeleteCurrent
2230 receive.denyNonFastForwards
2233 receive.updateserverinfo
2235 repack.usedeltabaseoffset
2239 sendemail.aliasesfile
2240 sendemail.aliasfiletype
2244 sendemail.chainreplyto
2246 sendemail.envelopesender
2250 sendemail.signedoffbycc
2251 sendemail.smtpdomain
2252 sendemail.smtpencryption
2254 sendemail.smtpserver
2255 sendemail.smtpserveroption
2256 sendemail.smtpserverport
2258 sendemail.suppresscc
2259 sendemail.suppressfrom
2264 status.relativePaths
2265 status.showUntrackedFiles
2266 status.submodulesummary
2269 transfer.unpackLimit
2281 local subcommands
="add rename rm set-head set-branches set-url show prune update"
2282 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
2283 if [ -z "$subcommand" ]; then
2284 __gitcomp
"$subcommands"
2288 case "$subcommand" in
2289 rename|
rm|set-url|show|prune
)
2290 __gitcomp_nl
"$(__git_remotes)"
2292 set-head|set-branches
)
2293 __git_complete_remote_or_refspec
2296 local i c
='' IFS
=$
'\n'
2297 for i
in $
(git
--git-dir="$(__gitdir)" config
--get-regexp "remotes\..*" 2>/dev
/null
); do
2311 __gitcomp_nl
"$(__git_refs)"
2316 __git_has_doubledash
&& return
2320 __gitcomp
"--merge --mixed --hard --soft --patch"
2324 __gitcomp_nl
"$(__git_refs)"
2331 __gitcomp
"--edit --mainline --no-edit --no-commit --signoff"
2335 __gitcomp_nl
"$(__git_refs)"
2340 __git_has_doubledash
&& return
2344 __gitcomp
"--cached --dry-run --ignore-unmatch --quiet"
2353 __git_has_doubledash
&& return
2358 $__git_log_common_options
2359 $__git_log_shortlog_options
2360 --numbered --summary
2365 __git_complete_revlist
2370 __git_has_doubledash
&& return
2373 --pretty=*|
--format=*)
2374 __gitcomp
"$__git_log_pretty_formats $(__git_pretty_aliases)
2379 __gitcomp
"--pretty= --format= --abbrev-commit --oneline
2380 $__git_diff_common_options
2393 --all --remotes --topo-order --current --more=
2394 --list --independent --merge-base --no-name
2396 --sha1-name --sparse --topics --reflog
2401 __git_complete_revlist
2406 local save_opts
='--keep-index --no-keep-index --quiet --patch'
2407 local subcommands
='save list show apply clear drop pop create branch'
2408 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
2409 if [ -z "$subcommand" ]; then
2412 __gitcomp
"$save_opts"
2415 if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then
2416 __gitcomp
"$subcommands"
2423 case "$subcommand,$cur" in
2425 __gitcomp
"$save_opts"
2428 __gitcomp
"--index --quiet"
2430 show
,--*|drop
,--*|branch
,--*)
2433 show
,*|apply
,*|drop
,*|pop
,*|branch
,*)
2434 __gitcomp_nl
"$(git --git-dir="$
(__gitdir
)" stash list \
2435 | sed -n -e 's/:.*//p')"
2446 __git_has_doubledash
&& return
2448 local subcommands
="add status init update summary foreach sync"
2449 if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then
2452 __gitcomp
"--quiet --cached"
2455 __gitcomp
"$subcommands"
2465 init fetch clone rebase dcommit log find-rev
2466 set-tree commit-diff info create-ignore propget
2467 proplist show-ignore show-externals branch tag blame
2468 migrate mkdirs reset gc
2470 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
2471 if [ -z "$subcommand" ]; then
2472 __gitcomp
"$subcommands"
2474 local remote_opts
="--username= --config-dir= --no-auth-cache"
2476 --follow-parent --authors-file= --repack=
2477 --no-metadata --use-svm-props --use-svnsync-props
2478 --log-window-size= --no-checkout --quiet
2479 --repack-flags --use-log-author --localtime
2480 --ignore-paths= $remote_opts
2483 --template= --shared= --trunk= --tags=
2484 --branches= --stdlayout --minimize-url
2485 --no-metadata --use-svm-props --use-svnsync-props
2486 --rewrite-root= --prefix= --use-log-author
2487 --add-author-from $remote_opts
2490 --edit --rmdir --find-copies-harder --copy-similarity=
2493 case "$subcommand,$cur" in
2495 __gitcomp
"--revision= --fetch-all $fc_opts"
2498 __gitcomp
"--revision= $fc_opts $init_opts"
2501 __gitcomp
"$init_opts"
2505 --merge --strategy= --verbose --dry-run
2506 --fetch-all --no-rebase --commit-url
2507 --revision --interactive $cmt_opts $fc_opts
2511 __gitcomp
"--stdin $cmt_opts $fc_opts"
2513 create-ignore
,--*|propget
,--*|proplist
,--*|show-ignore
,--*|\
2514 show-externals
,--*|mkdirs
,--*)
2515 __gitcomp
"--revision="
2519 --limit= --revision= --verbose --incremental
2520 --oneline --show-commit --non-recursive
2521 --authors-file= --color
2526 --merge --verbose --strategy= --local
2527 --fetch-all --dry-run $fc_opts
2531 __gitcomp
"--message= --file= --revision= $cmt_opts"
2537 __gitcomp
"--dry-run --message --tag"
2540 __gitcomp
"--dry-run --message"
2543 __gitcomp
"--git-format"
2547 --config-dir= --ignore-paths= --minimize
2548 --no-auth-cache --username=
2552 __gitcomp
"--revision= --parent"
2564 while [ $c -lt $cword ]; do
2568 __gitcomp_nl
"$(__git_tags)"
2584 __gitcomp_nl
"$(__git_tags)"
2590 __gitcomp_nl
"$(__git_refs)"
2602 local i c
=1 command __git_dir
2604 if [[ -n ${ZSH_VERSION-} ]]; then
2608 # workaround zsh's bug that leaves 'words' as a special
2609 # variable in versions < 4.3.12
2612 # workaround zsh's bug that quotes spaces in the COMPREPLY
2613 # array if IFS doesn't contain spaces.
2617 local cur words cword prev
2618 _get_comp_words_by_ref
-n =: cur words cword prev
2619 while [ $c -lt $cword ]; do
2622 --git-dir=*) __git_dir
="${i#--git-dir=}" ;;
2623 --bare) __git_dir
="." ;;
2624 --version|
-p|
--paginate) ;;
2625 --help) command="help"; break ;;
2626 *) command="$i"; break ;;
2631 if [ -z "$command" ]; then
2646 *) __git_compute_porcelain_commands
2647 __gitcomp
"$__git_porcelain_commands $(__git_aliases)" ;;
2652 local completion_func
="_git_${command//-/_}"
2653 declare -f $completion_func >/dev
/null
&& $completion_func && return
2655 local expansion
=$
(__git_aliased_command
"$command")
2656 if [ -n "$expansion" ]; then
2657 completion_func
="_git_${expansion//-/_}"
2658 declare -f $completion_func >/dev
/null
&& $completion_func
2664 if [[ -n ${ZSH_VERSION-} ]]; then
2668 # workaround zsh's bug that leaves 'words' as a special
2669 # variable in versions < 4.3.12
2672 # workaround zsh's bug that quotes spaces in the COMPREPLY
2673 # array if IFS doesn't contain spaces.
2677 local cur words cword prev
2678 _get_comp_words_by_ref
-n =: cur words cword prev
2680 __git_has_doubledash
&& return
2682 local g
="$(__gitdir)"
2684 if [ -f "$g/MERGE_HEAD" ]; then
2690 $__git_log_common_options
2691 $__git_log_gitk_options
2697 __git_complete_revlist
2700 complete
-o bashdefault
-o default
-o nospace
-F _git git
2>/dev
/null \
2701 || complete
-o default
-o nospace
-F _git git
2702 complete
-o bashdefault
-o default
-o nospace
-F _gitk gitk
2>/dev
/null \
2703 || complete
-o default
-o nospace
-F _gitk gitk
2705 # The following are necessary only for Cygwin, and only are needed
2706 # when the user has tab-completed the executable name and consequently
2707 # included the '.exe' suffix.
2709 if [ Cygwin
= "$(uname -o 2>/dev/null)" ]; then
2710 complete
-o bashdefault
-o default
-o nospace
-F _git git.exe
2>/dev
/null \
2711 || complete
-o default
-o nospace
-F _git git.exe