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
397 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)
492 for i
in $
(__git_refs
"$1"); do
497 # __git_refs_remotes requires 1 argument (to pass to ls-remote)
498 __git_refs_remotes
()
501 __git ls-remote
"$1" 'refs/heads/*' | \
502 while read -r hash i
; do
503 echo "$i:refs/remotes/$1/${i#refs/heads/}"
510 test -d "$__git_repo_path/remotes" && ls -1 "$__git_repo_path/remotes"
514 # Returns true if $1 matches the name of a configured remote, false otherwise.
515 __git_is_configured_remote
()
518 for remote
in $
(__git_remotes
); do
519 if [ "$remote" = "$1" ]; then
526 __git_list_merge_strategies
()
528 git merge
-s help 2>&1 |
529 sed -n -e '/[Aa]vailable strategies are: /,/^$/{
538 __git_merge_strategies
=
539 # 'git merge -s help' (and thus detection of the merge strategy
540 # list) fails, unfortunately, if run outside of any git working
541 # tree. __git_merge_strategies is set to the empty string in
542 # that case, and the detection will be repeated the next time it
544 __git_compute_merge_strategies
()
546 test -n "$__git_merge_strategies" ||
547 __git_merge_strategies
=$
(__git_list_merge_strategies
)
550 __git_complete_revlist_file
()
552 local pfx
ls ref cur_
="$cur"
572 case "$COMP_WORDBREAKS" in
574 *) pfx
="$ref:$pfx" ;;
577 __gitcomp_nl
"$(__git ls-tree "$ls" \
578 | sed '/^100... blob /{
594 pfx
="${cur_%...*}..."
596 __git_complete_refs
--pfx="$pfx" --cur="$cur_"
601 __git_complete_refs
--pfx="$pfx" --cur="$cur_"
610 # __git_complete_index_file requires 1 argument:
611 # 1: the options to pass to ls-file
613 # The exception is --committable, which finds the files appropriate commit.
614 __git_complete_index_file
()
616 local pfx
="" cur_
="$cur"
626 __gitcomp_file
"$(__git_index_files "$1" ${pfx:+"$pfx"})" "$pfx" "$cur_"
629 __git_complete_file
()
631 __git_complete_revlist_file
634 __git_complete_revlist
()
636 __git_complete_revlist_file
639 __git_complete_remote_or_refspec
()
641 local cur_
="$cur" cmd
="${words[1]}"
642 local i c
=2 remote
="" pfx
="" lhs
=1 no_complete_refspec
=0
643 if [ "$cmd" = "remote" ]; then
646 while [ $c -lt $cword ]; do
649 --mirror) [ "$cmd" = "push" ] && no_complete_refspec
=1 ;;
652 push
) no_complete_refspec
=1 ;;
660 *) remote
="$i"; break ;;
664 if [ -z "$remote" ]; then
665 __gitcomp_nl
"$(__git_remotes)"
668 if [ $no_complete_refspec = 1 ]; then
671 [ "$remote" = "." ] && remote
=
674 case "$COMP_WORDBREAKS" in
676 *) pfx
="${cur_%%:*}:" ;;
688 if [ $lhs = 1 ]; then
689 __gitcomp_nl
"$(__git_refs2 "$remote")" "$pfx" "$cur_"
691 __git_complete_refs
--pfx="$pfx" --cur="$cur_"
695 if [ $lhs = 1 ]; then
696 __git_complete_refs
--remote="$remote" --pfx="$pfx" --cur="$cur_"
698 __git_complete_refs
--pfx="$pfx" --cur="$cur_"
702 if [ $lhs = 1 ]; then
703 __git_complete_refs
--pfx="$pfx" --cur="$cur_"
705 __git_complete_refs
--remote="$remote" --pfx="$pfx" --cur="$cur_"
711 __git_complete_strategy
()
713 __git_compute_merge_strategies
716 __gitcomp
"$__git_merge_strategies"
721 __gitcomp
"$__git_merge_strategies" "" "${cur##--strategy=}"
729 if test -n "${GIT_TESTING_COMMAND_COMPLETION:-}"
731 printf "%s" "${GIT_TESTING_COMMAND_COMPLETION}"
733 git
help -a|
egrep '^ [a-zA-Z0-9]'
737 __git_list_all_commands
()
740 for i
in $
(__git_commands
)
743 *--*) : helper pattern
;;
750 __git_compute_all_commands
()
752 test -n "$__git_all_commands" ||
753 __git_all_commands
=$
(__git_list_all_commands
)
756 __git_list_porcelain_commands
()
759 __git_compute_all_commands
760 for i
in $__git_all_commands
763 *--*) : helper pattern
;;
764 applymbox
) : ask gittus
;;
765 applypatch
) : ask gittus
;;
766 archimport
) : import
;;
767 cat-file
) : plumbing
;;
768 check-attr
) : plumbing
;;
769 check-ignore
) : plumbing
;;
770 check-mailmap
) : plumbing
;;
771 check-ref-format
) : plumbing
;;
772 checkout-index
) : plumbing
;;
773 column) : internal helper
;;
774 commit-tree
) : plumbing
;;
775 count-objects
) : infrequent
;;
776 credential
) : credentials
;;
777 credential-
*) : credentials helper
;;
778 cvsexportcommit
) : export;;
779 cvsimport
) : import
;;
780 cvsserver
) : daemon
;;
782 diff-files
) : plumbing
;;
783 diff-index
) : plumbing
;;
784 diff-tree
) : plumbing
;;
785 fast-import
) : import
;;
786 fast-export
) : export;;
787 fsck-objects
) : plumbing
;;
788 fetch-pack
) : plumbing
;;
789 fmt-merge-msg
) : plumbing
;;
790 for-each-ref
) : plumbing
;;
791 hash-object
) : plumbing
;;
792 http-
*) : transport
;;
793 index-pack
) : plumbing
;;
794 init-db
) : deprecated
;;
795 local-fetch
) : plumbing
;;
796 ls-files
) : plumbing
;;
797 ls-remote
) : plumbing
;;
798 ls-tree
) : plumbing
;;
799 mailinfo
) : plumbing
;;
800 mailsplit
) : plumbing
;;
801 merge-
*) : plumbing
;;
804 pack-objects
) : plumbing
;;
805 pack-redundant
) : plumbing
;;
806 pack-refs
) : plumbing
;;
807 parse-remote
) : plumbing
;;
808 patch-id
) : plumbing
;;
810 prune-packed
) : plumbing
;;
811 quiltimport
) : import
;;
812 read-tree
) : plumbing
;;
813 receive-pack
) : plumbing
;;
814 remote-
*) : transport
;;
816 rev-list
) : plumbing
;;
817 rev-parse
) : plumbing
;;
818 runstatus
) : plumbing
;;
819 sh-setup
) : internal
;;
821 show-ref
) : plumbing
;;
822 send-pack
) : plumbing
;;
823 show-index
) : plumbing
;;
825 stripspace
) : plumbing
;;
826 symbolic-ref
) : plumbing
;;
827 unpack-file
) : plumbing
;;
828 unpack-objects
) : plumbing
;;
829 update-index
) : plumbing
;;
830 update-ref
) : plumbing
;;
831 update-server-info
) : daemon
;;
832 upload-archive
) : plumbing
;;
833 upload-pack
) : plumbing
;;
834 write-tree
) : plumbing
;;
836 verify-pack
) : infrequent
;;
837 verify-tag
) : plumbing
;;
843 __git_porcelain_commands
=
844 __git_compute_porcelain_commands
()
846 test -n "$__git_porcelain_commands" ||
847 __git_porcelain_commands
=$
(__git_list_porcelain_commands
)
850 # Lists all set config variables starting with the given section prefix,
851 # with the prefix removed.
852 __git_get_config_variables
()
854 local section
="$1" i IFS
=$
'\n'
855 for i
in $
(__git config
--name-only --get-regexp "^$section\..*"); do
856 echo "${i#$section.}"
860 __git_pretty_aliases
()
862 __git_get_config_variables
"pretty"
867 __git_get_config_variables
"alias"
870 # __git_aliased_command requires 1 argument
871 __git_aliased_command
()
873 local word cmdline
=$
(__git config
--get "alias.$1")
874 for word
in $cmdline; do
880 \
!*) : shell
command alias ;;
882 *=*) : setting env
;;
884 \
(\
)) : skip parens of shell
function definition
;;
885 {) : skip start of shell helper
function ;;
886 :) : skip null
command ;;
887 \'*) : skip opening quote after sh
-c ;;
895 # __git_find_on_cmdline requires 1 argument
896 __git_find_on_cmdline
()
898 local word subcommand c
=1
899 while [ $c -lt $cword ]; do
901 for subcommand
in $1; do
902 if [ "$subcommand" = "$word" ]; then
911 # Echo the value of an option set on the command line or config
913 # $1: short option name
914 # $2: long option name including =
915 # $3: list of possible values
916 # $4: config string (optional)
919 # result="$(__git_get_option_value "-d" "--do-something=" \
920 # "yes no" "core.doSomething")"
922 # result is then either empty (no option set) or "yes" or "no"
924 # __git_get_option_value requires 3 arguments
925 __git_get_option_value
()
927 local c short_opt long_opt val
928 local result
= values config_key word
936 while [ $c -ge 0 ]; do
938 for val
in $values; do
939 if [ "$short_opt$val" = "$word" ] ||
940 [ "$long_opt$val" = "$word" ]; then
948 if [ -n "$config_key" ] && [ -z "$result" ]; then
949 result
="$(__git config "$config_key")"
955 __git_has_doubledash
()
958 while [ $c -lt $cword ]; do
959 if [ "--" = "${words[c]}" ]; then
967 # Try to count non option arguments passed on the command line for the
968 # specified git command.
969 # When options are used, it is necessary to use the special -- option to
970 # tell the implementation were non option arguments begin.
971 # XXX this can not be improved, since options can appear everywhere, as
975 # __git_count_arguments requires 1 argument: the git command executed.
976 __git_count_arguments
()
980 # Skip "git" (first argument)
981 for ((i
=1; i
< ${#words[@]}; i
++)); do
986 # Good; we can assume that the following are only non
991 # Skip the specified git command and discard git
1004 __git_whitespacelist
="nowarn warn error error-all fix"
1008 __git_find_repo_path
1009 if [ -d "$__git_repo_path"/rebase-apply
]; then
1010 __gitcomp
"--skip --continue --resolved --abort"
1015 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
1020 --3way --committer-date-is-author-date --ignore-date
1021 --ignore-whitespace --ignore-space-change
1022 --interactive --keep --no-utf8 --signoff --utf8
1023 --whitespace= --scissors
1033 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
1038 --stat --numstat --summary --check --index
1039 --cached --index-info --reverse --reject --unidiff-zero
1040 --apply --no-add --exclude=
1041 --ignore-whitespace --ignore-space-change
1042 --whitespace= --inaccurate-eof --verbose
1053 --interactive --refresh --patch --update --dry-run
1054 --ignore-errors --intent-to-add
1059 # XXX should we check for --update and --all options ?
1060 __git_complete_index_file
"--others --modified --directory --no-empty-directory"
1067 __gitcomp
"$(git archive --list)" "" "${cur##--format=}"
1071 __gitcomp_nl
"$(__git_remotes)" "" "${cur##--remote=}"
1076 --format= --list --verbose
1077 --prefix= --remote= --exec=
1087 __git_has_doubledash
&& return
1089 local subcommands
="start bad good skip reset visualize replay log run"
1090 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
1091 if [ -z "$subcommand" ]; then
1092 __git_find_repo_path
1093 if [ -f "$__git_repo_path"/BISECT_START
]; then
1094 __gitcomp
"$subcommands"
1096 __gitcomp
"replay start"
1101 case "$subcommand" in
1102 bad|good|
reset|skip|start
)
1112 local i c
=1 only_local_ref
="n" has_r
="n"
1114 while [ $c -lt $cword ]; do
1117 -d|
--delete|
-m|
--move) only_local_ref
="y" ;;
1118 -r|
--remotes) has_r
="y" ;;
1124 --set-upstream-to=*)
1125 __git_complete_refs
--cur="${cur##--set-upstream-to=}"
1129 --color --no-color --verbose --abbrev= --no-abbrev
1130 --track --no-track --contains --merged --no-merged
1131 --set-upstream-to= --edit-description --list
1132 --unset-upstream --delete --move --remotes
1136 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
1137 __gitcomp_nl
"$(__git_heads)"
1147 local cmd
="${words[2]}"
1150 __gitcomp
"create list-heads verify unbundle"
1153 # looking for a file
1158 __git_complete_revlist
1167 __git_has_doubledash
&& return
1171 __gitcomp
"diff3 merge" "" "${cur##--conflict=}"
1175 --quiet --ours --theirs --track --no-track --merge
1176 --conflict= --orphan --patch
1180 # check if --track, --no-track, or --no-guess was specified
1181 # if so, disable DWIM mode
1182 local flags
="--track --no-track --no-guess" track_opt
="--track"
1183 if [ -n "$(__git_find_on_cmdline "$flags")" ]; then
1186 __git_complete_refs
$track_opt
1198 __git_find_repo_path
1199 if [ -f "$__git_repo_path"/CHERRY_PICK_HEAD
]; then
1200 __gitcomp
"--continue --quit --abort"
1205 __gitcomp
"--edit --no-commit --signoff --strategy= --mainline"
1217 __gitcomp
"--dry-run --quiet"
1222 # XXX should we check for -x option ?
1223 __git_complete_index_file
"--others --directory"
1245 --recurse-submodules
1252 __git_untracked_file_modes
="all no normal"
1265 __gitcomp
"default scissors strip verbatim whitespace
1266 " "" "${cur##--cleanup=}"
1269 --reuse-message=*|
--reedit-message=*|\
1270 --fixup=*|
--squash=*)
1271 __git_complete_refs
--cur="${cur#*=}"
1274 --untracked-files=*)
1275 __gitcomp
"$__git_untracked_file_modes" "" "${cur##--untracked-files=}"
1280 --all --author= --signoff --verify --no-verify
1282 --amend --include --only --interactive
1283 --dry-run --reuse-message= --reedit-message=
1284 --reset-author --file= --message= --template=
1285 --cleanup= --untracked-files --untracked-files=
1286 --verbose --quiet --fixup= --squash=
1291 if __git rev-parse
--verify --quiet HEAD
>/dev
/null
; then
1292 __git_complete_index_file
"--committable"
1294 # This is the first commit
1295 __git_complete_index_file
"--cached"
1304 --all --tags --contains --abbrev= --candidates=
1305 --exact-match --debug --long --match --always
1312 __git_diff_algorithms
="myers minimal patience histogram"
1314 __git_diff_submodule_formats
="diff log short"
1316 __git_diff_common_options
="--stat --numstat --shortstat --summary
1317 --patch-with-stat --name-only --name-status --color
1318 --no-color --color-words --no-renames --check
1319 --full-index --binary --abbrev --diff-filter=
1320 --find-copies-harder
1321 --text --ignore-space-at-eol --ignore-space-change
1322 --ignore-all-space --ignore-blank-lines --exit-code
1323 --quiet --ext-diff --no-ext-diff
1324 --no-prefix --src-prefix= --dst-prefix=
1325 --inter-hunk-context=
1326 --patience --histogram --minimal
1327 --raw --word-diff --word-diff-regex=
1328 --dirstat --dirstat= --dirstat-by-file
1329 --dirstat-by-file= --cumulative
1331 --submodule --submodule=
1336 __git_has_doubledash
&& return
1340 __gitcomp
"$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
1344 __gitcomp
"$__git_diff_submodule_formats" "" "${cur##--submodule=}"
1348 __gitcomp
"--cached --staged --pickaxe-all --pickaxe-regex
1349 --base --ours --theirs --no-index
1350 $__git_diff_common_options
1355 __git_complete_revlist_file
1358 __git_mergetools_common
="diffuse diffmerge ecmerge emerge kdiff3 meld opendiff
1359 tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc codecompare
1364 __git_has_doubledash
&& return
1368 __gitcomp
"$__git_mergetools_common kompare" "" "${cur##--tool=}"
1372 __gitcomp
"--cached --staged --pickaxe-all --pickaxe-regex
1373 --base --ours --theirs
1374 --no-renames --diff-filter= --find-copies-harder
1375 --relative --ignore-submodules
1380 __git_complete_revlist_file
1383 __git_fetch_recurse_submodules
="yes on-demand no"
1385 __git_fetch_options
="
1386 --quiet --verbose --append --upload-pack --force --keep --depth=
1387 --tags --no-tags --all --prune --dry-run --recurse-submodules=
1393 --recurse-submodules=*)
1394 __gitcomp
"$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}"
1398 __gitcomp
"$__git_fetch_options"
1402 __git_complete_remote_or_refspec
1405 __git_format_patch_options
="
1406 --stdout --attach --no-attach --thread --thread= --no-thread
1407 --numbered --start-number --numbered-files --keep-subject --signoff
1408 --signature --no-signature --in-reply-to= --cc= --full-index --binary
1409 --not --all --cover-letter --no-prefix --src-prefix= --dst-prefix=
1410 --inline --suffix= --ignore-if-in-upstream --subject-prefix=
1411 --output-directory --reroll-count --to= --quiet --notes
1414 _git_format_patch
()
1420 " "" "${cur##--thread=}"
1424 __gitcomp
"$__git_format_patch_options"
1428 __git_complete_revlist
1436 --tags --root --unreachable --cache --no-reflogs --full
1437 --strict --verbose --lost-found
1448 __gitcomp
"--prune --aggressive"
1459 __git_match_ctag
() {
1460 awk "/^${1//\//\\/}/ { print \$1 }" "$2"
1465 __git_has_doubledash
&& return
1471 --text --ignore-case --word-regexp --invert-match
1472 --full-name --line-number
1473 --extended-regexp --basic-regexp --fixed-strings
1476 --files-with-matches --name-only
1477 --files-without-match
1480 --and --or --not --all-match
1486 case "$cword,$prev" in
1488 if test -r tags
; then
1489 __gitcomp_nl
"$(__git_match_ctag "$cur" tags)"
1502 __gitcomp
"--all --guides --info --man --web"
1506 __git_compute_all_commands
1507 __gitcomp
"$__git_all_commands $(__git_aliases)
1508 attributes cli core-tutorial cvs-migration
1509 diffcore everyday gitk glossary hooks ignore modules
1510 namespaces repository-layout revisions tutorial tutorial-2
1520 false true umask group all world everybody
1521 " "" "${cur##--shared=}"
1525 __gitcomp
"--quiet --bare --template= --shared --shared="
1535 __gitcomp
"--cached --deleted --modified --others --ignored
1536 --stage --directory --no-empty-directory --unmerged
1537 --killed --exclude= --exclude-from=
1538 --exclude-per-directory= --exclude-standard
1539 --error-unmatch --with-tree= --full-name
1540 --abbrev --ignored --exclude-per-directory
1546 # XXX ignore options like --modified and always suggest all cached
1548 __git_complete_index_file
"--cached"
1553 __gitcomp_nl
"$(__git_remotes)"
1561 # Options that go well for log, shortlog and gitk
1562 __git_log_common_options
="
1564 --branches --tags --remotes
1565 --first-parent --merges --no-merges
1567 --max-age= --since= --after=
1568 --min-age= --until= --before=
1569 --min-parents= --max-parents=
1570 --no-min-parents --no-max-parents
1572 # Options that go well for log and gitk (not shortlog)
1573 __git_log_gitk_options
="
1574 --dense --sparse --full-history
1575 --simplify-merges --simplify-by-decoration
1576 --left-right --notes --no-notes
1578 # Options that go well for log and shortlog (not gitk)
1579 __git_log_shortlog_options
="
1580 --author= --committer= --grep=
1581 --all-match --invert-grep
1584 __git_log_pretty_formats
="oneline short medium full fuller email raw format:"
1585 __git_log_date_formats
="relative iso8601 rfc2822 short local default raw"
1589 __git_has_doubledash
&& return
1590 __git_find_repo_path
1593 if [ -f "$__git_repo_path/MERGE_HEAD" ]; then
1597 --pretty=*|
--format=*)
1598 __gitcomp
"$__git_log_pretty_formats $(__git_pretty_aliases)
1603 __gitcomp
"$__git_log_date_formats" "" "${cur##--date=}"
1607 __gitcomp
"full short no" "" "${cur##--decorate=}"
1611 __gitcomp
"$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
1615 __gitcomp
"$__git_diff_submodule_formats" "" "${cur##--submodule=}"
1620 $__git_log_common_options
1621 $__git_log_shortlog_options
1622 $__git_log_gitk_options
1623 --root --topo-order --date-order --reverse
1624 --follow --full-diff
1625 --abbrev-commit --abbrev=
1626 --relative-date --date=
1627 --pretty= --format= --oneline
1632 --decorate --decorate=
1634 --parents --children
1636 $__git_diff_common_options
1637 --pickaxe-all --pickaxe-regex
1642 __git_complete_revlist
1645 # Common merge options shared by git-merge(1) and git-pull(1).
1646 __git_merge_options
="
1647 --no-commit --no-stat --log --no-log --squash --strategy
1648 --commit --stat --no-squash --ff --no-ff --ff-only --edit --no-edit
1649 --verify-signatures --no-verify-signatures --gpg-sign
1650 --quiet --verbose --progress --no-progress
1655 __git_complete_strategy
&& return
1659 __gitcomp
"$__git_merge_options
1660 --rerere-autoupdate --no-rerere-autoupdate --abort --continue"
1670 __gitcomp
"$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"
1684 __gitcomp
"--octopus --independent --is-ancestor --fork-point"
1695 __gitcomp
"--dry-run"
1700 if [ $
(__git_count_arguments
"mv") -gt 0 ]; then
1701 # We need to show both cached and untracked files (including
1702 # empty directories) since this may not be the last argument.
1703 __git_complete_index_file
"--cached --others --directory"
1705 __git_complete_index_file
"--cached"
1711 __gitcomp
"--tags --all --stdin"
1716 local subcommands
='add append copy edit list prune remove show'
1717 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
1719 case "$subcommand,$cur" in
1729 __gitcomp
"$subcommands --ref"
1733 add
,--reuse-message=*|append
,--reuse-message=*|\
1734 add
,--reedit-message=*|append
,--reedit-message=*)
1735 __git_complete_refs
--cur="${cur#*=}"
1738 __gitcomp
'--file= --message= --reedit-message=
1745 __gitcomp
'--dry-run --verbose'
1763 __git_complete_strategy
&& return
1766 --recurse-submodules=*)
1767 __gitcomp
"$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}"
1772 --rebase --no-rebase
1773 $__git_merge_options
1774 $__git_fetch_options
1779 __git_complete_remote_or_refspec
1782 __git_push_recurse_submodules
="check on-demand"
1784 __git_complete_force_with_lease
()
1792 __git_complete_refs
--cur="${cur_#*:}"
1795 __git_complete_refs
--cur="$cur_"
1804 __gitcomp_nl
"$(__git_remotes)"
1807 --recurse-submodules)
1808 __gitcomp
"$__git_push_recurse_submodules"
1814 __gitcomp_nl
"$(__git_remotes)" "" "${cur##--repo=}"
1817 --recurse-submodules=*)
1818 __gitcomp
"$__git_push_recurse_submodules" "" "${cur##--recurse-submodules=}"
1821 --force-with-lease=*)
1822 __git_complete_force_with_lease
"${cur##--force-with-lease=}"
1827 --all --mirror --tags --dry-run --force --verbose
1828 --quiet --prune --delete --follow-tags
1829 --receive-pack= --repo= --set-upstream
1830 --force-with-lease --force-with-lease= --recurse-submodules=
1835 __git_complete_remote_or_refspec
1840 __git_find_repo_path
1841 if [ -f "$__git_repo_path"/rebase-merge
/interactive
]; then
1842 __gitcomp
"--continue --skip --abort --quit --edit-todo"
1844 elif [ -d "$__git_repo_path"/rebase-apply
] || \
1845 [ -d "$__git_repo_path"/rebase-merge
]; then
1846 __gitcomp
"--continue --skip --abort --quit"
1849 __git_complete_strategy
&& return
1852 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
1857 --onto --merge --strategy --interactive
1858 --preserve-merges --stat --no-stat
1859 --committer-date-is-author-date --ignore-date
1860 --ignore-whitespace --whitespace=
1861 --autosquash --no-autosquash
1862 --fork-point --no-fork-point
1863 --autostash --no-autostash
1864 --verify --no-verify
1865 --keep-empty --root --force-rebase --no-ff
1876 local subcommands
="show delete expire"
1877 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
1879 if [ -z "$subcommand" ]; then
1880 __gitcomp
"$subcommands"
1886 __git_send_email_confirm_options
="always never auto cc compose"
1887 __git_send_email_suppresscc_options
="author self cc bodycc sob cccmd body all"
1892 --to|
--cc|
--bcc|
--from)
1893 __gitcomp
"$(__git send-email --dump-aliases)"
1901 $__git_send_email_confirm_options
1902 " "" "${cur##--confirm=}"
1907 $__git_send_email_suppresscc_options
1908 " "" "${cur##--suppress-cc=}"
1912 --smtp-encryption=*)
1913 __gitcomp
"ssl tls" "" "${cur##--smtp-encryption=}"
1919 " "" "${cur##--thread=}"
1922 --to=*|
--cc=*|
--bcc=*|
--from=*)
1923 __gitcomp
"$(__git send-email --dump-aliases)" "" "${cur#--*=}"
1927 __gitcomp
"--annotate --bcc --cc --cc-cmd --chain-reply-to
1928 --compose --confirm= --dry-run --envelope-sender
1930 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
1931 --no-suppress-from --no-thread --quiet
1932 --signed-off-by-cc --smtp-pass --smtp-server
1933 --smtp-server-port --smtp-encryption= --smtp-user
1934 --subject --suppress-cc= --suppress-from --thread --to
1935 --validate --no-validate
1936 $__git_format_patch_options"
1940 __git_complete_revlist
1951 local untracked_state
1954 --ignore-submodules=*)
1955 __gitcomp
"none untracked dirty all" "" "${cur##--ignore-submodules=}"
1958 --untracked-files=*)
1959 __gitcomp
"$__git_untracked_file_modes" "" "${cur##--untracked-files=}"
1964 always never auto column row plain dense nodense
1965 " "" "${cur##--column=}"
1970 --short --branch --porcelain --long --verbose
1971 --untracked-files= --ignore-submodules= --ignored
1972 --column= --no-column
1978 untracked_state
="$(__git_get_option_value "-u" "--untracked-files=" \
1979 "$__git_untracked_file_modes" "status.showUntrackedFiles
")"
1981 case "$untracked_state" in
1983 # --ignored option does not matter
1987 complete_opt
="--cached --directory --no-empty-directory --others"
1989 if [ -n "$(__git_find_on_cmdline "--ignored")" ]; then
1990 complete_opt
="$complete_opt --ignored --exclude=*"
1995 __git_complete_index_file
"$complete_opt"
1998 __git_config_get_set_variables
()
2000 local prevword word config_file
= c
=$cword
2001 while [ $c -gt 1 ]; do
2004 --system|
--global|
--local|
--file=*)
2009 config_file
="$word $prevword"
2017 __git config
$config_file --name-only --list
2023 branch.
*.remote|branch.
*.pushremote
)
2024 __gitcomp_nl
"$(__git_remotes)"
2032 __gitcomp
"false true preserve interactive"
2036 __gitcomp_nl
"$(__git_remotes)"
2040 local remote
="${prev#remote.}"
2041 remote
="${remote%.fetch}"
2042 if [ -z "$cur" ]; then
2043 __gitcomp_nl
"refs/heads/" "" "" ""
2046 __gitcomp_nl
"$(__git_refs_remotes "$remote")"
2050 local remote
="${prev#remote.}"
2051 remote
="${remote%.push}"
2052 __gitcomp_nl
"$(__git for-each-ref \
2053 --format='%(refname):%(refname)' refs/heads)"
2056 pull.twohead|pull.octopus
)
2057 __git_compute_merge_strategies
2058 __gitcomp
"$__git_merge_strategies"
2061 color.branch|color.
diff|color.interactive|\
2062 color.showbranch|color.status|color.ui
)
2063 __gitcomp
"always never auto"
2067 __gitcomp
"false true"
2072 normal black red green yellow blue magenta cyan white
2073 bold dim ul blink reverse
2078 __gitcomp
"log short"
2082 __gitcomp
"man info web html"
2086 __gitcomp
"$__git_log_date_formats"
2089 sendemail.aliasesfiletype
)
2090 __gitcomp
"mutt mailrc pine elm gnus"
2094 __gitcomp
"$__git_send_email_confirm_options"
2097 sendemail.suppresscc
)
2098 __gitcomp
"$__git_send_email_suppresscc_options"
2101 sendemail.transferencoding
)
2102 __gitcomp
"7bit 8bit quoted-printable base64"
2105 --get|
--get-all|
--unset|
--unset-all)
2106 __gitcomp_nl
"$(__git_config_get_set_variables)"
2116 --system --global --local --file=
2117 --list --replace-all
2118 --get --get-all --get-regexp
2119 --add --unset --unset-all
2120 --remove-section --rename-section
2126 local pfx
="${cur%.*}." cur_
="${cur##*.}"
2127 __gitcomp
"remote pushremote merge mergeoptions rebase" "$pfx" "$cur_"
2131 local pfx
="${cur%.*}." cur_
="${cur#*.}"
2132 __gitcomp_nl
"$(__git_heads)" "$pfx" "$cur_" "."
2133 __gitcomp_nl_append $
'autosetupmerge\nautosetuprebase\n' "$pfx" "$cur_"
2137 local pfx
="${cur%.*}." cur_
="${cur##*.}"
2139 argprompt cmd confirm needsfile noconsole norescan
2140 prompt revprompt revunmerged title
2145 local pfx
="${cur%.*}." cur_
="${cur##*.}"
2146 __gitcomp
"cmd path" "$pfx" "$cur_"
2150 local pfx
="${cur%.*}." cur_
="${cur##*.}"
2151 __gitcomp
"cmd path" "$pfx" "$cur_"
2155 local pfx
="${cur%.*}." cur_
="${cur##*.}"
2156 __gitcomp
"cmd path trustExitCode" "$pfx" "$cur_"
2160 local pfx
="${cur%.*}." cur_
="${cur#*.}"
2161 __git_compute_all_commands
2162 __gitcomp_nl
"$__git_all_commands" "$pfx" "$cur_"
2166 local pfx
="${cur%.*}." cur_
="${cur##*.}"
2168 url proxy fetch push mirror skipDefaultUpdate
2169 receivepack uploadpack tagopt pushurl
2174 local pfx
="${cur%.*}." cur_
="${cur#*.}"
2175 __gitcomp_nl
"$(__git_remotes)" "$pfx" "$cur_" "."
2176 __gitcomp_nl_append
"pushdefault" "$pfx" "$cur_"
2180 local pfx
="${cur%.*}." cur_
="${cur##*.}"
2181 __gitcomp
"insteadOf pushInsteadOf" "$pfx" "$cur_"
2187 advice.commitBeforeMerge
2189 advice.implicitIdentity
2190 advice.pushNonFastForward
2191 advice.resolveConflict
2195 apply.ignorewhitespace
2197 branch.autosetupmerge
2198 branch.autosetuprebase
2202 color.branch.current
2207 color.decorate.branch
2208 color.decorate.remoteBranch
2209 color.decorate.stash
2219 color.diff.whitespace
2224 color.grep.linenumber
2227 color.grep.separator
2229 color.interactive.error
2230 color.interactive.header
2231 color.interactive.help
2232 color.interactive.prompt
2237 color.status.changed
2239 color.status.nobranch
2240 color.status.unmerged
2241 color.status.untracked
2242 color.status.updated
2251 core.bigFileThreshold
2254 core.deltaBaseCacheLimit
2259 core.fsyncobjectfiles
2263 core.logAllRefUpdates
2264 core.loosecompression
2267 core.packedGitWindowSize
2269 core.preferSymlinkRefs
2272 core.repositoryFormatVersion
2274 core.sharedRepository
2279 core.warnAmbiguousRefs
2282 diff.autorefreshindex
2284 diff.ignoreSubmodules
2291 diff.suppressBlankEmpty
2297 fetch.recurseSubmodules
2308 format.subjectprefix
2319 gc.reflogexpireunreachable
2323 gitcvs.commitmsgannotation
2324 gitcvs.dbTableNamePrefix
2335 gui.copyblamethreshold
2339 gui.matchtrackingbranch
2340 gui.newbranchtemplate
2341 gui.pruneduringfetch
2342 gui.spellingdictionary
2359 http.sslCertPasswordProtected
2364 i18n.logOutputEncoding
2370 imap.preformattedHTML
2380 interactive.singlekey
2396 mergetool.keepBackup
2397 mergetool.keepTemporaries
2402 notes.rewrite.rebase
2406 pack.deltaCacheLimit
2423 receive.denyCurrentBranch
2424 receive.denyDeleteCurrent
2426 receive.denyNonFastForwards
2429 receive.updateserverinfo
2432 repack.usedeltabaseoffset
2436 sendemail.aliasesfile
2437 sendemail.aliasfiletype
2441 sendemail.chainreplyto
2443 sendemail.envelopesender
2447 sendemail.signedoffbycc
2448 sendemail.smtpdomain
2449 sendemail.smtpencryption
2451 sendemail.smtpserver
2452 sendemail.smtpserveroption
2453 sendemail.smtpserverport
2455 sendemail.suppresscc
2456 sendemail.suppressfrom
2461 status.relativePaths
2462 status.showUntrackedFiles
2463 status.submodulesummary
2466 transfer.unpackLimit
2478 local subcommands
="add rename remove set-head set-branches set-url show prune update"
2479 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
2480 if [ -z "$subcommand" ]; then
2481 __gitcomp
"$subcommands"
2485 case "$subcommand" in
2486 rename|remove|set-url|show|prune
)
2487 __gitcomp_nl
"$(__git_remotes)"
2489 set-head|set-branches
)
2490 __git_complete_remote_or_refspec
2493 __gitcomp
"$(__git_get_config_variables "remotes
")"
2507 __git_has_doubledash
&& return
2511 __gitcomp
"--merge --mixed --hard --soft --patch"
2520 __git_find_repo_path
2521 if [ -f "$__git_repo_path"/REVERT_HEAD
]; then
2522 __gitcomp
"--continue --quit --abort"
2527 __gitcomp
"--edit --mainline --no-edit --no-commit --signoff"
2538 __gitcomp
"--cached --dry-run --ignore-unmatch --quiet"
2543 __git_complete_index_file
"--cached"
2548 __git_has_doubledash
&& return
2553 $__git_log_common_options
2554 $__git_log_shortlog_options
2555 --numbered --summary
2560 __git_complete_revlist
2565 __git_has_doubledash
&& return
2568 --pretty=*|
--format=*)
2569 __gitcomp
"$__git_log_pretty_formats $(__git_pretty_aliases)
2574 __gitcomp
"$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
2578 __gitcomp
"$__git_diff_submodule_formats" "" "${cur##--submodule=}"
2582 __gitcomp
"--pretty= --format= --abbrev-commit --oneline
2584 $__git_diff_common_options
2589 __git_complete_revlist_file
2597 --all --remotes --topo-order --date-order --current --more=
2598 --list --independent --merge-base --no-name
2600 --sha1-name --sparse --topics --reflog
2605 __git_complete_revlist
2610 local save_opts
='--all --keep-index --no-keep-index --quiet --patch --include-untracked'
2611 local subcommands
='save list show apply clear drop pop create branch'
2612 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
2613 if [ -z "$subcommand" ]; then
2616 __gitcomp
"$save_opts"
2619 if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then
2620 __gitcomp
"$subcommands"
2625 case "$subcommand,$cur" in
2627 __gitcomp
"$save_opts"
2630 __gitcomp
"--index --quiet"
2635 show
,--*|branch
,--*)
2638 if [ $cword -eq 3 ]; then
2641 __gitcomp_nl
"$(__git stash list \
2642 | sed -n -e 's/:.*//p')"
2645 show
,*|apply
,*|drop
,*|pop
,*)
2646 __gitcomp_nl
"$(__git stash list \
2647 | sed -n -e 's/:.*//p')"
2657 __git_has_doubledash
&& return
2659 local subcommands
="add status init deinit update summary foreach sync"
2660 if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then
2663 __gitcomp
"--quiet --cached"
2666 __gitcomp
"$subcommands"
2676 init fetch clone rebase dcommit log find-rev
2677 set-tree commit-diff info create-ignore propget
2678 proplist show-ignore show-externals branch tag blame
2679 migrate mkdirs reset gc
2681 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
2682 if [ -z "$subcommand" ]; then
2683 __gitcomp
"$subcommands"
2685 local remote_opts
="--username= --config-dir= --no-auth-cache"
2687 --follow-parent --authors-file= --repack=
2688 --no-metadata --use-svm-props --use-svnsync-props
2689 --log-window-size= --no-checkout --quiet
2690 --repack-flags --use-log-author --localtime
2691 --ignore-paths= --include-paths= $remote_opts
2694 --template= --shared= --trunk= --tags=
2695 --branches= --stdlayout --minimize-url
2696 --no-metadata --use-svm-props --use-svnsync-props
2697 --rewrite-root= --prefix= --use-log-author
2698 --add-author-from $remote_opts
2701 --edit --rmdir --find-copies-harder --copy-similarity=
2704 case "$subcommand,$cur" in
2706 __gitcomp
"--revision= --fetch-all $fc_opts"
2709 __gitcomp
"--revision= $fc_opts $init_opts"
2712 __gitcomp
"$init_opts"
2716 --merge --strategy= --verbose --dry-run
2717 --fetch-all --no-rebase --commit-url
2718 --revision --interactive $cmt_opts $fc_opts
2722 __gitcomp
"--stdin $cmt_opts $fc_opts"
2724 create-ignore
,--*|propget
,--*|proplist
,--*|show-ignore
,--*|\
2725 show-externals
,--*|mkdirs
,--*)
2726 __gitcomp
"--revision="
2730 --limit= --revision= --verbose --incremental
2731 --oneline --show-commit --non-recursive
2732 --authors-file= --color
2737 --merge --verbose --strategy= --local
2738 --fetch-all --dry-run $fc_opts
2742 __gitcomp
"--message= --file= --revision= $cmt_opts"
2748 __gitcomp
"--dry-run --message --tag"
2751 __gitcomp
"--dry-run --message"
2754 __gitcomp
"--git-format"
2758 --config-dir= --ignore-paths= --minimize
2759 --no-auth-cache --username=
2763 __gitcomp
"--revision= --parent"
2774 while [ $c -lt $cword ]; do
2778 __gitcomp_nl
"$(__git_tags)"
2793 __gitcomp_nl
"$(__git_tags)"
2804 --list --delete --verify --annotate --message --file
2805 --sign --cleanup --local-user --force --column --sort
2806 --contains --points-at
2819 local subcommands
="add list lock prune unlock"
2820 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
2821 if [ -z "$subcommand" ]; then
2822 __gitcomp
"$subcommands"
2824 case "$subcommand,$cur" in
2826 __gitcomp
"--detach"
2829 __gitcomp
"--porcelain"
2832 __gitcomp
"--reason"
2835 __gitcomp
"--dry-run --expire --verbose"
2845 local i c
=1 command __git_dir __git_repo_path
2846 local __git_C_args C_args_count
=0
2848 while [ $c -lt $cword ]; do
2851 --git-dir=*) __git_dir
="${i#--git-dir=}" ;;
2852 --git-dir) ((c
++)) ; __git_dir
="${words[c]}" ;;
2853 --bare) __git_dir
="." ;;
2854 --help) command="help"; break ;;
2855 -c|
--work-tree|
--namespace) ((c
++)) ;;
2856 -C) __git_C_args
[C_args_count
++]=-C
2858 __git_C_args
[C_args_count
++]="${words[c]}"
2861 *) command="$i"; break ;;
2866 if [ -z "$command" ]; then
2868 --git-dir|
-C|
--work-tree)
2869 # these need a path argument, let's fall back to
2870 # Bash filename completion
2874 # we don't support completing these options' arguments
2892 --no-replace-objects
2896 *) __git_compute_porcelain_commands
2897 __gitcomp
"$__git_porcelain_commands $(__git_aliases)" ;;
2902 local completion_func
="_git_${command//-/_}"
2903 declare -f $completion_func >/dev
/null
2>/dev
/null
&& $completion_func && return
2905 local expansion
=$
(__git_aliased_command
"$command")
2906 if [ -n "$expansion" ]; then
2908 completion_func
="_git_${expansion//-/_}"
2909 declare -f $completion_func >/dev
/null
2>/dev
/null
&& $completion_func
2915 __git_has_doubledash
&& return
2917 local __git_repo_path
2918 __git_find_repo_path
2921 if [ -f "$__git_repo_path/MERGE_HEAD" ]; then
2927 $__git_log_common_options
2928 $__git_log_gitk_options
2934 __git_complete_revlist
2937 if [[ -n ${ZSH_VERSION-} ]]; then
2938 echo "WARNING: this script is deprecated, please see git-completion.zsh" 1>&2
2940 autoload
-U +X compinit
&& compinit
2946 local cur_
="${3-$cur}"
2952 local c IFS
=$
' \t\n'
2960 array
[${#array[@]}+1]="$c"
2963 compadd
-Q -S '' -p "${2-}" -a -- array
&& _ret
=0
2974 compadd
-Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
2983 compadd -Q -p "${2-}" -f -- ${=1} && _ret=0
2988 local _ret=1 cur cword prev
2989 cur=${words[CURRENT]}
2990 prev=${words[CURRENT-1]}
2992 emulate ksh -c __${service}_main
2993 let _ret && _default && _ret=0
2997 compdef _git git gitk
3003 local cur words cword prev
3004 _get_comp_words_by_ref -n =: cur words cword prev
3008 # Setup completion for certain functions defined above by setting common
3009 # variables and workarounds.
3010 # This is NOT a public function; use at your own risk.
3013 local wrapper="__git_wrap
${2}"
3014 eval "$wrapper () { __git_func_wrap
$2 ; }"
3015 complete -o bashdefault -o default -o nospace -F $wrapper $1 2>/dev/null \
3016 || complete -o default -o nospace -F $wrapper $1
3019 # wrapper for backwards compatibility
3022 __git_wrap__git_main
3025 # wrapper for backwards compatibility
3028 __git_wrap__gitk_main
3031 __git_complete git __git_main
3032 __git_complete gitk __gitk_main
3034 # The following are necessary only for Cygwin, and only are needed
3035 # when the user has tab-completed the executable name and consequently
3036 # included the '.exe' suffix.
3038 if [ Cygwin = "$
(uname
-o 2>/dev
/null
)" ]; then
3039 __git_complete git.exe __git_main