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 --ignore-submodules \
146 --quiet --exit-code || w
="*"
147 if git rev-parse
--quiet --verify HEAD
>/dev
/null
; then
148 git diff-index
--cached --quiet \
149 --ignore-submodules HEAD
-- || i
="+"
155 if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ]; then
156 git rev-parse
--verify refs
/stash
>/dev
/null
2>&1 && s
="$"
159 if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ]; then
160 if [ -n "$(git ls-files --others --exclude-standard)" ]; then
166 if [ -n "${1-}" ]; then
167 printf "$1" "$c${b##refs/heads/}$w$i$s$u$r"
169 printf " (%s)" "$c${b##refs/heads/}$w$i$s$u$r"
174 # __gitcomp_1 requires 2 arguments
177 local c IFS
=' '$
'\t'$
'\n'
180 --*=*) printf %s$
'\n' "$c$2" ;;
181 *.
) printf %s$
'\n' "$c$2" ;;
182 *) printf %s$
'\n' "$c$2 " ;;
187 # __gitcomp accepts 1, 2, 3, or 4 arguments
188 # generates completion reply with compgen
191 local cur
="${COMP_WORDS[COMP_CWORD]}"
192 if [ $# -gt 2 ]; then
201 COMPREPLY
=($
(compgen
-P "${2-}" \
202 -W "$(__gitcomp_1 "${1-}" "${4-}")" \
208 # __git_heads accepts 0 or 1 arguments (to pass to __gitdir)
211 local cmd i is_hash
=y dir
="$(__gitdir "${1-}")"
212 if [ -d "$dir" ]; then
213 git
--git-dir="$dir" for-each-ref
--format='%(refname:short)' \
217 for i
in $
(git ls-remote
"${1-}" 2>/dev
/null
); do
218 case "$is_hash,$i" in
221 n
,refs
/heads
/*) is_hash
=y
; echo "${i#refs/heads/}" ;;
222 n
,*) is_hash
=y
; echo "$i" ;;
227 # __git_tags accepts 0 or 1 arguments (to pass to __gitdir)
230 local cmd i is_hash
=y dir
="$(__gitdir "${1-}")"
231 if [ -d "$dir" ]; then
232 git
--git-dir="$dir" for-each-ref
--format='%(refname:short)' \
236 for i
in $
(git ls-remote
"${1-}" 2>/dev
/null
); do
237 case "$is_hash,$i" in
240 n
,refs
/tags
/*) is_hash
=y
; echo "${i#refs/tags/}" ;;
241 n
,*) is_hash
=y
; echo "$i" ;;
246 # __git_refs accepts 0 or 1 arguments (to pass to __gitdir)
249 local i is_hash
=y dir
="$(__gitdir "${1-}")"
250 local cur
="${COMP_WORDS[COMP_CWORD]}" format refs
251 if [ -d "$dir" ]; then
258 if [ -e "$dir/HEAD" ]; then echo HEAD
; fi
259 format
="refname:short"
260 refs
="refs/tags refs/heads refs/remotes"
263 git
--git-dir="$dir" for-each-ref
--format="%($format)" \
267 for i
in $
(git ls-remote
"$dir" 2>/dev
/null
); do
268 case "$is_hash,$i" in
271 n
,refs
/tags
/*) is_hash
=y
; echo "${i#refs/tags/}" ;;
272 n
,refs
/heads
/*) is_hash
=y
; echo "${i#refs/heads/}" ;;
273 n
,refs
/remotes
/*) is_hash
=y
; echo "${i#refs/remotes/}" ;;
274 n
,*) is_hash
=y
; echo "$i" ;;
279 # __git_refs2 requires 1 argument (to pass to __git_refs)
283 for i
in $
(__git_refs
"$1"); do
288 # __git_refs_remotes requires 1 argument (to pass to ls-remote)
289 __git_refs_remotes
()
291 local cmd i is_hash
=y
292 for i
in $
(git ls-remote
"$1" 2>/dev
/null
); do
293 case "$is_hash,$i" in
296 echo "$i:refs/remotes/$1/${i#refs/heads/}"
300 n
,refs
/tags
/*) is_hash
=y
;;
308 local i ngoff IFS
=$
'\n' d
="$(__gitdir)"
309 shopt -q nullglob || ngoff
=1
311 for i
in "$d/remotes"/*; do
312 echo ${i#$d/remotes/}
314 [ "$ngoff" ] && shopt -u nullglob
315 for i
in $
(git
--git-dir="$d" config
--get-regexp 'remote\..*\.url' 2>/dev
/null
); do
321 __git_list_merge_strategies
()
323 git merge
-s help 2>&1 |
324 sed -n -e '/[Aa]vailable strategies are: /,/^$/{
333 __git_merge_strategies
=
334 # 'git merge -s help' (and thus detection of the merge strategy
335 # list) fails, unfortunately, if run outside of any git working
336 # tree. __git_merge_strategies is set to the empty string in
337 # that case, and the detection will be repeated the next time it
339 __git_compute_merge_strategies
()
341 : ${__git_merge_strategies:=$(__git_list_merge_strategies)}
344 __git_complete_file
()
346 local pfx
ls ref cur
="${COMP_WORDS[COMP_CWORD]}"
363 case "$COMP_WORDBREAKS" in
365 *) pfx
="$ref:$pfx" ;;
369 COMPREPLY
=($
(compgen
-P "$pfx" \
370 -W "$(git --git-dir="$
(__gitdir
)" ls-tree "$ls" \
371 | sed '/^100... blob /{
387 __gitcomp
"$(__git_refs)"
392 __git_complete_revlist
()
394 local pfx cur
="${COMP_WORDS[COMP_CWORD]}"
399 __gitcomp
"$(__git_refs)" "$pfx" "$cur"
404 __gitcomp
"$(__git_refs)" "$pfx" "$cur"
407 __gitcomp
"$(__git_refs)"
412 __git_complete_remote_or_refspec
()
414 local cmd
="${COMP_WORDS[1]}"
415 local cur
="${COMP_WORDS[COMP_CWORD]}"
416 local i c
=2 remote
="" pfx
="" lhs
=1 no_complete_refspec
=0
417 while [ $c -lt $COMP_CWORD ]; do
420 --all|
--mirror) [ "$cmd" = "push" ] && no_complete_refspec
=1 ;;
422 *) remote
="$i"; break ;;
426 if [ -z "$remote" ]; then
427 __gitcomp
"$(__git_remotes)"
430 if [ $no_complete_refspec = 1 ]; then
434 [ "$remote" = "." ] && remote
=
437 case "$COMP_WORDBREAKS" in
439 *) pfx
="${cur%%:*}:" ;;
451 if [ $lhs = 1 ]; then
452 __gitcomp
"$(__git_refs2 "$remote")" "$pfx" "$cur"
454 __gitcomp
"$(__git_refs)" "$pfx" "$cur"
458 if [ $lhs = 1 ]; then
459 __gitcomp
"$(__git_refs "$remote")" "$pfx" "$cur"
461 __gitcomp
"$(__git_refs)" "$pfx" "$cur"
465 if [ $lhs = 1 ]; then
466 __gitcomp
"$(__git_refs)" "$pfx" "$cur"
468 __gitcomp
"$(__git_refs "$remote")" "$pfx" "$cur"
474 __git_complete_strategy
()
476 __git_compute_merge_strategies
477 case "${COMP_WORDS[COMP_CWORD-1]}" in
479 __gitcomp
"$__git_merge_strategies"
482 local cur
="${COMP_WORDS[COMP_CWORD]}"
485 __gitcomp
"$__git_merge_strategies" "" "${cur##--strategy=}"
492 __git_list_all_commands
()
495 for i
in $
(git
help -a|
egrep '^ [a-zA-Z0-9]')
498 *--*) : helper pattern
;;
505 __git_compute_all_commands
()
507 : ${__git_all_commands:=$(__git_list_all_commands)}
510 __git_list_porcelain_commands
()
513 __git_compute_all_commands
514 for i
in "help" $__git_all_commands
517 *--*) : helper pattern
;;
518 applymbox
) : ask gittus
;;
519 applypatch
) : ask gittus
;;
520 archimport
) : import
;;
521 cat-file
) : plumbing
;;
522 check-attr
) : plumbing
;;
523 check-ref-format
) : plumbing
;;
524 checkout-index
) : plumbing
;;
525 commit-tree
) : plumbing
;;
526 count-objects
) : infrequent
;;
527 cvsexportcommit
) : export;;
528 cvsimport
) : import
;;
529 cvsserver
) : daemon
;;
531 diff-files
) : plumbing
;;
532 diff-index
) : plumbing
;;
533 diff-tree
) : plumbing
;;
534 fast-import
) : import
;;
535 fast-export
) : export;;
536 fsck-objects
) : plumbing
;;
537 fetch-pack
) : plumbing
;;
538 fmt-merge-msg
) : plumbing
;;
539 for-each-ref
) : plumbing
;;
540 hash-object
) : plumbing
;;
541 http-
*) : transport
;;
542 index-pack
) : plumbing
;;
543 init-db
) : deprecated
;;
544 local-fetch
) : plumbing
;;
545 lost-found
) : infrequent
;;
546 ls-files
) : plumbing
;;
547 ls-remote
) : plumbing
;;
548 ls-tree
) : plumbing
;;
549 mailinfo
) : plumbing
;;
550 mailsplit
) : plumbing
;;
551 merge-
*) : plumbing
;;
554 pack-objects
) : plumbing
;;
555 pack-redundant
) : plumbing
;;
556 pack-refs
) : plumbing
;;
557 parse-remote
) : plumbing
;;
558 patch-id
) : plumbing
;;
559 peek-remote
) : plumbing
;;
561 prune-packed
) : plumbing
;;
562 quiltimport
) : import
;;
563 read-tree
) : plumbing
;;
564 receive-pack
) : plumbing
;;
566 repo-config
) : deprecated
;;
568 rev-list
) : plumbing
;;
569 rev-parse
) : plumbing
;;
570 runstatus
) : plumbing
;;
571 sh-setup
) : internal
;;
573 show-ref
) : plumbing
;;
574 send-pack
) : plumbing
;;
575 show-index
) : plumbing
;;
577 stripspace
) : plumbing
;;
578 symbolic-ref
) : plumbing
;;
579 tar-tree
) : deprecated
;;
580 unpack-file
) : plumbing
;;
581 unpack-objects
) : plumbing
;;
582 update-index
) : plumbing
;;
583 update-ref
) : plumbing
;;
584 update-server-info
) : daemon
;;
585 upload-archive
) : plumbing
;;
586 upload-pack
) : plumbing
;;
587 write-tree
) : plumbing
;;
589 verify-pack
) : infrequent
;;
590 verify-tag
) : plumbing
;;
596 __git_porcelain_commands
=
597 __git_compute_porcelain_commands
()
599 __git_compute_all_commands
600 : ${__git_porcelain_commands:=$(__git_list_porcelain_commands)}
606 for i
in $
(git
--git-dir="$(__gitdir)" config
--get-regexp "alias\..*" 2>/dev
/null
); do
616 # __git_aliased_command requires 1 argument
617 __git_aliased_command
()
619 local word cmdline
=$
(git
--git-dir="$(__gitdir)" \
620 config
--get "alias.$1")
621 for word
in $cmdline; do
622 if [ "${word##-*}" ]; then
629 # __git_find_on_cmdline requires 1 argument
630 __git_find_on_cmdline
()
632 local word subcommand c
=1
634 while [ $c -lt $COMP_CWORD ]; do
635 word
="${COMP_WORDS[c]}"
636 for subcommand
in $1; do
637 if [ "$subcommand" = "$word" ]; then
646 __git_has_doubledash
()
649 while [ $c -lt $COMP_CWORD ]; do
650 if [ "--" = "${COMP_WORDS[c]}" ]; then
658 __git_whitespacelist
="nowarn warn error error-all fix"
662 local cur
="${COMP_WORDS[COMP_CWORD]}" dir
="$(__gitdir)"
663 if [ -d "$dir"/rebase-apply
]; then
664 __gitcomp
"--skip --resolved --abort"
669 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
674 --3way --committer-date-is-author-date --ignore-date
675 --ignore-whitespace --ignore-space-change
676 --interactive --keep --no-utf8 --signoff --utf8
677 --whitespace= --scissors
686 local cur
="${COMP_WORDS[COMP_CWORD]}"
689 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
694 --stat --numstat --summary --check --index
695 --cached --index-info --reverse --reject --unidiff-zero
696 --apply --no-add --exclude=
697 --ignore-whitespace --ignore-space-change
698 --whitespace= --inaccurate-eof --verbose
707 __git_has_doubledash
&& return
709 local cur
="${COMP_WORDS[COMP_CWORD]}"
713 --interactive --refresh --patch --update --dry-run
714 --ignore-errors --intent-to-add
723 local cur
="${COMP_WORDS[COMP_CWORD]}"
726 __gitcomp
"$(git archive --list)" "" "${cur##--format=}"
730 __gitcomp
"$(__git_remotes)" "" "${cur##--remote=}"
735 --format= --list --verbose
736 --prefix= --remote= --exec=
746 __git_has_doubledash
&& return
748 local subcommands
="start bad good skip reset visualize replay log run"
749 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
750 if [ -z "$subcommand" ]; then
751 __gitcomp
"$subcommands"
755 case "$subcommand" in
757 __gitcomp
"$(__git_refs)"
767 local i c
=1 only_local_ref
="n" has_r
="n"
769 while [ $c -lt $COMP_CWORD ]; do
772 -d|
-m) only_local_ref
="y" ;;
778 case "${COMP_WORDS[COMP_CWORD]}" in
781 --color --no-color --verbose --abbrev= --no-abbrev
782 --track --no-track --contains --merged --no-merged
786 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
787 __gitcomp
"$(__git_heads)"
789 __gitcomp
"$(__git_refs)"
797 local cmd
="${COMP_WORDS[2]}"
798 case "$COMP_CWORD" in
800 __gitcomp
"create list-heads verify unbundle"
808 __git_complete_revlist
817 __git_has_doubledash
&& return
819 local cur
="${COMP_WORDS[COMP_CWORD]}"
822 __gitcomp
"diff3 merge" "" "${cur##--conflict=}"
826 --quiet --ours --theirs --track --no-track --merge
831 __gitcomp
"$(__git_refs)"
838 __gitcomp
"$(__git_refs)"
843 local cur
="${COMP_WORDS[COMP_CWORD]}"
846 __gitcomp
"--edit --no-commit"
849 __gitcomp
"$(__git_refs)"
856 __git_has_doubledash
&& return
858 local cur
="${COMP_WORDS[COMP_CWORD]}"
861 __gitcomp
"--dry-run --quiet"
870 local cur
="${COMP_WORDS[COMP_CWORD]}"
895 __git_has_doubledash
&& return
897 local cur
="${COMP_WORDS[COMP_CWORD]}"
901 --all --author= --signoff --verify --no-verify
902 --edit --amend --include --only --interactive
912 local cur
="${COMP_WORDS[COMP_CWORD]}"
916 --all --tags --contains --abbrev= --candidates=
917 --exact-match --debug --long --match --always
921 __gitcomp
"$(__git_refs)"
924 __git_diff_common_options
="--stat --numstat --shortstat --summary
925 --patch-with-stat --name-only --name-status --color
926 --no-color --color-words --no-renames --check
927 --full-index --binary --abbrev --diff-filter=
929 --text --ignore-space-at-eol --ignore-space-change
930 --ignore-all-space --exit-code --quiet --ext-diff
932 --no-prefix --src-prefix= --dst-prefix=
933 --inter-hunk-context=
936 --dirstat --dirstat= --dirstat-by-file
937 --dirstat-by-file= --cumulative
942 __git_has_doubledash
&& return
944 local cur
="${COMP_WORDS[COMP_CWORD]}"
947 __gitcomp
"--cached --staged --pickaxe-all --pickaxe-regex
948 --base --ours --theirs
949 $__git_diff_common_options
957 __git_mergetools_common
="diffuse ecmerge emerge kdiff3 meld opendiff
958 tkdiff vimdiff gvimdiff xxdiff araxis
963 local cur
="${COMP_WORDS[COMP_CWORD]}"
966 __gitcomp
"$__git_mergetools_common kompare" "" "${cur##--tool=}"
977 __git_fetch_options
="
978 --quiet --verbose --append --upload-pack --force --keep --depth=
984 local cur
="${COMP_WORDS[COMP_CWORD]}"
987 __gitcomp
"$__git_fetch_options"
991 __git_complete_remote_or_refspec
996 local cur
="${COMP_WORDS[COMP_CWORD]}"
1001 " "" "${cur##--thread=}"
1006 --stdout --attach --no-attach --thread --thread=
1008 --numbered --start-number
1012 --in-reply-to= --cc=
1013 --full-index --binary
1016 --no-prefix --src-prefix= --dst-prefix=
1017 --inline --suffix= --ignore-if-in-upstream
1023 __git_complete_revlist
1028 local cur
="${COMP_WORDS[COMP_CWORD]}"
1032 --tags --root --unreachable --cache --no-reflogs --full
1033 --strict --verbose --lost-found
1043 local cur
="${COMP_WORDS[COMP_CWORD]}"
1046 __gitcomp
"--prune --aggressive"
1055 __git_has_doubledash
&& return
1057 local cur
="${COMP_WORDS[COMP_CWORD]}"
1062 --text --ignore-case --word-regexp --invert-match
1064 --extended-regexp --basic-regexp --fixed-strings
1065 --files-with-matches --name-only
1066 --files-without-match
1069 --and --or --not --all-match
1079 local cur
="${COMP_WORDS[COMP_CWORD]}"
1082 __gitcomp
"--all --info --man --web"
1086 __git_compute_all_commands
1087 __gitcomp
"$__git_all_commands
1088 attributes cli core-tutorial cvs-migration
1089 diffcore gitk glossary hooks ignore modules
1090 repository-layout tutorial tutorial-2
1097 local cur
="${COMP_WORDS[COMP_CWORD]}"
1101 false true umask group all world everybody
1102 " "" "${cur##--shared=}"
1106 __gitcomp
"--quiet --bare --template= --shared --shared="
1115 __git_has_doubledash
&& return
1117 local cur
="${COMP_WORDS[COMP_CWORD]}"
1120 __gitcomp
"--cached --deleted --modified --others --ignored
1121 --stage --directory --no-empty-directory --unmerged
1122 --killed --exclude= --exclude-from=
1123 --exclude-per-directory= --exclude-standard
1124 --error-unmatch --with-tree= --full-name
1125 --abbrev --ignored --exclude-per-directory
1135 __gitcomp
"$(__git_remotes)"
1143 # Options that go well for log, shortlog and gitk
1144 __git_log_common_options
="
1146 --branches --tags --remotes
1147 --first-parent --merges --no-merges
1149 --max-age= --since= --after=
1150 --min-age= --until= --before=
1152 # Options that go well for log and gitk (not shortlog)
1153 __git_log_gitk_options
="
1154 --dense --sparse --full-history
1155 --simplify-merges --simplify-by-decoration
1158 # Options that go well for log and shortlog (not gitk)
1159 __git_log_shortlog_options
="
1160 --author= --committer= --grep=
1164 __git_log_pretty_formats
="oneline short medium full fuller email raw format:"
1165 __git_log_date_formats
="relative iso8601 rfc2822 short local default raw"
1169 __git_has_doubledash
&& return
1171 local cur
="${COMP_WORDS[COMP_CWORD]}"
1172 local g
="$(git rev-parse --git-dir 2>/dev/null)"
1174 if [ -f "$g/MERGE_HEAD" ]; then
1179 __gitcomp
"$__git_log_pretty_formats
1180 " "" "${cur##--pretty=}"
1184 __gitcomp
"$__git_log_pretty_formats
1185 " "" "${cur##--format=}"
1189 __gitcomp
"$__git_log_date_formats" "" "${cur##--date=}"
1193 __gitcomp
"long short" "" "${cur##--decorate=}"
1198 $__git_log_common_options
1199 $__git_log_shortlog_options
1200 $__git_log_gitk_options
1201 --root --topo-order --date-order --reverse
1202 --follow --full-diff
1203 --abbrev-commit --abbrev=
1204 --relative-date --date=
1205 --pretty= --format= --oneline
1208 --decorate --decorate=
1210 --parents --children
1212 $__git_diff_common_options
1213 --pickaxe-all --pickaxe-regex
1218 __git_complete_revlist
1221 __git_merge_options
="
1222 --no-commit --no-stat --log --no-log --squash --strategy
1223 --commit --stat --no-squash --ff --no-ff
1228 __git_complete_strategy
&& return
1230 local cur
="${COMP_WORDS[COMP_CWORD]}"
1233 __gitcomp
"$__git_merge_options"
1236 __gitcomp
"$(__git_refs)"
1241 local cur
="${COMP_WORDS[COMP_CWORD]}"
1244 __gitcomp
"$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"
1257 __gitcomp
"$(__git_refs)"
1262 local cur
="${COMP_WORDS[COMP_CWORD]}"
1265 __gitcomp
"--dry-run"
1274 __gitcomp
"--tags --all --stdin"
1279 __git_complete_strategy
&& return
1281 local cur
="${COMP_WORDS[COMP_CWORD]}"
1285 --rebase --no-rebase
1286 $__git_merge_options
1287 $__git_fetch_options
1292 __git_complete_remote_or_refspec
1297 local cur
="${COMP_WORDS[COMP_CWORD]}"
1298 case "${COMP_WORDS[COMP_CWORD-1]}" in
1300 __gitcomp
"$(__git_remotes)"
1305 __gitcomp
"$(__git_remotes)" "" "${cur##--repo=}"
1310 --all --mirror --tags --dry-run --force --verbose
1311 --receive-pack= --repo=
1316 __git_complete_remote_or_refspec
1321 local cur
="${COMP_WORDS[COMP_CWORD]}" dir
="$(__gitdir)"
1322 if [ -d "$dir"/rebase-apply
] ||
[ -d "$dir"/rebase-merge
]; then
1323 __gitcomp
"--continue --skip --abort"
1326 __git_complete_strategy
&& return
1329 __gitcomp
"--onto --merge --strategy --interactive"
1332 __gitcomp
"$(__git_refs)"
1335 __git_send_email_confirm_options
="always never auto cc compose"
1336 __git_send_email_suppresscc_options
="author self cc bodycc sob cccmd body all"
1340 local cur
="${COMP_WORDS[COMP_CWORD]}"
1344 $__git_send_email_confirm_options
1345 " "" "${cur##--confirm=}"
1350 $__git_send_email_suppresscc_options
1351 " "" "${cur##--suppress-cc=}"
1355 --smtp-encryption=*)
1356 __gitcomp
"ssl tls" "" "${cur##--smtp-encryption=}"
1360 __gitcomp
"--annotate --bcc --cc --cc-cmd --chain-reply-to
1361 --compose --confirm= --dry-run --envelope-sender
1363 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
1364 --no-suppress-from --no-thread --quiet
1365 --signed-off-by-cc --smtp-pass --smtp-server
1366 --smtp-server-port --smtp-encryption= --smtp-user
1367 --subject --suppress-cc= --suppress-from --thread --to
1368 --validate --no-validate"
1375 __git_config_get_set_variables
()
1377 local prevword word config_file
= c
=$COMP_CWORD
1378 while [ $c -gt 1 ]; do
1379 word
="${COMP_WORDS[c]}"
1381 --global|
--system|
--file=*)
1386 config_file
="$word $prevword"
1394 git
--git-dir="$(__gitdir)" config
$config_file --list 2>/dev
/null |
1407 local cur
="${COMP_WORDS[COMP_CWORD]}"
1408 local prv
="${COMP_WORDS[COMP_CWORD-1]}"
1411 __gitcomp
"$(__git_remotes)"
1415 __gitcomp
"$(__git_refs)"
1419 local remote
="${prv#remote.}"
1420 remote
="${remote%.fetch}"
1421 __gitcomp
"$(__git_refs_remotes "$remote")"
1425 local remote
="${prv#remote.}"
1426 remote
="${remote%.push}"
1427 __gitcomp
"$(git --git-dir="$
(__gitdir
)" \
1428 for-each-ref --format='%(refname):%(refname)' \
1432 pull.twohead|pull.octopus
)
1433 __git_compute_merge_strategies
1434 __gitcomp
"$__git_merge_strategies"
1437 color.branch|color.
diff|color.interactive|\
1438 color.showbranch|color.status|color.ui
)
1439 __gitcomp
"always never auto"
1443 __gitcomp
"false true"
1448 normal black red green yellow blue magenta cyan white
1449 bold dim ul blink reverse
1454 __gitcomp
"man info web html"
1458 __gitcomp
"$__git_log_date_formats"
1461 sendemail.aliasesfiletype
)
1462 __gitcomp
"mutt mailrc pine elm gnus"
1466 __gitcomp
"$__git_send_email_confirm_options"
1469 sendemail.suppresscc
)
1470 __gitcomp
"$__git_send_email_suppresscc_options"
1473 --get|
--get-all|
--unset|
--unset-all)
1474 __gitcomp
"$(__git_config_get_set_variables)"
1485 --global --system --file=
1486 --list --replace-all
1487 --get --get-all --get-regexp
1488 --add --unset --unset-all
1489 --remove-section --rename-section
1494 local pfx
="${cur%.*}."
1496 __gitcomp
"remote merge mergeoptions rebase" "$pfx" "$cur"
1500 local pfx
="${cur%.*}."
1502 __gitcomp
"$(__git_heads)" "$pfx" "$cur" "."
1506 local pfx
="${cur%.*}."
1509 argprompt cmd confirm needsfile noconsole norescan
1510 prompt revprompt revunmerged title
1515 local pfx
="${cur%.*}."
1517 __gitcomp
"cmd path" "$pfx" "$cur"
1521 local pfx
="${cur%.*}."
1523 __gitcomp
"cmd path" "$pfx" "$cur"
1527 local pfx
="${cur%.*}."
1529 __gitcomp
"cmd path trustExitCode" "$pfx" "$cur"
1533 local pfx
="${cur%.*}."
1535 __git_compute_all_commands
1536 __gitcomp
"$__git_all_commands" "$pfx" "$cur"
1540 local pfx
="${cur%.*}."
1543 url proxy fetch push mirror skipDefaultUpdate
1544 receivepack uploadpack tagopt pushurl
1549 local pfx
="${cur%.*}."
1551 __gitcomp
"$(__git_remotes)" "$pfx" "$cur" "."
1555 local pfx
="${cur%.*}."
1557 __gitcomp
"insteadOf pushInsteadOf" "$pfx" "$cur"
1564 apply.ignorewhitespace
1566 branch.autosetupmerge
1567 branch.autosetuprebase
1570 color.branch.current
1581 color.diff.whitespace
1586 color.interactive.header
1587 color.interactive.help
1588 color.interactive.prompt
1593 color.status.changed
1595 color.status.nobranch
1596 color.status.untracked
1597 color.status.updated
1604 core.deltaBaseCacheLimit
1608 core.fsyncobjectfiles
1610 core.ignoreCygwinFSTricks
1612 core.logAllRefUpdates
1613 core.loosecompression
1615 core.packedGitWindowSize
1617 core.preferSymlinkRefs
1620 core.repositoryFormatVersion
1622 core.sharedRepository
1625 core.warnAmbiguousRefs
1628 diff.autorefreshindex
1634 diff.suppressBlankEmpty
1646 format.subjectprefix
1655 gc.reflogexpireunreachable
1659 gitcvs.commitmsgannotation
1660 gitcvs.dbTableNamePrefix
1671 gui.copyblamethreshold
1675 gui.matchtrackingbranch
1676 gui.newbranchtemplate
1677 gui.pruneduringfetch
1678 gui.spellingdictionary
1694 i18n.logOutputEncoding
1699 imap.preformattedHTML
1708 interactive.singlekey
1721 mergetool.keepBackup
1724 pack.deltaCacheLimit
1737 receive.denyCurrentBranch
1739 receive.denyNonFastForwards
1742 repack.usedeltabaseoffset
1745 sendemail.aliasesfile
1746 sendemail.aliasesfiletype
1750 sendemail.chainreplyto
1752 sendemail.envelopesender
1754 sendemail.signedoffbycc
1755 sendemail.smtpencryption
1757 sendemail.smtpserver
1758 sendemail.smtpserverport
1760 sendemail.suppresscc
1761 sendemail.suppressfrom
1766 status.relativePaths
1767 status.showUntrackedFiles
1769 transfer.unpackLimit
1781 local subcommands
="add rename rm show prune update set-head"
1782 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
1783 if [ -z "$subcommand" ]; then
1784 __gitcomp
"$subcommands"
1788 case "$subcommand" in
1789 rename|
rm|show|prune
)
1790 __gitcomp
"$(__git_remotes)"
1793 local i c
='' IFS
=$
'\n'
1794 for i
in $
(git
--git-dir="$(__gitdir)" config
--get-regexp "remotes\..*" 2>/dev
/null
); do
1808 __gitcomp
"$(__git_refs)"
1813 __git_has_doubledash
&& return
1815 local cur
="${COMP_WORDS[COMP_CWORD]}"
1818 __gitcomp
"--merge --mixed --hard --soft --patch"
1822 __gitcomp
"$(__git_refs)"
1827 local cur
="${COMP_WORDS[COMP_CWORD]}"
1830 __gitcomp
"--edit --mainline --no-edit --no-commit --signoff"
1834 __gitcomp
"$(__git_refs)"
1839 __git_has_doubledash
&& return
1841 local cur
="${COMP_WORDS[COMP_CWORD]}"
1844 __gitcomp
"--cached --dry-run --ignore-unmatch --quiet"
1853 __git_has_doubledash
&& return
1855 local cur
="${COMP_WORDS[COMP_CWORD]}"
1859 $__git_log_common_options
1860 $__git_log_shortlog_options
1861 --numbered --summary
1866 __git_complete_revlist
1871 __git_has_doubledash
&& return
1873 local cur
="${COMP_WORDS[COMP_CWORD]}"
1876 __gitcomp
"$__git_log_pretty_formats
1877 " "" "${cur##--pretty=}"
1881 __gitcomp
"$__git_log_pretty_formats
1882 " "" "${cur##--format=}"
1886 __gitcomp
"--pretty= --format= --abbrev-commit --oneline
1887 $__git_diff_common_options
1897 local cur
="${COMP_WORDS[COMP_CWORD]}"
1901 --all --remotes --topo-order --current --more=
1902 --list --independent --merge-base --no-name
1904 --sha1-name --sparse --topics --reflog
1909 __git_complete_revlist
1914 local cur
="${COMP_WORDS[COMP_CWORD]}"
1915 local save_opts
='--keep-index --no-keep-index --quiet --patch'
1916 local subcommands
='save list show apply clear drop pop create branch'
1917 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
1918 if [ -z "$subcommand" ]; then
1921 __gitcomp
"$save_opts"
1924 if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then
1925 __gitcomp
"$subcommands"
1932 case "$subcommand,$cur" in
1934 __gitcomp
"$save_opts"
1937 __gitcomp
"--index --quiet"
1939 show
,--*|drop
,--*|branch
,--*)
1942 show
,*|apply
,*|drop
,*|pop
,*|branch
,*)
1943 __gitcomp
"$(git --git-dir="$
(__gitdir
)" stash list \
1944 | sed -n -e 's/:.*//p')"
1955 __git_has_doubledash
&& return
1957 local subcommands
="add status init update summary foreach sync"
1958 if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then
1959 local cur
="${COMP_WORDS[COMP_CWORD]}"
1962 __gitcomp
"--quiet --cached"
1965 __gitcomp
"$subcommands"
1975 init fetch clone rebase dcommit log find-rev
1976 set-tree commit-diff info create-ignore propget
1977 proplist show-ignore show-externals branch tag blame
1980 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
1981 if [ -z "$subcommand" ]; then
1982 __gitcomp
"$subcommands"
1984 local remote_opts
="--username= --config-dir= --no-auth-cache"
1986 --follow-parent --authors-file= --repack=
1987 --no-metadata --use-svm-props --use-svnsync-props
1988 --log-window-size= --no-checkout --quiet
1989 --repack-flags --use-log-author --localtime
1990 --ignore-paths= $remote_opts
1993 --template= --shared= --trunk= --tags=
1994 --branches= --stdlayout --minimize-url
1995 --no-metadata --use-svm-props --use-svnsync-props
1996 --rewrite-root= --prefix= --use-log-author
1997 --add-author-from $remote_opts
2000 --edit --rmdir --find-copies-harder --copy-similarity=
2003 local cur
="${COMP_WORDS[COMP_CWORD]}"
2004 case "$subcommand,$cur" in
2006 __gitcomp
"--revision= --fetch-all $fc_opts"
2009 __gitcomp
"--revision= $fc_opts $init_opts"
2012 __gitcomp
"$init_opts"
2016 --merge --strategy= --verbose --dry-run
2017 --fetch-all --no-rebase --commit-url
2018 --revision $cmt_opts $fc_opts
2022 __gitcomp
"--stdin $cmt_opts $fc_opts"
2024 create-ignore
,--*|propget
,--*|proplist
,--*|show-ignore
,--*|\
2026 __gitcomp
"--revision="
2030 --limit= --revision= --verbose --incremental
2031 --oneline --show-commit --non-recursive
2032 --authors-file= --color
2037 --merge --verbose --strategy= --local
2038 --fetch-all --dry-run $fc_opts
2042 __gitcomp
"--message= --file= --revision= $cmt_opts"
2048 __gitcomp
"--dry-run --message --tag"
2051 __gitcomp
"--dry-run --message"
2054 __gitcomp
"--git-format"
2058 --config-dir= --ignore-paths= --minimize
2059 --no-auth-cache --username=
2072 while [ $c -lt $COMP_CWORD ]; do
2073 i
="${COMP_WORDS[c]}"
2076 __gitcomp
"$(__git_tags)"
2086 case "${COMP_WORDS[COMP_CWORD-1]}" in
2092 __gitcomp
"$(__git_tags)"
2098 __gitcomp
"$(__git_refs)"
2105 local i c
=1 command __git_dir
2107 while [ $c -lt $COMP_CWORD ]; do
2108 i
="${COMP_WORDS[c]}"
2110 --git-dir=*) __git_dir
="${i#--git-dir=}" ;;
2111 --bare) __git_dir
="." ;;
2112 --version|
-p|
--paginate) ;;
2113 --help) command="help"; break ;;
2114 *) command="$i"; break ;;
2119 if [ -z "$command" ]; then
2120 case "${COMP_WORDS[COMP_CWORD]}" in
2133 *) __git_compute_porcelain_commands
2134 __gitcomp
"$__git_porcelain_commands $(__git_aliases)" ;;
2139 local expansion
=$
(__git_aliased_command
"$command")
2140 [ "$expansion" ] && command="$expansion"
2145 apply
) _git_apply
;;
2146 archive
) _git_archive
;;
2147 bisect
) _git_bisect
;;
2148 bundle
) _git_bundle
;;
2149 branch
) _git_branch
;;
2150 checkout
) _git_checkout
;;
2151 cherry
) _git_cherry
;;
2152 cherry-pick
) _git_cherry_pick
;;
2153 clean
) _git_clean
;;
2154 clone
) _git_clone
;;
2155 commit
) _git_commit
;;
2156 config
) _git_config
;;
2157 describe
) _git_describe
;;
2159 difftool
) _git_difftool
;;
2160 fetch
) _git_fetch
;;
2161 format-patch
) _git_format_patch
;;
2168 ls-files
) _git_ls_files
;;
2169 ls-remote
) _git_ls_remote
;;
2170 ls-tree
) _git_ls_tree
;;
2172 mergetool
) _git_mergetool
;;
2173 merge-base
) _git_merge_base
;;
2175 name-rev
) _git_name_rev
;;
2178 rebase
) _git_rebase
;;
2179 remote
) _git_remote
;;
2180 replace
) _git_replace
;;
2181 reset) _git_reset
;;
2182 revert
) _git_revert
;;
2184 send-email
) _git_send_email
;;
2185 shortlog
) _git_shortlog
;;
2187 show-branch
) _git_show_branch
;;
2188 stash
) _git_stash
;;
2190 submodule
) _git_submodule
;;
2193 whatchanged
) _git_log
;;
2200 __git_has_doubledash
&& return
2202 local cur
="${COMP_WORDS[COMP_CWORD]}"
2203 local g
="$(__gitdir)"
2205 if [ -f "$g/MERGE_HEAD" ]; then
2211 $__git_log_common_options
2212 $__git_log_gitk_options
2218 __git_complete_revlist
2221 complete
-o bashdefault
-o default
-o nospace
-F _git git
2>/dev
/null \
2222 || complete
-o default
-o nospace
-F _git git
2223 complete
-o bashdefault
-o default
-o nospace
-F _gitk gitk
2>/dev
/null \
2224 || complete
-o default
-o nospace
-F _gitk gitk
2226 # The following are necessary only for Cygwin, and only are needed
2227 # when the user has tab-completed the executable name and consequently
2228 # included the '.exe' suffix.
2230 if [ Cygwin
= "$(uname -o 2>/dev/null)" ]; then
2231 complete
-o bashdefault
-o default
-o nospace
-F _git git.exe
2>/dev
/null \
2232 || complete
-o default
-o nospace
-F _git git.exe