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) Consider changing your PS1 to also show the current branch:
25 # PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
27 # The argument to __git_ps1 will be displayed only if you
28 # are currently in a git repository. The %s token will be
29 # the name of the current branch.
31 # In addition, if you set GIT_PS1_SHOWDIRTYSTATE to a nonempty
32 # value, unstaged (*) and staged (+) changes will be shown next
33 # to the branch name. You can configure this per-repository
34 # with the bash.showDirtyState variable, which defaults to true
35 # once GIT_PS1_SHOWDIRTYSTATE is enabled.
37 # You can also see if currently something is stashed, by setting
38 # GIT_PS1_SHOWSTASHSTATE to a nonempty value. If something is stashed,
39 # then a '$' will be shown next to the branch name.
41 # If you would like to see if there're untracked files, then you can
42 # set GIT_PS1_SHOWUNTRACKEDFILES to a nonempty value. If there're
43 # untracked files, then a '%' will be shown next to the branch name.
47 # *) Read Documentation/SubmittingPatches
48 # *) Send all patches to the current maintainer:
50 # "Shawn O. Pearce" <spearce@spearce.org>
52 # *) Always CC the Git mailing list:
57 case "$COMP_WORDBREAKS" in
59 *) COMP_WORDBREAKS
="$COMP_WORDBREAKS:"
62 # __gitdir accepts 0 or 1 arguments (i.e., location)
63 # returns location of .git repo
66 if [ -z "${1-}" ]; then
67 if [ -n "${__git_dir-}" ]; then
69 elif [ -d .git
]; then
72 git rev-parse
--git-dir 2>/dev
/null
74 elif [ -d "$1/.git" ]; then
81 # __git_ps1 accepts 0 or 1 arguments (i.e., format string)
82 # returns text to add to bash PS1 prompt (includes branch name)
89 if [ -f "$g/rebase-merge/interactive" ]; then
91 b
="$(cat "$g/rebase-merge
/head-name
")"
92 elif [ -d "$g/rebase-merge" ]; then
94 b
="$(cat "$g/rebase-merge
/head-name
")"
96 if [ -d "$g/rebase-apply" ]; then
97 if [ -f "$g/rebase-apply/rebasing" ]; then
99 elif [ -f "$g/rebase-apply/applying" ]; then
104 elif [ -f "$g/MERGE_HEAD" ]; then
106 elif [ -f "$g/BISECT_LOG" ]; then
110 b
="$(git symbolic-ref HEAD 2>/dev/null)" ||
{
113 case "${GIT_PS1_DESCRIBE_STYLE-}" in
115 git describe --contains HEAD ;;
117 git describe --contains --all HEAD ;;
121 git describe --exact-match HEAD ;;
122 esac 2>/dev/null)" ||
124 b
="$(cut -c1-7 "$g/HEAD
" 2>/dev/null)..." ||
136 if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then
137 if [ "true" = "$(git rev-parse --is-bare-repository 2>/dev/null)" ]; then
142 elif [ "true" = "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
143 if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ]; then
144 if [ "$(git config --bool bash.showDirtyState)" != "false" ]; then
145 git
diff --no-ext-diff --quiet --exit-code || w
="*"
146 if git rev-parse
--quiet --verify HEAD
>/dev
/null
; then
147 git diff-index
--cached --quiet HEAD
-- || i
="+"
153 if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ]; then
154 git rev-parse
--verify refs
/stash
>/dev
/null
2>&1 && s
="$"
157 if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ]; then
158 if [ -n "$(git ls-files --others --exclude-standard)" ]; then
165 printf "${1:- (%s)}" "$c${b##refs/heads/}${f:+ $f}$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
--get-regexp 'remote\..*\.url' 2>/dev
/null
); do
316 __git_list_merge_strategies
()
318 git merge
-s help 2>&1 |
319 sed -n -e '/[Aa]vailable strategies are: /,/^$/{
328 __git_merge_strategies
=
329 # 'git merge -s help' (and thus detection of the merge strategy
330 # list) fails, unfortunately, if run outside of any git working
331 # tree. __git_merge_strategies is set to the empty string in
332 # that case, and the detection will be repeated the next time it
334 __git_compute_merge_strategies
()
336 : ${__git_merge_strategies:=$(__git_list_merge_strategies)}
339 __git_complete_file
()
341 local pfx
ls ref cur
="${COMP_WORDS[COMP_CWORD]}"
358 case "$COMP_WORDBREAKS" in
360 *) pfx
="$ref:$pfx" ;;
364 COMPREPLY
=($
(compgen
-P "$pfx" \
365 -W "$(git --git-dir="$
(__gitdir
)" ls-tree "$ls" \
366 | sed '/^100... blob /{
382 __gitcomp
"$(__git_refs)"
387 __git_complete_revlist
()
389 local pfx cur
="${COMP_WORDS[COMP_CWORD]}"
394 __gitcomp
"$(__git_refs)" "$pfx" "$cur"
399 __gitcomp
"$(__git_refs)" "$pfx" "$cur"
402 __gitcomp
"$(__git_refs)"
407 __git_complete_remote_or_refspec
()
409 local cmd
="${COMP_WORDS[1]}"
410 local cur
="${COMP_WORDS[COMP_CWORD]}"
411 local i c
=2 remote
="" pfx
="" lhs
=1 no_complete_refspec
=0
412 while [ $c -lt $COMP_CWORD ]; do
415 --mirror) [ "$cmd" = "push" ] && no_complete_refspec
=1 ;;
418 push
) no_complete_refspec
=1 ;;
427 *) remote
="$i"; break ;;
431 if [ -z "$remote" ]; then
432 __gitcomp
"$(__git_remotes)"
435 if [ $no_complete_refspec = 1 ]; then
439 [ "$remote" = "." ] && remote
=
442 case "$COMP_WORDBREAKS" in
444 *) pfx
="${cur%%:*}:" ;;
456 if [ $lhs = 1 ]; then
457 __gitcomp
"$(__git_refs2 "$remote")" "$pfx" "$cur"
459 __gitcomp
"$(__git_refs)" "$pfx" "$cur"
463 if [ $lhs = 1 ]; then
464 __gitcomp
"$(__git_refs "$remote")" "$pfx" "$cur"
466 __gitcomp
"$(__git_refs)" "$pfx" "$cur"
470 if [ $lhs = 1 ]; then
471 __gitcomp
"$(__git_refs)" "$pfx" "$cur"
473 __gitcomp
"$(__git_refs "$remote")" "$pfx" "$cur"
479 __git_complete_strategy
()
481 __git_compute_merge_strategies
482 case "${COMP_WORDS[COMP_CWORD-1]}" in
484 __gitcomp
"$__git_merge_strategies"
487 local cur
="${COMP_WORDS[COMP_CWORD]}"
490 __gitcomp
"$__git_merge_strategies" "" "${cur##--strategy=}"
497 __git_list_all_commands
()
500 for i
in $
(git
help -a|
egrep '^ [a-zA-Z0-9]')
503 *--*) : helper pattern
;;
510 __git_compute_all_commands
()
512 : ${__git_all_commands:=$(__git_list_all_commands)}
515 __git_list_porcelain_commands
()
518 __git_compute_all_commands
519 for i
in "help" $__git_all_commands
522 *--*) : helper pattern
;;
523 applymbox
) : ask gittus
;;
524 applypatch
) : ask gittus
;;
525 archimport
) : import
;;
526 cat-file
) : plumbing
;;
527 check-attr
) : plumbing
;;
528 check-ref-format
) : plumbing
;;
529 checkout-index
) : plumbing
;;
530 commit-tree
) : plumbing
;;
531 count-objects
) : infrequent
;;
532 cvsexportcommit
) : export;;
533 cvsimport
) : import
;;
534 cvsserver
) : daemon
;;
536 diff-files
) : plumbing
;;
537 diff-index
) : plumbing
;;
538 diff-tree
) : plumbing
;;
539 fast-import
) : import
;;
540 fast-export
) : export;;
541 fsck-objects
) : plumbing
;;
542 fetch-pack
) : plumbing
;;
543 fmt-merge-msg
) : plumbing
;;
544 for-each-ref
) : plumbing
;;
545 hash-object
) : plumbing
;;
546 http-
*) : transport
;;
547 index-pack
) : plumbing
;;
548 init-db
) : deprecated
;;
549 local-fetch
) : plumbing
;;
550 lost-found
) : infrequent
;;
551 ls-files
) : plumbing
;;
552 ls-remote
) : plumbing
;;
553 ls-tree
) : plumbing
;;
554 mailinfo
) : plumbing
;;
555 mailsplit
) : plumbing
;;
556 merge-
*) : plumbing
;;
559 pack-objects
) : plumbing
;;
560 pack-redundant
) : plumbing
;;
561 pack-refs
) : plumbing
;;
562 parse-remote
) : plumbing
;;
563 patch-id
) : plumbing
;;
564 peek-remote
) : plumbing
;;
566 prune-packed
) : plumbing
;;
567 quiltimport
) : import
;;
568 read-tree
) : plumbing
;;
569 receive-pack
) : plumbing
;;
571 remote-
*) : transport
;;
572 repo-config
) : deprecated
;;
574 rev-list
) : plumbing
;;
575 rev-parse
) : plumbing
;;
576 runstatus
) : plumbing
;;
577 sh-setup
) : internal
;;
579 show-ref
) : plumbing
;;
580 send-pack
) : plumbing
;;
581 show-index
) : plumbing
;;
583 stripspace
) : plumbing
;;
584 symbolic-ref
) : plumbing
;;
585 tar-tree
) : deprecated
;;
586 unpack-file
) : plumbing
;;
587 unpack-objects
) : plumbing
;;
588 update-index
) : plumbing
;;
589 update-ref
) : plumbing
;;
590 update-server-info
) : daemon
;;
591 upload-archive
) : plumbing
;;
592 upload-pack
) : plumbing
;;
593 write-tree
) : plumbing
;;
595 verify-pack
) : infrequent
;;
596 verify-tag
) : plumbing
;;
602 __git_porcelain_commands
=
603 __git_compute_porcelain_commands
()
605 __git_compute_all_commands
606 : ${__git_porcelain_commands:=$(__git_list_porcelain_commands)}
612 for i
in $
(git
--git-dir="$(__gitdir)" config
--get-regexp "alias\..*" 2>/dev
/null
); do
622 # __git_aliased_command requires 1 argument
623 __git_aliased_command
()
625 local word cmdline
=$
(git
--git-dir="$(__gitdir)" \
626 config
--get "alias.$1")
627 for word
in $cmdline; do
628 if [ "${word##-*}" ]; then
635 # __git_find_on_cmdline requires 1 argument
636 __git_find_on_cmdline
()
638 local word subcommand c
=1
640 while [ $c -lt $COMP_CWORD ]; do
641 word
="${COMP_WORDS[c]}"
642 for subcommand
in $1; do
643 if [ "$subcommand" = "$word" ]; then
652 __git_has_doubledash
()
655 while [ $c -lt $COMP_CWORD ]; do
656 if [ "--" = "${COMP_WORDS[c]}" ]; then
664 __git_whitespacelist
="nowarn warn error error-all fix"
668 local cur
="${COMP_WORDS[COMP_CWORD]}" dir
="$(__gitdir)"
669 if [ -d "$dir"/rebase-apply
]; then
670 __gitcomp
"--skip --resolved --abort"
675 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
680 --3way --committer-date-is-author-date --ignore-date
681 --ignore-whitespace --ignore-space-change
682 --interactive --keep --no-utf8 --signoff --utf8
683 --whitespace= --scissors
692 local cur
="${COMP_WORDS[COMP_CWORD]}"
695 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
700 --stat --numstat --summary --check --index
701 --cached --index-info --reverse --reject --unidiff-zero
702 --apply --no-add --exclude=
703 --ignore-whitespace --ignore-space-change
704 --whitespace= --inaccurate-eof --verbose
713 __git_has_doubledash
&& return
715 local cur
="${COMP_WORDS[COMP_CWORD]}"
719 --interactive --refresh --patch --update --dry-run
720 --ignore-errors --intent-to-add
729 local cur
="${COMP_WORDS[COMP_CWORD]}"
732 __gitcomp
"$(git archive --list)" "" "${cur##--format=}"
736 __gitcomp
"$(__git_remotes)" "" "${cur##--remote=}"
741 --format= --list --verbose
742 --prefix= --remote= --exec=
752 __git_has_doubledash
&& return
754 local subcommands
="start bad good skip reset visualize replay log run"
755 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
756 if [ -z "$subcommand" ]; then
757 __gitcomp
"$subcommands"
761 case "$subcommand" in
763 __gitcomp
"$(__git_refs)"
773 local i c
=1 only_local_ref
="n" has_r
="n"
775 while [ $c -lt $COMP_CWORD ]; do
778 -d|
-m) only_local_ref
="y" ;;
784 case "${COMP_WORDS[COMP_CWORD]}" in
787 --color --no-color --verbose --abbrev= --no-abbrev
788 --track --no-track --contains --merged --no-merged
792 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
793 __gitcomp
"$(__git_heads)"
795 __gitcomp
"$(__git_refs)"
803 local cmd
="${COMP_WORDS[2]}"
804 case "$COMP_CWORD" in
806 __gitcomp
"create list-heads verify unbundle"
814 __git_complete_revlist
823 __git_has_doubledash
&& return
825 local cur
="${COMP_WORDS[COMP_CWORD]}"
828 __gitcomp
"diff3 merge" "" "${cur##--conflict=}"
832 --quiet --ours --theirs --track --no-track --merge
837 __gitcomp
"$(__git_refs)"
844 __gitcomp
"$(__git_refs)"
849 local cur
="${COMP_WORDS[COMP_CWORD]}"
852 __gitcomp
"--edit --no-commit"
855 __gitcomp
"$(__git_refs)"
862 __git_has_doubledash
&& return
864 local cur
="${COMP_WORDS[COMP_CWORD]}"
867 __gitcomp
"--dry-run --quiet"
876 local cur
="${COMP_WORDS[COMP_CWORD]}"
901 __git_has_doubledash
&& return
903 local cur
="${COMP_WORDS[COMP_CWORD]}"
906 __gitcomp
"default strip verbatim whitespace
907 " "" "${cur##--cleanup=}"
911 __gitcomp
"$(__git_refs)" "" "${cur##--reuse-message=}"
915 __gitcomp
"$(__git_refs)" "" "${cur##--reedit-message=}"
919 __gitcomp
"all no normal" "" "${cur##--untracked-files=}"
924 --all --author= --signoff --verify --no-verify
925 --edit --amend --include --only --interactive
926 --dry-run --reuse-message= --reedit-message=
927 --reset-author --file= --message= --template=
928 --cleanup= --untracked-files --untracked-files=
938 local cur
="${COMP_WORDS[COMP_CWORD]}"
942 --all --tags --contains --abbrev= --candidates=
943 --exact-match --debug --long --match --always
947 __gitcomp
"$(__git_refs)"
950 __git_diff_common_options
="--stat --numstat --shortstat --summary
951 --patch-with-stat --name-only --name-status --color
952 --no-color --color-words --no-renames --check
953 --full-index --binary --abbrev --diff-filter=
955 --text --ignore-space-at-eol --ignore-space-change
956 --ignore-all-space --exit-code --quiet --ext-diff
958 --no-prefix --src-prefix= --dst-prefix=
959 --inter-hunk-context=
962 --dirstat --dirstat= --dirstat-by-file
963 --dirstat-by-file= --cumulative
968 __git_has_doubledash
&& return
970 local cur
="${COMP_WORDS[COMP_CWORD]}"
973 __gitcomp
"--cached --staged --pickaxe-all --pickaxe-regex
974 --base --ours --theirs
975 $__git_diff_common_options
983 __git_mergetools_common
="diffuse ecmerge emerge kdiff3 meld opendiff
984 tkdiff vimdiff gvimdiff xxdiff araxis p4merge
989 __git_has_doubledash
&& return
991 local cur
="${COMP_WORDS[COMP_CWORD]}"
994 __gitcomp
"$__git_mergetools_common kompare" "" "${cur##--tool=}"
998 __gitcomp
"--cached --staged --pickaxe-all --pickaxe-regex
999 --base --ours --theirs
1000 --no-renames --diff-filter= --find-copies-harder
1001 --relative --ignore-submodules
1009 __git_fetch_options
="
1010 --quiet --verbose --append --upload-pack --force --keep --depth=
1011 --tags --no-tags --all --prune --dry-run
1016 local cur
="${COMP_WORDS[COMP_CWORD]}"
1019 __gitcomp
"$__git_fetch_options"
1023 __git_complete_remote_or_refspec
1026 _git_format_patch
()
1028 local cur
="${COMP_WORDS[COMP_CWORD]}"
1033 " "" "${cur##--thread=}"
1038 --stdout --attach --no-attach --thread --thread=
1040 --numbered --start-number
1044 --in-reply-to= --cc=
1045 --full-index --binary
1048 --no-prefix --src-prefix= --dst-prefix=
1049 --inline --suffix= --ignore-if-in-upstream
1055 __git_complete_revlist
1060 local cur
="${COMP_WORDS[COMP_CWORD]}"
1064 --tags --root --unreachable --cache --no-reflogs --full
1065 --strict --verbose --lost-found
1075 local cur
="${COMP_WORDS[COMP_CWORD]}"
1078 __gitcomp
"--prune --aggressive"
1087 __git_has_doubledash
&& return
1089 local cur
="${COMP_WORDS[COMP_CWORD]}"
1094 --text --ignore-case --word-regexp --invert-match
1096 --extended-regexp --basic-regexp --fixed-strings
1097 --files-with-matches --name-only
1098 --files-without-match
1101 --and --or --not --all-match
1107 __gitcomp
"$(__git_refs)"
1112 local cur
="${COMP_WORDS[COMP_CWORD]}"
1115 __gitcomp
"--all --info --man --web"
1119 __git_compute_all_commands
1120 __gitcomp
"$__git_all_commands
1121 attributes cli core-tutorial cvs-migration
1122 diffcore gitk glossary hooks ignore modules
1123 repository-layout tutorial tutorial-2
1130 local cur
="${COMP_WORDS[COMP_CWORD]}"
1134 false true umask group all world everybody
1135 " "" "${cur##--shared=}"
1139 __gitcomp
"--quiet --bare --template= --shared --shared="
1148 __git_has_doubledash
&& return
1150 local cur
="${COMP_WORDS[COMP_CWORD]}"
1153 __gitcomp
"--cached --deleted --modified --others --ignored
1154 --stage --directory --no-empty-directory --unmerged
1155 --killed --exclude= --exclude-from=
1156 --exclude-per-directory= --exclude-standard
1157 --error-unmatch --with-tree= --full-name
1158 --abbrev --ignored --exclude-per-directory
1168 __gitcomp
"$(__git_remotes)"
1176 # Options that go well for log, shortlog and gitk
1177 __git_log_common_options
="
1179 --branches --tags --remotes
1180 --first-parent --merges --no-merges
1182 --max-age= --since= --after=
1183 --min-age= --until= --before=
1185 # Options that go well for log and gitk (not shortlog)
1186 __git_log_gitk_options
="
1187 --dense --sparse --full-history
1188 --simplify-merges --simplify-by-decoration
1191 # Options that go well for log and shortlog (not gitk)
1192 __git_log_shortlog_options
="
1193 --author= --committer= --grep=
1197 __git_log_pretty_formats
="oneline short medium full fuller email raw format:"
1198 __git_log_date_formats
="relative iso8601 rfc2822 short local default raw"
1202 __git_has_doubledash
&& return
1204 local cur
="${COMP_WORDS[COMP_CWORD]}"
1205 local g
="$(git rev-parse --git-dir 2>/dev/null)"
1207 if [ -f "$g/MERGE_HEAD" ]; then
1212 __gitcomp
"$__git_log_pretty_formats
1213 " "" "${cur##--pretty=}"
1217 __gitcomp
"$__git_log_pretty_formats
1218 " "" "${cur##--format=}"
1222 __gitcomp
"$__git_log_date_formats" "" "${cur##--date=}"
1226 __gitcomp
"long short" "" "${cur##--decorate=}"
1231 $__git_log_common_options
1232 $__git_log_shortlog_options
1233 $__git_log_gitk_options
1234 --root --topo-order --date-order --reverse
1235 --follow --full-diff
1236 --abbrev-commit --abbrev=
1237 --relative-date --date=
1238 --pretty= --format= --oneline
1241 --decorate --decorate=
1243 --parents --children
1245 $__git_diff_common_options
1246 --pickaxe-all --pickaxe-regex
1251 __git_complete_revlist
1254 __git_merge_options
="
1255 --no-commit --no-stat --log --no-log --squash --strategy
1256 --commit --stat --no-squash --ff --no-ff --ff-only
1261 __git_complete_strategy
&& return
1263 local cur
="${COMP_WORDS[COMP_CWORD]}"
1266 __gitcomp
"$__git_merge_options"
1269 __gitcomp
"$(__git_refs)"
1274 local cur
="${COMP_WORDS[COMP_CWORD]}"
1277 __gitcomp
"$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"
1290 __gitcomp
"$(__git_refs)"
1295 local cur
="${COMP_WORDS[COMP_CWORD]}"
1298 __gitcomp
"--dry-run"
1307 __gitcomp
"--tags --all --stdin"
1312 local subcommands
="edit show"
1313 if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then
1314 __gitcomp
"$subcommands"
1318 case "${COMP_WORDS[COMP_CWORD-1]}" in
1323 __gitcomp
"$(__git_refs)"
1330 __git_complete_strategy
&& return
1332 local cur
="${COMP_WORDS[COMP_CWORD]}"
1336 --rebase --no-rebase
1337 $__git_merge_options
1338 $__git_fetch_options
1343 __git_complete_remote_or_refspec
1348 local cur
="${COMP_WORDS[COMP_CWORD]}"
1349 case "${COMP_WORDS[COMP_CWORD-1]}" in
1351 __gitcomp
"$(__git_remotes)"
1356 __gitcomp
"$(__git_remotes)" "" "${cur##--repo=}"
1361 --all --mirror --tags --dry-run --force --verbose
1362 --receive-pack= --repo=
1367 __git_complete_remote_or_refspec
1372 local cur
="${COMP_WORDS[COMP_CWORD]}" dir
="$(__gitdir)"
1373 if [ -d "$dir"/rebase-apply
] ||
[ -d "$dir"/rebase-merge
]; then
1374 __gitcomp
"--continue --skip --abort"
1377 __git_complete_strategy
&& return
1380 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
1385 --onto --merge --strategy --interactive
1386 --preserve-merges --stat --no-stat
1387 --committer-date-is-author-date --ignore-date
1388 --ignore-whitespace --whitespace=
1393 __gitcomp
"$(__git_refs)"
1396 __git_send_email_confirm_options
="always never auto cc compose"
1397 __git_send_email_suppresscc_options
="author self cc bodycc sob cccmd body all"
1401 local cur
="${COMP_WORDS[COMP_CWORD]}"
1405 $__git_send_email_confirm_options
1406 " "" "${cur##--confirm=}"
1411 $__git_send_email_suppresscc_options
1412 " "" "${cur##--suppress-cc=}"
1416 --smtp-encryption=*)
1417 __gitcomp
"ssl tls" "" "${cur##--smtp-encryption=}"
1421 __gitcomp
"--annotate --bcc --cc --cc-cmd --chain-reply-to
1422 --compose --confirm= --dry-run --envelope-sender
1424 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
1425 --no-suppress-from --no-thread --quiet
1426 --signed-off-by-cc --smtp-pass --smtp-server
1427 --smtp-server-port --smtp-encryption= --smtp-user
1428 --subject --suppress-cc= --suppress-from --thread --to
1429 --validate --no-validate"
1436 __git_config_get_set_variables
()
1438 local prevword word config_file
= c
=$COMP_CWORD
1439 while [ $c -gt 1 ]; do
1440 word
="${COMP_WORDS[c]}"
1442 --global|
--system|
--file=*)
1447 config_file
="$word $prevword"
1455 git
--git-dir="$(__gitdir)" config
$config_file --list 2>/dev
/null |
1468 local cur
="${COMP_WORDS[COMP_CWORD]}"
1469 local prv
="${COMP_WORDS[COMP_CWORD-1]}"
1472 __gitcomp
"$(__git_remotes)"
1476 __gitcomp
"$(__git_refs)"
1480 local remote
="${prv#remote.}"
1481 remote
="${remote%.fetch}"
1482 __gitcomp
"$(__git_refs_remotes "$remote")"
1486 local remote
="${prv#remote.}"
1487 remote
="${remote%.push}"
1488 __gitcomp
"$(git --git-dir="$
(__gitdir
)" \
1489 for-each-ref --format='%(refname):%(refname)' \
1493 pull.twohead|pull.octopus
)
1494 __git_compute_merge_strategies
1495 __gitcomp
"$__git_merge_strategies"
1498 color.branch|color.
diff|color.interactive|\
1499 color.showbranch|color.status|color.ui
)
1500 __gitcomp
"always never auto"
1504 __gitcomp
"false true"
1509 normal black red green yellow blue magenta cyan white
1510 bold dim ul blink reverse
1515 __gitcomp
"man info web html"
1519 __gitcomp
"$__git_log_date_formats"
1522 sendemail.aliasesfiletype
)
1523 __gitcomp
"mutt mailrc pine elm gnus"
1527 __gitcomp
"$__git_send_email_confirm_options"
1530 sendemail.suppresscc
)
1531 __gitcomp
"$__git_send_email_suppresscc_options"
1534 --get|
--get-all|
--unset|
--unset-all)
1535 __gitcomp
"$(__git_config_get_set_variables)"
1546 --global --system --file=
1547 --list --replace-all
1548 --get --get-all --get-regexp
1549 --add --unset --unset-all
1550 --remove-section --rename-section
1555 local pfx
="${cur%.*}."
1557 __gitcomp
"remote merge mergeoptions rebase" "$pfx" "$cur"
1561 local pfx
="${cur%.*}."
1563 __gitcomp
"$(__git_heads)" "$pfx" "$cur" "."
1567 local pfx
="${cur%.*}."
1570 argprompt cmd confirm needsfile noconsole norescan
1571 prompt revprompt revunmerged title
1576 local pfx
="${cur%.*}."
1578 __gitcomp
"cmd path" "$pfx" "$cur"
1582 local pfx
="${cur%.*}."
1584 __gitcomp
"cmd path" "$pfx" "$cur"
1588 local pfx
="${cur%.*}."
1590 __gitcomp
"cmd path trustExitCode" "$pfx" "$cur"
1594 local pfx
="${cur%.*}."
1596 __git_compute_all_commands
1597 __gitcomp
"$__git_all_commands" "$pfx" "$cur"
1601 local pfx
="${cur%.*}."
1604 url proxy fetch push mirror skipDefaultUpdate
1605 receivepack uploadpack tagopt pushurl
1610 local pfx
="${cur%.*}."
1612 __gitcomp
"$(__git_remotes)" "$pfx" "$cur" "."
1616 local pfx
="${cur%.*}."
1618 __gitcomp
"insteadOf pushInsteadOf" "$pfx" "$cur"
1625 apply.ignorewhitespace
1627 branch.autosetupmerge
1628 branch.autosetuprebase
1631 color.branch.current
1642 color.diff.whitespace
1647 color.interactive.header
1648 color.interactive.help
1649 color.interactive.prompt
1654 color.status.changed
1656 color.status.nobranch
1657 color.status.untracked
1658 color.status.updated
1665 core.deltaBaseCacheLimit
1669 core.fsyncobjectfiles
1671 core.ignoreCygwinFSTricks
1673 core.logAllRefUpdates
1674 core.loosecompression
1676 core.packedGitWindowSize
1678 core.preferSymlinkRefs
1681 core.repositoryFormatVersion
1683 core.sharedRepository
1686 core.warnAmbiguousRefs
1689 diff.autorefreshindex
1695 diff.suppressBlankEmpty
1707 format.subjectprefix
1716 gc.reflogexpireunreachable
1720 gitcvs.commitmsgannotation
1721 gitcvs.dbTableNamePrefix
1732 gui.copyblamethreshold
1736 gui.matchtrackingbranch
1737 gui.newbranchtemplate
1738 gui.pruneduringfetch
1739 gui.spellingdictionary
1755 i18n.logOutputEncoding
1760 imap.preformattedHTML
1769 interactive.singlekey
1782 mergetool.keepBackup
1785 pack.deltaCacheLimit
1798 receive.denyCurrentBranch
1800 receive.denyNonFastForwards
1803 repack.usedeltabaseoffset
1806 sendemail.aliasesfile
1807 sendemail.aliasesfiletype
1811 sendemail.chainreplyto
1813 sendemail.envelopesender
1815 sendemail.signedoffbycc
1816 sendemail.smtpencryption
1818 sendemail.smtpserver
1819 sendemail.smtpserverport
1821 sendemail.suppresscc
1822 sendemail.suppressfrom
1827 status.relativePaths
1828 status.showUntrackedFiles
1830 transfer.unpackLimit
1842 local subcommands
="add rename rm show prune update set-head"
1843 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
1844 if [ -z "$subcommand" ]; then
1845 __gitcomp
"$subcommands"
1849 case "$subcommand" in
1850 rename|
rm|show|prune
)
1851 __gitcomp
"$(__git_remotes)"
1854 local i c
='' IFS
=$
'\n'
1855 for i
in $
(git
--git-dir="$(__gitdir)" config
--get-regexp "remotes\..*" 2>/dev
/null
); do
1869 __gitcomp
"$(__git_refs)"
1874 __git_has_doubledash
&& return
1876 local cur
="${COMP_WORDS[COMP_CWORD]}"
1879 __gitcomp
"--merge --mixed --hard --soft --patch"
1883 __gitcomp
"$(__git_refs)"
1888 local cur
="${COMP_WORDS[COMP_CWORD]}"
1891 __gitcomp
"--edit --mainline --no-edit --no-commit --signoff"
1895 __gitcomp
"$(__git_refs)"
1900 __git_has_doubledash
&& return
1902 local cur
="${COMP_WORDS[COMP_CWORD]}"
1905 __gitcomp
"--cached --dry-run --ignore-unmatch --quiet"
1914 __git_has_doubledash
&& return
1916 local cur
="${COMP_WORDS[COMP_CWORD]}"
1920 $__git_log_common_options
1921 $__git_log_shortlog_options
1922 --numbered --summary
1927 __git_complete_revlist
1932 __git_has_doubledash
&& return
1934 local cur
="${COMP_WORDS[COMP_CWORD]}"
1937 __gitcomp
"$__git_log_pretty_formats
1938 " "" "${cur##--pretty=}"
1942 __gitcomp
"$__git_log_pretty_formats
1943 " "" "${cur##--format=}"
1947 __gitcomp
"--pretty= --format= --abbrev-commit --oneline
1948 $__git_diff_common_options
1958 local cur
="${COMP_WORDS[COMP_CWORD]}"
1962 --all --remotes --topo-order --current --more=
1963 --list --independent --merge-base --no-name
1965 --sha1-name --sparse --topics --reflog
1970 __git_complete_revlist
1975 local cur
="${COMP_WORDS[COMP_CWORD]}"
1976 local save_opts
='--keep-index --no-keep-index --quiet --patch'
1977 local subcommands
='save list show apply clear drop pop create branch'
1978 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
1979 if [ -z "$subcommand" ]; then
1982 __gitcomp
"$save_opts"
1985 if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then
1986 __gitcomp
"$subcommands"
1993 case "$subcommand,$cur" in
1995 __gitcomp
"$save_opts"
1998 __gitcomp
"--index --quiet"
2000 show
,--*|drop
,--*|branch
,--*)
2003 show
,*|apply
,*|drop
,*|pop
,*|branch
,*)
2004 __gitcomp
"$(git --git-dir="$
(__gitdir
)" stash list \
2005 | sed -n -e 's/:.*//p')"
2016 __git_has_doubledash
&& return
2018 local subcommands
="add status init update summary foreach sync"
2019 if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then
2020 local cur
="${COMP_WORDS[COMP_CWORD]}"
2023 __gitcomp
"--quiet --cached"
2026 __gitcomp
"$subcommands"
2036 init fetch clone rebase dcommit log find-rev
2037 set-tree commit-diff info create-ignore propget
2038 proplist show-ignore show-externals branch tag blame
2039 migrate mkdirs reset gc
2041 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
2042 if [ -z "$subcommand" ]; then
2043 __gitcomp
"$subcommands"
2045 local remote_opts
="--username= --config-dir= --no-auth-cache"
2047 --follow-parent --authors-file= --repack=
2048 --no-metadata --use-svm-props --use-svnsync-props
2049 --log-window-size= --no-checkout --quiet
2050 --repack-flags --use-log-author --localtime
2051 --ignore-paths= $remote_opts
2054 --template= --shared= --trunk= --tags=
2055 --branches= --stdlayout --minimize-url
2056 --no-metadata --use-svm-props --use-svnsync-props
2057 --rewrite-root= --prefix= --use-log-author
2058 --add-author-from $remote_opts
2061 --edit --rmdir --find-copies-harder --copy-similarity=
2064 local cur
="${COMP_WORDS[COMP_CWORD]}"
2065 case "$subcommand,$cur" in
2067 __gitcomp
"--revision= --fetch-all $fc_opts"
2070 __gitcomp
"--revision= $fc_opts $init_opts"
2073 __gitcomp
"$init_opts"
2077 --merge --strategy= --verbose --dry-run
2078 --fetch-all --no-rebase --commit-url
2079 --revision $cmt_opts $fc_opts
2083 __gitcomp
"--stdin $cmt_opts $fc_opts"
2085 create-ignore
,--*|propget
,--*|proplist
,--*|show-ignore
,--*|\
2086 show-externals
,--*|mkdirs
,--*)
2087 __gitcomp
"--revision="
2091 --limit= --revision= --verbose --incremental
2092 --oneline --show-commit --non-recursive
2093 --authors-file= --color
2098 --merge --verbose --strategy= --local
2099 --fetch-all --dry-run $fc_opts
2103 __gitcomp
"--message= --file= --revision= $cmt_opts"
2109 __gitcomp
"--dry-run --message --tag"
2112 __gitcomp
"--dry-run --message"
2115 __gitcomp
"--git-format"
2119 --config-dir= --ignore-paths= --minimize
2120 --no-auth-cache --username=
2124 __gitcomp
"--revision= --parent"
2136 while [ $c -lt $COMP_CWORD ]; do
2137 i
="${COMP_WORDS[c]}"
2140 __gitcomp
"$(__git_tags)"
2150 case "${COMP_WORDS[COMP_CWORD-1]}" in
2156 __gitcomp
"$(__git_tags)"
2162 __gitcomp
"$(__git_refs)"
2169 local i c
=1 command __git_dir
2171 while [ $c -lt $COMP_CWORD ]; do
2172 i
="${COMP_WORDS[c]}"
2174 --git-dir=*) __git_dir
="${i#--git-dir=}" ;;
2175 --bare) __git_dir
="." ;;
2176 --version|
-p|
--paginate) ;;
2177 --help) command="help"; break ;;
2178 *) command="$i"; break ;;
2183 if [ -z "$command" ]; then
2184 case "${COMP_WORDS[COMP_CWORD]}" in
2197 *) __git_compute_porcelain_commands
2198 __gitcomp
"$__git_porcelain_commands $(__git_aliases)" ;;
2203 local expansion
=$
(__git_aliased_command
"$command")
2204 [ "$expansion" ] && command="$expansion"
2209 apply
) _git_apply
;;
2210 archive
) _git_archive
;;
2211 bisect
) _git_bisect
;;
2212 bundle
) _git_bundle
;;
2213 branch
) _git_branch
;;
2214 checkout
) _git_checkout
;;
2215 cherry
) _git_cherry
;;
2216 cherry-pick
) _git_cherry_pick
;;
2217 clean
) _git_clean
;;
2218 clone
) _git_clone
;;
2219 commit
) _git_commit
;;
2220 config
) _git_config
;;
2221 describe
) _git_describe
;;
2223 difftool
) _git_difftool
;;
2224 fetch
) _git_fetch
;;
2225 format-patch
) _git_format_patch
;;
2232 ls-files
) _git_ls_files
;;
2233 ls-remote
) _git_ls_remote
;;
2234 ls-tree
) _git_ls_tree
;;
2236 mergetool
) _git_mergetool
;;
2237 merge-base
) _git_merge_base
;;
2239 name-rev
) _git_name_rev
;;
2240 notes
) _git_notes
;;
2243 rebase
) _git_rebase
;;
2244 remote
) _git_remote
;;
2245 replace
) _git_replace
;;
2246 reset) _git_reset
;;
2247 revert
) _git_revert
;;
2249 send-email
) _git_send_email
;;
2250 shortlog
) _git_shortlog
;;
2252 show-branch
) _git_show_branch
;;
2253 stash
) _git_stash
;;
2255 submodule
) _git_submodule
;;
2258 whatchanged
) _git_log
;;
2265 __git_has_doubledash
&& return
2267 local cur
="${COMP_WORDS[COMP_CWORD]}"
2268 local g
="$(__gitdir)"
2270 if [ -f "$g/MERGE_HEAD" ]; then
2276 $__git_log_common_options
2277 $__git_log_gitk_options
2283 __git_complete_revlist
2286 complete
-o bashdefault
-o default
-o nospace
-F _git git
2>/dev
/null \
2287 || complete
-o default
-o nospace
-F _git git
2288 complete
-o bashdefault
-o default
-o nospace
-F _gitk gitk
2>/dev
/null \
2289 || complete
-o default
-o nospace
-F _gitk gitk
2291 # The following are necessary only for Cygwin, and only are needed
2292 # when the user has tab-completed the executable name and consequently
2293 # included the '.exe' suffix.
2295 if [ Cygwin
= "$(uname -o 2>/dev/null)" ]; then
2296 complete
-o bashdefault
-o default
-o nospace
-F _git git.exe
2>/dev
/null \
2297 || complete
-o default
-o nospace
-F _git git.exe