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 local dir
="$(__gitdir)"
288 if [ "$2" == "--committable" ]; then
289 git
--git-dir="$dir" -C "$1" diff-index
--name-only --relative HEAD
291 # NOTE: $2 is not quoted in order to support multiple options
292 git
--git-dir="$dir" -C "$1" ls-files
--exclude-standard $2
297 # __git_index_files accepts 1 or 2 arguments:
298 # 1: Options to pass to ls-files (required).
299 # 2: A directory path (optional).
300 # If provided, only files within the specified directory are listed.
301 # Sub directories are never recursed. Path must have a trailing
305 local dir
="$(__gitdir)" root
="${2-.}" file
307 if [ -d "$dir" ]; then
308 __git_ls_files_helper
"$root" "$1" |
309 while read -r file; do
311 ?
*/*) echo "${file%%/*}" ;;
320 local dir
="$(__gitdir)"
321 if [ -d "$dir" ]; then
322 git
--git-dir="$dir" for-each-ref
--format='%(refname:short)' \
330 local dir
="$(__gitdir)"
331 if [ -d "$dir" ]; then
332 git
--git-dir="$dir" for-each-ref
--format='%(refname:short)' \
338 # Lists refs from the local (by default) or from a remote repository.
339 # It accepts 0, 1 or 2 arguments:
340 # 1: The remote to list refs from (optional; ignored, if set but empty).
341 # 2: In addition to local refs, list unique branches from refs/remotes/ for
342 # 'git checkout's tracking DWIMery (optional; ignored, if set but empty).
345 local i
hash dir
="$(__gitdir)" track
="${2-}"
346 local list_refs_from
=path remote
="${1-}"
347 local format refs pfx
349 if [ -n "$remote" ]; then
350 if __git_is_configured_remote
"$remote"; then
351 # configured remote takes precedence over a
352 # local directory with the same name
353 list_refs_from
=remote
354 elif [ -d "$remote/.git" ]; then
356 elif [ -d "$remote" ]; then
363 if [ "$list_refs_from" = path
] && [ -d "$dir" ]; then
371 [[ "$cur" == ^
* ]] && pfx
="^"
372 for i
in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD
; do
373 if [ -e "$dir/$i" ]; then echo $pfx$i; fi
375 format
="refname:short"
376 refs
="refs/tags refs/heads refs/remotes"
379 git
--git-dir="$dir" for-each-ref
--format="$pfx%($format)" \
381 if [ -n "$track" ]; then
382 # employ the heuristic used by git checkout
383 # Try to find a remote branch that matches the completion word
384 # but only output if the branch name is unique
386 git
--git-dir="$dir" for-each-ref
--shell --format="ref=%(refname:short)" \
388 while read -r entry
; do
391 if [[ "$ref" == "$cur"* ]]; then
394 done |
sort |
uniq -u
400 git
--git-dir="$dir" ls-remote
"$remote" "$cur*" 2>/dev
/null | \
401 while read -r hash i
; do
410 git
--git-dir="$dir" for-each-ref
--format="%(refname:short)" \
411 "refs/remotes/$remote/" 2>/dev
/null |
sed -e "s#^$remote/##"
416 # __git_refs2 requires 1 argument (to pass to __git_refs)
420 for i
in $
(__git_refs
"$1"); do
425 # __git_refs_remotes requires 1 argument (to pass to ls-remote)
426 __git_refs_remotes
()
429 git
--git-dir="$(__gitdir)" ls-remote
"$1" 'refs/heads/*' 2>/dev
/null | \
430 while read -r hash i
; do
431 echo "$i:refs/remotes/$1/${i#refs/heads/}"
437 local d
="$(__gitdir)"
438 test -d "$d/remotes" && ls -1 "$d/remotes"
439 git
--git-dir="$d" remote
442 # Returns true if $1 matches the name of a configured remote, false otherwise.
443 __git_is_configured_remote
()
446 for remote
in $
(__git_remotes
); do
447 if [ "$remote" = "$1" ]; then
454 __git_list_merge_strategies
()
456 git merge
-s help 2>&1 |
457 sed -n -e '/[Aa]vailable strategies are: /,/^$/{
466 __git_merge_strategies
=
467 # 'git merge -s help' (and thus detection of the merge strategy
468 # list) fails, unfortunately, if run outside of any git working
469 # tree. __git_merge_strategies is set to the empty string in
470 # that case, and the detection will be repeated the next time it
472 __git_compute_merge_strategies
()
474 test -n "$__git_merge_strategies" ||
475 __git_merge_strategies
=$
(__git_list_merge_strategies
)
478 __git_complete_revlist_file
()
480 local pfx
ls ref cur_
="$cur"
500 case "$COMP_WORDBREAKS" in
502 *) pfx
="$ref:$pfx" ;;
505 __gitcomp_nl
"$(git --git-dir="$
(__gitdir
)" ls-tree "$ls" 2>/dev/null \
506 | sed '/^100... blob /{
522 pfx
="${cur_%...*}..."
524 __gitcomp_nl
"$(__git_refs)" "$pfx" "$cur_"
529 __gitcomp_nl
"$(__git_refs)" "$pfx" "$cur_"
532 __gitcomp_nl
"$(__git_refs)"
538 # __git_complete_index_file requires 1 argument:
539 # 1: the options to pass to ls-file
541 # The exception is --committable, which finds the files appropriate commit.
542 __git_complete_index_file
()
544 local pfx
="" cur_
="$cur"
554 __gitcomp_file
"$(__git_index_files "$1" ${pfx:+"$pfx"})" "$pfx" "$cur_"
557 __git_complete_file
()
559 __git_complete_revlist_file
562 __git_complete_revlist
()
564 __git_complete_revlist_file
567 __git_complete_remote_or_refspec
()
569 local cur_
="$cur" cmd
="${words[1]}"
570 local i c
=2 remote
="" pfx
="" lhs
=1 no_complete_refspec
=0
571 if [ "$cmd" = "remote" ]; then
574 while [ $c -lt $cword ]; do
577 --mirror) [ "$cmd" = "push" ] && no_complete_refspec
=1 ;;
580 push
) no_complete_refspec
=1 ;;
588 *) remote
="$i"; break ;;
592 if [ -z "$remote" ]; then
593 __gitcomp_nl
"$(__git_remotes)"
596 if [ $no_complete_refspec = 1 ]; then
599 [ "$remote" = "." ] && remote
=
602 case "$COMP_WORDBREAKS" in
604 *) pfx
="${cur_%%:*}:" ;;
616 if [ $lhs = 1 ]; then
617 __gitcomp_nl
"$(__git_refs2 "$remote")" "$pfx" "$cur_"
619 __gitcomp_nl
"$(__git_refs)" "$pfx" "$cur_"
623 if [ $lhs = 1 ]; then
624 __gitcomp_nl
"$(__git_refs "$remote")" "$pfx" "$cur_"
626 __gitcomp_nl
"$(__git_refs)" "$pfx" "$cur_"
630 if [ $lhs = 1 ]; then
631 __gitcomp_nl
"$(__git_refs)" "$pfx" "$cur_"
633 __gitcomp_nl
"$(__git_refs "$remote")" "$pfx" "$cur_"
639 __git_complete_strategy
()
641 __git_compute_merge_strategies
644 __gitcomp
"$__git_merge_strategies"
649 __gitcomp
"$__git_merge_strategies" "" "${cur##--strategy=}"
657 if test -n "${GIT_TESTING_COMMAND_COMPLETION:-}"
659 printf "%s" "${GIT_TESTING_COMMAND_COMPLETION}"
661 git
help -a|
egrep '^ [a-zA-Z0-9]'
665 __git_list_all_commands
()
668 for i
in $
(__git_commands
)
671 *--*) : helper pattern
;;
678 __git_compute_all_commands
()
680 test -n "$__git_all_commands" ||
681 __git_all_commands
=$
(__git_list_all_commands
)
684 __git_list_porcelain_commands
()
687 __git_compute_all_commands
688 for i
in $__git_all_commands
691 *--*) : helper pattern
;;
692 applymbox
) : ask gittus
;;
693 applypatch
) : ask gittus
;;
694 archimport
) : import
;;
695 cat-file
) : plumbing
;;
696 check-attr
) : plumbing
;;
697 check-ignore
) : plumbing
;;
698 check-mailmap
) : plumbing
;;
699 check-ref-format
) : plumbing
;;
700 checkout-index
) : plumbing
;;
701 column) : internal helper
;;
702 commit-tree
) : plumbing
;;
703 count-objects
) : infrequent
;;
704 credential
) : credentials
;;
705 credential-
*) : credentials helper
;;
706 cvsexportcommit
) : export;;
707 cvsimport
) : import
;;
708 cvsserver
) : daemon
;;
710 diff-files
) : plumbing
;;
711 diff-index
) : plumbing
;;
712 diff-tree
) : plumbing
;;
713 fast-import
) : import
;;
714 fast-export
) : export;;
715 fsck-objects
) : plumbing
;;
716 fetch-pack
) : plumbing
;;
717 fmt-merge-msg
) : plumbing
;;
718 for-each-ref
) : plumbing
;;
719 hash-object
) : plumbing
;;
720 http-
*) : transport
;;
721 index-pack
) : plumbing
;;
722 init-db
) : deprecated
;;
723 local-fetch
) : plumbing
;;
724 ls-files
) : plumbing
;;
725 ls-remote
) : plumbing
;;
726 ls-tree
) : plumbing
;;
727 mailinfo
) : plumbing
;;
728 mailsplit
) : plumbing
;;
729 merge-
*) : plumbing
;;
732 pack-objects
) : plumbing
;;
733 pack-redundant
) : plumbing
;;
734 pack-refs
) : plumbing
;;
735 parse-remote
) : plumbing
;;
736 patch-id
) : plumbing
;;
738 prune-packed
) : plumbing
;;
739 quiltimport
) : import
;;
740 read-tree
) : plumbing
;;
741 receive-pack
) : plumbing
;;
742 remote-
*) : transport
;;
744 rev-list
) : plumbing
;;
745 rev-parse
) : plumbing
;;
746 runstatus
) : plumbing
;;
747 sh-setup
) : internal
;;
749 show-ref
) : plumbing
;;
750 send-pack
) : plumbing
;;
751 show-index
) : plumbing
;;
753 stripspace
) : plumbing
;;
754 symbolic-ref
) : plumbing
;;
755 unpack-file
) : plumbing
;;
756 unpack-objects
) : plumbing
;;
757 update-index
) : plumbing
;;
758 update-ref
) : plumbing
;;
759 update-server-info
) : daemon
;;
760 upload-archive
) : plumbing
;;
761 upload-pack
) : plumbing
;;
762 write-tree
) : plumbing
;;
764 verify-pack
) : infrequent
;;
765 verify-tag
) : plumbing
;;
771 __git_porcelain_commands
=
772 __git_compute_porcelain_commands
()
774 test -n "$__git_porcelain_commands" ||
775 __git_porcelain_commands
=$
(__git_list_porcelain_commands
)
778 # Lists all set config variables starting with the given section prefix,
779 # with the prefix removed.
780 __git_get_config_variables
()
782 local section
="$1" i IFS
=$
'\n'
783 for i
in $
(git
--git-dir="$(__gitdir)" config
--name-only --get-regexp "^$section\..*" 2>/dev
/null
); do
784 echo "${i#$section.}"
788 __git_pretty_aliases
()
790 __git_get_config_variables
"pretty"
795 __git_get_config_variables
"alias"
798 # __git_aliased_command requires 1 argument
799 __git_aliased_command
()
801 local word cmdline
=$
(git
--git-dir="$(__gitdir)" \
802 config
--get "alias.$1")
803 for word
in $cmdline; do
809 \
!*) : shell
command alias ;;
811 *=*) : setting env
;;
813 \
(\
)) : skip parens of shell
function definition
;;
814 {) : skip start of shell helper
function ;;
815 :) : skip null
command ;;
816 \'*) : skip opening quote after sh
-c ;;
824 # __git_find_on_cmdline requires 1 argument
825 __git_find_on_cmdline
()
827 local word subcommand c
=1
828 while [ $c -lt $cword ]; do
830 for subcommand
in $1; do
831 if [ "$subcommand" = "$word" ]; then
840 # Echo the value of an option set on the command line or config
842 # $1: short option name
843 # $2: long option name including =
844 # $3: list of possible values
845 # $4: config string (optional)
848 # result="$(__git_get_option_value "-d" "--do-something=" \
849 # "yes no" "core.doSomething")"
851 # result is then either empty (no option set) or "yes" or "no"
853 # __git_get_option_value requires 3 arguments
854 __git_get_option_value
()
856 local c short_opt long_opt val
857 local result
= values config_key word
865 while [ $c -ge 0 ]; do
867 for val
in $values; do
868 if [ "$short_opt$val" = "$word" ] ||
869 [ "$long_opt$val" = "$word" ]; then
877 if [ -n "$config_key" ] && [ -z "$result" ]; then
878 result
="$(git --git-dir="$
(__gitdir
)" config "$config_key")"
884 __git_has_doubledash
()
887 while [ $c -lt $cword ]; do
888 if [ "--" = "${words[c]}" ]; then
896 # Try to count non option arguments passed on the command line for the
897 # specified git command.
898 # When options are used, it is necessary to use the special -- option to
899 # tell the implementation were non option arguments begin.
900 # XXX this can not be improved, since options can appear everywhere, as
904 # __git_count_arguments requires 1 argument: the git command executed.
905 __git_count_arguments
()
909 # Skip "git" (first argument)
910 for ((i
=1; i
< ${#words[@]}; i
++)); do
915 # Good; we can assume that the following are only non
920 # Skip the specified git command and discard git
933 __git_whitespacelist
="nowarn warn error error-all fix"
937 local dir
="$(__gitdir)"
938 if [ -d "$dir"/rebase-apply
]; then
939 __gitcomp
"--skip --continue --resolved --abort"
944 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
949 --3way --committer-date-is-author-date --ignore-date
950 --ignore-whitespace --ignore-space-change
951 --interactive --keep --no-utf8 --signoff --utf8
952 --whitespace= --scissors
962 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
967 --stat --numstat --summary --check --index
968 --cached --index-info --reverse --reject --unidiff-zero
969 --apply --no-add --exclude=
970 --ignore-whitespace --ignore-space-change
971 --whitespace= --inaccurate-eof --verbose
982 --interactive --refresh --patch --update --dry-run
983 --ignore-errors --intent-to-add
988 # XXX should we check for --update and --all options ?
989 __git_complete_index_file
"--others --modified --directory --no-empty-directory"
996 __gitcomp
"$(git archive --list)" "" "${cur##--format=}"
1000 __gitcomp_nl
"$(__git_remotes)" "" "${cur##--remote=}"
1005 --format= --list --verbose
1006 --prefix= --remote= --exec=
1016 __git_has_doubledash
&& return
1018 local subcommands
="start bad good skip reset visualize replay log run"
1019 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
1020 if [ -z "$subcommand" ]; then
1021 if [ -f "$(__gitdir)"/BISECT_START
]; then
1022 __gitcomp
"$subcommands"
1024 __gitcomp
"replay start"
1029 case "$subcommand" in
1030 bad|good|
reset|skip|start
)
1031 __gitcomp_nl
"$(__git_refs)"
1040 local i c
=1 only_local_ref
="n" has_r
="n"
1042 while [ $c -lt $cword ]; do
1045 -d|
--delete|
-m|
--move) only_local_ref
="y" ;;
1046 -r|
--remotes) has_r
="y" ;;
1052 --set-upstream-to=*)
1053 __gitcomp_nl
"$(__git_refs)" "" "${cur##--set-upstream-to=}"
1057 --color --no-color --verbose --abbrev= --no-abbrev
1058 --track --no-track --contains --merged --no-merged
1059 --set-upstream-to= --edit-description --list
1060 --unset-upstream --delete --move --remotes
1064 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
1065 __gitcomp_nl
"$(__git_heads)"
1067 __gitcomp_nl
"$(__git_refs)"
1075 local cmd
="${words[2]}"
1078 __gitcomp
"create list-heads verify unbundle"
1081 # looking for a file
1086 __git_complete_revlist
1095 __git_has_doubledash
&& return
1099 __gitcomp
"diff3 merge" "" "${cur##--conflict=}"
1103 --quiet --ours --theirs --track --no-track --merge
1104 --conflict= --orphan --patch
1108 # check if --track, --no-track, or --no-guess was specified
1109 # if so, disable DWIM mode
1110 local flags
="--track --no-track --no-guess" track
=1
1111 if [ -n "$(__git_find_on_cmdline "$flags")" ]; then
1114 __gitcomp_nl
"$(__git_refs '' $track)"
1121 __gitcomp_nl
"$(__git_refs)"
1126 local dir
="$(__gitdir)"
1127 if [ -f "$dir"/CHERRY_PICK_HEAD
]; then
1128 __gitcomp
"--continue --quit --abort"
1133 __gitcomp
"--edit --no-commit --signoff --strategy= --mainline"
1136 __gitcomp_nl
"$(__git_refs)"
1145 __gitcomp
"--dry-run --quiet"
1150 # XXX should we check for -x option ?
1151 __git_complete_index_file
"--others --directory"
1173 --recurse-submodules
1180 __git_untracked_file_modes
="all no normal"
1186 __gitcomp_nl
"$(__git_refs)" "" "${cur}"
1193 __gitcomp
"default scissors strip verbatim whitespace
1194 " "" "${cur##--cleanup=}"
1197 --reuse-message=*|
--reedit-message=*|\
1198 --fixup=*|
--squash=*)
1199 __gitcomp_nl
"$(__git_refs)" "" "${cur#*=}"
1202 --untracked-files=*)
1203 __gitcomp
"$__git_untracked_file_modes" "" "${cur##--untracked-files=}"
1208 --all --author= --signoff --verify --no-verify
1210 --amend --include --only --interactive
1211 --dry-run --reuse-message= --reedit-message=
1212 --reset-author --file= --message= --template=
1213 --cleanup= --untracked-files --untracked-files=
1214 --verbose --quiet --fixup= --squash=
1219 if git
--git-dir="$(__gitdir)" rev-parse
--verify --quiet HEAD
>/dev
/null
; then
1220 __git_complete_index_file
"--committable"
1222 # This is the first commit
1223 __git_complete_index_file
"--cached"
1232 --all --tags --contains --abbrev= --candidates=
1233 --exact-match --debug --long --match --always
1237 __gitcomp_nl
"$(__git_refs)"
1240 __git_diff_algorithms
="myers minimal patience histogram"
1242 __git_diff_submodule_formats
="diff log short"
1244 __git_diff_common_options
="--stat --numstat --shortstat --summary
1245 --patch-with-stat --name-only --name-status --color
1246 --no-color --color-words --no-renames --check
1247 --full-index --binary --abbrev --diff-filter=
1248 --find-copies-harder
1249 --text --ignore-space-at-eol --ignore-space-change
1250 --ignore-all-space --ignore-blank-lines --exit-code
1251 --quiet --ext-diff --no-ext-diff
1252 --no-prefix --src-prefix= --dst-prefix=
1253 --inter-hunk-context=
1254 --patience --histogram --minimal
1255 --raw --word-diff --word-diff-regex=
1256 --dirstat --dirstat= --dirstat-by-file
1257 --dirstat-by-file= --cumulative
1259 --submodule --submodule=
1264 __git_has_doubledash
&& return
1268 __gitcomp
"$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
1272 __gitcomp
"$__git_diff_submodule_formats" "" "${cur##--submodule=}"
1276 __gitcomp
"--cached --staged --pickaxe-all --pickaxe-regex
1277 --base --ours --theirs --no-index
1278 $__git_diff_common_options
1283 __git_complete_revlist_file
1286 __git_mergetools_common
="diffuse diffmerge ecmerge emerge kdiff3 meld opendiff
1287 tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc codecompare
1292 __git_has_doubledash
&& return
1296 __gitcomp
"$__git_mergetools_common kompare" "" "${cur##--tool=}"
1300 __gitcomp
"--cached --staged --pickaxe-all --pickaxe-regex
1301 --base --ours --theirs
1302 --no-renames --diff-filter= --find-copies-harder
1303 --relative --ignore-submodules
1308 __git_complete_revlist_file
1311 __git_fetch_recurse_submodules
="yes on-demand no"
1313 __git_fetch_options
="
1314 --quiet --verbose --append --upload-pack --force --keep --depth=
1315 --tags --no-tags --all --prune --dry-run --recurse-submodules=
1321 --recurse-submodules=*)
1322 __gitcomp
"$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}"
1326 __gitcomp
"$__git_fetch_options"
1330 __git_complete_remote_or_refspec
1333 __git_format_patch_options
="
1334 --stdout --attach --no-attach --thread --thread= --no-thread
1335 --numbered --start-number --numbered-files --keep-subject --signoff
1336 --signature --no-signature --in-reply-to= --cc= --full-index --binary
1337 --not --all --cover-letter --no-prefix --src-prefix= --dst-prefix=
1338 --inline --suffix= --ignore-if-in-upstream --subject-prefix=
1339 --output-directory --reroll-count --to= --quiet --notes
1342 _git_format_patch
()
1348 " "" "${cur##--thread=}"
1352 __gitcomp
"$__git_format_patch_options"
1356 __git_complete_revlist
1364 --tags --root --unreachable --cache --no-reflogs --full
1365 --strict --verbose --lost-found
1376 __gitcomp
"--prune --aggressive"
1387 __git_match_ctag
() {
1388 awk "/^${1//\//\\/}/ { print \$1 }" "$2"
1393 __git_has_doubledash
&& return
1399 --text --ignore-case --word-regexp --invert-match
1400 --full-name --line-number
1401 --extended-regexp --basic-regexp --fixed-strings
1404 --files-with-matches --name-only
1405 --files-without-match
1408 --and --or --not --all-match
1414 case "$cword,$prev" in
1416 if test -r tags
; then
1417 __gitcomp_nl
"$(__git_match_ctag "$cur" tags)"
1423 __gitcomp_nl
"$(__git_refs)"
1430 __gitcomp
"--all --guides --info --man --web"
1434 __git_compute_all_commands
1435 __gitcomp
"$__git_all_commands $(__git_aliases)
1436 attributes cli core-tutorial cvs-migration
1437 diffcore everyday gitk glossary hooks ignore modules
1438 namespaces repository-layout revisions tutorial tutorial-2
1448 false true umask group all world everybody
1449 " "" "${cur##--shared=}"
1453 __gitcomp
"--quiet --bare --template= --shared --shared="
1463 __gitcomp
"--cached --deleted --modified --others --ignored
1464 --stage --directory --no-empty-directory --unmerged
1465 --killed --exclude= --exclude-from=
1466 --exclude-per-directory= --exclude-standard
1467 --error-unmatch --with-tree= --full-name
1468 --abbrev --ignored --exclude-per-directory
1474 # XXX ignore options like --modified and always suggest all cached
1476 __git_complete_index_file
"--cached"
1481 __gitcomp_nl
"$(__git_remotes)"
1489 # Options that go well for log, shortlog and gitk
1490 __git_log_common_options
="
1492 --branches --tags --remotes
1493 --first-parent --merges --no-merges
1495 --max-age= --since= --after=
1496 --min-age= --until= --before=
1497 --min-parents= --max-parents=
1498 --no-min-parents --no-max-parents
1500 # Options that go well for log and gitk (not shortlog)
1501 __git_log_gitk_options
="
1502 --dense --sparse --full-history
1503 --simplify-merges --simplify-by-decoration
1504 --left-right --notes --no-notes
1506 # Options that go well for log and shortlog (not gitk)
1507 __git_log_shortlog_options
="
1508 --author= --committer= --grep=
1509 --all-match --invert-grep
1512 __git_log_pretty_formats
="oneline short medium full fuller email raw format:"
1513 __git_log_date_formats
="relative iso8601 rfc2822 short local default raw"
1517 __git_has_doubledash
&& return
1519 local g
="$(__gitdir)"
1521 if [ -f "$g/MERGE_HEAD" ]; then
1525 --pretty=*|
--format=*)
1526 __gitcomp
"$__git_log_pretty_formats $(__git_pretty_aliases)
1531 __gitcomp
"$__git_log_date_formats" "" "${cur##--date=}"
1535 __gitcomp
"full short no" "" "${cur##--decorate=}"
1539 __gitcomp
"$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
1543 __gitcomp
"$__git_diff_submodule_formats" "" "${cur##--submodule=}"
1548 $__git_log_common_options
1549 $__git_log_shortlog_options
1550 $__git_log_gitk_options
1551 --root --topo-order --date-order --reverse
1552 --follow --full-diff
1553 --abbrev-commit --abbrev=
1554 --relative-date --date=
1555 --pretty= --format= --oneline
1560 --decorate --decorate=
1562 --parents --children
1564 $__git_diff_common_options
1565 --pickaxe-all --pickaxe-regex
1570 __git_complete_revlist
1573 # Common merge options shared by git-merge(1) and git-pull(1).
1574 __git_merge_options
="
1575 --no-commit --no-stat --log --no-log --squash --strategy
1576 --commit --stat --no-squash --ff --no-ff --ff-only --edit --no-edit
1577 --verify-signatures --no-verify-signatures --gpg-sign
1578 --quiet --verbose --progress --no-progress
1583 __git_complete_strategy
&& return
1587 __gitcomp
"$__git_merge_options
1588 --rerere-autoupdate --no-rerere-autoupdate --abort --continue"
1591 __gitcomp_nl
"$(__git_refs)"
1598 __gitcomp
"$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"
1612 __gitcomp
"--octopus --independent --is-ancestor --fork-point"
1616 __gitcomp_nl
"$(__git_refs)"
1623 __gitcomp
"--dry-run"
1628 if [ $
(__git_count_arguments
"mv") -gt 0 ]; then
1629 # We need to show both cached and untracked files (including
1630 # empty directories) since this may not be the last argument.
1631 __git_complete_index_file
"--cached --others --directory"
1633 __git_complete_index_file
"--cached"
1639 __gitcomp
"--tags --all --stdin"
1644 local subcommands
='add append copy edit list prune remove show'
1645 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
1647 case "$subcommand,$cur" in
1654 __gitcomp_nl
"$(__git_refs)"
1657 __gitcomp
"$subcommands --ref"
1661 add
,--reuse-message=*|append
,--reuse-message=*|\
1662 add
,--reedit-message=*|append
,--reedit-message=*)
1663 __gitcomp_nl
"$(__git_refs)" "" "${cur#*=}"
1666 __gitcomp
'--file= --message= --reedit-message=
1673 __gitcomp
'--dry-run --verbose'
1682 __gitcomp_nl
"$(__git_refs)"
1691 __git_complete_strategy
&& return
1694 --recurse-submodules=*)
1695 __gitcomp
"$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}"
1700 --rebase --no-rebase
1701 $__git_merge_options
1702 $__git_fetch_options
1707 __git_complete_remote_or_refspec
1710 __git_push_recurse_submodules
="check on-demand"
1712 __git_complete_force_with_lease
()
1720 __gitcomp_nl
"$(__git_refs)" "" "${cur_#*:}"
1723 __gitcomp_nl
"$(__git_refs)" "" "$cur_"
1732 __gitcomp_nl
"$(__git_remotes)"
1735 --recurse-submodules)
1736 __gitcomp
"$__git_push_recurse_submodules"
1742 __gitcomp_nl
"$(__git_remotes)" "" "${cur##--repo=}"
1745 --recurse-submodules=*)
1746 __gitcomp
"$__git_push_recurse_submodules" "" "${cur##--recurse-submodules=}"
1749 --force-with-lease=*)
1750 __git_complete_force_with_lease
"${cur##--force-with-lease=}"
1755 --all --mirror --tags --dry-run --force --verbose
1756 --quiet --prune --delete --follow-tags
1757 --receive-pack= --repo= --set-upstream
1758 --force-with-lease --force-with-lease= --recurse-submodules=
1763 __git_complete_remote_or_refspec
1768 local dir
="$(__gitdir)"
1769 if [ -f "$dir"/rebase-merge
/interactive
]; then
1770 __gitcomp
"--continue --skip --abort --quit --edit-todo"
1772 elif [ -d "$dir"/rebase-apply
] ||
[ -d "$dir"/rebase-merge
]; then
1773 __gitcomp
"--continue --skip --abort --quit"
1776 __git_complete_strategy
&& return
1779 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
1784 --onto --merge --strategy --interactive
1785 --preserve-merges --stat --no-stat
1786 --committer-date-is-author-date --ignore-date
1787 --ignore-whitespace --whitespace=
1788 --autosquash --no-autosquash
1789 --fork-point --no-fork-point
1790 --autostash --no-autostash
1791 --verify --no-verify
1792 --keep-empty --root --force-rebase --no-ff
1798 __gitcomp_nl
"$(__git_refs)"
1803 local subcommands
="show delete expire"
1804 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
1806 if [ -z "$subcommand" ]; then
1807 __gitcomp
"$subcommands"
1809 __gitcomp_nl
"$(__git_refs)"
1813 __git_send_email_confirm_options
="always never auto cc compose"
1814 __git_send_email_suppresscc_options
="author self cc bodycc sob cccmd body all"
1819 --to|
--cc|
--bcc|
--from)
1821 $(git --git-dir="$
(__gitdir
)" send-email --dump-aliases 2>/dev/null)
1830 $__git_send_email_confirm_options
1831 " "" "${cur##--confirm=}"
1836 $__git_send_email_suppresscc_options
1837 " "" "${cur##--suppress-cc=}"
1841 --smtp-encryption=*)
1842 __gitcomp
"ssl tls" "" "${cur##--smtp-encryption=}"
1848 " "" "${cur##--thread=}"
1851 --to=*|
--cc=*|
--bcc=*|
--from=*)
1853 $(git --git-dir="$
(__gitdir
)" send-email --dump-aliases 2>/dev/null)
1858 __gitcomp
"--annotate --bcc --cc --cc-cmd --chain-reply-to
1859 --compose --confirm= --dry-run --envelope-sender
1861 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
1862 --no-suppress-from --no-thread --quiet
1863 --signed-off-by-cc --smtp-pass --smtp-server
1864 --smtp-server-port --smtp-encryption= --smtp-user
1865 --subject --suppress-cc= --suppress-from --thread --to
1866 --validate --no-validate
1867 $__git_format_patch_options"
1871 __git_complete_revlist
1882 local untracked_state
1885 --ignore-submodules=*)
1886 __gitcomp
"none untracked dirty all" "" "${cur##--ignore-submodules=}"
1889 --untracked-files=*)
1890 __gitcomp
"$__git_untracked_file_modes" "" "${cur##--untracked-files=}"
1895 always never auto column row plain dense nodense
1896 " "" "${cur##--column=}"
1901 --short --branch --porcelain --long --verbose
1902 --untracked-files= --ignore-submodules= --ignored
1903 --column= --no-column
1909 untracked_state
="$(__git_get_option_value "-u" "--untracked-files=" \
1910 "$__git_untracked_file_modes" "status.showUntrackedFiles
")"
1912 case "$untracked_state" in
1914 # --ignored option does not matter
1918 complete_opt
="--cached --directory --no-empty-directory --others"
1920 if [ -n "$(__git_find_on_cmdline "--ignored")" ]; then
1921 complete_opt
="$complete_opt --ignored --exclude=*"
1926 __git_complete_index_file
"$complete_opt"
1929 __git_config_get_set_variables
()
1931 local prevword word config_file
= c
=$cword
1932 while [ $c -gt 1 ]; do
1935 --system|
--global|
--local|
--file=*)
1940 config_file
="$word $prevword"
1948 git
--git-dir="$(__gitdir)" config
$config_file --name-only --list 2>/dev
/null
1954 branch.
*.remote|branch.
*.pushremote
)
1955 __gitcomp_nl
"$(__git_remotes)"
1959 __gitcomp_nl
"$(__git_refs)"
1963 __gitcomp
"false true preserve interactive"
1967 __gitcomp_nl
"$(__git_remotes)"
1971 local remote
="${prev#remote.}"
1972 remote
="${remote%.fetch}"
1973 if [ -z "$cur" ]; then
1974 __gitcomp_nl
"refs/heads/" "" "" ""
1977 __gitcomp_nl
"$(__git_refs_remotes "$remote")"
1981 local remote
="${prev#remote.}"
1982 remote
="${remote%.push}"
1983 __gitcomp_nl
"$(git --git-dir="$
(__gitdir
)" \
1984 for-each-ref --format='%(refname):%(refname)' \
1988 pull.twohead|pull.octopus
)
1989 __git_compute_merge_strategies
1990 __gitcomp
"$__git_merge_strategies"
1993 color.branch|color.
diff|color.interactive|\
1994 color.showbranch|color.status|color.ui
)
1995 __gitcomp
"always never auto"
1999 __gitcomp
"false true"
2004 normal black red green yellow blue magenta cyan white
2005 bold dim ul blink reverse
2010 __gitcomp
"log short"
2014 __gitcomp
"man info web html"
2018 __gitcomp
"$__git_log_date_formats"
2021 sendemail.aliasesfiletype
)
2022 __gitcomp
"mutt mailrc pine elm gnus"
2026 __gitcomp
"$__git_send_email_confirm_options"
2029 sendemail.suppresscc
)
2030 __gitcomp
"$__git_send_email_suppresscc_options"
2033 sendemail.transferencoding
)
2034 __gitcomp
"7bit 8bit quoted-printable base64"
2037 --get|
--get-all|
--unset|
--unset-all)
2038 __gitcomp_nl
"$(__git_config_get_set_variables)"
2048 --system --global --local --file=
2049 --list --replace-all
2050 --get --get-all --get-regexp
2051 --add --unset --unset-all
2052 --remove-section --rename-section
2058 local pfx
="${cur%.*}." cur_
="${cur##*.}"
2059 __gitcomp
"remote pushremote merge mergeoptions rebase" "$pfx" "$cur_"
2063 local pfx
="${cur%.*}." cur_
="${cur#*.}"
2064 __gitcomp_nl
"$(__git_heads)" "$pfx" "$cur_" "."
2065 __gitcomp_nl_append $
'autosetupmerge\nautosetuprebase\n' "$pfx" "$cur_"
2069 local pfx
="${cur%.*}." cur_
="${cur##*.}"
2071 argprompt cmd confirm needsfile noconsole norescan
2072 prompt revprompt revunmerged title
2077 local pfx
="${cur%.*}." cur_
="${cur##*.}"
2078 __gitcomp
"cmd path" "$pfx" "$cur_"
2082 local pfx
="${cur%.*}." cur_
="${cur##*.}"
2083 __gitcomp
"cmd path" "$pfx" "$cur_"
2087 local pfx
="${cur%.*}." cur_
="${cur##*.}"
2088 __gitcomp
"cmd path trustExitCode" "$pfx" "$cur_"
2092 local pfx
="${cur%.*}." cur_
="${cur#*.}"
2093 __git_compute_all_commands
2094 __gitcomp_nl
"$__git_all_commands" "$pfx" "$cur_"
2098 local pfx
="${cur%.*}." cur_
="${cur##*.}"
2100 url proxy fetch push mirror skipDefaultUpdate
2101 receivepack uploadpack tagopt pushurl
2106 local pfx
="${cur%.*}." cur_
="${cur#*.}"
2107 __gitcomp_nl
"$(__git_remotes)" "$pfx" "$cur_" "."
2108 __gitcomp_nl_append
"pushdefault" "$pfx" "$cur_"
2112 local pfx
="${cur%.*}." cur_
="${cur##*.}"
2113 __gitcomp
"insteadOf pushInsteadOf" "$pfx" "$cur_"
2119 advice.commitBeforeMerge
2121 advice.implicitIdentity
2122 advice.pushNonFastForward
2123 advice.resolveConflict
2127 apply.ignorewhitespace
2129 branch.autosetupmerge
2130 branch.autosetuprebase
2134 color.branch.current
2139 color.decorate.branch
2140 color.decorate.remoteBranch
2141 color.decorate.stash
2151 color.diff.whitespace
2156 color.grep.linenumber
2159 color.grep.separator
2161 color.interactive.error
2162 color.interactive.header
2163 color.interactive.help
2164 color.interactive.prompt
2169 color.status.changed
2171 color.status.nobranch
2172 color.status.unmerged
2173 color.status.untracked
2174 color.status.updated
2183 core.bigFileThreshold
2186 core.deltaBaseCacheLimit
2191 core.fsyncobjectfiles
2195 core.logAllRefUpdates
2196 core.loosecompression
2199 core.packedGitWindowSize
2201 core.preferSymlinkRefs
2204 core.repositoryFormatVersion
2206 core.sharedRepository
2211 core.warnAmbiguousRefs
2214 diff.autorefreshindex
2216 diff.ignoreSubmodules
2223 diff.suppressBlankEmpty
2229 fetch.recurseSubmodules
2240 format.subjectprefix
2251 gc.reflogexpireunreachable
2255 gitcvs.commitmsgannotation
2256 gitcvs.dbTableNamePrefix
2267 gui.copyblamethreshold
2271 gui.matchtrackingbranch
2272 gui.newbranchtemplate
2273 gui.pruneduringfetch
2274 gui.spellingdictionary
2291 http.sslCertPasswordProtected
2296 i18n.logOutputEncoding
2302 imap.preformattedHTML
2312 interactive.singlekey
2328 mergetool.keepBackup
2329 mergetool.keepTemporaries
2334 notes.rewrite.rebase
2338 pack.deltaCacheLimit
2355 receive.denyCurrentBranch
2356 receive.denyDeleteCurrent
2358 receive.denyNonFastForwards
2361 receive.updateserverinfo
2364 repack.usedeltabaseoffset
2368 sendemail.aliasesfile
2369 sendemail.aliasfiletype
2373 sendemail.chainreplyto
2375 sendemail.envelopesender
2379 sendemail.signedoffbycc
2380 sendemail.smtpdomain
2381 sendemail.smtpencryption
2383 sendemail.smtpserver
2384 sendemail.smtpserveroption
2385 sendemail.smtpserverport
2387 sendemail.suppresscc
2388 sendemail.suppressfrom
2393 status.relativePaths
2394 status.showUntrackedFiles
2395 status.submodulesummary
2398 transfer.unpackLimit
2410 local subcommands
="add rename remove set-head set-branches set-url show prune update"
2411 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
2412 if [ -z "$subcommand" ]; then
2413 __gitcomp
"$subcommands"
2417 case "$subcommand" in
2418 rename|remove|set-url|show|prune
)
2419 __gitcomp_nl
"$(__git_remotes)"
2421 set-head|set-branches
)
2422 __git_complete_remote_or_refspec
2425 __gitcomp
"$(__git_get_config_variables "remotes
")"
2434 __gitcomp_nl
"$(__git_refs)"
2439 __git_has_doubledash
&& return
2443 __gitcomp
"--merge --mixed --hard --soft --patch"
2447 __gitcomp_nl
"$(__git_refs)"
2452 local dir
="$(__gitdir)"
2453 if [ -f "$dir"/REVERT_HEAD
]; then
2454 __gitcomp
"--continue --quit --abort"
2459 __gitcomp
"--edit --mainline --no-edit --no-commit --signoff"
2463 __gitcomp_nl
"$(__git_refs)"
2470 __gitcomp
"--cached --dry-run --ignore-unmatch --quiet"
2475 __git_complete_index_file
"--cached"
2480 __git_has_doubledash
&& return
2485 $__git_log_common_options
2486 $__git_log_shortlog_options
2487 --numbered --summary
2492 __git_complete_revlist
2497 __git_has_doubledash
&& return
2500 --pretty=*|
--format=*)
2501 __gitcomp
"$__git_log_pretty_formats $(__git_pretty_aliases)
2506 __gitcomp
"$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
2510 __gitcomp
"$__git_diff_submodule_formats" "" "${cur##--submodule=}"
2514 __gitcomp
"--pretty= --format= --abbrev-commit --oneline
2516 $__git_diff_common_options
2521 __git_complete_revlist_file
2529 --all --remotes --topo-order --date-order --current --more=
2530 --list --independent --merge-base --no-name
2532 --sha1-name --sparse --topics --reflog
2537 __git_complete_revlist
2542 local save_opts
='--all --keep-index --no-keep-index --quiet --patch --include-untracked'
2543 local subcommands
='save list show apply clear drop pop create branch'
2544 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
2545 if [ -z "$subcommand" ]; then
2548 __gitcomp
"$save_opts"
2551 if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then
2552 __gitcomp
"$subcommands"
2557 case "$subcommand,$cur" in
2559 __gitcomp
"$save_opts"
2562 __gitcomp
"--index --quiet"
2567 show
,--*|branch
,--*)
2570 if [ $cword -eq 3 ]; then
2571 __gitcomp_nl
"$(__git_refs)";
2573 __gitcomp_nl
"$(git --git-dir="$
(__gitdir
)" stash list \
2574 | sed -n -e 's/:.*//p')"
2577 show
,*|apply
,*|drop
,*|pop
,*)
2578 __gitcomp_nl
"$(git --git-dir="$
(__gitdir
)" stash list \
2579 | sed -n -e 's/:.*//p')"
2589 __git_has_doubledash
&& return
2591 local subcommands
="add status init deinit update summary foreach sync"
2592 if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then
2595 __gitcomp
"--quiet --cached"
2598 __gitcomp
"$subcommands"
2608 init fetch clone rebase dcommit log find-rev
2609 set-tree commit-diff info create-ignore propget
2610 proplist show-ignore show-externals branch tag blame
2611 migrate mkdirs reset gc
2613 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
2614 if [ -z "$subcommand" ]; then
2615 __gitcomp
"$subcommands"
2617 local remote_opts
="--username= --config-dir= --no-auth-cache"
2619 --follow-parent --authors-file= --repack=
2620 --no-metadata --use-svm-props --use-svnsync-props
2621 --log-window-size= --no-checkout --quiet
2622 --repack-flags --use-log-author --localtime
2623 --ignore-paths= --include-paths= $remote_opts
2626 --template= --shared= --trunk= --tags=
2627 --branches= --stdlayout --minimize-url
2628 --no-metadata --use-svm-props --use-svnsync-props
2629 --rewrite-root= --prefix= --use-log-author
2630 --add-author-from $remote_opts
2633 --edit --rmdir --find-copies-harder --copy-similarity=
2636 case "$subcommand,$cur" in
2638 __gitcomp
"--revision= --fetch-all $fc_opts"
2641 __gitcomp
"--revision= $fc_opts $init_opts"
2644 __gitcomp
"$init_opts"
2648 --merge --strategy= --verbose --dry-run
2649 --fetch-all --no-rebase --commit-url
2650 --revision --interactive $cmt_opts $fc_opts
2654 __gitcomp
"--stdin $cmt_opts $fc_opts"
2656 create-ignore
,--*|propget
,--*|proplist
,--*|show-ignore
,--*|\
2657 show-externals
,--*|mkdirs
,--*)
2658 __gitcomp
"--revision="
2662 --limit= --revision= --verbose --incremental
2663 --oneline --show-commit --non-recursive
2664 --authors-file= --color
2669 --merge --verbose --strategy= --local
2670 --fetch-all --dry-run $fc_opts
2674 __gitcomp
"--message= --file= --revision= $cmt_opts"
2680 __gitcomp
"--dry-run --message --tag"
2683 __gitcomp
"--dry-run --message"
2686 __gitcomp
"--git-format"
2690 --config-dir= --ignore-paths= --minimize
2691 --no-auth-cache --username=
2695 __gitcomp
"--revision= --parent"
2706 while [ $c -lt $cword ]; do
2710 __gitcomp_nl
"$(__git_tags)"
2725 __gitcomp_nl
"$(__git_tags)"
2729 __gitcomp_nl
"$(__git_refs)"
2736 --list --delete --verify --annotate --message --file
2737 --sign --cleanup --local-user --force --column --sort
2738 --contains --points-at
2751 local subcommands
="add list lock prune unlock"
2752 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
2753 if [ -z "$subcommand" ]; then
2754 __gitcomp
"$subcommands"
2756 case "$subcommand,$cur" in
2758 __gitcomp
"--detach"
2761 __gitcomp
"--porcelain"
2764 __gitcomp
"--reason"
2767 __gitcomp
"--dry-run --expire --verbose"
2777 local i c
=1 command __git_dir
2779 while [ $c -lt $cword ]; do
2782 --git-dir=*) __git_dir
="${i#--git-dir=}" ;;
2783 --git-dir) ((c
++)) ; __git_dir
="${words[c]}" ;;
2784 --bare) __git_dir
="." ;;
2785 --help) command="help"; break ;;
2786 -c|
--work-tree|
--namespace) ((c
++)) ;;
2788 *) command="$i"; break ;;
2793 if [ -z "$command" ]; then
2808 --no-replace-objects
2812 *) __git_compute_porcelain_commands
2813 __gitcomp
"$__git_porcelain_commands $(__git_aliases)" ;;
2818 local completion_func
="_git_${command//-/_}"
2819 declare -f $completion_func >/dev
/null
&& $completion_func && return
2821 local expansion
=$
(__git_aliased_command
"$command")
2822 if [ -n "$expansion" ]; then
2824 completion_func
="_git_${expansion//-/_}"
2825 declare -f $completion_func >/dev
/null
&& $completion_func
2831 __git_has_doubledash
&& return
2833 local g
="$(__gitdir)"
2835 if [ -f "$g/MERGE_HEAD" ]; then
2841 $__git_log_common_options
2842 $__git_log_gitk_options
2848 __git_complete_revlist
2851 if [[ -n ${ZSH_VERSION-} ]]; then
2852 echo "WARNING: this script is deprecated, please see git-completion.zsh" 1>&2
2854 autoload
-U +X compinit
&& compinit
2860 local cur_
="${3-$cur}"
2866 local c IFS
=$
' \t\n'
2874 array
[${#array[@]}+1]="$c"
2877 compadd
-Q -S '' -p "${2-}" -a -- array
&& _ret
=0
2888 compadd
-Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
2897 compadd -Q -p "${2-}" -f -- ${=1} && _ret=0
2902 local _ret=1 cur cword prev
2903 cur=${words[CURRENT]}
2904 prev=${words[CURRENT-1]}
2906 emulate ksh -c __${service}_main
2907 let _ret && _default && _ret=0
2911 compdef _git git gitk
2917 local cur words cword prev
2918 _get_comp_words_by_ref -n =: cur words cword prev
2922 # Setup completion for certain functions defined above by setting common
2923 # variables and workarounds.
2924 # This is NOT a public function; use at your own risk.
2927 local wrapper="__git_wrap
${2}"
2928 eval "$wrapper () { __git_func_wrap
$2 ; }"
2929 complete -o bashdefault -o default -o nospace -F $wrapper $1 2>/dev/null \
2930 || complete -o default -o nospace -F $wrapper $1
2933 # wrapper for backwards compatibility
2936 __git_wrap__git_main
2939 # wrapper for backwards compatibility
2942 __git_wrap__gitk_main
2945 __git_complete git __git_main
2946 __git_complete gitk __gitk_main
2948 # The following are necessary only for Cygwin, and only are needed
2949 # when the user has tab-completed the executable name and consequently
2950 # included the '.exe' suffix.
2952 if [ Cygwin = "$
(uname
-o 2>/dev
/null
)" ]; then
2953 __git_complete git.exe __git_main