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
512 # ZSH would quote the trailing space added with -S. bash users
513 # will appreciate the extra space to compensate the use of -o nospace.
514 if [ -n "${ZSH_VERSION-}" ] && [ "$suffix" = " " ]; then
518 COMPREPLY
=($
(compgen
-P "${2-}" -S "${4- }" -W "$1" -- "${3-$cur}"))
523 local dir
="$(__gitdir)"
524 if [ -d "$dir" ]; then
525 git
--git-dir="$dir" for-each-ref
--format='%(refname:short)' \
533 local dir
="$(__gitdir)"
534 if [ -d "$dir" ]; then
535 git
--git-dir="$dir" for-each-ref
--format='%(refname:short)' \
541 # __git_refs accepts 0, 1 (to pass to __gitdir), or 2 arguments
542 # presence of 2nd argument means use the guess heuristic employed
543 # by checkout for tracking branches
546 local i
hash dir
="$(__gitdir "${1-}")" track
="${2-}"
548 if [ -d "$dir" ]; then
556 for i
in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD
; do
557 if [ -e "$dir/$i" ]; then echo $i; fi
559 format
="refname:short"
560 refs
="refs/tags refs/heads refs/remotes"
563 git
--git-dir="$dir" for-each-ref
--format="%($format)" \
565 if [ -n "$track" ]; then
566 # employ the heuristic used by git checkout
567 # Try to find a remote branch that matches the completion word
568 # but only output if the branch name is unique
570 git
--git-dir="$dir" for-each-ref
--shell --format="ref=%(refname:short)" \
572 while read -r entry
; do
575 if [[ "$ref" == "$cur"* ]]; then
584 git ls-remote
"$dir" "$cur*" 2>/dev
/null | \
585 while read -r hash i
; do
593 git ls-remote
"$dir" HEAD ORIG_HEAD
'refs/tags/*' 'refs/heads/*' 'refs/remotes/*' 2>/dev
/null | \
594 while read -r hash i
; do
597 refs
/*) echo "${i#refs/*/}" ;;
605 # __git_refs2 requires 1 argument (to pass to __git_refs)
609 for i
in $
(__git_refs
"$1"); do
614 # __git_refs_remotes requires 1 argument (to pass to ls-remote)
615 __git_refs_remotes
()
618 git ls-remote
"$1" 'refs/heads/*' 2>/dev
/null | \
619 while read -r hash i
; do
620 echo "$i:refs/remotes/$1/${i#refs/heads/}"
626 local i IFS
=$
'\n' d
="$(__gitdir)"
627 test -d "$d/remotes" && ls -1 "$d/remotes"
628 for i
in $
(git
--git-dir="$d" config
--get-regexp 'remote\..*\.url' 2>/dev
/null
); do
634 __git_list_merge_strategies
()
636 git merge
-s help 2>&1 |
637 sed -n -e '/[Aa]vailable strategies are: /,/^$/{
646 __git_merge_strategies
=
647 # 'git merge -s help' (and thus detection of the merge strategy
648 # list) fails, unfortunately, if run outside of any git working
649 # tree. __git_merge_strategies is set to the empty string in
650 # that case, and the detection will be repeated the next time it
652 __git_compute_merge_strategies
()
654 test -n "$__git_merge_strategies" ||
655 __git_merge_strategies
=$
(__git_list_merge_strategies
)
658 __git_complete_revlist_file
()
660 local pfx
ls ref cur_
="$cur"
680 case "$COMP_WORDBREAKS" in
682 *) pfx
="$ref:$pfx" ;;
686 COMPREPLY
=($
(compgen
-P "$pfx" \
687 -W "$(git --git-dir="$
(__gitdir
)" ls-tree "$ls" \
688 | sed '/^100... blob /{
704 pfx
="${cur_%...*}..."
706 __gitcomp_nl
"$(__git_refs)" "$pfx" "$cur_"
711 __gitcomp_nl
"$(__git_refs)" "$pfx" "$cur_"
714 __gitcomp_nl
"$(__git_refs)"
720 __git_complete_file
()
722 __git_complete_revlist_file
725 __git_complete_revlist
()
727 __git_complete_revlist_file
730 __git_complete_remote_or_refspec
()
732 local cur_
="$cur" cmd
="${words[1]}"
733 local i c
=2 remote
="" pfx
="" lhs
=1 no_complete_refspec
=0
734 if [ "$cmd" = "remote" ]; then
737 while [ $c -lt $cword ]; do
740 --mirror) [ "$cmd" = "push" ] && no_complete_refspec
=1 ;;
743 push
) no_complete_refspec
=1 ;;
752 *) remote
="$i"; break ;;
756 if [ -z "$remote" ]; then
757 __gitcomp_nl
"$(__git_remotes)"
760 if [ $no_complete_refspec = 1 ]; then
764 [ "$remote" = "." ] && remote
=
767 case "$COMP_WORDBREAKS" in
769 *) pfx
="${cur_%%:*}:" ;;
781 if [ $lhs = 1 ]; then
782 __gitcomp_nl
"$(__git_refs2 "$remote")" "$pfx" "$cur_"
784 __gitcomp_nl
"$(__git_refs)" "$pfx" "$cur_"
788 if [ $lhs = 1 ]; then
789 __gitcomp_nl
"$(__git_refs "$remote")" "$pfx" "$cur_"
791 __gitcomp_nl
"$(__git_refs)" "$pfx" "$cur_"
795 if [ $lhs = 1 ]; then
796 __gitcomp_nl
"$(__git_refs)" "$pfx" "$cur_"
798 __gitcomp_nl
"$(__git_refs "$remote")" "$pfx" "$cur_"
804 __git_complete_strategy
()
806 __git_compute_merge_strategies
809 __gitcomp
"$__git_merge_strategies"
814 __gitcomp
"$__git_merge_strategies" "" "${cur##--strategy=}"
821 __git_list_all_commands
()
824 for i
in $
(git
help -a|
egrep '^ [a-zA-Z0-9]')
827 *--*) : helper pattern
;;
834 __git_compute_all_commands
()
836 test -n "$__git_all_commands" ||
837 __git_all_commands
=$
(__git_list_all_commands
)
840 __git_list_porcelain_commands
()
843 __git_compute_all_commands
844 for i
in "help" $__git_all_commands
847 *--*) : helper pattern
;;
848 applymbox
) : ask gittus
;;
849 applypatch
) : ask gittus
;;
850 archimport
) : import
;;
851 cat-file
) : plumbing
;;
852 check-attr
) : plumbing
;;
853 check-ref-format
) : plumbing
;;
854 checkout-index
) : plumbing
;;
855 commit-tree
) : plumbing
;;
856 count-objects
) : infrequent
;;
857 cvsexportcommit
) : export;;
858 cvsimport
) : import
;;
859 cvsserver
) : daemon
;;
861 diff-files
) : plumbing
;;
862 diff-index
) : plumbing
;;
863 diff-tree
) : plumbing
;;
864 fast-import
) : import
;;
865 fast-export
) : export;;
866 fsck-objects
) : plumbing
;;
867 fetch-pack
) : plumbing
;;
868 fmt-merge-msg
) : plumbing
;;
869 for-each-ref
) : plumbing
;;
870 hash-object
) : plumbing
;;
871 http-
*) : transport
;;
872 index-pack
) : plumbing
;;
873 init-db
) : deprecated
;;
874 local-fetch
) : plumbing
;;
875 lost-found
) : infrequent
;;
876 ls-files
) : plumbing
;;
877 ls-remote
) : plumbing
;;
878 ls-tree
) : plumbing
;;
879 mailinfo
) : plumbing
;;
880 mailsplit
) : plumbing
;;
881 merge-
*) : plumbing
;;
884 pack-objects
) : plumbing
;;
885 pack-redundant
) : plumbing
;;
886 pack-refs
) : plumbing
;;
887 parse-remote
) : plumbing
;;
888 patch-id
) : plumbing
;;
889 peek-remote
) : plumbing
;;
891 prune-packed
) : plumbing
;;
892 quiltimport
) : import
;;
893 read-tree
) : plumbing
;;
894 receive-pack
) : plumbing
;;
895 remote-
*) : transport
;;
896 repo-config
) : deprecated
;;
898 rev-list
) : plumbing
;;
899 rev-parse
) : plumbing
;;
900 runstatus
) : plumbing
;;
901 sh-setup
) : internal
;;
903 show-ref
) : plumbing
;;
904 send-pack
) : plumbing
;;
905 show-index
) : plumbing
;;
907 stripspace
) : plumbing
;;
908 symbolic-ref
) : plumbing
;;
909 tar-tree
) : deprecated
;;
910 unpack-file
) : plumbing
;;
911 unpack-objects
) : plumbing
;;
912 update-index
) : plumbing
;;
913 update-ref
) : plumbing
;;
914 update-server-info
) : daemon
;;
915 upload-archive
) : plumbing
;;
916 upload-pack
) : plumbing
;;
917 write-tree
) : plumbing
;;
919 verify-pack
) : infrequent
;;
920 verify-tag
) : plumbing
;;
926 __git_porcelain_commands
=
927 __git_compute_porcelain_commands
()
929 __git_compute_all_commands
930 test -n "$__git_porcelain_commands" ||
931 __git_porcelain_commands
=$
(__git_list_porcelain_commands
)
934 __git_pretty_aliases
()
937 for i
in $
(git
--git-dir="$(__gitdir)" config
--get-regexp "pretty\..*" 2>/dev
/null
); do
950 for i
in $
(git
--git-dir="$(__gitdir)" config
--get-regexp "alias\..*" 2>/dev
/null
); do
960 # __git_aliased_command requires 1 argument
961 __git_aliased_command
()
963 local word cmdline
=$
(git
--git-dir="$(__gitdir)" \
964 config
--get "alias.$1")
965 for word
in $cmdline; do
971 \
!*) : shell
command alias ;;
973 *=*) : setting env
;;
982 # __git_find_on_cmdline requires 1 argument
983 __git_find_on_cmdline
()
985 local word subcommand c
=1
986 while [ $c -lt $cword ]; do
988 for subcommand
in $1; do
989 if [ "$subcommand" = "$word" ]; then
998 __git_has_doubledash
()
1001 while [ $c -lt $cword ]; do
1002 if [ "--" = "${words[c]}" ]; then
1010 __git_whitespacelist
="nowarn warn error error-all fix"
1014 local dir
="$(__gitdir)"
1015 if [ -d "$dir"/rebase-apply
]; then
1016 __gitcomp
"--skip --continue --resolved --abort"
1021 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
1026 --3way --committer-date-is-author-date --ignore-date
1027 --ignore-whitespace --ignore-space-change
1028 --interactive --keep --no-utf8 --signoff --utf8
1029 --whitespace= --scissors
1040 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
1045 --stat --numstat --summary --check --index
1046 --cached --index-info --reverse --reject --unidiff-zero
1047 --apply --no-add --exclude=
1048 --ignore-whitespace --ignore-space-change
1049 --whitespace= --inaccurate-eof --verbose
1058 __git_has_doubledash
&& return
1063 --interactive --refresh --patch --update --dry-run
1064 --ignore-errors --intent-to-add
1075 __gitcomp
"$(git archive --list)" "" "${cur##--format=}"
1079 __gitcomp_nl
"$(__git_remotes)" "" "${cur##--remote=}"
1084 --format= --list --verbose
1085 --prefix= --remote= --exec=
1095 __git_has_doubledash
&& return
1097 local subcommands
="start bad good skip reset visualize replay log run"
1098 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
1099 if [ -z "$subcommand" ]; then
1100 if [ -f "$(__gitdir)"/BISECT_START
]; then
1101 __gitcomp
"$subcommands"
1103 __gitcomp
"replay start"
1108 case "$subcommand" in
1109 bad|good|
reset|skip|start
)
1110 __gitcomp_nl
"$(__git_refs)"
1120 local i c
=1 only_local_ref
="n" has_r
="n"
1122 while [ $c -lt $cword ]; do
1125 -d|
-m) only_local_ref
="y" ;;
1134 --color --no-color --verbose --abbrev= --no-abbrev
1135 --track --no-track --contains --merged --no-merged
1136 --set-upstream --edit-description --list
1140 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
1141 __gitcomp_nl
"$(__git_heads)"
1143 __gitcomp_nl
"$(__git_refs)"
1151 local cmd
="${words[2]}"
1154 __gitcomp
"create list-heads verify unbundle"
1157 # looking for a file
1162 __git_complete_revlist
1171 __git_has_doubledash
&& return
1175 __gitcomp
"diff3 merge" "" "${cur##--conflict=}"
1179 --quiet --ours --theirs --track --no-track --merge
1180 --conflict= --orphan --patch
1184 # check if --track, --no-track, or --no-guess was specified
1185 # if so, disable DWIM mode
1186 local flags
="--track --no-track --no-guess" track
=1
1187 if [ -n "$(__git_find_on_cmdline "$flags")" ]; then
1190 __gitcomp_nl
"$(__git_refs '' $track)"
1197 __gitcomp
"$(__git_refs)"
1204 __gitcomp
"--edit --no-commit"
1207 __gitcomp_nl
"$(__git_refs)"
1214 __git_has_doubledash
&& return
1218 __gitcomp
"--dry-run --quiet"
1251 __git_has_doubledash
&& return
1255 __gitcomp
"default strip verbatim whitespace
1256 " "" "${cur##--cleanup=}"
1259 --reuse-message=*|
--reedit-message=*|\
1260 --fixup=*|
--squash=*)
1261 __gitcomp_nl
"$(__git_refs)" "" "${cur#*=}"
1264 --untracked-files=*)
1265 __gitcomp
"all no normal" "" "${cur##--untracked-files=}"
1270 --all --author= --signoff --verify --no-verify
1271 --edit --amend --include --only --interactive
1272 --dry-run --reuse-message= --reedit-message=
1273 --reset-author --file= --message= --template=
1274 --cleanup= --untracked-files --untracked-files=
1275 --verbose --quiet --fixup= --squash=
1287 --all --tags --contains --abbrev= --candidates=
1288 --exact-match --debug --long --match --always
1292 __gitcomp_nl
"$(__git_refs)"
1295 __git_diff_common_options
="--stat --numstat --shortstat --summary
1296 --patch-with-stat --name-only --name-status --color
1297 --no-color --color-words --no-renames --check
1298 --full-index --binary --abbrev --diff-filter=
1299 --find-copies-harder
1300 --text --ignore-space-at-eol --ignore-space-change
1301 --ignore-all-space --exit-code --quiet --ext-diff
1303 --no-prefix --src-prefix= --dst-prefix=
1304 --inter-hunk-context=
1307 --dirstat --dirstat= --dirstat-by-file
1308 --dirstat-by-file= --cumulative
1313 __git_has_doubledash
&& return
1317 __gitcomp
"--cached --staged --pickaxe-all --pickaxe-regex
1318 --base --ours --theirs --no-index
1319 $__git_diff_common_options
1324 __git_complete_revlist_file
1327 __git_mergetools_common
="diffuse ecmerge emerge kdiff3 meld opendiff
1328 tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc3
1333 __git_has_doubledash
&& return
1337 __gitcomp
"$__git_mergetools_common kompare" "" "${cur##--tool=}"
1341 __gitcomp
"--cached --staged --pickaxe-all --pickaxe-regex
1342 --base --ours --theirs
1343 --no-renames --diff-filter= --find-copies-harder
1344 --relative --ignore-submodules
1352 __git_fetch_options
="
1353 --quiet --verbose --append --upload-pack --force --keep --depth=
1354 --tags --no-tags --all --prune --dry-run
1361 __gitcomp
"$__git_fetch_options"
1365 __git_complete_remote_or_refspec
1368 _git_format_patch
()
1374 " "" "${cur##--thread=}"
1379 --stdout --attach --no-attach --thread --thread=
1381 --numbered --start-number
1384 --signoff --signature --no-signature
1385 --in-reply-to= --cc=
1386 --full-index --binary
1389 --no-prefix --src-prefix= --dst-prefix=
1390 --inline --suffix= --ignore-if-in-upstream
1396 __git_complete_revlist
1404 --tags --root --unreachable --cache --no-reflogs --full
1405 --strict --verbose --lost-found
1417 __gitcomp
"--prune --aggressive"
1429 __git_match_ctag
() {
1430 awk "/^${1////\\/}/ { print \$1 }" "$2"
1435 __git_has_doubledash
&& return
1441 --text --ignore-case --word-regexp --invert-match
1442 --full-name --line-number
1443 --extended-regexp --basic-regexp --fixed-strings
1445 --files-with-matches --name-only
1446 --files-without-match
1449 --and --or --not --all-match
1455 case "$cword,$prev" in
1457 if test -r tags
; then
1458 __gitcomp_nl
"$(__git_match_ctag "$cur" tags)"
1464 __gitcomp_nl
"$(__git_refs)"
1471 __gitcomp
"--all --info --man --web"
1475 __git_compute_all_commands
1476 __gitcomp
"$__git_all_commands $(__git_aliases)
1477 attributes cli core-tutorial cvs-migration
1478 diffcore gitk glossary hooks ignore modules
1479 namespaces repository-layout tutorial tutorial-2
1489 false true umask group all world everybody
1490 " "" "${cur##--shared=}"
1494 __gitcomp
"--quiet --bare --template= --shared --shared="
1503 __git_has_doubledash
&& return
1507 __gitcomp
"--cached --deleted --modified --others --ignored
1508 --stage --directory --no-empty-directory --unmerged
1509 --killed --exclude= --exclude-from=
1510 --exclude-per-directory= --exclude-standard
1511 --error-unmatch --with-tree= --full-name
1512 --abbrev --ignored --exclude-per-directory
1522 __gitcomp_nl
"$(__git_remotes)"
1530 # Options that go well for log, shortlog and gitk
1531 __git_log_common_options
="
1533 --branches --tags --remotes
1534 --first-parent --merges --no-merges
1536 --max-age= --since= --after=
1537 --min-age= --until= --before=
1538 --min-parents= --max-parents=
1539 --no-min-parents --no-max-parents
1541 # Options that go well for log and gitk (not shortlog)
1542 __git_log_gitk_options
="
1543 --dense --sparse --full-history
1544 --simplify-merges --simplify-by-decoration
1545 --left-right --notes --no-notes
1547 # Options that go well for log and shortlog (not gitk)
1548 __git_log_shortlog_options
="
1549 --author= --committer= --grep=
1553 __git_log_pretty_formats
="oneline short medium full fuller email raw format:"
1554 __git_log_date_formats
="relative iso8601 rfc2822 short local default raw"
1558 __git_has_doubledash
&& return
1560 local g
="$(git rev-parse --git-dir 2>/dev/null)"
1562 if [ -f "$g/MERGE_HEAD" ]; then
1566 --pretty=*|
--format=*)
1567 __gitcomp
"$__git_log_pretty_formats $(__git_pretty_aliases)
1572 __gitcomp
"$__git_log_date_formats" "" "${cur##--date=}"
1576 __gitcomp
"long short" "" "${cur##--decorate=}"
1581 $__git_log_common_options
1582 $__git_log_shortlog_options
1583 $__git_log_gitk_options
1584 --root --topo-order --date-order --reverse
1585 --follow --full-diff
1586 --abbrev-commit --abbrev=
1587 --relative-date --date=
1588 --pretty= --format= --oneline
1591 --decorate --decorate=
1593 --parents --children
1595 $__git_diff_common_options
1596 --pickaxe-all --pickaxe-regex
1601 __git_complete_revlist
1604 __git_merge_options
="
1605 --no-commit --no-stat --log --no-log --squash --strategy
1606 --commit --stat --no-squash --ff --no-ff --ff-only --edit --no-edit
1611 __git_complete_strategy
&& return
1615 __gitcomp
"$__git_merge_options"
1618 __gitcomp_nl
"$(__git_refs)"
1625 __gitcomp
"$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"
1638 __gitcomp_nl
"$(__git_refs)"
1645 __gitcomp
"--dry-run"
1654 __gitcomp
"--tags --all --stdin"
1659 local subcommands
='add append copy edit list prune remove show'
1660 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
1662 case "$subcommand,$cur" in
1667 case "${words[cword-1]}" in
1669 __gitcomp_nl
"$(__git_refs)"
1672 __gitcomp
"$subcommands --ref"
1676 add
,--reuse-message=*|append
,--reuse-message=*|\
1677 add
,--reedit-message=*|append
,--reedit-message=*)
1678 __gitcomp_nl
"$(__git_refs)" "" "${cur#*=}"
1681 __gitcomp
'--file= --message= --reedit-message=
1688 __gitcomp
'--dry-run --verbose'
1693 case "${words[cword-1]}" in
1697 __gitcomp_nl
"$(__git_refs)"
1706 __git_complete_strategy
&& return
1711 --rebase --no-rebase
1712 $__git_merge_options
1713 $__git_fetch_options
1718 __git_complete_remote_or_refspec
1725 __gitcomp_nl
"$(__git_remotes)"
1730 __gitcomp_nl
"$(__git_remotes)" "" "${cur##--repo=}"
1735 --all --mirror --tags --dry-run --force --verbose
1736 --receive-pack= --repo= --set-upstream
1741 __git_complete_remote_or_refspec
1746 local dir
="$(__gitdir)"
1747 if [ -d "$dir"/rebase-apply
] ||
[ -d "$dir"/rebase-merge
]; then
1748 __gitcomp
"--continue --skip --abort"
1751 __git_complete_strategy
&& return
1754 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
1759 --onto --merge --strategy --interactive
1760 --preserve-merges --stat --no-stat
1761 --committer-date-is-author-date --ignore-date
1762 --ignore-whitespace --whitespace=
1768 __gitcomp_nl
"$(__git_refs)"
1773 local subcommands
="show delete expire"
1774 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
1776 if [ -z "$subcommand" ]; then
1777 __gitcomp
"$subcommands"
1779 __gitcomp_nl
"$(__git_refs)"
1783 __git_send_email_confirm_options
="always never auto cc compose"
1784 __git_send_email_suppresscc_options
="author self cc bodycc sob cccmd body all"
1791 $__git_send_email_confirm_options
1792 " "" "${cur##--confirm=}"
1797 $__git_send_email_suppresscc_options
1798 " "" "${cur##--suppress-cc=}"
1802 --smtp-encryption=*)
1803 __gitcomp
"ssl tls" "" "${cur##--smtp-encryption=}"
1807 __gitcomp
"--annotate --bcc --cc --cc-cmd --chain-reply-to
1808 --compose --confirm= --dry-run --envelope-sender
1810 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
1811 --no-suppress-from --no-thread --quiet
1812 --signed-off-by-cc --smtp-pass --smtp-server
1813 --smtp-server-port --smtp-encryption= --smtp-user
1814 --subject --suppress-cc= --suppress-from --thread --to
1815 --validate --no-validate"
1827 __git_config_get_set_variables
()
1829 local prevword word config_file
= c
=$cword
1830 while [ $c -gt 1 ]; do
1833 --global|
--system|
--file=*)
1838 config_file
="$word $prevword"
1846 git
--git-dir="$(__gitdir)" config
$config_file --list 2>/dev
/null |
1861 __gitcomp_nl
"$(__git_remotes)"
1865 __gitcomp_nl
"$(__git_refs)"
1869 local remote
="${prev#remote.}"
1870 remote
="${remote%.fetch}"
1871 if [ -z "$cur" ]; then
1872 COMPREPLY
=("refs/heads/")
1875 __gitcomp_nl
"$(__git_refs_remotes "$remote")"
1879 local remote
="${prev#remote.}"
1880 remote
="${remote%.push}"
1881 __gitcomp_nl
"$(git --git-dir="$
(__gitdir
)" \
1882 for-each-ref --format='%(refname):%(refname)' \
1886 pull.twohead|pull.octopus
)
1887 __git_compute_merge_strategies
1888 __gitcomp
"$__git_merge_strategies"
1891 color.branch|color.
diff|color.interactive|\
1892 color.showbranch|color.status|color.ui
)
1893 __gitcomp
"always never auto"
1897 __gitcomp
"false true"
1902 normal black red green yellow blue magenta cyan white
1903 bold dim ul blink reverse
1908 __gitcomp
"man info web html"
1912 __gitcomp
"$__git_log_date_formats"
1915 sendemail.aliasesfiletype
)
1916 __gitcomp
"mutt mailrc pine elm gnus"
1920 __gitcomp
"$__git_send_email_confirm_options"
1923 sendemail.suppresscc
)
1924 __gitcomp
"$__git_send_email_suppresscc_options"
1927 --get|
--get-all|
--unset|
--unset-all)
1928 __gitcomp_nl
"$(__git_config_get_set_variables)"
1939 --global --system --file=
1940 --list --replace-all
1941 --get --get-all --get-regexp
1942 --add --unset --unset-all
1943 --remove-section --rename-section
1948 local pfx
="${cur%.*}." cur_
="${cur##*.}"
1949 __gitcomp
"remote merge mergeoptions rebase" "$pfx" "$cur_"
1953 local pfx
="${cur%.*}." cur_
="${cur#*.}"
1954 __gitcomp_nl
"$(__git_heads)" "$pfx" "$cur_" "."
1958 local pfx
="${cur%.*}." cur_
="${cur##*.}"
1960 argprompt cmd confirm needsfile noconsole norescan
1961 prompt revprompt revunmerged title
1966 local pfx
="${cur%.*}." cur_
="${cur##*.}"
1967 __gitcomp
"cmd path" "$pfx" "$cur_"
1971 local pfx
="${cur%.*}." cur_
="${cur##*.}"
1972 __gitcomp
"cmd path" "$pfx" "$cur_"
1976 local pfx
="${cur%.*}." cur_
="${cur##*.}"
1977 __gitcomp
"cmd path trustExitCode" "$pfx" "$cur_"
1981 local pfx
="${cur%.*}." cur_
="${cur#*.}"
1982 __git_compute_all_commands
1983 __gitcomp_nl
"$__git_all_commands" "$pfx" "$cur_"
1987 local pfx
="${cur%.*}." cur_
="${cur##*.}"
1989 url proxy fetch push mirror skipDefaultUpdate
1990 receivepack uploadpack tagopt pushurl
1995 local pfx
="${cur%.*}." cur_
="${cur#*.}"
1996 __gitcomp_nl
"$(__git_remotes)" "$pfx" "$cur_" "."
2000 local pfx
="${cur%.*}." cur_
="${cur##*.}"
2001 __gitcomp
"insteadOf pushInsteadOf" "$pfx" "$cur_"
2007 advice.commitBeforeMerge
2009 advice.implicitIdentity
2010 advice.pushNonFastForward
2011 advice.resolveConflict
2015 apply.ignorewhitespace
2017 branch.autosetupmerge
2018 branch.autosetuprebase
2022 color.branch.current
2027 color.decorate.branch
2028 color.decorate.remoteBranch
2029 color.decorate.stash
2039 color.diff.whitespace
2044 color.grep.linenumber
2047 color.grep.separator
2049 color.interactive.error
2050 color.interactive.header
2051 color.interactive.help
2052 color.interactive.prompt
2057 color.status.changed
2059 color.status.nobranch
2060 color.status.untracked
2061 color.status.updated
2070 core.bigFileThreshold
2073 core.deltaBaseCacheLimit
2078 core.fsyncobjectfiles
2080 core.ignoreCygwinFSTricks
2083 core.logAllRefUpdates
2084 core.loosecompression
2087 core.packedGitWindowSize
2089 core.preferSymlinkRefs
2092 core.repositoryFormatVersion
2094 core.sharedRepository
2098 core.warnAmbiguousRefs
2101 diff.autorefreshindex
2104 diff.ignoreSubmodules
2109 diff.suppressBlankEmpty
2114 fetch.recurseSubmodules
2123 format.subjectprefix
2134 gc.reflogexpireunreachable
2138 gitcvs.commitmsgannotation
2139 gitcvs.dbTableNamePrefix
2150 gui.copyblamethreshold
2154 gui.matchtrackingbranch
2155 gui.newbranchtemplate
2156 gui.pruneduringfetch
2157 gui.spellingdictionary
2172 http.sslCertPasswordProtected
2177 i18n.logOutputEncoding
2183 imap.preformattedHTML
2193 interactive.singlekey
2209 mergetool.keepBackup
2210 mergetool.keepTemporaries
2215 notes.rewrite.rebase
2219 pack.deltaCacheLimit
2235 receive.denyCurrentBranch
2236 receive.denyDeleteCurrent
2238 receive.denyNonFastForwards
2241 receive.updateserverinfo
2243 repack.usedeltabaseoffset
2247 sendemail.aliasesfile
2248 sendemail.aliasfiletype
2252 sendemail.chainreplyto
2254 sendemail.envelopesender
2258 sendemail.signedoffbycc
2259 sendemail.smtpdomain
2260 sendemail.smtpencryption
2262 sendemail.smtpserver
2263 sendemail.smtpserveroption
2264 sendemail.smtpserverport
2266 sendemail.suppresscc
2267 sendemail.suppressfrom
2272 status.relativePaths
2273 status.showUntrackedFiles
2274 status.submodulesummary
2277 transfer.unpackLimit
2289 local subcommands
="add rename rm set-head set-branches set-url show prune update"
2290 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
2291 if [ -z "$subcommand" ]; then
2292 __gitcomp
"$subcommands"
2296 case "$subcommand" in
2297 rename|
rm|set-url|show|prune
)
2298 __gitcomp_nl
"$(__git_remotes)"
2300 set-head|set-branches
)
2301 __git_complete_remote_or_refspec
2304 local i c
='' IFS
=$
'\n'
2305 for i
in $
(git
--git-dir="$(__gitdir)" config
--get-regexp "remotes\..*" 2>/dev
/null
); do
2319 __gitcomp_nl
"$(__git_refs)"
2324 __git_has_doubledash
&& return
2328 __gitcomp
"--merge --mixed --hard --soft --patch"
2332 __gitcomp_nl
"$(__git_refs)"
2339 __gitcomp
"--edit --mainline --no-edit --no-commit --signoff"
2343 __gitcomp_nl
"$(__git_refs)"
2348 __git_has_doubledash
&& return
2352 __gitcomp
"--cached --dry-run --ignore-unmatch --quiet"
2361 __git_has_doubledash
&& return
2366 $__git_log_common_options
2367 $__git_log_shortlog_options
2368 --numbered --summary
2373 __git_complete_revlist
2378 __git_has_doubledash
&& return
2381 --pretty=*|
--format=*)
2382 __gitcomp
"$__git_log_pretty_formats $(__git_pretty_aliases)
2387 __gitcomp
"--pretty= --format= --abbrev-commit --oneline
2388 $__git_diff_common_options
2401 --all --remotes --topo-order --current --more=
2402 --list --independent --merge-base --no-name
2404 --sha1-name --sparse --topics --reflog
2409 __git_complete_revlist
2414 local save_opts
='--keep-index --no-keep-index --quiet --patch'
2415 local subcommands
='save list show apply clear drop pop create branch'
2416 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
2417 if [ -z "$subcommand" ]; then
2420 __gitcomp
"$save_opts"
2423 if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then
2424 __gitcomp
"$subcommands"
2431 case "$subcommand,$cur" in
2433 __gitcomp
"$save_opts"
2436 __gitcomp
"--index --quiet"
2438 show
,--*|drop
,--*|branch
,--*)
2441 show
,*|apply
,*|drop
,*|pop
,*|branch
,*)
2442 __gitcomp_nl
"$(git --git-dir="$
(__gitdir
)" stash list \
2443 | sed -n -e 's/:.*//p')"
2454 __git_has_doubledash
&& return
2456 local subcommands
="add status init update summary foreach sync"
2457 if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then
2460 __gitcomp
"--quiet --cached"
2463 __gitcomp
"$subcommands"
2473 init fetch clone rebase dcommit log find-rev
2474 set-tree commit-diff info create-ignore propget
2475 proplist show-ignore show-externals branch tag blame
2476 migrate mkdirs reset gc
2478 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
2479 if [ -z "$subcommand" ]; then
2480 __gitcomp
"$subcommands"
2482 local remote_opts
="--username= --config-dir= --no-auth-cache"
2484 --follow-parent --authors-file= --repack=
2485 --no-metadata --use-svm-props --use-svnsync-props
2486 --log-window-size= --no-checkout --quiet
2487 --repack-flags --use-log-author --localtime
2488 --ignore-paths= $remote_opts
2491 --template= --shared= --trunk= --tags=
2492 --branches= --stdlayout --minimize-url
2493 --no-metadata --use-svm-props --use-svnsync-props
2494 --rewrite-root= --prefix= --use-log-author
2495 --add-author-from $remote_opts
2498 --edit --rmdir --find-copies-harder --copy-similarity=
2501 case "$subcommand,$cur" in
2503 __gitcomp
"--revision= --fetch-all $fc_opts"
2506 __gitcomp
"--revision= $fc_opts $init_opts"
2509 __gitcomp
"$init_opts"
2513 --merge --strategy= --verbose --dry-run
2514 --fetch-all --no-rebase --commit-url
2515 --revision --interactive $cmt_opts $fc_opts
2519 __gitcomp
"--stdin $cmt_opts $fc_opts"
2521 create-ignore
,--*|propget
,--*|proplist
,--*|show-ignore
,--*|\
2522 show-externals
,--*|mkdirs
,--*)
2523 __gitcomp
"--revision="
2527 --limit= --revision= --verbose --incremental
2528 --oneline --show-commit --non-recursive
2529 --authors-file= --color
2534 --merge --verbose --strategy= --local
2535 --fetch-all --dry-run $fc_opts
2539 __gitcomp
"--message= --file= --revision= $cmt_opts"
2545 __gitcomp
"--dry-run --message --tag"
2548 __gitcomp
"--dry-run --message"
2551 __gitcomp
"--git-format"
2555 --config-dir= --ignore-paths= --minimize
2556 --no-auth-cache --username=
2560 __gitcomp
"--revision= --parent"
2572 while [ $c -lt $cword ]; do
2576 __gitcomp_nl
"$(__git_tags)"
2592 __gitcomp_nl
"$(__git_tags)"
2598 __gitcomp_nl
"$(__git_refs)"
2610 local i c
=1 command __git_dir
2612 if [[ -n ${ZSH_VERSION-} ]]; then
2616 # workaround zsh's bug that leaves 'words' as a special
2617 # variable in versions < 4.3.12
2620 # workaround zsh's bug that quotes spaces in the COMPREPLY
2621 # array if IFS doesn't contain spaces.
2625 local cur words cword prev
2626 _get_comp_words_by_ref
-n =: cur words cword prev
2627 while [ $c -lt $cword ]; do
2630 --git-dir=*) __git_dir
="${i#--git-dir=}" ;;
2631 --bare) __git_dir
="." ;;
2632 --version|
-p|
--paginate) ;;
2633 --help) command="help"; break ;;
2634 *) command="$i"; break ;;
2639 if [ -z "$command" ]; then
2654 *) __git_compute_porcelain_commands
2655 __gitcomp
"$__git_porcelain_commands $(__git_aliases)" ;;
2660 local completion_func
="_git_${command//-/_}"
2661 declare -f $completion_func >/dev
/null
&& $completion_func && return
2663 local expansion
=$
(__git_aliased_command
"$command")
2664 if [ -n "$expansion" ]; then
2665 completion_func
="_git_${expansion//-/_}"
2666 declare -f $completion_func >/dev
/null
&& $completion_func
2672 if [[ -n ${ZSH_VERSION-} ]]; then
2676 # workaround zsh's bug that leaves 'words' as a special
2677 # variable in versions < 4.3.12
2680 # workaround zsh's bug that quotes spaces in the COMPREPLY
2681 # array if IFS doesn't contain spaces.
2685 local cur words cword prev
2686 _get_comp_words_by_ref
-n =: cur words cword prev
2688 __git_has_doubledash
&& return
2690 local g
="$(__gitdir)"
2692 if [ -f "$g/MERGE_HEAD" ]; then
2698 $__git_log_common_options
2699 $__git_log_gitk_options
2705 __git_complete_revlist
2708 complete
-o bashdefault
-o default
-o nospace
-F _git git
2>/dev
/null \
2709 || complete
-o default
-o nospace
-F _git git
2710 complete
-o bashdefault
-o default
-o nospace
-F _gitk gitk
2>/dev
/null \
2711 || complete
-o default
-o nospace
-F _gitk gitk
2713 # The following are necessary only for Cygwin, and only are needed
2714 # when the user has tab-completed the executable name and consequently
2715 # included the '.exe' suffix.
2717 if [ Cygwin
= "$(uname -o 2>/dev/null)" ]; then
2718 complete
-o bashdefault
-o default
-o nospace
-F _git git.exe
2>/dev
/null \
2719 || complete
-o default
-o nospace
-F _git git.exe