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 # __gitdir accepts 0 or 1 arguments (i.e., location)
38 # returns location of .git repo
41 if [ -z "${1-}" ]; then
42 if [ -n "${__git_dir-}" ]; then
43 test -d "$__git_dir" || return 1
45 elif [ -n "${GIT_DIR-}" ]; then
46 test -d "${GIT_DIR-}" || return 1
48 elif [ -d .git ]; then
51 git rev-parse --git-dir 2>/dev/null
53 elif [ -d "$1/.git" ]; then
60 # The following function is based on code from:
62 # bash_completion - programmable completion functions for bash 3.2+
64 # Copyright © 2006-2008, Ian Macdonald <ian@caliban.org>
65 # © 2009-2010, Bash Completion Maintainers
66 # <bash-completion-devel@lists.alioth.debian.org>
68 # This program is free software; you can redistribute it and/or modify
69 # it under the terms of the GNU General Public License as published by
70 # the Free Software Foundation; either version 2, or (at your option)
73 # This program is distributed in the hope that it will be useful,
74 # but WITHOUT ANY WARRANTY; without even the implied warranty of
75 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
76 # GNU General Public License for more details.
78 # You should have received a copy of the GNU General Public License
79 # along with this program; if not, write to the Free Software Foundation,
80 # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
82 # The latest version of this software can be obtained here:
84 # http://bash-completion.alioth.debian.org/
88 # This function can be used to access a tokenized list of words
89 # on the command line:
91 # __git_reassemble_comp_words_by_ref '=:'
92 # if test "${words_[cword_-1]}" = -w
97 # The argument should be a collection of characters from the list of
98 # word completion separators (COMP_WORDBREAKS) to treat as ordinary
101 # This is roughly equivalent to going back in time and setting
102 # COMP_WORDBREAKS to exclude those characters. The intent is to
103 # make option types like --date=<type> and <rev>:<path> easy to
104 # recognize by treating each shell word as a single token.
106 # It is best not to set COMP_WORDBREAKS directly because the value is
107 # shared with other completion scripts. By the time the completion
108 # function gets called, COMP_WORDS has already been populated so local
109 # changes to COMP_WORDBREAKS have no effect.
111 # Output: words_, cword_, cur_.
113 __git_reassemble_comp_words_by_ref()
115 local exclude i j first
116 # Which word separators to exclude?
117 exclude="${1//[^$COMP_WORDBREAKS]}"
119 if [ -z "$exclude" ]; then
120 words_=("${COMP_WORDS[@]}")
123 # List of word completion separators has shrunk;
124 # re-assemble words to complete.
125 for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)); do
126 # Append each nonempty word consisting of just
127 # word separator characters to the current word.
131 [ -n "${COMP_WORDS[$i]}" ] &&
132 # word consists of excluded word separators
133 [ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ]
135 # Attach to the previous token,
136 # unless the previous token is the command name.
137 if [ $j -ge 2 ] && [ -n "$first" ]; then
141 words_[$j]=${words_[j]}${COMP_WORDS[i]}
142 if [ $i = $COMP_CWORD ]; then
145 if (($i < ${#COMP_WORDS[@]} - 1)); then
152 words_[$j]=${words_[j]}${COMP_WORDS[i]}
153 if [ $i = $COMP_CWORD ]; then
159 if ! type _get_comp_words_by_ref >/dev/null 2>&1; then
160 _get_comp_words_by_ref ()
162 local exclude cur_ words_ cword_
163 if [ "$1" = "-n" ]; then
167 __git_reassemble_comp_words_by_ref "$exclude"
168 cur_=${words_[cword_]}
169 while [ $# -gt 0 ]; do
175 prev=${words_[$cword_-1]}
178 words=("${words_[@]}")
191 local x i=${#COMPREPLY[@]}
193 if [[ "$x" == "$3"* ]]; then
194 COMPREPLY[i++]="$2$x$4"
205 # Generates completion reply, appending a space to possible completion words,
207 # It accepts 1 to 4 arguments:
208 # 1: List of possible completion words.
209 # 2: A prefix to be added to each possible completion word (optional).
210 # 3: Generate possible completion matches for this word (optional).
211 # 4: A suffix to be appended to each possible completion word (optional).
214 local cur_="${3-$cur}"
220 local c i=0 IFS=$' \t\n'
223 if [[ $c == "$cur_"* ]]; then
228 COMPREPLY[i++]="${2-}$c"
235 # Variation of __gitcomp_nl () that appends to the existing list of
236 # completion candidates, COMPREPLY.
237 __gitcomp_nl_append ()
240 __gitcompappend "$1" "${2-}" "${3-$cur}" "${4- }"
243 # Generates completion reply from newline-separated possible completion words
244 # by appending a space to all of them.
245 # It accepts 1 to 4 arguments:
246 # 1: List of possible completion words, separated by a single newline.
247 # 2: A prefix to be added to each possible completion word (optional).
248 # 3: Generate possible completion matches for this word (optional).
249 # 4: A suffix to be appended to each possible completion word instead of
250 # the default space (optional). If specified but empty, nothing is
255 __gitcomp_nl_append "$@"
258 # Generates completion reply with compgen from newline-separated possible
259 # completion filenames.
260 # It accepts 1 to 3 arguments:
261 # 1: List of possible completion filenames, separated by a single newline.
262 # 2: A directory prefix to be added to each possible completion filename
264 # 3: Generate possible completion matches for this word (optional).
269 # XXX does not work when the directory prefix contains a tilde,
270 # since tilde expansion is not applied.
271 # This means that COMPREPLY will be empty and Bash default
272 # completion will be used.
273 __gitcompadd "$1" "${2-}" "${3-$cur}" ""
275 # use a hack to enable file mode in bash < 4
276 compopt -o filenames +o nospace 2>/dev/null ||
277 compgen -f /non-existing-dir/ > /dev/null
280 # Execute 'git ls-files', unless the --committable option is specified, in
281 # which case it runs 'git diff-index' to find out the files that can be
282 # committed. It return paths relative to the directory specified in the first
283 # argument, and using the options specified in the second argument.
284 __git_ls_files_helper ()
286 if [ "$2" == "--committable" ]; then
287 git -C "$1" diff-index --name-only --relative HEAD
289 # NOTE: $2 is not quoted in order to support multiple options
290 git -C "$1" ls-files --exclude-standard $2
295 # __git_index_files accepts 1 or 2 arguments:
296 # 1: Options to pass to ls-files (required).
297 # 2: A directory path (optional).
298 # If provided, only files within the specified directory are listed.
299 # Sub directories are never recursed. Path must have a trailing
303 local dir="$(__gitdir)" root="${2-.}" file
305 if [ -d "$dir" ]; then
306 __git_ls_files_helper "$root" "$1" |
307 while read -r file; do
309 ?*/*) echo "${file%%/*}" ;;
318 local dir="$(__gitdir)"
319 if [ -d "$dir" ]; then
320 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
328 local dir="$(__gitdir)"
329 if [ -d "$dir" ]; then
330 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
336 # Lists refs from the local (by default) or from a remote repository.
337 # It accepts 0, 1 or 2 arguments:
338 # 1: The remote to list refs from (optional; ignored, if set but empty).
339 # 2: In addition to local refs, list unique branches from refs/remotes/ for
340 # 'git checkout's tracking DWIMery (optional; ignored, if set but empty).
343 local i hash dir="$(__gitdir "${1-}")" track="${2-}"
344 local format refs pfx
345 if [ -d "$dir" ]; then
353 [[ "$cur" == ^* ]] && pfx="^"
354 for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do
355 if [ -e "$dir/$i" ]; then echo $pfx$i; fi
357 format="refname:short"
358 refs="refs/tags refs/heads refs/remotes"
361 git --git-dir="$dir" for-each-ref --format="$pfx%($format)" \
363 if [ -n "$track" ]; then
364 # employ the heuristic used by git checkout
365 # Try to find a remote branch that matches the completion word
366 # but only output if the branch name is unique
368 git --git-dir="$dir" for-each-ref --shell --format="ref=%(refname:short)" \
370 while read -r entry; do
373 if [[ "$ref" == "$cur"* ]]; then
376 done | sort | uniq -u
382 git ls-remote "$dir" "$cur*" 2>/dev/null | \
383 while read -r hash i; do
392 git for-each-ref --format="%(refname:short)" -- \
393 "refs/remotes/$dir/" 2>/dev/null | sed -e "s#^$dir/##"
398 # __git_refs2 requires 1 argument (to pass to __git_refs)
402 for i in $(__git_refs "$1"); do
407 # __git_refs_remotes requires 1 argument (to pass to ls-remote)
408 __git_refs_remotes ()
411 git ls-remote "$1" 'refs/heads/*' 2>/dev/null | \
412 while read -r hash i; do
413 echo "$i:refs/remotes/$1/${i#refs/heads/}"
419 local d="$(__gitdir)"
420 test -d "$d/remotes" && ls -1 "$d/remotes"
421 git --git-dir="$d" remote
424 __git_list_merge_strategies ()
426 git merge -s help 2>&1 |
427 sed -n -e '/[Aa]vailable strategies are: /,/^$/{
436 __git_merge_strategies=
437 # 'git merge -s help' (and thus detection of the merge strategy
438 # list) fails, unfortunately, if run outside of any git working
439 # tree. __git_merge_strategies is set to the empty string in
440 # that case, and the detection will be repeated the next time it
442 __git_compute_merge_strategies ()
444 test -n "$__git_merge_strategies" ||
445 __git_merge_strategies=$(__git_list_merge_strategies)
448 __git_complete_revlist_file ()
450 local pfx ls ref cur_="$cur"
470 case "$COMP_WORDBREAKS" in
472 *) pfx="$ref:$pfx" ;;
475 __gitcomp_nl "$(git --git-dir="$(__gitdir)" ls-tree "$ls" 2>/dev/null \
476 | sed '/^100... blob /{
492 pfx="${cur_%...*}..."
494 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
499 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
502 __gitcomp_nl "$(__git_refs)"
508 # __git_complete_index_file requires 1 argument:
509 # 1: the options to pass to ls-file
511 # The exception is --committable, which finds the files appropriate commit.
512 __git_complete_index_file ()
514 local pfx="" cur_="$cur"
524 __gitcomp_file "$(__git_index_files "$1" ${pfx:+"$pfx"})" "$pfx" "$cur_"
527 __git_complete_file ()
529 __git_complete_revlist_file
532 __git_complete_revlist ()
534 __git_complete_revlist_file
537 __git_complete_remote_or_refspec ()
539 local cur_="$cur" cmd="${words[1]}"
540 local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0
541 if [ "$cmd" = "remote" ]; then
544 while [ $c -lt $cword ]; do
547 --mirror) [ "$cmd" = "push" ] && no_complete_refspec=1 ;;
550 push) no_complete_refspec=1 ;;
558 *) remote="$i"; break ;;
562 if [ -z "$remote" ]; then
563 __gitcomp_nl "$(__git_remotes)"
566 if [ $no_complete_refspec = 1 ]; then
569 [ "$remote" = "." ] && remote=
572 case "$COMP_WORDBREAKS" in
574 *) pfx="${cur_%%:*}:" ;;
586 if [ $lhs = 1 ]; then
587 __gitcomp_nl "$(__git_refs2 "$remote")" "$pfx" "$cur_"
589 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
593 if [ $lhs = 1 ]; then
594 __gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_"
596 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
600 if [ $lhs = 1 ]; then
601 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
603 __gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_"
609 __git_complete_strategy ()
611 __git_compute_merge_strategies
614 __gitcomp "$__git_merge_strategies"
619 __gitcomp "$__git_merge_strategies" "" "${cur##--strategy=}"
627 if test -n "${GIT_TESTING_COMMAND_COMPLETION:-}"
629 printf "%s" "${GIT_TESTING_COMMAND_COMPLETION}"
631 git help -a|egrep '^ [a-zA-Z0-9]'
635 __git_list_all_commands ()
638 for i in $(__git_commands)
641 *--*) : helper pattern;;
648 __git_compute_all_commands ()
650 test -n "$__git_all_commands" ||
651 __git_all_commands=$(__git_list_all_commands)
654 __git_list_porcelain_commands ()
657 __git_compute_all_commands
658 for i in $__git_all_commands
661 *--*) : helper pattern;;
662 applymbox) : ask gittus;;
663 applypatch) : ask gittus;;
664 archimport) : import;;
665 cat-file) : plumbing;;
666 check-attr) : plumbing;;
667 check-ignore) : plumbing;;
668 check-mailmap) : plumbing;;
669 check-ref-format) : plumbing;;
670 checkout-index) : plumbing;;
671 column) : internal helper;;
672 commit-tree) : plumbing;;
673 count-objects) : infrequent;;
674 credential) : credentials;;
675 credential-*) : credentials helper;;
676 cvsexportcommit) : export;;
677 cvsimport) : import;;
678 cvsserver) : daemon;;
680 diff-files) : plumbing;;
681 diff-index) : plumbing;;
682 diff-tree) : plumbing;;
683 fast-import) : import;;
684 fast-export) : export;;
685 fsck-objects) : plumbing;;
686 fetch-pack) : plumbing;;
687 fmt-merge-msg) : plumbing;;
688 for-each-ref) : plumbing;;
689 hash-object) : plumbing;;
690 http-*) : transport;;
691 index-pack) : plumbing;;
692 init-db) : deprecated;;
693 local-fetch) : plumbing;;
694 ls-files) : plumbing;;
695 ls-remote) : plumbing;;
696 ls-tree) : plumbing;;
697 mailinfo) : plumbing;;
698 mailsplit) : plumbing;;
699 merge-*) : plumbing;;
702 pack-objects) : plumbing;;
703 pack-redundant) : plumbing;;
704 pack-refs) : plumbing;;
705 parse-remote) : plumbing;;
706 patch-id) : plumbing;;
708 prune-packed) : plumbing;;
709 quiltimport) : import;;
710 read-tree) : plumbing;;
711 receive-pack) : plumbing;;
712 remote-*) : transport;;
714 rev-list) : plumbing;;
715 rev-parse) : plumbing;;
716 runstatus) : plumbing;;
717 sh-setup) : internal;;
719 show-ref) : plumbing;;
720 send-pack) : plumbing;;
721 show-index) : plumbing;;
723 stripspace) : plumbing;;
724 symbolic-ref) : plumbing;;
725 unpack-file) : plumbing;;
726 unpack-objects) : plumbing;;
727 update-index) : plumbing;;
728 update-ref) : plumbing;;
729 update-server-info) : daemon;;
730 upload-archive) : plumbing;;
731 upload-pack) : plumbing;;
732 write-tree) : plumbing;;
734 verify-pack) : infrequent;;
735 verify-tag) : plumbing;;
741 __git_porcelain_commands=
742 __git_compute_porcelain_commands ()
744 test -n "$__git_porcelain_commands" ||
745 __git_porcelain_commands=$(__git_list_porcelain_commands)
748 # Lists all set config variables starting with the given section prefix,
749 # with the prefix removed.
750 __git_get_config_variables ()
752 local section="$1" i IFS=$'\n'
753 for i in $(git --git-dir="$(__gitdir)" config --name-only --get-regexp "^$section\..*" 2>/dev/null); do
754 echo "${i#$section.}"
758 __git_pretty_aliases ()
760 __git_get_config_variables "pretty"
765 __git_get_config_variables "alias"
768 # __git_aliased_command requires 1 argument
769 __git_aliased_command ()
771 local word cmdline=$(git --git-dir="$(__gitdir)" \
772 config --get "alias.$1")
773 for word in $cmdline; do
779 \!*) : shell command alias ;;
781 *=*) : setting env ;;
783 \(\)) : skip parens of shell function definition ;;
784 {) : skip start of shell helper function ;;
785 :) : skip null command ;;
786 \'*) : skip opening quote after sh -c ;;
794 # __git_find_on_cmdline requires 1 argument
795 __git_find_on_cmdline ()
797 local word subcommand c=1
798 while [ $c -lt $cword ]; do
800 for subcommand in $1; do
801 if [ "$subcommand" = "$word" ]; then
810 # Echo the value of an option set on the command line or config
812 # $1: short option name
813 # $2: long option name including =
814 # $3: list of possible values
815 # $4: config string (optional)
818 # result="$(__git_get_option_value "-d" "--do-something=" \
819 # "yes no" "core.doSomething")"
821 # result is then either empty (no option set) or "yes" or "no"
823 # __git_get_option_value requires 3 arguments
824 __git_get_option_value ()
826 local c short_opt long_opt val
827 local result= values config_key word
835 while [ $c -ge 0 ]; do
837 for val in $values; do
838 if [ "$short_opt$val" = "$word" ] ||
839 [ "$long_opt$val" = "$word" ]; then
847 if [ -n "$config_key" ] && [ -z "$result" ]; then
848 result="$(git --git-dir="$(__gitdir)" config "$config_key")"
854 __git_has_doubledash ()
857 while [ $c -lt $cword ]; do
858 if [ "--" = "${words[c]}" ]; then
866 # Try to count non option arguments passed on the command line for the
867 # specified git command.
868 # When options are used, it is necessary to use the special -- option to
869 # tell the implementation were non option arguments begin.
870 # XXX this can not be improved, since options can appear everywhere, as
874 # __git_count_arguments requires 1 argument: the git command executed.
875 __git_count_arguments ()
879 # Skip "git" (first argument)
880 for ((i=1; i < ${#words[@]}; i++)); do
885 # Good; we can assume that the following are only non
890 # Skip the specified git command and discard git
903 __git_whitespacelist="nowarn warn error error-all fix"
907 local dir="$(__gitdir)"
908 if [ -d "$dir"/rebase-apply ]; then
909 __gitcomp "--skip --continue --resolved --abort"
914 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
919 --3way --committer-date-is-author-date --ignore-date
920 --ignore-whitespace --ignore-space-change
921 --interactive --keep --no-utf8 --signoff --utf8
922 --whitespace= --scissors
932 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
937 --stat --numstat --summary --check --index
938 --cached --index-info --reverse --reject --unidiff-zero
939 --apply --no-add --exclude=
940 --ignore-whitespace --ignore-space-change
941 --whitespace= --inaccurate-eof --verbose
952 --interactive --refresh --patch --update --dry-run
953 --ignore-errors --intent-to-add
958 # XXX should we check for --update and --all options ?
959 __git_complete_index_file "--others --modified --directory --no-empty-directory"
966 __gitcomp "$(git archive --list)" "" "${cur##--format=}"
970 __gitcomp_nl "$(__git_remotes)" "" "${cur##--remote=}"
975 --format= --list --verbose
976 --prefix= --remote= --exec=
986 __git_has_doubledash && return
988 local subcommands="start bad good skip reset visualize replay log run"
989 local subcommand="$(__git_find_on_cmdline "$subcommands")"
990 if [ -z "$subcommand" ]; then
991 if [ -f "$(__gitdir)"/BISECT_START ]; then
992 __gitcomp "$subcommands"
994 __gitcomp "replay start"
999 case "$subcommand" in
1000 bad|good|reset|skip|start)
1001 __gitcomp_nl "$(__git_refs)"
1010 local i c=1 only_local_ref="n" has_r="n"
1012 while [ $c -lt $cword ]; do
1015 -d|--delete|-m|--move) only_local_ref="y" ;;
1016 -r|--remotes) has_r="y" ;;
1022 --set-upstream-to=*)
1023 __gitcomp_nl "$(__git_refs)" "" "${cur##--set-upstream-to=}"
1027 --color --no-color --verbose --abbrev= --no-abbrev
1028 --track --no-track --contains --merged --no-merged
1029 --set-upstream-to= --edit-description --list
1030 --unset-upstream --delete --move --remotes
1034 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
1035 __gitcomp_nl "$(__git_heads)"
1037 __gitcomp_nl "$(__git_refs)"
1045 local cmd="${words[2]}"
1048 __gitcomp "create list-heads verify unbundle"
1051 # looking for a file
1056 __git_complete_revlist
1065 __git_has_doubledash && return
1069 __gitcomp "diff3 merge" "" "${cur##--conflict=}"
1073 --quiet --ours --theirs --track --no-track --merge
1074 --conflict= --orphan --patch
1078 # check if --track, --no-track, or --no-guess was specified
1079 # if so, disable DWIM mode
1080 local flags="--track --no-track --no-guess" track=1
1081 if [ -n "$(__git_find_on_cmdline "$flags")" ]; then
1084 __gitcomp_nl "$(__git_refs '' $track)"
1091 __gitcomp_nl "$(__git_refs)"
1096 local dir="$(__gitdir)"
1097 if [ -f "$dir"/CHERRY_PICK_HEAD ]; then
1098 __gitcomp "--continue --quit --abort"
1103 __gitcomp "--edit --no-commit --signoff --strategy= --mainline"
1106 __gitcomp_nl "$(__git_refs)"
1115 __gitcomp "--dry-run --quiet"
1120 # XXX should we check for -x option ?
1121 __git_complete_index_file "--others --directory"
1143 --recurse-submodules
1150 __git_untracked_file_modes="all no normal"
1156 __gitcomp_nl "$(__git_refs)" "" "${cur}"
1163 __gitcomp "default scissors strip verbatim whitespace
1164 " "" "${cur##--cleanup=}"
1167 --reuse-message=*|--reedit-message=*|\
1168 --fixup=*|--squash=*)
1169 __gitcomp_nl "$(__git_refs)" "" "${cur#*=}"
1172 --untracked-files=*)
1173 __gitcomp "$__git_untracked_file_modes" "" "${cur##--untracked-files=}"
1178 --all --author= --signoff --verify --no-verify
1180 --amend --include --only --interactive
1181 --dry-run --reuse-message= --reedit-message=
1182 --reset-author --file= --message= --template=
1183 --cleanup= --untracked-files --untracked-files=
1184 --verbose --quiet --fixup= --squash=
1189 if git rev-parse --verify --quiet HEAD >/dev/null; then
1190 __git_complete_index_file "--committable"
1192 # This is the first commit
1193 __git_complete_index_file "--cached"
1202 --all --tags --contains --abbrev= --candidates=
1203 --exact-match --debug --long --match --always
1207 __gitcomp_nl "$(__git_refs)"
1210 __git_diff_algorithms="myers minimal patience histogram"
1212 __git_diff_submodule_formats="diff log short"
1214 __git_diff_common_options="--stat --numstat --shortstat --summary
1215 --patch-with-stat --name-only --name-status --color
1216 --no-color --color-words --no-renames --check
1217 --full-index --binary --abbrev --diff-filter=
1218 --find-copies-harder
1219 --text --ignore-space-at-eol --ignore-space-change
1220 --ignore-all-space --ignore-blank-lines --exit-code
1221 --quiet --ext-diff --no-ext-diff
1222 --no-prefix --src-prefix= --dst-prefix=
1223 --inter-hunk-context=
1224 --patience --histogram --minimal
1225 --raw --word-diff --word-diff-regex=
1226 --dirstat --dirstat= --dirstat-by-file
1227 --dirstat-by-file= --cumulative
1229 --submodule --submodule=
1234 __git_has_doubledash && return
1238 __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
1242 __gitcomp "$__git_diff_submodule_formats" "" "${cur##--submodule=}"
1246 __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
1247 --base --ours --theirs --no-index
1248 $__git_diff_common_options
1253 __git_complete_revlist_file
1256 __git_mergetools_common="diffuse diffmerge ecmerge emerge kdiff3 meld opendiff
1257 tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc codecompare
1262 __git_has_doubledash && return
1266 __gitcomp "$__git_mergetools_common kompare" "" "${cur##--tool=}"
1270 __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
1271 --base --ours --theirs
1272 --no-renames --diff-filter= --find-copies-harder
1273 --relative --ignore-submodules
1278 __git_complete_revlist_file
1281 __git_fetch_recurse_submodules="yes on-demand no"
1283 __git_fetch_options="
1284 --quiet --verbose --append --upload-pack --force --keep --depth=
1285 --tags --no-tags --all --prune --dry-run --recurse-submodules=
1291 --recurse-submodules=*)
1292 __gitcomp "$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}"
1296 __gitcomp "$__git_fetch_options"
1300 __git_complete_remote_or_refspec
1303 __git_format_patch_options="
1304 --stdout --attach --no-attach --thread --thread= --no-thread
1305 --numbered --start-number --numbered-files --keep-subject --signoff
1306 --signature --no-signature --in-reply-to= --cc= --full-index --binary
1307 --not --all --cover-letter --no-prefix --src-prefix= --dst-prefix=
1308 --inline --suffix= --ignore-if-in-upstream --subject-prefix=
1309 --output-directory --reroll-count --to= --quiet --notes
1312 _git_format_patch ()
1318 " "" "${cur##--thread=}"
1322 __gitcomp "$__git_format_patch_options"
1326 __git_complete_revlist
1334 --tags --root --unreachable --cache --no-reflogs --full
1335 --strict --verbose --lost-found
1346 __gitcomp "--prune --aggressive"
1357 __git_match_ctag() {
1358 awk "/^${1//\//\\/}/ { print \$1 }" "$2"
1363 __git_has_doubledash && return
1369 --text --ignore-case --word-regexp --invert-match
1370 --full-name --line-number
1371 --extended-regexp --basic-regexp --fixed-strings
1374 --files-with-matches --name-only
1375 --files-without-match
1378 --and --or --not --all-match
1384 case "$cword,$prev" in
1386 if test -r tags; then
1387 __gitcomp_nl "$(__git_match_ctag "$cur" tags)"
1393 __gitcomp_nl "$(__git_refs)"
1400 __gitcomp "--all --guides --info --man --web"
1404 __git_compute_all_commands
1405 __gitcomp "$__git_all_commands $(__git_aliases)
1406 attributes cli core-tutorial cvs-migration
1407 diffcore everyday gitk glossary hooks ignore modules
1408 namespaces repository-layout revisions tutorial tutorial-2
1418 false true umask group all world everybody
1419 " "" "${cur##--shared=}"
1423 __gitcomp "--quiet --bare --template= --shared --shared="
1433 __gitcomp "--cached --deleted --modified --others --ignored
1434 --stage --directory --no-empty-directory --unmerged
1435 --killed --exclude= --exclude-from=
1436 --exclude-per-directory= --exclude-standard
1437 --error-unmatch --with-tree= --full-name
1438 --abbrev --ignored --exclude-per-directory
1444 # XXX ignore options like --modified and always suggest all cached
1446 __git_complete_index_file "--cached"
1451 __gitcomp_nl "$(__git_remotes)"
1459 # Options that go well for log, shortlog and gitk
1460 __git_log_common_options="
1462 --branches --tags --remotes
1463 --first-parent --merges --no-merges
1465 --max-age= --since= --after=
1466 --min-age= --until= --before=
1467 --min-parents= --max-parents=
1468 --no-min-parents --no-max-parents
1470 # Options that go well for log and gitk (not shortlog)
1471 __git_log_gitk_options="
1472 --dense --sparse --full-history
1473 --simplify-merges --simplify-by-decoration
1474 --left-right --notes --no-notes
1476 # Options that go well for log and shortlog (not gitk)
1477 __git_log_shortlog_options="
1478 --author= --committer= --grep=
1479 --all-match --invert-grep
1482 __git_log_pretty_formats="oneline short medium full fuller email raw format:"
1483 __git_log_date_formats="relative iso8601 rfc2822 short local default raw"
1487 __git_has_doubledash && return
1489 local g="$(git rev-parse --git-dir 2>/dev/null)"
1491 if [ -f "$g/MERGE_HEAD" ]; then
1495 --pretty=*|--format=*)
1496 __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
1501 __gitcomp "$__git_log_date_formats" "" "${cur##--date=}"
1505 __gitcomp "full short no" "" "${cur##--decorate=}"
1509 __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
1513 __gitcomp "$__git_diff_submodule_formats" "" "${cur##--submodule=}"
1518 $__git_log_common_options
1519 $__git_log_shortlog_options
1520 $__git_log_gitk_options
1521 --root --topo-order --date-order --reverse
1522 --follow --full-diff
1523 --abbrev-commit --abbrev=
1524 --relative-date --date=
1525 --pretty= --format= --oneline
1530 --decorate --decorate=
1532 --parents --children
1534 $__git_diff_common_options
1535 --pickaxe-all --pickaxe-regex
1540 __git_complete_revlist
1543 # Common merge options shared by git-merge(1) and git-pull(1).
1544 __git_merge_options="
1545 --no-commit --no-stat --log --no-log --squash --strategy
1546 --commit --stat --no-squash --ff --no-ff --ff-only --edit --no-edit
1547 --verify-signatures --no-verify-signatures --gpg-sign
1548 --quiet --verbose --progress --no-progress
1553 __git_complete_strategy && return
1557 __gitcomp "$__git_merge_options
1558 --rerere-autoupdate --no-rerere-autoupdate --abort --continue"
1561 __gitcomp_nl "$(__git_refs)"
1568 __gitcomp "$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"
1582 __gitcomp "--octopus --independent --is-ancestor --fork-point"
1586 __gitcomp_nl "$(__git_refs)"
1593 __gitcomp "--dry-run"
1598 if [ $(__git_count_arguments "mv") -gt 0 ]; then
1599 # We need to show both cached and untracked files (including
1600 # empty directories) since this may not be the last argument.
1601 __git_complete_index_file "--cached --others --directory"
1603 __git_complete_index_file "--cached"
1609 __gitcomp "--tags --all --stdin"
1614 local subcommands='add append copy edit list prune remove show'
1615 local subcommand="$(__git_find_on_cmdline "$subcommands")"
1617 case "$subcommand,$cur" in
1624 __gitcomp_nl "$(__git_refs)"
1627 __gitcomp "$subcommands --ref"
1631 add,--reuse-message=*|append,--reuse-message=*|\
1632 add,--reedit-message=*|append,--reedit-message=*)
1633 __gitcomp_nl "$(__git_refs)" "" "${cur#*=}"
1636 __gitcomp '--file= --message= --reedit-message=
1643 __gitcomp '--dry-run --verbose'
1652 __gitcomp_nl "$(__git_refs)"
1661 __git_complete_strategy && return
1664 --recurse-submodules=*)
1665 __gitcomp "$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}"
1670 --rebase --no-rebase
1671 $__git_merge_options
1672 $__git_fetch_options
1677 __git_complete_remote_or_refspec
1680 __git_push_recurse_submodules="check on-demand"
1682 __git_complete_force_with_lease ()
1690 __gitcomp_nl "$(__git_refs)" "" "${cur_#*:}"
1693 __gitcomp_nl "$(__git_refs)" "" "$cur_"
1702 __gitcomp_nl "$(__git_remotes)"
1705 --recurse-submodules)
1706 __gitcomp "$__git_push_recurse_submodules"
1712 __gitcomp_nl "$(__git_remotes)" "" "${cur##--repo=}"
1715 --recurse-submodules=*)
1716 __gitcomp "$__git_push_recurse_submodules" "" "${cur##--recurse-submodules=}"
1719 --force-with-lease=*)
1720 __git_complete_force_with_lease "${cur##--force-with-lease=}"
1725 --all --mirror --tags --dry-run --force --verbose
1726 --quiet --prune --delete --follow-tags
1727 --receive-pack= --repo= --set-upstream
1728 --force-with-lease --force-with-lease= --recurse-submodules=
1733 __git_complete_remote_or_refspec
1738 local dir="$(__gitdir)"
1739 if [ -f "$dir"/rebase-merge/interactive ]; then
1740 __gitcomp "--continue --skip --abort --quit --edit-todo"
1742 elif [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
1743 __gitcomp "--continue --skip --abort --quit"
1746 __git_complete_strategy && return
1749 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
1754 --onto --merge --strategy --interactive
1755 --preserve-merges --stat --no-stat
1756 --committer-date-is-author-date --ignore-date
1757 --ignore-whitespace --whitespace=
1758 --autosquash --no-autosquash
1759 --fork-point --no-fork-point
1760 --autostash --no-autostash
1761 --verify --no-verify
1762 --keep-empty --root --force-rebase --no-ff
1768 __gitcomp_nl "$(__git_refs)"
1773 local subcommands="show delete expire"
1774 local subcommand="$(__git_find_on_cmdline "$subcommands")"
1776 if [ -z "$subcommand" ]; then
1777 __gitcomp "$subcommands"
1779 __gitcomp_nl "$(__git_refs)"
1783 __git_send_email_confirm_options="always never auto cc compose"
1784 __git_send_email_suppresscc_options="author self cc bodycc sob cccmd body all"
1789 --to|--cc|--bcc|--from)
1791 $(git --git-dir="$(__gitdir)" send-email --dump-aliases 2>/dev/null)
1800 $__git_send_email_confirm_options
1801 " "" "${cur##--confirm=}"
1806 $__git_send_email_suppresscc_options
1807 " "" "${cur##--suppress-cc=}"
1811 --smtp-encryption=*)
1812 __gitcomp "ssl tls" "" "${cur##--smtp-encryption=}"
1818 " "" "${cur##--thread=}"
1821 --to=*|--cc=*|--bcc=*|--from=*)
1823 $(git --git-dir="$(__gitdir)" send-email --dump-aliases 2>/dev/null)
1828 __gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to
1829 --compose --confirm= --dry-run --envelope-sender
1831 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
1832 --no-suppress-from --no-thread --quiet
1833 --signed-off-by-cc --smtp-pass --smtp-server
1834 --smtp-server-port --smtp-encryption= --smtp-user
1835 --subject --suppress-cc= --suppress-from --thread --to
1836 --validate --no-validate
1837 $__git_format_patch_options"
1841 __git_complete_revlist
1852 local untracked_state
1855 --ignore-submodules=*)
1856 __gitcomp "none untracked dirty all" "" "${cur##--ignore-submodules=}"
1859 --untracked-files=*)
1860 __gitcomp "$__git_untracked_file_modes" "" "${cur##--untracked-files=}"
1865 always never auto column row plain dense nodense
1866 " "" "${cur##--column=}"
1871 --short --branch --porcelain --long --verbose
1872 --untracked-files= --ignore-submodules= --ignored
1873 --column= --no-column
1879 untracked_state="$(__git_get_option_value "-u" "--untracked-files=" \
1880 "$__git_untracked_file_modes" "status.showUntrackedFiles")"
1882 case "$untracked_state" in
1884 # --ignored option does not matter
1888 complete_opt="--cached --directory --no-empty-directory --others"
1890 if [ -n "$(__git_find_on_cmdline "--ignored")" ]; then
1891 complete_opt="$complete_opt --ignored --exclude=*"
1896 __git_complete_index_file "$complete_opt"
1899 __git_config_get_set_variables ()
1901 local prevword word config_file= c=$cword
1902 while [ $c -gt 1 ]; do
1905 --system|--global|--local|--file=*)
1910 config_file="$word $prevword"
1918 git --git-dir="$(__gitdir)" config $config_file --name-only --list 2>/dev/null
1924 branch.*.remote|branch.*.pushremote)
1925 __gitcomp_nl "$(__git_remotes)"
1929 __gitcomp_nl "$(__git_refs)"
1933 __gitcomp "false true preserve interactive"
1937 __gitcomp_nl "$(__git_remotes)"
1941 local remote="${prev#remote.}"
1942 remote="${remote%.fetch}"
1943 if [ -z "$cur" ]; then
1944 __gitcomp_nl "refs/heads/" "" "" ""
1947 __gitcomp_nl "$(__git_refs_remotes "$remote")"
1951 local remote="${prev#remote.}"
1952 remote="${remote%.push}"
1953 __gitcomp_nl "$(git --git-dir="$(__gitdir)" \
1954 for-each-ref --format='%(refname):%(refname)' \
1958 pull.twohead|pull.octopus)
1959 __git_compute_merge_strategies
1960 __gitcomp "$__git_merge_strategies"
1963 color.branch|color.diff|color.interactive|\
1964 color.showbranch|color.status|color.ui)
1965 __gitcomp "always never auto"
1969 __gitcomp "false true"
1974 normal black red green yellow blue magenta cyan white
1975 bold dim ul blink reverse
1980 __gitcomp "log short"
1984 __gitcomp "man info web html"
1988 __gitcomp "$__git_log_date_formats"
1991 sendemail.aliasesfiletype)
1992 __gitcomp "mutt mailrc pine elm gnus"
1996 __gitcomp "$__git_send_email_confirm_options"
1999 sendemail.suppresscc)
2000 __gitcomp "$__git_send_email_suppresscc_options"
2003 sendemail.transferencoding)
2004 __gitcomp "7bit 8bit quoted-printable base64"
2007 --get|--get-all|--unset|--unset-all)
2008 __gitcomp_nl "$(__git_config_get_set_variables)"
2018 --system --global --local --file=
2019 --list --replace-all
2020 --get --get-all --get-regexp
2021 --add --unset --unset-all
2022 --remove-section --rename-section
2028 local pfx="${cur%.*}." cur_="${cur##*.}"
2029 __gitcomp "remote pushremote merge mergeoptions rebase" "$pfx" "$cur_"
2033 local pfx="${cur%.*}." cur_="${cur#*.}"
2034 __gitcomp_nl "$(__git_heads)" "$pfx" "$cur_" "."
2035 __gitcomp_nl_append $'autosetupmerge\nautosetuprebase\n' "$pfx" "$cur_"
2039 local pfx="${cur%.*}." cur_="${cur##*.}"
2041 argprompt cmd confirm needsfile noconsole norescan
2042 prompt revprompt revunmerged title
2047 local pfx="${cur%.*}." cur_="${cur##*.}"
2048 __gitcomp "cmd path" "$pfx" "$cur_"
2052 local pfx="${cur%.*}." cur_="${cur##*.}"
2053 __gitcomp "cmd path" "$pfx" "$cur_"
2057 local pfx="${cur%.*}." cur_="${cur##*.}"
2058 __gitcomp "cmd path trustExitCode" "$pfx" "$cur_"
2062 local pfx="${cur%.*}." cur_="${cur#*.}"
2063 __git_compute_all_commands
2064 __gitcomp_nl "$__git_all_commands" "$pfx" "$cur_"
2068 local pfx="${cur%.*}." cur_="${cur##*.}"
2070 url proxy fetch push mirror skipDefaultUpdate
2071 receivepack uploadpack tagopt pushurl
2076 local pfx="${cur%.*}." cur_="${cur#*.}"
2077 __gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "."
2078 __gitcomp_nl_append "pushdefault" "$pfx" "$cur_"
2082 local pfx="${cur%.*}." cur_="${cur##*.}"
2083 __gitcomp "insteadOf pushInsteadOf" "$pfx" "$cur_"
2089 advice.commitBeforeMerge
2091 advice.implicitIdentity
2092 advice.pushNonFastForward
2093 advice.resolveConflict
2097 apply.ignorewhitespace
2099 branch.autosetupmerge
2100 branch.autosetuprebase
2104 color.branch.current
2109 color.decorate.branch
2110 color.decorate.remoteBranch
2111 color.decorate.stash
2121 color.diff.whitespace
2126 color.grep.linenumber
2129 color.grep.separator
2131 color.interactive.error
2132 color.interactive.header
2133 color.interactive.help
2134 color.interactive.prompt
2139 color.status.changed
2141 color.status.nobranch
2142 color.status.unmerged
2143 color.status.untracked
2144 color.status.updated
2153 core.bigFileThreshold
2156 core.deltaBaseCacheLimit
2161 core.fsyncobjectfiles
2165 core.logAllRefUpdates
2166 core.loosecompression
2169 core.packedGitWindowSize
2171 core.preferSymlinkRefs
2174 core.repositoryFormatVersion
2176 core.sharedRepository
2181 core.warnAmbiguousRefs
2184 diff.autorefreshindex
2186 diff.ignoreSubmodules
2193 diff.suppressBlankEmpty
2199 fetch.recurseSubmodules
2210 format.subjectprefix
2221 gc.reflogexpireunreachable
2225 gitcvs.commitmsgannotation
2226 gitcvs.dbTableNamePrefix
2237 gui.copyblamethreshold
2241 gui.matchtrackingbranch
2242 gui.newbranchtemplate
2243 gui.pruneduringfetch
2244 gui.spellingdictionary
2261 http.sslCertPasswordProtected
2266 i18n.logOutputEncoding
2272 imap.preformattedHTML
2282 interactive.singlekey
2298 mergetool.keepBackup
2299 mergetool.keepTemporaries
2304 notes.rewrite.rebase
2308 pack.deltaCacheLimit
2325 receive.denyCurrentBranch
2326 receive.denyDeleteCurrent
2328 receive.denyNonFastForwards
2331 receive.updateserverinfo
2334 repack.usedeltabaseoffset
2338 sendemail.aliasesfile
2339 sendemail.aliasfiletype
2343 sendemail.chainreplyto
2345 sendemail.envelopesender
2349 sendemail.signedoffbycc
2350 sendemail.smtpdomain
2351 sendemail.smtpencryption
2353 sendemail.smtpserver
2354 sendemail.smtpserveroption
2355 sendemail.smtpserverport
2357 sendemail.suppresscc
2358 sendemail.suppressfrom
2363 status.relativePaths
2364 status.showUntrackedFiles
2365 status.submodulesummary
2368 transfer.unpackLimit
2380 local subcommands="add rename remove set-head set-branches set-url show prune update"
2381 local subcommand="$(__git_find_on_cmdline "$subcommands")"
2382 if [ -z "$subcommand" ]; then
2383 __gitcomp "$subcommands"
2387 case "$subcommand" in
2388 rename|remove|set-url|show|prune)
2389 __gitcomp_nl "$(__git_remotes)"
2391 set-head|set-branches)
2392 __git_complete_remote_or_refspec
2395 __gitcomp "$(__git_get_config_variables "remotes")"
2404 __gitcomp_nl "$(__git_refs)"
2409 __git_has_doubledash && return
2413 __gitcomp "--merge --mixed --hard --soft --patch"
2417 __gitcomp_nl "$(__git_refs)"
2422 local dir="$(__gitdir)"
2423 if [ -f "$dir"/REVERT_HEAD ]; then
2424 __gitcomp "--continue --quit --abort"
2429 __gitcomp "--edit --mainline --no-edit --no-commit --signoff"
2433 __gitcomp_nl "$(__git_refs)"
2440 __gitcomp "--cached --dry-run --ignore-unmatch --quiet"
2445 __git_complete_index_file "--cached"
2450 __git_has_doubledash && return
2455 $__git_log_common_options
2456 $__git_log_shortlog_options
2457 --numbered --summary
2462 __git_complete_revlist
2467 __git_has_doubledash && return
2470 --pretty=*|--format=*)
2471 __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
2476 __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
2480 __gitcomp "$__git_diff_submodule_formats" "" "${cur##--submodule=}"
2484 __gitcomp "--pretty= --format= --abbrev-commit --oneline
2486 $__git_diff_common_options
2491 __git_complete_revlist_file
2499 --all --remotes --topo-order --date-order --current --more=
2500 --list --independent --merge-base --no-name
2502 --sha1-name --sparse --topics --reflog
2507 __git_complete_revlist
2512 local save_opts='--all --keep-index --no-keep-index --quiet --patch --include-untracked'
2513 local subcommands='save list show apply clear drop pop create branch'
2514 local subcommand="$(__git_find_on_cmdline "$subcommands")"
2515 if [ -z "$subcommand" ]; then
2518 __gitcomp "$save_opts"
2521 if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then
2522 __gitcomp "$subcommands"
2527 case "$subcommand,$cur" in
2529 __gitcomp "$save_opts"
2532 __gitcomp "--index --quiet"
2537 show,--*|branch,--*)
2540 if [ $cword -eq 3 ]; then
2541 __gitcomp_nl "$(__git_refs)";
2543 __gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \
2544 | sed -n -e 's/:.*//p')"
2547 show,*|apply,*|drop,*|pop,*)
2548 __gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \
2549 | sed -n -e 's/:.*//p')"
2559 __git_has_doubledash && return
2561 local subcommands="add status init deinit update summary foreach sync"
2562 if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then
2565 __gitcomp "--quiet --cached"
2568 __gitcomp "$subcommands"
2578 init fetch clone rebase dcommit log find-rev
2579 set-tree commit-diff info create-ignore propget
2580 proplist show-ignore show-externals branch tag blame
2581 migrate mkdirs reset gc
2583 local subcommand="$(__git_find_on_cmdline "$subcommands")"
2584 if [ -z "$subcommand" ]; then
2585 __gitcomp "$subcommands"
2587 local remote_opts="--username= --config-dir= --no-auth-cache"
2589 --follow-parent --authors-file= --repack=
2590 --no-metadata --use-svm-props --use-svnsync-props
2591 --log-window-size= --no-checkout --quiet
2592 --repack-flags --use-log-author --localtime
2593 --ignore-paths= --include-paths= $remote_opts
2596 --template= --shared= --trunk= --tags=
2597 --branches= --stdlayout --minimize-url
2598 --no-metadata --use-svm-props --use-svnsync-props
2599 --rewrite-root= --prefix= --use-log-author
2600 --add-author-from $remote_opts
2603 --edit --rmdir --find-copies-harder --copy-similarity=
2606 case "$subcommand,$cur" in
2608 __gitcomp "--revision= --fetch-all $fc_opts"
2611 __gitcomp "--revision= $fc_opts $init_opts"
2614 __gitcomp "$init_opts"
2618 --merge --strategy= --verbose --dry-run
2619 --fetch-all --no-rebase --commit-url
2620 --revision --interactive $cmt_opts $fc_opts
2624 __gitcomp "--stdin $cmt_opts $fc_opts"
2626 create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\
2627 show-externals,--*|mkdirs,--*)
2628 __gitcomp "--revision="
2632 --limit= --revision= --verbose --incremental
2633 --oneline --show-commit --non-recursive
2634 --authors-file= --color
2639 --merge --verbose --strategy= --local
2640 --fetch-all --dry-run $fc_opts
2644 __gitcomp "--message= --file= --revision= $cmt_opts"
2650 __gitcomp "--dry-run --message --tag"
2653 __gitcomp "--dry-run --message"
2656 __gitcomp "--git-format"
2660 --config-dir= --ignore-paths= --minimize
2661 --no-auth-cache --username=
2665 __gitcomp "--revision= --parent"
2676 while [ $c -lt $cword ]; do
2680 __gitcomp_nl "$(__git_tags)"
2695 __gitcomp_nl "$(__git_tags)"
2699 __gitcomp_nl "$(__git_refs)"
2706 --list --delete --verify --annotate --message --file
2707 --sign --cleanup --local-user --force --column --sort
2708 --contains --points-at
2721 local subcommands="add list lock prune unlock"
2722 local subcommand="$(__git_find_on_cmdline "$subcommands")"
2723 if [ -z "$subcommand" ]; then
2724 __gitcomp "$subcommands"
2726 case "$subcommand,$cur" in
2728 __gitcomp "--detach"
2731 __gitcomp "--porcelain"
2734 __gitcomp "--reason"
2737 __gitcomp "--dry-run --expire --verbose"
2747 local i c=1 command __git_dir
2749 while [ $c -lt $cword ]; do
2752 --git-dir=*) __git_dir="${i#--git-dir=}" ;;
2753 --git-dir) ((c++)) ; __git_dir="${words[c]}" ;;
2754 --bare) __git_dir="." ;;
2755 --help) command="help"; break ;;
2756 -c|--work-tree|--namespace) ((c++)) ;;
2758 *) command="$i"; break ;;
2763 if [ -z "$command" ]; then
2778 --no-replace-objects
2782 *) __git_compute_porcelain_commands
2783 __gitcomp "$__git_porcelain_commands $(__git_aliases)" ;;
2788 local completion_func="_git_${command//-/_}"
2789 declare -f $completion_func >/dev/null && $completion_func && return
2791 local expansion=$(__git_aliased_command "$command")
2792 if [ -n "$expansion" ]; then
2794 completion_func="_git_${expansion//-/_}"
2795 declare -f $completion_func >/dev/null && $completion_func
2801 __git_has_doubledash && return
2803 local g="$(__gitdir)"
2805 if [ -f "$g/MERGE_HEAD" ]; then
2811 $__git_log_common_options
2812 $__git_log_gitk_options
2818 __git_complete_revlist
2821 if [[ -n ${ZSH_VERSION-} ]]; then
2822 echo "WARNING: this script is deprecated, please see git-completion.zsh" 1>&2
2824 autoload -U +X compinit && compinit
2830 local cur_="${3-$cur}"
2836 local c IFS=$' \t\n'
2844 array[${#array[@]}+1]="$c"
2847 compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
2858 compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
2867 compadd -Q -p "${2-}" -f -- ${=1} && _ret=0
2872 local _ret=1 cur cword prev
2873 cur=${words[CURRENT]}
2874 prev=${words[CURRENT-1]}
2876 emulate ksh -c __${service}_main
2877 let _ret && _default && _ret=0
2881 compdef _git git gitk
2887 local cur words cword prev
2888 _get_comp_words_by_ref -n =: cur words cword prev
2892 # Setup completion for certain functions defined above by setting common
2893 # variables and workarounds.
2894 # This is NOT a public function; use at your own risk.
2897 local wrapper="__git_wrap${2}"
2898 eval "$wrapper () { __git_func_wrap $2 ; }"
2899 complete -o bashdefault -o default -o nospace -F $wrapper $1 2>/dev/null \
2900 || complete -o default -o nospace -F $wrapper $1
2903 # wrapper for backwards compatibility
2906 __git_wrap__git_main
2909 # wrapper for backwards compatibility
2912 __git_wrap__gitk_main
2915 __git_complete git __git_main
2916 __git_complete gitk __gitk_main
2918 # The following are necessary only for Cygwin, and only are needed
2919 # when the user has tab-completed the executable name and consequently
2920 # included the '.exe' suffix.
2922 if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
2923 __git_complete git.exe __git_main