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_C_args-}" ]; then
43 git "${__git_C_args[@]}" \
44 ${__git_dir:+--git-dir="$__git_dir"} \
45 rev-parse --absolute-git-dir 2>/dev/null
46 elif [ -n "${__git_dir-}" ]; then
47 test -d "$__git_dir" || return 1
49 elif [ -n "${GIT_DIR-}" ]; then
50 test -d "${GIT_DIR-}" || return 1
52 elif [ -d .git ]; then
55 git rev-parse --git-dir 2>/dev/null
57 elif [ -d "$1/.git" ]; then
64 # Runs git with all the options given as argument, respecting any
65 # '--git-dir=<path>' and '-C <path>' options present on the command line
68 git ${__git_C_args:+"${__git_C_args[@]}"} \
69 ${__git_dir:+--git-dir="$__git_dir"} "$@" 2>/dev/null
72 # The following function is based on code from:
74 # bash_completion - programmable completion functions for bash 3.2+
76 # Copyright © 2006-2008, Ian Macdonald <ian@caliban.org>
77 # © 2009-2010, Bash Completion Maintainers
78 # <bash-completion-devel@lists.alioth.debian.org>
80 # This program is free software; you can redistribute it and/or modify
81 # it under the terms of the GNU General Public License as published by
82 # the Free Software Foundation; either version 2, or (at your option)
85 # This program is distributed in the hope that it will be useful,
86 # but WITHOUT ANY WARRANTY; without even the implied warranty of
87 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
88 # GNU General Public License for more details.
90 # You should have received a copy of the GNU General Public License
91 # along with this program; if not, write to the Free Software Foundation,
92 # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
94 # The latest version of this software can be obtained here:
96 # http://bash-completion.alioth.debian.org/
100 # This function can be used to access a tokenized list of words
101 # on the command line:
103 # __git_reassemble_comp_words_by_ref '=:'
104 # if test "${words_[cword_-1]}" = -w
109 # The argument should be a collection of characters from the list of
110 # word completion separators (COMP_WORDBREAKS) to treat as ordinary
113 # This is roughly equivalent to going back in time and setting
114 # COMP_WORDBREAKS to exclude those characters. The intent is to
115 # make option types like --date=<type> and <rev>:<path> easy to
116 # recognize by treating each shell word as a single token.
118 # It is best not to set COMP_WORDBREAKS directly because the value is
119 # shared with other completion scripts. By the time the completion
120 # function gets called, COMP_WORDS has already been populated so local
121 # changes to COMP_WORDBREAKS have no effect.
123 # Output: words_, cword_, cur_.
125 __git_reassemble_comp_words_by_ref()
127 local exclude i j first
128 # Which word separators to exclude?
129 exclude="${1//[^$COMP_WORDBREAKS]}"
131 if [ -z "$exclude" ]; then
132 words_=("${COMP_WORDS[@]}")
135 # List of word completion separators has shrunk;
136 # re-assemble words to complete.
137 for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)); do
138 # Append each nonempty word consisting of just
139 # word separator characters to the current word.
143 [ -n "${COMP_WORDS[$i]}" ] &&
144 # word consists of excluded word separators
145 [ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ]
147 # Attach to the previous token,
148 # unless the previous token is the command name.
149 if [ $j -ge 2 ] && [ -n "$first" ]; then
153 words_[$j]=${words_[j]}${COMP_WORDS[i]}
154 if [ $i = $COMP_CWORD ]; then
157 if (($i < ${#COMP_WORDS[@]} - 1)); then
164 words_[$j]=${words_[j]}${COMP_WORDS[i]}
165 if [ $i = $COMP_CWORD ]; then
171 if ! type _get_comp_words_by_ref >/dev/null 2>&1; then
172 _get_comp_words_by_ref ()
174 local exclude cur_ words_ cword_
175 if [ "$1" = "-n" ]; then
179 __git_reassemble_comp_words_by_ref "$exclude"
180 cur_=${words_[cword_]}
181 while [ $# -gt 0 ]; do
187 prev=${words_[$cword_-1]}
190 words=("${words_[@]}")
203 local x i=${#COMPREPLY[@]}
205 if [[ "$x" == "$3"* ]]; then
206 COMPREPLY[i++]="$2$x$4"
217 # Generates completion reply, appending a space to possible completion words,
219 # It accepts 1 to 4 arguments:
220 # 1: List of possible completion words.
221 # 2: A prefix to be added to each possible completion word (optional).
222 # 3: Generate possible completion matches for this word (optional).
223 # 4: A suffix to be appended to each possible completion word (optional).
226 local cur_="${3-$cur}"
232 local c i=0 IFS=$' \t\n'
235 if [[ $c == "$cur_"* ]]; then
240 COMPREPLY[i++]="${2-}$c"
247 # Variation of __gitcomp_nl () that appends to the existing list of
248 # completion candidates, COMPREPLY.
249 __gitcomp_nl_append ()
252 __gitcompappend "$1" "${2-}" "${3-$cur}" "${4- }"
255 # Generates completion reply from newline-separated possible completion words
256 # by appending a space to all of them.
257 # It accepts 1 to 4 arguments:
258 # 1: List of possible completion words, separated by a single newline.
259 # 2: A prefix to be added to each possible completion word (optional).
260 # 3: Generate possible completion matches for this word (optional).
261 # 4: A suffix to be appended to each possible completion word instead of
262 # the default space (optional). If specified but empty, nothing is
267 __gitcomp_nl_append "$@"
270 # Generates completion reply with compgen from newline-separated possible
271 # completion filenames.
272 # It accepts 1 to 3 arguments:
273 # 1: List of possible completion filenames, separated by a single newline.
274 # 2: A directory prefix to be added to each possible completion filename
276 # 3: Generate possible completion matches for this word (optional).
281 # XXX does not work when the directory prefix contains a tilde,
282 # since tilde expansion is not applied.
283 # This means that COMPREPLY will be empty and Bash default
284 # completion will be used.
285 __gitcompadd "$1" "${2-}" "${3-$cur}" ""
287 # use a hack to enable file mode in bash < 4
288 compopt -o filenames +o nospace 2>/dev/null ||
289 compgen -f /non-existing-dir/ > /dev/null
292 # Execute 'git ls-files', unless the --committable option is specified, in
293 # which case it runs 'git diff-index' to find out the files that can be
294 # committed. It return paths relative to the directory specified in the first
295 # argument, and using the options specified in the second argument.
296 __git_ls_files_helper ()
298 if [ "$2" == "--committable" ]; then
299 __git -C "$1" diff-index --name-only --relative HEAD
301 # NOTE: $2 is not quoted in order to support multiple options
302 __git -C "$1" ls-files --exclude-standard $2
307 # __git_index_files accepts 1 or 2 arguments:
308 # 1: Options to pass to ls-files (required).
309 # 2: A directory path (optional).
310 # If provided, only files within the specified directory are listed.
311 # Sub directories are never recursed. Path must have a trailing
315 local dir="$(__gitdir)" root="${2-.}" file
317 if [ -d "$dir" ]; then
318 __git_ls_files_helper "$root" "$1" |
319 while read -r file; do
321 ?*/*) echo "${file%%/*}" ;;
330 local dir="$(__gitdir)"
331 if [ -d "$dir" ]; then
332 __git for-each-ref --format='%(refname:short)' refs/heads
339 local dir="$(__gitdir)"
340 if [ -d "$dir" ]; then
341 __git for-each-ref --format='%(refname:short)' refs/tags
346 # Lists refs from the local (by default) or from a remote repository.
347 # It accepts 0, 1 or 2 arguments:
348 # 1: The remote to list refs from (optional; ignored, if set but empty).
349 # Can be the name of a configured remote, a path, or a URL.
350 # 2: In addition to local refs, list unique branches from refs/remotes/ for
351 # 'git checkout's tracking DWIMery (optional; ignored, if set but empty).
354 local i hash dir="$(__gitdir)" track="${2-}"
355 local list_refs_from=path remote="${1-}"
356 local format refs pfx
358 if [ -z "$remote" ]; then
359 if [ -z "$dir" ]; then
363 if __git_is_configured_remote "$remote"; then
364 # configured remote takes precedence over a
365 # local directory with the same name
366 list_refs_from=remote
367 elif [ -d "$remote/.git" ]; then
369 elif [ -d "$remote" ]; then
376 if [ "$list_refs_from" = path ]; then
384 [[ "$cur" == ^* ]] && pfx="^"
385 for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do
386 if [ -e "$dir/$i" ]; then echo $pfx$i; fi
388 format="refname:short"
389 refs="refs/tags refs/heads refs/remotes"
392 __git_dir="$dir" __git for-each-ref --format="$pfx%($format)" \
394 if [ -n "$track" ]; then
395 # employ the heuristic used by git checkout
396 # Try to find a remote branch that matches the completion word
397 # but only output if the branch name is unique
399 __git for-each-ref --shell --format="ref=%(refname:short)" \
401 while read -r entry; do
404 if [[ "$ref" == "$cur"* ]]; then
407 done | sort | uniq -u
413 __git ls-remote "$remote" "$cur*" | \
414 while read -r hash i; do
422 if [ "$list_refs_from" = remote ]; then
424 __git for-each-ref --format="%(refname:short)" \
425 "refs/remotes/$remote/" | sed -e "s#^$remote/##"
427 __git ls-remote "$remote" HEAD \
428 "refs/tags/*" "refs/heads/*" "refs/remotes/*" |
429 while read -r hash i; do
432 refs/*) echo "${i#refs/*/}" ;;
433 *) echo "$i" ;; # symbolic refs
441 # __git_refs2 requires 1 argument (to pass to __git_refs)
445 for i in $(__git_refs "$1"); do
450 # __git_refs_remotes requires 1 argument (to pass to ls-remote)
451 __git_refs_remotes ()
454 __git ls-remote "$1" 'refs/heads/*' | \
455 while read -r hash i; do
456 echo "$i:refs/remotes/$1/${i#refs/heads/}"
462 local d="$(__gitdir)"
463 test -d "$d/remotes" && ls -1 "$d/remotes"
467 # Returns true if $1 matches the name of a configured remote, false otherwise.
468 __git_is_configured_remote ()
471 for remote in $(__git_remotes); do
472 if [ "$remote" = "$1" ]; then
479 __git_list_merge_strategies ()
481 git merge -s help 2>&1 |
482 sed -n -e '/[Aa]vailable strategies are: /,/^$/{
491 __git_merge_strategies=
492 # 'git merge -s help' (and thus detection of the merge strategy
493 # list) fails, unfortunately, if run outside of any git working
494 # tree. __git_merge_strategies is set to the empty string in
495 # that case, and the detection will be repeated the next time it
497 __git_compute_merge_strategies ()
499 test -n "$__git_merge_strategies" ||
500 __git_merge_strategies=$(__git_list_merge_strategies)
503 __git_complete_revlist_file ()
505 local pfx ls ref cur_="$cur"
525 case "$COMP_WORDBREAKS" in
527 *) pfx="$ref:$pfx" ;;
530 __gitcomp_nl "$(__git ls-tree "$ls" \
531 | sed '/^100... blob /{
547 pfx="${cur_%...*}..."
549 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
554 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
557 __gitcomp_nl "$(__git_refs)"
563 # __git_complete_index_file requires 1 argument:
564 # 1: the options to pass to ls-file
566 # The exception is --committable, which finds the files appropriate commit.
567 __git_complete_index_file ()
569 local pfx="" cur_="$cur"
579 __gitcomp_file "$(__git_index_files "$1" ${pfx:+"$pfx"})" "$pfx" "$cur_"
582 __git_complete_file ()
584 __git_complete_revlist_file
587 __git_complete_revlist ()
589 __git_complete_revlist_file
592 __git_complete_remote_or_refspec ()
594 local cur_="$cur" cmd="${words[1]}"
595 local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0
596 if [ "$cmd" = "remote" ]; then
599 while [ $c -lt $cword ]; do
602 --mirror) [ "$cmd" = "push" ] && no_complete_refspec=1 ;;
605 push) no_complete_refspec=1 ;;
613 *) remote="$i"; break ;;
617 if [ -z "$remote" ]; then
618 __gitcomp_nl "$(__git_remotes)"
621 if [ $no_complete_refspec = 1 ]; then
624 [ "$remote" = "." ] && remote=
627 case "$COMP_WORDBREAKS" in
629 *) pfx="${cur_%%:*}:" ;;
641 if [ $lhs = 1 ]; then
642 __gitcomp_nl "$(__git_refs2 "$remote")" "$pfx" "$cur_"
644 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
648 if [ $lhs = 1 ]; then
649 __gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_"
651 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
655 if [ $lhs = 1 ]; then
656 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
658 __gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_"
664 __git_complete_strategy ()
666 __git_compute_merge_strategies
669 __gitcomp "$__git_merge_strategies"
674 __gitcomp "$__git_merge_strategies" "" "${cur##--strategy=}"
682 if test -n "${GIT_TESTING_COMMAND_COMPLETION:-}"
684 printf "%s" "${GIT_TESTING_COMMAND_COMPLETION}"
686 git help -a|egrep '^ [a-zA-Z0-9]'
690 __git_list_all_commands ()
693 for i in $(__git_commands)
696 *--*) : helper pattern;;
703 __git_compute_all_commands ()
705 test -n "$__git_all_commands" ||
706 __git_all_commands=$(__git_list_all_commands)
709 __git_list_porcelain_commands ()
712 __git_compute_all_commands
713 for i in $__git_all_commands
716 *--*) : helper pattern;;
717 applymbox) : ask gittus;;
718 applypatch) : ask gittus;;
719 archimport) : import;;
720 cat-file) : plumbing;;
721 check-attr) : plumbing;;
722 check-ignore) : plumbing;;
723 check-mailmap) : plumbing;;
724 check-ref-format) : plumbing;;
725 checkout-index) : plumbing;;
726 column) : internal helper;;
727 commit-tree) : plumbing;;
728 count-objects) : infrequent;;
729 credential) : credentials;;
730 credential-*) : credentials helper;;
731 cvsexportcommit) : export;;
732 cvsimport) : import;;
733 cvsserver) : daemon;;
735 diff-files) : plumbing;;
736 diff-index) : plumbing;;
737 diff-tree) : plumbing;;
738 fast-import) : import;;
739 fast-export) : export;;
740 fsck-objects) : plumbing;;
741 fetch-pack) : plumbing;;
742 fmt-merge-msg) : plumbing;;
743 for-each-ref) : plumbing;;
744 hash-object) : plumbing;;
745 http-*) : transport;;
746 index-pack) : plumbing;;
747 init-db) : deprecated;;
748 local-fetch) : plumbing;;
749 ls-files) : plumbing;;
750 ls-remote) : plumbing;;
751 ls-tree) : plumbing;;
752 mailinfo) : plumbing;;
753 mailsplit) : plumbing;;
754 merge-*) : plumbing;;
757 pack-objects) : plumbing;;
758 pack-redundant) : plumbing;;
759 pack-refs) : plumbing;;
760 parse-remote) : plumbing;;
761 patch-id) : plumbing;;
763 prune-packed) : plumbing;;
764 quiltimport) : import;;
765 read-tree) : plumbing;;
766 receive-pack) : plumbing;;
767 remote-*) : transport;;
769 rev-list) : plumbing;;
770 rev-parse) : plumbing;;
771 runstatus) : plumbing;;
772 sh-setup) : internal;;
774 show-ref) : plumbing;;
775 send-pack) : plumbing;;
776 show-index) : plumbing;;
778 stripspace) : plumbing;;
779 symbolic-ref) : plumbing;;
780 unpack-file) : plumbing;;
781 unpack-objects) : plumbing;;
782 update-index) : plumbing;;
783 update-ref) : plumbing;;
784 update-server-info) : daemon;;
785 upload-archive) : plumbing;;
786 upload-pack) : plumbing;;
787 write-tree) : plumbing;;
789 verify-pack) : infrequent;;
790 verify-tag) : plumbing;;
796 __git_porcelain_commands=
797 __git_compute_porcelain_commands ()
799 test -n "$__git_porcelain_commands" ||
800 __git_porcelain_commands=$(__git_list_porcelain_commands)
803 # Lists all set config variables starting with the given section prefix,
804 # with the prefix removed.
805 __git_get_config_variables ()
807 local section="$1" i IFS=$'\n'
808 for i in $(__git config --name-only --get-regexp "^$section\..*"); do
809 echo "${i#$section.}"
813 __git_pretty_aliases ()
815 __git_get_config_variables "pretty"
820 __git_get_config_variables "alias"
823 # __git_aliased_command requires 1 argument
824 __git_aliased_command ()
826 local word cmdline=$(__git config --get "alias.$1")
827 for word in $cmdline; do
833 \!*) : shell command alias ;;
835 *=*) : setting env ;;
837 \(\)) : skip parens of shell function definition ;;
838 {) : skip start of shell helper function ;;
839 :) : skip null command ;;
840 \'*) : skip opening quote after sh -c ;;
848 # __git_find_on_cmdline requires 1 argument
849 __git_find_on_cmdline ()
851 local word subcommand c=1
852 while [ $c -lt $cword ]; do
854 for subcommand in $1; do
855 if [ "$subcommand" = "$word" ]; then
864 # Echo the value of an option set on the command line or config
866 # $1: short option name
867 # $2: long option name including =
868 # $3: list of possible values
869 # $4: config string (optional)
872 # result="$(__git_get_option_value "-d" "--do-something=" \
873 # "yes no" "core.doSomething")"
875 # result is then either empty (no option set) or "yes" or "no"
877 # __git_get_option_value requires 3 arguments
878 __git_get_option_value ()
880 local c short_opt long_opt val
881 local result= values config_key word
889 while [ $c -ge 0 ]; do
891 for val in $values; do
892 if [ "$short_opt$val" = "$word" ] ||
893 [ "$long_opt$val" = "$word" ]; then
901 if [ -n "$config_key" ] && [ -z "$result" ]; then
902 result="$(__git config "$config_key")"
908 __git_has_doubledash ()
911 while [ $c -lt $cword ]; do
912 if [ "--" = "${words[c]}" ]; then
920 # Try to count non option arguments passed on the command line for the
921 # specified git command.
922 # When options are used, it is necessary to use the special -- option to
923 # tell the implementation were non option arguments begin.
924 # XXX this can not be improved, since options can appear everywhere, as
928 # __git_count_arguments requires 1 argument: the git command executed.
929 __git_count_arguments ()
933 # Skip "git" (first argument)
934 for ((i=1; i < ${#words[@]}; i++)); do
939 # Good; we can assume that the following are only non
944 # Skip the specified git command and discard git
957 __git_whitespacelist="nowarn warn error error-all fix"
961 local dir="$(__gitdir)"
962 if [ -d "$dir"/rebase-apply ]; then
963 __gitcomp "--skip --continue --resolved --abort"
968 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
973 --3way --committer-date-is-author-date --ignore-date
974 --ignore-whitespace --ignore-space-change
975 --interactive --keep --no-utf8 --signoff --utf8
976 --whitespace= --scissors
986 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
991 --stat --numstat --summary --check --index
992 --cached --index-info --reverse --reject --unidiff-zero
993 --apply --no-add --exclude=
994 --ignore-whitespace --ignore-space-change
995 --whitespace= --inaccurate-eof --verbose
1006 --interactive --refresh --patch --update --dry-run
1007 --ignore-errors --intent-to-add
1012 # XXX should we check for --update and --all options ?
1013 __git_complete_index_file "--others --modified --directory --no-empty-directory"
1020 __gitcomp "$(git archive --list)" "" "${cur##--format=}"
1024 __gitcomp_nl "$(__git_remotes)" "" "${cur##--remote=}"
1029 --format= --list --verbose
1030 --prefix= --remote= --exec=
1040 __git_has_doubledash && return
1042 local subcommands="start bad good skip reset visualize replay log run"
1043 local subcommand="$(__git_find_on_cmdline "$subcommands")"
1044 if [ -z "$subcommand" ]; then
1045 if [ -f "$(__gitdir)"/BISECT_START ]; then
1046 __gitcomp "$subcommands"
1048 __gitcomp "replay start"
1053 case "$subcommand" in
1054 bad|good|reset|skip|start)
1055 __gitcomp_nl "$(__git_refs)"
1064 local i c=1 only_local_ref="n" has_r="n"
1066 while [ $c -lt $cword ]; do
1069 -d|--delete|-m|--move) only_local_ref="y" ;;
1070 -r|--remotes) has_r="y" ;;
1076 --set-upstream-to=*)
1077 __gitcomp_nl "$(__git_refs)" "" "${cur##--set-upstream-to=}"
1081 --color --no-color --verbose --abbrev= --no-abbrev
1082 --track --no-track --contains --merged --no-merged
1083 --set-upstream-to= --edit-description --list
1084 --unset-upstream --delete --move --remotes
1088 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
1089 __gitcomp_nl "$(__git_heads)"
1091 __gitcomp_nl "$(__git_refs)"
1099 local cmd="${words[2]}"
1102 __gitcomp "create list-heads verify unbundle"
1105 # looking for a file
1110 __git_complete_revlist
1119 __git_has_doubledash && return
1123 __gitcomp "diff3 merge" "" "${cur##--conflict=}"
1127 --quiet --ours --theirs --track --no-track --merge
1128 --conflict= --orphan --patch
1132 # check if --track, --no-track, or --no-guess was specified
1133 # if so, disable DWIM mode
1134 local flags="--track --no-track --no-guess" track=1
1135 if [ -n "$(__git_find_on_cmdline "$flags")" ]; then
1138 __gitcomp_nl "$(__git_refs '' $track)"
1145 __gitcomp_nl "$(__git_refs)"
1150 local dir="$(__gitdir)"
1151 if [ -f "$dir"/CHERRY_PICK_HEAD ]; then
1152 __gitcomp "--continue --quit --abort"
1157 __gitcomp "--edit --no-commit --signoff --strategy= --mainline"
1160 __gitcomp_nl "$(__git_refs)"
1169 __gitcomp "--dry-run --quiet"
1174 # XXX should we check for -x option ?
1175 __git_complete_index_file "--others --directory"
1197 --recurse-submodules
1204 __git_untracked_file_modes="all no normal"
1210 __gitcomp_nl "$(__git_refs)" "" "${cur}"
1217 __gitcomp "default scissors strip verbatim whitespace
1218 " "" "${cur##--cleanup=}"
1221 --reuse-message=*|--reedit-message=*|\
1222 --fixup=*|--squash=*)
1223 __gitcomp_nl "$(__git_refs)" "" "${cur#*=}"
1226 --untracked-files=*)
1227 __gitcomp "$__git_untracked_file_modes" "" "${cur##--untracked-files=}"
1232 --all --author= --signoff --verify --no-verify
1234 --amend --include --only --interactive
1235 --dry-run --reuse-message= --reedit-message=
1236 --reset-author --file= --message= --template=
1237 --cleanup= --untracked-files --untracked-files=
1238 --verbose --quiet --fixup= --squash=
1243 if __git rev-parse --verify --quiet HEAD >/dev/null; then
1244 __git_complete_index_file "--committable"
1246 # This is the first commit
1247 __git_complete_index_file "--cached"
1256 --all --tags --contains --abbrev= --candidates=
1257 --exact-match --debug --long --match --always
1261 __gitcomp_nl "$(__git_refs)"
1264 __git_diff_algorithms="myers minimal patience histogram"
1266 __git_diff_submodule_formats="diff log short"
1268 __git_diff_common_options="--stat --numstat --shortstat --summary
1269 --patch-with-stat --name-only --name-status --color
1270 --no-color --color-words --no-renames --check
1271 --full-index --binary --abbrev --diff-filter=
1272 --find-copies-harder
1273 --text --ignore-space-at-eol --ignore-space-change
1274 --ignore-all-space --ignore-blank-lines --exit-code
1275 --quiet --ext-diff --no-ext-diff
1276 --no-prefix --src-prefix= --dst-prefix=
1277 --inter-hunk-context=
1278 --patience --histogram --minimal
1279 --raw --word-diff --word-diff-regex=
1280 --dirstat --dirstat= --dirstat-by-file
1281 --dirstat-by-file= --cumulative
1283 --submodule --submodule=
1288 __git_has_doubledash && return
1292 __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
1296 __gitcomp "$__git_diff_submodule_formats" "" "${cur##--submodule=}"
1300 __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
1301 --base --ours --theirs --no-index
1302 $__git_diff_common_options
1307 __git_complete_revlist_file
1310 __git_mergetools_common="diffuse diffmerge ecmerge emerge kdiff3 meld opendiff
1311 tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc codecompare
1316 __git_has_doubledash && return
1320 __gitcomp "$__git_mergetools_common kompare" "" "${cur##--tool=}"
1324 __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
1325 --base --ours --theirs
1326 --no-renames --diff-filter= --find-copies-harder
1327 --relative --ignore-submodules
1332 __git_complete_revlist_file
1335 __git_fetch_recurse_submodules="yes on-demand no"
1337 __git_fetch_options="
1338 --quiet --verbose --append --upload-pack --force --keep --depth=
1339 --tags --no-tags --all --prune --dry-run --recurse-submodules=
1345 --recurse-submodules=*)
1346 __gitcomp "$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}"
1350 __gitcomp "$__git_fetch_options"
1354 __git_complete_remote_or_refspec
1357 __git_format_patch_options="
1358 --stdout --attach --no-attach --thread --thread= --no-thread
1359 --numbered --start-number --numbered-files --keep-subject --signoff
1360 --signature --no-signature --in-reply-to= --cc= --full-index --binary
1361 --not --all --cover-letter --no-prefix --src-prefix= --dst-prefix=
1362 --inline --suffix= --ignore-if-in-upstream --subject-prefix=
1363 --output-directory --reroll-count --to= --quiet --notes
1366 _git_format_patch ()
1372 " "" "${cur##--thread=}"
1376 __gitcomp "$__git_format_patch_options"
1380 __git_complete_revlist
1388 --tags --root --unreachable --cache --no-reflogs --full
1389 --strict --verbose --lost-found
1400 __gitcomp "--prune --aggressive"
1411 __git_match_ctag() {
1412 awk "/^${1//\//\\/}/ { print \$1 }" "$2"
1417 __git_has_doubledash && return
1423 --text --ignore-case --word-regexp --invert-match
1424 --full-name --line-number
1425 --extended-regexp --basic-regexp --fixed-strings
1428 --files-with-matches --name-only
1429 --files-without-match
1432 --and --or --not --all-match
1438 case "$cword,$prev" in
1440 if test -r tags; then
1441 __gitcomp_nl "$(__git_match_ctag "$cur" tags)"
1447 __gitcomp_nl "$(__git_refs)"
1454 __gitcomp "--all --guides --info --man --web"
1458 __git_compute_all_commands
1459 __gitcomp "$__git_all_commands $(__git_aliases)
1460 attributes cli core-tutorial cvs-migration
1461 diffcore everyday gitk glossary hooks ignore modules
1462 namespaces repository-layout revisions tutorial tutorial-2
1472 false true umask group all world everybody
1473 " "" "${cur##--shared=}"
1477 __gitcomp "--quiet --bare --template= --shared --shared="
1487 __gitcomp "--cached --deleted --modified --others --ignored
1488 --stage --directory --no-empty-directory --unmerged
1489 --killed --exclude= --exclude-from=
1490 --exclude-per-directory= --exclude-standard
1491 --error-unmatch --with-tree= --full-name
1492 --abbrev --ignored --exclude-per-directory
1498 # XXX ignore options like --modified and always suggest all cached
1500 __git_complete_index_file "--cached"
1505 __gitcomp_nl "$(__git_remotes)"
1513 # Options that go well for log, shortlog and gitk
1514 __git_log_common_options="
1516 --branches --tags --remotes
1517 --first-parent --merges --no-merges
1519 --max-age= --since= --after=
1520 --min-age= --until= --before=
1521 --min-parents= --max-parents=
1522 --no-min-parents --no-max-parents
1524 # Options that go well for log and gitk (not shortlog)
1525 __git_log_gitk_options="
1526 --dense --sparse --full-history
1527 --simplify-merges --simplify-by-decoration
1528 --left-right --notes --no-notes
1530 # Options that go well for log and shortlog (not gitk)
1531 __git_log_shortlog_options="
1532 --author= --committer= --grep=
1533 --all-match --invert-grep
1536 __git_log_pretty_formats="oneline short medium full fuller email raw format:"
1537 __git_log_date_formats="relative iso8601 rfc2822 short local default raw"
1541 __git_has_doubledash && return
1543 local g="$(__gitdir)"
1545 if [ -f "$g/MERGE_HEAD" ]; then
1549 --pretty=*|--format=*)
1550 __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
1555 __gitcomp "$__git_log_date_formats" "" "${cur##--date=}"
1559 __gitcomp "full short no" "" "${cur##--decorate=}"
1563 __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
1567 __gitcomp "$__git_diff_submodule_formats" "" "${cur##--submodule=}"
1572 $__git_log_common_options
1573 $__git_log_shortlog_options
1574 $__git_log_gitk_options
1575 --root --topo-order --date-order --reverse
1576 --follow --full-diff
1577 --abbrev-commit --abbrev=
1578 --relative-date --date=
1579 --pretty= --format= --oneline
1584 --decorate --decorate=
1586 --parents --children
1588 $__git_diff_common_options
1589 --pickaxe-all --pickaxe-regex
1594 __git_complete_revlist
1597 # Common merge options shared by git-merge(1) and git-pull(1).
1598 __git_merge_options="
1599 --no-commit --no-stat --log --no-log --squash --strategy
1600 --commit --stat --no-squash --ff --no-ff --ff-only --edit --no-edit
1601 --verify-signatures --no-verify-signatures --gpg-sign
1602 --quiet --verbose --progress --no-progress
1607 __git_complete_strategy && return
1611 __gitcomp "$__git_merge_options
1612 --rerere-autoupdate --no-rerere-autoupdate --abort --continue"
1615 __gitcomp_nl "$(__git_refs)"
1622 __gitcomp "$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"
1636 __gitcomp "--octopus --independent --is-ancestor --fork-point"
1640 __gitcomp_nl "$(__git_refs)"
1647 __gitcomp "--dry-run"
1652 if [ $(__git_count_arguments "mv") -gt 0 ]; then
1653 # We need to show both cached and untracked files (including
1654 # empty directories) since this may not be the last argument.
1655 __git_complete_index_file "--cached --others --directory"
1657 __git_complete_index_file "--cached"
1663 __gitcomp "--tags --all --stdin"
1668 local subcommands='add append copy edit list prune remove show'
1669 local subcommand="$(__git_find_on_cmdline "$subcommands")"
1671 case "$subcommand,$cur" in
1678 __gitcomp_nl "$(__git_refs)"
1681 __gitcomp "$subcommands --ref"
1685 add,--reuse-message=*|append,--reuse-message=*|\
1686 add,--reedit-message=*|append,--reedit-message=*)
1687 __gitcomp_nl "$(__git_refs)" "" "${cur#*=}"
1690 __gitcomp '--file= --message= --reedit-message=
1697 __gitcomp '--dry-run --verbose'
1706 __gitcomp_nl "$(__git_refs)"
1715 __git_complete_strategy && return
1718 --recurse-submodules=*)
1719 __gitcomp "$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}"
1724 --rebase --no-rebase
1725 $__git_merge_options
1726 $__git_fetch_options
1731 __git_complete_remote_or_refspec
1734 __git_push_recurse_submodules="check on-demand"
1736 __git_complete_force_with_lease ()
1744 __gitcomp_nl "$(__git_refs)" "" "${cur_#*:}"
1747 __gitcomp_nl "$(__git_refs)" "" "$cur_"
1756 __gitcomp_nl "$(__git_remotes)"
1759 --recurse-submodules)
1760 __gitcomp "$__git_push_recurse_submodules"
1766 __gitcomp_nl "$(__git_remotes)" "" "${cur##--repo=}"
1769 --recurse-submodules=*)
1770 __gitcomp "$__git_push_recurse_submodules" "" "${cur##--recurse-submodules=}"
1773 --force-with-lease=*)
1774 __git_complete_force_with_lease "${cur##--force-with-lease=}"
1779 --all --mirror --tags --dry-run --force --verbose
1780 --quiet --prune --delete --follow-tags
1781 --receive-pack= --repo= --set-upstream
1782 --force-with-lease --force-with-lease= --recurse-submodules=
1787 __git_complete_remote_or_refspec
1792 local dir="$(__gitdir)"
1793 if [ -f "$dir"/rebase-merge/interactive ]; then
1794 __gitcomp "--continue --skip --abort --quit --edit-todo"
1796 elif [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
1797 __gitcomp "--continue --skip --abort --quit"
1800 __git_complete_strategy && return
1803 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
1808 --onto --merge --strategy --interactive
1809 --preserve-merges --stat --no-stat
1810 --committer-date-is-author-date --ignore-date
1811 --ignore-whitespace --whitespace=
1812 --autosquash --no-autosquash
1813 --fork-point --no-fork-point
1814 --autostash --no-autostash
1815 --verify --no-verify
1816 --keep-empty --root --force-rebase --no-ff
1822 __gitcomp_nl "$(__git_refs)"
1827 local subcommands="show delete expire"
1828 local subcommand="$(__git_find_on_cmdline "$subcommands")"
1830 if [ -z "$subcommand" ]; then
1831 __gitcomp "$subcommands"
1833 __gitcomp_nl "$(__git_refs)"
1837 __git_send_email_confirm_options="always never auto cc compose"
1838 __git_send_email_suppresscc_options="author self cc bodycc sob cccmd body all"
1843 --to|--cc|--bcc|--from)
1844 __gitcomp "$(__git send-email --dump-aliases)"
1852 $__git_send_email_confirm_options
1853 " "" "${cur##--confirm=}"
1858 $__git_send_email_suppresscc_options
1859 " "" "${cur##--suppress-cc=}"
1863 --smtp-encryption=*)
1864 __gitcomp "ssl tls" "" "${cur##--smtp-encryption=}"
1870 " "" "${cur##--thread=}"
1873 --to=*|--cc=*|--bcc=*|--from=*)
1874 __gitcomp "$(__git send-email --dump-aliases)" "" "${cur#--*=}"
1878 __gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to
1879 --compose --confirm= --dry-run --envelope-sender
1881 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
1882 --no-suppress-from --no-thread --quiet
1883 --signed-off-by-cc --smtp-pass --smtp-server
1884 --smtp-server-port --smtp-encryption= --smtp-user
1885 --subject --suppress-cc= --suppress-from --thread --to
1886 --validate --no-validate
1887 $__git_format_patch_options"
1891 __git_complete_revlist
1902 local untracked_state
1905 --ignore-submodules=*)
1906 __gitcomp "none untracked dirty all" "" "${cur##--ignore-submodules=}"
1909 --untracked-files=*)
1910 __gitcomp "$__git_untracked_file_modes" "" "${cur##--untracked-files=}"
1915 always never auto column row plain dense nodense
1916 " "" "${cur##--column=}"
1921 --short --branch --porcelain --long --verbose
1922 --untracked-files= --ignore-submodules= --ignored
1923 --column= --no-column
1929 untracked_state="$(__git_get_option_value "-u" "--untracked-files=" \
1930 "$__git_untracked_file_modes" "status.showUntrackedFiles")"
1932 case "$untracked_state" in
1934 # --ignored option does not matter
1938 complete_opt="--cached --directory --no-empty-directory --others"
1940 if [ -n "$(__git_find_on_cmdline "--ignored")" ]; then
1941 complete_opt="$complete_opt --ignored --exclude=*"
1946 __git_complete_index_file "$complete_opt"
1949 __git_config_get_set_variables ()
1951 local prevword word config_file= c=$cword
1952 while [ $c -gt 1 ]; do
1955 --system|--global|--local|--file=*)
1960 config_file="$word $prevword"
1968 __git config $config_file --name-only --list
1974 branch.*.remote|branch.*.pushremote)
1975 __gitcomp_nl "$(__git_remotes)"
1979 __gitcomp_nl "$(__git_refs)"
1983 __gitcomp "false true preserve interactive"
1987 __gitcomp_nl "$(__git_remotes)"
1991 local remote="${prev#remote.}"
1992 remote="${remote%.fetch}"
1993 if [ -z "$cur" ]; then
1994 __gitcomp_nl "refs/heads/" "" "" ""
1997 __gitcomp_nl "$(__git_refs_remotes "$remote")"
2001 local remote="${prev#remote.}"
2002 remote="${remote%.push}"
2003 __gitcomp_nl "$(__git for-each-ref
2004 --format='%(refname):%(refname)' refs/heads)"
2007 pull.twohead|pull.octopus)
2008 __git_compute_merge_strategies
2009 __gitcomp "$__git_merge_strategies"
2012 color.branch|color.diff|color.interactive|\
2013 color.showbranch|color.status|color.ui)
2014 __gitcomp "always never auto"
2018 __gitcomp "false true"
2023 normal black red green yellow blue magenta cyan white
2024 bold dim ul blink reverse
2029 __gitcomp "log short"
2033 __gitcomp "man info web html"
2037 __gitcomp "$__git_log_date_formats"
2040 sendemail.aliasesfiletype)
2041 __gitcomp "mutt mailrc pine elm gnus"
2045 __gitcomp "$__git_send_email_confirm_options"
2048 sendemail.suppresscc)
2049 __gitcomp "$__git_send_email_suppresscc_options"
2052 sendemail.transferencoding)
2053 __gitcomp "7bit 8bit quoted-printable base64"
2056 --get|--get-all|--unset|--unset-all)
2057 __gitcomp_nl "$(__git_config_get_set_variables)"
2067 --system --global --local --file=
2068 --list --replace-all
2069 --get --get-all --get-regexp
2070 --add --unset --unset-all
2071 --remove-section --rename-section
2077 local pfx="${cur%.*}." cur_="${cur##*.}"
2078 __gitcomp "remote pushremote merge mergeoptions rebase" "$pfx" "$cur_"
2082 local pfx="${cur%.*}." cur_="${cur#*.}"
2083 __gitcomp_nl "$(__git_heads)" "$pfx" "$cur_" "."
2084 __gitcomp_nl_append $'autosetupmerge\nautosetuprebase\n' "$pfx" "$cur_"
2088 local pfx="${cur%.*}." cur_="${cur##*.}"
2090 argprompt cmd confirm needsfile noconsole norescan
2091 prompt revprompt revunmerged title
2096 local pfx="${cur%.*}." cur_="${cur##*.}"
2097 __gitcomp "cmd path" "$pfx" "$cur_"
2101 local pfx="${cur%.*}." cur_="${cur##*.}"
2102 __gitcomp "cmd path" "$pfx" "$cur_"
2106 local pfx="${cur%.*}." cur_="${cur##*.}"
2107 __gitcomp "cmd path trustExitCode" "$pfx" "$cur_"
2111 local pfx="${cur%.*}." cur_="${cur#*.}"
2112 __git_compute_all_commands
2113 __gitcomp_nl "$__git_all_commands" "$pfx" "$cur_"
2117 local pfx="${cur%.*}." cur_="${cur##*.}"
2119 url proxy fetch push mirror skipDefaultUpdate
2120 receivepack uploadpack tagopt pushurl
2125 local pfx="${cur%.*}." cur_="${cur#*.}"
2126 __gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "."
2127 __gitcomp_nl_append "pushdefault" "$pfx" "$cur_"
2131 local pfx="${cur%.*}." cur_="${cur##*.}"
2132 __gitcomp "insteadOf pushInsteadOf" "$pfx" "$cur_"
2138 advice.commitBeforeMerge
2140 advice.implicitIdentity
2141 advice.pushNonFastForward
2142 advice.resolveConflict
2146 apply.ignorewhitespace
2148 branch.autosetupmerge
2149 branch.autosetuprebase
2153 color.branch.current
2158 color.decorate.branch
2159 color.decorate.remoteBranch
2160 color.decorate.stash
2170 color.diff.whitespace
2175 color.grep.linenumber
2178 color.grep.separator
2180 color.interactive.error
2181 color.interactive.header
2182 color.interactive.help
2183 color.interactive.prompt
2188 color.status.changed
2190 color.status.nobranch
2191 color.status.unmerged
2192 color.status.untracked
2193 color.status.updated
2202 core.bigFileThreshold
2205 core.deltaBaseCacheLimit
2210 core.fsyncobjectfiles
2214 core.logAllRefUpdates
2215 core.loosecompression
2218 core.packedGitWindowSize
2220 core.preferSymlinkRefs
2223 core.repositoryFormatVersion
2225 core.sharedRepository
2230 core.warnAmbiguousRefs
2233 diff.autorefreshindex
2235 diff.ignoreSubmodules
2242 diff.suppressBlankEmpty
2248 fetch.recurseSubmodules
2259 format.subjectprefix
2270 gc.reflogexpireunreachable
2274 gitcvs.commitmsgannotation
2275 gitcvs.dbTableNamePrefix
2286 gui.copyblamethreshold
2290 gui.matchtrackingbranch
2291 gui.newbranchtemplate
2292 gui.pruneduringfetch
2293 gui.spellingdictionary
2310 http.sslCertPasswordProtected
2315 i18n.logOutputEncoding
2321 imap.preformattedHTML
2331 interactive.singlekey
2347 mergetool.keepBackup
2348 mergetool.keepTemporaries
2353 notes.rewrite.rebase
2357 pack.deltaCacheLimit
2374 receive.denyCurrentBranch
2375 receive.denyDeleteCurrent
2377 receive.denyNonFastForwards
2380 receive.updateserverinfo
2383 repack.usedeltabaseoffset
2387 sendemail.aliasesfile
2388 sendemail.aliasfiletype
2392 sendemail.chainreplyto
2394 sendemail.envelopesender
2398 sendemail.signedoffbycc
2399 sendemail.smtpdomain
2400 sendemail.smtpencryption
2402 sendemail.smtpserver
2403 sendemail.smtpserveroption
2404 sendemail.smtpserverport
2406 sendemail.suppresscc
2407 sendemail.suppressfrom
2412 status.relativePaths
2413 status.showUntrackedFiles
2414 status.submodulesummary
2417 transfer.unpackLimit
2429 local subcommands="add rename remove set-head set-branches set-url show prune update"
2430 local subcommand="$(__git_find_on_cmdline "$subcommands")"
2431 if [ -z "$subcommand" ]; then
2432 __gitcomp "$subcommands"
2436 case "$subcommand" in
2437 rename|remove|set-url|show|prune)
2438 __gitcomp_nl "$(__git_remotes)"
2440 set-head|set-branches)
2441 __git_complete_remote_or_refspec
2444 __gitcomp "$(__git_get_config_variables "remotes")"
2453 __gitcomp_nl "$(__git_refs)"
2458 __git_has_doubledash && return
2462 __gitcomp "--merge --mixed --hard --soft --patch"
2466 __gitcomp_nl "$(__git_refs)"
2471 local dir="$(__gitdir)"
2472 if [ -f "$dir"/REVERT_HEAD ]; then
2473 __gitcomp "--continue --quit --abort"
2478 __gitcomp "--edit --mainline --no-edit --no-commit --signoff"
2482 __gitcomp_nl "$(__git_refs)"
2489 __gitcomp "--cached --dry-run --ignore-unmatch --quiet"
2494 __git_complete_index_file "--cached"
2499 __git_has_doubledash && return
2504 $__git_log_common_options
2505 $__git_log_shortlog_options
2506 --numbered --summary
2511 __git_complete_revlist
2516 __git_has_doubledash && return
2519 --pretty=*|--format=*)
2520 __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
2525 __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
2529 __gitcomp "$__git_diff_submodule_formats" "" "${cur##--submodule=}"
2533 __gitcomp "--pretty= --format= --abbrev-commit --oneline
2535 $__git_diff_common_options
2540 __git_complete_revlist_file
2548 --all --remotes --topo-order --date-order --current --more=
2549 --list --independent --merge-base --no-name
2551 --sha1-name --sparse --topics --reflog
2556 __git_complete_revlist
2561 local save_opts='--all --keep-index --no-keep-index --quiet --patch --include-untracked'
2562 local subcommands='save list show apply clear drop pop create branch'
2563 local subcommand="$(__git_find_on_cmdline "$subcommands")"
2564 if [ -z "$subcommand" ]; then
2567 __gitcomp "$save_opts"
2570 if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then
2571 __gitcomp "$subcommands"
2576 case "$subcommand,$cur" in
2578 __gitcomp "$save_opts"
2581 __gitcomp "--index --quiet"
2586 show,--*|branch,--*)
2589 if [ $cword -eq 3 ]; then
2590 __gitcomp_nl "$(__git_refs)";
2592 __gitcomp_nl "$(__git stash list \
2593 | sed -n -e 's/:.*//p')"
2596 show,*|apply,*|drop,*|pop,*)
2597 __gitcomp_nl "$(__git stash list \
2598 | sed -n -e 's/:.*//p')"
2608 __git_has_doubledash && return
2610 local subcommands="add status init deinit update summary foreach sync"
2611 if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then
2614 __gitcomp "--quiet --cached"
2617 __gitcomp "$subcommands"
2627 init fetch clone rebase dcommit log find-rev
2628 set-tree commit-diff info create-ignore propget
2629 proplist show-ignore show-externals branch tag blame
2630 migrate mkdirs reset gc
2632 local subcommand="$(__git_find_on_cmdline "$subcommands")"
2633 if [ -z "$subcommand" ]; then
2634 __gitcomp "$subcommands"
2636 local remote_opts="--username= --config-dir= --no-auth-cache"
2638 --follow-parent --authors-file= --repack=
2639 --no-metadata --use-svm-props --use-svnsync-props
2640 --log-window-size= --no-checkout --quiet
2641 --repack-flags --use-log-author --localtime
2642 --ignore-paths= --include-paths= $remote_opts
2645 --template= --shared= --trunk= --tags=
2646 --branches= --stdlayout --minimize-url
2647 --no-metadata --use-svm-props --use-svnsync-props
2648 --rewrite-root= --prefix= --use-log-author
2649 --add-author-from $remote_opts
2652 --edit --rmdir --find-copies-harder --copy-similarity=
2655 case "$subcommand,$cur" in
2657 __gitcomp "--revision= --fetch-all $fc_opts"
2660 __gitcomp "--revision= $fc_opts $init_opts"
2663 __gitcomp "$init_opts"
2667 --merge --strategy= --verbose --dry-run
2668 --fetch-all --no-rebase --commit-url
2669 --revision --interactive $cmt_opts $fc_opts
2673 __gitcomp "--stdin $cmt_opts $fc_opts"
2675 create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\
2676 show-externals,--*|mkdirs,--*)
2677 __gitcomp "--revision="
2681 --limit= --revision= --verbose --incremental
2682 --oneline --show-commit --non-recursive
2683 --authors-file= --color
2688 --merge --verbose --strategy= --local
2689 --fetch-all --dry-run $fc_opts
2693 __gitcomp "--message= --file= --revision= $cmt_opts"
2699 __gitcomp "--dry-run --message --tag"
2702 __gitcomp "--dry-run --message"
2705 __gitcomp "--git-format"
2709 --config-dir= --ignore-paths= --minimize
2710 --no-auth-cache --username=
2714 __gitcomp "--revision= --parent"
2725 while [ $c -lt $cword ]; do
2729 __gitcomp_nl "$(__git_tags)"
2744 __gitcomp_nl "$(__git_tags)"
2748 __gitcomp_nl "$(__git_refs)"
2755 --list --delete --verify --annotate --message --file
2756 --sign --cleanup --local-user --force --column --sort
2757 --contains --points-at
2770 local subcommands="add list lock prune unlock"
2771 local subcommand="$(__git_find_on_cmdline "$subcommands")"
2772 if [ -z "$subcommand" ]; then
2773 __gitcomp "$subcommands"
2775 case "$subcommand,$cur" in
2777 __gitcomp "--detach"
2780 __gitcomp "--porcelain"
2783 __gitcomp "--reason"
2786 __gitcomp "--dry-run --expire --verbose"
2796 local i c=1 command __git_dir
2797 local __git_C_args C_args_count=0
2799 while [ $c -lt $cword ]; do
2802 --git-dir=*) __git_dir="${i#--git-dir=}" ;;
2803 --git-dir) ((c++)) ; __git_dir="${words[c]}" ;;
2804 --bare) __git_dir="." ;;
2805 --help) command="help"; break ;;
2806 -c|--work-tree|--namespace) ((c++)) ;;
2807 -C) __git_C_args[C_args_count++]=-C
2809 __git_C_args[C_args_count++]="${words[c]}"
2812 *) command="$i"; break ;;
2817 if [ -z "$command" ]; then
2819 --git-dir|-C|--work-tree)
2820 # these need a path argument, let's fall back to
2821 # Bash filename completion
2825 # we don't support completing these options' arguments
2843 --no-replace-objects
2847 *) __git_compute_porcelain_commands
2848 __gitcomp "$__git_porcelain_commands $(__git_aliases)" ;;
2853 local completion_func="_git_${command//-/_}"
2854 declare -f $completion_func >/dev/null 2>/dev/null && $completion_func && return
2856 local expansion=$(__git_aliased_command "$command")
2857 if [ -n "$expansion" ]; then
2859 completion_func="_git_${expansion//-/_}"
2860 declare -f $completion_func >/dev/null 2>/dev/null && $completion_func
2866 __git_has_doubledash && return
2868 local g="$(__gitdir)"
2870 if [ -f "$g/MERGE_HEAD" ]; then
2876 $__git_log_common_options
2877 $__git_log_gitk_options
2883 __git_complete_revlist
2886 if [[ -n ${ZSH_VERSION-} ]]; then
2887 echo "WARNING: this script is deprecated, please see git-completion.zsh" 1>&2
2889 autoload -U +X compinit && compinit
2895 local cur_="${3-$cur}"
2901 local c IFS=$' \t\n'
2909 array[${#array[@]}+1]="$c"
2912 compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
2923 compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
2932 compadd -Q -p "${2-}" -f -- ${=1} && _ret=0
2937 local _ret=1 cur cword prev
2938 cur=${words[CURRENT]}
2939 prev=${words[CURRENT-1]}
2941 emulate ksh -c __${service}_main
2942 let _ret && _default && _ret=0
2946 compdef _git git gitk
2952 local cur words cword prev
2953 _get_comp_words_by_ref -n =: cur words cword prev
2957 # Setup completion for certain functions defined above by setting common
2958 # variables and workarounds.
2959 # This is NOT a public function; use at your own risk.
2962 local wrapper="__git_wrap${2}"
2963 eval "$wrapper () { __git_func_wrap $2 ; }"
2964 complete -o bashdefault -o default -o nospace -F $wrapper $1 2>/dev/null \
2965 || complete -o default -o nospace -F $wrapper $1
2968 # wrapper for backwards compatibility
2971 __git_wrap__git_main
2974 # wrapper for backwards compatibility
2977 __git_wrap__gitk_main
2980 __git_complete git __git_main
2981 __git_complete gitk __gitk_main
2983 # The following are necessary only for Cygwin, and only are needed
2984 # when the user has tab-completed the executable name and consequently
2985 # included the '.exe' suffix.
2987 if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
2988 __git_complete git.exe __git_main