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_[@]}")
216 # Fills the COMPREPLY array with prefiltered words without any additional
218 # Callers must take care of providing only words that match the current word
219 # to be completed and adding any prefix and/or suffix (trailing space!), if
221 # 1: List of newline-separated matching completion words, complete with
232 local x i
=${#COMPREPLY[@]}
234 if [[ "$x" == "$3"* ]]; then
235 COMPREPLY
[i
++]="$2$x$4"
246 # Generates completion reply, appending a space to possible completion words,
248 # It accepts 1 to 4 arguments:
249 # 1: List of possible completion words.
250 # 2: A prefix to be added to each possible completion word (optional).
251 # 3: Generate possible completion matches for this word (optional).
252 # 4: A suffix to be appended to each possible completion word (optional).
255 local cur_
="${3-$cur}"
261 local c i
=0 IFS
=$
' \t\n'
264 if [[ $c == "$cur_"* ]]; then
269 COMPREPLY
[i
++]="${2-}$c"
276 # Variation of __gitcomp_nl () that appends to the existing list of
277 # completion candidates, COMPREPLY.
278 __gitcomp_nl_append
()
281 __gitcompappend
"$1" "${2-}" "${3-$cur}" "${4- }"
284 # Generates completion reply from newline-separated possible completion words
285 # by appending a space to all of them.
286 # It accepts 1 to 4 arguments:
287 # 1: List of possible completion words, separated by a single newline.
288 # 2: A prefix to be added to each possible completion word (optional).
289 # 3: Generate possible completion matches for this word (optional).
290 # 4: A suffix to be appended to each possible completion word instead of
291 # the default space (optional). If specified but empty, nothing is
296 __gitcomp_nl_append
"$@"
299 # Generates completion reply with compgen from newline-separated possible
300 # completion filenames.
301 # It accepts 1 to 3 arguments:
302 # 1: List of possible completion filenames, separated by a single newline.
303 # 2: A directory prefix to be added to each possible completion filename
305 # 3: Generate possible completion matches for this word (optional).
310 # XXX does not work when the directory prefix contains a tilde,
311 # since tilde expansion is not applied.
312 # This means that COMPREPLY will be empty and Bash default
313 # completion will be used.
314 __gitcompadd
"$1" "${2-}" "${3-$cur}" ""
316 # use a hack to enable file mode in bash < 4
317 compopt
-o filenames
+o nospace
2>/dev
/null ||
318 compgen
-f /non-existing-dir
/ > /dev
/null
321 # Execute 'git ls-files', unless the --committable option is specified, in
322 # which case it runs 'git diff-index' to find out the files that can be
323 # committed. It return paths relative to the directory specified in the first
324 # argument, and using the options specified in the second argument.
325 __git_ls_files_helper
()
327 if [ "$2" == "--committable" ]; then
328 __git
-C "$1" diff-index
--name-only --relative HEAD
330 # NOTE: $2 is not quoted in order to support multiple options
331 __git
-C "$1" ls-files
--exclude-standard $2
336 # __git_index_files accepts 1 or 2 arguments:
337 # 1: Options to pass to ls-files (required).
338 # 2: A directory path (optional).
339 # If provided, only files within the specified directory are listed.
340 # Sub directories are never recursed. Path must have a trailing
344 local root
="${2-.}" file
346 __git_ls_files_helper
"$root" "$1" |
347 while read -r file; do
349 ?
*/*) echo "${file%%/*}" ;;
357 __git for-each-ref
--format='%(refname:strip=2)' refs
/heads
362 __git for-each-ref
--format='%(refname:strip=2)' refs
/tags
365 # Lists refs from the local (by default) or from a remote repository.
366 # It accepts 0, 1 or 2 arguments:
367 # 1: The remote to list refs from (optional; ignored, if set but empty).
368 # Can be the name of a configured remote, a path, or a URL.
369 # 2: In addition to local refs, list unique branches from refs/remotes/ for
370 # 'git checkout's tracking DWIMery (optional; ignored, if set but empty).
371 # 3: A prefix to be added to each listed ref (optional).
372 # 4: List only refs matching this word (optional; list all refs if unset or
374 # 5: A suffix to be appended to each listed ref (optional; ignored, if set
377 # Use __git_complete_refs() instead.
380 local i
hash dir track
="${2-}"
381 local list_refs_from
=path remote
="${1-}"
383 local pfx
="${3-}" cur_="${4-$cur}" sfx="${5-}"
385 local fer_pfx
="${pfx//\%/%%}" # "escape" for-each-ref format specifiers
388 dir
="$__git_repo_path"
390 if [ -z "$remote" ]; then
391 if [ -z "$dir" ]; then
395 if __git_is_configured_remote
"$remote"; then
396 # configured remote takes precedence over a
397 # local directory with the same name
398 list_refs_from
=remote
399 elif [ -d "$remote/.git" ]; then
401 elif [ -d "$remote" ]; then
408 if [ "$list_refs_from" = path
]; then
409 if [[ "$cur_" == ^
* ]]; then
418 refs
=("$match*" "$match*/**")
422 for i
in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD
; do
425 if [ -e "$dir/$i" ]; then
431 format
="refname:strip=2"
432 refs
=("refs/tags/$match*" "refs/tags/$match*/**"
433 "refs/heads/$match*" "refs/heads/$match*/**"
434 "refs/remotes/$match*" "refs/remotes/$match*/**")
437 __git_dir
="$dir" __git for-each-ref
--format="$fer_pfx%($format)$sfx" \
439 if [ -n "$track" ]; then
440 # employ the heuristic used by git checkout
441 # Try to find a remote branch that matches the completion word
442 # but only output if the branch name is unique
443 __git for-each-ref
--format="$fer_pfx%(refname:strip=3)$sfx" \
444 --sort="refname:strip=3" \
445 "refs/remotes/*/$match*" "refs/remotes/*/$match*/**" | \
452 __git ls-remote
"$remote" "$match*" | \
453 while read -r hash i
; do
456 *) echo "$pfx$i$sfx" ;;
461 if [ "$list_refs_from" = remote
]; then
463 $match*) echo "${pfx}HEAD$sfx" ;;
465 __git for-each-ref
--format="$fer_pfx%(refname:strip=3)$sfx" \
466 "refs/remotes/$remote/$match*" \
467 "refs/remotes/$remote/$match*/**"
471 $match*) query_symref
="HEAD" ;;
473 __git ls-remote
"$remote" $query_symref \
474 "refs/tags/$match*" "refs/heads/$match*" \
475 "refs/remotes/$match*" |
476 while read -r hash i
; do
479 refs
/*) echo "$pfx${i#refs/*/}$sfx" ;;
480 *) echo "$pfx$i$sfx" ;; # symbolic refs
488 # Completes refs, short and long, local and remote, symbolic and pseudo.
490 # Usage: __git_complete_refs [<option>]...
491 # --remote=<remote>: The remote to list refs from, can be the name of a
492 # configured remote, a path, or a URL.
493 # --track: List unique remote branches for 'git checkout's tracking DWIMery.
494 # --pfx=<prefix>: A prefix to be added to each ref.
495 # --cur=<word>: The current ref to be completed. Defaults to the current
496 # word to be completed.
497 # --sfx=<suffix>: A suffix to be appended to each ref instead of the default
499 __git_complete_refs
()
501 local remote track pfx cur_
="$cur" sfx
=" "
503 while test $# != 0; do
505 --remote=*) remote
="${1##--remote=}" ;;
506 --track) track
="yes" ;;
507 --pfx=*) pfx
="${1##--pfx=}" ;;
508 --cur=*) cur_
="${1##--cur=}" ;;
509 --sfx=*) sfx
="${1##--sfx=}" ;;
515 __gitcomp_direct
"$(__git_refs "$remote" "$track" "$pfx" "$cur_" "$sfx")"
518 # __git_refs2 requires 1 argument (to pass to __git_refs)
519 # Deprecated: use __git_complete_fetch_refspecs() instead.
523 for i
in $
(__git_refs
"$1"); do
528 # Completes refspecs for fetching from a remote repository.
529 # 1: The remote repository.
530 # 2: A prefix to be added to each listed refspec (optional).
531 # 3: The ref to be completed as a refspec instead of the current word to be
532 # completed (optional)
533 # 4: A suffix to be appended to each listed refspec instead of the default
535 __git_complete_fetch_refspecs
()
537 local i remote
="$1" pfx
="${2-}" cur_="${3-$cur}" sfx="${4- }"
540 for i in $(__git_refs "$remote" "" "" "$cur_") ; do
543 )" "$pfx" "$cur_" "$sfx"
546 # __git_refs_remotes requires 1 argument (to pass to ls-remote)
547 __git_refs_remotes
()
550 __git ls-remote
"$1" 'refs/heads/*' | \
551 while read -r hash i
; do
552 echo "$i:refs/remotes/$1/${i#refs/heads/}"
559 test -d "$__git_repo_path/remotes" && ls -1 "$__git_repo_path/remotes"
563 # Returns true if $1 matches the name of a configured remote, false otherwise.
564 __git_is_configured_remote
()
567 for remote
in $
(__git_remotes
); do
568 if [ "$remote" = "$1" ]; then
575 __git_list_merge_strategies
()
577 git merge
-s help 2>&1 |
578 sed -n -e '/[Aa]vailable strategies are: /,/^$/{
587 __git_merge_strategies
=
588 # 'git merge -s help' (and thus detection of the merge strategy
589 # list) fails, unfortunately, if run outside of any git working
590 # tree. __git_merge_strategies is set to the empty string in
591 # that case, and the detection will be repeated the next time it
593 __git_compute_merge_strategies
()
595 test -n "$__git_merge_strategies" ||
596 __git_merge_strategies
=$
(__git_list_merge_strategies
)
599 __git_complete_revlist_file
()
601 local pfx
ls ref cur_
="$cur"
621 case "$COMP_WORDBREAKS" in
623 *) pfx
="$ref:$pfx" ;;
626 __gitcomp_nl
"$(__git ls-tree "$ls" \
627 | sed '/^100... blob /{
643 pfx
="${cur_%...*}..."
645 __git_complete_refs
--pfx="$pfx" --cur="$cur_"
650 __git_complete_refs
--pfx="$pfx" --cur="$cur_"
659 # __git_complete_index_file requires 1 argument:
660 # 1: the options to pass to ls-file
662 # The exception is --committable, which finds the files appropriate commit.
663 __git_complete_index_file
()
665 local pfx
="" cur_
="$cur"
675 __gitcomp_file
"$(__git_index_files "$1" ${pfx:+"$pfx"})" "$pfx" "$cur_"
678 __git_complete_file
()
680 __git_complete_revlist_file
683 __git_complete_revlist
()
685 __git_complete_revlist_file
688 __git_complete_remote_or_refspec
()
690 local cur_
="$cur" cmd
="${words[1]}"
691 local i c
=2 remote
="" pfx
="" lhs
=1 no_complete_refspec
=0
692 if [ "$cmd" = "remote" ]; then
695 while [ $c -lt $cword ]; do
698 --mirror) [ "$cmd" = "push" ] && no_complete_refspec
=1 ;;
701 push
) no_complete_refspec
=1 ;;
709 *) remote
="$i"; break ;;
713 if [ -z "$remote" ]; then
714 __gitcomp_nl
"$(__git_remotes)"
717 if [ $no_complete_refspec = 1 ]; then
720 [ "$remote" = "." ] && remote
=
723 case "$COMP_WORDBREAKS" in
725 *) pfx
="${cur_%%:*}:" ;;
737 if [ $lhs = 1 ]; then
738 __git_complete_fetch_refspecs
"$remote" "$pfx" "$cur_"
740 __git_complete_refs
--pfx="$pfx" --cur="$cur_"
744 if [ $lhs = 1 ]; then
745 __git_complete_refs
--remote="$remote" --pfx="$pfx" --cur="$cur_"
747 __git_complete_refs
--pfx="$pfx" --cur="$cur_"
751 if [ $lhs = 1 ]; then
752 __git_complete_refs
--pfx="$pfx" --cur="$cur_"
754 __git_complete_refs
--remote="$remote" --pfx="$pfx" --cur="$cur_"
760 __git_complete_strategy
()
762 __git_compute_merge_strategies
765 __gitcomp
"$__git_merge_strategies"
770 __gitcomp
"$__git_merge_strategies" "" "${cur##--strategy=}"
778 if test -n "${GIT_TESTING_COMMAND_COMPLETION:-}"
780 printf "%s" "${GIT_TESTING_COMMAND_COMPLETION}"
782 git
help -a|
egrep '^ [a-zA-Z0-9]'
786 __git_list_all_commands
()
789 for i
in $
(__git_commands
)
792 *--*) : helper pattern
;;
799 __git_compute_all_commands
()
801 test -n "$__git_all_commands" ||
802 __git_all_commands
=$
(__git_list_all_commands
)
805 __git_list_porcelain_commands
()
808 __git_compute_all_commands
809 for i
in $__git_all_commands
812 *--*) : helper pattern
;;
813 applymbox
) : ask gittus
;;
814 applypatch
) : ask gittus
;;
815 archimport
) : import
;;
816 cat-file
) : plumbing
;;
817 check-attr
) : plumbing
;;
818 check-ignore
) : plumbing
;;
819 check-mailmap
) : plumbing
;;
820 check-ref-format
) : plumbing
;;
821 checkout-index
) : plumbing
;;
822 column) : internal helper
;;
823 commit-tree
) : plumbing
;;
824 count-objects
) : infrequent
;;
825 credential
) : credentials
;;
826 credential-
*) : credentials helper
;;
827 cvsexportcommit
) : export;;
828 cvsimport
) : import
;;
829 cvsserver
) : daemon
;;
831 diff-files
) : plumbing
;;
832 diff-index
) : plumbing
;;
833 diff-tree
) : plumbing
;;
834 fast-import
) : import
;;
835 fast-export
) : export;;
836 fsck-objects
) : plumbing
;;
837 fetch-pack
) : plumbing
;;
838 fmt-merge-msg
) : plumbing
;;
839 for-each-ref
) : plumbing
;;
840 hash-object
) : plumbing
;;
841 http-
*) : transport
;;
842 index-pack
) : plumbing
;;
843 init-db
) : deprecated
;;
844 local-fetch
) : plumbing
;;
845 ls-files
) : plumbing
;;
846 ls-remote
) : plumbing
;;
847 ls-tree
) : plumbing
;;
848 mailinfo
) : plumbing
;;
849 mailsplit
) : plumbing
;;
850 merge-
*) : plumbing
;;
853 pack-objects
) : plumbing
;;
854 pack-redundant
) : plumbing
;;
855 pack-refs
) : plumbing
;;
856 parse-remote
) : plumbing
;;
857 patch-id
) : plumbing
;;
859 prune-packed
) : plumbing
;;
860 quiltimport
) : import
;;
861 read-tree
) : plumbing
;;
862 receive-pack
) : plumbing
;;
863 remote-
*) : transport
;;
865 rev-list
) : plumbing
;;
866 rev-parse
) : plumbing
;;
867 runstatus
) : plumbing
;;
868 sh-setup
) : internal
;;
870 show-ref
) : plumbing
;;
871 send-pack
) : plumbing
;;
872 show-index
) : plumbing
;;
874 stripspace
) : plumbing
;;
875 symbolic-ref
) : plumbing
;;
876 unpack-file
) : plumbing
;;
877 unpack-objects
) : plumbing
;;
878 update-index
) : plumbing
;;
879 update-ref
) : plumbing
;;
880 update-server-info
) : daemon
;;
881 upload-archive
) : plumbing
;;
882 upload-pack
) : plumbing
;;
883 write-tree
) : plumbing
;;
885 verify-pack
) : infrequent
;;
886 verify-tag
) : plumbing
;;
892 __git_porcelain_commands
=
893 __git_compute_porcelain_commands
()
895 test -n "$__git_porcelain_commands" ||
896 __git_porcelain_commands
=$
(__git_list_porcelain_commands
)
899 # Lists all set config variables starting with the given section prefix,
900 # with the prefix removed.
901 __git_get_config_variables
()
903 local section
="$1" i IFS
=$
'\n'
904 for i
in $
(__git config
--name-only --get-regexp "^$section\..*"); do
905 echo "${i#$section.}"
909 __git_pretty_aliases
()
911 __git_get_config_variables
"pretty"
916 __git_get_config_variables
"alias"
919 # __git_aliased_command requires 1 argument
920 __git_aliased_command
()
922 local word cmdline
=$
(__git config
--get "alias.$1")
923 for word
in $cmdline; do
929 \
!*) : shell
command alias ;;
931 *=*) : setting env
;;
933 \
(\
)) : skip parens of shell
function definition
;;
934 {) : skip start of shell helper
function ;;
935 :) : skip null
command ;;
936 \'*) : skip opening quote after sh
-c ;;
944 # __git_find_on_cmdline requires 1 argument
945 __git_find_on_cmdline
()
947 local word subcommand c
=1
948 while [ $c -lt $cword ]; do
950 for subcommand
in $1; do
951 if [ "$subcommand" = "$word" ]; then
960 # Echo the value of an option set on the command line or config
962 # $1: short option name
963 # $2: long option name including =
964 # $3: list of possible values
965 # $4: config string (optional)
968 # result="$(__git_get_option_value "-d" "--do-something=" \
969 # "yes no" "core.doSomething")"
971 # result is then either empty (no option set) or "yes" or "no"
973 # __git_get_option_value requires 3 arguments
974 __git_get_option_value
()
976 local c short_opt long_opt val
977 local result
= values config_key word
985 while [ $c -ge 0 ]; do
987 for val
in $values; do
988 if [ "$short_opt$val" = "$word" ] ||
989 [ "$long_opt$val" = "$word" ]; then
997 if [ -n "$config_key" ] && [ -z "$result" ]; then
998 result
="$(__git config "$config_key")"
1004 __git_has_doubledash
()
1007 while [ $c -lt $cword ]; do
1008 if [ "--" = "${words[c]}" ]; then
1016 # Try to count non option arguments passed on the command line for the
1017 # specified git command.
1018 # When options are used, it is necessary to use the special -- option to
1019 # tell the implementation were non option arguments begin.
1020 # XXX this can not be improved, since options can appear everywhere, as
1024 # __git_count_arguments requires 1 argument: the git command executed.
1025 __git_count_arguments
()
1029 # Skip "git" (first argument)
1030 for ((i
=1; i
< ${#words[@]}; i
++)); do
1035 # Good; we can assume that the following are only non
1040 # Skip the specified git command and discard git
1053 __git_whitespacelist
="nowarn warn error error-all fix"
1057 __git_find_repo_path
1058 if [ -d "$__git_repo_path"/rebase-apply
]; then
1059 __gitcomp
"--skip --continue --resolved --abort"
1064 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
1069 --3way --committer-date-is-author-date --ignore-date
1070 --ignore-whitespace --ignore-space-change
1071 --interactive --keep --no-utf8 --signoff --utf8
1072 --whitespace= --scissors
1082 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
1087 --stat --numstat --summary --check --index
1088 --cached --index-info --reverse --reject --unidiff-zero
1089 --apply --no-add --exclude=
1090 --ignore-whitespace --ignore-space-change
1091 --whitespace= --inaccurate-eof --verbose
1102 --interactive --refresh --patch --update --dry-run
1103 --ignore-errors --intent-to-add
1108 # XXX should we check for --update and --all options ?
1109 __git_complete_index_file
"--others --modified --directory --no-empty-directory"
1116 __gitcomp
"$(git archive --list)" "" "${cur##--format=}"
1120 __gitcomp_nl
"$(__git_remotes)" "" "${cur##--remote=}"
1125 --format= --list --verbose
1126 --prefix= --remote= --exec=
1136 __git_has_doubledash
&& return
1138 local subcommands
="start bad good skip reset visualize replay log run"
1139 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
1140 if [ -z "$subcommand" ]; then
1141 __git_find_repo_path
1142 if [ -f "$__git_repo_path"/BISECT_START
]; then
1143 __gitcomp
"$subcommands"
1145 __gitcomp
"replay start"
1150 case "$subcommand" in
1151 bad|good|
reset|skip|start
)
1161 local i c
=1 only_local_ref
="n" has_r
="n"
1163 while [ $c -lt $cword ]; do
1166 -d|
--delete|
-m|
--move) only_local_ref
="y" ;;
1167 -r|
--remotes) has_r
="y" ;;
1173 --set-upstream-to=*)
1174 __git_complete_refs
--cur="${cur##--set-upstream-to=}"
1178 --color --no-color --verbose --abbrev= --no-abbrev
1179 --track --no-track --contains --merged --no-merged
1180 --set-upstream-to= --edit-description --list
1181 --unset-upstream --delete --move --remotes
1185 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
1186 __gitcomp_nl
"$(__git_heads)"
1196 local cmd
="${words[2]}"
1199 __gitcomp
"create list-heads verify unbundle"
1202 # looking for a file
1207 __git_complete_revlist
1216 __git_has_doubledash
&& return
1220 __gitcomp
"diff3 merge" "" "${cur##--conflict=}"
1224 --quiet --ours --theirs --track --no-track --merge
1225 --conflict= --orphan --patch
1229 # check if --track, --no-track, or --no-guess was specified
1230 # if so, disable DWIM mode
1231 local flags
="--track --no-track --no-guess" track_opt
="--track"
1232 if [ -n "$(__git_find_on_cmdline "$flags")" ]; then
1235 __git_complete_refs
$track_opt
1247 __git_find_repo_path
1248 if [ -f "$__git_repo_path"/CHERRY_PICK_HEAD
]; then
1249 __gitcomp
"--continue --quit --abort"
1254 __gitcomp
"--edit --no-commit --signoff --strategy= --mainline"
1266 __gitcomp
"--dry-run --quiet"
1271 # XXX should we check for -x option ?
1272 __git_complete_index_file
"--others --directory"
1294 --recurse-submodules
1301 __git_untracked_file_modes
="all no normal"
1314 __gitcomp
"default scissors strip verbatim whitespace
1315 " "" "${cur##--cleanup=}"
1318 --reuse-message=*|
--reedit-message=*|\
1319 --fixup=*|
--squash=*)
1320 __git_complete_refs
--cur="${cur#*=}"
1323 --untracked-files=*)
1324 __gitcomp
"$__git_untracked_file_modes" "" "${cur##--untracked-files=}"
1329 --all --author= --signoff --verify --no-verify
1331 --amend --include --only --interactive
1332 --dry-run --reuse-message= --reedit-message=
1333 --reset-author --file= --message= --template=
1334 --cleanup= --untracked-files --untracked-files=
1335 --verbose --quiet --fixup= --squash=
1340 if __git rev-parse
--verify --quiet HEAD
>/dev
/null
; then
1341 __git_complete_index_file
"--committable"
1343 # This is the first commit
1344 __git_complete_index_file
"--cached"
1353 --all --tags --contains --abbrev= --candidates=
1354 --exact-match --debug --long --match --always
1361 __git_diff_algorithms
="myers minimal patience histogram"
1363 __git_diff_submodule_formats
="diff log short"
1365 __git_diff_common_options
="--stat --numstat --shortstat --summary
1366 --patch-with-stat --name-only --name-status --color
1367 --no-color --color-words --no-renames --check
1368 --full-index --binary --abbrev --diff-filter=
1369 --find-copies-harder
1370 --text --ignore-space-at-eol --ignore-space-change
1371 --ignore-all-space --ignore-blank-lines --exit-code
1372 --quiet --ext-diff --no-ext-diff
1373 --no-prefix --src-prefix= --dst-prefix=
1374 --inter-hunk-context=
1375 --patience --histogram --minimal
1376 --raw --word-diff --word-diff-regex=
1377 --dirstat --dirstat= --dirstat-by-file
1378 --dirstat-by-file= --cumulative
1380 --submodule --submodule=
1385 __git_has_doubledash
&& return
1389 __gitcomp
"$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
1393 __gitcomp
"$__git_diff_submodule_formats" "" "${cur##--submodule=}"
1397 __gitcomp
"--cached --staged --pickaxe-all --pickaxe-regex
1398 --base --ours --theirs --no-index
1399 $__git_diff_common_options
1404 __git_complete_revlist_file
1407 __git_mergetools_common
="diffuse diffmerge ecmerge emerge kdiff3 meld opendiff
1408 tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc codecompare
1413 __git_has_doubledash
&& return
1417 __gitcomp
"$__git_mergetools_common kompare" "" "${cur##--tool=}"
1421 __gitcomp
"--cached --staged --pickaxe-all --pickaxe-regex
1422 --base --ours --theirs
1423 --no-renames --diff-filter= --find-copies-harder
1424 --relative --ignore-submodules
1429 __git_complete_revlist_file
1432 __git_fetch_recurse_submodules
="yes on-demand no"
1434 __git_fetch_options
="
1435 --quiet --verbose --append --upload-pack --force --keep --depth=
1436 --tags --no-tags --all --prune --dry-run --recurse-submodules=
1442 --recurse-submodules=*)
1443 __gitcomp
"$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}"
1447 __gitcomp
"$__git_fetch_options"
1451 __git_complete_remote_or_refspec
1454 __git_format_patch_options
="
1455 --stdout --attach --no-attach --thread --thread= --no-thread
1456 --numbered --start-number --numbered-files --keep-subject --signoff
1457 --signature --no-signature --in-reply-to= --cc= --full-index --binary
1458 --not --all --cover-letter --no-prefix --src-prefix= --dst-prefix=
1459 --inline --suffix= --ignore-if-in-upstream --subject-prefix=
1460 --output-directory --reroll-count --to= --quiet --notes
1463 _git_format_patch
()
1469 " "" "${cur##--thread=}"
1473 __gitcomp
"$__git_format_patch_options"
1477 __git_complete_revlist
1485 --tags --root --unreachable --cache --no-reflogs --full
1486 --strict --verbose --lost-found
1497 __gitcomp
"--prune --aggressive"
1508 __git_match_ctag
() {
1509 awk "/^${1//\//\\/}/ { print \$1 }" "$2"
1514 __git_has_doubledash
&& return
1520 --text --ignore-case --word-regexp --invert-match
1521 --full-name --line-number
1522 --extended-regexp --basic-regexp --fixed-strings
1525 --files-with-matches --name-only
1526 --files-without-match
1529 --and --or --not --all-match
1535 case "$cword,$prev" in
1537 if test -r tags
; then
1538 __gitcomp_nl
"$(__git_match_ctag "$cur" tags)"
1551 __gitcomp
"--all --guides --info --man --web"
1555 __git_compute_all_commands
1556 __gitcomp
"$__git_all_commands $(__git_aliases)
1557 attributes cli core-tutorial cvs-migration
1558 diffcore everyday gitk glossary hooks ignore modules
1559 namespaces repository-layout revisions tutorial tutorial-2
1569 false true umask group all world everybody
1570 " "" "${cur##--shared=}"
1574 __gitcomp
"--quiet --bare --template= --shared --shared="
1584 __gitcomp
"--cached --deleted --modified --others --ignored
1585 --stage --directory --no-empty-directory --unmerged
1586 --killed --exclude= --exclude-from=
1587 --exclude-per-directory= --exclude-standard
1588 --error-unmatch --with-tree= --full-name
1589 --abbrev --ignored --exclude-per-directory
1595 # XXX ignore options like --modified and always suggest all cached
1597 __git_complete_index_file
"--cached"
1602 __gitcomp_nl
"$(__git_remotes)"
1610 # Options that go well for log, shortlog and gitk
1611 __git_log_common_options
="
1613 --branches --tags --remotes
1614 --first-parent --merges --no-merges
1616 --max-age= --since= --after=
1617 --min-age= --until= --before=
1618 --min-parents= --max-parents=
1619 --no-min-parents --no-max-parents
1621 # Options that go well for log and gitk (not shortlog)
1622 __git_log_gitk_options
="
1623 --dense --sparse --full-history
1624 --simplify-merges --simplify-by-decoration
1625 --left-right --notes --no-notes
1627 # Options that go well for log and shortlog (not gitk)
1628 __git_log_shortlog_options
="
1629 --author= --committer= --grep=
1630 --all-match --invert-grep
1633 __git_log_pretty_formats
="oneline short medium full fuller email raw format:"
1634 __git_log_date_formats
="relative iso8601 rfc2822 short local default raw"
1638 __git_has_doubledash
&& return
1639 __git_find_repo_path
1642 if [ -f "$__git_repo_path/MERGE_HEAD" ]; then
1646 --pretty=*|
--format=*)
1647 __gitcomp
"$__git_log_pretty_formats $(__git_pretty_aliases)
1652 __gitcomp
"$__git_log_date_formats" "" "${cur##--date=}"
1656 __gitcomp
"full short no" "" "${cur##--decorate=}"
1660 __gitcomp
"$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
1664 __gitcomp
"$__git_diff_submodule_formats" "" "${cur##--submodule=}"
1669 $__git_log_common_options
1670 $__git_log_shortlog_options
1671 $__git_log_gitk_options
1672 --root --topo-order --date-order --reverse
1673 --follow --full-diff
1674 --abbrev-commit --abbrev=
1675 --relative-date --date=
1676 --pretty= --format= --oneline
1681 --decorate --decorate=
1683 --parents --children
1685 $__git_diff_common_options
1686 --pickaxe-all --pickaxe-regex
1691 __git_complete_revlist
1694 # Common merge options shared by git-merge(1) and git-pull(1).
1695 __git_merge_options
="
1696 --no-commit --no-stat --log --no-log --squash --strategy
1697 --commit --stat --no-squash --ff --no-ff --ff-only --edit --no-edit
1698 --verify-signatures --no-verify-signatures --gpg-sign
1699 --quiet --verbose --progress --no-progress
1704 __git_complete_strategy
&& return
1708 __gitcomp
"$__git_merge_options
1709 --rerere-autoupdate --no-rerere-autoupdate --abort --continue"
1719 __gitcomp
"$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"
1733 __gitcomp
"--octopus --independent --is-ancestor --fork-point"
1744 __gitcomp
"--dry-run"
1749 if [ $
(__git_count_arguments
"mv") -gt 0 ]; then
1750 # We need to show both cached and untracked files (including
1751 # empty directories) since this may not be the last argument.
1752 __git_complete_index_file
"--cached --others --directory"
1754 __git_complete_index_file
"--cached"
1760 __gitcomp
"--tags --all --stdin"
1765 local subcommands
='add append copy edit list prune remove show'
1766 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
1768 case "$subcommand,$cur" in
1778 __gitcomp
"$subcommands --ref"
1782 add
,--reuse-message=*|append
,--reuse-message=*|\
1783 add
,--reedit-message=*|append
,--reedit-message=*)
1784 __git_complete_refs
--cur="${cur#*=}"
1787 __gitcomp
'--file= --message= --reedit-message=
1794 __gitcomp
'--dry-run --verbose'
1812 __git_complete_strategy
&& return
1815 --recurse-submodules=*)
1816 __gitcomp
"$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}"
1821 --rebase --no-rebase
1822 $__git_merge_options
1823 $__git_fetch_options
1828 __git_complete_remote_or_refspec
1831 __git_push_recurse_submodules
="check on-demand"
1833 __git_complete_force_with_lease
()
1841 __git_complete_refs
--cur="${cur_#*:}"
1844 __git_complete_refs
--cur="$cur_"
1853 __gitcomp_nl
"$(__git_remotes)"
1856 --recurse-submodules)
1857 __gitcomp
"$__git_push_recurse_submodules"
1863 __gitcomp_nl
"$(__git_remotes)" "" "${cur##--repo=}"
1866 --recurse-submodules=*)
1867 __gitcomp
"$__git_push_recurse_submodules" "" "${cur##--recurse-submodules=}"
1870 --force-with-lease=*)
1871 __git_complete_force_with_lease
"${cur##--force-with-lease=}"
1876 --all --mirror --tags --dry-run --force --verbose
1877 --quiet --prune --delete --follow-tags
1878 --receive-pack= --repo= --set-upstream
1879 --force-with-lease --force-with-lease= --recurse-submodules=
1884 __git_complete_remote_or_refspec
1889 __git_find_repo_path
1890 if [ -f "$__git_repo_path"/rebase-merge
/interactive
]; then
1891 __gitcomp
"--continue --skip --abort --quit --edit-todo"
1893 elif [ -d "$__git_repo_path"/rebase-apply
] || \
1894 [ -d "$__git_repo_path"/rebase-merge
]; then
1895 __gitcomp
"--continue --skip --abort --quit"
1898 __git_complete_strategy
&& return
1901 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
1906 --onto --merge --strategy --interactive
1907 --preserve-merges --stat --no-stat
1908 --committer-date-is-author-date --ignore-date
1909 --ignore-whitespace --whitespace=
1910 --autosquash --no-autosquash
1911 --fork-point --no-fork-point
1912 --autostash --no-autostash
1913 --verify --no-verify
1914 --keep-empty --root --force-rebase --no-ff
1925 local subcommands
="show delete expire"
1926 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
1928 if [ -z "$subcommand" ]; then
1929 __gitcomp
"$subcommands"
1935 __git_send_email_confirm_options
="always never auto cc compose"
1936 __git_send_email_suppresscc_options
="author self cc bodycc sob cccmd body all"
1941 --to|
--cc|
--bcc|
--from)
1942 __gitcomp
"$(__git send-email --dump-aliases)"
1950 $__git_send_email_confirm_options
1951 " "" "${cur##--confirm=}"
1956 $__git_send_email_suppresscc_options
1957 " "" "${cur##--suppress-cc=}"
1961 --smtp-encryption=*)
1962 __gitcomp
"ssl tls" "" "${cur##--smtp-encryption=}"
1968 " "" "${cur##--thread=}"
1971 --to=*|
--cc=*|
--bcc=*|
--from=*)
1972 __gitcomp
"$(__git send-email --dump-aliases)" "" "${cur#--*=}"
1976 __gitcomp
"--annotate --bcc --cc --cc-cmd --chain-reply-to
1977 --compose --confirm= --dry-run --envelope-sender
1979 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
1980 --no-suppress-from --no-thread --quiet
1981 --signed-off-by-cc --smtp-pass --smtp-server
1982 --smtp-server-port --smtp-encryption= --smtp-user
1983 --subject --suppress-cc= --suppress-from --thread --to
1984 --validate --no-validate
1985 $__git_format_patch_options"
1989 __git_complete_revlist
2000 local untracked_state
2003 --ignore-submodules=*)
2004 __gitcomp
"none untracked dirty all" "" "${cur##--ignore-submodules=}"
2007 --untracked-files=*)
2008 __gitcomp
"$__git_untracked_file_modes" "" "${cur##--untracked-files=}"
2013 always never auto column row plain dense nodense
2014 " "" "${cur##--column=}"
2019 --short --branch --porcelain --long --verbose
2020 --untracked-files= --ignore-submodules= --ignored
2021 --column= --no-column
2027 untracked_state
="$(__git_get_option_value "-u" "--untracked-files=" \
2028 "$__git_untracked_file_modes" "status.showUntrackedFiles
")"
2030 case "$untracked_state" in
2032 # --ignored option does not matter
2036 complete_opt
="--cached --directory --no-empty-directory --others"
2038 if [ -n "$(__git_find_on_cmdline "--ignored")" ]; then
2039 complete_opt
="$complete_opt --ignored --exclude=*"
2044 __git_complete_index_file
"$complete_opt"
2047 __git_config_get_set_variables
()
2049 local prevword word config_file
= c
=$cword
2050 while [ $c -gt 1 ]; do
2053 --system|
--global|
--local|
--file=*)
2058 config_file
="$word $prevword"
2066 __git config
$config_file --name-only --list
2072 branch.
*.remote|branch.
*.pushremote
)
2073 __gitcomp_nl
"$(__git_remotes)"
2081 __gitcomp
"false true preserve interactive"
2085 __gitcomp_nl
"$(__git_remotes)"
2089 local remote
="${prev#remote.}"
2090 remote
="${remote%.fetch}"
2091 if [ -z "$cur" ]; then
2092 __gitcomp_nl
"refs/heads/" "" "" ""
2095 __gitcomp_nl
"$(__git_refs_remotes "$remote")"
2099 local remote
="${prev#remote.}"
2100 remote
="${remote%.push}"
2101 __gitcomp_nl
"$(__git for-each-ref \
2102 --format='%(refname):%(refname)' refs/heads)"
2105 pull.twohead|pull.octopus
)
2106 __git_compute_merge_strategies
2107 __gitcomp
"$__git_merge_strategies"
2110 color.branch|color.
diff|color.interactive|\
2111 color.showbranch|color.status|color.ui
)
2112 __gitcomp
"always never auto"
2116 __gitcomp
"false true"
2121 normal black red green yellow blue magenta cyan white
2122 bold dim ul blink reverse
2127 __gitcomp
"log short"
2131 __gitcomp
"man info web html"
2135 __gitcomp
"$__git_log_date_formats"
2138 sendemail.aliasesfiletype
)
2139 __gitcomp
"mutt mailrc pine elm gnus"
2143 __gitcomp
"$__git_send_email_confirm_options"
2146 sendemail.suppresscc
)
2147 __gitcomp
"$__git_send_email_suppresscc_options"
2150 sendemail.transferencoding
)
2151 __gitcomp
"7bit 8bit quoted-printable base64"
2154 --get|
--get-all|
--unset|
--unset-all)
2155 __gitcomp_nl
"$(__git_config_get_set_variables)"
2165 --system --global --local --file=
2166 --list --replace-all
2167 --get --get-all --get-regexp
2168 --add --unset --unset-all
2169 --remove-section --rename-section
2175 local pfx
="${cur%.*}." cur_
="${cur##*.}"
2176 __gitcomp
"remote pushremote merge mergeoptions rebase" "$pfx" "$cur_"
2180 local pfx
="${cur%.*}." cur_
="${cur#*.}"
2181 __gitcomp_nl
"$(__git_heads)" "$pfx" "$cur_" "."
2182 __gitcomp_nl_append $
'autosetupmerge\nautosetuprebase\n' "$pfx" "$cur_"
2186 local pfx
="${cur%.*}." cur_
="${cur##*.}"
2188 argprompt cmd confirm needsfile noconsole norescan
2189 prompt revprompt revunmerged title
2194 local pfx
="${cur%.*}." cur_
="${cur##*.}"
2195 __gitcomp
"cmd path" "$pfx" "$cur_"
2199 local pfx
="${cur%.*}." cur_
="${cur##*.}"
2200 __gitcomp
"cmd path" "$pfx" "$cur_"
2204 local pfx
="${cur%.*}." cur_
="${cur##*.}"
2205 __gitcomp
"cmd path trustExitCode" "$pfx" "$cur_"
2209 local pfx
="${cur%.*}." cur_
="${cur#*.}"
2210 __git_compute_all_commands
2211 __gitcomp_nl
"$__git_all_commands" "$pfx" "$cur_"
2215 local pfx
="${cur%.*}." cur_
="${cur##*.}"
2217 url proxy fetch push mirror skipDefaultUpdate
2218 receivepack uploadpack tagopt pushurl
2223 local pfx
="${cur%.*}." cur_
="${cur#*.}"
2224 __gitcomp_nl
"$(__git_remotes)" "$pfx" "$cur_" "."
2225 __gitcomp_nl_append
"pushdefault" "$pfx" "$cur_"
2229 local pfx
="${cur%.*}." cur_
="${cur##*.}"
2230 __gitcomp
"insteadOf pushInsteadOf" "$pfx" "$cur_"
2236 advice.commitBeforeMerge
2238 advice.implicitIdentity
2239 advice.pushNonFastForward
2240 advice.resolveConflict
2244 apply.ignorewhitespace
2246 branch.autosetupmerge
2247 branch.autosetuprebase
2251 color.branch.current
2256 color.decorate.branch
2257 color.decorate.remoteBranch
2258 color.decorate.stash
2268 color.diff.whitespace
2273 color.grep.linenumber
2276 color.grep.separator
2278 color.interactive.error
2279 color.interactive.header
2280 color.interactive.help
2281 color.interactive.prompt
2286 color.status.changed
2288 color.status.nobranch
2289 color.status.unmerged
2290 color.status.untracked
2291 color.status.updated
2300 core.bigFileThreshold
2303 core.deltaBaseCacheLimit
2308 core.fsyncobjectfiles
2312 core.logAllRefUpdates
2313 core.loosecompression
2316 core.packedGitWindowSize
2318 core.preferSymlinkRefs
2321 core.repositoryFormatVersion
2323 core.sharedRepository
2328 core.warnAmbiguousRefs
2331 diff.autorefreshindex
2333 diff.ignoreSubmodules
2340 diff.suppressBlankEmpty
2346 fetch.recurseSubmodules
2357 format.subjectprefix
2368 gc.reflogexpireunreachable
2372 gitcvs.commitmsgannotation
2373 gitcvs.dbTableNamePrefix
2384 gui.copyblamethreshold
2388 gui.matchtrackingbranch
2389 gui.newbranchtemplate
2390 gui.pruneduringfetch
2391 gui.spellingdictionary
2408 http.sslCertPasswordProtected
2413 i18n.logOutputEncoding
2419 imap.preformattedHTML
2429 interactive.singlekey
2445 mergetool.keepBackup
2446 mergetool.keepTemporaries
2451 notes.rewrite.rebase
2455 pack.deltaCacheLimit
2472 receive.denyCurrentBranch
2473 receive.denyDeleteCurrent
2475 receive.denyNonFastForwards
2478 receive.updateserverinfo
2481 repack.usedeltabaseoffset
2485 sendemail.aliasesfile
2486 sendemail.aliasfiletype
2490 sendemail.chainreplyto
2492 sendemail.envelopesender
2496 sendemail.signedoffbycc
2497 sendemail.smtpdomain
2498 sendemail.smtpencryption
2500 sendemail.smtpserver
2501 sendemail.smtpserveroption
2502 sendemail.smtpserverport
2504 sendemail.suppresscc
2505 sendemail.suppressfrom
2510 status.relativePaths
2511 status.showUntrackedFiles
2512 status.submodulesummary
2515 transfer.unpackLimit
2527 local subcommands
="add rename remove set-head set-branches set-url show prune update"
2528 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
2529 if [ -z "$subcommand" ]; then
2530 __gitcomp
"$subcommands"
2534 case "$subcommand" in
2535 rename|remove|set-url|show|prune
)
2536 __gitcomp_nl
"$(__git_remotes)"
2538 set-head|set-branches
)
2539 __git_complete_remote_or_refspec
2542 __gitcomp
"$(__git_get_config_variables "remotes
")"
2556 __git_has_doubledash
&& return
2560 __gitcomp
"--merge --mixed --hard --soft --patch"
2569 __git_find_repo_path
2570 if [ -f "$__git_repo_path"/REVERT_HEAD
]; then
2571 __gitcomp
"--continue --quit --abort"
2576 __gitcomp
"--edit --mainline --no-edit --no-commit --signoff"
2587 __gitcomp
"--cached --dry-run --ignore-unmatch --quiet"
2592 __git_complete_index_file
"--cached"
2597 __git_has_doubledash
&& return
2602 $__git_log_common_options
2603 $__git_log_shortlog_options
2604 --numbered --summary
2609 __git_complete_revlist
2614 __git_has_doubledash
&& return
2617 --pretty=*|
--format=*)
2618 __gitcomp
"$__git_log_pretty_formats $(__git_pretty_aliases)
2623 __gitcomp
"$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
2627 __gitcomp
"$__git_diff_submodule_formats" "" "${cur##--submodule=}"
2631 __gitcomp
"--pretty= --format= --abbrev-commit --oneline
2633 $__git_diff_common_options
2638 __git_complete_revlist_file
2646 --all --remotes --topo-order --date-order --current --more=
2647 --list --independent --merge-base --no-name
2649 --sha1-name --sparse --topics --reflog
2654 __git_complete_revlist
2659 local save_opts
='--all --keep-index --no-keep-index --quiet --patch --include-untracked'
2660 local subcommands
='save list show apply clear drop pop create branch'
2661 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
2662 if [ -z "$subcommand" ]; then
2665 __gitcomp
"$save_opts"
2668 if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then
2669 __gitcomp
"$subcommands"
2674 case "$subcommand,$cur" in
2676 __gitcomp
"$save_opts"
2679 __gitcomp
"--index --quiet"
2684 show
,--*|branch
,--*)
2687 if [ $cword -eq 3 ]; then
2690 __gitcomp_nl
"$(__git stash list \
2691 | sed -n -e 's/:.*//p')"
2694 show
,*|apply
,*|drop
,*|pop
,*)
2695 __gitcomp_nl
"$(__git stash list \
2696 | sed -n -e 's/:.*//p')"
2706 __git_has_doubledash
&& return
2708 local subcommands
="add status init deinit update summary foreach sync"
2709 if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then
2712 __gitcomp
"--quiet --cached"
2715 __gitcomp
"$subcommands"
2725 init fetch clone rebase dcommit log find-rev
2726 set-tree commit-diff info create-ignore propget
2727 proplist show-ignore show-externals branch tag blame
2728 migrate mkdirs reset gc
2730 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
2731 if [ -z "$subcommand" ]; then
2732 __gitcomp
"$subcommands"
2734 local remote_opts
="--username= --config-dir= --no-auth-cache"
2736 --follow-parent --authors-file= --repack=
2737 --no-metadata --use-svm-props --use-svnsync-props
2738 --log-window-size= --no-checkout --quiet
2739 --repack-flags --use-log-author --localtime
2740 --ignore-paths= --include-paths= $remote_opts
2743 --template= --shared= --trunk= --tags=
2744 --branches= --stdlayout --minimize-url
2745 --no-metadata --use-svm-props --use-svnsync-props
2746 --rewrite-root= --prefix= --use-log-author
2747 --add-author-from $remote_opts
2750 --edit --rmdir --find-copies-harder --copy-similarity=
2753 case "$subcommand,$cur" in
2755 __gitcomp
"--revision= --fetch-all $fc_opts"
2758 __gitcomp
"--revision= $fc_opts $init_opts"
2761 __gitcomp
"$init_opts"
2765 --merge --strategy= --verbose --dry-run
2766 --fetch-all --no-rebase --commit-url
2767 --revision --interactive $cmt_opts $fc_opts
2771 __gitcomp
"--stdin $cmt_opts $fc_opts"
2773 create-ignore
,--*|propget
,--*|proplist
,--*|show-ignore
,--*|\
2774 show-externals
,--*|mkdirs
,--*)
2775 __gitcomp
"--revision="
2779 --limit= --revision= --verbose --incremental
2780 --oneline --show-commit --non-recursive
2781 --authors-file= --color
2786 --merge --verbose --strategy= --local
2787 --fetch-all --dry-run $fc_opts
2791 __gitcomp
"--message= --file= --revision= $cmt_opts"
2797 __gitcomp
"--dry-run --message --tag"
2800 __gitcomp
"--dry-run --message"
2803 __gitcomp
"--git-format"
2807 --config-dir= --ignore-paths= --minimize
2808 --no-auth-cache --username=
2812 __gitcomp
"--revision= --parent"
2823 while [ $c -lt $cword ]; do
2827 __gitcomp_nl
"$(__git_tags)"
2842 __gitcomp_nl
"$(__git_tags)"
2853 --list --delete --verify --annotate --message --file
2854 --sign --cleanup --local-user --force --column --sort
2855 --contains --points-at
2868 local subcommands
="add list lock prune unlock"
2869 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
2870 if [ -z "$subcommand" ]; then
2871 __gitcomp
"$subcommands"
2873 case "$subcommand,$cur" in
2875 __gitcomp
"--detach"
2878 __gitcomp
"--porcelain"
2881 __gitcomp
"--reason"
2884 __gitcomp
"--dry-run --expire --verbose"
2894 local i c
=1 command __git_dir __git_repo_path
2895 local __git_C_args C_args_count
=0
2897 while [ $c -lt $cword ]; do
2900 --git-dir=*) __git_dir
="${i#--git-dir=}" ;;
2901 --git-dir) ((c
++)) ; __git_dir
="${words[c]}" ;;
2902 --bare) __git_dir
="." ;;
2903 --help) command="help"; break ;;
2904 -c|
--work-tree|
--namespace) ((c
++)) ;;
2905 -C) __git_C_args
[C_args_count
++]=-C
2907 __git_C_args
[C_args_count
++]="${words[c]}"
2910 *) command="$i"; break ;;
2915 if [ -z "$command" ]; then
2917 --git-dir|
-C|
--work-tree)
2918 # these need a path argument, let's fall back to
2919 # Bash filename completion
2923 # we don't support completing these options' arguments
2941 --no-replace-objects
2945 *) __git_compute_porcelain_commands
2946 __gitcomp
"$__git_porcelain_commands $(__git_aliases)" ;;
2951 local completion_func
="_git_${command//-/_}"
2952 declare -f $completion_func >/dev
/null
2>/dev
/null
&& $completion_func && return
2954 local expansion
=$
(__git_aliased_command
"$command")
2955 if [ -n "$expansion" ]; then
2957 completion_func
="_git_${expansion//-/_}"
2958 declare -f $completion_func >/dev
/null
2>/dev
/null
&& $completion_func
2964 __git_has_doubledash
&& return
2966 local __git_repo_path
2967 __git_find_repo_path
2970 if [ -f "$__git_repo_path/MERGE_HEAD" ]; then
2976 $__git_log_common_options
2977 $__git_log_gitk_options
2983 __git_complete_revlist
2986 if [[ -n ${ZSH_VERSION-} ]]; then
2987 echo "WARNING: this script is deprecated, please see git-completion.zsh" 1>&2
2989 autoload
-U +X compinit
&& compinit
2995 local cur_
="${3-$cur}"
3001 local c IFS
=$
' \t\n'
3009 array
[${#array[@]}+1]="$c"
3012 compadd
-Q -S '' -p "${2-}" -a -- array
&& _ret
=0
3023 compadd
-Q -- ${=1} && _ret
=0
3032 compadd
-Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
3041 compadd -Q -p "${2-}" -f -- ${=1} && _ret=0
3046 local _ret=1 cur cword prev
3047 cur=${words[CURRENT]}
3048 prev=${words[CURRENT-1]}
3050 emulate ksh -c __${service}_main
3051 let _ret && _default && _ret=0
3055 compdef _git git gitk
3061 local cur words cword prev
3062 _get_comp_words_by_ref -n =: cur words cword prev
3066 # Setup completion for certain functions defined above by setting common
3067 # variables and workarounds.
3068 # This is NOT a public function; use at your own risk.
3071 local wrapper="__git_wrap
${2}"
3072 eval "$wrapper () { __git_func_wrap
$2 ; }"
3073 complete -o bashdefault -o default -o nospace -F $wrapper $1 2>/dev/null \
3074 || complete -o default -o nospace -F $wrapper $1
3077 # wrapper for backwards compatibility
3080 __git_wrap__git_main
3083 # wrapper for backwards compatibility
3086 __git_wrap__gitk_main
3089 __git_complete git __git_main
3090 __git_complete gitk __gitk_main
3092 # The following are necessary only for Cygwin, and only are needed
3093 # when the user has tab-completed the executable name and consequently
3094 # included the '.exe' suffix.
3096 if [ Cygwin = "$
(uname
-o 2>/dev
/null
)" ]; then
3097 __git_complete git.exe __git_main