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
66 # *) Read Documentation/SubmittingPatches
67 # *) Send all patches to the current maintainer:
69 # "Shawn O. Pearce" <spearce@spearce.org>
71 # *) Always CC the Git mailing list:
76 if [[ -n ${ZSH_VERSION-} ]]; then
77 autoload
-U +X bashcompinit
&& bashcompinit
80 case "$COMP_WORDBREAKS" in
82 *) COMP_WORDBREAKS
="$COMP_WORDBREAKS:"
85 # __gitdir accepts 0 or 1 arguments (i.e., location)
86 # returns location of .git repo
89 if [ -z "${1-}" ]; then
90 if [ -n "${__git_dir-}" ]; then
92 elif [ -d .git
]; then
95 git rev-parse
--git-dir 2>/dev
/null
97 elif [ -d "$1/.git" ]; then
104 # stores the divergence from upstream in $p
105 # used by GIT_PS1_SHOWUPSTREAM
106 __git_ps1_show_upstream
()
109 local svn_remote
=() svn_url_pattern count n
110 local upstream
=git legacy
="" verbose
=""
112 # get some config options from git-config
113 while read key value
; do
116 GIT_PS1_SHOWUPSTREAM
="$value"
117 if [[ -z "${GIT_PS1_SHOWUPSTREAM}" ]]; then
123 svn_remote
[ $
((${#svn_remote[@]} + 1)) ]="$value"
124 svn_url_pattern
+="\\|$value"
125 upstream
=svn
+git
# default upstream is SVN if available, else git
128 done < <(git config
-z --get-regexp '^(svn-remote\..*\.url|bash\.showupstream)$' 2>/dev
/null |
tr '\0\n' '\n ')
130 # parse configuration values
131 for option
in ${GIT_PS1_SHOWUPSTREAM}; do
133 git|svn
) upstream
="$option" ;;
134 verbose
) verbose
=1 ;;
141 git
) upstream
="@{upstream}" ;;
143 # get the upstream from the "git-svn-id: ..." in a commit message
144 # (git-svn uses essentially the same procedure internally)
145 local svn_upstream
=($
(git log
--first-parent -1 \
146 --grep="^git-svn-id: \(${svn_url_pattern#??}\)" 2>/dev
/null
))
147 if [[ 0 -ne ${#svn_upstream[@]} ]]; then
148 svn_upstream
=${svn_upstream[ ${#svn_upstream[@]} - 2 ]}
149 svn_upstream
=${svn_upstream%@*}
150 local n_stop
="${#svn_remote[@]}"
151 for ((n
=1; n
<= n_stop
; ++n
)); do
152 svn_upstream
=${svn_upstream#${svn_remote[$n]}}
155 if [[ -z "$svn_upstream" ]]; then
156 # default branch name for checkouts with no layout:
157 upstream
=${GIT_SVN_ID:-git-svn}
159 upstream
=${svn_upstream#/}
161 elif [[ "svn+git" = "$upstream" ]]; then
162 upstream
="@{upstream}"
167 # Find how many commits we are ahead/behind our upstream
168 if [[ -z "$legacy" ]]; then
169 count
="$(git rev-list --count --left-right \
170 "$upstream"...HEAD 2>/dev/null)"
172 # produce equivalent output to --count for older versions of git
174 if commits
="$(git rev-list --left-right "$upstream"...HEAD 2>/dev/null)"
176 local commit behind
=0 ahead
=0
177 for commit
in $commits
186 count
="$behind $ahead"
192 # calculate the result
193 if [[ -z "$verbose" ]]; then
197 "0 0") # equal to upstream
199 "0 "*) # ahead of upstream
201 *" 0") # behind upstream
203 *) # diverged from upstream
210 "0 0") # equal to upstream
212 "0 "*) # ahead of upstream
213 p
=" u+${count#0 }" ;;
214 *" 0") # behind upstream
215 p
=" u-${count% 0}" ;;
216 *) # diverged from upstream
217 p
=" u+${count#* }-${count% *}" ;;
224 # __git_ps1 accepts 0 or 1 arguments (i.e., format string)
225 # returns text to add to bash PS1 prompt (includes branch name)
228 local g
="$(__gitdir)"
232 if [ -f "$g/rebase-merge/interactive" ]; then
234 b
="$(cat "$g/rebase-merge
/head-name
")"
235 elif [ -d "$g/rebase-merge" ]; then
237 b
="$(cat "$g/rebase-merge
/head-name
")"
239 if [ -d "$g/rebase-apply" ]; then
240 if [ -f "$g/rebase-apply/rebasing" ]; then
242 elif [ -f "$g/rebase-apply/applying" ]; then
247 elif [ -f "$g/MERGE_HEAD" ]; then
249 elif [ -f "$g/CHERRY_PICK_HEAD" ]; then
251 elif [ -f "$g/BISECT_LOG" ]; then
255 b
="$(git symbolic-ref HEAD 2>/dev/null)" ||
{
258 case "${GIT_PS1_DESCRIBE_STYLE-}" in
260 git describe --contains HEAD ;;
262 git describe --contains --all HEAD ;;
266 git describe --tags --exact-match HEAD ;;
267 esac 2>/dev/null)" ||
269 b
="$(cut -c1-7 "$g/HEAD
" 2>/dev/null)..." ||
282 if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then
283 if [ "true" = "$(git rev-parse --is-bare-repository 2>/dev/null)" ]; then
288 elif [ "true" = "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
289 if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ]; then
290 if [ "$(git config --bool bash.showDirtyState)" != "false" ]; then
291 git
diff --no-ext-diff --quiet --exit-code || w
="*"
292 if git rev-parse
--quiet --verify HEAD
>/dev
/null
; then
293 git diff-index
--cached --quiet HEAD
-- || i
="+"
299 if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ]; then
300 git rev-parse
--verify refs
/stash
>/dev
/null
2>&1 && s
="$"
303 if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ]; then
304 if [ -n "$(git ls-files --others --exclude-standard)" ]; then
309 if [ -n "${GIT_PS1_SHOWUPSTREAM-}" ]; then
310 __git_ps1_show_upstream
315 printf "${1:- (%s)}" "$c${b##refs/heads/}${f:+ $f}$r$p"
319 # __gitcomp_1 requires 2 arguments
322 local c IFS
=' '$
'\t'$
'\n'
325 --*=*) printf %s$
'\n' "$c$2" ;;
326 *.
) printf %s$
'\n' "$c$2" ;;
327 *) printf %s$
'\n' "$c$2 " ;;
332 # The following function is based on code from:
334 # bash_completion - programmable completion functions for bash 3.2+
336 # Copyright © 2006-2008, Ian Macdonald <ian@caliban.org>
337 # © 2009-2010, Bash Completion Maintainers
338 # <bash-completion-devel@lists.alioth.debian.org>
340 # This program is free software; you can redistribute it and/or modify
341 # it under the terms of the GNU General Public License as published by
342 # the Free Software Foundation; either version 2, or (at your option)
345 # This program is distributed in the hope that it will be useful,
346 # but WITHOUT ANY WARRANTY; without even the implied warranty of
347 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
348 # GNU General Public License for more details.
350 # You should have received a copy of the GNU General Public License
351 # along with this program; if not, write to the Free Software Foundation,
352 # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
354 # The latest version of this software can be obtained here:
356 # http://bash-completion.alioth.debian.org/
360 # This function can be used to access a tokenized list of words
361 # on the command line:
363 # __git_reassemble_comp_words_by_ref '=:'
364 # if test "${words_[cword_-1]}" = -w
369 # The argument should be a collection of characters from the list of
370 # word completion separators (COMP_WORDBREAKS) to treat as ordinary
373 # This is roughly equivalent to going back in time and setting
374 # COMP_WORDBREAKS to exclude those characters. The intent is to
375 # make option types like --date=<type> and <rev>:<path> easy to
376 # recognize by treating each shell word as a single token.
378 # It is best not to set COMP_WORDBREAKS directly because the value is
379 # shared with other completion scripts. By the time the completion
380 # function gets called, COMP_WORDS has already been populated so local
381 # changes to COMP_WORDBREAKS have no effect.
383 # Output: words_, cword_, cur_.
385 __git_reassemble_comp_words_by_ref
()
387 local exclude i j first
388 # Which word separators to exclude?
389 exclude
="${1//[^$COMP_WORDBREAKS]}"
391 if [ -z "$exclude" ]; then
392 words_
=("${COMP_WORDS[@]}")
395 # List of word completion separators has shrunk;
396 # re-assemble words to complete.
397 for ((i
=0, j
=0; i
< ${#COMP_WORDS[@]}; i
++, j
++)); do
398 # Append each nonempty word consisting of just
399 # word separator characters to the current word.
403 [ -n "${COMP_WORDS[$i]}" ] &&
404 # word consists of excluded word separators
405 [ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ]
407 # Attach to the previous token,
408 # unless the previous token is the command name.
409 if [ $j -ge 2 ] && [ -n "$first" ]; then
413 words_
[$j]=${words_[j]}${COMP_WORDS[i]}
414 if [ $i = $COMP_CWORD ]; then
417 if (($i < ${#COMP_WORDS[@]} - 1)); then
424 words_
[$j]=${words_[j]}${COMP_WORDS[i]}
425 if [ $i = $COMP_CWORD ]; then
431 if ! type _get_comp_words_by_ref
>/dev
/null
2>&1; then
432 if [[ -z ${ZSH_VERSION:+set} ]]; then
433 _get_comp_words_by_ref
()
435 local exclude cur_ words_ cword_
436 if [ "$1" = "-n" ]; then
440 __git_reassemble_comp_words_by_ref
"$exclude"
441 cur_
=${words_[cword_]}
442 while [ $# -gt 0 ]; do
448 prev
=${words_[$cword_-1]}
451 words
=("${words_[@]}")
461 _get_comp_words_by_ref
()
463 while [ $# -gt 0 ]; do
466 cur
=${COMP_WORDS[COMP_CWORD]}
469 prev
=${COMP_WORDS[COMP_CWORD-1]}
472 words
=("${COMP_WORDS[@]}")
478 # assume COMP_WORDBREAKS is already set sanely
488 # Generates completion reply with compgen, appending a space to possible
489 # completion words, if necessary.
490 # It accepts 1 to 4 arguments:
491 # 1: List of possible completion words.
492 # 2: A prefix to be added to each possible completion word (optional).
493 # 3: Generate possible completion matches for this word (optional).
494 # 4: A suffix to be appended to each possible completion word (optional).
499 if [ $# -gt 2 ]; then
508 COMPREPLY
=($
(compgen
-P "${2-}" \
509 -W "$(__gitcomp_1 "${1-}" "${4-}")" \
515 # __git_heads accepts 0 or 1 arguments (to pass to __gitdir)
518 local cmd i is_hash
=y dir
="$(__gitdir "${1-}")"
519 if [ -d "$dir" ]; then
520 git
--git-dir="$dir" for-each-ref
--format='%(refname:short)' \
524 for i
in $
(git ls-remote
"${1-}" 2>/dev
/null
); do
525 case "$is_hash,$i" in
528 n
,refs
/heads
/*) is_hash
=y
; echo "${i#refs/heads/}" ;;
529 n
,*) is_hash
=y
; echo "$i" ;;
534 # __git_tags accepts 0 or 1 arguments (to pass to __gitdir)
537 local cmd i is_hash
=y dir
="$(__gitdir "${1-}")"
538 if [ -d "$dir" ]; then
539 git
--git-dir="$dir" for-each-ref
--format='%(refname:short)' \
543 for i
in $
(git ls-remote
"${1-}" 2>/dev
/null
); do
544 case "$is_hash,$i" in
547 n
,refs
/tags
/*) is_hash
=y
; echo "${i#refs/tags/}" ;;
548 n
,*) is_hash
=y
; echo "$i" ;;
553 # __git_refs accepts 0, 1 (to pass to __gitdir), or 2 arguments
554 # presence of 2nd argument means use the guess heuristic employed
555 # by checkout for tracking branches
558 local i is_hash
=y dir
="$(__gitdir "${1-}")" track
="${2-}"
560 if [ -d "$dir" ]; then
568 for i
in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD
; do
569 if [ -e "$dir/$i" ]; then echo $i; fi
571 format
="refname:short"
572 refs
="refs/tags refs/heads refs/remotes"
575 git
--git-dir="$dir" for-each-ref
--format="%($format)" \
577 if [ -n "$track" ]; then
578 # employ the heuristic used by git checkout
579 # Try to find a remote branch that matches the completion word
580 # but only output if the branch name is unique
582 git
--git-dir="$dir" for-each-ref
--shell --format="ref=%(refname:short)" \
587 if [[ "$ref" == "$cur"* ]]; then
594 for i
in $
(git ls-remote
"$dir" 2>/dev
/null
); do
595 case "$is_hash,$i" in
598 n
,refs
/tags
/*) is_hash
=y
; echo "${i#refs/tags/}" ;;
599 n
,refs
/heads
/*) is_hash
=y
; echo "${i#refs/heads/}" ;;
600 n
,refs
/remotes
/*) is_hash
=y
; echo "${i#refs/remotes/}" ;;
601 n
,*) is_hash
=y
; echo "$i" ;;
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
()
618 local cmd i is_hash
=y
619 for i
in $
(git ls-remote
"$1" 2>/dev
/null
); do
620 case "$is_hash,$i" in
623 echo "$i:refs/remotes/$1/${i#refs/heads/}"
627 n
,refs
/tags
/*) is_hash
=y
;;
635 local i ngoff IFS
=$
'\n' d
="$(__gitdir)"
636 __git_shopt
-q nullglob || ngoff
=1
637 __git_shopt
-s nullglob
638 for i
in "$d/remotes"/*; do
639 echo ${i#$d/remotes/}
641 [ "$ngoff" ] && __git_shopt
-u nullglob
642 for i
in $
(git
--git-dir="$d" config
--get-regexp 'remote\..*\.url' 2>/dev
/null
); do
648 __git_list_merge_strategies
()
650 git merge
-s help 2>&1 |
651 sed -n -e '/[Aa]vailable strategies are: /,/^$/{
660 __git_merge_strategies
=
661 # 'git merge -s help' (and thus detection of the merge strategy
662 # list) fails, unfortunately, if run outside of any git working
663 # tree. __git_merge_strategies is set to the empty string in
664 # that case, and the detection will be repeated the next time it
666 __git_compute_merge_strategies
()
668 : ${__git_merge_strategies:=$(__git_list_merge_strategies)}
671 __git_complete_revlist_file
()
673 local pfx
ls ref cur_
="$cur"
693 case "$COMP_WORDBREAKS" in
695 *) pfx
="$ref:$pfx" ;;
699 COMPREPLY
=($
(compgen
-P "$pfx" \
700 -W "$(git --git-dir="$
(__gitdir
)" ls-tree "$ls" \
701 | sed '/^100... blob /{
717 pfx
="${cur_%...*}..."
719 __gitcomp
"$(__git_refs)" "$pfx" "$cur_"
724 __gitcomp
"$(__git_refs)" "$pfx" "$cur_"
727 __gitcomp
"$(__git_refs)"
733 __git_complete_file
()
735 __git_complete_revlist_file
738 __git_complete_revlist
()
740 __git_complete_revlist_file
743 __git_complete_remote_or_refspec
()
745 local cur_
="$cur" cmd
="${words[1]}"
746 local i c
=2 remote
="" pfx
="" lhs
=1 no_complete_refspec
=0
747 while [ $c -lt $cword ]; do
750 --mirror) [ "$cmd" = "push" ] && no_complete_refspec
=1 ;;
753 push
) no_complete_refspec
=1 ;;
762 *) remote
="$i"; break ;;
766 if [ -z "$remote" ]; then
767 __gitcomp
"$(__git_remotes)"
770 if [ $no_complete_refspec = 1 ]; then
774 [ "$remote" = "." ] && remote
=
777 case "$COMP_WORDBREAKS" in
779 *) pfx
="${cur_%%:*}:" ;;
791 if [ $lhs = 1 ]; then
792 __gitcomp
"$(__git_refs2 "$remote")" "$pfx" "$cur_"
794 __gitcomp
"$(__git_refs)" "$pfx" "$cur_"
798 if [ $lhs = 1 ]; then
799 __gitcomp
"$(__git_refs "$remote")" "$pfx" "$cur_"
801 __gitcomp
"$(__git_refs)" "$pfx" "$cur_"
805 if [ $lhs = 1 ]; then
806 __gitcomp
"$(__git_refs)" "$pfx" "$cur_"
808 __gitcomp
"$(__git_refs "$remote")" "$pfx" "$cur_"
814 __git_complete_strategy
()
816 __git_compute_merge_strategies
819 __gitcomp
"$__git_merge_strategies"
824 __gitcomp
"$__git_merge_strategies" "" "${cur##--strategy=}"
831 __git_list_all_commands
()
834 for i
in $
(git
help -a|
egrep '^ [a-zA-Z0-9]')
837 *--*) : helper pattern
;;
844 __git_compute_all_commands
()
846 : ${__git_all_commands:=$(__git_list_all_commands)}
849 __git_list_porcelain_commands
()
852 __git_compute_all_commands
853 for i
in "help" $__git_all_commands
856 *--*) : helper pattern
;;
857 applymbox
) : ask gittus
;;
858 applypatch
) : ask gittus
;;
859 archimport
) : import
;;
860 cat-file
) : plumbing
;;
861 check-attr
) : plumbing
;;
862 check-ref-format
) : plumbing
;;
863 checkout-index
) : plumbing
;;
864 commit-tree
) : plumbing
;;
865 count-objects
) : infrequent
;;
866 cvsexportcommit
) : export;;
867 cvsimport
) : import
;;
868 cvsserver
) : daemon
;;
870 diff-files
) : plumbing
;;
871 diff-index
) : plumbing
;;
872 diff-tree
) : plumbing
;;
873 fast-import
) : import
;;
874 fast-export
) : export;;
875 fsck-objects
) : plumbing
;;
876 fetch-pack
) : plumbing
;;
877 fmt-merge-msg
) : plumbing
;;
878 for-each-ref
) : plumbing
;;
879 hash-object
) : plumbing
;;
880 http-
*) : transport
;;
881 index-pack
) : plumbing
;;
882 init-db
) : deprecated
;;
883 local-fetch
) : plumbing
;;
884 lost-found
) : infrequent
;;
885 ls-files
) : plumbing
;;
886 ls-remote
) : plumbing
;;
887 ls-tree
) : plumbing
;;
888 mailinfo
) : plumbing
;;
889 mailsplit
) : plumbing
;;
890 merge-
*) : plumbing
;;
893 pack-objects
) : plumbing
;;
894 pack-redundant
) : plumbing
;;
895 pack-refs
) : plumbing
;;
896 parse-remote
) : plumbing
;;
897 patch-id
) : plumbing
;;
898 peek-remote
) : plumbing
;;
900 prune-packed
) : plumbing
;;
901 quiltimport
) : import
;;
902 read-tree
) : plumbing
;;
903 receive-pack
) : plumbing
;;
904 remote-
*) : transport
;;
905 repo-config
) : deprecated
;;
907 rev-list
) : plumbing
;;
908 rev-parse
) : plumbing
;;
909 runstatus
) : plumbing
;;
910 sh-setup
) : internal
;;
912 show-ref
) : plumbing
;;
913 send-pack
) : plumbing
;;
914 show-index
) : plumbing
;;
916 stripspace
) : plumbing
;;
917 symbolic-ref
) : plumbing
;;
918 tar-tree
) : deprecated
;;
919 unpack-file
) : plumbing
;;
920 unpack-objects
) : plumbing
;;
921 update-index
) : plumbing
;;
922 update-ref
) : plumbing
;;
923 update-server-info
) : daemon
;;
924 upload-archive
) : plumbing
;;
925 upload-pack
) : plumbing
;;
926 write-tree
) : plumbing
;;
928 verify-pack
) : infrequent
;;
929 verify-tag
) : plumbing
;;
935 __git_porcelain_commands
=
936 __git_compute_porcelain_commands
()
938 __git_compute_all_commands
939 : ${__git_porcelain_commands:=$(__git_list_porcelain_commands)}
942 __git_pretty_aliases
()
945 for i
in $
(git
--git-dir="$(__gitdir)" config
--get-regexp "pretty\..*" 2>/dev
/null
); do
958 for i
in $
(git
--git-dir="$(__gitdir)" config
--get-regexp "alias\..*" 2>/dev
/null
); do
968 # __git_aliased_command requires 1 argument
969 __git_aliased_command
()
971 local word cmdline
=$
(git
--git-dir="$(__gitdir)" \
972 config
--get "alias.$1")
973 for word
in $cmdline; do
979 \
!*) : shell
command alias ;;
981 *=*) : setting env
;;
990 # __git_find_on_cmdline requires 1 argument
991 __git_find_on_cmdline
()
993 local word subcommand c
=1
994 while [ $c -lt $cword ]; do
996 for subcommand
in $1; do
997 if [ "$subcommand" = "$word" ]; then
1006 __git_has_doubledash
()
1009 while [ $c -lt $cword ]; do
1010 if [ "--" = "${words[c]}" ]; then
1018 __git_whitespacelist
="nowarn warn error error-all fix"
1022 local dir
="$(__gitdir)"
1023 if [ -d "$dir"/rebase-apply
]; then
1024 __gitcomp
"--skip --continue --resolved --abort"
1029 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
1034 --3way --committer-date-is-author-date --ignore-date
1035 --ignore-whitespace --ignore-space-change
1036 --interactive --keep --no-utf8 --signoff --utf8
1037 --whitespace= --scissors
1048 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
1053 --stat --numstat --summary --check --index
1054 --cached --index-info --reverse --reject --unidiff-zero
1055 --apply --no-add --exclude=
1056 --ignore-whitespace --ignore-space-change
1057 --whitespace= --inaccurate-eof --verbose
1066 __git_has_doubledash
&& return
1071 --interactive --refresh --patch --update --dry-run
1072 --ignore-errors --intent-to-add
1083 __gitcomp
"$(git archive --list)" "" "${cur##--format=}"
1087 __gitcomp
"$(__git_remotes)" "" "${cur##--remote=}"
1092 --format= --list --verbose
1093 --prefix= --remote= --exec=
1103 __git_has_doubledash
&& return
1105 local subcommands
="start bad good skip reset visualize replay log run"
1106 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
1107 if [ -z "$subcommand" ]; then
1108 if [ -f "$(__gitdir)"/BISECT_START
]; then
1109 __gitcomp
"$subcommands"
1111 __gitcomp
"replay start"
1116 case "$subcommand" in
1117 bad|good|
reset|skip|start
)
1118 __gitcomp
"$(__git_refs)"
1128 local i c
=1 only_local_ref
="n" has_r
="n"
1130 while [ $c -lt $cword ]; do
1133 -d|
-m) only_local_ref
="y" ;;
1142 --color --no-color --verbose --abbrev= --no-abbrev
1143 --track --no-track --contains --merged --no-merged
1148 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
1149 __gitcomp
"$(__git_heads)"
1151 __gitcomp
"$(__git_refs)"
1159 local cmd
="${words[2]}"
1162 __gitcomp
"create list-heads verify unbundle"
1165 # looking for a file
1170 __git_complete_revlist
1179 __git_has_doubledash
&& return
1183 __gitcomp
"diff3 merge" "" "${cur##--conflict=}"
1187 --quiet --ours --theirs --track --no-track --merge
1188 --conflict= --orphan --patch
1192 # check if --track, --no-track, or --no-guess was specified
1193 # if so, disable DWIM mode
1194 local flags
="--track --no-track --no-guess" track
=1
1195 if [ -n "$(__git_find_on_cmdline "$flags")" ]; then
1198 __gitcomp
"$(__git_refs '' $track)"
1205 __gitcomp
"$(__git_refs)"
1212 __gitcomp
"--edit --no-commit"
1215 __gitcomp
"$(__git_refs)"
1222 __git_has_doubledash
&& return
1226 __gitcomp
"--dry-run --quiet"
1259 __git_has_doubledash
&& return
1263 __gitcomp
"default strip verbatim whitespace
1264 " "" "${cur##--cleanup=}"
1267 --reuse-message=*|
--reedit-message=*|\
1268 --fixup=*|
--squash=*)
1269 __gitcomp
"$(__git_refs)" "" "${cur#*=}"
1272 --untracked-files=*)
1273 __gitcomp
"all no normal" "" "${cur##--untracked-files=}"
1278 --all --author= --signoff --verify --no-verify
1279 --edit --amend --include --only --interactive
1280 --dry-run --reuse-message= --reedit-message=
1281 --reset-author --file= --message= --template=
1282 --cleanup= --untracked-files --untracked-files=
1283 --verbose --quiet --fixup= --squash=
1295 --all --tags --contains --abbrev= --candidates=
1296 --exact-match --debug --long --match --always
1300 __gitcomp
"$(__git_refs)"
1303 __git_diff_common_options
="--stat --numstat --shortstat --summary
1304 --patch-with-stat --name-only --name-status --color
1305 --no-color --color-words --no-renames --check
1306 --full-index --binary --abbrev --diff-filter=
1307 --find-copies-harder
1308 --text --ignore-space-at-eol --ignore-space-change
1309 --ignore-all-space --exit-code --quiet --ext-diff
1311 --no-prefix --src-prefix= --dst-prefix=
1312 --inter-hunk-context=
1315 --dirstat --dirstat= --dirstat-by-file
1316 --dirstat-by-file= --cumulative
1321 __git_has_doubledash
&& return
1325 __gitcomp
"--cached --staged --pickaxe-all --pickaxe-regex
1326 --base --ours --theirs --no-index
1327 $__git_diff_common_options
1332 __git_complete_revlist_file
1335 __git_mergetools_common
="diffuse ecmerge emerge kdiff3 meld opendiff
1336 tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc3
1341 __git_has_doubledash
&& return
1345 __gitcomp
"$__git_mergetools_common kompare" "" "${cur##--tool=}"
1349 __gitcomp
"--cached --staged --pickaxe-all --pickaxe-regex
1350 --base --ours --theirs
1351 --no-renames --diff-filter= --find-copies-harder
1352 --relative --ignore-submodules
1360 __git_fetch_options
="
1361 --quiet --verbose --append --upload-pack --force --keep --depth=
1362 --tags --no-tags --all --prune --dry-run
1369 __gitcomp
"$__git_fetch_options"
1373 __git_complete_remote_or_refspec
1376 _git_format_patch
()
1382 " "" "${cur##--thread=}"
1387 --stdout --attach --no-attach --thread --thread=
1389 --numbered --start-number
1392 --signoff --signature --no-signature
1393 --in-reply-to= --cc=
1394 --full-index --binary
1397 --no-prefix --src-prefix= --dst-prefix=
1398 --inline --suffix= --ignore-if-in-upstream
1404 __git_complete_revlist
1412 --tags --root --unreachable --cache --no-reflogs --full
1413 --strict --verbose --lost-found
1425 __gitcomp
"--prune --aggressive"
1439 __git_has_doubledash
&& return
1445 --text --ignore-case --word-regexp --invert-match
1446 --full-name --line-number
1447 --extended-regexp --basic-regexp --fixed-strings
1449 --files-with-matches --name-only
1450 --files-without-match
1453 --and --or --not --all-match
1459 __gitcomp
"$(__git_refs)"
1466 __gitcomp
"--all --info --man --web"
1470 __git_compute_all_commands
1471 __gitcomp
"$__git_all_commands $(__git_aliases)
1472 attributes cli core-tutorial cvs-migration
1473 diffcore gitk glossary hooks ignore modules
1474 namespaces repository-layout tutorial tutorial-2
1484 false true umask group all world everybody
1485 " "" "${cur##--shared=}"
1489 __gitcomp
"--quiet --bare --template= --shared --shared="
1498 __git_has_doubledash
&& return
1502 __gitcomp
"--cached --deleted --modified --others --ignored
1503 --stage --directory --no-empty-directory --unmerged
1504 --killed --exclude= --exclude-from=
1505 --exclude-per-directory= --exclude-standard
1506 --error-unmatch --with-tree= --full-name
1507 --abbrev --ignored --exclude-per-directory
1517 __gitcomp
"$(__git_remotes)"
1525 # Options that go well for log, shortlog and gitk
1526 __git_log_common_options
="
1528 --branches --tags --remotes
1529 --first-parent --merges --no-merges
1531 --max-age= --since= --after=
1532 --min-age= --until= --before=
1533 --min-parents= --max-parents=
1534 --no-min-parents --no-max-parents
1536 # Options that go well for log and gitk (not shortlog)
1537 __git_log_gitk_options
="
1538 --dense --sparse --full-history
1539 --simplify-merges --simplify-by-decoration
1540 --left-right --notes --no-notes
1542 # Options that go well for log and shortlog (not gitk)
1543 __git_log_shortlog_options
="
1544 --author= --committer= --grep=
1548 __git_log_pretty_formats
="oneline short medium full fuller email raw format:"
1549 __git_log_date_formats
="relative iso8601 rfc2822 short local default raw"
1553 __git_has_doubledash
&& return
1555 local g
="$(git rev-parse --git-dir 2>/dev/null)"
1557 if [ -f "$g/MERGE_HEAD" ]; then
1561 --pretty=*|
--format=*)
1562 __gitcomp
"$__git_log_pretty_formats $(__git_pretty_aliases)
1567 __gitcomp
"$__git_log_date_formats" "" "${cur##--date=}"
1571 __gitcomp
"long short" "" "${cur##--decorate=}"
1576 $__git_log_common_options
1577 $__git_log_shortlog_options
1578 $__git_log_gitk_options
1579 --root --topo-order --date-order --reverse
1580 --follow --full-diff
1581 --abbrev-commit --abbrev=
1582 --relative-date --date=
1583 --pretty= --format= --oneline
1586 --decorate --decorate=
1588 --parents --children
1590 $__git_diff_common_options
1591 --pickaxe-all --pickaxe-regex
1596 __git_complete_revlist
1599 __git_merge_options
="
1600 --no-commit --no-stat --log --no-log --squash --strategy
1601 --commit --stat --no-squash --ff --no-ff --ff-only
1606 __git_complete_strategy
&& return
1610 __gitcomp
"$__git_merge_options"
1613 __gitcomp
"$(__git_refs)"
1620 __gitcomp
"$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"
1633 __gitcomp
"$(__git_refs)"
1640 __gitcomp
"--dry-run"
1649 __gitcomp
"--tags --all --stdin"
1654 local subcommands
='add append copy edit list prune remove show'
1655 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
1657 case "$subcommand,$cur" in
1662 case "${words[cword-1]}" in
1664 __gitcomp
"$(__git_refs)"
1667 __gitcomp
"$subcommands --ref"
1671 add
,--reuse-message=*|append
,--reuse-message=*|\
1672 add
,--reedit-message=*|append
,--reedit-message=*)
1673 __gitcomp
"$(__git_refs)" "" "${cur#*=}"
1676 __gitcomp
'--file= --message= --reedit-message=
1683 __gitcomp
'--dry-run --verbose'
1688 case "${words[cword-1]}" in
1692 __gitcomp
"$(__git_refs)"
1701 __git_complete_strategy
&& return
1706 --rebase --no-rebase
1707 $__git_merge_options
1708 $__git_fetch_options
1713 __git_complete_remote_or_refspec
1720 __gitcomp
"$(__git_remotes)"
1725 __gitcomp
"$(__git_remotes)" "" "${cur##--repo=}"
1730 --all --mirror --tags --dry-run --force --verbose
1731 --receive-pack= --repo= --set-upstream
1736 __git_complete_remote_or_refspec
1741 local dir
="$(__gitdir)"
1742 if [ -d "$dir"/rebase-apply
] ||
[ -d "$dir"/rebase-merge
]; then
1743 __gitcomp
"--continue --skip --abort"
1746 __git_complete_strategy
&& return
1749 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
1754 --onto --merge --strategy --interactive
1755 --preserve-merges --stat --no-stat
1756 --committer-date-is-author-date --ignore-date
1757 --ignore-whitespace --whitespace=
1763 __gitcomp
"$(__git_refs)"
1768 local subcommands
="show delete expire"
1769 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
1771 if [ -z "$subcommand" ]; then
1772 __gitcomp
"$subcommands"
1774 __gitcomp
"$(__git_refs)"
1778 __git_send_email_confirm_options
="always never auto cc compose"
1779 __git_send_email_suppresscc_options
="author self cc bodycc sob cccmd body all"
1786 $__git_send_email_confirm_options
1787 " "" "${cur##--confirm=}"
1792 $__git_send_email_suppresscc_options
1793 " "" "${cur##--suppress-cc=}"
1797 --smtp-encryption=*)
1798 __gitcomp
"ssl tls" "" "${cur##--smtp-encryption=}"
1802 __gitcomp
"--annotate --bcc --cc --cc-cmd --chain-reply-to
1803 --compose --confirm= --dry-run --envelope-sender
1805 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
1806 --no-suppress-from --no-thread --quiet
1807 --signed-off-by-cc --smtp-pass --smtp-server
1808 --smtp-server-port --smtp-encryption= --smtp-user
1809 --subject --suppress-cc= --suppress-from --thread --to
1810 --validate --no-validate"
1822 __git_config_get_set_variables
()
1824 local prevword word config_file
= c
=$cword
1825 while [ $c -gt 1 ]; do
1828 --global|
--system|
--file=*)
1833 config_file
="$word $prevword"
1841 git
--git-dir="$(__gitdir)" config
$config_file --list 2>/dev
/null |
1856 __gitcomp
"$(__git_remotes)"
1860 __gitcomp
"$(__git_refs)"
1864 local remote
="${prev#remote.}"
1865 remote
="${remote%.fetch}"
1866 __gitcomp
"$(__git_refs_remotes "$remote")"
1870 local remote
="${prev#remote.}"
1871 remote
="${remote%.push}"
1872 __gitcomp
"$(git --git-dir="$
(__gitdir
)" \
1873 for-each-ref --format='%(refname):%(refname)' \
1877 pull.twohead|pull.octopus
)
1878 __git_compute_merge_strategies
1879 __gitcomp
"$__git_merge_strategies"
1882 color.branch|color.
diff|color.interactive|\
1883 color.showbranch|color.status|color.ui
)
1884 __gitcomp
"always never auto"
1888 __gitcomp
"false true"
1893 normal black red green yellow blue magenta cyan white
1894 bold dim ul blink reverse
1899 __gitcomp
"man info web html"
1903 __gitcomp
"$__git_log_date_formats"
1906 sendemail.aliasesfiletype
)
1907 __gitcomp
"mutt mailrc pine elm gnus"
1911 __gitcomp
"$__git_send_email_confirm_options"
1914 sendemail.suppresscc
)
1915 __gitcomp
"$__git_send_email_suppresscc_options"
1918 --get|
--get-all|
--unset|
--unset-all)
1919 __gitcomp
"$(__git_config_get_set_variables)"
1930 --global --system --file=
1931 --list --replace-all
1932 --get --get-all --get-regexp
1933 --add --unset --unset-all
1934 --remove-section --rename-section
1939 local pfx
="${cur%.*}." cur_
="${cur##*.}"
1940 __gitcomp
"remote merge mergeoptions rebase" "$pfx" "$cur_"
1944 local pfx
="${cur%.*}." cur_
="${cur#*.}"
1945 __gitcomp
"$(__git_heads)" "$pfx" "$cur_" "."
1949 local pfx
="${cur%.*}." cur_
="${cur##*.}"
1951 argprompt cmd confirm needsfile noconsole norescan
1952 prompt revprompt revunmerged title
1957 local pfx
="${cur%.*}." cur_
="${cur##*.}"
1958 __gitcomp
"cmd path" "$pfx" "$cur_"
1962 local pfx
="${cur%.*}." cur_
="${cur##*.}"
1963 __gitcomp
"cmd path" "$pfx" "$cur_"
1967 local pfx
="${cur%.*}." cur_
="${cur##*.}"
1968 __gitcomp
"cmd path trustExitCode" "$pfx" "$cur_"
1972 local pfx
="${cur%.*}." cur_
="${cur#*.}"
1973 __git_compute_all_commands
1974 __gitcomp
"$__git_all_commands" "$pfx" "$cur_"
1978 local pfx
="${cur%.*}." cur_
="${cur##*.}"
1980 url proxy fetch push mirror skipDefaultUpdate
1981 receivepack uploadpack tagopt pushurl
1986 local pfx
="${cur%.*}." cur_
="${cur#*.}"
1987 __gitcomp
"$(__git_remotes)" "$pfx" "$cur_" "."
1991 local pfx
="${cur%.*}." cur_
="${cur##*.}"
1992 __gitcomp
"insteadOf pushInsteadOf" "$pfx" "$cur_"
1998 advice.commitBeforeMerge
2000 advice.implicitIdentity
2001 advice.pushNonFastForward
2002 advice.resolveConflict
2006 apply.ignorewhitespace
2008 branch.autosetupmerge
2009 branch.autosetuprebase
2013 color.branch.current
2018 color.decorate.branch
2019 color.decorate.remoteBranch
2020 color.decorate.stash
2030 color.diff.whitespace
2035 color.grep.linenumber
2038 color.grep.separator
2040 color.interactive.error
2041 color.interactive.header
2042 color.interactive.help
2043 color.interactive.prompt
2048 color.status.changed
2050 color.status.nobranch
2051 color.status.untracked
2052 color.status.updated
2061 core.bigFileThreshold
2064 core.deltaBaseCacheLimit
2069 core.fsyncobjectfiles
2071 core.ignoreCygwinFSTricks
2074 core.logAllRefUpdates
2075 core.loosecompression
2078 core.packedGitWindowSize
2080 core.preferSymlinkRefs
2083 core.repositoryFormatVersion
2085 core.sharedRepository
2089 core.warnAmbiguousRefs
2092 diff.autorefreshindex
2094 diff.ignoreSubmodules
2099 diff.suppressBlankEmpty
2104 fetch.recurseSubmodules
2113 format.subjectprefix
2124 gc.reflogexpireunreachable
2128 gitcvs.commitmsgannotation
2129 gitcvs.dbTableNamePrefix
2140 gui.copyblamethreshold
2144 gui.matchtrackingbranch
2145 gui.newbranchtemplate
2146 gui.pruneduringfetch
2147 gui.spellingdictionary
2162 http.sslCertPasswordProtected
2167 i18n.logOutputEncoding
2173 imap.preformattedHTML
2183 interactive.singlekey
2199 mergetool.keepBackup
2200 mergetool.keepTemporaries
2205 notes.rewrite.rebase
2209 pack.deltaCacheLimit
2225 receive.denyCurrentBranch
2226 receive.denyDeleteCurrent
2228 receive.denyNonFastForwards
2231 receive.updateserverinfo
2233 repack.usedeltabaseoffset
2237 sendemail.aliasesfile
2238 sendemail.aliasfiletype
2242 sendemail.chainreplyto
2244 sendemail.envelopesender
2248 sendemail.signedoffbycc
2249 sendemail.smtpdomain
2250 sendemail.smtpencryption
2252 sendemail.smtpserver
2253 sendemail.smtpserveroption
2254 sendemail.smtpserverport
2256 sendemail.suppresscc
2257 sendemail.suppressfrom
2262 status.relativePaths
2263 status.showUntrackedFiles
2264 status.submodulesummary
2267 transfer.unpackLimit
2279 local subcommands
="add rename rm show prune update set-head"
2280 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
2281 if [ -z "$subcommand" ]; then
2282 __gitcomp
"$subcommands"
2286 case "$subcommand" in
2287 rename|
rm|show|prune
)
2288 __gitcomp
"$(__git_remotes)"
2291 local i c
='' IFS
=$
'\n'
2292 for i
in $
(git
--git-dir="$(__gitdir)" config
--get-regexp "remotes\..*" 2>/dev
/null
); do
2306 __gitcomp
"$(__git_refs)"
2311 __git_has_doubledash
&& return
2315 __gitcomp
"--merge --mixed --hard --soft --patch"
2319 __gitcomp
"$(__git_refs)"
2326 __gitcomp
"--edit --mainline --no-edit --no-commit --signoff"
2330 __gitcomp
"$(__git_refs)"
2335 __git_has_doubledash
&& return
2339 __gitcomp
"--cached --dry-run --ignore-unmatch --quiet"
2348 __git_has_doubledash
&& return
2353 $__git_log_common_options
2354 $__git_log_shortlog_options
2355 --numbered --summary
2360 __git_complete_revlist
2365 __git_has_doubledash
&& return
2368 --pretty=*|
--format=*)
2369 __gitcomp
"$__git_log_pretty_formats $(__git_pretty_aliases)
2374 __gitcomp
"--pretty= --format= --abbrev-commit --oneline
2375 $__git_diff_common_options
2388 --all --remotes --topo-order --current --more=
2389 --list --independent --merge-base --no-name
2391 --sha1-name --sparse --topics --reflog
2396 __git_complete_revlist
2401 local save_opts
='--keep-index --no-keep-index --quiet --patch'
2402 local subcommands
='save list show apply clear drop pop create branch'
2403 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
2404 if [ -z "$subcommand" ]; then
2407 __gitcomp
"$save_opts"
2410 if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then
2411 __gitcomp
"$subcommands"
2418 case "$subcommand,$cur" in
2420 __gitcomp
"$save_opts"
2423 __gitcomp
"--index --quiet"
2425 show
,--*|drop
,--*|branch
,--*)
2428 show
,*|apply
,*|drop
,*|pop
,*|branch
,*)
2429 __gitcomp
"$(git --git-dir="$
(__gitdir
)" stash list \
2430 | sed -n -e 's/:.*//p')"
2441 __git_has_doubledash
&& return
2443 local subcommands
="add status init update summary foreach sync"
2444 if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then
2447 __gitcomp
"--quiet --cached"
2450 __gitcomp
"$subcommands"
2460 init fetch clone rebase dcommit log find-rev
2461 set-tree commit-diff info create-ignore propget
2462 proplist show-ignore show-externals branch tag blame
2463 migrate mkdirs reset gc
2465 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
2466 if [ -z "$subcommand" ]; then
2467 __gitcomp
"$subcommands"
2469 local remote_opts
="--username= --config-dir= --no-auth-cache"
2471 --follow-parent --authors-file= --repack=
2472 --no-metadata --use-svm-props --use-svnsync-props
2473 --log-window-size= --no-checkout --quiet
2474 --repack-flags --use-log-author --localtime
2475 --ignore-paths= $remote_opts
2478 --template= --shared= --trunk= --tags=
2479 --branches= --stdlayout --minimize-url
2480 --no-metadata --use-svm-props --use-svnsync-props
2481 --rewrite-root= --prefix= --use-log-author
2482 --add-author-from $remote_opts
2485 --edit --rmdir --find-copies-harder --copy-similarity=
2488 case "$subcommand,$cur" in
2490 __gitcomp
"--revision= --fetch-all $fc_opts"
2493 __gitcomp
"--revision= $fc_opts $init_opts"
2496 __gitcomp
"$init_opts"
2500 --merge --strategy= --verbose --dry-run
2501 --fetch-all --no-rebase --commit-url
2502 --revision $cmt_opts $fc_opts
2506 __gitcomp
"--stdin $cmt_opts $fc_opts"
2508 create-ignore
,--*|propget
,--*|proplist
,--*|show-ignore
,--*|\
2509 show-externals
,--*|mkdirs
,--*)
2510 __gitcomp
"--revision="
2514 --limit= --revision= --verbose --incremental
2515 --oneline --show-commit --non-recursive
2516 --authors-file= --color
2521 --merge --verbose --strategy= --local
2522 --fetch-all --dry-run $fc_opts
2526 __gitcomp
"--message= --file= --revision= $cmt_opts"
2532 __gitcomp
"--dry-run --message --tag"
2535 __gitcomp
"--dry-run --message"
2538 __gitcomp
"--git-format"
2542 --config-dir= --ignore-paths= --minimize
2543 --no-auth-cache --username=
2547 __gitcomp
"--revision= --parent"
2559 while [ $c -lt $cword ]; do
2563 __gitcomp
"$(__git_tags)"
2579 __gitcomp
"$(__git_tags)"
2585 __gitcomp
"$(__git_refs)"
2597 local i c
=1 command __git_dir
2599 if [[ -n ${ZSH_VERSION-} ]]; then
2603 # workaround zsh's bug that leaves 'words' as a special
2604 # variable in versions < 4.3.12
2608 local cur words cword prev
2609 _get_comp_words_by_ref
-n =: cur words cword prev
2610 while [ $c -lt $cword ]; do
2613 --git-dir=*) __git_dir
="${i#--git-dir=}" ;;
2614 --bare) __git_dir
="." ;;
2615 --version|
-p|
--paginate) ;;
2616 --help) command="help"; break ;;
2617 *) command="$i"; break ;;
2622 if [ -z "$command" ]; then
2637 *) __git_compute_porcelain_commands
2638 __gitcomp
"$__git_porcelain_commands $(__git_aliases)" ;;
2643 local completion_func
="_git_${command//-/_}"
2644 declare -f $completion_func >/dev
/null
&& $completion_func && return
2646 local expansion
=$
(__git_aliased_command
"$command")
2647 if [ -n "$expansion" ]; then
2648 completion_func
="_git_${expansion//-/_}"
2649 declare -f $completion_func >/dev
/null
&& $completion_func
2655 if [[ -n ${ZSH_VERSION-} ]]; then
2659 # workaround zsh's bug that leaves 'words' as a special
2660 # variable in versions < 4.3.12
2664 local cur words cword prev
2665 _get_comp_words_by_ref
-n =: cur words cword prev
2667 __git_has_doubledash
&& return
2669 local g
="$(__gitdir)"
2671 if [ -f "$g/MERGE_HEAD" ]; then
2677 $__git_log_common_options
2678 $__git_log_gitk_options
2684 __git_complete_revlist
2687 complete
-o bashdefault
-o default
-o nospace
-F _git git
2>/dev
/null \
2688 || complete
-o default
-o nospace
-F _git git
2689 complete
-o bashdefault
-o default
-o nospace
-F _gitk gitk
2>/dev
/null \
2690 || complete
-o default
-o nospace
-F _gitk gitk
2692 # The following are necessary only for Cygwin, and only are needed
2693 # when the user has tab-completed the executable name and consequently
2694 # included the '.exe' suffix.
2696 if [ Cygwin
= "$(uname -o 2>/dev/null)" ]; then
2697 complete
-o bashdefault
-o default
-o nospace
-F _git git.exe
2>/dev
/null \
2698 || complete
-o default
-o nospace
-F _git git.exe
2701 if [[ -n ${ZSH_VERSION-} ]]; then
2704 if [ $# -ne 2 ]; then
2705 echo "USAGE: $0 (-q|-s|-u) <option>" >&2
2713 echo "$0: invalid option: $2" >&2
2717 -q) setopt |
grep -q "$option" ;;
2718 -u) unsetopt
"$option" ;;
2719 -s) setopt
"$option" ;;
2721 echo "$0: invalid flag: $1" >&2