1 # bash/zsh completion support for core Git.
3 # Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
4 # Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
5 # Distributed under the GNU General Public License, version 2.0.
7 # The contained completion routines provide support for completing:
9 # *) local and remote branch names
10 # *) local and remote tag names
11 # *) .git/remotes file names
12 # *) git 'subcommands'
13 # *) git email aliases for git-send-email
14 # *) tree paths within 'ref:path/to/file' expressions
15 # *) file paths within current working directory and index
16 # *) common --long-options
18 # To use these routines:
20 # 1) Copy this file to somewhere (e.g. ~/.git-completion.bash).
21 # 2) Add the following line to your .bashrc/.zshrc:
22 # source ~/.git-completion.bash
23 # 3) Consider changing your PS1 to also show the current branch,
24 # see git-prompt.sh for details.
26 # If you use complex aliases of form '!f() { ... }; f', you can use the null
27 # command ':' as the first command in the function body to declare the desired
28 # completion style. For example '!f() { : git commit ; ... }; f' will
29 # tell the completion to use commit completion. This also works with aliases
30 # of form "!sh -c '...'". For example, "!sh -c ': git commit ; ... '".
32 case "$COMP_WORDBREAKS" in
34 *) COMP_WORDBREAKS
="$COMP_WORDBREAKS:"
37 # Discovers the path to the git repository taking any '--git-dir=<path>' and
38 # '-C <path>' options into account and stores it in the $__git_repo_path
40 __git_find_repo_path
()
42 if [ -n "$__git_repo_path" ]; then
43 # we already know where it is
47 if [ -n "${__git_C_args-}" ]; then
48 __git_repo_path
="$(git "${__git_C_args[@]}" \
49 ${__git_dir:+--git-dir="$__git_dir"} \
50 rev-parse --absolute-git-dir 2>/dev/null)"
51 elif [ -n "${__git_dir-}" ]; then
52 test -d "$__git_dir" &&
53 __git_repo_path
="$__git_dir"
54 elif [ -n "${GIT_DIR-}" ]; then
55 test -d "${GIT_DIR-}" &&
56 __git_repo_path
="$GIT_DIR"
57 elif [ -d .git
]; then
60 __git_repo_path
="$(git rev-parse --git-dir 2>/dev/null)"
64 # Deprecated: use __git_find_repo_path() and $__git_repo_path instead
65 # __gitdir accepts 0 or 1 arguments (i.e., location)
66 # returns location of .git repo
69 if [ -z "${1-}" ]; then
70 __git_find_repo_path ||
return 1
71 echo "$__git_repo_path"
72 elif [ -d "$1/.git" ]; then
79 # Runs git with all the options given as argument, respecting any
80 # '--git-dir=<path>' and '-C <path>' options present on the command line
83 git
${__git_C_args:+"${__git_C_args[@]}"} \
84 ${__git_dir:+--git-dir="$__git_dir"} "$@" 2>/dev
/null
87 # The following function is based on code from:
89 # bash_completion - programmable completion functions for bash 3.2+
91 # Copyright © 2006-2008, Ian Macdonald <ian@caliban.org>
92 # © 2009-2010, Bash Completion Maintainers
93 # <bash-completion-devel@lists.alioth.debian.org>
95 # This program is free software; you can redistribute it and/or modify
96 # it under the terms of the GNU General Public License as published by
97 # the Free Software Foundation; either version 2, or (at your option)
100 # This program is distributed in the hope that it will be useful,
101 # but WITHOUT ANY WARRANTY; without even the implied warranty of
102 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
103 # GNU General Public License for more details.
105 # You should have received a copy of the GNU General Public License
106 # along with this program; if not, write to the Free Software Foundation,
107 # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
109 # The latest version of this software can be obtained here:
111 # http://bash-completion.alioth.debian.org/
115 # This function can be used to access a tokenized list of words
116 # on the command line:
118 # __git_reassemble_comp_words_by_ref '=:'
119 # if test "${words_[cword_-1]}" = -w
124 # The argument should be a collection of characters from the list of
125 # word completion separators (COMP_WORDBREAKS) to treat as ordinary
128 # This is roughly equivalent to going back in time and setting
129 # COMP_WORDBREAKS to exclude those characters. The intent is to
130 # make option types like --date=<type> and <rev>:<path> easy to
131 # recognize by treating each shell word as a single token.
133 # It is best not to set COMP_WORDBREAKS directly because the value is
134 # shared with other completion scripts. By the time the completion
135 # function gets called, COMP_WORDS has already been populated so local
136 # changes to COMP_WORDBREAKS have no effect.
138 # Output: words_, cword_, cur_.
140 __git_reassemble_comp_words_by_ref
()
142 local exclude i j first
143 # Which word separators to exclude?
144 exclude
="${1//[^$COMP_WORDBREAKS]}"
146 if [ -z "$exclude" ]; then
147 words_
=("${COMP_WORDS[@]}")
150 # List of word completion separators has shrunk;
151 # re-assemble words to complete.
152 for ((i
=0, j
=0; i
< ${#COMP_WORDS[@]}; i
++, j
++)); do
153 # Append each nonempty word consisting of just
154 # word separator characters to the current word.
158 [ -n "${COMP_WORDS[$i]}" ] &&
159 # word consists of excluded word separators
160 [ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ]
162 # Attach to the previous token,
163 # unless the previous token is the command name.
164 if [ $j -ge 2 ] && [ -n "$first" ]; then
168 words_
[$j]=${words_[j]}${COMP_WORDS[i]}
169 if [ $i = $COMP_CWORD ]; then
172 if (($i < ${#COMP_WORDS[@]} - 1)); then
179 words_
[$j]=${words_[j]}${COMP_WORDS[i]}
180 if [ $i = $COMP_CWORD ]; then
186 if ! type _get_comp_words_by_ref
>/dev
/null
2>&1; then
187 _get_comp_words_by_ref
()
189 local exclude cur_ words_ cword_
190 if [ "$1" = "-n" ]; then
194 __git_reassemble_comp_words_by_ref
"$exclude"
195 cur_
=${words_[cword_]}
196 while [ $# -gt 0 ]; do
202 prev
=${words_[$cword_-1]}
205 words
=("${words_[@]}")
218 local x i
=${#COMPREPLY[@]}
220 if [[ "$x" == "$3"* ]]; then
221 COMPREPLY
[i
++]="$2$x$4"
232 # Generates completion reply, appending a space to possible completion words,
234 # It accepts 1 to 4 arguments:
235 # 1: List of possible completion words.
236 # 2: A prefix to be added to each possible completion word (optional).
237 # 3: Generate possible completion matches for this word (optional).
238 # 4: A suffix to be appended to each possible completion word (optional).
241 local cur_
="${3-$cur}"
247 local c i
=0 IFS
=$
' \t\n'
250 if [[ $c == "$cur_"* ]]; then
255 COMPREPLY
[i
++]="${2-}$c"
262 # Variation of __gitcomp_nl () that appends to the existing list of
263 # completion candidates, COMPREPLY.
264 __gitcomp_nl_append
()
267 __gitcompappend
"$1" "${2-}" "${3-$cur}" "${4- }"
270 # Generates completion reply from newline-separated possible completion words
271 # by appending a space to all of them.
272 # It accepts 1 to 4 arguments:
273 # 1: List of possible completion words, separated by a single newline.
274 # 2: A prefix to be added to each possible completion word (optional).
275 # 3: Generate possible completion matches for this word (optional).
276 # 4: A suffix to be appended to each possible completion word instead of
277 # the default space (optional). If specified but empty, nothing is
282 __gitcomp_nl_append
"$@"
285 # Generates completion reply with compgen from newline-separated possible
286 # completion filenames.
287 # It accepts 1 to 3 arguments:
288 # 1: List of possible completion filenames, separated by a single newline.
289 # 2: A directory prefix to be added to each possible completion filename
291 # 3: Generate possible completion matches for this word (optional).
296 # XXX does not work when the directory prefix contains a tilde,
297 # since tilde expansion is not applied.
298 # This means that COMPREPLY will be empty and Bash default
299 # completion will be used.
300 __gitcompadd
"$1" "${2-}" "${3-$cur}" ""
302 # use a hack to enable file mode in bash < 4
303 compopt
-o filenames
+o nospace
2>/dev
/null ||
304 compgen
-f /non-existing-dir
/ > /dev
/null
307 # Execute 'git ls-files', unless the --committable option is specified, in
308 # which case it runs 'git diff-index' to find out the files that can be
309 # committed. It return paths relative to the directory specified in the first
310 # argument, and using the options specified in the second argument.
311 __git_ls_files_helper
()
313 if [ "$2" == "--committable" ]; then
314 __git
-C "$1" diff-index
--name-only --relative HEAD
316 # NOTE: $2 is not quoted in order to support multiple options
317 __git
-C "$1" ls-files
--exclude-standard $2
322 # __git_index_files accepts 1 or 2 arguments:
323 # 1: Options to pass to ls-files (required).
324 # 2: A directory path (optional).
325 # If provided, only files within the specified directory are listed.
326 # Sub directories are never recursed. Path must have a trailing
330 local root
="${2-.}" file
332 __git_ls_files_helper
"$root" "$1" |
333 while read -r file; do
335 ?
*/*) echo "${file%%/*}" ;;
343 __git for-each-ref
--format='%(refname:short)' refs
/heads
348 __git for-each-ref
--format='%(refname:short)' refs
/tags
351 # Lists refs from the local (by default) or from a remote repository.
352 # It accepts 0, 1 or 2 arguments:
353 # 1: The remote to list refs from (optional; ignored, if set but empty).
354 # Can be the name of a configured remote, a path, or a URL.
355 # 2: In addition to local refs, list unique branches from refs/remotes/ for
356 # 'git checkout's tracking DWIMery (optional; ignored, if set but empty).
357 # 3: Currently ignored.
358 # 4: The current ref to be completed (optional).
360 # Use __git_complete_refs() instead.
363 local i
hash dir track
="${2-}"
364 local list_refs_from
=path remote
="${1-}"
365 local format refs pfx
366 local cur_
="${4-$cur}"
369 dir
="$__git_repo_path"
371 if [ -z "$remote" ]; then
372 if [ -z "$dir" ]; then
376 if __git_is_configured_remote
"$remote"; then
377 # configured remote takes precedence over a
378 # local directory with the same name
379 list_refs_from
=remote
380 elif [ -d "$remote/.git" ]; then
382 elif [ -d "$remote" ]; then
389 if [ "$list_refs_from" = path
]; then
390 if [[ "$cur_" == ^
* ]]; then
401 for i
in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD
; do
402 if [ -e "$dir/$i" ]; then echo $pfx$i; fi
404 format
="refname:short"
405 refs
="refs/tags refs/heads refs/remotes"
408 __git_dir
="$dir" __git for-each-ref
--format="$pfx%($format)" \
410 if [ -n "$track" ]; then
411 # employ the heuristic used by git checkout
412 # Try to find a remote branch that matches the completion word
413 # but only output if the branch name is unique
415 __git for-each-ref
--shell --format="ref=%(refname:short)" \
417 while read -r entry
; do
420 if [[ "$ref" == "$cur_"* ]]; then
423 done |
sort |
uniq -u
429 __git ls-remote
"$remote" "$cur_*" | \
430 while read -r hash i
; do
438 if [ "$list_refs_from" = remote
]; then
440 __git for-each-ref
--format="%(refname:short)" \
441 "refs/remotes/$remote/" |
sed -e "s#^$remote/##"
443 __git ls-remote
"$remote" HEAD \
444 "refs/tags/*" "refs/heads/*" "refs/remotes/*" |
445 while read -r hash i
; do
448 refs
/*) echo "${i#refs/*/}" ;;
449 *) echo "$i" ;; # symbolic refs
457 # Completes refs, short and long, local and remote, symbolic and pseudo.
459 # Usage: __git_complete_refs [<option>]...
460 # --remote=<remote>: The remote to list refs from, can be the name of a
461 # configured remote, a path, or a URL.
462 # --track: List unique remote branches for 'git checkout's tracking DWIMery.
463 # --pfx=<prefix>: A prefix to be added to each ref.
464 # --cur=<word>: The current ref to be completed. Defaults to the current
465 # word to be completed.
466 # --sfx=<suffix>: A suffix to be appended to each ref instead of the default
468 __git_complete_refs
()
470 local remote track pfx cur_
="$cur" sfx
=" "
472 while test $# != 0; do
474 --remote=*) remote
="${1##--remote=}" ;;
475 --track) track
="yes" ;;
476 --pfx=*) pfx
="${1##--pfx=}" ;;
477 --cur=*) cur_
="${1##--cur=}" ;;
478 --sfx=*) sfx
="${1##--sfx=}" ;;
484 __gitcomp_nl
"$(__git_refs "$remote" "$track" "" "$cur_")" \
485 "$pfx" "$cur_" "$sfx"
488 # __git_refs2 requires 1 argument (to pass to __git_refs)
489 # Deprecated: use __git_complete_fetch_refspecs() instead.
493 for i
in $
(__git_refs
"$1"); do
498 # Completes refspecs for fetching from a remote repository.
499 # 1: The remote repository.
500 # 2: A prefix to be added to each listed refspec (optional).
501 # 3: The ref to be completed as a refspec instead of the current word to be
502 # completed (optional)
503 # 4: A suffix to be appended to each listed refspec instead of the default
505 __git_complete_fetch_refspecs
()
507 local i remote
="$1" pfx
="${2-}" cur_="${3-$cur}" sfx="${4- }"
510 for i in $(__git_refs "$remote" "" "" "$cur_") ; do
513 )" "$pfx" "$cur_" "$sfx"
516 # __git_refs_remotes requires 1 argument (to pass to ls-remote)
517 __git_refs_remotes
()
520 __git ls-remote
"$1" 'refs/heads/*' | \
521 while read -r hash i
; do
522 echo "$i:refs/remotes/$1/${i#refs/heads/}"
529 test -d "$__git_repo_path/remotes" && ls -1 "$__git_repo_path/remotes"
533 # Returns true if $1 matches the name of a configured remote, false otherwise.
534 __git_is_configured_remote
()
537 for remote
in $
(__git_remotes
); do
538 if [ "$remote" = "$1" ]; then
545 __git_list_merge_strategies
()
547 git merge
-s help 2>&1 |
548 sed -n -e '/[Aa]vailable strategies are: /,/^$/{
557 __git_merge_strategies
=
558 # 'git merge -s help' (and thus detection of the merge strategy
559 # list) fails, unfortunately, if run outside of any git working
560 # tree. __git_merge_strategies is set to the empty string in
561 # that case, and the detection will be repeated the next time it
563 __git_compute_merge_strategies
()
565 test -n "$__git_merge_strategies" ||
566 __git_merge_strategies
=$
(__git_list_merge_strategies
)
569 __git_complete_revlist_file
()
571 local pfx
ls ref cur_
="$cur"
591 case "$COMP_WORDBREAKS" in
593 *) pfx
="$ref:$pfx" ;;
596 __gitcomp_nl
"$(__git ls-tree "$ls" \
597 | sed '/^100... blob /{
613 pfx
="${cur_%...*}..."
615 __git_complete_refs
--pfx="$pfx" --cur="$cur_"
620 __git_complete_refs
--pfx="$pfx" --cur="$cur_"
629 # __git_complete_index_file requires 1 argument:
630 # 1: the options to pass to ls-file
632 # The exception is --committable, which finds the files appropriate commit.
633 __git_complete_index_file
()
635 local pfx
="" cur_
="$cur"
645 __gitcomp_file
"$(__git_index_files "$1" ${pfx:+"$pfx"})" "$pfx" "$cur_"
648 __git_complete_file
()
650 __git_complete_revlist_file
653 __git_complete_revlist
()
655 __git_complete_revlist_file
658 __git_complete_remote_or_refspec
()
660 local cur_
="$cur" cmd
="${words[1]}"
661 local i c
=2 remote
="" pfx
="" lhs
=1 no_complete_refspec
=0
662 if [ "$cmd" = "remote" ]; then
665 while [ $c -lt $cword ]; do
668 --mirror) [ "$cmd" = "push" ] && no_complete_refspec
=1 ;;
671 push
) no_complete_refspec
=1 ;;
679 *) remote
="$i"; break ;;
683 if [ -z "$remote" ]; then
684 __gitcomp_nl
"$(__git_remotes)"
687 if [ $no_complete_refspec = 1 ]; then
690 [ "$remote" = "." ] && remote
=
693 case "$COMP_WORDBREAKS" in
695 *) pfx
="${cur_%%:*}:" ;;
707 if [ $lhs = 1 ]; then
708 __git_complete_fetch_refspecs
"$remote" "$pfx" "$cur_"
710 __git_complete_refs
--pfx="$pfx" --cur="$cur_"
714 if [ $lhs = 1 ]; then
715 __git_complete_refs
--remote="$remote" --pfx="$pfx" --cur="$cur_"
717 __git_complete_refs
--pfx="$pfx" --cur="$cur_"
721 if [ $lhs = 1 ]; then
722 __git_complete_refs
--pfx="$pfx" --cur="$cur_"
724 __git_complete_refs
--remote="$remote" --pfx="$pfx" --cur="$cur_"
730 __git_complete_strategy
()
732 __git_compute_merge_strategies
735 __gitcomp
"$__git_merge_strategies"
740 __gitcomp
"$__git_merge_strategies" "" "${cur##--strategy=}"
748 if test -n "${GIT_TESTING_COMMAND_COMPLETION:-}"
750 printf "%s" "${GIT_TESTING_COMMAND_COMPLETION}"
752 git
help -a|
egrep '^ [a-zA-Z0-9]'
756 __git_list_all_commands
()
759 for i
in $
(__git_commands
)
762 *--*) : helper pattern
;;
769 __git_compute_all_commands
()
771 test -n "$__git_all_commands" ||
772 __git_all_commands
=$
(__git_list_all_commands
)
775 __git_list_porcelain_commands
()
778 __git_compute_all_commands
779 for i
in $__git_all_commands
782 *--*) : helper pattern
;;
783 applymbox
) : ask gittus
;;
784 applypatch
) : ask gittus
;;
785 archimport
) : import
;;
786 cat-file
) : plumbing
;;
787 check-attr
) : plumbing
;;
788 check-ignore
) : plumbing
;;
789 check-mailmap
) : plumbing
;;
790 check-ref-format
) : plumbing
;;
791 checkout-index
) : plumbing
;;
792 column) : internal helper
;;
793 commit-tree
) : plumbing
;;
794 count-objects
) : infrequent
;;
795 credential
) : credentials
;;
796 credential-
*) : credentials helper
;;
797 cvsexportcommit
) : export;;
798 cvsimport
) : import
;;
799 cvsserver
) : daemon
;;
801 diff-files
) : plumbing
;;
802 diff-index
) : plumbing
;;
803 diff-tree
) : plumbing
;;
804 fast-import
) : import
;;
805 fast-export
) : export;;
806 fsck-objects
) : plumbing
;;
807 fetch-pack
) : plumbing
;;
808 fmt-merge-msg
) : plumbing
;;
809 for-each-ref
) : plumbing
;;
810 hash-object
) : plumbing
;;
811 http-
*) : transport
;;
812 index-pack
) : plumbing
;;
813 init-db
) : deprecated
;;
814 local-fetch
) : plumbing
;;
815 ls-files
) : plumbing
;;
816 ls-remote
) : plumbing
;;
817 ls-tree
) : plumbing
;;
818 mailinfo
) : plumbing
;;
819 mailsplit
) : plumbing
;;
820 merge-
*) : plumbing
;;
823 pack-objects
) : plumbing
;;
824 pack-redundant
) : plumbing
;;
825 pack-refs
) : plumbing
;;
826 parse-remote
) : plumbing
;;
827 patch-id
) : plumbing
;;
829 prune-packed
) : plumbing
;;
830 quiltimport
) : import
;;
831 read-tree
) : plumbing
;;
832 receive-pack
) : plumbing
;;
833 remote-
*) : transport
;;
835 rev-list
) : plumbing
;;
836 rev-parse
) : plumbing
;;
837 runstatus
) : plumbing
;;
838 sh-setup
) : internal
;;
840 show-ref
) : plumbing
;;
841 send-pack
) : plumbing
;;
842 show-index
) : plumbing
;;
844 stripspace
) : plumbing
;;
845 symbolic-ref
) : plumbing
;;
846 unpack-file
) : plumbing
;;
847 unpack-objects
) : plumbing
;;
848 update-index
) : plumbing
;;
849 update-ref
) : plumbing
;;
850 update-server-info
) : daemon
;;
851 upload-archive
) : plumbing
;;
852 upload-pack
) : plumbing
;;
853 write-tree
) : plumbing
;;
855 verify-pack
) : infrequent
;;
856 verify-tag
) : plumbing
;;
862 __git_porcelain_commands
=
863 __git_compute_porcelain_commands
()
865 test -n "$__git_porcelain_commands" ||
866 __git_porcelain_commands
=$
(__git_list_porcelain_commands
)
869 # Lists all set config variables starting with the given section prefix,
870 # with the prefix removed.
871 __git_get_config_variables
()
873 local section
="$1" i IFS
=$
'\n'
874 for i
in $
(__git config
--name-only --get-regexp "^$section\..*"); do
875 echo "${i#$section.}"
879 __git_pretty_aliases
()
881 __git_get_config_variables
"pretty"
886 __git_get_config_variables
"alias"
889 # __git_aliased_command requires 1 argument
890 __git_aliased_command
()
892 local word cmdline
=$
(__git config
--get "alias.$1")
893 for word
in $cmdline; do
899 \
!*) : shell
command alias ;;
901 *=*) : setting env
;;
903 \
(\
)) : skip parens of shell
function definition
;;
904 {) : skip start of shell helper
function ;;
905 :) : skip null
command ;;
906 \'*) : skip opening quote after sh
-c ;;
914 # __git_find_on_cmdline requires 1 argument
915 __git_find_on_cmdline
()
917 local word subcommand c
=1
918 while [ $c -lt $cword ]; do
920 for subcommand
in $1; do
921 if [ "$subcommand" = "$word" ]; then
930 # Echo the value of an option set on the command line or config
932 # $1: short option name
933 # $2: long option name including =
934 # $3: list of possible values
935 # $4: config string (optional)
938 # result="$(__git_get_option_value "-d" "--do-something=" \
939 # "yes no" "core.doSomething")"
941 # result is then either empty (no option set) or "yes" or "no"
943 # __git_get_option_value requires 3 arguments
944 __git_get_option_value
()
946 local c short_opt long_opt val
947 local result
= values config_key word
955 while [ $c -ge 0 ]; do
957 for val
in $values; do
958 if [ "$short_opt$val" = "$word" ] ||
959 [ "$long_opt$val" = "$word" ]; then
967 if [ -n "$config_key" ] && [ -z "$result" ]; then
968 result
="$(__git config "$config_key")"
974 __git_has_doubledash
()
977 while [ $c -lt $cword ]; do
978 if [ "--" = "${words[c]}" ]; then
986 # Try to count non option arguments passed on the command line for the
987 # specified git command.
988 # When options are used, it is necessary to use the special -- option to
989 # tell the implementation were non option arguments begin.
990 # XXX this can not be improved, since options can appear everywhere, as
994 # __git_count_arguments requires 1 argument: the git command executed.
995 __git_count_arguments
()
999 # Skip "git" (first argument)
1000 for ((i
=1; i
< ${#words[@]}; i
++)); do
1005 # Good; we can assume that the following are only non
1010 # Skip the specified git command and discard git
1023 __git_whitespacelist
="nowarn warn error error-all fix"
1027 __git_find_repo_path
1028 if [ -d "$__git_repo_path"/rebase-apply
]; then
1029 __gitcomp
"--skip --continue --resolved --abort"
1034 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
1039 --3way --committer-date-is-author-date --ignore-date
1040 --ignore-whitespace --ignore-space-change
1041 --interactive --keep --no-utf8 --signoff --utf8
1042 --whitespace= --scissors
1052 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
1057 --stat --numstat --summary --check --index
1058 --cached --index-info --reverse --reject --unidiff-zero
1059 --apply --no-add --exclude=
1060 --ignore-whitespace --ignore-space-change
1061 --whitespace= --inaccurate-eof --verbose
1072 --interactive --refresh --patch --update --dry-run
1073 --ignore-errors --intent-to-add
1078 # XXX should we check for --update and --all options ?
1079 __git_complete_index_file
"--others --modified --directory --no-empty-directory"
1086 __gitcomp
"$(git archive --list)" "" "${cur##--format=}"
1090 __gitcomp_nl
"$(__git_remotes)" "" "${cur##--remote=}"
1095 --format= --list --verbose
1096 --prefix= --remote= --exec=
1106 __git_has_doubledash
&& return
1108 local subcommands
="start bad good skip reset visualize replay log run"
1109 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
1110 if [ -z "$subcommand" ]; then
1111 __git_find_repo_path
1112 if [ -f "$__git_repo_path"/BISECT_START
]; then
1113 __gitcomp
"$subcommands"
1115 __gitcomp
"replay start"
1120 case "$subcommand" in
1121 bad|good|
reset|skip|start
)
1131 local i c
=1 only_local_ref
="n" has_r
="n"
1133 while [ $c -lt $cword ]; do
1136 -d|
--delete|
-m|
--move) only_local_ref
="y" ;;
1137 -r|
--remotes) has_r
="y" ;;
1143 --set-upstream-to=*)
1144 __git_complete_refs
--cur="${cur##--set-upstream-to=}"
1148 --color --no-color --verbose --abbrev= --no-abbrev
1149 --track --no-track --contains --merged --no-merged
1150 --set-upstream-to= --edit-description --list
1151 --unset-upstream --delete --move --remotes
1155 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
1156 __gitcomp_nl
"$(__git_heads)"
1166 local cmd
="${words[2]}"
1169 __gitcomp
"create list-heads verify unbundle"
1172 # looking for a file
1177 __git_complete_revlist
1186 __git_has_doubledash
&& return
1190 __gitcomp
"diff3 merge" "" "${cur##--conflict=}"
1194 --quiet --ours --theirs --track --no-track --merge
1195 --conflict= --orphan --patch
1199 # check if --track, --no-track, or --no-guess was specified
1200 # if so, disable DWIM mode
1201 local flags
="--track --no-track --no-guess" track_opt
="--track"
1202 if [ -n "$(__git_find_on_cmdline "$flags")" ]; then
1205 __git_complete_refs
$track_opt
1217 __git_find_repo_path
1218 if [ -f "$__git_repo_path"/CHERRY_PICK_HEAD
]; then
1219 __gitcomp
"--continue --quit --abort"
1224 __gitcomp
"--edit --no-commit --signoff --strategy= --mainline"
1236 __gitcomp
"--dry-run --quiet"
1241 # XXX should we check for -x option ?
1242 __git_complete_index_file
"--others --directory"
1264 --recurse-submodules
1271 __git_untracked_file_modes
="all no normal"
1284 __gitcomp
"default scissors strip verbatim whitespace
1285 " "" "${cur##--cleanup=}"
1288 --reuse-message=*|
--reedit-message=*|\
1289 --fixup=*|
--squash=*)
1290 __git_complete_refs
--cur="${cur#*=}"
1293 --untracked-files=*)
1294 __gitcomp
"$__git_untracked_file_modes" "" "${cur##--untracked-files=}"
1299 --all --author= --signoff --verify --no-verify
1301 --amend --include --only --interactive
1302 --dry-run --reuse-message= --reedit-message=
1303 --reset-author --file= --message= --template=
1304 --cleanup= --untracked-files --untracked-files=
1305 --verbose --quiet --fixup= --squash=
1310 if __git rev-parse
--verify --quiet HEAD
>/dev
/null
; then
1311 __git_complete_index_file
"--committable"
1313 # This is the first commit
1314 __git_complete_index_file
"--cached"
1323 --all --tags --contains --abbrev= --candidates=
1324 --exact-match --debug --long --match --always
1331 __git_diff_algorithms
="myers minimal patience histogram"
1333 __git_diff_submodule_formats
="diff log short"
1335 __git_diff_common_options
="--stat --numstat --shortstat --summary
1336 --patch-with-stat --name-only --name-status --color
1337 --no-color --color-words --no-renames --check
1338 --full-index --binary --abbrev --diff-filter=
1339 --find-copies-harder
1340 --text --ignore-space-at-eol --ignore-space-change
1341 --ignore-all-space --ignore-blank-lines --exit-code
1342 --quiet --ext-diff --no-ext-diff
1343 --no-prefix --src-prefix= --dst-prefix=
1344 --inter-hunk-context=
1345 --patience --histogram --minimal
1346 --raw --word-diff --word-diff-regex=
1347 --dirstat --dirstat= --dirstat-by-file
1348 --dirstat-by-file= --cumulative
1350 --submodule --submodule=
1355 __git_has_doubledash
&& return
1359 __gitcomp
"$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
1363 __gitcomp
"$__git_diff_submodule_formats" "" "${cur##--submodule=}"
1367 __gitcomp
"--cached --staged --pickaxe-all --pickaxe-regex
1368 --base --ours --theirs --no-index
1369 $__git_diff_common_options
1374 __git_complete_revlist_file
1377 __git_mergetools_common
="diffuse diffmerge ecmerge emerge kdiff3 meld opendiff
1378 tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc codecompare
1383 __git_has_doubledash
&& return
1387 __gitcomp
"$__git_mergetools_common kompare" "" "${cur##--tool=}"
1391 __gitcomp
"--cached --staged --pickaxe-all --pickaxe-regex
1392 --base --ours --theirs
1393 --no-renames --diff-filter= --find-copies-harder
1394 --relative --ignore-submodules
1399 __git_complete_revlist_file
1402 __git_fetch_recurse_submodules
="yes on-demand no"
1404 __git_fetch_options
="
1405 --quiet --verbose --append --upload-pack --force --keep --depth=
1406 --tags --no-tags --all --prune --dry-run --recurse-submodules=
1412 --recurse-submodules=*)
1413 __gitcomp
"$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}"
1417 __gitcomp
"$__git_fetch_options"
1421 __git_complete_remote_or_refspec
1424 __git_format_patch_options
="
1425 --stdout --attach --no-attach --thread --thread= --no-thread
1426 --numbered --start-number --numbered-files --keep-subject --signoff
1427 --signature --no-signature --in-reply-to= --cc= --full-index --binary
1428 --not --all --cover-letter --no-prefix --src-prefix= --dst-prefix=
1429 --inline --suffix= --ignore-if-in-upstream --subject-prefix=
1430 --output-directory --reroll-count --to= --quiet --notes
1433 _git_format_patch
()
1439 " "" "${cur##--thread=}"
1443 __gitcomp
"$__git_format_patch_options"
1447 __git_complete_revlist
1455 --tags --root --unreachable --cache --no-reflogs --full
1456 --strict --verbose --lost-found
1467 __gitcomp
"--prune --aggressive"
1478 __git_match_ctag
() {
1479 awk "/^${1//\//\\/}/ { print \$1 }" "$2"
1484 __git_has_doubledash
&& return
1490 --text --ignore-case --word-regexp --invert-match
1491 --full-name --line-number
1492 --extended-regexp --basic-regexp --fixed-strings
1495 --files-with-matches --name-only
1496 --files-without-match
1499 --and --or --not --all-match
1505 case "$cword,$prev" in
1507 if test -r tags
; then
1508 __gitcomp_nl
"$(__git_match_ctag "$cur" tags)"
1521 __gitcomp
"--all --guides --info --man --web"
1525 __git_compute_all_commands
1526 __gitcomp
"$__git_all_commands $(__git_aliases)
1527 attributes cli core-tutorial cvs-migration
1528 diffcore everyday gitk glossary hooks ignore modules
1529 namespaces repository-layout revisions tutorial tutorial-2
1539 false true umask group all world everybody
1540 " "" "${cur##--shared=}"
1544 __gitcomp
"--quiet --bare --template= --shared --shared="
1554 __gitcomp
"--cached --deleted --modified --others --ignored
1555 --stage --directory --no-empty-directory --unmerged
1556 --killed --exclude= --exclude-from=
1557 --exclude-per-directory= --exclude-standard
1558 --error-unmatch --with-tree= --full-name
1559 --abbrev --ignored --exclude-per-directory
1565 # XXX ignore options like --modified and always suggest all cached
1567 __git_complete_index_file
"--cached"
1572 __gitcomp_nl
"$(__git_remotes)"
1580 # Options that go well for log, shortlog and gitk
1581 __git_log_common_options
="
1583 --branches --tags --remotes
1584 --first-parent --merges --no-merges
1586 --max-age= --since= --after=
1587 --min-age= --until= --before=
1588 --min-parents= --max-parents=
1589 --no-min-parents --no-max-parents
1591 # Options that go well for log and gitk (not shortlog)
1592 __git_log_gitk_options
="
1593 --dense --sparse --full-history
1594 --simplify-merges --simplify-by-decoration
1595 --left-right --notes --no-notes
1597 # Options that go well for log and shortlog (not gitk)
1598 __git_log_shortlog_options
="
1599 --author= --committer= --grep=
1600 --all-match --invert-grep
1603 __git_log_pretty_formats
="oneline short medium full fuller email raw format:"
1604 __git_log_date_formats
="relative iso8601 rfc2822 short local default raw"
1608 __git_has_doubledash
&& return
1609 __git_find_repo_path
1612 if [ -f "$__git_repo_path/MERGE_HEAD" ]; then
1616 --pretty=*|
--format=*)
1617 __gitcomp
"$__git_log_pretty_formats $(__git_pretty_aliases)
1622 __gitcomp
"$__git_log_date_formats" "" "${cur##--date=}"
1626 __gitcomp
"full short no" "" "${cur##--decorate=}"
1630 __gitcomp
"$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
1634 __gitcomp
"$__git_diff_submodule_formats" "" "${cur##--submodule=}"
1639 $__git_log_common_options
1640 $__git_log_shortlog_options
1641 $__git_log_gitk_options
1642 --root --topo-order --date-order --reverse
1643 --follow --full-diff
1644 --abbrev-commit --abbrev=
1645 --relative-date --date=
1646 --pretty= --format= --oneline
1651 --decorate --decorate=
1653 --parents --children
1655 $__git_diff_common_options
1656 --pickaxe-all --pickaxe-regex
1661 __git_complete_revlist
1664 # Common merge options shared by git-merge(1) and git-pull(1).
1665 __git_merge_options
="
1666 --no-commit --no-stat --log --no-log --squash --strategy
1667 --commit --stat --no-squash --ff --no-ff --ff-only --edit --no-edit
1668 --verify-signatures --no-verify-signatures --gpg-sign
1669 --quiet --verbose --progress --no-progress
1674 __git_complete_strategy
&& return
1678 __gitcomp
"$__git_merge_options
1679 --rerere-autoupdate --no-rerere-autoupdate --abort --continue"
1689 __gitcomp
"$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"
1703 __gitcomp
"--octopus --independent --is-ancestor --fork-point"
1714 __gitcomp
"--dry-run"
1719 if [ $
(__git_count_arguments
"mv") -gt 0 ]; then
1720 # We need to show both cached and untracked files (including
1721 # empty directories) since this may not be the last argument.
1722 __git_complete_index_file
"--cached --others --directory"
1724 __git_complete_index_file
"--cached"
1730 __gitcomp
"--tags --all --stdin"
1735 local subcommands
='add append copy edit list prune remove show'
1736 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
1738 case "$subcommand,$cur" in
1748 __gitcomp
"$subcommands --ref"
1752 add
,--reuse-message=*|append
,--reuse-message=*|\
1753 add
,--reedit-message=*|append
,--reedit-message=*)
1754 __git_complete_refs
--cur="${cur#*=}"
1757 __gitcomp
'--file= --message= --reedit-message=
1764 __gitcomp
'--dry-run --verbose'
1782 __git_complete_strategy
&& return
1785 --recurse-submodules=*)
1786 __gitcomp
"$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}"
1791 --rebase --no-rebase
1792 $__git_merge_options
1793 $__git_fetch_options
1798 __git_complete_remote_or_refspec
1801 __git_push_recurse_submodules
="check on-demand"
1803 __git_complete_force_with_lease
()
1811 __git_complete_refs
--cur="${cur_#*:}"
1814 __git_complete_refs
--cur="$cur_"
1823 __gitcomp_nl
"$(__git_remotes)"
1826 --recurse-submodules)
1827 __gitcomp
"$__git_push_recurse_submodules"
1833 __gitcomp_nl
"$(__git_remotes)" "" "${cur##--repo=}"
1836 --recurse-submodules=*)
1837 __gitcomp
"$__git_push_recurse_submodules" "" "${cur##--recurse-submodules=}"
1840 --force-with-lease=*)
1841 __git_complete_force_with_lease
"${cur##--force-with-lease=}"
1846 --all --mirror --tags --dry-run --force --verbose
1847 --quiet --prune --delete --follow-tags
1848 --receive-pack= --repo= --set-upstream
1849 --force-with-lease --force-with-lease= --recurse-submodules=
1854 __git_complete_remote_or_refspec
1859 __git_find_repo_path
1860 if [ -f "$__git_repo_path"/rebase-merge
/interactive
]; then
1861 __gitcomp
"--continue --skip --abort --quit --edit-todo"
1863 elif [ -d "$__git_repo_path"/rebase-apply
] || \
1864 [ -d "$__git_repo_path"/rebase-merge
]; then
1865 __gitcomp
"--continue --skip --abort --quit"
1868 __git_complete_strategy
&& return
1871 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
1876 --onto --merge --strategy --interactive
1877 --preserve-merges --stat --no-stat
1878 --committer-date-is-author-date --ignore-date
1879 --ignore-whitespace --whitespace=
1880 --autosquash --no-autosquash
1881 --fork-point --no-fork-point
1882 --autostash --no-autostash
1883 --verify --no-verify
1884 --keep-empty --root --force-rebase --no-ff
1895 local subcommands
="show delete expire"
1896 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
1898 if [ -z "$subcommand" ]; then
1899 __gitcomp
"$subcommands"
1905 __git_send_email_confirm_options
="always never auto cc compose"
1906 __git_send_email_suppresscc_options
="author self cc bodycc sob cccmd body all"
1911 --to|
--cc|
--bcc|
--from)
1912 __gitcomp
"$(__git send-email --dump-aliases)"
1920 $__git_send_email_confirm_options
1921 " "" "${cur##--confirm=}"
1926 $__git_send_email_suppresscc_options
1927 " "" "${cur##--suppress-cc=}"
1931 --smtp-encryption=*)
1932 __gitcomp
"ssl tls" "" "${cur##--smtp-encryption=}"
1938 " "" "${cur##--thread=}"
1941 --to=*|
--cc=*|
--bcc=*|
--from=*)
1942 __gitcomp
"$(__git send-email --dump-aliases)" "" "${cur#--*=}"
1946 __gitcomp
"--annotate --bcc --cc --cc-cmd --chain-reply-to
1947 --compose --confirm= --dry-run --envelope-sender
1949 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
1950 --no-suppress-from --no-thread --quiet
1951 --signed-off-by-cc --smtp-pass --smtp-server
1952 --smtp-server-port --smtp-encryption= --smtp-user
1953 --subject --suppress-cc= --suppress-from --thread --to
1954 --validate --no-validate
1955 $__git_format_patch_options"
1959 __git_complete_revlist
1970 local untracked_state
1973 --ignore-submodules=*)
1974 __gitcomp
"none untracked dirty all" "" "${cur##--ignore-submodules=}"
1977 --untracked-files=*)
1978 __gitcomp
"$__git_untracked_file_modes" "" "${cur##--untracked-files=}"
1983 always never auto column row plain dense nodense
1984 " "" "${cur##--column=}"
1989 --short --branch --porcelain --long --verbose
1990 --untracked-files= --ignore-submodules= --ignored
1991 --column= --no-column
1997 untracked_state
="$(__git_get_option_value "-u" "--untracked-files=" \
1998 "$__git_untracked_file_modes" "status.showUntrackedFiles
")"
2000 case "$untracked_state" in
2002 # --ignored option does not matter
2006 complete_opt
="--cached --directory --no-empty-directory --others"
2008 if [ -n "$(__git_find_on_cmdline "--ignored")" ]; then
2009 complete_opt
="$complete_opt --ignored --exclude=*"
2014 __git_complete_index_file
"$complete_opt"
2017 __git_config_get_set_variables
()
2019 local prevword word config_file
= c
=$cword
2020 while [ $c -gt 1 ]; do
2023 --system|
--global|
--local|
--file=*)
2028 config_file
="$word $prevword"
2036 __git config
$config_file --name-only --list
2042 branch.
*.remote|branch.
*.pushremote
)
2043 __gitcomp_nl
"$(__git_remotes)"
2051 __gitcomp
"false true preserve interactive"
2055 __gitcomp_nl
"$(__git_remotes)"
2059 local remote
="${prev#remote.}"
2060 remote
="${remote%.fetch}"
2061 if [ -z "$cur" ]; then
2062 __gitcomp_nl
"refs/heads/" "" "" ""
2065 __gitcomp_nl
"$(__git_refs_remotes "$remote")"
2069 local remote
="${prev#remote.}"
2070 remote
="${remote%.push}"
2071 __gitcomp_nl
"$(__git for-each-ref \
2072 --format='%(refname):%(refname)' refs/heads)"
2075 pull.twohead|pull.octopus
)
2076 __git_compute_merge_strategies
2077 __gitcomp
"$__git_merge_strategies"
2080 color.branch|color.
diff|color.interactive|\
2081 color.showbranch|color.status|color.ui
)
2082 __gitcomp
"always never auto"
2086 __gitcomp
"false true"
2091 normal black red green yellow blue magenta cyan white
2092 bold dim ul blink reverse
2097 __gitcomp
"log short"
2101 __gitcomp
"man info web html"
2105 __gitcomp
"$__git_log_date_formats"
2108 sendemail.aliasesfiletype
)
2109 __gitcomp
"mutt mailrc pine elm gnus"
2113 __gitcomp
"$__git_send_email_confirm_options"
2116 sendemail.suppresscc
)
2117 __gitcomp
"$__git_send_email_suppresscc_options"
2120 sendemail.transferencoding
)
2121 __gitcomp
"7bit 8bit quoted-printable base64"
2124 --get|
--get-all|
--unset|
--unset-all)
2125 __gitcomp_nl
"$(__git_config_get_set_variables)"
2135 --system --global --local --file=
2136 --list --replace-all
2137 --get --get-all --get-regexp
2138 --add --unset --unset-all
2139 --remove-section --rename-section
2145 local pfx
="${cur%.*}." cur_
="${cur##*.}"
2146 __gitcomp
"remote pushremote merge mergeoptions rebase" "$pfx" "$cur_"
2150 local pfx
="${cur%.*}." cur_
="${cur#*.}"
2151 __gitcomp_nl
"$(__git_heads)" "$pfx" "$cur_" "."
2152 __gitcomp_nl_append $
'autosetupmerge\nautosetuprebase\n' "$pfx" "$cur_"
2156 local pfx
="${cur%.*}." cur_
="${cur##*.}"
2158 argprompt cmd confirm needsfile noconsole norescan
2159 prompt revprompt revunmerged title
2164 local pfx
="${cur%.*}." cur_
="${cur##*.}"
2165 __gitcomp
"cmd path" "$pfx" "$cur_"
2169 local pfx
="${cur%.*}." cur_
="${cur##*.}"
2170 __gitcomp
"cmd path" "$pfx" "$cur_"
2174 local pfx
="${cur%.*}." cur_
="${cur##*.}"
2175 __gitcomp
"cmd path trustExitCode" "$pfx" "$cur_"
2179 local pfx
="${cur%.*}." cur_
="${cur#*.}"
2180 __git_compute_all_commands
2181 __gitcomp_nl
"$__git_all_commands" "$pfx" "$cur_"
2185 local pfx
="${cur%.*}." cur_
="${cur##*.}"
2187 url proxy fetch push mirror skipDefaultUpdate
2188 receivepack uploadpack tagopt pushurl
2193 local pfx
="${cur%.*}." cur_
="${cur#*.}"
2194 __gitcomp_nl
"$(__git_remotes)" "$pfx" "$cur_" "."
2195 __gitcomp_nl_append
"pushdefault" "$pfx" "$cur_"
2199 local pfx
="${cur%.*}." cur_
="${cur##*.}"
2200 __gitcomp
"insteadOf pushInsteadOf" "$pfx" "$cur_"
2206 advice.commitBeforeMerge
2208 advice.implicitIdentity
2209 advice.pushNonFastForward
2210 advice.resolveConflict
2214 apply.ignorewhitespace
2216 branch.autosetupmerge
2217 branch.autosetuprebase
2221 color.branch.current
2226 color.decorate.branch
2227 color.decorate.remoteBranch
2228 color.decorate.stash
2238 color.diff.whitespace
2243 color.grep.linenumber
2246 color.grep.separator
2248 color.interactive.error
2249 color.interactive.header
2250 color.interactive.help
2251 color.interactive.prompt
2256 color.status.changed
2258 color.status.nobranch
2259 color.status.unmerged
2260 color.status.untracked
2261 color.status.updated
2270 core.bigFileThreshold
2273 core.deltaBaseCacheLimit
2278 core.fsyncobjectfiles
2282 core.logAllRefUpdates
2283 core.loosecompression
2286 core.packedGitWindowSize
2288 core.preferSymlinkRefs
2291 core.repositoryFormatVersion
2293 core.sharedRepository
2298 core.warnAmbiguousRefs
2301 diff.autorefreshindex
2303 diff.ignoreSubmodules
2310 diff.suppressBlankEmpty
2316 fetch.recurseSubmodules
2327 format.subjectprefix
2338 gc.reflogexpireunreachable
2342 gitcvs.commitmsgannotation
2343 gitcvs.dbTableNamePrefix
2354 gui.copyblamethreshold
2358 gui.matchtrackingbranch
2359 gui.newbranchtemplate
2360 gui.pruneduringfetch
2361 gui.spellingdictionary
2378 http.sslCertPasswordProtected
2383 i18n.logOutputEncoding
2389 imap.preformattedHTML
2399 interactive.singlekey
2415 mergetool.keepBackup
2416 mergetool.keepTemporaries
2421 notes.rewrite.rebase
2425 pack.deltaCacheLimit
2442 receive.denyCurrentBranch
2443 receive.denyDeleteCurrent
2445 receive.denyNonFastForwards
2448 receive.updateserverinfo
2451 repack.usedeltabaseoffset
2455 sendemail.aliasesfile
2456 sendemail.aliasfiletype
2460 sendemail.chainreplyto
2462 sendemail.envelopesender
2466 sendemail.signedoffbycc
2467 sendemail.smtpdomain
2468 sendemail.smtpencryption
2470 sendemail.smtpserver
2471 sendemail.smtpserveroption
2472 sendemail.smtpserverport
2474 sendemail.suppresscc
2475 sendemail.suppressfrom
2480 status.relativePaths
2481 status.showUntrackedFiles
2482 status.submodulesummary
2485 transfer.unpackLimit
2497 local subcommands
="add rename remove set-head set-branches set-url show prune update"
2498 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
2499 if [ -z "$subcommand" ]; then
2500 __gitcomp
"$subcommands"
2504 case "$subcommand" in
2505 rename|remove|set-url|show|prune
)
2506 __gitcomp_nl
"$(__git_remotes)"
2508 set-head|set-branches
)
2509 __git_complete_remote_or_refspec
2512 __gitcomp
"$(__git_get_config_variables "remotes
")"
2526 __git_has_doubledash
&& return
2530 __gitcomp
"--merge --mixed --hard --soft --patch"
2539 __git_find_repo_path
2540 if [ -f "$__git_repo_path"/REVERT_HEAD
]; then
2541 __gitcomp
"--continue --quit --abort"
2546 __gitcomp
"--edit --mainline --no-edit --no-commit --signoff"
2557 __gitcomp
"--cached --dry-run --ignore-unmatch --quiet"
2562 __git_complete_index_file
"--cached"
2567 __git_has_doubledash
&& return
2572 $__git_log_common_options
2573 $__git_log_shortlog_options
2574 --numbered --summary
2579 __git_complete_revlist
2584 __git_has_doubledash
&& return
2587 --pretty=*|
--format=*)
2588 __gitcomp
"$__git_log_pretty_formats $(__git_pretty_aliases)
2593 __gitcomp
"$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
2597 __gitcomp
"$__git_diff_submodule_formats" "" "${cur##--submodule=}"
2601 __gitcomp
"--pretty= --format= --abbrev-commit --oneline
2603 $__git_diff_common_options
2608 __git_complete_revlist_file
2616 --all --remotes --topo-order --date-order --current --more=
2617 --list --independent --merge-base --no-name
2619 --sha1-name --sparse --topics --reflog
2624 __git_complete_revlist
2629 local save_opts
='--all --keep-index --no-keep-index --quiet --patch --include-untracked'
2630 local subcommands
='save list show apply clear drop pop create branch'
2631 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
2632 if [ -z "$subcommand" ]; then
2635 __gitcomp
"$save_opts"
2638 if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then
2639 __gitcomp
"$subcommands"
2644 case "$subcommand,$cur" in
2646 __gitcomp
"$save_opts"
2649 __gitcomp
"--index --quiet"
2654 show
,--*|branch
,--*)
2657 if [ $cword -eq 3 ]; then
2660 __gitcomp_nl
"$(__git stash list \
2661 | sed -n -e 's/:.*//p')"
2664 show
,*|apply
,*|drop
,*|pop
,*)
2665 __gitcomp_nl
"$(__git stash list \
2666 | sed -n -e 's/:.*//p')"
2676 __git_has_doubledash
&& return
2678 local subcommands
="add status init deinit update summary foreach sync"
2679 if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then
2682 __gitcomp
"--quiet --cached"
2685 __gitcomp
"$subcommands"
2695 init fetch clone rebase dcommit log find-rev
2696 set-tree commit-diff info create-ignore propget
2697 proplist show-ignore show-externals branch tag blame
2698 migrate mkdirs reset gc
2700 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
2701 if [ -z "$subcommand" ]; then
2702 __gitcomp
"$subcommands"
2704 local remote_opts
="--username= --config-dir= --no-auth-cache"
2706 --follow-parent --authors-file= --repack=
2707 --no-metadata --use-svm-props --use-svnsync-props
2708 --log-window-size= --no-checkout --quiet
2709 --repack-flags --use-log-author --localtime
2710 --ignore-paths= --include-paths= $remote_opts
2713 --template= --shared= --trunk= --tags=
2714 --branches= --stdlayout --minimize-url
2715 --no-metadata --use-svm-props --use-svnsync-props
2716 --rewrite-root= --prefix= --use-log-author
2717 --add-author-from $remote_opts
2720 --edit --rmdir --find-copies-harder --copy-similarity=
2723 case "$subcommand,$cur" in
2725 __gitcomp
"--revision= --fetch-all $fc_opts"
2728 __gitcomp
"--revision= $fc_opts $init_opts"
2731 __gitcomp
"$init_opts"
2735 --merge --strategy= --verbose --dry-run
2736 --fetch-all --no-rebase --commit-url
2737 --revision --interactive $cmt_opts $fc_opts
2741 __gitcomp
"--stdin $cmt_opts $fc_opts"
2743 create-ignore
,--*|propget
,--*|proplist
,--*|show-ignore
,--*|\
2744 show-externals
,--*|mkdirs
,--*)
2745 __gitcomp
"--revision="
2749 --limit= --revision= --verbose --incremental
2750 --oneline --show-commit --non-recursive
2751 --authors-file= --color
2756 --merge --verbose --strategy= --local
2757 --fetch-all --dry-run $fc_opts
2761 __gitcomp
"--message= --file= --revision= $cmt_opts"
2767 __gitcomp
"--dry-run --message --tag"
2770 __gitcomp
"--dry-run --message"
2773 __gitcomp
"--git-format"
2777 --config-dir= --ignore-paths= --minimize
2778 --no-auth-cache --username=
2782 __gitcomp
"--revision= --parent"
2793 while [ $c -lt $cword ]; do
2797 __gitcomp_nl
"$(__git_tags)"
2812 __gitcomp_nl
"$(__git_tags)"
2823 --list --delete --verify --annotate --message --file
2824 --sign --cleanup --local-user --force --column --sort
2825 --contains --points-at
2838 local subcommands
="add list lock prune unlock"
2839 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
2840 if [ -z "$subcommand" ]; then
2841 __gitcomp
"$subcommands"
2843 case "$subcommand,$cur" in
2845 __gitcomp
"--detach"
2848 __gitcomp
"--porcelain"
2851 __gitcomp
"--reason"
2854 __gitcomp
"--dry-run --expire --verbose"
2864 local i c
=1 command __git_dir __git_repo_path
2865 local __git_C_args C_args_count
=0
2867 while [ $c -lt $cword ]; do
2870 --git-dir=*) __git_dir
="${i#--git-dir=}" ;;
2871 --git-dir) ((c
++)) ; __git_dir
="${words[c]}" ;;
2872 --bare) __git_dir
="." ;;
2873 --help) command="help"; break ;;
2874 -c|
--work-tree|
--namespace) ((c
++)) ;;
2875 -C) __git_C_args
[C_args_count
++]=-C
2877 __git_C_args
[C_args_count
++]="${words[c]}"
2880 *) command="$i"; break ;;
2885 if [ -z "$command" ]; then
2887 --git-dir|
-C|
--work-tree)
2888 # these need a path argument, let's fall back to
2889 # Bash filename completion
2893 # we don't support completing these options' arguments
2911 --no-replace-objects
2915 *) __git_compute_porcelain_commands
2916 __gitcomp
"$__git_porcelain_commands $(__git_aliases)" ;;
2921 local completion_func
="_git_${command//-/_}"
2922 declare -f $completion_func >/dev
/null
2>/dev
/null
&& $completion_func && return
2924 local expansion
=$
(__git_aliased_command
"$command")
2925 if [ -n "$expansion" ]; then
2927 completion_func
="_git_${expansion//-/_}"
2928 declare -f $completion_func >/dev
/null
2>/dev
/null
&& $completion_func
2934 __git_has_doubledash
&& return
2936 local __git_repo_path
2937 __git_find_repo_path
2940 if [ -f "$__git_repo_path/MERGE_HEAD" ]; then
2946 $__git_log_common_options
2947 $__git_log_gitk_options
2953 __git_complete_revlist
2956 if [[ -n ${ZSH_VERSION-} ]]; then
2957 echo "WARNING: this script is deprecated, please see git-completion.zsh" 1>&2
2959 autoload
-U +X compinit
&& compinit
2965 local cur_
="${3-$cur}"
2971 local c IFS
=$
' \t\n'
2979 array
[${#array[@]}+1]="$c"
2982 compadd
-Q -S '' -p "${2-}" -a -- array
&& _ret
=0
2993 compadd
-Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
3002 compadd -Q -p "${2-}" -f -- ${=1} && _ret=0
3007 local _ret=1 cur cword prev
3008 cur=${words[CURRENT]}
3009 prev=${words[CURRENT-1]}
3011 emulate ksh -c __${service}_main
3012 let _ret && _default && _ret=0
3016 compdef _git git gitk
3022 local cur words cword prev
3023 _get_comp_words_by_ref -n =: cur words cword prev
3027 # Setup completion for certain functions defined above by setting common
3028 # variables and workarounds.
3029 # This is NOT a public function; use at your own risk.
3032 local wrapper="__git_wrap
${2}"
3033 eval "$wrapper () { __git_func_wrap
$2 ; }"
3034 complete -o bashdefault -o default -o nospace -F $wrapper $1 2>/dev/null \
3035 || complete -o default -o nospace -F $wrapper $1
3038 # wrapper for backwards compatibility
3041 __git_wrap__git_main
3044 # wrapper for backwards compatibility
3047 __git_wrap__gitk_main
3050 __git_complete git __git_main
3051 __git_complete gitk __gitk_main
3053 # The following are necessary only for Cygwin, and only are needed
3054 # when the user has tab-completed the executable name and consequently
3055 # included the '.exe' suffix.
3057 if [ Cygwin = "$
(uname
-o 2>/dev
/null
)" ]; then
3058 __git_complete git.exe __git_main