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
175 count
="$behind $ahead"
181 # calculate the result
182 if [[ -z "$verbose" ]]; then
186 "0 0") # equal to upstream
188 "0 "*) # ahead of upstream
190 *" 0") # behind upstream
192 *) # diverged from upstream
199 "0 0") # equal to upstream
201 "0 "*) # ahead of upstream
202 p
=" u+${count#0 }" ;;
203 *" 0") # behind upstream
204 p
=" u-${count% 0}" ;;
205 *) # diverged from upstream
206 p
=" u+${count#* }-${count% *}" ;;
213 # __git_ps1 accepts 0 or 1 arguments (i.e., format string)
214 # returns text to add to bash PS1 prompt (includes branch name)
217 local g
="$(__gitdir)"
221 if [ -f "$g/rebase-merge/interactive" ]; then
223 b
="$(cat "$g/rebase-merge
/head-name
")"
224 elif [ -d "$g/rebase-merge" ]; then
226 b
="$(cat "$g/rebase-merge
/head-name
")"
228 if [ -d "$g/rebase-apply" ]; then
229 if [ -f "$g/rebase-apply/rebasing" ]; then
231 elif [ -f "$g/rebase-apply/applying" ]; then
236 elif [ -f "$g/MERGE_HEAD" ]; then
238 elif [ -f "$g/CHERRY_PICK_HEAD" ]; then
240 elif [ -f "$g/BISECT_LOG" ]; then
244 b
="$(git symbolic-ref HEAD 2>/dev/null)" ||
{
247 case "${GIT_PS1_DESCRIBE_STYLE-}" in
249 git describe --contains HEAD ;;
251 git describe --contains --all HEAD ;;
255 git describe --tags --exact-match HEAD ;;
256 esac 2>/dev/null)" ||
258 b
="$(cut -c1-7 "$g/HEAD
" 2>/dev/null)..." ||
271 if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then
272 if [ "true" = "$(git rev-parse --is-bare-repository 2>/dev/null)" ]; then
277 elif [ "true" = "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
278 if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ]; then
279 if [ "$(git config --bool bash.showDirtyState)" != "false" ]; then
280 git
diff --no-ext-diff --quiet --exit-code || w
="*"
281 if git rev-parse
--quiet --verify HEAD
>/dev
/null
; then
282 git diff-index
--cached --quiet HEAD
-- || i
="+"
288 if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ]; then
289 git rev-parse
--verify refs
/stash
>/dev
/null
2>&1 && s
="$"
292 if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ]; then
293 if [ -n "$(git ls-files --others --exclude-standard)" ]; then
298 if [ -n "${GIT_PS1_SHOWUPSTREAM-}" ]; then
299 __git_ps1_show_upstream
304 printf -- "${1:- (%s)}" "$c${b##refs/heads/}${f:+ $f}$r$p"
308 # __gitcomp_1 requires 2 arguments
311 local c IFS
=' '$
'\t'$
'\n'
314 --*=*) printf %s$
'\n' "$c$2" ;;
315 *.
) printf %s$
'\n' "$c$2" ;;
316 *) printf %s$
'\n' "$c$2 " ;;
321 # The following function is based on code from:
323 # bash_completion - programmable completion functions for bash 3.2+
325 # Copyright © 2006-2008, Ian Macdonald <ian@caliban.org>
326 # © 2009-2010, Bash Completion Maintainers
327 # <bash-completion-devel@lists.alioth.debian.org>
329 # This program is free software; you can redistribute it and/or modify
330 # it under the terms of the GNU General Public License as published by
331 # the Free Software Foundation; either version 2, or (at your option)
334 # This program is distributed in the hope that it will be useful,
335 # but WITHOUT ANY WARRANTY; without even the implied warranty of
336 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
337 # GNU General Public License for more details.
339 # You should have received a copy of the GNU General Public License
340 # along with this program; if not, write to the Free Software Foundation,
341 # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
343 # The latest version of this software can be obtained here:
345 # http://bash-completion.alioth.debian.org/
349 # This function can be used to access a tokenized list of words
350 # on the command line:
352 # __git_reassemble_comp_words_by_ref '=:'
353 # if test "${words_[cword_-1]}" = -w
358 # The argument should be a collection of characters from the list of
359 # word completion separators (COMP_WORDBREAKS) to treat as ordinary
362 # This is roughly equivalent to going back in time and setting
363 # COMP_WORDBREAKS to exclude those characters. The intent is to
364 # make option types like --date=<type> and <rev>:<path> easy to
365 # recognize by treating each shell word as a single token.
367 # It is best not to set COMP_WORDBREAKS directly because the value is
368 # shared with other completion scripts. By the time the completion
369 # function gets called, COMP_WORDS has already been populated so local
370 # changes to COMP_WORDBREAKS have no effect.
372 # Output: words_, cword_, cur_.
374 __git_reassemble_comp_words_by_ref
()
376 local exclude i j first
377 # Which word separators to exclude?
378 exclude
="${1//[^$COMP_WORDBREAKS]}"
380 if [ -z "$exclude" ]; then
381 words_
=("${COMP_WORDS[@]}")
384 # List of word completion separators has shrunk;
385 # re-assemble words to complete.
386 for ((i
=0, j
=0; i
< ${#COMP_WORDS[@]}; i
++, j
++)); do
387 # Append each nonempty word consisting of just
388 # word separator characters to the current word.
392 [ -n "${COMP_WORDS[$i]}" ] &&
393 # word consists of excluded word separators
394 [ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ]
396 # Attach to the previous token,
397 # unless the previous token is the command name.
398 if [ $j -ge 2 ] && [ -n "$first" ]; then
402 words_
[$j]=${words_[j]}${COMP_WORDS[i]}
403 if [ $i = $COMP_CWORD ]; then
406 if (($i < ${#COMP_WORDS[@]} - 1)); then
413 words_
[$j]=${words_[j]}${COMP_WORDS[i]}
414 if [ $i = $COMP_CWORD ]; then
420 if ! type _get_comp_words_by_ref
>/dev
/null
2>&1; then
421 if [[ -z ${ZSH_VERSION:+set} ]]; then
422 _get_comp_words_by_ref
()
424 local exclude cur_ words_ cword_
425 if [ "$1" = "-n" ]; then
429 __git_reassemble_comp_words_by_ref
"$exclude"
430 cur_
=${words_[cword_]}
431 while [ $# -gt 0 ]; do
437 prev
=${words_[$cword_-1]}
440 words
=("${words_[@]}")
450 _get_comp_words_by_ref
()
452 while [ $# -gt 0 ]; do
455 cur
=${COMP_WORDS[COMP_CWORD]}
458 prev
=${COMP_WORDS[COMP_CWORD-1]}
461 words
=("${COMP_WORDS[@]}")
467 # assume COMP_WORDBREAKS is already set sanely
477 # Generates completion reply with compgen, appending a space to possible
478 # completion words, if necessary.
479 # It accepts 1 to 4 arguments:
480 # 1: List of possible completion words.
481 # 2: A prefix to be added to each possible completion word (optional).
482 # 3: Generate possible completion matches for this word (optional).
483 # 4: A suffix to be appended to each possible completion word (optional).
486 local cur_
="${3-$cur}"
494 COMPREPLY
=($
(compgen
-P "${2-}" \
495 -W "$(__gitcomp_1 "${1-}" "${4-}")" \
501 # Generates completion reply with compgen from newline-separated possible
502 # completion words by appending a space to all of them.
503 # It accepts 1 to 4 arguments:
504 # 1: List of possible completion words, separated by a single newline.
505 # 2: A prefix to be added to each possible completion word (optional).
506 # 3: Generate possible completion matches for this word (optional).
507 # 4: A suffix to be appended to each possible completion word instead of
508 # the default space (optional). If specified but empty, nothing is
513 COMPREPLY
=($
(compgen
-P "${2-}" -S "${4- }" -W "$1" -- "${3-$cur}"))
518 local dir
="$(__gitdir)"
519 if [ -d "$dir" ]; then
520 git
--git-dir="$dir" for-each-ref
--format='%(refname:short)' \
528 local dir
="$(__gitdir)"
529 if [ -d "$dir" ]; then
530 git
--git-dir="$dir" for-each-ref
--format='%(refname:short)' \
536 # __git_refs accepts 0, 1 (to pass to __gitdir), or 2 arguments
537 # presence of 2nd argument means use the guess heuristic employed
538 # by checkout for tracking branches
541 local i
hash dir
="$(__gitdir "${1-}")" track
="${2-}"
543 if [ -d "$dir" ]; then
551 for i
in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD
; do
552 if [ -e "$dir/$i" ]; then echo $i; fi
554 format
="refname:short"
555 refs
="refs/tags refs/heads refs/remotes"
558 git
--git-dir="$dir" for-each-ref
--format="%($format)" \
560 if [ -n "$track" ]; then
561 # employ the heuristic used by git checkout
562 # Try to find a remote branch that matches the completion word
563 # but only output if the branch name is unique
565 git
--git-dir="$dir" for-each-ref
--shell --format="ref=%(refname:short)" \
567 while read -r entry
; do
570 if [[ "$ref" == "$cur"* ]]; then
579 git ls-remote
"$dir" "$cur*" 2>/dev
/null | \
580 while read -r hash i
; do
588 git ls-remote
"$dir" HEAD ORIG_HEAD
'refs/tags/*' 'refs/heads/*' 'refs/remotes/*' 2>/dev
/null | \
589 while read -r hash i
; do
592 refs
/*) echo "${i#refs/*/}" ;;
600 # __git_refs2 requires 1 argument (to pass to __git_refs)
604 for i
in $
(__git_refs
"$1"); do
609 # __git_refs_remotes requires 1 argument (to pass to ls-remote)
610 __git_refs_remotes
()
613 git ls-remote
"$1" 'refs/heads/*' 2>/dev
/null | \
614 while read -r hash i
; do
615 echo "$i:refs/remotes/$1/${i#refs/heads/}"
621 local i IFS
=$
'\n' d
="$(__gitdir)"
622 test -d "$d/remotes" && ls -1 "$d/remotes"
623 for i
in $
(git
--git-dir="$d" config
--get-regexp 'remote\..*\.url' 2>/dev
/null
); do
629 __git_list_merge_strategies
()
631 git merge
-s help 2>&1 |
632 sed -n -e '/[Aa]vailable strategies are: /,/^$/{
641 __git_merge_strategies
=
642 # 'git merge -s help' (and thus detection of the merge strategy
643 # list) fails, unfortunately, if run outside of any git working
644 # tree. __git_merge_strategies is set to the empty string in
645 # that case, and the detection will be repeated the next time it
647 __git_compute_merge_strategies
()
649 test -n "$__git_merge_strategies" ||
650 __git_merge_strategies
=$
(__git_list_merge_strategies
)
653 __git_complete_revlist_file
()
655 local pfx
ls ref cur_
="$cur"
675 case "$COMP_WORDBREAKS" in
677 *) pfx
="$ref:$pfx" ;;
681 COMPREPLY
=($
(compgen
-P "$pfx" \
682 -W "$(git --git-dir="$
(__gitdir
)" ls-tree "$ls" \
683 | sed '/^100... blob /{
699 pfx
="${cur_%...*}..."
701 __gitcomp_nl
"$(__git_refs)" "$pfx" "$cur_"
706 __gitcomp_nl
"$(__git_refs)" "$pfx" "$cur_"
709 __gitcomp_nl
"$(__git_refs)"
715 __git_complete_file
()
717 __git_complete_revlist_file
720 __git_complete_revlist
()
722 __git_complete_revlist_file
725 __git_complete_remote_or_refspec
()
727 local cur_
="$cur" cmd
="${words[1]}"
728 local i c
=2 remote
="" pfx
="" lhs
=1 no_complete_refspec
=0
729 while [ $c -lt $cword ]; do
732 --mirror) [ "$cmd" = "push" ] && no_complete_refspec
=1 ;;
735 push
) no_complete_refspec
=1 ;;
744 *) remote
="$i"; break ;;
748 if [ -z "$remote" ]; then
749 __gitcomp_nl
"$(__git_remotes)"
752 if [ $no_complete_refspec = 1 ]; then
756 [ "$remote" = "." ] && remote
=
759 case "$COMP_WORDBREAKS" in
761 *) pfx
="${cur_%%:*}:" ;;
773 if [ $lhs = 1 ]; then
774 __gitcomp_nl
"$(__git_refs2 "$remote")" "$pfx" "$cur_"
776 __gitcomp_nl
"$(__git_refs)" "$pfx" "$cur_"
780 if [ $lhs = 1 ]; then
781 __gitcomp_nl
"$(__git_refs "$remote")" "$pfx" "$cur_"
783 __gitcomp_nl
"$(__git_refs)" "$pfx" "$cur_"
787 if [ $lhs = 1 ]; then
788 __gitcomp_nl
"$(__git_refs)" "$pfx" "$cur_"
790 __gitcomp_nl
"$(__git_refs "$remote")" "$pfx" "$cur_"
796 __git_complete_strategy
()
798 __git_compute_merge_strategies
801 __gitcomp
"$__git_merge_strategies"
806 __gitcomp
"$__git_merge_strategies" "" "${cur##--strategy=}"
813 __git_list_all_commands
()
816 for i
in $
(git
help -a|
egrep '^ [a-zA-Z0-9]')
819 *--*) : helper pattern
;;
826 __git_compute_all_commands
()
828 test -n "$__git_all_commands" ||
829 __git_all_commands
=$
(__git_list_all_commands
)
832 __git_list_porcelain_commands
()
835 __git_compute_all_commands
836 for i
in "help" $__git_all_commands
839 *--*) : helper pattern
;;
840 applymbox
) : ask gittus
;;
841 applypatch
) : ask gittus
;;
842 archimport
) : import
;;
843 cat-file
) : plumbing
;;
844 check-attr
) : plumbing
;;
845 check-ref-format
) : plumbing
;;
846 checkout-index
) : plumbing
;;
847 commit-tree
) : plumbing
;;
848 count-objects
) : infrequent
;;
849 cvsexportcommit
) : export;;
850 cvsimport
) : import
;;
851 cvsserver
) : daemon
;;
853 diff-files
) : plumbing
;;
854 diff-index
) : plumbing
;;
855 diff-tree
) : plumbing
;;
856 fast-import
) : import
;;
857 fast-export
) : export;;
858 fsck-objects
) : plumbing
;;
859 fetch-pack
) : plumbing
;;
860 fmt-merge-msg
) : plumbing
;;
861 for-each-ref
) : plumbing
;;
862 hash-object
) : plumbing
;;
863 http-
*) : transport
;;
864 index-pack
) : plumbing
;;
865 init-db
) : deprecated
;;
866 local-fetch
) : plumbing
;;
867 lost-found
) : infrequent
;;
868 ls-files
) : plumbing
;;
869 ls-remote
) : plumbing
;;
870 ls-tree
) : plumbing
;;
871 mailinfo
) : plumbing
;;
872 mailsplit
) : plumbing
;;
873 merge-
*) : plumbing
;;
876 pack-objects
) : plumbing
;;
877 pack-redundant
) : plumbing
;;
878 pack-refs
) : plumbing
;;
879 parse-remote
) : plumbing
;;
880 patch-id
) : plumbing
;;
881 peek-remote
) : plumbing
;;
883 prune-packed
) : plumbing
;;
884 quiltimport
) : import
;;
885 read-tree
) : plumbing
;;
886 receive-pack
) : plumbing
;;
887 remote-
*) : transport
;;
888 repo-config
) : deprecated
;;
890 rev-list
) : plumbing
;;
891 rev-parse
) : plumbing
;;
892 runstatus
) : plumbing
;;
893 sh-setup
) : internal
;;
895 show-ref
) : plumbing
;;
896 send-pack
) : plumbing
;;
897 show-index
) : plumbing
;;
899 stripspace
) : plumbing
;;
900 symbolic-ref
) : plumbing
;;
901 tar-tree
) : deprecated
;;
902 unpack-file
) : plumbing
;;
903 unpack-objects
) : plumbing
;;
904 update-index
) : plumbing
;;
905 update-ref
) : plumbing
;;
906 update-server-info
) : daemon
;;
907 upload-archive
) : plumbing
;;
908 upload-pack
) : plumbing
;;
909 write-tree
) : plumbing
;;
911 verify-pack
) : infrequent
;;
912 verify-tag
) : plumbing
;;
918 __git_porcelain_commands
=
919 __git_compute_porcelain_commands
()
921 __git_compute_all_commands
922 test -n "$__git_porcelain_commands" ||
923 __git_porcelain_commands
=$
(__git_list_porcelain_commands
)
926 __git_pretty_aliases
()
929 for i
in $
(git
--git-dir="$(__gitdir)" config
--get-regexp "pretty\..*" 2>/dev
/null
); do
942 for i
in $
(git
--git-dir="$(__gitdir)" config
--get-regexp "alias\..*" 2>/dev
/null
); do
952 # __git_aliased_command requires 1 argument
953 __git_aliased_command
()
955 local word cmdline
=$
(git
--git-dir="$(__gitdir)" \
956 config
--get "alias.$1")
957 for word
in $cmdline; do
963 \
!*) : shell
command alias ;;
965 *=*) : setting env
;;
974 # __git_find_on_cmdline requires 1 argument
975 __git_find_on_cmdline
()
977 local word subcommand c
=1
978 while [ $c -lt $cword ]; do
980 for subcommand
in $1; do
981 if [ "$subcommand" = "$word" ]; then
990 __git_has_doubledash
()
993 while [ $c -lt $cword ]; do
994 if [ "--" = "${words[c]}" ]; then
1002 __git_whitespacelist
="nowarn warn error error-all fix"
1006 local dir
="$(__gitdir)"
1007 if [ -d "$dir"/rebase-apply
]; then
1008 __gitcomp
"--skip --continue --resolved --abort"
1013 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
1018 --3way --committer-date-is-author-date --ignore-date
1019 --ignore-whitespace --ignore-space-change
1020 --interactive --keep --no-utf8 --signoff --utf8
1021 --whitespace= --scissors
1032 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
1037 --stat --numstat --summary --check --index
1038 --cached --index-info --reverse --reject --unidiff-zero
1039 --apply --no-add --exclude=
1040 --ignore-whitespace --ignore-space-change
1041 --whitespace= --inaccurate-eof --verbose
1050 __git_has_doubledash
&& return
1055 --interactive --refresh --patch --update --dry-run
1056 --ignore-errors --intent-to-add
1067 __gitcomp
"$(git archive --list)" "" "${cur##--format=}"
1071 __gitcomp_nl
"$(__git_remotes)" "" "${cur##--remote=}"
1076 --format= --list --verbose
1077 --prefix= --remote= --exec=
1087 __git_has_doubledash
&& return
1089 local subcommands
="start bad good skip reset visualize replay log run"
1090 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
1091 if [ -z "$subcommand" ]; then
1092 if [ -f "$(__gitdir)"/BISECT_START
]; then
1093 __gitcomp
"$subcommands"
1095 __gitcomp
"replay start"
1100 case "$subcommand" in
1101 bad|good|
reset|skip|start
)
1102 __gitcomp_nl
"$(__git_refs)"
1112 local i c
=1 only_local_ref
="n" has_r
="n"
1114 while [ $c -lt $cword ]; do
1117 -d|
-m) only_local_ref
="y" ;;
1126 --color --no-color --verbose --abbrev= --no-abbrev
1127 --track --no-track --contains --merged --no-merged
1128 --set-upstream --edit-description --list
1132 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
1133 __gitcomp_nl
"$(__git_heads)"
1135 __gitcomp_nl
"$(__git_refs)"
1143 local cmd
="${words[2]}"
1146 __gitcomp
"create list-heads verify unbundle"
1149 # looking for a file
1154 __git_complete_revlist
1163 __git_has_doubledash
&& return
1167 __gitcomp
"diff3 merge" "" "${cur##--conflict=}"
1171 --quiet --ours --theirs --track --no-track --merge
1172 --conflict= --orphan --patch
1176 # check if --track, --no-track, or --no-guess was specified
1177 # if so, disable DWIM mode
1178 local flags
="--track --no-track --no-guess" track
=1
1179 if [ -n "$(__git_find_on_cmdline "$flags")" ]; then
1182 __gitcomp_nl
"$(__git_refs '' $track)"
1189 __gitcomp
"$(__git_refs)"
1196 __gitcomp
"--edit --no-commit"
1199 __gitcomp_nl
"$(__git_refs)"
1206 __git_has_doubledash
&& return
1210 __gitcomp
"--dry-run --quiet"
1243 __git_has_doubledash
&& return
1247 __gitcomp
"default strip verbatim whitespace
1248 " "" "${cur##--cleanup=}"
1251 --reuse-message=*|
--reedit-message=*|\
1252 --fixup=*|
--squash=*)
1253 __gitcomp_nl
"$(__git_refs)" "" "${cur#*=}"
1256 --untracked-files=*)
1257 __gitcomp
"all no normal" "" "${cur##--untracked-files=}"
1262 --all --author= --signoff --verify --no-verify
1263 --edit --amend --include --only --interactive
1264 --dry-run --reuse-message= --reedit-message=
1265 --reset-author --file= --message= --template=
1266 --cleanup= --untracked-files --untracked-files=
1267 --verbose --quiet --fixup= --squash=
1279 --all --tags --contains --abbrev= --candidates=
1280 --exact-match --debug --long --match --always
1284 __gitcomp_nl
"$(__git_refs)"
1287 __git_diff_common_options
="--stat --numstat --shortstat --summary
1288 --patch-with-stat --name-only --name-status --color
1289 --no-color --color-words --no-renames --check
1290 --full-index --binary --abbrev --diff-filter=
1291 --find-copies-harder
1292 --text --ignore-space-at-eol --ignore-space-change
1293 --ignore-all-space --exit-code --quiet --ext-diff
1295 --no-prefix --src-prefix= --dst-prefix=
1296 --inter-hunk-context=
1299 --dirstat --dirstat= --dirstat-by-file
1300 --dirstat-by-file= --cumulative
1305 __git_has_doubledash
&& return
1309 __gitcomp
"--cached --staged --pickaxe-all --pickaxe-regex
1310 --base --ours --theirs --no-index
1311 $__git_diff_common_options
1316 __git_complete_revlist_file
1319 __git_mergetools_common
="diffuse ecmerge emerge kdiff3 meld opendiff
1320 tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc3
1325 __git_has_doubledash
&& return
1329 __gitcomp
"$__git_mergetools_common kompare" "" "${cur##--tool=}"
1333 __gitcomp
"--cached --staged --pickaxe-all --pickaxe-regex
1334 --base --ours --theirs
1335 --no-renames --diff-filter= --find-copies-harder
1336 --relative --ignore-submodules
1344 __git_fetch_options
="
1345 --quiet --verbose --append --upload-pack --force --keep --depth=
1346 --tags --no-tags --all --prune --dry-run
1353 __gitcomp
"$__git_fetch_options"
1357 __git_complete_remote_or_refspec
1360 _git_format_patch
()
1366 " "" "${cur##--thread=}"
1371 --stdout --attach --no-attach --thread --thread=
1373 --numbered --start-number
1376 --signoff --signature --no-signature
1377 --in-reply-to= --cc=
1378 --full-index --binary
1381 --no-prefix --src-prefix= --dst-prefix=
1382 --inline --suffix= --ignore-if-in-upstream
1388 __git_complete_revlist
1396 --tags --root --unreachable --cache --no-reflogs --full
1397 --strict --verbose --lost-found
1409 __gitcomp
"--prune --aggressive"
1421 __git_match_ctag
() {
1422 awk "/^${1////\\/}/ { print \$1 }" "$2"
1427 __git_has_doubledash
&& return
1433 --text --ignore-case --word-regexp --invert-match
1434 --full-name --line-number
1435 --extended-regexp --basic-regexp --fixed-strings
1437 --files-with-matches --name-only
1438 --files-without-match
1441 --and --or --not --all-match
1447 case "$cword,$prev" in
1449 if test -r tags
; then
1450 __gitcomp_nl
"$(__git_match_ctag "$cur" tags)"
1456 __gitcomp_nl
"$(__git_refs)"
1463 __gitcomp
"--all --info --man --web"
1467 __git_compute_all_commands
1468 __gitcomp
"$__git_all_commands $(__git_aliases)
1469 attributes cli core-tutorial cvs-migration
1470 diffcore gitk glossary hooks ignore modules
1471 namespaces repository-layout tutorial tutorial-2
1481 false true umask group all world everybody
1482 " "" "${cur##--shared=}"
1486 __gitcomp
"--quiet --bare --template= --shared --shared="
1495 __git_has_doubledash
&& return
1499 __gitcomp
"--cached --deleted --modified --others --ignored
1500 --stage --directory --no-empty-directory --unmerged
1501 --killed --exclude= --exclude-from=
1502 --exclude-per-directory= --exclude-standard
1503 --error-unmatch --with-tree= --full-name
1504 --abbrev --ignored --exclude-per-directory
1514 __gitcomp_nl
"$(__git_remotes)"
1522 # Options that go well for log, shortlog and gitk
1523 __git_log_common_options
="
1525 --branches --tags --remotes
1526 --first-parent --merges --no-merges
1528 --max-age= --since= --after=
1529 --min-age= --until= --before=
1530 --min-parents= --max-parents=
1531 --no-min-parents --no-max-parents
1533 # Options that go well for log and gitk (not shortlog)
1534 __git_log_gitk_options
="
1535 --dense --sparse --full-history
1536 --simplify-merges --simplify-by-decoration
1537 --left-right --notes --no-notes
1539 # Options that go well for log and shortlog (not gitk)
1540 __git_log_shortlog_options
="
1541 --author= --committer= --grep=
1545 __git_log_pretty_formats
="oneline short medium full fuller email raw format:"
1546 __git_log_date_formats
="relative iso8601 rfc2822 short local default raw"
1550 __git_has_doubledash
&& return
1552 local g
="$(git rev-parse --git-dir 2>/dev/null)"
1554 if [ -f "$g/MERGE_HEAD" ]; then
1558 --pretty=*|
--format=*)
1559 __gitcomp
"$__git_log_pretty_formats $(__git_pretty_aliases)
1564 __gitcomp
"$__git_log_date_formats" "" "${cur##--date=}"
1568 __gitcomp
"long short" "" "${cur##--decorate=}"
1573 $__git_log_common_options
1574 $__git_log_shortlog_options
1575 $__git_log_gitk_options
1576 --root --topo-order --date-order --reverse
1577 --follow --full-diff
1578 --abbrev-commit --abbrev=
1579 --relative-date --date=
1580 --pretty= --format= --oneline
1583 --decorate --decorate=
1585 --parents --children
1587 $__git_diff_common_options
1588 --pickaxe-all --pickaxe-regex
1593 __git_complete_revlist
1596 __git_merge_options
="
1597 --no-commit --no-stat --log --no-log --squash --strategy
1598 --commit --stat --no-squash --ff --no-ff --ff-only --edit --no-edit
1603 __git_complete_strategy
&& return
1607 __gitcomp
"$__git_merge_options"
1610 __gitcomp_nl
"$(__git_refs)"
1617 __gitcomp
"$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"
1630 __gitcomp_nl
"$(__git_refs)"
1637 __gitcomp
"--dry-run"
1646 __gitcomp
"--tags --all --stdin"
1651 local subcommands
='add append copy edit list prune remove show'
1652 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
1654 case "$subcommand,$cur" in
1659 case "${words[cword-1]}" in
1661 __gitcomp_nl
"$(__git_refs)"
1664 __gitcomp
"$subcommands --ref"
1668 add
,--reuse-message=*|append
,--reuse-message=*|\
1669 add
,--reedit-message=*|append
,--reedit-message=*)
1670 __gitcomp_nl
"$(__git_refs)" "" "${cur#*=}"
1673 __gitcomp
'--file= --message= --reedit-message=
1680 __gitcomp
'--dry-run --verbose'
1685 case "${words[cword-1]}" in
1689 __gitcomp_nl
"$(__git_refs)"
1698 __git_complete_strategy
&& return
1703 --rebase --no-rebase
1704 $__git_merge_options
1705 $__git_fetch_options
1710 __git_complete_remote_or_refspec
1717 __gitcomp_nl
"$(__git_remotes)"
1722 __gitcomp_nl
"$(__git_remotes)" "" "${cur##--repo=}"
1727 --all --mirror --tags --dry-run --force --verbose
1728 --receive-pack= --repo= --set-upstream
1733 __git_complete_remote_or_refspec
1738 local dir
="$(__gitdir)"
1739 if [ -d "$dir"/rebase-apply
] ||
[ -d "$dir"/rebase-merge
]; then
1740 __gitcomp
"--continue --skip --abort"
1743 __git_complete_strategy
&& return
1746 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
1751 --onto --merge --strategy --interactive
1752 --preserve-merges --stat --no-stat
1753 --committer-date-is-author-date --ignore-date
1754 --ignore-whitespace --whitespace=
1760 __gitcomp_nl
"$(__git_refs)"
1765 local subcommands
="show delete expire"
1766 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
1768 if [ -z "$subcommand" ]; then
1769 __gitcomp
"$subcommands"
1771 __gitcomp_nl
"$(__git_refs)"
1775 __git_send_email_confirm_options
="always never auto cc compose"
1776 __git_send_email_suppresscc_options
="author self cc bodycc sob cccmd body all"
1783 $__git_send_email_confirm_options
1784 " "" "${cur##--confirm=}"
1789 $__git_send_email_suppresscc_options
1790 " "" "${cur##--suppress-cc=}"
1794 --smtp-encryption=*)
1795 __gitcomp
"ssl tls" "" "${cur##--smtp-encryption=}"
1799 __gitcomp
"--annotate --bcc --cc --cc-cmd --chain-reply-to
1800 --compose --confirm= --dry-run --envelope-sender
1802 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
1803 --no-suppress-from --no-thread --quiet
1804 --signed-off-by-cc --smtp-pass --smtp-server
1805 --smtp-server-port --smtp-encryption= --smtp-user
1806 --subject --suppress-cc= --suppress-from --thread --to
1807 --validate --no-validate"
1819 __git_config_get_set_variables
()
1821 local prevword word config_file
= c
=$cword
1822 while [ $c -gt 1 ]; do
1825 --global|
--system|
--file=*)
1830 config_file
="$word $prevword"
1838 git
--git-dir="$(__gitdir)" config
$config_file --list 2>/dev
/null |
1853 __gitcomp_nl
"$(__git_remotes)"
1857 __gitcomp_nl
"$(__git_refs)"
1861 local remote
="${prev#remote.}"
1862 remote
="${remote%.fetch}"
1863 if [ -z "$cur" ]; then
1864 COMPREPLY
=("refs/heads/")
1867 __gitcomp_nl
"$(__git_refs_remotes "$remote")"
1871 local remote
="${prev#remote.}"
1872 remote
="${remote%.push}"
1873 __gitcomp_nl
"$(git --git-dir="$
(__gitdir
)" \
1874 for-each-ref --format='%(refname):%(refname)' \
1878 pull.twohead|pull.octopus
)
1879 __git_compute_merge_strategies
1880 __gitcomp
"$__git_merge_strategies"
1883 color.branch|color.
diff|color.interactive|\
1884 color.showbranch|color.status|color.ui
)
1885 __gitcomp
"always never auto"
1889 __gitcomp
"false true"
1894 normal black red green yellow blue magenta cyan white
1895 bold dim ul blink reverse
1900 __gitcomp
"man info web html"
1904 __gitcomp
"$__git_log_date_formats"
1907 sendemail.aliasesfiletype
)
1908 __gitcomp
"mutt mailrc pine elm gnus"
1912 __gitcomp
"$__git_send_email_confirm_options"
1915 sendemail.suppresscc
)
1916 __gitcomp
"$__git_send_email_suppresscc_options"
1919 --get|
--get-all|
--unset|
--unset-all)
1920 __gitcomp_nl
"$(__git_config_get_set_variables)"
1931 --global --system --file=
1932 --list --replace-all
1933 --get --get-all --get-regexp
1934 --add --unset --unset-all
1935 --remove-section --rename-section
1940 local pfx
="${cur%.*}." cur_
="${cur##*.}"
1941 __gitcomp
"remote merge mergeoptions rebase" "$pfx" "$cur_"
1945 local pfx
="${cur%.*}." cur_
="${cur#*.}"
1946 __gitcomp_nl
"$(__git_heads)" "$pfx" "$cur_" "."
1950 local pfx
="${cur%.*}." cur_
="${cur##*.}"
1952 argprompt cmd confirm needsfile noconsole norescan
1953 prompt revprompt revunmerged title
1958 local pfx
="${cur%.*}." cur_
="${cur##*.}"
1959 __gitcomp
"cmd path" "$pfx" "$cur_"
1963 local pfx
="${cur%.*}." cur_
="${cur##*.}"
1964 __gitcomp
"cmd path" "$pfx" "$cur_"
1968 local pfx
="${cur%.*}." cur_
="${cur##*.}"
1969 __gitcomp
"cmd path trustExitCode" "$pfx" "$cur_"
1973 local pfx
="${cur%.*}." cur_
="${cur#*.}"
1974 __git_compute_all_commands
1975 __gitcomp_nl
"$__git_all_commands" "$pfx" "$cur_"
1979 local pfx
="${cur%.*}." cur_
="${cur##*.}"
1981 url proxy fetch push mirror skipDefaultUpdate
1982 receivepack uploadpack tagopt pushurl
1987 local pfx
="${cur%.*}." cur_
="${cur#*.}"
1988 __gitcomp_nl
"$(__git_remotes)" "$pfx" "$cur_" "."
1992 local pfx
="${cur%.*}." cur_
="${cur##*.}"
1993 __gitcomp
"insteadOf pushInsteadOf" "$pfx" "$cur_"
1999 advice.commitBeforeMerge
2001 advice.implicitIdentity
2002 advice.pushNonFastForward
2003 advice.resolveConflict
2007 apply.ignorewhitespace
2009 branch.autosetupmerge
2010 branch.autosetuprebase
2014 color.branch.current
2019 color.decorate.branch
2020 color.decorate.remoteBranch
2021 color.decorate.stash
2031 color.diff.whitespace
2036 color.grep.linenumber
2039 color.grep.separator
2041 color.interactive.error
2042 color.interactive.header
2043 color.interactive.help
2044 color.interactive.prompt
2049 color.status.changed
2051 color.status.nobranch
2052 color.status.untracked
2053 color.status.updated
2062 core.bigFileThreshold
2065 core.deltaBaseCacheLimit
2070 core.fsyncobjectfiles
2072 core.ignoreCygwinFSTricks
2075 core.logAllRefUpdates
2076 core.loosecompression
2079 core.packedGitWindowSize
2081 core.preferSymlinkRefs
2084 core.repositoryFormatVersion
2086 core.sharedRepository
2090 core.warnAmbiguousRefs
2093 diff.autorefreshindex
2095 diff.ignoreSubmodules
2100 diff.suppressBlankEmpty
2105 fetch.recurseSubmodules
2114 format.subjectprefix
2125 gc.reflogexpireunreachable
2129 gitcvs.commitmsgannotation
2130 gitcvs.dbTableNamePrefix
2141 gui.copyblamethreshold
2145 gui.matchtrackingbranch
2146 gui.newbranchtemplate
2147 gui.pruneduringfetch
2148 gui.spellingdictionary
2163 http.sslCertPasswordProtected
2168 i18n.logOutputEncoding
2174 imap.preformattedHTML
2184 interactive.singlekey
2200 mergetool.keepBackup
2201 mergetool.keepTemporaries
2206 notes.rewrite.rebase
2210 pack.deltaCacheLimit
2226 receive.denyCurrentBranch
2227 receive.denyDeleteCurrent
2229 receive.denyNonFastForwards
2232 receive.updateserverinfo
2234 repack.usedeltabaseoffset
2238 sendemail.aliasesfile
2239 sendemail.aliasfiletype
2243 sendemail.chainreplyto
2245 sendemail.envelopesender
2249 sendemail.signedoffbycc
2250 sendemail.smtpdomain
2251 sendemail.smtpencryption
2253 sendemail.smtpserver
2254 sendemail.smtpserveroption
2255 sendemail.smtpserverport
2257 sendemail.suppresscc
2258 sendemail.suppressfrom
2263 status.relativePaths
2264 status.showUntrackedFiles
2265 status.submodulesummary
2268 transfer.unpackLimit
2280 local subcommands
="add rename rm show prune update set-head"
2281 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
2282 if [ -z "$subcommand" ]; then
2283 __gitcomp
"$subcommands"
2287 case "$subcommand" in
2288 rename|
rm|show|prune
)
2289 __gitcomp_nl
"$(__git_remotes)"
2292 local i c
='' IFS
=$
'\n'
2293 for i
in $
(git
--git-dir="$(__gitdir)" config
--get-regexp "remotes\..*" 2>/dev
/null
); do
2307 __gitcomp_nl
"$(__git_refs)"
2312 __git_has_doubledash
&& return
2316 __gitcomp
"--merge --mixed --hard --soft --patch"
2320 __gitcomp_nl
"$(__git_refs)"
2327 __gitcomp
"--edit --mainline --no-edit --no-commit --signoff"
2331 __gitcomp_nl
"$(__git_refs)"
2336 __git_has_doubledash
&& return
2340 __gitcomp
"--cached --dry-run --ignore-unmatch --quiet"
2349 __git_has_doubledash
&& return
2354 $__git_log_common_options
2355 $__git_log_shortlog_options
2356 --numbered --summary
2361 __git_complete_revlist
2366 __git_has_doubledash
&& return
2369 --pretty=*|
--format=*)
2370 __gitcomp
"$__git_log_pretty_formats $(__git_pretty_aliases)
2375 __gitcomp
"--pretty= --format= --abbrev-commit --oneline
2376 $__git_diff_common_options
2389 --all --remotes --topo-order --current --more=
2390 --list --independent --merge-base --no-name
2392 --sha1-name --sparse --topics --reflog
2397 __git_complete_revlist
2402 local save_opts
='--keep-index --no-keep-index --quiet --patch'
2403 local subcommands
='save list show apply clear drop pop create branch'
2404 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
2405 if [ -z "$subcommand" ]; then
2408 __gitcomp
"$save_opts"
2411 if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then
2412 __gitcomp
"$subcommands"
2419 case "$subcommand,$cur" in
2421 __gitcomp
"$save_opts"
2424 __gitcomp
"--index --quiet"
2426 show
,--*|drop
,--*|branch
,--*)
2429 show
,*|apply
,*|drop
,*|pop
,*|branch
,*)
2430 __gitcomp_nl
"$(git --git-dir="$
(__gitdir
)" stash list \
2431 | sed -n -e 's/:.*//p')"
2442 __git_has_doubledash
&& return
2444 local subcommands
="add status init update summary foreach sync"
2445 if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then
2448 __gitcomp
"--quiet --cached"
2451 __gitcomp
"$subcommands"
2461 init fetch clone rebase dcommit log find-rev
2462 set-tree commit-diff info create-ignore propget
2463 proplist show-ignore show-externals branch tag blame
2464 migrate mkdirs reset gc
2466 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
2467 if [ -z "$subcommand" ]; then
2468 __gitcomp
"$subcommands"
2470 local remote_opts
="--username= --config-dir= --no-auth-cache"
2472 --follow-parent --authors-file= --repack=
2473 --no-metadata --use-svm-props --use-svnsync-props
2474 --log-window-size= --no-checkout --quiet
2475 --repack-flags --use-log-author --localtime
2476 --ignore-paths= $remote_opts
2479 --template= --shared= --trunk= --tags=
2480 --branches= --stdlayout --minimize-url
2481 --no-metadata --use-svm-props --use-svnsync-props
2482 --rewrite-root= --prefix= --use-log-author
2483 --add-author-from $remote_opts
2486 --edit --rmdir --find-copies-harder --copy-similarity=
2489 case "$subcommand,$cur" in
2491 __gitcomp
"--revision= --fetch-all $fc_opts"
2494 __gitcomp
"--revision= $fc_opts $init_opts"
2497 __gitcomp
"$init_opts"
2501 --merge --strategy= --verbose --dry-run
2502 --fetch-all --no-rebase --commit-url
2503 --revision $cmt_opts $fc_opts
2507 __gitcomp
"--stdin $cmt_opts $fc_opts"
2509 create-ignore
,--*|propget
,--*|proplist
,--*|show-ignore
,--*|\
2510 show-externals
,--*|mkdirs
,--*)
2511 __gitcomp
"--revision="
2515 --limit= --revision= --verbose --incremental
2516 --oneline --show-commit --non-recursive
2517 --authors-file= --color
2522 --merge --verbose --strategy= --local
2523 --fetch-all --dry-run $fc_opts
2527 __gitcomp
"--message= --file= --revision= $cmt_opts"
2533 __gitcomp
"--dry-run --message --tag"
2536 __gitcomp
"--dry-run --message"
2539 __gitcomp
"--git-format"
2543 --config-dir= --ignore-paths= --minimize
2544 --no-auth-cache --username=
2548 __gitcomp
"--revision= --parent"
2560 while [ $c -lt $cword ]; do
2564 __gitcomp_nl
"$(__git_tags)"
2580 __gitcomp_nl
"$(__git_tags)"
2586 __gitcomp_nl
"$(__git_refs)"
2598 local i c
=1 command __git_dir
2600 if [[ -n ${ZSH_VERSION-} ]]; then
2604 # workaround zsh's bug that leaves 'words' as a special
2605 # variable in versions < 4.3.12
2608 # workaround zsh's bug that quotes spaces in the COMPREPLY
2609 # array if IFS doesn't contain spaces.
2613 local cur words cword prev
2614 _get_comp_words_by_ref
-n =: cur words cword prev
2615 while [ $c -lt $cword ]; do
2618 --git-dir=*) __git_dir
="${i#--git-dir=}" ;;
2619 --bare) __git_dir
="." ;;
2620 --version|
-p|
--paginate) ;;
2621 --help) command="help"; break ;;
2622 *) command="$i"; break ;;
2627 if [ -z "$command" ]; then
2642 *) __git_compute_porcelain_commands
2643 __gitcomp
"$__git_porcelain_commands $(__git_aliases)" ;;
2648 local completion_func
="_git_${command//-/_}"
2649 declare -f $completion_func >/dev
/null
&& $completion_func && return
2651 local expansion
=$
(__git_aliased_command
"$command")
2652 if [ -n "$expansion" ]; then
2653 completion_func
="_git_${expansion//-/_}"
2654 declare -f $completion_func >/dev
/null
&& $completion_func
2660 if [[ -n ${ZSH_VERSION-} ]]; then
2664 # workaround zsh's bug that leaves 'words' as a special
2665 # variable in versions < 4.3.12
2668 # workaround zsh's bug that quotes spaces in the COMPREPLY
2669 # array if IFS doesn't contain spaces.
2673 local cur words cword prev
2674 _get_comp_words_by_ref
-n =: cur words cword prev
2676 __git_has_doubledash
&& return
2678 local g
="$(__gitdir)"
2680 if [ -f "$g/MERGE_HEAD" ]; then
2686 $__git_log_common_options
2687 $__git_log_gitk_options
2693 __git_complete_revlist
2696 complete
-o bashdefault
-o default
-o nospace
-F _git git
2>/dev
/null \
2697 || complete
-o default
-o nospace
-F _git git
2698 complete
-o bashdefault
-o default
-o nospace
-F _gitk gitk
2>/dev
/null \
2699 || complete
-o default
-o nospace
-F _gitk gitk
2701 # The following are necessary only for Cygwin, and only are needed
2702 # when the user has tab-completed the executable name and consequently
2703 # included the '.exe' suffix.
2705 if [ Cygwin
= "$(uname -o 2>/dev/null)" ]; then
2706 complete
-o bashdefault
-o default
-o nospace
-F _git git.exe
2>/dev
/null \
2707 || complete
-o default
-o nospace
-F _git git.exe