3 # bash completion support for core Git.
5 # Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
6 # Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
7 # Distributed under the GNU General Public License, version 2.0.
9 # The contained completion routines provide support for completing:
11 # *) local and remote branch names
12 # *) local and remote tag names
13 # *) .git/remotes file names
14 # *) git 'subcommands'
15 # *) tree paths within 'ref:path/to/file' expressions
16 # *) common --long-options
18 # To use these routines:
20 # 1) Copy this file to somewhere (e.g. ~/.git-completion.sh).
21 # 2) Added the following line to your .bashrc:
22 # source ~/.git-completion.sh
24 # 3) You may want to make sure the git executable is available
25 # in your PATH before this script is sourced, as some caching
26 # is performed while the script loads. If git isn't found
27 # at source time then all lookups will be done on demand,
28 # which may be slightly slower.
30 # 4) Consider changing your PS1 to also show the current branch:
31 # PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
33 # The argument to __git_ps1 will be displayed only if you
34 # are currently in a git repository. The %s token will be
35 # the name of the current branch.
37 # In addition, if you set GIT_PS1_SHOWDIRTYSTATE to a nonempty
38 # value, unstaged (*) and staged (+) changes will be shown next
39 # to the branch name. You can configure this per-repository
40 # with the bash.showDirtyState variable, which defaults to true
41 # once GIT_PS1_SHOWDIRTYSTATE is enabled.
43 # You can also see if currently something is stashed, by setting
44 # GIT_PS1_SHOWSTASHSTATE to a nonempty value. If something is stashed,
45 # then a '$' will be shown next to the branch name.
49 # *) Read Documentation/SubmittingPatches
50 # *) Send all patches to the current maintainer:
52 # "Shawn O. Pearce" <spearce@spearce.org>
54 # *) Always CC the Git mailing list:
59 case "$COMP_WORDBREAKS" in
61 *) COMP_WORDBREAKS
="$COMP_WORDBREAKS:"
64 # __gitdir accepts 0 or 1 arguments (i.e., location)
65 # returns location of .git repo
68 if [ -z "${1-}" ]; then
69 if [ -n "${__git_dir-}" ]; then
71 elif [ -d .git
]; then
74 git rev-parse
--git-dir 2>/dev
/null
76 elif [ -d "$1/.git" ]; then
83 # __git_ps1 accepts 0 or 1 arguments (i.e., format string)
84 # returns text to add to bash PS1 prompt (includes branch name)
91 if [ -f "$g/rebase-merge/interactive" ]; then
93 b
="$(cat "$g/rebase-merge
/head-name
")"
94 elif [ -d "$g/rebase-merge" ]; then
96 b
="$(cat "$g/rebase-merge
/head-name
")"
98 if [ -d "$g/rebase-apply" ]; then
99 if [ -f "$g/rebase-apply/rebasing" ]; then
101 elif [ -f "$g/rebase-apply/applying" ]; then
106 elif [ -f "$g/MERGE_HEAD" ]; then
108 elif [ -f "$g/BISECT_LOG" ]; then
112 b
="$(git symbolic-ref HEAD 2>/dev/null)" ||
{
115 case "${GIT_PS1_DESCRIBE_STYLE-}" in
117 git describe --contains HEAD ;;
119 git describe --contains --all HEAD ;;
123 git describe --exact-match HEAD ;;
124 esac 2>/dev/null)" ||
126 b
="$(cut -c1-7 "$g/HEAD
" 2>/dev/null)..." ||
137 if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then
138 if [ "true" = "$(git rev-parse --is-bare-repository 2>/dev/null)" ]; then
143 elif [ "true" = "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
144 if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ]; then
145 if [ "$(git config --bool bash.showDirtyState)" != "false" ]; then
146 git
diff --no-ext-diff --ignore-submodules \
147 --quiet --exit-code || w
="*"
148 if git rev-parse
--quiet --verify HEAD
>/dev
/null
; then
149 git diff-index
--cached --quiet \
150 --ignore-submodules HEAD
-- || i
="+"
156 if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ]; then
157 git rev-parse
--verify refs
/stash
>/dev
/null
2>&1 && s
="$"
161 if [ -n "${1-}" ]; then
162 printf "$1" "$c${b##refs/heads/}$w$i$s$r"
164 printf " (%s)" "$c${b##refs/heads/}$w$i$s$r"
169 # __gitcomp_1 requires 2 arguments
172 local c IFS
=' '$
'\t'$
'\n'
175 --*=*) printf %s$
'\n' "$c$2" ;;
176 *.
) printf %s$
'\n' "$c$2" ;;
177 *) printf %s$
'\n' "$c$2 " ;;
182 # __gitcomp accepts 1, 2, 3, or 4 arguments
183 # generates completion reply with compgen
186 local cur
="${COMP_WORDS[COMP_CWORD]}"
187 if [ $# -gt 2 ]; then
196 COMPREPLY
=($
(compgen
-P "${2-}" \
197 -W "$(__gitcomp_1 "${1-}" "${4-}")" \
203 # __git_heads accepts 0 or 1 arguments (to pass to __gitdir)
206 local cmd i is_hash
=y dir
="$(__gitdir "${1-}")"
207 if [ -d "$dir" ]; then
208 git
--git-dir="$dir" for-each-ref
--format='%(refname:short)' \
212 for i
in $
(git ls-remote
"${1-}" 2>/dev
/null
); do
213 case "$is_hash,$i" in
216 n
,refs
/heads
/*) is_hash
=y
; echo "${i#refs/heads/}" ;;
217 n
,*) is_hash
=y
; echo "$i" ;;
222 # __git_tags accepts 0 or 1 arguments (to pass to __gitdir)
225 local cmd i is_hash
=y dir
="$(__gitdir "${1-}")"
226 if [ -d "$dir" ]; then
227 git
--git-dir="$dir" for-each-ref
--format='%(refname:short)' \
231 for i
in $
(git ls-remote
"${1-}" 2>/dev
/null
); do
232 case "$is_hash,$i" in
235 n
,refs
/tags
/*) is_hash
=y
; echo "${i#refs/tags/}" ;;
236 n
,*) is_hash
=y
; echo "$i" ;;
241 # __git_refs accepts 0 or 1 arguments (to pass to __gitdir)
244 local i is_hash
=y dir
="$(__gitdir "${1-}")"
245 local cur
="${COMP_WORDS[COMP_CWORD]}" format refs
246 if [ -d "$dir" ]; then
253 if [ -e "$dir/HEAD" ]; then echo HEAD
; fi
254 format
="refname:short"
255 refs
="refs/tags refs/heads refs/remotes"
258 git
--git-dir="$dir" for-each-ref
--format="%($format)" \
262 for i
in $
(git ls-remote
"$dir" 2>/dev
/null
); do
263 case "$is_hash,$i" in
266 n
,refs
/tags
/*) is_hash
=y
; echo "${i#refs/tags/}" ;;
267 n
,refs
/heads
/*) is_hash
=y
; echo "${i#refs/heads/}" ;;
268 n
,refs
/remotes
/*) is_hash
=y
; echo "${i#refs/remotes/}" ;;
269 n
,*) is_hash
=y
; echo "$i" ;;
274 # __git_refs2 requires 1 argument (to pass to __git_refs)
278 for i
in $
(__git_refs
"$1"); do
283 # __git_refs_remotes requires 1 argument (to pass to ls-remote)
284 __git_refs_remotes
()
286 local cmd i is_hash
=y
287 for i
in $
(git ls-remote
"$1" 2>/dev
/null
); do
288 case "$is_hash,$i" in
291 echo "$i:refs/remotes/$1/${i#refs/heads/}"
295 n
,refs
/tags
/*) is_hash
=y
;;
303 local i ngoff IFS
=$
'\n' d
="$(__gitdir)"
304 shopt -q nullglob || ngoff
=1
306 for i
in "$d/remotes"/*; do
307 echo ${i#$d/remotes/}
309 [ "$ngoff" ] && shopt -u nullglob
310 for i
in $
(git
--git-dir="$d" config
--list); do
320 __git_merge_strategies
()
322 if [ -n "${__git_merge_strategylist-}" ]; then
323 echo "$__git_merge_strategylist"
326 git merge
-s help 2>&1 |
327 sed -n -e '/[Aa]vailable strategies are: /,/^$/{
335 __git_merge_strategylist
=
336 __git_merge_strategylist
=$
(__git_merge_strategies
2>/dev
/null
)
338 __git_complete_file
()
340 local pfx
ls ref cur
="${COMP_WORDS[COMP_CWORD]}"
357 case "$COMP_WORDBREAKS" in
359 *) pfx
="$ref:$pfx" ;;
363 COMPREPLY
=($
(compgen
-P "$pfx" \
364 -W "$(git --git-dir="$
(__gitdir
)" ls-tree "$ls" \
365 | sed '/^100... blob /{
381 __gitcomp
"$(__git_refs)"
386 __git_complete_revlist
()
388 local pfx cur
="${COMP_WORDS[COMP_CWORD]}"
393 __gitcomp
"$(__git_refs)" "$pfx" "$cur"
398 __gitcomp
"$(__git_refs)" "$pfx" "$cur"
401 __gitcomp
"$(__git_refs)"
406 __git_complete_remote_or_refspec
()
408 local cmd
="${COMP_WORDS[1]}"
409 local cur
="${COMP_WORDS[COMP_CWORD]}"
410 local i c
=2 remote
="" pfx
="" lhs
=1 no_complete_refspec
=0
411 while [ $c -lt $COMP_CWORD ]; do
414 --all|
--mirror) [ "$cmd" = "push" ] && no_complete_refspec
=1 ;;
416 *) remote
="$i"; break ;;
420 if [ -z "$remote" ]; then
421 __gitcomp
"$(__git_remotes)"
424 if [ $no_complete_refspec = 1 ]; then
428 [ "$remote" = "." ] && remote
=
431 case "$COMP_WORDBREAKS" in
433 *) pfx
="${cur%%:*}:" ;;
445 if [ $lhs = 1 ]; then
446 __gitcomp
"$(__git_refs2 "$remote")" "$pfx" "$cur"
448 __gitcomp
"$(__git_refs)" "$pfx" "$cur"
452 if [ $lhs = 1 ]; then
453 __gitcomp
"$(__git_refs "$remote")" "$pfx" "$cur"
455 __gitcomp
"$(__git_refs)" "$pfx" "$cur"
459 if [ $lhs = 1 ]; then
460 __gitcomp
"$(__git_refs)" "$pfx" "$cur"
462 __gitcomp
"$(__git_refs "$remote")" "$pfx" "$cur"
468 __git_complete_strategy
()
470 case "${COMP_WORDS[COMP_CWORD-1]}" in
472 __gitcomp
"$(__git_merge_strategies)"
475 local cur
="${COMP_WORDS[COMP_CWORD]}"
478 __gitcomp
"$(__git_merge_strategies)" "" "${cur##--strategy=}"
485 __git_all_commands
()
487 if [ -n "${__git_all_commandlist-}" ]; then
488 echo "$__git_all_commandlist"
492 for i
in $
(git
help -a|
egrep '^ ')
495 *--*) : helper pattern
;;
500 __git_all_commandlist
=
501 __git_all_commandlist
="$(__git_all_commands 2>/dev/null)"
503 __git_porcelain_commands
()
505 if [ -n "${__git_porcelain_commandlist-}" ]; then
506 echo "$__git_porcelain_commandlist"
510 for i
in "help" $
(__git_all_commands
)
513 *--*) : helper pattern
;;
514 applymbox
) : ask gittus
;;
515 applypatch
) : ask gittus
;;
516 archimport
) : import
;;
517 cat-file
) : plumbing
;;
518 check-attr
) : plumbing
;;
519 check-ref-format
) : plumbing
;;
520 checkout-index
) : plumbing
;;
521 commit-tree
) : plumbing
;;
522 count-objects
) : infrequent
;;
523 cvsexportcommit
) : export;;
524 cvsimport
) : import
;;
525 cvsserver
) : daemon
;;
527 diff-files
) : plumbing
;;
528 diff-index
) : plumbing
;;
529 diff-tree
) : plumbing
;;
530 fast-import
) : import
;;
531 fast-export
) : export;;
532 fsck-objects
) : plumbing
;;
533 fetch-pack
) : plumbing
;;
534 fmt-merge-msg
) : plumbing
;;
535 for-each-ref
) : plumbing
;;
536 hash-object
) : plumbing
;;
537 http-
*) : transport
;;
538 index-pack
) : plumbing
;;
539 init-db
) : deprecated
;;
540 local-fetch
) : plumbing
;;
541 lost-found
) : infrequent
;;
542 ls-files
) : plumbing
;;
543 ls-remote
) : plumbing
;;
544 ls-tree
) : plumbing
;;
545 mailinfo
) : plumbing
;;
546 mailsplit
) : plumbing
;;
547 merge-
*) : plumbing
;;
550 pack-objects
) : plumbing
;;
551 pack-redundant
) : plumbing
;;
552 pack-refs
) : plumbing
;;
553 parse-remote
) : plumbing
;;
554 patch-id
) : plumbing
;;
555 peek-remote
) : plumbing
;;
557 prune-packed
) : plumbing
;;
558 quiltimport
) : import
;;
559 read-tree
) : plumbing
;;
560 receive-pack
) : plumbing
;;
562 repo-config
) : deprecated
;;
564 rev-list
) : plumbing
;;
565 rev-parse
) : plumbing
;;
566 runstatus
) : plumbing
;;
567 sh-setup
) : internal
;;
569 show-ref
) : plumbing
;;
570 send-pack
) : plumbing
;;
571 show-index
) : plumbing
;;
573 stripspace
) : plumbing
;;
574 symbolic-ref
) : plumbing
;;
575 tar-tree
) : deprecated
;;
576 unpack-file
) : plumbing
;;
577 unpack-objects
) : plumbing
;;
578 update-index
) : plumbing
;;
579 update-ref
) : plumbing
;;
580 update-server-info
) : daemon
;;
581 upload-archive
) : plumbing
;;
582 upload-pack
) : plumbing
;;
583 write-tree
) : plumbing
;;
585 verify-pack
) : infrequent
;;
586 verify-tag
) : plumbing
;;
591 __git_porcelain_commandlist
=
592 __git_porcelain_commandlist
="$(__git_porcelain_commands 2>/dev/null)"
597 for i
in $
(git
--git-dir="$(__gitdir)" config
--list); do
607 # __git_aliased_command requires 1 argument
608 __git_aliased_command
()
610 local word cmdline
=$
(git
--git-dir="$(__gitdir)" \
611 config
--get "alias.$1")
612 for word
in $cmdline; do
613 if [ "${word##-*}" ]; then
620 # __git_find_subcommand requires 1 argument
621 __git_find_subcommand
()
623 local word subcommand c
=1
625 while [ $c -lt $COMP_CWORD ]; do
626 word
="${COMP_WORDS[c]}"
627 for subcommand
in $1; do
628 if [ "$subcommand" = "$word" ]; then
637 __git_has_doubledash
()
640 while [ $c -lt $COMP_CWORD ]; do
641 if [ "--" = "${COMP_WORDS[c]}" ]; then
649 __git_whitespacelist
="nowarn warn error error-all fix"
653 local cur
="${COMP_WORDS[COMP_CWORD]}" dir
="$(__gitdir)"
654 if [ -d "$dir"/rebase-apply
]; then
655 __gitcomp
"--skip --resolved --abort"
660 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
665 --3way --committer-date-is-author-date --ignore-date
666 --interactive --keep --no-utf8 --signoff --utf8
676 local cur
="${COMP_WORDS[COMP_CWORD]}"
679 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
684 --stat --numstat --summary --check --index
685 --cached --index-info --reverse --reject --unidiff-zero
686 --apply --no-add --exclude=
687 --whitespace= --inaccurate-eof --verbose
696 __git_has_doubledash
&& return
698 local cur
="${COMP_WORDS[COMP_CWORD]}"
702 --interactive --refresh --patch --update --dry-run
703 --ignore-errors --intent-to-add
712 local cur
="${COMP_WORDS[COMP_CWORD]}"
715 __gitcomp
"$(git archive --list)" "" "${cur##--format=}"
719 __gitcomp
"$(__git_remotes)" "" "${cur##--remote=}"
724 --format= --list --verbose
725 --prefix= --remote= --exec=
735 __git_has_doubledash
&& return
737 local subcommands
="start bad good skip reset visualize replay log run"
738 local subcommand
="$(__git_find_subcommand "$subcommands")"
739 if [ -z "$subcommand" ]; then
740 __gitcomp
"$subcommands"
744 case "$subcommand" in
746 __gitcomp
"$(__git_refs)"
756 local i c
=1 only_local_ref
="n" has_r
="n"
758 while [ $c -lt $COMP_CWORD ]; do
761 -d|
-m) only_local_ref
="y" ;;
767 case "${COMP_WORDS[COMP_CWORD]}" in
770 --color --no-color --verbose --abbrev= --no-abbrev
771 --track --no-track --contains --merged --no-merged
775 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
776 __gitcomp
"$(__git_heads)"
778 __gitcomp
"$(__git_refs)"
786 local cmd
="${COMP_WORDS[2]}"
787 case "$COMP_CWORD" in
789 __gitcomp
"create list-heads verify unbundle"
797 __git_complete_revlist
806 __git_has_doubledash
&& return
808 __gitcomp
"$(__git_refs)"
813 __gitcomp
"$(__git_refs)"
818 local cur
="${COMP_WORDS[COMP_CWORD]}"
821 __gitcomp
"--edit --no-commit"
824 __gitcomp
"$(__git_refs)"
831 __git_has_doubledash
&& return
833 local cur
="${COMP_WORDS[COMP_CWORD]}"
836 __gitcomp
"--dry-run --quiet"
845 local cur
="${COMP_WORDS[COMP_CWORD]}"
870 __git_has_doubledash
&& return
872 local cur
="${COMP_WORDS[COMP_CWORD]}"
876 --all --author= --signoff --verify --no-verify
877 --edit --amend --include --only --interactive
886 local cur
="${COMP_WORDS[COMP_CWORD]}"
890 --all --tags --contains --abbrev= --candidates=
891 --exact-match --debug --long --match --always
895 __gitcomp
"$(__git_refs)"
898 __git_diff_common_options
="--stat --numstat --shortstat --summary
899 --patch-with-stat --name-only --name-status --color
900 --no-color --color-words --no-renames --check
901 --full-index --binary --abbrev --diff-filter=
903 --text --ignore-space-at-eol --ignore-space-change
904 --ignore-all-space --exit-code --quiet --ext-diff
906 --no-prefix --src-prefix= --dst-prefix=
907 --inter-hunk-context=
914 __git_has_doubledash
&& return
916 local cur
="${COMP_WORDS[COMP_CWORD]}"
919 __gitcomp
"--cached --staged --pickaxe-all --pickaxe-regex
920 --base --ours --theirs
921 $__git_diff_common_options
929 __git_mergetools_common
="diffuse ecmerge emerge kdiff3 meld opendiff
930 tkdiff vimdiff gvimdiff xxdiff araxis
935 local cur
="${COMP_WORDS[COMP_CWORD]}"
938 __gitcomp
"$__git_mergetools_common kompare" "" "${cur##--tool=}"
949 __git_fetch_options
="
950 --quiet --verbose --append --upload-pack --force --keep --depth=
956 local cur
="${COMP_WORDS[COMP_CWORD]}"
959 __gitcomp
"$__git_fetch_options"
963 __git_complete_remote_or_refspec
968 local cur
="${COMP_WORDS[COMP_CWORD]}"
973 " "" "${cur##--thread=}"
978 --stdout --attach --no-attach --thread --thread=
980 --numbered --start-number
985 --full-index --binary
988 --no-prefix --src-prefix= --dst-prefix=
989 --inline --suffix= --ignore-if-in-upstream
995 __git_complete_revlist
1000 local cur
="${COMP_WORDS[COMP_CWORD]}"
1004 --tags --root --unreachable --cache --no-reflogs --full
1005 --strict --verbose --lost-found
1015 local cur
="${COMP_WORDS[COMP_CWORD]}"
1018 __gitcomp
"--prune --aggressive"
1027 __git_has_doubledash
&& return
1029 local cur
="${COMP_WORDS[COMP_CWORD]}"
1034 --text --ignore-case --word-regexp --invert-match
1036 --extended-regexp --basic-regexp --fixed-strings
1037 --files-with-matches --name-only
1038 --files-without-match
1040 --and --or --not --all-match
1050 local cur
="${COMP_WORDS[COMP_CWORD]}"
1053 __gitcomp
"--all --info --man --web"
1057 __gitcomp
"$(__git_all_commands)
1058 attributes cli core-tutorial cvs-migration
1059 diffcore gitk glossary hooks ignore modules
1060 repository-layout tutorial tutorial-2
1067 local cur
="${COMP_WORDS[COMP_CWORD]}"
1071 false true umask group all world everybody
1072 " "" "${cur##--shared=}"
1076 __gitcomp
"--quiet --bare --template= --shared --shared="
1085 __git_has_doubledash
&& return
1087 local cur
="${COMP_WORDS[COMP_CWORD]}"
1090 __gitcomp
"--cached --deleted --modified --others --ignored
1091 --stage --directory --no-empty-directory --unmerged
1092 --killed --exclude= --exclude-from=
1093 --exclude-per-directory= --exclude-standard
1094 --error-unmatch --with-tree= --full-name
1095 --abbrev --ignored --exclude-per-directory
1105 __gitcomp
"$(__git_remotes)"
1113 # Options that go well for log, shortlog and gitk
1114 __git_log_common_options
="
1116 --branches --tags --remotes
1117 --first-parent --merges --no-merges
1119 --max-age= --since= --after=
1120 --min-age= --until= --before=
1122 # Options that go well for log and gitk (not shortlog)
1123 __git_log_gitk_options
="
1124 --dense --sparse --full-history
1125 --simplify-merges --simplify-by-decoration
1128 # Options that go well for log and shortlog (not gitk)
1129 __git_log_shortlog_options
="
1130 --author= --committer= --grep=
1134 __git_log_pretty_formats
="oneline short medium full fuller email raw format:"
1135 __git_log_date_formats
="relative iso8601 rfc2822 short local default raw"
1139 __git_has_doubledash
&& return
1141 local cur
="${COMP_WORDS[COMP_CWORD]}"
1142 local g
="$(git rev-parse --git-dir 2>/dev/null)"
1144 if [ -f "$g/MERGE_HEAD" ]; then
1149 __gitcomp
"$__git_log_pretty_formats
1150 " "" "${cur##--pretty=}"
1154 __gitcomp
"$__git_log_pretty_formats
1155 " "" "${cur##--format=}"
1159 __gitcomp
"$__git_log_date_formats" "" "${cur##--date=}"
1164 $__git_log_common_options
1165 $__git_log_shortlog_options
1166 $__git_log_gitk_options
1167 --root --topo-order --date-order --reverse
1168 --follow --full-diff
1169 --abbrev-commit --abbrev=
1170 --relative-date --date=
1171 --pretty= --format= --oneline
1176 --parents --children
1178 $__git_diff_common_options
1179 --pickaxe-all --pickaxe-regex
1184 __git_complete_revlist
1187 __git_merge_options
="
1188 --no-commit --no-stat --log --no-log --squash --strategy
1189 --commit --stat --no-squash --ff --no-ff
1194 __git_complete_strategy
&& return
1196 local cur
="${COMP_WORDS[COMP_CWORD]}"
1199 __gitcomp
"$__git_merge_options"
1202 __gitcomp
"$(__git_refs)"
1207 local cur
="${COMP_WORDS[COMP_CWORD]}"
1210 __gitcomp
"$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"
1223 __gitcomp
"$(__git_refs)"
1228 local cur
="${COMP_WORDS[COMP_CWORD]}"
1231 __gitcomp
"--dry-run"
1240 __gitcomp
"--tags --all --stdin"
1245 __git_complete_strategy
&& return
1247 local cur
="${COMP_WORDS[COMP_CWORD]}"
1251 --rebase --no-rebase
1252 $__git_merge_options
1253 $__git_fetch_options
1258 __git_complete_remote_or_refspec
1263 local cur
="${COMP_WORDS[COMP_CWORD]}"
1264 case "${COMP_WORDS[COMP_CWORD-1]}" in
1266 __gitcomp
"$(__git_remotes)"
1271 __gitcomp
"$(__git_remotes)" "" "${cur##--repo=}"
1276 --all --mirror --tags --dry-run --force --verbose
1277 --receive-pack= --repo=
1282 __git_complete_remote_or_refspec
1287 local cur
="${COMP_WORDS[COMP_CWORD]}" dir
="$(__gitdir)"
1288 if [ -d "$dir"/rebase-apply
] ||
[ -d "$dir"/rebase-merge
]; then
1289 __gitcomp
"--continue --skip --abort"
1292 __git_complete_strategy
&& return
1295 __gitcomp
"--onto --merge --strategy --interactive"
1298 __gitcomp
"$(__git_refs)"
1301 __git_send_email_confirm_options
="always never auto cc compose"
1302 __git_send_email_suppresscc_options
="author self cc bodycc sob cccmd body all"
1306 local cur
="${COMP_WORDS[COMP_CWORD]}"
1310 $__git_send_email_confirm_options
1311 " "" "${cur##--confirm=}"
1316 $__git_send_email_suppresscc_options
1317 " "" "${cur##--suppress-cc=}"
1321 --smtp-encryption=*)
1322 __gitcomp
"ssl tls" "" "${cur##--smtp-encryption=}"
1326 __gitcomp
"--annotate --bcc --cc --cc-cmd --chain-reply-to
1327 --compose --confirm= --dry-run --envelope-sender
1329 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
1330 --no-suppress-from --no-thread --quiet
1331 --signed-off-by-cc --smtp-pass --smtp-server
1332 --smtp-server-port --smtp-encryption= --smtp-user
1333 --subject --suppress-cc= --suppress-from --thread --to
1334 --validate --no-validate"
1341 __git_config_get_set_variables
()
1343 local prevword word config_file
= c
=$COMP_CWORD
1344 while [ $c -gt 1 ]; do
1345 word
="${COMP_WORDS[c]}"
1347 --global|
--system|
--file=*)
1352 config_file
="$word $prevword"
1360 git
--git-dir="$(__gitdir)" config
$config_file --list 2>/dev
/null |
1373 local cur
="${COMP_WORDS[COMP_CWORD]}"
1374 local prv
="${COMP_WORDS[COMP_CWORD-1]}"
1377 __gitcomp
"$(__git_remotes)"
1381 __gitcomp
"$(__git_refs)"
1385 local remote
="${prv#remote.}"
1386 remote
="${remote%.fetch}"
1387 __gitcomp
"$(__git_refs_remotes "$remote")"
1391 local remote
="${prv#remote.}"
1392 remote
="${remote%.push}"
1393 __gitcomp
"$(git --git-dir="$
(__gitdir
)" \
1394 for-each-ref --format='%(refname):%(refname)' \
1398 pull.twohead|pull.octopus
)
1399 __gitcomp
"$(__git_merge_strategies)"
1402 color.branch|color.
diff|color.interactive|\
1403 color.showbranch|color.status|color.ui
)
1404 __gitcomp
"always never auto"
1408 __gitcomp
"false true"
1413 normal black red green yellow blue magenta cyan white
1414 bold dim ul blink reverse
1419 __gitcomp
"man info web html"
1423 __gitcomp
"$__git_log_date_formats"
1426 sendemail.aliasesfiletype
)
1427 __gitcomp
"mutt mailrc pine elm gnus"
1431 __gitcomp
"$__git_send_email_confirm_options"
1434 sendemail.suppresscc
)
1435 __gitcomp
"$__git_send_email_suppresscc_options"
1438 --get|
--get-all|
--unset|
--unset-all)
1439 __gitcomp
"$(__git_config_get_set_variables)"
1450 --global --system --file=
1451 --list --replace-all
1452 --get --get-all --get-regexp
1453 --add --unset --unset-all
1454 --remove-section --rename-section
1459 local pfx
="${cur%.*}."
1461 __gitcomp
"remote merge mergeoptions rebase" "$pfx" "$cur"
1465 local pfx
="${cur%.*}."
1467 __gitcomp
"$(__git_heads)" "$pfx" "$cur" "."
1471 local pfx
="${cur%.*}."
1474 argprompt cmd confirm needsfile noconsole norescan
1475 prompt revprompt revunmerged title
1480 local pfx
="${cur%.*}."
1482 __gitcomp
"cmd path" "$pfx" "$cur"
1486 local pfx
="${cur%.*}."
1488 __gitcomp
"cmd path" "$pfx" "$cur"
1492 local pfx
="${cur%.*}."
1494 __gitcomp
"cmd path trustExitCode" "$pfx" "$cur"
1498 local pfx
="${cur%.*}."
1500 __gitcomp
"$(__git_all_commands)" "$pfx" "$cur"
1504 local pfx
="${cur%.*}."
1507 url proxy fetch push mirror skipDefaultUpdate
1508 receivepack uploadpack tagopt pushurl
1513 local pfx
="${cur%.*}."
1515 __gitcomp
"$(__git_remotes)" "$pfx" "$cur" "."
1519 local pfx
="${cur%.*}."
1521 __gitcomp
"insteadof" "$pfx" "$cur"
1529 branch.autosetupmerge
1530 branch.autosetuprebase
1533 color.branch.current
1544 color.diff.whitespace
1549 color.interactive.header
1550 color.interactive.help
1551 color.interactive.prompt
1556 color.status.changed
1558 color.status.nobranch
1559 color.status.untracked
1560 color.status.updated
1567 core.deltaBaseCacheLimit
1571 core.fsyncobjectfiles
1573 core.ignoreCygwinFSTricks
1575 core.logAllRefUpdates
1576 core.loosecompression
1578 core.packedGitWindowSize
1580 core.preferSymlinkRefs
1583 core.repositoryFormatVersion
1585 core.sharedRepository
1588 core.warnAmbiguousRefs
1591 diff.autorefreshindex
1597 diff.suppressBlankEmpty
1609 format.subjectprefix
1618 gc.reflogexpireunreachable
1622 gitcvs.commitmsgannotation
1623 gitcvs.dbTableNamePrefix
1634 gui.copyblamethreshold
1638 gui.matchtrackingbranch
1639 gui.newbranchtemplate
1640 gui.pruneduringfetch
1641 gui.spellingdictionary
1657 i18n.logOutputEncoding
1662 imap.preformattedHTML
1671 interactive.singlekey
1684 mergetool.keepBackup
1687 pack.deltaCacheLimit
1700 receive.denyCurrentBranch
1702 receive.denyNonFastForwards
1705 repack.usedeltabaseoffset
1708 sendemail.aliasesfile
1709 sendemail.aliasesfiletype
1713 sendemail.chainreplyto
1715 sendemail.envelopesender
1717 sendemail.signedoffbycc
1718 sendemail.smtpencryption
1720 sendemail.smtpserver
1721 sendemail.smtpserverport
1723 sendemail.suppresscc
1724 sendemail.suppressfrom
1729 status.relativePaths
1730 status.showUntrackedFiles
1732 transfer.unpackLimit
1744 local subcommands
="add rename rm show prune update set-head"
1745 local subcommand
="$(__git_find_subcommand "$subcommands")"
1746 if [ -z "$subcommand" ]; then
1747 __gitcomp
"$subcommands"
1751 case "$subcommand" in
1752 rename|
rm|show|prune
)
1753 __gitcomp
"$(__git_remotes)"
1756 local i c
='' IFS
=$
'\n'
1757 for i
in $
(git
--git-dir="$(__gitdir)" config
--list); do
1775 __git_has_doubledash
&& return
1777 local cur
="${COMP_WORDS[COMP_CWORD]}"
1780 __gitcomp
"--merge --mixed --hard --soft"
1784 __gitcomp
"$(__git_refs)"
1789 local cur
="${COMP_WORDS[COMP_CWORD]}"
1792 __gitcomp
"--edit --mainline --no-edit --no-commit --signoff"
1796 __gitcomp
"$(__git_refs)"
1801 __git_has_doubledash
&& return
1803 local cur
="${COMP_WORDS[COMP_CWORD]}"
1806 __gitcomp
"--cached --dry-run --ignore-unmatch --quiet"
1815 __git_has_doubledash
&& return
1817 local cur
="${COMP_WORDS[COMP_CWORD]}"
1821 $__git_log_common_options
1822 $__git_log_shortlog_options
1823 --numbered --summary
1828 __git_complete_revlist
1833 __git_has_doubledash
&& return
1835 local cur
="${COMP_WORDS[COMP_CWORD]}"
1838 __gitcomp
"$__git_log_pretty_formats
1839 " "" "${cur##--pretty=}"
1843 __gitcomp
"$__git_log_pretty_formats
1844 " "" "${cur##--format=}"
1848 __gitcomp
"--pretty= --format= --abbrev-commit --oneline
1849 $__git_diff_common_options
1859 local cur
="${COMP_WORDS[COMP_CWORD]}"
1863 --all --remotes --topo-order --current --more=
1864 --list --independent --merge-base --no-name
1866 --sha1-name --sparse --topics --reflog
1871 __git_complete_revlist
1876 local subcommands
='save list show apply clear drop pop create branch'
1877 local subcommand
="$(__git_find_subcommand "$subcommands")"
1878 if [ -z "$subcommand" ]; then
1879 __gitcomp
"$subcommands"
1881 local cur
="${COMP_WORDS[COMP_CWORD]}"
1882 case "$subcommand,$cur" in
1884 __gitcomp
"--keep-index"
1889 show
,--*|drop
,--*|branch
,--*)
1892 show
,*|apply
,*|drop
,*|pop
,*|branch
,*)
1893 __gitcomp
"$(git --git-dir="$
(__gitdir
)" stash list \
1894 | sed -n -e 's/:.*//p')"
1905 __git_has_doubledash
&& return
1907 local subcommands
="add status init update summary foreach sync"
1908 if [ -z "$(__git_find_subcommand "$subcommands")" ]; then
1909 local cur
="${COMP_WORDS[COMP_CWORD]}"
1912 __gitcomp
"--quiet --cached"
1915 __gitcomp
"$subcommands"
1925 init fetch clone rebase dcommit log find-rev
1926 set-tree commit-diff info create-ignore propget
1927 proplist show-ignore show-externals branch tag blame
1930 local subcommand
="$(__git_find_subcommand "$subcommands")"
1931 if [ -z "$subcommand" ]; then
1932 __gitcomp
"$subcommands"
1934 local remote_opts
="--username= --config-dir= --no-auth-cache"
1936 --follow-parent --authors-file= --repack=
1937 --no-metadata --use-svm-props --use-svnsync-props
1938 --log-window-size= --no-checkout --quiet
1939 --repack-flags --use-log-author --localtime
1940 --ignore-paths= $remote_opts
1943 --template= --shared= --trunk= --tags=
1944 --branches= --stdlayout --minimize-url
1945 --no-metadata --use-svm-props --use-svnsync-props
1946 --rewrite-root= --prefix= --use-log-author
1947 --add-author-from $remote_opts
1950 --edit --rmdir --find-copies-harder --copy-similarity=
1953 local cur
="${COMP_WORDS[COMP_CWORD]}"
1954 case "$subcommand,$cur" in
1956 __gitcomp
"--revision= --fetch-all $fc_opts"
1959 __gitcomp
"--revision= $fc_opts $init_opts"
1962 __gitcomp
"$init_opts"
1966 --merge --strategy= --verbose --dry-run
1967 --fetch-all --no-rebase --commit-url
1968 --revision $cmt_opts $fc_opts
1972 __gitcomp
"--stdin $cmt_opts $fc_opts"
1974 create-ignore
,--*|propget
,--*|proplist
,--*|show-ignore
,--*|\
1976 __gitcomp
"--revision="
1980 --limit= --revision= --verbose --incremental
1981 --oneline --show-commit --non-recursive
1982 --authors-file= --color
1987 --merge --verbose --strategy= --local
1988 --fetch-all --dry-run $fc_opts
1992 __gitcomp
"--message= --file= --revision= $cmt_opts"
1998 __gitcomp
"--dry-run --message --tag"
2001 __gitcomp
"--dry-run --message"
2004 __gitcomp
"--git-format"
2008 --config-dir= --ignore-paths= --minimize
2009 --no-auth-cache --username=
2022 while [ $c -lt $COMP_CWORD ]; do
2023 i
="${COMP_WORDS[c]}"
2026 __gitcomp
"$(__git_tags)"
2036 case "${COMP_WORDS[COMP_CWORD-1]}" in
2042 __gitcomp
"$(__git_tags)"
2048 __gitcomp
"$(__git_refs)"
2055 local i c
=1 command __git_dir
2057 while [ $c -lt $COMP_CWORD ]; do
2058 i
="${COMP_WORDS[c]}"
2060 --git-dir=*) __git_dir
="${i#--git-dir=}" ;;
2061 --bare) __git_dir
="." ;;
2062 --version|
-p|
--paginate) ;;
2063 --help) command="help"; break ;;
2064 *) command="$i"; break ;;
2069 if [ -z "$command" ]; then
2070 case "${COMP_WORDS[COMP_CWORD]}" in
2083 *) __gitcomp
"$(__git_porcelain_commands) $(__git_aliases)" ;;
2088 local expansion
=$
(__git_aliased_command
"$command")
2089 [ "$expansion" ] && command="$expansion"
2094 apply
) _git_apply
;;
2095 archive
) _git_archive
;;
2096 bisect
) _git_bisect
;;
2097 bundle
) _git_bundle
;;
2098 branch
) _git_branch
;;
2099 checkout
) _git_checkout
;;
2100 cherry
) _git_cherry
;;
2101 cherry-pick
) _git_cherry_pick
;;
2102 clean
) _git_clean
;;
2103 clone
) _git_clone
;;
2104 commit
) _git_commit
;;
2105 config
) _git_config
;;
2106 describe
) _git_describe
;;
2108 difftool
) _git_difftool
;;
2109 fetch
) _git_fetch
;;
2110 format-patch
) _git_format_patch
;;
2117 ls-files
) _git_ls_files
;;
2118 ls-remote
) _git_ls_remote
;;
2119 ls-tree
) _git_ls_tree
;;
2121 mergetool
) _git_mergetool
;;
2122 merge-base
) _git_merge_base
;;
2124 name-rev
) _git_name_rev
;;
2127 rebase
) _git_rebase
;;
2128 remote
) _git_remote
;;
2129 reset) _git_reset
;;
2130 revert
) _git_revert
;;
2132 send-email
) _git_send_email
;;
2133 shortlog
) _git_shortlog
;;
2135 show-branch
) _git_show_branch
;;
2136 stash
) _git_stash
;;
2138 submodule
) _git_submodule
;;
2141 whatchanged
) _git_log
;;
2148 __git_has_doubledash
&& return
2150 local cur
="${COMP_WORDS[COMP_CWORD]}"
2151 local g
="$(__gitdir)"
2153 if [ -f "$g/MERGE_HEAD" ]; then
2159 $__git_log_common_options
2160 $__git_log_gitk_options
2166 __git_complete_revlist
2169 complete
-o bashdefault
-o default
-o nospace
-F _git git
2>/dev
/null \
2170 || complete
-o default
-o nospace
-F _git git
2171 complete
-o bashdefault
-o default
-o nospace
-F _gitk gitk
2>/dev
/null \
2172 || complete
-o default
-o nospace
-F _gitk gitk
2174 # The following are necessary only for Cygwin, and only are needed
2175 # when the user has tab-completed the executable name and consequently
2176 # included the '.exe' suffix.
2178 if [ Cygwin
= "$(uname -o 2>/dev/null)" ]; then
2179 complete
-o bashdefault
-o default
-o nospace
-F _git git.exe
2>/dev
/null \
2180 || complete
-o default
-o nospace
-F _git git.exe