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
=""
101 # get some config options from git-config
102 local output
="$(git config -z --get-regexp '^(svn-remote\..*\.url|bash\.showupstream)$' 2>/dev/null | tr '\0\n' '\n ')"
103 while read -r key value
; do
106 GIT_PS1_SHOWUPSTREAM
="$value"
107 if [[ -z "${GIT_PS1_SHOWUPSTREAM}" ]]; then
113 svn_remote
[ $
((${#svn_remote[@]} + 1)) ]="$value"
114 svn_url_pattern
+="\\|$value"
115 upstream
=svn
+git
# default upstream is SVN if available, else git
120 # parse configuration values
121 for option
in ${GIT_PS1_SHOWUPSTREAM}; do
123 git|svn
) upstream
="$option" ;;
124 verbose
) verbose
=1 ;;
131 git
) upstream
="@{upstream}" ;;
133 # get the upstream from the "git-svn-id: ..." in a commit message
134 # (git-svn uses essentially the same procedure internally)
135 local svn_upstream
=($
(git log
--first-parent -1 \
136 --grep="^git-svn-id: \(${svn_url_pattern#??}\)" 2>/dev
/null
))
137 if [[ 0 -ne ${#svn_upstream[@]} ]]; then
138 svn_upstream
=${svn_upstream[ ${#svn_upstream[@]} - 2 ]}
139 svn_upstream
=${svn_upstream%@*}
140 local n_stop
="${#svn_remote[@]}"
141 for ((n
=1; n
<= n_stop
; n
++)); do
142 svn_upstream
=${svn_upstream#${svn_remote[$n]}}
145 if [[ -z "$svn_upstream" ]]; then
146 # default branch name for checkouts with no layout:
147 upstream
=${GIT_SVN_ID:-git-svn}
149 upstream
=${svn_upstream#/}
151 elif [[ "svn+git" = "$upstream" ]]; then
152 upstream
="@{upstream}"
157 # Find how many commits we are ahead/behind our upstream
158 if [[ -z "$legacy" ]]; then
159 count
="$(git rev-list --count --left-right \
160 "$upstream"...HEAD 2>/dev/null)"
162 # produce equivalent output to --count for older versions of git
164 if commits
="$(git rev-list --left-right "$upstream"...HEAD 2>/dev/null)"
166 local commit behind
=0 ahead
=0
167 for commit
in $commits
170 "<"*) ((behind
++)) ;;
174 count
="$behind $ahead"
180 # calculate the result
181 if [[ -z "$verbose" ]]; then
185 "0 0") # equal to upstream
187 "0 "*) # ahead of upstream
189 *" 0") # behind upstream
191 *) # diverged from upstream
198 "0 0") # equal to upstream
200 "0 "*) # ahead of upstream
201 p
=" u+${count#0 }" ;;
202 *" 0") # behind upstream
203 p
=" u-${count% 0}" ;;
204 *) # diverged from upstream
205 p
=" u+${count#* }-${count% *}" ;;
212 # __git_ps1 accepts 0 or 1 arguments (i.e., format string)
213 # returns text to add to bash PS1 prompt (includes branch name)
216 local g
="$(__gitdir)"
220 if [ -f "$g/rebase-merge/interactive" ]; then
222 b
="$(cat "$g/rebase-merge
/head-name
")"
223 elif [ -d "$g/rebase-merge" ]; then
225 b
="$(cat "$g/rebase-merge
/head-name
")"
227 if [ -d "$g/rebase-apply" ]; then
228 if [ -f "$g/rebase-apply/rebasing" ]; then
230 elif [ -f "$g/rebase-apply/applying" ]; then
235 elif [ -f "$g/MERGE_HEAD" ]; then
237 elif [ -f "$g/CHERRY_PICK_HEAD" ]; then
239 elif [ -f "$g/BISECT_LOG" ]; then
243 b
="$(git symbolic-ref HEAD 2>/dev/null)" ||
{
246 case "${GIT_PS1_DESCRIBE_STYLE-}" in
248 git describe --contains HEAD ;;
250 git describe --contains --all HEAD ;;
254 git describe --tags --exact-match HEAD ;;
255 esac 2>/dev/null)" ||
257 b
="$(cut -c1-7 "$g/HEAD
" 2>/dev/null)..." ||
270 if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then
271 if [ "true" = "$(git rev-parse --is-bare-repository 2>/dev/null)" ]; then
276 elif [ "true" = "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
277 if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ]; then
278 if [ "$(git config --bool bash.showDirtyState)" != "false" ]; then
279 git
diff --no-ext-diff --quiet --exit-code || w
="*"
280 if git rev-parse
--quiet --verify HEAD
>/dev
/null
; then
281 git diff-index
--cached --quiet HEAD
-- || i
="+"
287 if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ]; then
288 git rev-parse
--verify refs
/stash
>/dev
/null
2>&1 && s
="$"
291 if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ]; then
292 if [ -n "$(git ls-files --others --exclude-standard)" ]; then
297 if [ -n "${GIT_PS1_SHOWUPSTREAM-}" ]; then
298 __git_ps1_show_upstream
303 printf -- "${1:- (%s)}" "$c${b##refs/heads/}${f:+ $f}$r$p"
320 # The following function is based on code from:
322 # bash_completion - programmable completion functions for bash 3.2+
324 # Copyright © 2006-2008, Ian Macdonald <ian@caliban.org>
325 # © 2009-2010, Bash Completion Maintainers
326 # <bash-completion-devel@lists.alioth.debian.org>
328 # This program is free software; you can redistribute it and/or modify
329 # it under the terms of the GNU General Public License as published by
330 # the Free Software Foundation; either version 2, or (at your option)
333 # This program is distributed in the hope that it will be useful,
334 # but WITHOUT ANY WARRANTY; without even the implied warranty of
335 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
336 # GNU General Public License for more details.
338 # You should have received a copy of the GNU General Public License
339 # along with this program; if not, write to the Free Software Foundation,
340 # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
342 # The latest version of this software can be obtained here:
344 # http://bash-completion.alioth.debian.org/
348 # This function can be used to access a tokenized list of words
349 # on the command line:
351 # __git_reassemble_comp_words_by_ref '=:'
352 # if test "${words_[cword_-1]}" = -w
357 # The argument should be a collection of characters from the list of
358 # word completion separators (COMP_WORDBREAKS) to treat as ordinary
361 # This is roughly equivalent to going back in time and setting
362 # COMP_WORDBREAKS to exclude those characters. The intent is to
363 # make option types like --date=<type> and <rev>:<path> easy to
364 # recognize by treating each shell word as a single token.
366 # It is best not to set COMP_WORDBREAKS directly because the value is
367 # shared with other completion scripts. By the time the completion
368 # function gets called, COMP_WORDS has already been populated so local
369 # changes to COMP_WORDBREAKS have no effect.
371 # Output: words_, cword_, cur_.
373 __git_reassemble_comp_words_by_ref
()
375 local exclude i j first
376 # Which word separators to exclude?
377 exclude
="${1//[^$COMP_WORDBREAKS]}"
379 if [ -z "$exclude" ]; then
380 words_
=("${COMP_WORDS[@]}")
383 # List of word completion separators has shrunk;
384 # re-assemble words to complete.
385 for ((i
=0, j
=0; i
< ${#COMP_WORDS[@]}; i
++, j
++)); do
386 # Append each nonempty word consisting of just
387 # word separator characters to the current word.
391 [ -n "${COMP_WORDS[$i]}" ] &&
392 # word consists of excluded word separators
393 [ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ]
395 # Attach to the previous token,
396 # unless the previous token is the command name.
397 if [ $j -ge 2 ] && [ -n "$first" ]; then
401 words_
[$j]=${words_[j]}${COMP_WORDS[i]}
402 if [ $i = $COMP_CWORD ]; then
405 if (($i < ${#COMP_WORDS[@]} - 1)); then
412 words_
[$j]=${words_[j]}${COMP_WORDS[i]}
413 if [ $i = $COMP_CWORD ]; then
419 if ! type _get_comp_words_by_ref
>/dev
/null
2>&1; then
420 if [[ -z ${ZSH_VERSION:+set} ]]; then
421 _get_comp_words_by_ref
()
423 local exclude cur_ words_ cword_
424 if [ "$1" = "-n" ]; then
428 __git_reassemble_comp_words_by_ref
"$exclude"
429 cur_
=${words_[cword_]}
430 while [ $# -gt 0 ]; do
436 prev
=${words_[$cword_-1]}
439 words
=("${words_[@]}")
449 _get_comp_words_by_ref
()
451 while [ $# -gt 0 ]; do
454 cur
=${COMP_WORDS[COMP_CWORD]}
457 prev
=${COMP_WORDS[COMP_CWORD-1]}
460 words
=("${COMP_WORDS[@]}")
466 # assume COMP_WORDBREAKS is already set sanely
476 # Generates completion reply with compgen, appending a space to possible
477 # completion words, if necessary.
478 # It accepts 1 to 4 arguments:
479 # 1: List of possible completion words.
480 # 2: A prefix to be added to each possible completion word (optional).
481 # 3: Generate possible completion matches for this word (optional).
482 # 4: A suffix to be appended to each possible completion word (optional).
485 local cur_
="${3-$cur}"
493 COMPREPLY
=($
(compgen
-P "${2-}" \
494 -W "$(__gitcomp_1 "${1-}" "${4-}")" \
500 # Generates completion reply with compgen from newline-separated possible
501 # completion words by appending a space to all of them.
502 # It accepts 1 to 4 arguments:
503 # 1: List of possible completion words, separated by a single newline.
504 # 2: A prefix to be added to each possible completion word (optional).
505 # 3: Generate possible completion matches for this word (optional).
506 # 4: A suffix to be appended to each possible completion word instead of
507 # the default space (optional). If specified but empty, nothing is
513 # ZSH would quote the trailing space added with -S. bash users
514 # will appreciate the extra space to compensate the use of -o nospace.
515 if [ -n "${ZSH_VERSION-}" ] && [ "$suffix" = " " ]; then
519 COMPREPLY
=($
(compgen
-P "${2-}" -S "${4- }" -W "$1" -- "${3-$cur}"))
524 local dir
="$(__gitdir)"
525 if [ -d "$dir" ]; then
526 git
--git-dir="$dir" for-each-ref
--format='%(refname:short)' \
534 local dir
="$(__gitdir)"
535 if [ -d "$dir" ]; then
536 git
--git-dir="$dir" for-each-ref
--format='%(refname:short)' \
542 # __git_refs accepts 0, 1 (to pass to __gitdir), or 2 arguments
543 # presence of 2nd argument means use the guess heuristic employed
544 # by checkout for tracking branches
547 local i
hash dir
="$(__gitdir "${1-}")" track
="${2-}"
549 if [ -d "$dir" ]; then
557 for i
in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD
; do
558 if [ -e "$dir/$i" ]; then echo $i; fi
560 format
="refname:short"
561 refs
="refs/tags refs/heads refs/remotes"
564 git
--git-dir="$dir" for-each-ref
--format="%($format)" \
566 if [ -n "$track" ]; then
567 # employ the heuristic used by git checkout
568 # Try to find a remote branch that matches the completion word
569 # but only output if the branch name is unique
571 git
--git-dir="$dir" for-each-ref
--shell --format="ref=%(refname:short)" \
573 while read -r entry
; do
576 if [[ "$ref" == "$cur"* ]]; then
585 git ls-remote
"$dir" "$cur*" 2>/dev
/null | \
586 while read -r hash i
; do
594 git ls-remote
"$dir" HEAD ORIG_HEAD
'refs/tags/*' 'refs/heads/*' 'refs/remotes/*' 2>/dev
/null | \
595 while read -r hash i
; do
598 refs
/*) echo "${i#refs/*/}" ;;
606 # __git_refs2 requires 1 argument (to pass to __git_refs)
610 for i
in $
(__git_refs
"$1"); do
615 # __git_refs_remotes requires 1 argument (to pass to ls-remote)
616 __git_refs_remotes
()
619 git ls-remote
"$1" 'refs/heads/*' 2>/dev
/null | \
620 while read -r hash i
; do
621 echo "$i:refs/remotes/$1/${i#refs/heads/}"
627 local i IFS
=$
'\n' d
="$(__gitdir)"
628 test -d "$d/remotes" && ls -1 "$d/remotes"
629 for i
in $
(git
--git-dir="$d" config
--get-regexp 'remote\..*\.url' 2>/dev
/null
); do
635 __git_list_merge_strategies
()
637 git merge
-s help 2>&1 |
638 sed -n -e '/[Aa]vailable strategies are: /,/^$/{
647 __git_merge_strategies
=
648 # 'git merge -s help' (and thus detection of the merge strategy
649 # list) fails, unfortunately, if run outside of any git working
650 # tree. __git_merge_strategies is set to the empty string in
651 # that case, and the detection will be repeated the next time it
653 __git_compute_merge_strategies
()
655 test -n "$__git_merge_strategies" ||
656 __git_merge_strategies
=$
(__git_list_merge_strategies
)
659 __git_complete_revlist_file
()
661 local pfx
ls ref cur_
="$cur"
681 case "$COMP_WORDBREAKS" in
683 *) pfx
="$ref:$pfx" ;;
686 __gitcomp_nl
"$(git --git-dir="$
(__gitdir
)" ls-tree "$ls" \
687 | sed '/^100... blob /{
703 pfx
="${cur_%...*}..."
705 __gitcomp_nl
"$(__git_refs)" "$pfx" "$cur_"
710 __gitcomp_nl
"$(__git_refs)" "$pfx" "$cur_"
713 __gitcomp_nl
"$(__git_refs)"
719 __git_complete_file
()
721 __git_complete_revlist_file
724 __git_complete_revlist
()
726 __git_complete_revlist_file
729 __git_complete_remote_or_refspec
()
731 local cur_
="$cur" cmd
="${words[1]}"
732 local i c
=2 remote
="" pfx
="" lhs
=1 no_complete_refspec
=0
733 if [ "$cmd" = "remote" ]; then
736 while [ $c -lt $cword ]; do
739 --mirror) [ "$cmd" = "push" ] && no_complete_refspec
=1 ;;
742 push
) no_complete_refspec
=1 ;;
751 *) remote
="$i"; break ;;
755 if [ -z "$remote" ]; then
756 __gitcomp_nl
"$(__git_remotes)"
759 if [ $no_complete_refspec = 1 ]; then
763 [ "$remote" = "." ] && remote
=
766 case "$COMP_WORDBREAKS" in
768 *) pfx
="${cur_%%:*}:" ;;
780 if [ $lhs = 1 ]; then
781 __gitcomp_nl
"$(__git_refs2 "$remote")" "$pfx" "$cur_"
783 __gitcomp_nl
"$(__git_refs)" "$pfx" "$cur_"
787 if [ $lhs = 1 ]; then
788 __gitcomp_nl
"$(__git_refs "$remote")" "$pfx" "$cur_"
790 __gitcomp_nl
"$(__git_refs)" "$pfx" "$cur_"
794 if [ $lhs = 1 ]; then
795 __gitcomp_nl
"$(__git_refs)" "$pfx" "$cur_"
797 __gitcomp_nl
"$(__git_refs "$remote")" "$pfx" "$cur_"
803 __git_complete_strategy
()
805 __git_compute_merge_strategies
808 __gitcomp
"$__git_merge_strategies"
813 __gitcomp
"$__git_merge_strategies" "" "${cur##--strategy=}"
820 __git_list_all_commands
()
823 for i
in $
(git
help -a|
egrep '^ [a-zA-Z0-9]')
826 *--*) : helper pattern
;;
833 __git_compute_all_commands
()
835 test -n "$__git_all_commands" ||
836 __git_all_commands
=$
(__git_list_all_commands
)
839 __git_list_porcelain_commands
()
842 __git_compute_all_commands
843 for i
in "help" $__git_all_commands
846 *--*) : helper pattern
;;
847 applymbox
) : ask gittus
;;
848 applypatch
) : ask gittus
;;
849 archimport
) : import
;;
850 cat-file
) : plumbing
;;
851 check-attr
) : plumbing
;;
852 check-ref-format
) : plumbing
;;
853 checkout-index
) : plumbing
;;
854 commit-tree
) : plumbing
;;
855 count-objects
) : infrequent
;;
856 cvsexportcommit
) : export;;
857 cvsimport
) : import
;;
858 cvsserver
) : daemon
;;
860 diff-files
) : plumbing
;;
861 diff-index
) : plumbing
;;
862 diff-tree
) : plumbing
;;
863 fast-import
) : import
;;
864 fast-export
) : export;;
865 fsck-objects
) : plumbing
;;
866 fetch-pack
) : plumbing
;;
867 fmt-merge-msg
) : plumbing
;;
868 for-each-ref
) : plumbing
;;
869 hash-object
) : plumbing
;;
870 http-
*) : transport
;;
871 index-pack
) : plumbing
;;
872 init-db
) : deprecated
;;
873 local-fetch
) : plumbing
;;
874 lost-found
) : infrequent
;;
875 ls-files
) : plumbing
;;
876 ls-remote
) : plumbing
;;
877 ls-tree
) : plumbing
;;
878 mailinfo
) : plumbing
;;
879 mailsplit
) : plumbing
;;
880 merge-
*) : plumbing
;;
883 pack-objects
) : plumbing
;;
884 pack-redundant
) : plumbing
;;
885 pack-refs
) : plumbing
;;
886 parse-remote
) : plumbing
;;
887 patch-id
) : plumbing
;;
888 peek-remote
) : plumbing
;;
890 prune-packed
) : plumbing
;;
891 quiltimport
) : import
;;
892 read-tree
) : plumbing
;;
893 receive-pack
) : plumbing
;;
894 remote-
*) : transport
;;
895 repo-config
) : deprecated
;;
897 rev-list
) : plumbing
;;
898 rev-parse
) : plumbing
;;
899 runstatus
) : plumbing
;;
900 sh-setup
) : internal
;;
902 show-ref
) : plumbing
;;
903 send-pack
) : plumbing
;;
904 show-index
) : plumbing
;;
906 stripspace
) : plumbing
;;
907 symbolic-ref
) : plumbing
;;
908 tar-tree
) : deprecated
;;
909 unpack-file
) : plumbing
;;
910 unpack-objects
) : plumbing
;;
911 update-index
) : plumbing
;;
912 update-ref
) : plumbing
;;
913 update-server-info
) : daemon
;;
914 upload-archive
) : plumbing
;;
915 upload-pack
) : plumbing
;;
916 write-tree
) : plumbing
;;
918 verify-pack
) : infrequent
;;
919 verify-tag
) : plumbing
;;
925 __git_porcelain_commands
=
926 __git_compute_porcelain_commands
()
928 __git_compute_all_commands
929 test -n "$__git_porcelain_commands" ||
930 __git_porcelain_commands
=$
(__git_list_porcelain_commands
)
933 __git_pretty_aliases
()
936 for i
in $
(git
--git-dir="$(__gitdir)" config
--get-regexp "pretty\..*" 2>/dev
/null
); do
949 for i
in $
(git
--git-dir="$(__gitdir)" config
--get-regexp "alias\..*" 2>/dev
/null
); do
959 # __git_aliased_command requires 1 argument
960 __git_aliased_command
()
962 local word cmdline
=$
(git
--git-dir="$(__gitdir)" \
963 config
--get "alias.$1")
964 for word
in $cmdline; do
970 \
!*) : shell
command alias ;;
972 *=*) : setting env
;;
981 # __git_find_on_cmdline requires 1 argument
982 __git_find_on_cmdline
()
984 local word subcommand c
=1
985 while [ $c -lt $cword ]; do
987 for subcommand
in $1; do
988 if [ "$subcommand" = "$word" ]; then
997 __git_has_doubledash
()
1000 while [ $c -lt $cword ]; do
1001 if [ "--" = "${words[c]}" ]; then
1009 __git_whitespacelist
="nowarn warn error error-all fix"
1013 local dir
="$(__gitdir)"
1014 if [ -d "$dir"/rebase-apply
]; then
1015 __gitcomp
"--skip --continue --resolved --abort"
1020 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
1025 --3way --committer-date-is-author-date --ignore-date
1026 --ignore-whitespace --ignore-space-change
1027 --interactive --keep --no-utf8 --signoff --utf8
1028 --whitespace= --scissors
1039 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
1044 --stat --numstat --summary --check --index
1045 --cached --index-info --reverse --reject --unidiff-zero
1046 --apply --no-add --exclude=
1047 --ignore-whitespace --ignore-space-change
1048 --whitespace= --inaccurate-eof --verbose
1057 __git_has_doubledash
&& return
1062 --interactive --refresh --patch --update --dry-run
1063 --ignore-errors --intent-to-add
1074 __gitcomp
"$(git archive --list)" "" "${cur##--format=}"
1078 __gitcomp_nl
"$(__git_remotes)" "" "${cur##--remote=}"
1083 --format= --list --verbose
1084 --prefix= --remote= --exec=
1094 __git_has_doubledash
&& return
1096 local subcommands
="start bad good skip reset visualize replay log run"
1097 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
1098 if [ -z "$subcommand" ]; then
1099 if [ -f "$(__gitdir)"/BISECT_START
]; then
1100 __gitcomp
"$subcommands"
1102 __gitcomp
"replay start"
1107 case "$subcommand" in
1108 bad|good|
reset|skip|start
)
1109 __gitcomp_nl
"$(__git_refs)"
1119 local i c
=1 only_local_ref
="n" has_r
="n"
1121 while [ $c -lt $cword ]; do
1124 -d|
-m) only_local_ref
="y" ;;
1133 --color --no-color --verbose --abbrev= --no-abbrev
1134 --track --no-track --contains --merged --no-merged
1135 --set-upstream --edit-description --list
1139 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
1140 __gitcomp_nl
"$(__git_heads)"
1142 __gitcomp_nl
"$(__git_refs)"
1150 local cmd
="${words[2]}"
1153 __gitcomp
"create list-heads verify unbundle"
1156 # looking for a file
1161 __git_complete_revlist
1170 __git_has_doubledash
&& return
1174 __gitcomp
"diff3 merge" "" "${cur##--conflict=}"
1178 --quiet --ours --theirs --track --no-track --merge
1179 --conflict= --orphan --patch
1183 # check if --track, --no-track, or --no-guess was specified
1184 # if so, disable DWIM mode
1185 local flags
="--track --no-track --no-guess" track
=1
1186 if [ -n "$(__git_find_on_cmdline "$flags")" ]; then
1189 __gitcomp_nl
"$(__git_refs '' $track)"
1196 __gitcomp
"$(__git_refs)"
1203 __gitcomp
"--edit --no-commit"
1206 __gitcomp_nl
"$(__git_refs)"
1213 __git_has_doubledash
&& return
1217 __gitcomp
"--dry-run --quiet"
1250 __git_has_doubledash
&& return
1254 __gitcomp
"default strip verbatim whitespace
1255 " "" "${cur##--cleanup=}"
1258 --reuse-message=*|
--reedit-message=*|\
1259 --fixup=*|
--squash=*)
1260 __gitcomp_nl
"$(__git_refs)" "" "${cur#*=}"
1263 --untracked-files=*)
1264 __gitcomp
"all no normal" "" "${cur##--untracked-files=}"
1269 --all --author= --signoff --verify --no-verify
1270 --edit --amend --include --only --interactive
1271 --dry-run --reuse-message= --reedit-message=
1272 --reset-author --file= --message= --template=
1273 --cleanup= --untracked-files --untracked-files=
1274 --verbose --quiet --fixup= --squash=
1286 --all --tags --contains --abbrev= --candidates=
1287 --exact-match --debug --long --match --always
1291 __gitcomp_nl
"$(__git_refs)"
1294 __git_diff_common_options
="--stat --numstat --shortstat --summary
1295 --patch-with-stat --name-only --name-status --color
1296 --no-color --color-words --no-renames --check
1297 --full-index --binary --abbrev --diff-filter=
1298 --find-copies-harder
1299 --text --ignore-space-at-eol --ignore-space-change
1300 --ignore-all-space --exit-code --quiet --ext-diff
1302 --no-prefix --src-prefix= --dst-prefix=
1303 --inter-hunk-context=
1306 --dirstat --dirstat= --dirstat-by-file
1307 --dirstat-by-file= --cumulative
1312 __git_has_doubledash
&& return
1316 __gitcomp
"--cached --staged --pickaxe-all --pickaxe-regex
1317 --base --ours --theirs --no-index
1318 $__git_diff_common_options
1323 __git_complete_revlist_file
1326 __git_mergetools_common
="diffuse ecmerge emerge kdiff3 meld opendiff
1327 tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc3
1332 __git_has_doubledash
&& return
1336 __gitcomp
"$__git_mergetools_common kompare" "" "${cur##--tool=}"
1340 __gitcomp
"--cached --staged --pickaxe-all --pickaxe-regex
1341 --base --ours --theirs
1342 --no-renames --diff-filter= --find-copies-harder
1343 --relative --ignore-submodules
1351 __git_fetch_options
="
1352 --quiet --verbose --append --upload-pack --force --keep --depth=
1353 --tags --no-tags --all --prune --dry-run
1360 __gitcomp
"$__git_fetch_options"
1364 __git_complete_remote_or_refspec
1367 _git_format_patch
()
1373 " "" "${cur##--thread=}"
1378 --stdout --attach --no-attach --thread --thread=
1380 --numbered --start-number
1383 --signoff --signature --no-signature
1384 --in-reply-to= --cc=
1385 --full-index --binary
1388 --no-prefix --src-prefix= --dst-prefix=
1389 --inline --suffix= --ignore-if-in-upstream
1395 __git_complete_revlist
1403 --tags --root --unreachable --cache --no-reflogs --full
1404 --strict --verbose --lost-found
1416 __gitcomp
"--prune --aggressive"
1428 __git_match_ctag
() {
1429 awk "/^${1////\\/}/ { print \$1 }" "$2"
1434 __git_has_doubledash
&& return
1440 --text --ignore-case --word-regexp --invert-match
1441 --full-name --line-number
1442 --extended-regexp --basic-regexp --fixed-strings
1444 --files-with-matches --name-only
1445 --files-without-match
1448 --and --or --not --all-match
1454 case "$cword,$prev" in
1456 if test -r tags
; then
1457 __gitcomp_nl
"$(__git_match_ctag "$cur" tags)"
1463 __gitcomp_nl
"$(__git_refs)"
1470 __gitcomp
"--all --info --man --web"
1474 __git_compute_all_commands
1475 __gitcomp
"$__git_all_commands $(__git_aliases)
1476 attributes cli core-tutorial cvs-migration
1477 diffcore gitk glossary hooks ignore modules
1478 namespaces repository-layout tutorial tutorial-2
1488 false true umask group all world everybody
1489 " "" "${cur##--shared=}"
1493 __gitcomp
"--quiet --bare --template= --shared --shared="
1502 __git_has_doubledash
&& return
1506 __gitcomp
"--cached --deleted --modified --others --ignored
1507 --stage --directory --no-empty-directory --unmerged
1508 --killed --exclude= --exclude-from=
1509 --exclude-per-directory= --exclude-standard
1510 --error-unmatch --with-tree= --full-name
1511 --abbrev --ignored --exclude-per-directory
1521 __gitcomp_nl
"$(__git_remotes)"
1529 # Options that go well for log, shortlog and gitk
1530 __git_log_common_options
="
1532 --branches --tags --remotes
1533 --first-parent --merges --no-merges
1535 --max-age= --since= --after=
1536 --min-age= --until= --before=
1537 --min-parents= --max-parents=
1538 --no-min-parents --no-max-parents
1540 # Options that go well for log and gitk (not shortlog)
1541 __git_log_gitk_options
="
1542 --dense --sparse --full-history
1543 --simplify-merges --simplify-by-decoration
1544 --left-right --notes --no-notes
1546 # Options that go well for log and shortlog (not gitk)
1547 __git_log_shortlog_options
="
1548 --author= --committer= --grep=
1552 __git_log_pretty_formats
="oneline short medium full fuller email raw format:"
1553 __git_log_date_formats
="relative iso8601 rfc2822 short local default raw"
1557 __git_has_doubledash
&& return
1559 local g
="$(git rev-parse --git-dir 2>/dev/null)"
1561 if [ -f "$g/MERGE_HEAD" ]; then
1565 --pretty=*|
--format=*)
1566 __gitcomp
"$__git_log_pretty_formats $(__git_pretty_aliases)
1571 __gitcomp
"$__git_log_date_formats" "" "${cur##--date=}"
1575 __gitcomp
"long short" "" "${cur##--decorate=}"
1580 $__git_log_common_options
1581 $__git_log_shortlog_options
1582 $__git_log_gitk_options
1583 --root --topo-order --date-order --reverse
1584 --follow --full-diff
1585 --abbrev-commit --abbrev=
1586 --relative-date --date=
1587 --pretty= --format= --oneline
1590 --decorate --decorate=
1592 --parents --children
1594 $__git_diff_common_options
1595 --pickaxe-all --pickaxe-regex
1600 __git_complete_revlist
1603 __git_merge_options
="
1604 --no-commit --no-stat --log --no-log --squash --strategy
1605 --commit --stat --no-squash --ff --no-ff --ff-only --edit --no-edit
1610 __git_complete_strategy
&& return
1614 __gitcomp
"$__git_merge_options"
1617 __gitcomp_nl
"$(__git_refs)"
1624 __gitcomp
"$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"
1637 __gitcomp_nl
"$(__git_refs)"
1644 __gitcomp
"--dry-run"
1653 __gitcomp
"--tags --all --stdin"
1658 local subcommands
='add append copy edit list prune remove show'
1659 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
1661 case "$subcommand,$cur" in
1668 __gitcomp_nl
"$(__git_refs)"
1671 __gitcomp
"$subcommands --ref"
1675 add
,--reuse-message=*|append
,--reuse-message=*|\
1676 add
,--reedit-message=*|append
,--reedit-message=*)
1677 __gitcomp_nl
"$(__git_refs)" "" "${cur#*=}"
1680 __gitcomp
'--file= --message= --reedit-message=
1687 __gitcomp
'--dry-run --verbose'
1696 __gitcomp_nl
"$(__git_refs)"
1705 __git_complete_strategy
&& return
1710 --rebase --no-rebase
1711 $__git_merge_options
1712 $__git_fetch_options
1717 __git_complete_remote_or_refspec
1724 __gitcomp_nl
"$(__git_remotes)"
1729 __gitcomp_nl
"$(__git_remotes)" "" "${cur##--repo=}"
1734 --all --mirror --tags --dry-run --force --verbose
1735 --receive-pack= --repo= --set-upstream
1740 __git_complete_remote_or_refspec
1745 local dir
="$(__gitdir)"
1746 if [ -d "$dir"/rebase-apply
] ||
[ -d "$dir"/rebase-merge
]; then
1747 __gitcomp
"--continue --skip --abort"
1750 __git_complete_strategy
&& return
1753 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
1758 --onto --merge --strategy --interactive
1759 --preserve-merges --stat --no-stat
1760 --committer-date-is-author-date --ignore-date
1761 --ignore-whitespace --whitespace=
1767 __gitcomp_nl
"$(__git_refs)"
1772 local subcommands
="show delete expire"
1773 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
1775 if [ -z "$subcommand" ]; then
1776 __gitcomp
"$subcommands"
1778 __gitcomp_nl
"$(__git_refs)"
1782 __git_send_email_confirm_options
="always never auto cc compose"
1783 __git_send_email_suppresscc_options
="author self cc bodycc sob cccmd body all"
1790 $__git_send_email_confirm_options
1791 " "" "${cur##--confirm=}"
1796 $__git_send_email_suppresscc_options
1797 " "" "${cur##--suppress-cc=}"
1801 --smtp-encryption=*)
1802 __gitcomp
"ssl tls" "" "${cur##--smtp-encryption=}"
1806 __gitcomp
"--annotate --bcc --cc --cc-cmd --chain-reply-to
1807 --compose --confirm= --dry-run --envelope-sender
1809 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
1810 --no-suppress-from --no-thread --quiet
1811 --signed-off-by-cc --smtp-pass --smtp-server
1812 --smtp-server-port --smtp-encryption= --smtp-user
1813 --subject --suppress-cc= --suppress-from --thread --to
1814 --validate --no-validate"
1826 __git_config_get_set_variables
()
1828 local prevword word config_file
= c
=$cword
1829 while [ $c -gt 1 ]; do
1832 --global|
--system|
--file=*)
1837 config_file
="$word $prevword"
1845 git
--git-dir="$(__gitdir)" config
$config_file --list 2>/dev
/null |
1860 __gitcomp_nl
"$(__git_remotes)"
1864 __gitcomp_nl
"$(__git_refs)"
1868 local remote
="${prev#remote.}"
1869 remote
="${remote%.fetch}"
1870 if [ -z "$cur" ]; then
1871 COMPREPLY
=("refs/heads/")
1874 __gitcomp_nl
"$(__git_refs_remotes "$remote")"
1878 local remote
="${prev#remote.}"
1879 remote
="${remote%.push}"
1880 __gitcomp_nl
"$(git --git-dir="$
(__gitdir
)" \
1881 for-each-ref --format='%(refname):%(refname)' \
1885 pull.twohead|pull.octopus
)
1886 __git_compute_merge_strategies
1887 __gitcomp
"$__git_merge_strategies"
1890 color.branch|color.
diff|color.interactive|\
1891 color.showbranch|color.status|color.ui
)
1892 __gitcomp
"always never auto"
1896 __gitcomp
"false true"
1901 normal black red green yellow blue magenta cyan white
1902 bold dim ul blink reverse
1907 __gitcomp
"man info web html"
1911 __gitcomp
"$__git_log_date_formats"
1914 sendemail.aliasesfiletype
)
1915 __gitcomp
"mutt mailrc pine elm gnus"
1919 __gitcomp
"$__git_send_email_confirm_options"
1922 sendemail.suppresscc
)
1923 __gitcomp
"$__git_send_email_suppresscc_options"
1926 --get|
--get-all|
--unset|
--unset-all)
1927 __gitcomp_nl
"$(__git_config_get_set_variables)"
1938 --global --system --file=
1939 --list --replace-all
1940 --get --get-all --get-regexp
1941 --add --unset --unset-all
1942 --remove-section --rename-section
1947 local pfx
="${cur%.*}." cur_
="${cur##*.}"
1948 __gitcomp
"remote merge mergeoptions rebase" "$pfx" "$cur_"
1952 local pfx
="${cur%.*}." cur_
="${cur#*.}"
1953 __gitcomp_nl
"$(__git_heads)" "$pfx" "$cur_" "."
1957 local pfx
="${cur%.*}." cur_
="${cur##*.}"
1959 argprompt cmd confirm needsfile noconsole norescan
1960 prompt revprompt revunmerged title
1965 local pfx
="${cur%.*}." cur_
="${cur##*.}"
1966 __gitcomp
"cmd path" "$pfx" "$cur_"
1970 local pfx
="${cur%.*}." cur_
="${cur##*.}"
1971 __gitcomp
"cmd path" "$pfx" "$cur_"
1975 local pfx
="${cur%.*}." cur_
="${cur##*.}"
1976 __gitcomp
"cmd path trustExitCode" "$pfx" "$cur_"
1980 local pfx
="${cur%.*}." cur_
="${cur#*.}"
1981 __git_compute_all_commands
1982 __gitcomp_nl
"$__git_all_commands" "$pfx" "$cur_"
1986 local pfx
="${cur%.*}." cur_
="${cur##*.}"
1988 url proxy fetch push mirror skipDefaultUpdate
1989 receivepack uploadpack tagopt pushurl
1994 local pfx
="${cur%.*}." cur_
="${cur#*.}"
1995 __gitcomp_nl
"$(__git_remotes)" "$pfx" "$cur_" "."
1999 local pfx
="${cur%.*}." cur_
="${cur##*.}"
2000 __gitcomp
"insteadOf pushInsteadOf" "$pfx" "$cur_"
2006 advice.commitBeforeMerge
2008 advice.implicitIdentity
2009 advice.pushNonFastForward
2010 advice.resolveConflict
2014 apply.ignorewhitespace
2016 branch.autosetupmerge
2017 branch.autosetuprebase
2021 color.branch.current
2026 color.decorate.branch
2027 color.decorate.remoteBranch
2028 color.decorate.stash
2038 color.diff.whitespace
2043 color.grep.linenumber
2046 color.grep.separator
2048 color.interactive.error
2049 color.interactive.header
2050 color.interactive.help
2051 color.interactive.prompt
2056 color.status.changed
2058 color.status.nobranch
2059 color.status.untracked
2060 color.status.updated
2069 core.bigFileThreshold
2072 core.deltaBaseCacheLimit
2077 core.fsyncobjectfiles
2079 core.ignoreCygwinFSTricks
2082 core.logAllRefUpdates
2083 core.loosecompression
2086 core.packedGitWindowSize
2088 core.preferSymlinkRefs
2091 core.repositoryFormatVersion
2093 core.sharedRepository
2097 core.warnAmbiguousRefs
2100 diff.autorefreshindex
2103 diff.ignoreSubmodules
2108 diff.suppressBlankEmpty
2113 fetch.recurseSubmodules
2122 format.subjectprefix
2133 gc.reflogexpireunreachable
2137 gitcvs.commitmsgannotation
2138 gitcvs.dbTableNamePrefix
2149 gui.copyblamethreshold
2153 gui.matchtrackingbranch
2154 gui.newbranchtemplate
2155 gui.pruneduringfetch
2156 gui.spellingdictionary
2171 http.sslCertPasswordProtected
2176 i18n.logOutputEncoding
2182 imap.preformattedHTML
2192 interactive.singlekey
2208 mergetool.keepBackup
2209 mergetool.keepTemporaries
2214 notes.rewrite.rebase
2218 pack.deltaCacheLimit
2234 receive.denyCurrentBranch
2235 receive.denyDeleteCurrent
2237 receive.denyNonFastForwards
2240 receive.updateserverinfo
2242 repack.usedeltabaseoffset
2246 sendemail.aliasesfile
2247 sendemail.aliasfiletype
2251 sendemail.chainreplyto
2253 sendemail.envelopesender
2257 sendemail.signedoffbycc
2258 sendemail.smtpdomain
2259 sendemail.smtpencryption
2261 sendemail.smtpserver
2262 sendemail.smtpserveroption
2263 sendemail.smtpserverport
2265 sendemail.suppresscc
2266 sendemail.suppressfrom
2271 status.relativePaths
2272 status.showUntrackedFiles
2273 status.submodulesummary
2276 transfer.unpackLimit
2288 local subcommands
="add rename rm set-head set-branches set-url show prune update"
2289 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
2290 if [ -z "$subcommand" ]; then
2291 __gitcomp
"$subcommands"
2295 case "$subcommand" in
2296 rename|
rm|set-url|show|prune
)
2297 __gitcomp_nl
"$(__git_remotes)"
2299 set-head|set-branches
)
2300 __git_complete_remote_or_refspec
2303 local i c
='' IFS
=$
'\n'
2304 for i
in $
(git
--git-dir="$(__gitdir)" config
--get-regexp "remotes\..*" 2>/dev
/null
); do
2318 __gitcomp_nl
"$(__git_refs)"
2323 __git_has_doubledash
&& return
2327 __gitcomp
"--merge --mixed --hard --soft --patch"
2331 __gitcomp_nl
"$(__git_refs)"
2338 __gitcomp
"--edit --mainline --no-edit --no-commit --signoff"
2342 __gitcomp_nl
"$(__git_refs)"
2347 __git_has_doubledash
&& return
2351 __gitcomp
"--cached --dry-run --ignore-unmatch --quiet"
2360 __git_has_doubledash
&& return
2365 $__git_log_common_options
2366 $__git_log_shortlog_options
2367 --numbered --summary
2372 __git_complete_revlist
2377 __git_has_doubledash
&& return
2380 --pretty=*|
--format=*)
2381 __gitcomp
"$__git_log_pretty_formats $(__git_pretty_aliases)
2386 __gitcomp
"--pretty= --format= --abbrev-commit --oneline
2387 $__git_diff_common_options
2400 --all --remotes --topo-order --current --more=
2401 --list --independent --merge-base --no-name
2403 --sha1-name --sparse --topics --reflog
2408 __git_complete_revlist
2413 local save_opts
='--keep-index --no-keep-index --quiet --patch'
2414 local subcommands
='save list show apply clear drop pop create branch'
2415 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
2416 if [ -z "$subcommand" ]; then
2419 __gitcomp
"$save_opts"
2422 if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then
2423 __gitcomp
"$subcommands"
2430 case "$subcommand,$cur" in
2432 __gitcomp
"$save_opts"
2435 __gitcomp
"--index --quiet"
2437 show
,--*|drop
,--*|branch
,--*)
2440 show
,*|apply
,*|drop
,*|pop
,*|branch
,*)
2441 __gitcomp_nl
"$(git --git-dir="$
(__gitdir
)" stash list \
2442 | sed -n -e 's/:.*//p')"
2453 __git_has_doubledash
&& return
2455 local subcommands
="add status init update summary foreach sync"
2456 if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then
2459 __gitcomp
"--quiet --cached"
2462 __gitcomp
"$subcommands"
2472 init fetch clone rebase dcommit log find-rev
2473 set-tree commit-diff info create-ignore propget
2474 proplist show-ignore show-externals branch tag blame
2475 migrate mkdirs reset gc
2477 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
2478 if [ -z "$subcommand" ]; then
2479 __gitcomp
"$subcommands"
2481 local remote_opts
="--username= --config-dir= --no-auth-cache"
2483 --follow-parent --authors-file= --repack=
2484 --no-metadata --use-svm-props --use-svnsync-props
2485 --log-window-size= --no-checkout --quiet
2486 --repack-flags --use-log-author --localtime
2487 --ignore-paths= $remote_opts
2490 --template= --shared= --trunk= --tags=
2491 --branches= --stdlayout --minimize-url
2492 --no-metadata --use-svm-props --use-svnsync-props
2493 --rewrite-root= --prefix= --use-log-author
2494 --add-author-from $remote_opts
2497 --edit --rmdir --find-copies-harder --copy-similarity=
2500 case "$subcommand,$cur" in
2502 __gitcomp
"--revision= --fetch-all $fc_opts"
2505 __gitcomp
"--revision= $fc_opts $init_opts"
2508 __gitcomp
"$init_opts"
2512 --merge --strategy= --verbose --dry-run
2513 --fetch-all --no-rebase --commit-url
2514 --revision --interactive $cmt_opts $fc_opts
2518 __gitcomp
"--stdin $cmt_opts $fc_opts"
2520 create-ignore
,--*|propget
,--*|proplist
,--*|show-ignore
,--*|\
2521 show-externals
,--*|mkdirs
,--*)
2522 __gitcomp
"--revision="
2526 --limit= --revision= --verbose --incremental
2527 --oneline --show-commit --non-recursive
2528 --authors-file= --color
2533 --merge --verbose --strategy= --local
2534 --fetch-all --dry-run $fc_opts
2538 __gitcomp
"--message= --file= --revision= $cmt_opts"
2544 __gitcomp
"--dry-run --message --tag"
2547 __gitcomp
"--dry-run --message"
2550 __gitcomp
"--git-format"
2554 --config-dir= --ignore-paths= --minimize
2555 --no-auth-cache --username=
2559 __gitcomp
"--revision= --parent"
2571 while [ $c -lt $cword ]; do
2575 __gitcomp_nl
"$(__git_tags)"
2591 __gitcomp_nl
"$(__git_tags)"
2597 __gitcomp_nl
"$(__git_refs)"
2609 local i c
=1 command __git_dir
2611 while [ $c -lt $cword ]; do
2614 --git-dir=*) __git_dir
="${i#--git-dir=}" ;;
2615 --bare) __git_dir
="." ;;
2616 --help) command="help"; break ;;
2619 *) command="$i"; break ;;
2624 if [ -z "$command" ]; then
2638 --no-replace-objects
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 __git_has_doubledash
&& return
2662 local g
="$(__gitdir)"
2664 if [ -f "$g/MERGE_HEAD" ]; then
2670 $__git_log_common_options
2671 $__git_log_gitk_options
2677 __git_complete_revlist
2682 if [[ -n ${ZSH_VERSION-} ]]; then
2686 # workaround zsh's bug that leaves 'words' as a special
2687 # variable in versions < 4.3.12
2690 # workaround zsh's bug that quotes spaces in the COMPREPLY
2691 # array if IFS doesn't contain spaces.
2694 local cur words cword prev
2695 _get_comp_words_by_ref
-n =: cur words cword prev
2699 # Setup completion for certain functions defined above by setting common
2700 # variables and workarounds.
2701 # This is NOT a public function; use at your own risk.
2704 local wrapper
="__git_wrap${2}"
2705 eval "$wrapper () { __git_func_wrap $2 ; }"
2706 complete
-o bashdefault
-o default
-o nospace
-F $wrapper $1 2>/dev
/null \
2707 || complete
-o default
-o nospace
-F $wrapper $1
2710 # wrapper for backwards compatibility
2716 # wrapper for backwards compatibility
2719 __git_wrap_main_gitk
2722 __git_complete git _main_git
2723 __git_complete gitk _main_gitk
2725 # The following are necessary only for Cygwin, and only are needed
2726 # when the user has tab-completed the executable name and consequently
2727 # included the '.exe' suffix.
2729 if [ Cygwin
= "$(uname -o 2>/dev/null)" ]; then
2730 __git_complete git.exe _main_git