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
44 elif [ -n "${GIT_DIR-}" ]; then
45 test -d "${GIT_DIR-}" ||
return 1
47 elif [ -d .git
]; then
50 git rev-parse
--git-dir 2>/dev
/null
52 elif [ -d "$1/.git" ]; then
59 # The following function is based on code from:
61 # bash_completion - programmable completion functions for bash 3.2+
63 # Copyright © 2006-2008, Ian Macdonald <ian@caliban.org>
64 # © 2009-2010, Bash Completion Maintainers
65 # <bash-completion-devel@lists.alioth.debian.org>
67 # This program is free software; you can redistribute it and/or modify
68 # it under the terms of the GNU General Public License as published by
69 # the Free Software Foundation; either version 2, or (at your option)
72 # This program is distributed in the hope that it will be useful,
73 # but WITHOUT ANY WARRANTY; without even the implied warranty of
74 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
75 # GNU General Public License for more details.
77 # You should have received a copy of the GNU General Public License
78 # along with this program; if not, write to the Free Software Foundation,
79 # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
81 # The latest version of this software can be obtained here:
83 # http://bash-completion.alioth.debian.org/
87 # This function can be used to access a tokenized list of words
88 # on the command line:
90 # __git_reassemble_comp_words_by_ref '=:'
91 # if test "${words_[cword_-1]}" = -w
96 # The argument should be a collection of characters from the list of
97 # word completion separators (COMP_WORDBREAKS) to treat as ordinary
100 # This is roughly equivalent to going back in time and setting
101 # COMP_WORDBREAKS to exclude those characters. The intent is to
102 # make option types like --date=<type> and <rev>:<path> easy to
103 # recognize by treating each shell word as a single token.
105 # It is best not to set COMP_WORDBREAKS directly because the value is
106 # shared with other completion scripts. By the time the completion
107 # function gets called, COMP_WORDS has already been populated so local
108 # changes to COMP_WORDBREAKS have no effect.
110 # Output: words_, cword_, cur_.
112 __git_reassemble_comp_words_by_ref
()
114 local exclude i j first
115 # Which word separators to exclude?
116 exclude
="${1//[^$COMP_WORDBREAKS]}"
118 if [ -z "$exclude" ]; then
119 words_
=("${COMP_WORDS[@]}")
122 # List of word completion separators has shrunk;
123 # re-assemble words to complete.
124 for ((i
=0, j
=0; i
< ${#COMP_WORDS[@]}; i
++, j
++)); do
125 # Append each nonempty word consisting of just
126 # word separator characters to the current word.
130 [ -n "${COMP_WORDS[$i]}" ] &&
131 # word consists of excluded word separators
132 [ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ]
134 # Attach to the previous token,
135 # unless the previous token is the command name.
136 if [ $j -ge 2 ] && [ -n "$first" ]; then
140 words_
[$j]=${words_[j]}${COMP_WORDS[i]}
141 if [ $i = $COMP_CWORD ]; then
144 if (($i < ${#COMP_WORDS[@]} - 1)); then
151 words_
[$j]=${words_[j]}${COMP_WORDS[i]}
152 if [ $i = $COMP_CWORD ]; then
158 if ! type _get_comp_words_by_ref
>/dev
/null
2>&1; then
159 _get_comp_words_by_ref
()
161 local exclude cur_ words_ cword_
162 if [ "$1" = "-n" ]; then
166 __git_reassemble_comp_words_by_ref
"$exclude"
167 cur_
=${words_[cword_]}
168 while [ $# -gt 0 ]; do
174 prev
=${words_[$cword_-1]}
177 words
=("${words_[@]}")
190 local x i
=${#COMPREPLY[@]}
192 if [[ "$x" == "$3"* ]]; then
193 COMPREPLY
[i
++]="$2$x$4"
204 # Generates completion reply, appending a space to possible completion words,
206 # It accepts 1 to 4 arguments:
207 # 1: List of possible completion words.
208 # 2: A prefix to be added to each possible completion word (optional).
209 # 3: Generate possible completion matches for this word (optional).
210 # 4: A suffix to be appended to each possible completion word (optional).
213 local cur_
="${3-$cur}"
219 local c i
=0 IFS
=$
' \t\n'
222 if [[ $c == "$cur_"* ]]; then
227 COMPREPLY
[i
++]="${2-}$c"
234 # Variation of __gitcomp_nl () that appends to the existing list of
235 # completion candidates, COMPREPLY.
236 __gitcomp_nl_append
()
239 __gitcompappend
"$1" "${2-}" "${3-$cur}" "${4- }"
242 # Generates completion reply from newline-separated possible completion words
243 # by appending a space to all of them.
244 # It accepts 1 to 4 arguments:
245 # 1: List of possible completion words, separated by a single newline.
246 # 2: A prefix to be added to each possible completion word (optional).
247 # 3: Generate possible completion matches for this word (optional).
248 # 4: A suffix to be appended to each possible completion word instead of
249 # the default space (optional). If specified but empty, nothing is
254 __gitcomp_nl_append
"$@"
257 # Generates completion reply with compgen from newline-separated possible
258 # completion filenames.
259 # It accepts 1 to 3 arguments:
260 # 1: List of possible completion filenames, separated by a single newline.
261 # 2: A directory prefix to be added to each possible completion filename
263 # 3: Generate possible completion matches for this word (optional).
268 # XXX does not work when the directory prefix contains a tilde,
269 # since tilde expansion is not applied.
270 # This means that COMPREPLY will be empty and Bash default
271 # completion will be used.
272 __gitcompadd
"$1" "${2-}" "${3-$cur}" ""
274 # use a hack to enable file mode in bash < 4
275 compopt
-o filenames
+o nospace
2>/dev
/null ||
276 compgen
-f /non-existing-dir
/ > /dev
/null
279 # Execute 'git ls-files', unless the --committable option is specified, in
280 # which case it runs 'git diff-index' to find out the files that can be
281 # committed. It return paths relative to the directory specified in the first
282 # argument, and using the options specified in the second argument.
283 __git_ls_files_helper
()
285 if [ "$2" == "--committable" ]; then
286 git
-C "$1" diff-index
--name-only --relative HEAD
288 # NOTE: $2 is not quoted in order to support multiple options
289 git
-C "$1" ls-files
--exclude-standard $2
294 # __git_index_files accepts 1 or 2 arguments:
295 # 1: Options to pass to ls-files (required).
296 # 2: A directory path (optional).
297 # If provided, only files within the specified directory are listed.
298 # Sub directories are never recursed. Path must have a trailing
302 local dir
="$(__gitdir)" root
="${2-.}" file
304 if [ -d "$dir" ]; then
305 __git_ls_files_helper
"$root" "$1" |
306 while read -r file; do
308 ?
*/*) echo "${file%%/*}" ;;
317 local dir
="$(__gitdir)"
318 if [ -d "$dir" ]; then
319 git
--git-dir="$dir" for-each-ref
--format='%(refname:short)' \
327 local dir
="$(__gitdir)"
328 if [ -d "$dir" ]; then
329 git
--git-dir="$dir" for-each-ref
--format='%(refname:short)' \
335 # Lists refs from the local (by default) or from a remote repository.
336 # It accepts 0, 1 or 2 arguments:
337 # 1: The remote to list refs from (optional; ignored, if set but empty).
338 # 2: In addition to local refs, list unique branches from refs/remotes/ for
339 # 'git checkout's tracking DWIMery (optional; ignored, if set but empty).
342 local i
hash dir
="$(__gitdir "${1-}")" track
="${2-}"
343 local format refs pfx
344 if [ -d "$dir" ]; then
352 [[ "$cur" == ^
* ]] && pfx
="^"
353 for i
in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD
; do
354 if [ -e "$dir/$i" ]; then echo $pfx$i; fi
356 format
="refname:short"
357 refs
="refs/tags refs/heads refs/remotes"
360 git
--git-dir="$dir" for-each-ref
--format="$pfx%($format)" \
362 if [ -n "$track" ]; then
363 # employ the heuristic used by git checkout
364 # Try to find a remote branch that matches the completion word
365 # but only output if the branch name is unique
367 git
--git-dir="$dir" for-each-ref
--shell --format="ref=%(refname:short)" \
369 while read -r entry
; do
372 if [[ "$ref" == "$cur"* ]]; then
375 done |
sort |
uniq -u
381 git ls-remote
"$dir" "$cur*" 2>/dev
/null | \
382 while read -r hash i
; do
391 git for-each-ref
--format="%(refname:short)" -- \
392 "refs/remotes/$dir/" 2>/dev
/null |
sed -e "s#^$dir/##"
397 # __git_refs2 requires 1 argument (to pass to __git_refs)
401 for i
in $
(__git_refs
"$1"); do
406 # __git_refs_remotes requires 1 argument (to pass to ls-remote)
407 __git_refs_remotes
()
410 git ls-remote
"$1" 'refs/heads/*' 2>/dev
/null | \
411 while read -r hash i
; do
412 echo "$i:refs/remotes/$1/${i#refs/heads/}"
418 local d
="$(__gitdir)"
419 test -d "$d/remotes" && ls -1 "$d/remotes"
420 git
--git-dir="$d" remote
423 __git_list_merge_strategies
()
425 git merge
-s help 2>&1 |
426 sed -n -e '/[Aa]vailable strategies are: /,/^$/{
435 __git_merge_strategies
=
436 # 'git merge -s help' (and thus detection of the merge strategy
437 # list) fails, unfortunately, if run outside of any git working
438 # tree. __git_merge_strategies is set to the empty string in
439 # that case, and the detection will be repeated the next time it
441 __git_compute_merge_strategies
()
443 test -n "$__git_merge_strategies" ||
444 __git_merge_strategies
=$
(__git_list_merge_strategies
)
447 __git_complete_revlist_file
()
449 local pfx
ls ref cur_
="$cur"
469 case "$COMP_WORDBREAKS" in
471 *) pfx
="$ref:$pfx" ;;
474 __gitcomp_nl
"$(git --git-dir="$
(__gitdir
)" ls-tree "$ls" 2>/dev/null \
475 | sed '/^100... blob /{
491 pfx
="${cur_%...*}..."
493 __gitcomp_nl
"$(__git_refs)" "$pfx" "$cur_"
498 __gitcomp_nl
"$(__git_refs)" "$pfx" "$cur_"
501 __gitcomp_nl
"$(__git_refs)"
507 # __git_complete_index_file requires 1 argument:
508 # 1: the options to pass to ls-file
510 # The exception is --committable, which finds the files appropriate commit.
511 __git_complete_index_file
()
513 local pfx
="" cur_
="$cur"
523 __gitcomp_file
"$(__git_index_files "$1" ${pfx:+"$pfx"})" "$pfx" "$cur_"
526 __git_complete_file
()
528 __git_complete_revlist_file
531 __git_complete_revlist
()
533 __git_complete_revlist_file
536 __git_complete_remote_or_refspec
()
538 local cur_
="$cur" cmd
="${words[1]}"
539 local i c
=2 remote
="" pfx
="" lhs
=1 no_complete_refspec
=0
540 if [ "$cmd" = "remote" ]; then
543 while [ $c -lt $cword ]; do
546 --mirror) [ "$cmd" = "push" ] && no_complete_refspec
=1 ;;
549 push
) no_complete_refspec
=1 ;;
557 *) remote
="$i"; break ;;
561 if [ -z "$remote" ]; then
562 __gitcomp_nl
"$(__git_remotes)"
565 if [ $no_complete_refspec = 1 ]; then
568 [ "$remote" = "." ] && remote
=
571 case "$COMP_WORDBREAKS" in
573 *) pfx
="${cur_%%:*}:" ;;
585 if [ $lhs = 1 ]; then
586 __gitcomp_nl
"$(__git_refs2 "$remote")" "$pfx" "$cur_"
588 __gitcomp_nl
"$(__git_refs)" "$pfx" "$cur_"
592 if [ $lhs = 1 ]; then
593 __gitcomp_nl
"$(__git_refs "$remote")" "$pfx" "$cur_"
595 __gitcomp_nl
"$(__git_refs)" "$pfx" "$cur_"
599 if [ $lhs = 1 ]; then
600 __gitcomp_nl
"$(__git_refs)" "$pfx" "$cur_"
602 __gitcomp_nl
"$(__git_refs "$remote")" "$pfx" "$cur_"
608 __git_complete_strategy
()
610 __git_compute_merge_strategies
613 __gitcomp
"$__git_merge_strategies"
618 __gitcomp
"$__git_merge_strategies" "" "${cur##--strategy=}"
626 if test -n "${GIT_TESTING_COMMAND_COMPLETION:-}"
628 printf "%s" "${GIT_TESTING_COMMAND_COMPLETION}"
630 git
help -a|
egrep '^ [a-zA-Z0-9]'
634 __git_list_all_commands
()
637 for i
in $
(__git_commands
)
640 *--*) : helper pattern
;;
647 __git_compute_all_commands
()
649 test -n "$__git_all_commands" ||
650 __git_all_commands
=$
(__git_list_all_commands
)
653 __git_list_porcelain_commands
()
656 __git_compute_all_commands
657 for i
in $__git_all_commands
660 *--*) : helper pattern
;;
661 applymbox
) : ask gittus
;;
662 applypatch
) : ask gittus
;;
663 archimport
) : import
;;
664 cat-file
) : plumbing
;;
665 check-attr
) : plumbing
;;
666 check-ignore
) : plumbing
;;
667 check-mailmap
) : plumbing
;;
668 check-ref-format
) : plumbing
;;
669 checkout-index
) : plumbing
;;
670 column) : internal helper
;;
671 commit-tree
) : plumbing
;;
672 count-objects
) : infrequent
;;
673 credential
) : credentials
;;
674 credential-
*) : credentials helper
;;
675 cvsexportcommit
) : export;;
676 cvsimport
) : import
;;
677 cvsserver
) : daemon
;;
679 diff-files
) : plumbing
;;
680 diff-index
) : plumbing
;;
681 diff-tree
) : plumbing
;;
682 fast-import
) : import
;;
683 fast-export
) : export;;
684 fsck-objects
) : plumbing
;;
685 fetch-pack
) : plumbing
;;
686 fmt-merge-msg
) : plumbing
;;
687 for-each-ref
) : plumbing
;;
688 hash-object
) : plumbing
;;
689 http-
*) : transport
;;
690 index-pack
) : plumbing
;;
691 init-db
) : deprecated
;;
692 local-fetch
) : plumbing
;;
693 ls-files
) : plumbing
;;
694 ls-remote
) : plumbing
;;
695 ls-tree
) : plumbing
;;
696 mailinfo
) : plumbing
;;
697 mailsplit
) : plumbing
;;
698 merge-
*) : plumbing
;;
701 pack-objects
) : plumbing
;;
702 pack-redundant
) : plumbing
;;
703 pack-refs
) : plumbing
;;
704 parse-remote
) : plumbing
;;
705 patch-id
) : plumbing
;;
707 prune-packed
) : plumbing
;;
708 quiltimport
) : import
;;
709 read-tree
) : plumbing
;;
710 receive-pack
) : plumbing
;;
711 remote-
*) : transport
;;
713 rev-list
) : plumbing
;;
714 rev-parse
) : plumbing
;;
715 runstatus
) : plumbing
;;
716 sh-setup
) : internal
;;
718 show-ref
) : plumbing
;;
719 send-pack
) : plumbing
;;
720 show-index
) : plumbing
;;
722 stripspace
) : plumbing
;;
723 symbolic-ref
) : plumbing
;;
724 unpack-file
) : plumbing
;;
725 unpack-objects
) : plumbing
;;
726 update-index
) : plumbing
;;
727 update-ref
) : plumbing
;;
728 update-server-info
) : daemon
;;
729 upload-archive
) : plumbing
;;
730 upload-pack
) : plumbing
;;
731 write-tree
) : plumbing
;;
733 verify-pack
) : infrequent
;;
734 verify-tag
) : plumbing
;;
740 __git_porcelain_commands
=
741 __git_compute_porcelain_commands
()
743 test -n "$__git_porcelain_commands" ||
744 __git_porcelain_commands
=$
(__git_list_porcelain_commands
)
747 # Lists all set config variables starting with the given section prefix,
748 # with the prefix removed.
749 __git_get_config_variables
()
751 local section
="$1" i IFS
=$
'\n'
752 for i
in $
(git
--git-dir="$(__gitdir)" config
--name-only --get-regexp "^$section\..*" 2>/dev
/null
); do
753 echo "${i#$section.}"
757 __git_pretty_aliases
()
759 __git_get_config_variables
"pretty"
764 __git_get_config_variables
"alias"
767 # __git_aliased_command requires 1 argument
768 __git_aliased_command
()
770 local word cmdline
=$
(git
--git-dir="$(__gitdir)" \
771 config
--get "alias.$1")
772 for word
in $cmdline; do
778 \
!*) : shell
command alias ;;
780 *=*) : setting env
;;
782 \
(\
)) : skip parens of shell
function definition
;;
783 {) : skip start of shell helper
function ;;
784 :) : skip null
command ;;
785 \'*) : skip opening quote after sh
-c ;;
793 # __git_find_on_cmdline requires 1 argument
794 __git_find_on_cmdline
()
796 local word subcommand c
=1
797 while [ $c -lt $cword ]; do
799 for subcommand
in $1; do
800 if [ "$subcommand" = "$word" ]; then
809 # Echo the value of an option set on the command line or config
811 # $1: short option name
812 # $2: long option name including =
813 # $3: list of possible values
814 # $4: config string (optional)
817 # result="$(__git_get_option_value "-d" "--do-something=" \
818 # "yes no" "core.doSomething")"
820 # result is then either empty (no option set) or "yes" or "no"
822 # __git_get_option_value requires 3 arguments
823 __git_get_option_value
()
825 local c short_opt long_opt val
826 local result
= values config_key word
834 while [ $c -ge 0 ]; do
836 for val
in $values; do
837 if [ "$short_opt$val" = "$word" ] ||
838 [ "$long_opt$val" = "$word" ]; then
846 if [ -n "$config_key" ] && [ -z "$result" ]; then
847 result
="$(git --git-dir="$
(__gitdir
)" config "$config_key")"
853 __git_has_doubledash
()
856 while [ $c -lt $cword ]; do
857 if [ "--" = "${words[c]}" ]; then
865 # Try to count non option arguments passed on the command line for the
866 # specified git command.
867 # When options are used, it is necessary to use the special -- option to
868 # tell the implementation were non option arguments begin.
869 # XXX this can not be improved, since options can appear everywhere, as
873 # __git_count_arguments requires 1 argument: the git command executed.
874 __git_count_arguments
()
878 # Skip "git" (first argument)
879 for ((i
=1; i
< ${#words[@]}; i
++)); do
884 # Good; we can assume that the following are only non
889 # Skip the specified git command and discard git
902 __git_whitespacelist
="nowarn warn error error-all fix"
906 local dir
="$(__gitdir)"
907 if [ -d "$dir"/rebase-apply
]; then
908 __gitcomp
"--skip --continue --resolved --abort"
913 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
918 --3way --committer-date-is-author-date --ignore-date
919 --ignore-whitespace --ignore-space-change
920 --interactive --keep --no-utf8 --signoff --utf8
921 --whitespace= --scissors
931 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
936 --stat --numstat --summary --check --index
937 --cached --index-info --reverse --reject --unidiff-zero
938 --apply --no-add --exclude=
939 --ignore-whitespace --ignore-space-change
940 --whitespace= --inaccurate-eof --verbose
951 --interactive --refresh --patch --update --dry-run
952 --ignore-errors --intent-to-add
957 # XXX should we check for --update and --all options ?
958 __git_complete_index_file
"--others --modified --directory --no-empty-directory"
965 __gitcomp
"$(git archive --list)" "" "${cur##--format=}"
969 __gitcomp_nl
"$(__git_remotes)" "" "${cur##--remote=}"
974 --format= --list --verbose
975 --prefix= --remote= --exec=
985 __git_has_doubledash
&& return
987 local subcommands
="start bad good skip reset visualize replay log run"
988 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
989 if [ -z "$subcommand" ]; then
990 if [ -f "$(__gitdir)"/BISECT_START
]; then
991 __gitcomp
"$subcommands"
993 __gitcomp
"replay start"
998 case "$subcommand" in
999 bad|good|
reset|skip|start
)
1000 __gitcomp_nl
"$(__git_refs)"
1009 local i c
=1 only_local_ref
="n" has_r
="n"
1011 while [ $c -lt $cword ]; do
1014 -d|
--delete|
-m|
--move) only_local_ref
="y" ;;
1015 -r|
--remotes) has_r
="y" ;;
1021 --set-upstream-to=*)
1022 __gitcomp_nl
"$(__git_refs)" "" "${cur##--set-upstream-to=}"
1026 --color --no-color --verbose --abbrev= --no-abbrev
1027 --track --no-track --contains --merged --no-merged
1028 --set-upstream-to= --edit-description --list
1029 --unset-upstream --delete --move --remotes
1033 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
1034 __gitcomp_nl
"$(__git_heads)"
1036 __gitcomp_nl
"$(__git_refs)"
1044 local cmd
="${words[2]}"
1047 __gitcomp
"create list-heads verify unbundle"
1050 # looking for a file
1055 __git_complete_revlist
1064 __git_has_doubledash
&& return
1068 __gitcomp
"diff3 merge" "" "${cur##--conflict=}"
1072 --quiet --ours --theirs --track --no-track --merge
1073 --conflict= --orphan --patch
1077 # check if --track, --no-track, or --no-guess was specified
1078 # if so, disable DWIM mode
1079 local flags
="--track --no-track --no-guess" track
=1
1080 if [ -n "$(__git_find_on_cmdline "$flags")" ]; then
1083 __gitcomp_nl
"$(__git_refs '' $track)"
1090 __gitcomp_nl
"$(__git_refs)"
1095 local dir
="$(__gitdir)"
1096 if [ -f "$dir"/CHERRY_PICK_HEAD
]; then
1097 __gitcomp
"--continue --quit --abort"
1102 __gitcomp
"--edit --no-commit --signoff --strategy= --mainline"
1105 __gitcomp_nl
"$(__git_refs)"
1114 __gitcomp
"--dry-run --quiet"
1119 # XXX should we check for -x option ?
1120 __git_complete_index_file
"--others --directory"
1142 --recurse-submodules
1149 __git_untracked_file_modes
="all no normal"
1155 __gitcomp_nl
"$(__git_refs)" "" "${cur}"
1162 __gitcomp
"default scissors strip verbatim whitespace
1163 " "" "${cur##--cleanup=}"
1166 --reuse-message=*|
--reedit-message=*|\
1167 --fixup=*|
--squash=*)
1168 __gitcomp_nl
"$(__git_refs)" "" "${cur#*=}"
1171 --untracked-files=*)
1172 __gitcomp
"$__git_untracked_file_modes" "" "${cur##--untracked-files=}"
1177 --all --author= --signoff --verify --no-verify
1179 --amend --include --only --interactive
1180 --dry-run --reuse-message= --reedit-message=
1181 --reset-author --file= --message= --template=
1182 --cleanup= --untracked-files --untracked-files=
1183 --verbose --quiet --fixup= --squash=
1188 if git rev-parse
--verify --quiet HEAD
>/dev
/null
; then
1189 __git_complete_index_file
"--committable"
1191 # This is the first commit
1192 __git_complete_index_file
"--cached"
1201 --all --tags --contains --abbrev= --candidates=
1202 --exact-match --debug --long --match --always
1206 __gitcomp_nl
"$(__git_refs)"
1209 __git_diff_algorithms
="myers minimal patience histogram"
1211 __git_diff_submodule_formats
="diff log short"
1213 __git_diff_common_options
="--stat --numstat --shortstat --summary
1214 --patch-with-stat --name-only --name-status --color
1215 --no-color --color-words --no-renames --check
1216 --full-index --binary --abbrev --diff-filter=
1217 --find-copies-harder
1218 --text --ignore-space-at-eol --ignore-space-change
1219 --ignore-all-space --ignore-blank-lines --exit-code
1220 --quiet --ext-diff --no-ext-diff
1221 --no-prefix --src-prefix= --dst-prefix=
1222 --inter-hunk-context=
1223 --patience --histogram --minimal
1224 --raw --word-diff --word-diff-regex=
1225 --dirstat --dirstat= --dirstat-by-file
1226 --dirstat-by-file= --cumulative
1228 --submodule --submodule=
1233 __git_has_doubledash
&& return
1237 __gitcomp
"$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
1241 __gitcomp
"$__git_diff_submodule_formats" "" "${cur##--submodule=}"
1245 __gitcomp
"--cached --staged --pickaxe-all --pickaxe-regex
1246 --base --ours --theirs --no-index
1247 $__git_diff_common_options
1252 __git_complete_revlist_file
1255 __git_mergetools_common
="diffuse diffmerge ecmerge emerge kdiff3 meld opendiff
1256 tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc codecompare
1261 __git_has_doubledash
&& return
1265 __gitcomp
"$__git_mergetools_common kompare" "" "${cur##--tool=}"
1269 __gitcomp
"--cached --staged --pickaxe-all --pickaxe-regex
1270 --base --ours --theirs
1271 --no-renames --diff-filter= --find-copies-harder
1272 --relative --ignore-submodules
1277 __git_complete_revlist_file
1280 __git_fetch_recurse_submodules
="yes on-demand no"
1282 __git_fetch_options
="
1283 --quiet --verbose --append --upload-pack --force --keep --depth=
1284 --tags --no-tags --all --prune --dry-run --recurse-submodules=
1290 --recurse-submodules=*)
1291 __gitcomp
"$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}"
1295 __gitcomp
"$__git_fetch_options"
1299 __git_complete_remote_or_refspec
1302 __git_format_patch_options
="
1303 --stdout --attach --no-attach --thread --thread= --no-thread
1304 --numbered --start-number --numbered-files --keep-subject --signoff
1305 --signature --no-signature --in-reply-to= --cc= --full-index --binary
1306 --not --all --cover-letter --no-prefix --src-prefix= --dst-prefix=
1307 --inline --suffix= --ignore-if-in-upstream --subject-prefix=
1308 --output-directory --reroll-count --to= --quiet --notes
1311 _git_format_patch
()
1317 " "" "${cur##--thread=}"
1321 __gitcomp
"$__git_format_patch_options"
1325 __git_complete_revlist
1333 --tags --root --unreachable --cache --no-reflogs --full
1334 --strict --verbose --lost-found
1345 __gitcomp
"--prune --aggressive"
1356 __git_match_ctag
() {
1357 awk "/^${1//\//\\/}/ { print \$1 }" "$2"
1362 __git_has_doubledash
&& return
1368 --text --ignore-case --word-regexp --invert-match
1369 --full-name --line-number
1370 --extended-regexp --basic-regexp --fixed-strings
1373 --files-with-matches --name-only
1374 --files-without-match
1377 --and --or --not --all-match
1383 case "$cword,$prev" in
1385 if test -r tags
; then
1386 __gitcomp_nl
"$(__git_match_ctag "$cur" tags)"
1392 __gitcomp_nl
"$(__git_refs)"
1399 __gitcomp
"--all --guides --info --man --web"
1403 __git_compute_all_commands
1404 __gitcomp
"$__git_all_commands $(__git_aliases)
1405 attributes cli core-tutorial cvs-migration
1406 diffcore everyday gitk glossary hooks ignore modules
1407 namespaces repository-layout revisions tutorial tutorial-2
1417 false true umask group all world everybody
1418 " "" "${cur##--shared=}"
1422 __gitcomp
"--quiet --bare --template= --shared --shared="
1432 __gitcomp
"--cached --deleted --modified --others --ignored
1433 --stage --directory --no-empty-directory --unmerged
1434 --killed --exclude= --exclude-from=
1435 --exclude-per-directory= --exclude-standard
1436 --error-unmatch --with-tree= --full-name
1437 --abbrev --ignored --exclude-per-directory
1443 # XXX ignore options like --modified and always suggest all cached
1445 __git_complete_index_file
"--cached"
1450 __gitcomp_nl
"$(__git_remotes)"
1458 # Options that go well for log, shortlog and gitk
1459 __git_log_common_options
="
1461 --branches --tags --remotes
1462 --first-parent --merges --no-merges
1464 --max-age= --since= --after=
1465 --min-age= --until= --before=
1466 --min-parents= --max-parents=
1467 --no-min-parents --no-max-parents
1469 # Options that go well for log and gitk (not shortlog)
1470 __git_log_gitk_options
="
1471 --dense --sparse --full-history
1472 --simplify-merges --simplify-by-decoration
1473 --left-right --notes --no-notes
1475 # Options that go well for log and shortlog (not gitk)
1476 __git_log_shortlog_options
="
1477 --author= --committer= --grep=
1478 --all-match --invert-grep
1481 __git_log_pretty_formats
="oneline short medium full fuller email raw format:"
1482 __git_log_date_formats
="relative iso8601 rfc2822 short local default raw"
1486 __git_has_doubledash
&& return
1488 local g
="$(git rev-parse --git-dir 2>/dev/null)"
1490 if [ -f "$g/MERGE_HEAD" ]; then
1494 --pretty=*|
--format=*)
1495 __gitcomp
"$__git_log_pretty_formats $(__git_pretty_aliases)
1500 __gitcomp
"$__git_log_date_formats" "" "${cur##--date=}"
1504 __gitcomp
"full short no" "" "${cur##--decorate=}"
1508 __gitcomp
"$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
1512 __gitcomp
"$__git_diff_submodule_formats" "" "${cur##--submodule=}"
1517 $__git_log_common_options
1518 $__git_log_shortlog_options
1519 $__git_log_gitk_options
1520 --root --topo-order --date-order --reverse
1521 --follow --full-diff
1522 --abbrev-commit --abbrev=
1523 --relative-date --date=
1524 --pretty= --format= --oneline
1529 --decorate --decorate=
1531 --parents --children
1533 $__git_diff_common_options
1534 --pickaxe-all --pickaxe-regex
1539 __git_complete_revlist
1542 # Common merge options shared by git-merge(1) and git-pull(1).
1543 __git_merge_options
="
1544 --no-commit --no-stat --log --no-log --squash --strategy
1545 --commit --stat --no-squash --ff --no-ff --ff-only --edit --no-edit
1546 --verify-signatures --no-verify-signatures --gpg-sign
1547 --quiet --verbose --progress --no-progress
1552 __git_complete_strategy
&& return
1556 __gitcomp
"$__git_merge_options
1557 --rerere-autoupdate --no-rerere-autoupdate --abort --continue"
1560 __gitcomp_nl
"$(__git_refs)"
1567 __gitcomp
"$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"
1581 __gitcomp
"--octopus --independent --is-ancestor --fork-point"
1585 __gitcomp_nl
"$(__git_refs)"
1592 __gitcomp
"--dry-run"
1597 if [ $
(__git_count_arguments
"mv") -gt 0 ]; then
1598 # We need to show both cached and untracked files (including
1599 # empty directories) since this may not be the last argument.
1600 __git_complete_index_file
"--cached --others --directory"
1602 __git_complete_index_file
"--cached"
1608 __gitcomp
"--tags --all --stdin"
1613 local subcommands
='add append copy edit list prune remove show'
1614 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
1616 case "$subcommand,$cur" in
1623 __gitcomp_nl
"$(__git_refs)"
1626 __gitcomp
"$subcommands --ref"
1630 add
,--reuse-message=*|append
,--reuse-message=*|\
1631 add
,--reedit-message=*|append
,--reedit-message=*)
1632 __gitcomp_nl
"$(__git_refs)" "" "${cur#*=}"
1635 __gitcomp
'--file= --message= --reedit-message=
1642 __gitcomp
'--dry-run --verbose'
1651 __gitcomp_nl
"$(__git_refs)"
1660 __git_complete_strategy
&& return
1663 --recurse-submodules=*)
1664 __gitcomp
"$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}"
1669 --rebase --no-rebase
1670 $__git_merge_options
1671 $__git_fetch_options
1676 __git_complete_remote_or_refspec
1679 __git_push_recurse_submodules
="check on-demand"
1681 __git_complete_force_with_lease
()
1689 __gitcomp_nl
"$(__git_refs)" "" "${cur_#*:}"
1692 __gitcomp_nl
"$(__git_refs)" "" "$cur_"
1701 __gitcomp_nl
"$(__git_remotes)"
1704 --recurse-submodules)
1705 __gitcomp
"$__git_push_recurse_submodules"
1711 __gitcomp_nl
"$(__git_remotes)" "" "${cur##--repo=}"
1714 --recurse-submodules=*)
1715 __gitcomp
"$__git_push_recurse_submodules" "" "${cur##--recurse-submodules=}"
1718 --force-with-lease=*)
1719 __git_complete_force_with_lease
"${cur##--force-with-lease=}"
1724 --all --mirror --tags --dry-run --force --verbose
1725 --quiet --prune --delete --follow-tags
1726 --receive-pack= --repo= --set-upstream
1727 --force-with-lease --force-with-lease= --recurse-submodules=
1732 __git_complete_remote_or_refspec
1737 local dir
="$(__gitdir)"
1738 if [ -f "$dir"/rebase-merge
/interactive
]; then
1739 __gitcomp
"--continue --skip --abort --quit --edit-todo"
1741 elif [ -d "$dir"/rebase-apply
] ||
[ -d "$dir"/rebase-merge
]; then
1742 __gitcomp
"--continue --skip --abort --quit"
1745 __git_complete_strategy
&& return
1748 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
1753 --onto --merge --strategy --interactive
1754 --preserve-merges --stat --no-stat
1755 --committer-date-is-author-date --ignore-date
1756 --ignore-whitespace --whitespace=
1757 --autosquash --no-autosquash
1758 --fork-point --no-fork-point
1759 --autostash --no-autostash
1760 --verify --no-verify
1761 --keep-empty --root --force-rebase --no-ff
1767 __gitcomp_nl
"$(__git_refs)"
1772 local subcommands
="show delete expire"
1773 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
1775 if [ -z "$subcommand" ]; then
1776 __gitcomp
"$subcommands"
1778 __gitcomp_nl
"$(__git_refs)"
1782 __git_send_email_confirm_options
="always never auto cc compose"
1783 __git_send_email_suppresscc_options
="author self cc bodycc sob cccmd body all"
1788 --to|
--cc|
--bcc|
--from)
1790 $(git --git-dir="$
(__gitdir
)" send-email --dump-aliases 2>/dev/null)
1799 $__git_send_email_confirm_options
1800 " "" "${cur##--confirm=}"
1805 $__git_send_email_suppresscc_options
1806 " "" "${cur##--suppress-cc=}"
1810 --smtp-encryption=*)
1811 __gitcomp
"ssl tls" "" "${cur##--smtp-encryption=}"
1817 " "" "${cur##--thread=}"
1820 --to=*|
--cc=*|
--bcc=*|
--from=*)
1822 $(git --git-dir="$
(__gitdir
)" send-email --dump-aliases 2>/dev/null)
1827 __gitcomp
"--annotate --bcc --cc --cc-cmd --chain-reply-to
1828 --compose --confirm= --dry-run --envelope-sender
1830 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
1831 --no-suppress-from --no-thread --quiet
1832 --signed-off-by-cc --smtp-pass --smtp-server
1833 --smtp-server-port --smtp-encryption= --smtp-user
1834 --subject --suppress-cc= --suppress-from --thread --to
1835 --validate --no-validate
1836 $__git_format_patch_options"
1840 __git_complete_revlist
1851 local untracked_state
1854 --ignore-submodules=*)
1855 __gitcomp
"none untracked dirty all" "" "${cur##--ignore-submodules=}"
1858 --untracked-files=*)
1859 __gitcomp
"$__git_untracked_file_modes" "" "${cur##--untracked-files=}"
1864 always never auto column row plain dense nodense
1865 " "" "${cur##--column=}"
1870 --short --branch --porcelain --long --verbose
1871 --untracked-files= --ignore-submodules= --ignored
1872 --column= --no-column
1878 untracked_state
="$(__git_get_option_value "-u" "--untracked-files=" \
1879 "$__git_untracked_file_modes" "status.showUntrackedFiles
")"
1881 case "$untracked_state" in
1883 # --ignored option does not matter
1887 complete_opt
="--cached --directory --no-empty-directory --others"
1889 if [ -n "$(__git_find_on_cmdline "--ignored")" ]; then
1890 complete_opt
="$complete_opt --ignored --exclude=*"
1895 __git_complete_index_file
"$complete_opt"
1898 __git_config_get_set_variables
()
1900 local prevword word config_file
= c
=$cword
1901 while [ $c -gt 1 ]; do
1904 --system|
--global|
--local|
--file=*)
1909 config_file
="$word $prevword"
1917 git
--git-dir="$(__gitdir)" config
$config_file --name-only --list 2>/dev
/null
1923 branch.
*.remote|branch.
*.pushremote
)
1924 __gitcomp_nl
"$(__git_remotes)"
1928 __gitcomp_nl
"$(__git_refs)"
1932 __gitcomp
"false true preserve interactive"
1936 __gitcomp_nl
"$(__git_remotes)"
1940 local remote
="${prev#remote.}"
1941 remote
="${remote%.fetch}"
1942 if [ -z "$cur" ]; then
1943 __gitcomp_nl
"refs/heads/" "" "" ""
1946 __gitcomp_nl
"$(__git_refs_remotes "$remote")"
1950 local remote
="${prev#remote.}"
1951 remote
="${remote%.push}"
1952 __gitcomp_nl
"$(git --git-dir="$
(__gitdir
)" \
1953 for-each-ref --format='%(refname):%(refname)' \
1957 pull.twohead|pull.octopus
)
1958 __git_compute_merge_strategies
1959 __gitcomp
"$__git_merge_strategies"
1962 color.branch|color.
diff|color.interactive|\
1963 color.showbranch|color.status|color.ui
)
1964 __gitcomp
"always never auto"
1968 __gitcomp
"false true"
1973 normal black red green yellow blue magenta cyan white
1974 bold dim ul blink reverse
1979 __gitcomp
"log short"
1983 __gitcomp
"man info web html"
1987 __gitcomp
"$__git_log_date_formats"
1990 sendemail.aliasesfiletype
)
1991 __gitcomp
"mutt mailrc pine elm gnus"
1995 __gitcomp
"$__git_send_email_confirm_options"
1998 sendemail.suppresscc
)
1999 __gitcomp
"$__git_send_email_suppresscc_options"
2002 sendemail.transferencoding
)
2003 __gitcomp
"7bit 8bit quoted-printable base64"
2006 --get|
--get-all|
--unset|
--unset-all)
2007 __gitcomp_nl
"$(__git_config_get_set_variables)"
2017 --system --global --local --file=
2018 --list --replace-all
2019 --get --get-all --get-regexp
2020 --add --unset --unset-all
2021 --remove-section --rename-section
2027 local pfx
="${cur%.*}." cur_
="${cur##*.}"
2028 __gitcomp
"remote pushremote merge mergeoptions rebase" "$pfx" "$cur_"
2032 local pfx
="${cur%.*}." cur_
="${cur#*.}"
2033 __gitcomp_nl
"$(__git_heads)" "$pfx" "$cur_" "."
2034 __gitcomp_nl_append $
'autosetupmerge\nautosetuprebase\n' "$pfx" "$cur_"
2038 local pfx
="${cur%.*}." cur_
="${cur##*.}"
2040 argprompt cmd confirm needsfile noconsole norescan
2041 prompt revprompt revunmerged title
2046 local pfx
="${cur%.*}." cur_
="${cur##*.}"
2047 __gitcomp
"cmd path" "$pfx" "$cur_"
2051 local pfx
="${cur%.*}." cur_
="${cur##*.}"
2052 __gitcomp
"cmd path" "$pfx" "$cur_"
2056 local pfx
="${cur%.*}." cur_
="${cur##*.}"
2057 __gitcomp
"cmd path trustExitCode" "$pfx" "$cur_"
2061 local pfx
="${cur%.*}." cur_
="${cur#*.}"
2062 __git_compute_all_commands
2063 __gitcomp_nl
"$__git_all_commands" "$pfx" "$cur_"
2067 local pfx
="${cur%.*}." cur_
="${cur##*.}"
2069 url proxy fetch push mirror skipDefaultUpdate
2070 receivepack uploadpack tagopt pushurl
2075 local pfx
="${cur%.*}." cur_
="${cur#*.}"
2076 __gitcomp_nl
"$(__git_remotes)" "$pfx" "$cur_" "."
2077 __gitcomp_nl_append
"pushdefault" "$pfx" "$cur_"
2081 local pfx
="${cur%.*}." cur_
="${cur##*.}"
2082 __gitcomp
"insteadOf pushInsteadOf" "$pfx" "$cur_"
2088 advice.commitBeforeMerge
2090 advice.implicitIdentity
2091 advice.pushNonFastForward
2092 advice.resolveConflict
2096 apply.ignorewhitespace
2098 branch.autosetupmerge
2099 branch.autosetuprebase
2103 color.branch.current
2108 color.decorate.branch
2109 color.decorate.remoteBranch
2110 color.decorate.stash
2120 color.diff.whitespace
2125 color.grep.linenumber
2128 color.grep.separator
2130 color.interactive.error
2131 color.interactive.header
2132 color.interactive.help
2133 color.interactive.prompt
2138 color.status.changed
2140 color.status.nobranch
2141 color.status.unmerged
2142 color.status.untracked
2143 color.status.updated
2152 core.bigFileThreshold
2155 core.deltaBaseCacheLimit
2160 core.fsyncobjectfiles
2164 core.logAllRefUpdates
2165 core.loosecompression
2168 core.packedGitWindowSize
2170 core.preferSymlinkRefs
2173 core.repositoryFormatVersion
2175 core.sharedRepository
2180 core.warnAmbiguousRefs
2183 diff.autorefreshindex
2185 diff.ignoreSubmodules
2192 diff.suppressBlankEmpty
2198 fetch.recurseSubmodules
2209 format.subjectprefix
2220 gc.reflogexpireunreachable
2224 gitcvs.commitmsgannotation
2225 gitcvs.dbTableNamePrefix
2236 gui.copyblamethreshold
2240 gui.matchtrackingbranch
2241 gui.newbranchtemplate
2242 gui.pruneduringfetch
2243 gui.spellingdictionary
2260 http.sslCertPasswordProtected
2265 i18n.logOutputEncoding
2271 imap.preformattedHTML
2281 interactive.singlekey
2297 mergetool.keepBackup
2298 mergetool.keepTemporaries
2303 notes.rewrite.rebase
2307 pack.deltaCacheLimit
2324 receive.denyCurrentBranch
2325 receive.denyDeleteCurrent
2327 receive.denyNonFastForwards
2330 receive.updateserverinfo
2333 repack.usedeltabaseoffset
2337 sendemail.aliasesfile
2338 sendemail.aliasfiletype
2342 sendemail.chainreplyto
2344 sendemail.envelopesender
2348 sendemail.signedoffbycc
2349 sendemail.smtpdomain
2350 sendemail.smtpencryption
2352 sendemail.smtpserver
2353 sendemail.smtpserveroption
2354 sendemail.smtpserverport
2356 sendemail.suppresscc
2357 sendemail.suppressfrom
2362 status.relativePaths
2363 status.showUntrackedFiles
2364 status.submodulesummary
2367 transfer.unpackLimit
2379 local subcommands
="add rename remove set-head set-branches set-url show prune update"
2380 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
2381 if [ -z "$subcommand" ]; then
2382 __gitcomp
"$subcommands"
2386 case "$subcommand" in
2387 rename|remove|set-url|show|prune
)
2388 __gitcomp_nl
"$(__git_remotes)"
2390 set-head|set-branches
)
2391 __git_complete_remote_or_refspec
2394 __gitcomp
"$(__git_get_config_variables "remotes
")"
2403 __gitcomp_nl
"$(__git_refs)"
2408 __git_has_doubledash
&& return
2412 __gitcomp
"--merge --mixed --hard --soft --patch"
2416 __gitcomp_nl
"$(__git_refs)"
2421 local dir
="$(__gitdir)"
2422 if [ -f "$dir"/REVERT_HEAD
]; then
2423 __gitcomp
"--continue --quit --abort"
2428 __gitcomp
"--edit --mainline --no-edit --no-commit --signoff"
2432 __gitcomp_nl
"$(__git_refs)"
2439 __gitcomp
"--cached --dry-run --ignore-unmatch --quiet"
2444 __git_complete_index_file
"--cached"
2449 __git_has_doubledash
&& return
2454 $__git_log_common_options
2455 $__git_log_shortlog_options
2456 --numbered --summary
2461 __git_complete_revlist
2466 __git_has_doubledash
&& return
2469 --pretty=*|
--format=*)
2470 __gitcomp
"$__git_log_pretty_formats $(__git_pretty_aliases)
2475 __gitcomp
"$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
2479 __gitcomp
"$__git_diff_submodule_formats" "" "${cur##--submodule=}"
2483 __gitcomp
"--pretty= --format= --abbrev-commit --oneline
2485 $__git_diff_common_options
2490 __git_complete_revlist_file
2498 --all --remotes --topo-order --date-order --current --more=
2499 --list --independent --merge-base --no-name
2501 --sha1-name --sparse --topics --reflog
2506 __git_complete_revlist
2511 local save_opts
='--all --keep-index --no-keep-index --quiet --patch --include-untracked'
2512 local subcommands
='save list show apply clear drop pop create branch'
2513 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
2514 if [ -z "$subcommand" ]; then
2517 __gitcomp
"$save_opts"
2520 if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then
2521 __gitcomp
"$subcommands"
2526 case "$subcommand,$cur" in
2528 __gitcomp
"$save_opts"
2531 __gitcomp
"--index --quiet"
2536 show
,--*|branch
,--*)
2539 if [ $cword -eq 3 ]; then
2540 __gitcomp_nl
"$(__git_refs)";
2542 __gitcomp_nl
"$(git --git-dir="$
(__gitdir
)" stash list \
2543 | sed -n -e 's/:.*//p')"
2546 show
,*|apply
,*|drop
,*|pop
,*)
2547 __gitcomp_nl
"$(git --git-dir="$
(__gitdir
)" stash list \
2548 | sed -n -e 's/:.*//p')"
2558 __git_has_doubledash
&& return
2560 local subcommands
="add status init deinit update summary foreach sync"
2561 if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then
2564 __gitcomp
"--quiet --cached"
2567 __gitcomp
"$subcommands"
2577 init fetch clone rebase dcommit log find-rev
2578 set-tree commit-diff info create-ignore propget
2579 proplist show-ignore show-externals branch tag blame
2580 migrate mkdirs reset gc
2582 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
2583 if [ -z "$subcommand" ]; then
2584 __gitcomp
"$subcommands"
2586 local remote_opts
="--username= --config-dir= --no-auth-cache"
2588 --follow-parent --authors-file= --repack=
2589 --no-metadata --use-svm-props --use-svnsync-props
2590 --log-window-size= --no-checkout --quiet
2591 --repack-flags --use-log-author --localtime
2592 --ignore-paths= --include-paths= $remote_opts
2595 --template= --shared= --trunk= --tags=
2596 --branches= --stdlayout --minimize-url
2597 --no-metadata --use-svm-props --use-svnsync-props
2598 --rewrite-root= --prefix= --use-log-author
2599 --add-author-from $remote_opts
2602 --edit --rmdir --find-copies-harder --copy-similarity=
2605 case "$subcommand,$cur" in
2607 __gitcomp
"--revision= --fetch-all $fc_opts"
2610 __gitcomp
"--revision= $fc_opts $init_opts"
2613 __gitcomp
"$init_opts"
2617 --merge --strategy= --verbose --dry-run
2618 --fetch-all --no-rebase --commit-url
2619 --revision --interactive $cmt_opts $fc_opts
2623 __gitcomp
"--stdin $cmt_opts $fc_opts"
2625 create-ignore
,--*|propget
,--*|proplist
,--*|show-ignore
,--*|\
2626 show-externals
,--*|mkdirs
,--*)
2627 __gitcomp
"--revision="
2631 --limit= --revision= --verbose --incremental
2632 --oneline --show-commit --non-recursive
2633 --authors-file= --color
2638 --merge --verbose --strategy= --local
2639 --fetch-all --dry-run $fc_opts
2643 __gitcomp
"--message= --file= --revision= $cmt_opts"
2649 __gitcomp
"--dry-run --message --tag"
2652 __gitcomp
"--dry-run --message"
2655 __gitcomp
"--git-format"
2659 --config-dir= --ignore-paths= --minimize
2660 --no-auth-cache --username=
2664 __gitcomp
"--revision= --parent"
2675 while [ $c -lt $cword ]; do
2679 __gitcomp_nl
"$(__git_tags)"
2694 __gitcomp_nl
"$(__git_tags)"
2698 __gitcomp_nl
"$(__git_refs)"
2705 --list --delete --verify --annotate --message --file
2706 --sign --cleanup --local-user --force --column --sort
2707 --contains --points-at
2720 local subcommands
="add list lock prune unlock"
2721 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
2722 if [ -z "$subcommand" ]; then
2723 __gitcomp
"$subcommands"
2725 case "$subcommand,$cur" in
2727 __gitcomp
"--detach"
2730 __gitcomp
"--porcelain"
2733 __gitcomp
"--reason"
2736 __gitcomp
"--dry-run --expire --verbose"
2746 local i c
=1 command __git_dir
2748 while [ $c -lt $cword ]; do
2751 --git-dir=*) __git_dir
="${i#--git-dir=}" ;;
2752 --git-dir) ((c
++)) ; __git_dir
="${words[c]}" ;;
2753 --bare) __git_dir
="." ;;
2754 --help) command="help"; break ;;
2755 -c|
--work-tree|
--namespace) ((c
++)) ;;
2757 *) command="$i"; break ;;
2762 if [ -z "$command" ]; then
2777 --no-replace-objects
2781 *) __git_compute_porcelain_commands
2782 __gitcomp
"$__git_porcelain_commands $(__git_aliases)" ;;
2787 local completion_func
="_git_${command//-/_}"
2788 declare -f $completion_func >/dev
/null
&& $completion_func && return
2790 local expansion
=$
(__git_aliased_command
"$command")
2791 if [ -n "$expansion" ]; then
2793 completion_func
="_git_${expansion//-/_}"
2794 declare -f $completion_func >/dev
/null
&& $completion_func
2800 __git_has_doubledash
&& return
2802 local g
="$(__gitdir)"
2804 if [ -f "$g/MERGE_HEAD" ]; then
2810 $__git_log_common_options
2811 $__git_log_gitk_options
2817 __git_complete_revlist
2820 if [[ -n ${ZSH_VERSION-} ]]; then
2821 echo "WARNING: this script is deprecated, please see git-completion.zsh" 1>&2
2823 autoload
-U +X compinit
&& compinit
2829 local cur_
="${3-$cur}"
2835 local c IFS
=$
' \t\n'
2843 array
[${#array[@]}+1]="$c"
2846 compadd
-Q -S '' -p "${2-}" -a -- array
&& _ret
=0
2857 compadd
-Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
2866 compadd -Q -p "${2-}" -f -- ${=1} && _ret=0
2871 local _ret=1 cur cword prev
2872 cur=${words[CURRENT]}
2873 prev=${words[CURRENT-1]}
2875 emulate ksh -c __${service}_main
2876 let _ret && _default && _ret=0
2880 compdef _git git gitk
2886 local cur words cword prev
2887 _get_comp_words_by_ref -n =: cur words cword prev
2891 # Setup completion for certain functions defined above by setting common
2892 # variables and workarounds.
2893 # This is NOT a public function; use at your own risk.
2896 local wrapper="__git_wrap
${2}"
2897 eval "$wrapper () { __git_func_wrap
$2 ; }"
2898 complete -o bashdefault -o default -o nospace -F $wrapper $1 2>/dev/null \
2899 || complete -o default -o nospace -F $wrapper $1
2902 # wrapper for backwards compatibility
2905 __git_wrap__git_main
2908 # wrapper for backwards compatibility
2911 __git_wrap__gitk_main
2914 __git_complete git __git_main
2915 __git_complete gitk __gitk_main
2917 # The following are necessary only for Cygwin, and only are needed
2918 # when the user has tab-completed the executable name and consequently
2919 # included the '.exe' suffix.
2921 if [ Cygwin = "$
(uname
-o 2>/dev
/null
)" ]; then
2922 __git_complete git.exe __git_main