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%%/*}" ;;
355 # Lists branches from the local repository.
356 # 1: A prefix to be added to each listed branch (optional).
357 # 2: List only branches matching this word (optional; list all branches if
359 # 3: A suffix to be appended to each listed branch (optional).
362 local pfx="${1-}" cur_="${2-}" sfx="${3-}"
364 __git for-each-ref --format="${pfx//\%/%%}%(refname:strip=2)$sfx" \
365 "refs/heads/$cur_*" "refs/heads/$cur_*/**"
368 # Lists tags from the local repository.
369 # Accepts the same positional parameters as __git_heads() above.
372 local pfx="${1-}" cur_="${2-}" sfx="${3-}"
374 __git for-each-ref --format="${pfx//\%/%%}%(refname:strip=2)$sfx" \
375 "refs/tags/$cur_*" "refs/tags/$cur_*/**"
378 # Lists refs from the local (by default) or from a remote repository.
379 # It accepts 0, 1 or 2 arguments:
380 # 1: The remote to list refs from (optional; ignored, if set but empty).
381 # Can be the name of a configured remote, a path, or a URL.
382 # 2: In addition to local refs, list unique branches from refs/remotes/ for
383 # 'git checkout's tracking DWIMery (optional; ignored, if set but empty).
384 # 3: A prefix to be added to each listed ref (optional).
385 # 4: List only refs matching this word (optional; list all refs if unset or
387 # 5: A suffix to be appended to each listed ref (optional; ignored, if set
390 # Use __git_complete_refs() instead.
393 local i hash dir track="${2-}"
394 local list_refs_from=path remote="${1-}"
396 local pfx="${3-}" cur_="${4-$cur}" sfx="${5-}"
398 local fer_pfx="${pfx//\%/%%}" # "escape" for-each-ref format specifiers
401 dir="$__git_repo_path"
403 if [ -z "$remote" ]; then
404 if [ -z "$dir" ]; then
408 if __git_is_configured_remote "$remote"; then
409 # configured remote takes precedence over a
410 # local directory with the same name
411 list_refs_from=remote
412 elif [ -d "$remote/.git" ]; then
414 elif [ -d "$remote" ]; then
421 if [ "$list_refs_from" = path ]; then
422 if [[ "$cur_" == ^* ]]; then
431 refs=("$match*" "$match*/**")
435 for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do
438 if [ -e "$dir/$i" ]; then
444 format="refname:strip=2"
445 refs=("refs/tags/$match*" "refs/tags/$match*/**"
446 "refs/heads/$match*" "refs/heads/$match*/**"
447 "refs/remotes/$match*" "refs/remotes/$match*/**")
450 __git_dir="$dir" __git for-each-ref --format="$fer_pfx%($format)$sfx" \
452 if [ -n "$track" ]; then
453 # employ the heuristic used by git checkout
454 # Try to find a remote branch that matches the completion word
455 # but only output if the branch name is unique
456 __git for-each-ref --format="$fer_pfx%(refname:strip=3)$sfx" \
457 --sort="refname:strip=3" \
458 "refs/remotes/*/$match*" "refs/remotes/*/$match*/**" | \
465 __git ls-remote "$remote" "$match*" | \
466 while read -r hash i; do
469 *) echo "$pfx$i$sfx" ;;
474 if [ "$list_refs_from" = remote ]; then
476 $match*) echo "${pfx}HEAD$sfx" ;;
478 __git for-each-ref --format="$fer_pfx%(refname:strip=3)$sfx" \
479 "refs/remotes/$remote/$match*" \
480 "refs/remotes/$remote/$match*/**"
484 $match*) query_symref="HEAD" ;;
486 __git ls-remote "$remote" $query_symref \
487 "refs/tags/$match*" "refs/heads/$match*" \
488 "refs/remotes/$match*" |
489 while read -r hash i; do
492 refs/*) echo "$pfx${i#refs/*/}$sfx" ;;
493 *) echo "$pfx$i$sfx" ;; # symbolic refs
501 # Completes refs, short and long, local and remote, symbolic and pseudo.
503 # Usage: __git_complete_refs [<option>]...
504 # --remote=<remote>: The remote to list refs from, can be the name of a
505 # configured remote, a path, or a URL.
506 # --track: List unique remote branches for 'git checkout's tracking DWIMery.
507 # --pfx=<prefix>: A prefix to be added to each ref.
508 # --cur=<word>: The current ref to be completed. Defaults to the current
509 # word to be completed.
510 # --sfx=<suffix>: A suffix to be appended to each ref instead of the default
512 __git_complete_refs ()
514 local remote track pfx cur_="$cur" sfx=" "
516 while test $# != 0; do
518 --remote=*) remote="${1##--remote=}" ;;
519 --track) track="yes" ;;
520 --pfx=*) pfx="${1##--pfx=}" ;;
521 --cur=*) cur_="${1##--cur=}" ;;
522 --sfx=*) sfx="${1##--sfx=}" ;;
528 __gitcomp_direct "$(__git_refs "$remote" "$track" "$pfx" "$cur_" "$sfx")"
531 # __git_refs2 requires 1 argument (to pass to __git_refs)
532 # Deprecated: use __git_complete_fetch_refspecs() instead.
536 for i in $(__git_refs "$1"); do
541 # Completes refspecs for fetching from a remote repository.
542 # 1: The remote repository.
543 # 2: A prefix to be added to each listed refspec (optional).
544 # 3: The ref to be completed as a refspec instead of the current word to be
545 # completed (optional)
546 # 4: A suffix to be appended to each listed refspec instead of the default
548 __git_complete_fetch_refspecs ()
550 local i remote="$1" pfx="${2-}" cur_="${3-$cur}" sfx="${4- }"
553 for i in $(__git_refs "$remote" "" "" "$cur_") ; do
559 # __git_refs_remotes requires 1 argument (to pass to ls-remote)
560 __git_refs_remotes ()
563 __git ls-remote "$1" 'refs/heads/*' | \
564 while read -r hash i; do
565 echo "$i:refs/remotes/$1/${i#refs/heads/}"
572 test -d "$__git_repo_path/remotes" && ls -1 "$__git_repo_path/remotes"
576 # Returns true if $1 matches the name of a configured remote, false otherwise.
577 __git_is_configured_remote ()
580 for remote in $(__git_remotes); do
581 if [ "$remote" = "$1" ]; then
588 __git_list_merge_strategies ()
590 git merge -s help 2>&1 |
591 sed -n -e '/[Aa]vailable strategies are: /,/^$/{
600 __git_merge_strategies=
601 # 'git merge -s help' (and thus detection of the merge strategy
602 # list) fails, unfortunately, if run outside of any git working
603 # tree. __git_merge_strategies is set to the empty string in
604 # that case, and the detection will be repeated the next time it
606 __git_compute_merge_strategies ()
608 test -n "$__git_merge_strategies" ||
609 __git_merge_strategies=$(__git_list_merge_strategies)
612 __git_complete_revlist_file ()
614 local pfx ls ref cur_="$cur"
634 case "$COMP_WORDBREAKS" in
636 *) pfx="$ref:$pfx" ;;
639 __gitcomp_nl "$(__git ls-tree "$ls" \
640 | sed '/^100... blob /{
656 pfx="${cur_%...*}..."
658 __git_complete_refs --pfx="$pfx" --cur="$cur_"
663 __git_complete_refs --pfx="$pfx" --cur="$cur_"
672 # __git_complete_index_file requires 1 argument:
673 # 1: the options to pass to ls-file
675 # The exception is --committable, which finds the files appropriate commit.
676 __git_complete_index_file ()
678 local pfx="" cur_="$cur"
688 __gitcomp_file "$(__git_index_files "$1" ${pfx:+"$pfx"})" "$pfx" "$cur_"
691 __git_complete_file ()
693 __git_complete_revlist_file
696 __git_complete_revlist ()
698 __git_complete_revlist_file
701 __git_complete_remote_or_refspec ()
703 local cur_="$cur" cmd="${words[1]}"
704 local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0
705 if [ "$cmd" = "remote" ]; then
708 while [ $c -lt $cword ]; do
711 --mirror) [ "$cmd" = "push" ] && no_complete_refspec=1 ;;
714 push) no_complete_refspec=1 ;;
722 *) remote="$i"; break ;;
726 if [ -z "$remote" ]; then
727 __gitcomp_nl "$(__git_remotes)"
730 if [ $no_complete_refspec = 1 ]; then
733 [ "$remote" = "." ] && remote=
736 case "$COMP_WORDBREAKS" in
738 *) pfx="${cur_%%:*}:" ;;
750 if [ $lhs = 1 ]; then
751 __git_complete_fetch_refspecs "$remote" "$pfx" "$cur_"
753 __git_complete_refs --pfx="$pfx" --cur="$cur_"
757 if [ $lhs = 1 ]; then
758 __git_complete_refs --remote="$remote" --pfx="$pfx" --cur="$cur_"
760 __git_complete_refs --pfx="$pfx" --cur="$cur_"
764 if [ $lhs = 1 ]; then
765 __git_complete_refs --pfx="$pfx" --cur="$cur_"
767 __git_complete_refs --remote="$remote" --pfx="$pfx" --cur="$cur_"
773 __git_complete_strategy ()
775 __git_compute_merge_strategies
778 __gitcomp "$__git_merge_strategies"
783 __gitcomp "$__git_merge_strategies" "" "${cur##--strategy=}"
791 if test -n "${GIT_TESTING_COMMAND_COMPLETION:-}"
793 printf "%s" "${GIT_TESTING_COMMAND_COMPLETION}"
795 git help -a|egrep '^ [a-zA-Z0-9]'
799 __git_list_all_commands ()
802 for i in $(__git_commands)
805 *--*) : helper pattern;;
812 __git_compute_all_commands ()
814 test -n "$__git_all_commands" ||
815 __git_all_commands=$(__git_list_all_commands)
818 __git_list_porcelain_commands ()
821 __git_compute_all_commands
822 for i in $__git_all_commands
825 *--*) : helper pattern;;
826 applymbox) : ask gittus;;
827 applypatch) : ask gittus;;
828 archimport) : import;;
829 cat-file) : plumbing;;
830 check-attr) : plumbing;;
831 check-ignore) : plumbing;;
832 check-mailmap) : plumbing;;
833 check-ref-format) : plumbing;;
834 checkout-index) : plumbing;;
835 column) : internal helper;;
836 commit-tree) : plumbing;;
837 count-objects) : infrequent;;
838 credential) : credentials;;
839 credential-*) : credentials helper;;
840 cvsexportcommit) : export;;
841 cvsimport) : import;;
842 cvsserver) : daemon;;
844 diff-files) : plumbing;;
845 diff-index) : plumbing;;
846 diff-tree) : plumbing;;
847 fast-import) : import;;
848 fast-export) : export;;
849 fsck-objects) : plumbing;;
850 fetch-pack) : plumbing;;
851 fmt-merge-msg) : plumbing;;
852 for-each-ref) : plumbing;;
853 hash-object) : plumbing;;
854 http-*) : transport;;
855 index-pack) : plumbing;;
856 init-db) : deprecated;;
857 local-fetch) : plumbing;;
858 ls-files) : plumbing;;
859 ls-remote) : plumbing;;
860 ls-tree) : plumbing;;
861 mailinfo) : plumbing;;
862 mailsplit) : plumbing;;
863 merge-*) : plumbing;;
866 pack-objects) : plumbing;;
867 pack-redundant) : plumbing;;
868 pack-refs) : plumbing;;
869 parse-remote) : plumbing;;
870 patch-id) : plumbing;;
872 prune-packed) : plumbing;;
873 quiltimport) : import;;
874 read-tree) : plumbing;;
875 receive-pack) : plumbing;;
876 remote-*) : transport;;
878 rev-list) : plumbing;;
879 rev-parse) : plumbing;;
880 runstatus) : plumbing;;
881 sh-setup) : internal;;
883 show-ref) : plumbing;;
884 send-pack) : plumbing;;
885 show-index) : plumbing;;
887 stripspace) : plumbing;;
888 symbolic-ref) : plumbing;;
889 unpack-file) : plumbing;;
890 unpack-objects) : plumbing;;
891 update-index) : plumbing;;
892 update-ref) : plumbing;;
893 update-server-info) : daemon;;
894 upload-archive) : plumbing;;
895 upload-pack) : plumbing;;
896 write-tree) : plumbing;;
898 verify-pack) : infrequent;;
899 verify-tag) : plumbing;;
905 __git_porcelain_commands=
906 __git_compute_porcelain_commands ()
908 test -n "$__git_porcelain_commands" ||
909 __git_porcelain_commands=$(__git_list_porcelain_commands)
912 # Lists all set config variables starting with the given section prefix,
913 # with the prefix removed.
914 __git_get_config_variables ()
916 local section="$1" i IFS=$'\n'
917 for i in $(__git config --name-only --get-regexp "^$section\..*"); do
918 echo "${i#$section.}"
922 __git_pretty_aliases ()
924 __git_get_config_variables "pretty"
929 __git_get_config_variables "alias"
932 # __git_aliased_command requires 1 argument
933 __git_aliased_command ()
935 local word cmdline=$(__git config --get "alias.$1")
936 for word in $cmdline; do
942 \!*) : shell command alias ;;
944 *=*) : setting env ;;
946 \(\)) : skip parens of shell function definition ;;
947 {) : skip start of shell helper function ;;
948 :) : skip null command ;;
949 \'*) : skip opening quote after sh -c ;;
957 # __git_find_on_cmdline requires 1 argument
958 __git_find_on_cmdline ()
960 local word subcommand c=1
961 while [ $c -lt $cword ]; do
963 for subcommand in $1; do
964 if [ "$subcommand" = "$word" ]; then
973 # Echo the value of an option set on the command line or config
975 # $1: short option name
976 # $2: long option name including =
977 # $3: list of possible values
978 # $4: config string (optional)
981 # result="$(__git_get_option_value "-d" "--do-something=" \
982 # "yes no" "core.doSomething")"
984 # result is then either empty (no option set) or "yes" or "no"
986 # __git_get_option_value requires 3 arguments
987 __git_get_option_value ()
989 local c short_opt long_opt val
990 local result= values config_key word
998 while [ $c -ge 0 ]; do
1000 for val in $values; do
1001 if [ "$short_opt$val" = "$word" ] ||
1002 [ "$long_opt$val" = "$word" ]; then
1010 if [ -n "$config_key" ] && [ -z "$result" ]; then
1011 result="$(__git config "$config_key")"
1017 __git_has_doubledash ()
1020 while [ $c -lt $cword ]; do
1021 if [ "--" = "${words[c]}" ]; then
1029 # Try to count non option arguments passed on the command line for the
1030 # specified git command.
1031 # When options are used, it is necessary to use the special -- option to
1032 # tell the implementation were non option arguments begin.
1033 # XXX this can not be improved, since options can appear everywhere, as
1037 # __git_count_arguments requires 1 argument: the git command executed.
1038 __git_count_arguments ()
1042 # Skip "git" (first argument)
1043 for ((i=1; i < ${#words[@]}; i++)); do
1048 # Good; we can assume that the following are only non
1053 # Skip the specified git command and discard git
1066 __git_whitespacelist="nowarn warn error error-all fix"
1070 __git_find_repo_path
1071 if [ -d "$__git_repo_path"/rebase-apply ]; then
1072 __gitcomp "--skip --continue --resolved --abort"
1077 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
1082 --3way --committer-date-is-author-date --ignore-date
1083 --ignore-whitespace --ignore-space-change
1084 --interactive --keep --no-utf8 --signoff --utf8
1085 --whitespace= --scissors
1095 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
1100 --stat --numstat --summary --check --index
1101 --cached --index-info --reverse --reject --unidiff-zero
1102 --apply --no-add --exclude=
1103 --ignore-whitespace --ignore-space-change
1104 --whitespace= --inaccurate-eof --verbose
1105 --recount --directory=
1116 --interactive --refresh --patch --update --dry-run
1117 --ignore-errors --intent-to-add --force --edit --chmod=
1122 local complete_opt="--others --modified --directory --no-empty-directory"
1123 if test -n "$(__git_find_on_cmdline "-u --update")"
1125 complete_opt="--modified"
1127 __git_complete_index_file "$complete_opt"
1134 __gitcomp "$(git archive --list)" "" "${cur##--format=}"
1138 __gitcomp_nl "$(__git_remotes)" "" "${cur##--remote=}"
1143 --format= --list --verbose
1144 --prefix= --remote= --exec= --output
1154 __git_has_doubledash && return
1156 local subcommands="start bad good skip reset visualize replay log run"
1157 local subcommand="$(__git_find_on_cmdline "$subcommands")"
1158 if [ -z "$subcommand" ]; then
1159 __git_find_repo_path
1160 if [ -f "$__git_repo_path"/BISECT_START ]; then
1161 __gitcomp "$subcommands"
1163 __gitcomp "replay start"
1168 case "$subcommand" in
1169 bad|good|reset|skip|start)
1179 local i c=1 only_local_ref="n" has_r="n"
1181 while [ $c -lt $cword ]; do
1184 -d|--delete|-m|--move) only_local_ref="y" ;;
1185 -r|--remotes) has_r="y" ;;
1191 --set-upstream-to=*)
1192 __git_complete_refs --cur="${cur##--set-upstream-to=}"
1196 --color --no-color --verbose --abbrev= --no-abbrev
1197 --track --no-track --contains --no-contains --merged --no-merged
1198 --set-upstream-to= --edit-description --list
1199 --unset-upstream --delete --move --remotes
1200 --column --no-column --sort= --points-at
1204 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
1205 __gitcomp_direct "$(__git_heads "" "$cur" " ")"
1215 local cmd="${words[2]}"
1218 __gitcomp "create list-heads verify unbundle"
1221 # looking for a file
1226 __git_complete_revlist
1235 __git_has_doubledash && return
1239 __gitcomp "diff3 merge" "" "${cur##--conflict=}"
1243 --quiet --ours --theirs --track --no-track --merge
1244 --conflict= --orphan --patch
1248 # check if --track, --no-track, or --no-guess was specified
1249 # if so, disable DWIM mode
1250 local flags="--track --no-track --no-guess" track_opt="--track"
1251 if [ -n "$(__git_find_on_cmdline "$flags")" ]; then
1254 __git_complete_refs $track_opt
1266 __git_find_repo_path
1267 if [ -f "$__git_repo_path"/CHERRY_PICK_HEAD ]; then
1268 __gitcomp "--continue --quit --abort"
1273 __gitcomp "--edit --no-commit --signoff --strategy= --mainline"
1285 __gitcomp "--dry-run --quiet"
1290 # XXX should we check for -x option ?
1291 __git_complete_index_file "--others --directory"
1313 --recurse-submodules
1315 --shallow-submodules
1322 __git_untracked_file_modes="all no normal"
1335 __gitcomp "default scissors strip verbatim whitespace
1336 " "" "${cur##--cleanup=}"
1339 --reuse-message=*|--reedit-message=*|\
1340 --fixup=*|--squash=*)
1341 __git_complete_refs --cur="${cur#*=}"
1344 --untracked-files=*)
1345 __gitcomp "$__git_untracked_file_modes" "" "${cur##--untracked-files=}"
1350 --all --author= --signoff --verify --no-verify
1352 --amend --include --only --interactive
1353 --dry-run --reuse-message= --reedit-message=
1354 --reset-author --file= --message= --template=
1355 --cleanup= --untracked-files --untracked-files=
1356 --verbose --quiet --fixup= --squash=
1357 --patch --short --date --allow-empty
1362 if __git rev-parse --verify --quiet HEAD >/dev/null; then
1363 __git_complete_index_file "--committable"
1365 # This is the first commit
1366 __git_complete_index_file "--cached"
1375 --all --tags --contains --abbrev= --candidates=
1376 --exact-match --debug --long --match --always --first-parent
1384 __git_diff_algorithms="myers minimal patience histogram"
1386 __git_diff_submodule_formats="diff log short"
1388 __git_diff_common_options="--stat --numstat --shortstat --summary
1389 --patch-with-stat --name-only --name-status --color
1390 --no-color --color-words --no-renames --check
1391 --full-index --binary --abbrev --diff-filter=
1392 --find-copies-harder
1393 --text --ignore-space-at-eol --ignore-space-change
1394 --ignore-all-space --ignore-blank-lines --exit-code
1395 --quiet --ext-diff --no-ext-diff
1396 --no-prefix --src-prefix= --dst-prefix=
1397 --inter-hunk-context=
1398 --patience --histogram --minimal
1399 --raw --word-diff --word-diff-regex=
1400 --dirstat --dirstat= --dirstat-by-file
1401 --dirstat-by-file= --cumulative
1403 --submodule --submodule=
1408 __git_has_doubledash && return
1412 __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
1416 __gitcomp "$__git_diff_submodule_formats" "" "${cur##--submodule=}"
1420 __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
1421 --base --ours --theirs --no-index
1422 $__git_diff_common_options
1427 __git_complete_revlist_file
1430 __git_mergetools_common="diffuse diffmerge ecmerge emerge kdiff3 meld opendiff
1431 tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc codecompare
1436 __git_has_doubledash && return
1440 __gitcomp "$__git_mergetools_common kompare" "" "${cur##--tool=}"
1444 __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
1445 --base --ours --theirs
1446 --no-renames --diff-filter= --find-copies-harder
1447 --relative --ignore-submodules
1452 __git_complete_revlist_file
1455 __git_fetch_recurse_submodules="yes on-demand no"
1457 __git_fetch_options="
1458 --quiet --verbose --append --upload-pack --force --keep --depth=
1459 --tags --no-tags --all --prune --dry-run --recurse-submodules=
1460 --unshallow --update-shallow
1466 --recurse-submodules=*)
1467 __gitcomp "$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}"
1471 __gitcomp "$__git_fetch_options"
1475 __git_complete_remote_or_refspec
1478 __git_format_patch_options="
1479 --stdout --attach --no-attach --thread --thread= --no-thread
1480 --numbered --start-number --numbered-files --keep-subject --signoff
1481 --signature --no-signature --in-reply-to= --cc= --full-index --binary
1482 --not --all --cover-letter --no-prefix --src-prefix= --dst-prefix=
1483 --inline --suffix= --ignore-if-in-upstream --subject-prefix=
1484 --output-directory --reroll-count --to= --quiet --notes
1487 _git_format_patch ()
1493 " "" "${cur##--thread=}"
1497 __gitcomp "$__git_format_patch_options"
1501 __git_complete_revlist
1509 --tags --root --unreachable --cache --no-reflogs --full
1510 --strict --verbose --lost-found --name-objects
1521 __gitcomp "--prune --aggressive"
1532 # Lists matching symbol names from a tag (as in ctags) file.
1533 # 1: List symbol names matching this word.
1534 # 2: The tag file to list symbol names from.
1535 # 3: A prefix to be added to each listed symbol name (optional).
1536 # 4: A suffix to be appended to each listed symbol name (optional).
1537 __git_match_ctag () {
1538 awk -v pfx="${3-}" -v sfx="${4-}" "
1539 /^${1//\//\\/}/ { print pfx \$1 sfx }
1543 # Complete symbol names from a tag file.
1544 # Usage: __git_complete_symbol [<option>]...
1545 # --tags=<file>: The tag file to list symbol names from instead of the
1547 # --pfx=<prefix>: A prefix to be added to each symbol name.
1548 # --cur=<word>: The current symbol name to be completed. Defaults to
1549 # the current word to be completed.
1550 # --sfx=<suffix>: A suffix to be appended to each symbol name instead
1551 # of the default space.
1552 __git_complete_symbol () {
1553 local tags=tags pfx="" cur_="${cur-}" sfx=" "
1555 while test $# != 0; do
1557 --tags=*) tags="${1##--tags=}" ;;
1558 --pfx=*) pfx="${1##--pfx=}" ;;
1559 --cur=*) cur_="${1##--cur=}" ;;
1560 --sfx=*) sfx="${1##--sfx=}" ;;
1566 if test -r "$tags"; then
1567 __gitcomp_direct "$(__git_match_ctag "$cur_" "$tags" "$pfx" "$sfx")"
1573 __git_has_doubledash && return
1579 --text --ignore-case --word-regexp --invert-match
1580 --full-name --line-number
1581 --extended-regexp --basic-regexp --fixed-strings
1584 --files-with-matches --name-only
1585 --files-without-match
1588 --and --or --not --all-match
1589 --break --heading --show-function --function-context
1590 --untracked --no-index
1596 case "$cword,$prev" in
1598 __git_complete_symbol && return
1609 __gitcomp "--all --guides --info --man --web"
1613 __git_compute_all_commands
1614 __gitcomp "$__git_all_commands $(__git_aliases)
1615 attributes cli core-tutorial cvs-migration
1616 diffcore everyday gitk glossary hooks ignore modules
1617 namespaces repository-layout revisions tutorial tutorial-2
1627 false true umask group all world everybody
1628 " "" "${cur##--shared=}"
1632 __gitcomp "--quiet --bare --template= --shared --shared="
1642 __gitcomp "--cached --deleted --modified --others --ignored
1643 --stage --directory --no-empty-directory --unmerged
1644 --killed --exclude= --exclude-from=
1645 --exclude-per-directory= --exclude-standard
1646 --error-unmatch --with-tree= --full-name
1647 --abbrev --ignored --exclude-per-directory
1653 # XXX ignore options like --modified and always suggest all cached
1655 __git_complete_index_file "--cached"
1662 __gitcomp "--heads --tags --refs --get-url --symref"
1666 __gitcomp_nl "$(__git_remotes)"
1674 # Options that go well for log, shortlog and gitk
1675 __git_log_common_options="
1677 --branches --tags --remotes
1678 --first-parent --merges --no-merges
1680 --max-age= --since= --after=
1681 --min-age= --until= --before=
1682 --min-parents= --max-parents=
1683 --no-min-parents --no-max-parents
1685 # Options that go well for log and gitk (not shortlog)
1686 __git_log_gitk_options="
1687 --dense --sparse --full-history
1688 --simplify-merges --simplify-by-decoration
1689 --left-right --notes --no-notes
1691 # Options that go well for log and shortlog (not gitk)
1692 __git_log_shortlog_options="
1693 --author= --committer= --grep=
1694 --all-match --invert-grep
1697 __git_log_pretty_formats="oneline short medium full fuller email raw format:"
1698 __git_log_date_formats="relative iso8601 rfc2822 short local default raw"
1702 __git_has_doubledash && return
1703 __git_find_repo_path
1706 if [ -f "$__git_repo_path/MERGE_HEAD" ]; then
1709 case "$prev,$cur" in
1711 return # fall back to Bash filename completion
1714 __git_complete_symbol --cur="${cur#:}" --sfx=":"
1718 __git_complete_symbol
1723 --pretty=*|--format=*)
1724 __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
1729 __gitcomp "$__git_log_date_formats" "" "${cur##--date=}"
1733 __gitcomp "full short no" "" "${cur##--decorate=}"
1737 __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
1741 __gitcomp "$__git_diff_submodule_formats" "" "${cur##--submodule=}"
1746 $__git_log_common_options
1747 $__git_log_shortlog_options
1748 $__git_log_gitk_options
1749 --root --topo-order --date-order --reverse
1750 --follow --full-diff
1751 --abbrev-commit --abbrev=
1752 --relative-date --date=
1753 --pretty= --format= --oneline
1758 --decorate --decorate=
1760 --parents --children
1762 $__git_diff_common_options
1763 --pickaxe-all --pickaxe-regex
1768 return # fall back to Bash filename completion
1771 __git_complete_symbol --cur="${cur#-L:}" --sfx=":"
1775 __git_complete_symbol --pfx="-G" --cur="${cur#-G}"
1779 __git_complete_symbol --pfx="-S" --cur="${cur#-S}"
1783 __git_complete_revlist
1786 # Common merge options shared by git-merge(1) and git-pull(1).
1787 __git_merge_options="
1788 --no-commit --no-stat --log --no-log --squash --strategy
1789 --commit --stat --no-squash --ff --no-ff --ff-only --edit --no-edit
1790 --verify-signatures --no-verify-signatures --gpg-sign
1791 --quiet --verbose --progress --no-progress
1796 __git_complete_strategy && return
1800 __gitcomp "$__git_merge_options
1801 --rerere-autoupdate --no-rerere-autoupdate --abort --continue"
1811 __gitcomp "$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"
1815 __gitcomp "--tool= --prompt --no-prompt"
1825 __gitcomp "--octopus --independent --is-ancestor --fork-point"
1836 __gitcomp "--dry-run"
1841 if [ $(__git_count_arguments "mv") -gt 0 ]; then
1842 # We need to show both cached and untracked files (including
1843 # empty directories) since this may not be the last argument.
1844 __git_complete_index_file "--cached --others --directory"
1846 __git_complete_index_file "--cached"
1852 __gitcomp "--tags --all --stdin"
1857 local subcommands='add append copy edit list prune remove show'
1858 local subcommand="$(__git_find_on_cmdline "$subcommands")"
1860 case "$subcommand,$cur" in
1870 __gitcomp "$subcommands --ref"
1874 add,--reuse-message=*|append,--reuse-message=*|\
1875 add,--reedit-message=*|append,--reedit-message=*)
1876 __git_complete_refs --cur="${cur#*=}"
1879 __gitcomp '--file= --message= --reedit-message=
1886 __gitcomp '--dry-run --verbose'
1904 __git_complete_strategy && return
1907 --recurse-submodules=*)
1908 __gitcomp "$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}"
1913 --rebase --no-rebase
1914 $__git_merge_options
1915 $__git_fetch_options
1920 __git_complete_remote_or_refspec
1923 __git_push_recurse_submodules="check on-demand only"
1925 __git_complete_force_with_lease ()
1933 __git_complete_refs --cur="${cur_#*:}"
1936 __git_complete_refs --cur="$cur_"
1945 __gitcomp_nl "$(__git_remotes)"
1948 --recurse-submodules)
1949 __gitcomp "$__git_push_recurse_submodules"
1955 __gitcomp_nl "$(__git_remotes)" "" "${cur##--repo=}"
1958 --recurse-submodules=*)
1959 __gitcomp "$__git_push_recurse_submodules" "" "${cur##--recurse-submodules=}"
1962 --force-with-lease=*)
1963 __git_complete_force_with_lease "${cur##--force-with-lease=}"
1968 --all --mirror --tags --dry-run --force --verbose
1969 --quiet --prune --delete --follow-tags
1970 --receive-pack= --repo= --set-upstream
1971 --force-with-lease --force-with-lease= --recurse-submodules=
1976 __git_complete_remote_or_refspec
1981 __git_find_repo_path
1982 if [ -f "$__git_repo_path"/rebase-merge/interactive ]; then
1983 __gitcomp "--continue --skip --abort --quit --edit-todo"
1985 elif [ -d "$__git_repo_path"/rebase-apply ] || \
1986 [ -d "$__git_repo_path"/rebase-merge ]; then
1987 __gitcomp "--continue --skip --abort --quit"
1990 __git_complete_strategy && return
1993 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
1998 --onto --merge --strategy --interactive
1999 --preserve-merges --stat --no-stat
2000 --committer-date-is-author-date --ignore-date
2001 --ignore-whitespace --whitespace=
2002 --autosquash --no-autosquash
2003 --fork-point --no-fork-point
2004 --autostash --no-autostash
2005 --verify --no-verify
2006 --keep-empty --root --force-rebase --no-ff
2017 local subcommands="show delete expire"
2018 local subcommand="$(__git_find_on_cmdline "$subcommands")"
2020 if [ -z "$subcommand" ]; then
2021 __gitcomp "$subcommands"
2027 __git_send_email_confirm_options="always never auto cc compose"
2028 __git_send_email_suppresscc_options="author self cc bodycc sob cccmd body all"
2033 --to|--cc|--bcc|--from)
2034 __gitcomp "$(__git send-email --dump-aliases)"
2042 $__git_send_email_confirm_options
2043 " "" "${cur##--confirm=}"
2048 $__git_send_email_suppresscc_options
2049 " "" "${cur##--suppress-cc=}"
2053 --smtp-encryption=*)
2054 __gitcomp "ssl tls" "" "${cur##--smtp-encryption=}"
2060 " "" "${cur##--thread=}"
2063 --to=*|--cc=*|--bcc=*|--from=*)
2064 __gitcomp "$(__git send-email --dump-aliases)" "" "${cur#--*=}"
2068 __gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to
2069 --compose --confirm= --dry-run --envelope-sender
2071 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
2072 --no-suppress-from --no-thread --quiet
2073 --signed-off-by-cc --smtp-pass --smtp-server
2074 --smtp-server-port --smtp-encryption= --smtp-user
2075 --subject --suppress-cc= --suppress-from --thread --to
2076 --validate --no-validate
2077 $__git_format_patch_options"
2081 __git_complete_revlist
2092 local untracked_state
2095 --ignore-submodules=*)
2096 __gitcomp "none untracked dirty all" "" "${cur##--ignore-submodules=}"
2099 --untracked-files=*)
2100 __gitcomp "$__git_untracked_file_modes" "" "${cur##--untracked-files=}"
2105 always never auto column row plain dense nodense
2106 " "" "${cur##--column=}"
2111 --short --branch --porcelain --long --verbose
2112 --untracked-files= --ignore-submodules= --ignored
2113 --column= --no-column
2119 untracked_state="$(__git_get_option_value "-u" "--untracked-files=" \
2120 "$__git_untracked_file_modes" "status.showUntrackedFiles")"
2122 case "$untracked_state" in
2124 # --ignored option does not matter
2128 complete_opt="--cached --directory --no-empty-directory --others"
2130 if [ -n "$(__git_find_on_cmdline "--ignored")" ]; then
2131 complete_opt="$complete_opt --ignored --exclude=*"
2136 __git_complete_index_file "$complete_opt"
2139 __git_config_get_set_variables ()
2141 local prevword word config_file= c=$cword
2142 while [ $c -gt 1 ]; do
2145 --system|--global|--local|--file=*)
2150 config_file="$word $prevword"
2158 __git config $config_file --name-only --list
2164 branch.*.remote|branch.*.pushremote)
2165 __gitcomp_nl "$(__git_remotes)"
2173 __gitcomp "false true preserve interactive"
2177 __gitcomp_nl "$(__git_remotes)"
2181 local remote="${prev#remote.}"
2182 remote="${remote%.fetch}"
2183 if [ -z "$cur" ]; then
2184 __gitcomp_nl "refs/heads/" "" "" ""
2187 __gitcomp_nl "$(__git_refs_remotes "$remote")"
2191 local remote="${prev#remote.}"
2192 remote="${remote%.push}"
2193 __gitcomp_nl "$(__git for-each-ref \
2194 --format='%(refname):%(refname)' refs/heads)"
2197 pull.twohead|pull.octopus)
2198 __git_compute_merge_strategies
2199 __gitcomp "$__git_merge_strategies"
2202 color.branch|color.diff|color.interactive|\
2203 color.showbranch|color.status|color.ui)
2204 __gitcomp "always never auto"
2208 __gitcomp "false true"
2213 normal black red green yellow blue magenta cyan white
2214 bold dim ul blink reverse
2219 __gitcomp "log short"
2223 __gitcomp "man info web html"
2227 __gitcomp "$__git_log_date_formats"
2230 sendemail.aliasesfiletype)
2231 __gitcomp "mutt mailrc pine elm gnus"
2235 __gitcomp "$__git_send_email_confirm_options"
2238 sendemail.suppresscc)
2239 __gitcomp "$__git_send_email_suppresscc_options"
2242 sendemail.transferencoding)
2243 __gitcomp "7bit 8bit quoted-printable base64"
2246 --get|--get-all|--unset|--unset-all)
2247 __gitcomp_nl "$(__git_config_get_set_variables)"
2257 --system --global --local --file=
2258 --list --replace-all
2259 --get --get-all --get-regexp
2260 --add --unset --unset-all
2261 --remove-section --rename-section
2267 local pfx="${cur%.*}." cur_="${cur##*.}"
2268 __gitcomp "remote pushremote merge mergeoptions rebase" "$pfx" "$cur_"
2272 local pfx="${cur%.*}." cur_="${cur#*.}"
2273 __gitcomp_direct "$(__git_heads "$pfx" "$cur_" ".")"
2274 __gitcomp_nl_append $'autosetupmerge\nautosetuprebase\n' "$pfx" "$cur_"
2278 local pfx="${cur%.*}." cur_="${cur##*.}"
2280 argprompt cmd confirm needsfile noconsole norescan
2281 prompt revprompt revunmerged title
2286 local pfx="${cur%.*}." cur_="${cur##*.}"
2287 __gitcomp "cmd path" "$pfx" "$cur_"
2291 local pfx="${cur%.*}." cur_="${cur##*.}"
2292 __gitcomp "cmd path" "$pfx" "$cur_"
2296 local pfx="${cur%.*}." cur_="${cur##*.}"
2297 __gitcomp "cmd path trustExitCode" "$pfx" "$cur_"
2301 local pfx="${cur%.*}." cur_="${cur#*.}"
2302 __git_compute_all_commands
2303 __gitcomp_nl "$__git_all_commands" "$pfx" "$cur_"
2307 local pfx="${cur%.*}." cur_="${cur##*.}"
2309 url proxy fetch push mirror skipDefaultUpdate
2310 receivepack uploadpack tagopt pushurl
2315 local pfx="${cur%.*}." cur_="${cur#*.}"
2316 __gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "."
2317 __gitcomp_nl_append "pushdefault" "$pfx" "$cur_"
2321 local pfx="${cur%.*}." cur_="${cur##*.}"
2322 __gitcomp "insteadOf pushInsteadOf" "$pfx" "$cur_"
2328 advice.commitBeforeMerge
2330 advice.implicitIdentity
2331 advice.pushNonFastForward
2332 advice.resolveConflict
2336 apply.ignorewhitespace
2338 branch.autosetupmerge
2339 branch.autosetuprebase
2343 color.branch.current
2348 color.decorate.branch
2349 color.decorate.remoteBranch
2350 color.decorate.stash
2360 color.diff.whitespace
2365 color.grep.linenumber
2368 color.grep.separator
2370 color.interactive.error
2371 color.interactive.header
2372 color.interactive.help
2373 color.interactive.prompt
2378 color.status.changed
2380 color.status.nobranch
2381 color.status.unmerged
2382 color.status.untracked
2383 color.status.updated
2392 core.bigFileThreshold
2395 core.deltaBaseCacheLimit
2400 core.fsyncobjectfiles
2404 core.logAllRefUpdates
2405 core.loosecompression
2408 core.packedGitWindowSize
2410 core.preferSymlinkRefs
2413 core.repositoryFormatVersion
2415 core.sharedRepository
2420 core.warnAmbiguousRefs
2423 diff.autorefreshindex
2425 diff.ignoreSubmodules
2432 diff.suppressBlankEmpty
2438 fetch.recurseSubmodules
2449 format.subjectprefix
2460 gc.reflogexpireunreachable
2464 gitcvs.commitmsgannotation
2465 gitcvs.dbTableNamePrefix
2476 gui.copyblamethreshold
2480 gui.matchtrackingbranch
2481 gui.newbranchtemplate
2482 gui.pruneduringfetch
2483 gui.spellingdictionary
2500 http.sslCertPasswordProtected
2505 i18n.logOutputEncoding
2511 imap.preformattedHTML
2521 interactive.singlekey
2537 mergetool.keepBackup
2538 mergetool.keepTemporaries
2543 notes.rewrite.rebase
2547 pack.deltaCacheLimit
2564 receive.denyCurrentBranch
2565 receive.denyDeleteCurrent
2567 receive.denyNonFastForwards
2570 receive.updateserverinfo
2573 repack.usedeltabaseoffset
2577 sendemail.aliasesfile
2578 sendemail.aliasfiletype
2582 sendemail.chainreplyto
2584 sendemail.envelopesender
2588 sendemail.signedoffbycc
2589 sendemail.smtpdomain
2590 sendemail.smtpencryption
2592 sendemail.smtpserver
2593 sendemail.smtpserveroption
2594 sendemail.smtpserverport
2596 sendemail.suppresscc
2597 sendemail.suppressfrom
2602 status.relativePaths
2603 status.showUntrackedFiles
2604 status.submodulesummary
2607 transfer.unpackLimit
2620 add rename remove set-head set-branches
2621 get-url set-url show prune update
2623 local subcommand="$(__git_find_on_cmdline "$subcommands")"
2624 if [ -z "$subcommand" ]; then
2627 __gitcomp "--verbose"
2630 __gitcomp "$subcommands"
2636 case "$subcommand,$cur" in
2638 __gitcomp "--track --master --fetch --tags --no-tags --mirror="
2643 __gitcomp "--auto --delete"
2648 set-head,*|set-branches,*)
2649 __git_complete_remote_or_refspec
2655 __gitcomp "$(__git_get_config_variables "remotes")"
2658 __gitcomp "--push --add --delete"
2661 __gitcomp "--push --all"
2664 __gitcomp "--dry-run"
2667 __gitcomp_nl "$(__git_remotes)"
2676 __gitcomp "--edit --graft --format= --list --delete"
2685 local subcommands="clear forget diff remaining status gc"
2686 local subcommand="$(__git_find_on_cmdline "$subcommands")"
2687 if test -z "$subcommand"
2689 __gitcomp "$subcommands"
2696 __git_has_doubledash && return
2700 __gitcomp "--merge --mixed --hard --soft --patch --keep"
2709 __git_find_repo_path
2710 if [ -f "$__git_repo_path"/REVERT_HEAD ]; then
2711 __gitcomp "--continue --quit --abort"
2717 --edit --mainline --no-edit --no-commit --signoff
2718 --strategy= --strategy-option=
2730 __gitcomp "--cached --dry-run --ignore-unmatch --quiet"
2735 __git_complete_index_file "--cached"
2740 __git_has_doubledash && return
2745 $__git_log_common_options
2746 $__git_log_shortlog_options
2747 --numbered --summary --email
2752 __git_complete_revlist
2757 __git_has_doubledash && return
2760 --pretty=*|--format=*)
2761 __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
2766 __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
2770 __gitcomp "$__git_diff_submodule_formats" "" "${cur##--submodule=}"
2774 __gitcomp "--pretty= --format= --abbrev-commit --oneline
2776 $__git_diff_common_options
2781 __git_complete_revlist_file
2789 --all --remotes --topo-order --date-order --current --more=
2790 --list --independent --merge-base --no-name
2792 --sha1-name --sparse --topics --reflog
2797 __git_complete_revlist
2802 local save_opts='--all --keep-index --no-keep-index --quiet --patch --include-untracked'
2803 local subcommands='save list show apply clear drop pop create branch'
2804 local subcommand="$(__git_find_on_cmdline "$subcommands")"
2805 if [ -z "$subcommand" ]; then
2808 __gitcomp "$save_opts"
2811 if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then
2812 __gitcomp "$subcommands"
2817 case "$subcommand,$cur" in
2819 __gitcomp "$save_opts"
2822 __gitcomp "--index --quiet"
2827 show,--*|branch,--*)
2830 if [ $cword -eq 3 ]; then
2833 __gitcomp_nl "$(__git stash list \
2834 | sed -n -e 's/:.*//p')"
2837 show,*|apply,*|drop,*|pop,*)
2838 __gitcomp_nl "$(__git stash list \
2839 | sed -n -e 's/:.*//p')"
2849 __git_has_doubledash && return
2851 local subcommands="add status init deinit update summary foreach sync"
2852 local subcommand="$(__git_find_on_cmdline "$subcommands")"
2853 if [ -z "$subcommand" ]; then
2859 __gitcomp "$subcommands"
2865 case "$subcommand,$cur" in
2867 __gitcomp "--branch --force --name --reference --depth"
2870 __gitcomp "--cached --recursive"
2873 __gitcomp "--force --all"
2877 --init --remote --no-fetch
2878 --recommend-shallow --no-recommend-shallow
2879 --force --rebase --merge --reference --depth --recursive --jobs
2883 __gitcomp "--cached --files --summary-limit"
2885 foreach,--*|sync,--*)
2886 __gitcomp "--recursive"
2896 init fetch clone rebase dcommit log find-rev
2897 set-tree commit-diff info create-ignore propget
2898 proplist show-ignore show-externals branch tag blame
2899 migrate mkdirs reset gc
2901 local subcommand="$(__git_find_on_cmdline "$subcommands")"
2902 if [ -z "$subcommand" ]; then
2903 __gitcomp "$subcommands"
2905 local remote_opts="--username= --config-dir= --no-auth-cache"
2907 --follow-parent --authors-file= --repack=
2908 --no-metadata --use-svm-props --use-svnsync-props
2909 --log-window-size= --no-checkout --quiet
2910 --repack-flags --use-log-author --localtime
2912 --ignore-paths= --include-paths= $remote_opts
2915 --template= --shared= --trunk= --tags=
2916 --branches= --stdlayout --minimize-url
2917 --no-metadata --use-svm-props --use-svnsync-props
2918 --rewrite-root= --prefix= $remote_opts
2921 --edit --rmdir --find-copies-harder --copy-similarity=
2924 case "$subcommand,$cur" in
2926 __gitcomp "--revision= --fetch-all $fc_opts"
2929 __gitcomp "--revision= $fc_opts $init_opts"
2932 __gitcomp "$init_opts"
2936 --merge --strategy= --verbose --dry-run
2937 --fetch-all --no-rebase --commit-url
2938 --revision --interactive $cmt_opts $fc_opts
2942 __gitcomp "--stdin $cmt_opts $fc_opts"
2944 create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\
2945 show-externals,--*|mkdirs,--*)
2946 __gitcomp "--revision="
2950 --limit= --revision= --verbose --incremental
2951 --oneline --show-commit --non-recursive
2952 --authors-file= --color
2957 --merge --verbose --strategy= --local
2958 --fetch-all --dry-run $fc_opts
2962 __gitcomp "--message= --file= --revision= $cmt_opts"
2968 __gitcomp "--dry-run --message --tag"
2971 __gitcomp "--dry-run --message"
2974 __gitcomp "--git-format"
2978 --config-dir= --ignore-paths= --minimize
2979 --no-auth-cache --username=
2983 __gitcomp "--revision= --parent"
2994 while [ $c -lt $cword ]; do
2998 __gitcomp_direct "$(__git_tags "" "$cur" " ")"
3013 __gitcomp_direct "$(__git_tags "" "$cur" " ")"
3024 --list --delete --verify --annotate --message --file
3025 --sign --cleanup --local-user --force --column --sort=
3026 --contains --no-contains --points-at --merged --no-merged --create-reflog
3039 local subcommands="add list lock prune unlock"
3040 local subcommand="$(__git_find_on_cmdline "$subcommands")"
3041 if [ -z "$subcommand" ]; then
3042 __gitcomp "$subcommands"
3044 case "$subcommand,$cur" in
3046 __gitcomp "--detach"
3049 __gitcomp "--porcelain"
3052 __gitcomp "--reason"
3055 __gitcomp "--dry-run --expire --verbose"
3065 local i c=1 command __git_dir __git_repo_path
3066 local __git_C_args C_args_count=0
3068 while [ $c -lt $cword ]; do
3071 --git-dir=*) __git_dir="${i#--git-dir=}" ;;
3072 --git-dir) ((c++)) ; __git_dir="${words[c]}" ;;
3073 --bare) __git_dir="." ;;
3074 --help) command="help"; break ;;
3075 -c|--work-tree|--namespace) ((c++)) ;;
3076 -C) __git_C_args[C_args_count++]=-C
3078 __git_C_args[C_args_count++]="${words[c]}"
3081 *) command="$i"; break ;;
3086 if [ -z "$command" ]; then
3088 --git-dir|-C|--work-tree)
3089 # these need a path argument, let's fall back to
3090 # Bash filename completion
3094 # we don't support completing these options' arguments
3112 --no-replace-objects
3116 *) __git_compute_porcelain_commands
3117 __gitcomp "$__git_porcelain_commands $(__git_aliases)" ;;
3122 local completion_func="_git_${command//-/_}"
3123 declare -f $completion_func >/dev/null 2>/dev/null && $completion_func && return
3125 local expansion=$(__git_aliased_command "$command")
3126 if [ -n "$expansion" ]; then
3128 completion_func="_git_${expansion//-/_}"
3129 declare -f $completion_func >/dev/null 2>/dev/null && $completion_func
3135 __git_has_doubledash && return
3137 local __git_repo_path
3138 __git_find_repo_path
3141 if [ -f "$__git_repo_path/MERGE_HEAD" ]; then
3147 $__git_log_common_options
3148 $__git_log_gitk_options
3154 __git_complete_revlist
3157 if [[ -n ${ZSH_VERSION-} ]]; then
3158 echo "WARNING: this script is deprecated, please see git-completion.zsh" 1>&2
3160 autoload -U +X compinit && compinit
3166 local cur_="${3-$cur}"
3172 local c IFS=$' \t\n'
3180 array[${#array[@]}+1]="$c"
3183 compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
3194 compadd -Q -- ${=1} && _ret=0
3203 compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
3212 compadd -Q -p "${2-}" -f -- ${=1} && _ret=0
3217 local _ret=1 cur cword prev
3218 cur=${words[CURRENT]}
3219 prev=${words[CURRENT-1]}
3221 emulate ksh -c __${service}_main
3222 let _ret && _default && _ret=0
3226 compdef _git git gitk
3232 local cur words cword prev
3233 _get_comp_words_by_ref -n =: cur words cword prev
3237 # Setup completion for certain functions defined above by setting common
3238 # variables and workarounds.
3239 # This is NOT a public function; use at your own risk.
3242 local wrapper="__git_wrap${2}"
3243 eval "$wrapper () { __git_func_wrap $2 ; }"
3244 complete -o bashdefault -o default -o nospace -F $wrapper $1 2>/dev/null \
3245 || complete -o default -o nospace -F $wrapper $1
3248 # wrapper for backwards compatibility
3251 __git_wrap__git_main
3254 # wrapper for backwards compatibility
3257 __git_wrap__gitk_main
3260 __git_complete git __git_main
3261 __git_complete gitk __gitk_main
3263 # The following are necessary only for Cygwin, and only are needed
3264 # when the user has tab-completed the executable name and consequently
3265 # included the '.exe' suffix.
3267 if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
3268 __git_complete git.exe __git_main