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.
45 # *) Read Documentation/SubmittingPatches
46 # *) Send all patches to the current maintainer:
48 # "Shawn O. Pearce" <spearce@spearce.org>
50 # *) Always CC the Git mailing list:
55 case "$COMP_WORDBREAKS" in
57 *) COMP_WORDBREAKS
="$COMP_WORDBREAKS:"
60 # __gitdir accepts 0 or 1 arguments (i.e., location)
61 # returns location of .git repo
64 if [ -z "${1-}" ]; then
65 if [ -n "${__git_dir-}" ]; then
67 elif [ -d .git
]; then
70 git rev-parse
--git-dir 2>/dev
/null
72 elif [ -d "$1/.git" ]; then
79 # __git_ps1 accepts 0 or 1 arguments (i.e., format string)
80 # returns text to add to bash PS1 prompt (includes branch name)
87 if [ -d "$g/rebase-apply" ]; then
88 if [ -f "$g/rebase-apply/rebasing" ]; then
90 elif [ -f "$g/rebase-apply/applying" ]; then
95 b
="$(git symbolic-ref HEAD 2>/dev/null)"
96 elif [ -f "$g/rebase-merge/interactive" ]; then
98 b
="$(cat "$g/rebase-merge
/head-name
")"
99 elif [ -d "$g/rebase-merge" ]; then
101 b
="$(cat "$g/rebase-merge
/head-name
")"
103 if [ -f "$g/MERGE_HEAD" ]; then
106 if [ -f "$g/BISECT_LOG" ]; then
110 b
="$(git symbolic-ref HEAD 2>/dev/null)" ||
{
111 b
="$(git describe --exact-match HEAD 2>/dev/null)" ||
112 b
="$(cut -c1-7 "$g/HEAD
" 2>/dev/null)..." ||
123 if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then
124 if [ "true" = "$(git config --bool core.bare 2>/dev/null)" ]; then
129 elif [ "true" = "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
130 if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ]; then
131 if [ "$(git config --bool bash.showDirtyState)" != "false" ]; then
132 git
diff --no-ext-diff --ignore-submodules \
133 --quiet --exit-code || w
="*"
134 if git rev-parse
--quiet --verify HEAD
>/dev
/null
; then
135 git diff-index
--cached --quiet \
136 --ignore-submodules HEAD
-- || i
="+"
145 if [ -n "${1-}" ]; then
146 printf "$1" "$c${b##refs/heads/}$w$i$r"
148 printf " (%s)" "$c${b##refs/heads/}$w$i$r"
154 # __gitcomp_1 requires 2 arguments
157 local c IFS
=' '$
'\t'$
'\n'
160 --*=*) printf %s$
'\n' "$c$2" ;;
161 *.
) printf %s$
'\n' "$c$2" ;;
162 *) printf %s$
'\n' "$c$2 " ;;
167 # __gitcomp accepts 1, 2, 3, or 4 arguments
168 # generates completion reply with compgen
171 local cur
="${COMP_WORDS[COMP_CWORD]}"
172 if [ $# -gt 2 ]; then
181 COMPREPLY
=($
(compgen
-P "${2-}" \
182 -W "$(__gitcomp_1 "${1-}" "${4-}")" \
188 # __git_heads accepts 0 or 1 arguments (to pass to __gitdir)
191 local cmd i is_hash
=y dir
="$(__gitdir "${1-}")"
192 if [ -d "$dir" ]; then
193 git
--git-dir="$dir" for-each-ref
--format='%(refname:short)' \
197 for i
in $
(git ls-remote
"${1-}" 2>/dev
/null
); do
198 case "$is_hash,$i" in
201 n
,refs
/heads
/*) is_hash
=y
; echo "${i#refs/heads/}" ;;
202 n
,*) is_hash
=y
; echo "$i" ;;
207 # __git_tags accepts 0 or 1 arguments (to pass to __gitdir)
210 local cmd i is_hash
=y dir
="$(__gitdir "${1-}")"
211 if [ -d "$dir" ]; then
212 git
--git-dir="$dir" for-each-ref
--format='%(refname:short)' \
216 for i
in $
(git ls-remote
"${1-}" 2>/dev
/null
); do
217 case "$is_hash,$i" in
220 n
,refs
/tags
/*) is_hash
=y
; echo "${i#refs/tags/}" ;;
221 n
,*) is_hash
=y
; echo "$i" ;;
226 # __git_refs accepts 0 or 1 arguments (to pass to __gitdir)
229 local i is_hash
=y dir
="$(__gitdir "${1-}")"
230 local cur
="${COMP_WORDS[COMP_CWORD]}" format refs
231 if [ -d "$dir" ]; then
238 if [ -e "$dir/HEAD" ]; then echo HEAD
; fi
239 format
="refname:short"
240 refs
="refs/tags refs/heads refs/remotes"
243 git
--git-dir="$dir" for-each-ref
--format="%($format)" \
247 for i
in $
(git ls-remote
"$dir" 2>/dev
/null
); do
248 case "$is_hash,$i" in
251 n
,refs
/tags
/*) is_hash
=y
; echo "${i#refs/tags/}" ;;
252 n
,refs
/heads
/*) is_hash
=y
; echo "${i#refs/heads/}" ;;
253 n
,refs
/remotes
/*) is_hash
=y
; echo "${i#refs/remotes/}" ;;
254 n
,*) is_hash
=y
; echo "$i" ;;
259 # __git_refs2 requires 1 argument (to pass to __git_refs)
263 for i
in $
(__git_refs
"$1"); do
268 # __git_refs_remotes requires 1 argument (to pass to ls-remote)
269 __git_refs_remotes
()
271 local cmd i is_hash
=y
272 for i
in $
(git ls-remote
"$1" 2>/dev
/null
); do
273 case "$is_hash,$i" in
276 echo "$i:refs/remotes/$1/${i#refs/heads/}"
280 n
,refs
/tags
/*) is_hash
=y
;;
288 local i ngoff IFS
=$
'\n' d
="$(__gitdir)"
289 shopt -q nullglob || ngoff
=1
291 for i
in "$d/remotes"/*; do
292 echo ${i#$d/remotes/}
294 [ "$ngoff" ] && shopt -u nullglob
295 for i
in $
(git
--git-dir="$d" config
--list); do
305 __git_merge_strategies
()
307 if [ -n "${__git_merge_strategylist-}" ]; then
308 echo "$__git_merge_strategylist"
311 git merge
-s help 2>&1 |
312 sed -n -e '/[Aa]vailable strategies are: /,/^$/{
320 __git_merge_strategylist
=
321 __git_merge_strategylist
=$
(__git_merge_strategies
2>/dev
/null
)
323 __git_complete_file
()
325 local pfx
ls ref cur
="${COMP_WORDS[COMP_CWORD]}"
342 case "$COMP_WORDBREAKS" in
344 *) pfx
="$ref:$pfx" ;;
348 COMPREPLY
=($
(compgen
-P "$pfx" \
349 -W "$(git --git-dir="$
(__gitdir
)" ls-tree "$ls" \
350 | sed '/^100... blob /{
366 __gitcomp
"$(__git_refs)"
371 __git_complete_revlist
()
373 local pfx cur
="${COMP_WORDS[COMP_CWORD]}"
378 __gitcomp
"$(__git_refs)" "$pfx" "$cur"
383 __gitcomp
"$(__git_refs)" "$pfx" "$cur"
386 __gitcomp
"$(__git_refs)"
391 __git_complete_remote_or_refspec
()
393 local cmd
="${COMP_WORDS[1]}"
394 local cur
="${COMP_WORDS[COMP_CWORD]}"
395 local i c
=2 remote
="" pfx
="" lhs
=1 no_complete_refspec
=0
396 while [ $c -lt $COMP_CWORD ]; do
399 --all|
--mirror) [ "$cmd" = "push" ] && no_complete_refspec
=1 ;;
401 *) remote
="$i"; break ;;
405 if [ -z "$remote" ]; then
406 __gitcomp
"$(__git_remotes)"
409 if [ $no_complete_refspec = 1 ]; then
413 [ "$remote" = "." ] && remote
=
416 case "$COMP_WORDBREAKS" in
418 *) pfx
="${cur%%:*}:" ;;
430 if [ $lhs = 1 ]; then
431 __gitcomp
"$(__git_refs2 "$remote")" "$pfx" "$cur"
433 __gitcomp
"$(__git_refs)" "$pfx" "$cur"
437 if [ $lhs = 1 ]; then
438 __gitcomp
"$(__git_refs "$remote")" "$pfx" "$cur"
440 __gitcomp
"$(__git_refs)" "$pfx" "$cur"
444 if [ $lhs = 1 ]; then
445 __gitcomp
"$(__git_refs)" "$pfx" "$cur"
447 __gitcomp
"$(__git_refs "$remote")" "$pfx" "$cur"
453 __git_complete_strategy
()
455 case "${COMP_WORDS[COMP_CWORD-1]}" in
457 __gitcomp
"$(__git_merge_strategies)"
460 local cur
="${COMP_WORDS[COMP_CWORD]}"
463 __gitcomp
"$(__git_merge_strategies)" "" "${cur##--strategy=}"
470 __git_all_commands
()
472 if [ -n "${__git_all_commandlist-}" ]; then
473 echo "$__git_all_commandlist"
477 for i
in $
(git
help -a|
egrep '^ ')
480 *--*) : helper pattern
;;
485 __git_all_commandlist
=
486 __git_all_commandlist
="$(__git_all_commands 2>/dev/null)"
488 __git_porcelain_commands
()
490 if [ -n "${__git_porcelain_commandlist-}" ]; then
491 echo "$__git_porcelain_commandlist"
495 for i
in "help" $
(__git_all_commands
)
498 *--*) : helper pattern
;;
499 applymbox
) : ask gittus
;;
500 applypatch
) : ask gittus
;;
501 archimport
) : import
;;
502 cat-file
) : plumbing
;;
503 check-attr
) : plumbing
;;
504 check-ref-format
) : plumbing
;;
505 checkout-index
) : plumbing
;;
506 commit-tree
) : plumbing
;;
507 count-objects
) : infrequent
;;
508 cvsexportcommit
) : export;;
509 cvsimport
) : import
;;
510 cvsserver
) : daemon
;;
512 diff-files
) : plumbing
;;
513 diff-index
) : plumbing
;;
514 diff-tree
) : plumbing
;;
515 fast-import
) : import
;;
516 fast-export
) : export;;
517 fsck-objects
) : plumbing
;;
518 fetch-pack
) : plumbing
;;
519 fmt-merge-msg
) : plumbing
;;
520 for-each-ref
) : plumbing
;;
521 hash-object
) : plumbing
;;
522 http-
*) : transport
;;
523 index-pack
) : plumbing
;;
524 init-db
) : deprecated
;;
525 local-fetch
) : plumbing
;;
526 lost-found
) : infrequent
;;
527 ls-files
) : plumbing
;;
528 ls-remote
) : plumbing
;;
529 ls-tree
) : plumbing
;;
530 mailinfo
) : plumbing
;;
531 mailsplit
) : plumbing
;;
532 merge-
*) : plumbing
;;
535 pack-objects
) : plumbing
;;
536 pack-redundant
) : plumbing
;;
537 pack-refs
) : plumbing
;;
538 parse-remote
) : plumbing
;;
539 patch-id
) : plumbing
;;
540 peek-remote
) : plumbing
;;
542 prune-packed
) : plumbing
;;
543 quiltimport
) : import
;;
544 read-tree
) : plumbing
;;
545 receive-pack
) : plumbing
;;
547 repo-config
) : deprecated
;;
549 rev-list
) : plumbing
;;
550 rev-parse
) : plumbing
;;
551 runstatus
) : plumbing
;;
552 sh-setup
) : internal
;;
554 show-ref
) : plumbing
;;
555 send-pack
) : plumbing
;;
556 show-index
) : plumbing
;;
558 stripspace
) : plumbing
;;
559 symbolic-ref
) : plumbing
;;
560 tar-tree
) : deprecated
;;
561 unpack-file
) : plumbing
;;
562 unpack-objects
) : plumbing
;;
563 update-index
) : plumbing
;;
564 update-ref
) : plumbing
;;
565 update-server-info
) : daemon
;;
566 upload-archive
) : plumbing
;;
567 upload-pack
) : plumbing
;;
568 write-tree
) : plumbing
;;
570 verify-pack
) : infrequent
;;
571 verify-tag
) : plumbing
;;
576 __git_porcelain_commandlist
=
577 __git_porcelain_commandlist
="$(__git_porcelain_commands 2>/dev/null)"
582 for i
in $
(git
--git-dir="$(__gitdir)" config
--list); do
592 # __git_aliased_command requires 1 argument
593 __git_aliased_command
()
595 local word cmdline
=$
(git
--git-dir="$(__gitdir)" \
596 config
--get "alias.$1")
597 for word
in $cmdline; do
598 if [ "${word##-*}" ]; then
605 # __git_find_subcommand requires 1 argument
606 __git_find_subcommand
()
608 local word subcommand c
=1
610 while [ $c -lt $COMP_CWORD ]; do
611 word
="${COMP_WORDS[c]}"
612 for subcommand
in $1; do
613 if [ "$subcommand" = "$word" ]; then
622 __git_has_doubledash
()
625 while [ $c -lt $COMP_CWORD ]; do
626 if [ "--" = "${COMP_WORDS[c]}" ]; then
634 __git_whitespacelist
="nowarn warn error error-all fix"
638 local cur
="${COMP_WORDS[COMP_CWORD]}" dir
="$(__gitdir)"
639 if [ -d "$dir"/rebase-apply
]; then
640 __gitcomp
"--skip --resolved --abort"
645 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
650 --3way --committer-date-is-author-date --ignore-date
651 --interactive --keep --no-utf8 --signoff --utf8
661 local cur
="${COMP_WORDS[COMP_CWORD]}"
664 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
669 --stat --numstat --summary --check --index
670 --cached --index-info --reverse --reject --unidiff-zero
671 --apply --no-add --exclude=
672 --whitespace= --inaccurate-eof --verbose
681 __git_has_doubledash
&& return
683 local cur
="${COMP_WORDS[COMP_CWORD]}"
687 --interactive --refresh --patch --update --dry-run
688 --ignore-errors --intent-to-add
697 local cur
="${COMP_WORDS[COMP_CWORD]}"
700 __gitcomp
"$(git archive --list)" "" "${cur##--format=}"
704 __gitcomp
"$(__git_remotes)" "" "${cur##--remote=}"
709 --format= --list --verbose
710 --prefix= --remote= --exec=
720 __git_has_doubledash
&& return
722 local subcommands
="start bad good skip reset visualize replay log run"
723 local subcommand
="$(__git_find_subcommand "$subcommands")"
724 if [ -z "$subcommand" ]; then
725 __gitcomp
"$subcommands"
729 case "$subcommand" in
731 __gitcomp
"$(__git_refs)"
741 local i c
=1 only_local_ref
="n" has_r
="n"
743 while [ $c -lt $COMP_CWORD ]; do
746 -d|
-m) only_local_ref
="y" ;;
752 case "${COMP_WORDS[COMP_CWORD]}" in
755 --color --no-color --verbose --abbrev= --no-abbrev
756 --track --no-track --contains --merged --no-merged
760 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
761 __gitcomp
"$(__git_heads)"
763 __gitcomp
"$(__git_refs)"
771 local cmd
="${COMP_WORDS[2]}"
772 case "$COMP_CWORD" in
774 __gitcomp
"create list-heads verify unbundle"
782 __git_complete_revlist
791 __git_has_doubledash
&& return
793 __gitcomp
"$(__git_refs)"
798 __gitcomp
"$(__git_refs)"
803 local cur
="${COMP_WORDS[COMP_CWORD]}"
806 __gitcomp
"--edit --no-commit"
809 __gitcomp
"$(__git_refs)"
816 __git_has_doubledash
&& return
818 local cur
="${COMP_WORDS[COMP_CWORD]}"
821 __gitcomp
"--dry-run --quiet"
830 local cur
="${COMP_WORDS[COMP_CWORD]}"
855 __git_has_doubledash
&& return
857 local cur
="${COMP_WORDS[COMP_CWORD]}"
861 --all --author= --signoff --verify --no-verify
862 --edit --amend --include --only --interactive
871 local cur
="${COMP_WORDS[COMP_CWORD]}"
875 --all --tags --contains --abbrev= --candidates=
876 --exact-match --debug --long --match --always
880 __gitcomp
"$(__git_refs)"
883 __git_diff_common_options
="--stat --numstat --shortstat --summary
884 --patch-with-stat --name-only --name-status --color
885 --no-color --color-words --no-renames --check
886 --full-index --binary --abbrev --diff-filter=
888 --text --ignore-space-at-eol --ignore-space-change
889 --ignore-all-space --exit-code --quiet --ext-diff
891 --no-prefix --src-prefix= --dst-prefix=
892 --inter-hunk-context=
899 __git_has_doubledash
&& return
901 local cur
="${COMP_WORDS[COMP_CWORD]}"
904 __gitcomp
"--cached --staged --pickaxe-all --pickaxe-regex
905 --base --ours --theirs
906 $__git_diff_common_options
914 __git_mergetools_common
="diffuse ecmerge emerge kdiff3 meld opendiff
915 tkdiff vimdiff gvimdiff xxdiff
920 local cur
="${COMP_WORDS[COMP_CWORD]}"
923 __gitcomp
"$__git_mergetools_common kompare" "" "${cur##--tool=}"
934 __git_fetch_options
="
935 --quiet --verbose --append --upload-pack --force --keep --depth=
941 local cur
="${COMP_WORDS[COMP_CWORD]}"
944 __gitcomp
"$__git_fetch_options"
948 __git_complete_remote_or_refspec
953 local cur
="${COMP_WORDS[COMP_CWORD]}"
958 " "" "${cur##--thread=}"
963 --stdout --attach --no-attach --thread --thread=
965 --numbered --start-number
970 --full-index --binary
973 --no-prefix --src-prefix= --dst-prefix=
974 --inline --suffix= --ignore-if-in-upstream
980 __git_complete_revlist
985 local cur
="${COMP_WORDS[COMP_CWORD]}"
989 --tags --root --unreachable --cache --no-reflogs --full
990 --strict --verbose --lost-found
1000 local cur
="${COMP_WORDS[COMP_CWORD]}"
1003 __gitcomp
"--prune --aggressive"
1012 __git_has_doubledash
&& return
1014 local cur
="${COMP_WORDS[COMP_CWORD]}"
1019 --text --ignore-case --word-regexp --invert-match
1021 --extended-regexp --basic-regexp --fixed-strings
1022 --files-with-matches --name-only
1023 --files-without-match
1025 --and --or --not --all-match
1035 local cur
="${COMP_WORDS[COMP_CWORD]}"
1038 __gitcomp
"--all --info --man --web"
1042 __gitcomp
"$(__git_all_commands)
1043 attributes cli core-tutorial cvs-migration
1044 diffcore gitk glossary hooks ignore modules
1045 repository-layout tutorial tutorial-2
1052 local cur
="${COMP_WORDS[COMP_CWORD]}"
1056 false true umask group all world everybody
1057 " "" "${cur##--shared=}"
1061 __gitcomp
"--quiet --bare --template= --shared --shared="
1070 __git_has_doubledash
&& return
1072 local cur
="${COMP_WORDS[COMP_CWORD]}"
1075 __gitcomp
"--cached --deleted --modified --others --ignored
1076 --stage --directory --no-empty-directory --unmerged
1077 --killed --exclude= --exclude-from=
1078 --exclude-per-directory= --exclude-standard
1079 --error-unmatch --with-tree= --full-name
1080 --abbrev --ignored --exclude-per-directory
1090 __gitcomp
"$(__git_remotes)"
1098 # Options that go well for log, shortlog and gitk
1099 __git_log_common_options
="
1101 --branches --tags --remotes
1102 --first-parent --no-merges
1104 --max-age= --since= --after=
1105 --min-age= --until= --before=
1107 # Options that go well for log and gitk (not shortlog)
1108 __git_log_gitk_options
="
1109 --dense --sparse --full-history
1110 --simplify-merges --simplify-by-decoration
1113 # Options that go well for log and shortlog (not gitk)
1114 __git_log_shortlog_options
="
1115 --author= --committer= --grep=
1119 __git_log_pretty_formats
="oneline short medium full fuller email raw format:"
1120 __git_log_date_formats
="relative iso8601 rfc2822 short local default raw"
1124 __git_has_doubledash
&& return
1126 local cur
="${COMP_WORDS[COMP_CWORD]}"
1127 local g
="$(git rev-parse --git-dir 2>/dev/null)"
1129 if [ -f "$g/MERGE_HEAD" ]; then
1134 __gitcomp
"$__git_log_pretty_formats
1135 " "" "${cur##--pretty=}"
1139 __gitcomp
"$__git_log_pretty_formats
1140 " "" "${cur##--format=}"
1144 __gitcomp
"$__git_log_date_formats" "" "${cur##--date=}"
1149 $__git_log_common_options
1150 $__git_log_shortlog_options
1151 $__git_log_gitk_options
1152 --root --topo-order --date-order --reverse
1154 --abbrev-commit --abbrev=
1155 --relative-date --date=
1156 --pretty= --format= --oneline
1161 --parents --children
1163 $__git_diff_common_options
1164 --pickaxe-all --pickaxe-regex
1169 __git_complete_revlist
1172 __git_merge_options
="
1173 --no-commit --no-stat --log --no-log --squash --strategy
1174 --commit --stat --no-squash --ff --no-ff
1179 __git_complete_strategy
&& return
1181 local cur
="${COMP_WORDS[COMP_CWORD]}"
1184 __gitcomp
"$__git_merge_options"
1187 __gitcomp
"$(__git_refs)"
1192 local cur
="${COMP_WORDS[COMP_CWORD]}"
1195 __gitcomp
"$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"
1208 __gitcomp
"$(__git_refs)"
1213 local cur
="${COMP_WORDS[COMP_CWORD]}"
1216 __gitcomp
"--dry-run"
1225 __gitcomp
"--tags --all --stdin"
1230 __git_complete_strategy
&& return
1232 local cur
="${COMP_WORDS[COMP_CWORD]}"
1236 --rebase --no-rebase
1237 $__git_merge_options
1238 $__git_fetch_options
1243 __git_complete_remote_or_refspec
1248 local cur
="${COMP_WORDS[COMP_CWORD]}"
1249 case "${COMP_WORDS[COMP_CWORD-1]}" in
1251 __gitcomp
"$(__git_remotes)"
1256 __gitcomp
"$(__git_remotes)" "" "${cur##--repo=}"
1261 --all --mirror --tags --dry-run --force --verbose
1262 --receive-pack= --repo=
1267 __git_complete_remote_or_refspec
1272 local cur
="${COMP_WORDS[COMP_CWORD]}" dir
="$(__gitdir)"
1273 if [ -d "$dir"/rebase-apply
] ||
[ -d "$dir"/rebase-merge
]; then
1274 __gitcomp
"--continue --skip --abort"
1277 __git_complete_strategy
&& return
1280 __gitcomp
"--onto --merge --strategy --interactive"
1283 __gitcomp
"$(__git_refs)"
1286 __git_send_email_confirm_options
="always never auto cc compose"
1287 __git_send_email_suppresscc_options
="author self cc ccbody sob cccmd body all"
1291 local cur
="${COMP_WORDS[COMP_CWORD]}"
1295 $__git_send_email_confirm_options
1296 " "" "${cur##--confirm=}"
1301 $__git_send_email_suppresscc_options
1302 " "" "${cur##--suppress-cc=}"
1306 --smtp-encryption=*)
1307 __gitcomp
"ssl tls" "" "${cur##--smtp-encryption=}"
1311 __gitcomp
"--annotate --bcc --cc --cc-cmd --chain-reply-to
1312 --compose --confirm= --dry-run --envelope-sender
1314 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
1315 --no-suppress-from --no-thread --quiet
1316 --signed-off-by-cc --smtp-pass --smtp-server
1317 --smtp-server-port --smtp-encryption= --smtp-user
1318 --subject --suppress-cc= --suppress-from --thread --to
1319 --validate --no-validate"
1328 local cur
="${COMP_WORDS[COMP_CWORD]}"
1329 local prv
="${COMP_WORDS[COMP_CWORD-1]}"
1332 __gitcomp
"$(__git_remotes)"
1336 __gitcomp
"$(__git_refs)"
1340 local remote
="${prv#remote.}"
1341 remote
="${remote%.fetch}"
1342 __gitcomp
"$(__git_refs_remotes "$remote")"
1346 local remote
="${prv#remote.}"
1347 remote
="${remote%.push}"
1348 __gitcomp
"$(git --git-dir="$
(__gitdir
)" \
1349 for-each-ref --format='%(refname):%(refname)' \
1353 pull.twohead|pull.octopus
)
1354 __gitcomp
"$(__git_merge_strategies)"
1357 color.branch|color.
diff|color.interactive|color.status|color.ui
)
1358 __gitcomp
"always never auto"
1362 __gitcomp
"false true"
1367 normal black red green yellow blue magenta cyan white
1368 bold dim ul blink reverse
1373 __gitcomp
"man info web html"
1377 __gitcomp
"$__git_log_date_formats"
1380 sendemail.aliasesfiletype
)
1381 __gitcomp
"mutt mailrc pine elm gnus"
1385 __gitcomp
"$__git_send_email_confirm_options"
1388 sendemail.suppresscc
)
1389 __gitcomp
"$__git_send_email_suppresscc_options"
1400 --global --system --file=
1401 --list --replace-all
1402 --get --get-all --get-regexp
1403 --add --unset --unset-all
1404 --remove-section --rename-section
1409 local pfx
="${cur%.*}."
1411 __gitcomp
"remote merge mergeoptions" "$pfx" "$cur"
1415 local pfx
="${cur%.*}."
1417 __gitcomp
"$(__git_heads)" "$pfx" "$cur" "."
1421 local pfx
="${cur%.*}."
1424 argprompt cmd confirm needsfile noconsole norescan
1425 prompt revprompt revunmerged title
1430 local pfx
="${cur%.*}."
1432 __gitcomp
"cmd path" "$pfx" "$cur"
1436 local pfx
="${cur%.*}."
1438 __gitcomp
"cmd path" "$pfx" "$cur"
1442 local pfx
="${cur%.*}."
1444 __gitcomp
"cmd path trustExitCode" "$pfx" "$cur"
1448 local pfx
="${cur%.*}."
1450 __gitcomp
"$(__git_all_commands)" "$pfx" "$cur"
1454 local pfx
="${cur%.*}."
1457 url proxy fetch push mirror skipDefaultUpdate
1458 receivepack uploadpack tagopt
1463 local pfx
="${cur%.*}."
1465 __gitcomp
"$(__git_remotes)" "$pfx" "$cur" "."
1469 local pfx
="${cur%.*}."
1471 __gitcomp
"insteadof" "$pfx" "$cur"
1478 branch.autosetupmerge
1479 branch.autosetuprebase
1482 color.branch.current
1493 color.diff.whitespace
1498 color.interactive.header
1499 color.interactive.help
1500 color.interactive.prompt
1504 color.status.changed
1506 color.status.nobranch
1507 color.status.untracked
1508 color.status.updated
1515 core.deltaBaseCacheLimit
1519 core.fsyncobjectfiles
1521 core.ignoreCygwinFSTricks
1523 core.logAllRefUpdates
1524 core.loosecompression
1526 core.packedGitWindowSize
1528 core.preferSymlinkRefs
1531 core.repositoryFormatVersion
1533 core.sharedRepository
1536 core.warnAmbiguousRefs
1539 diff.autorefreshindex
1545 diff.suppressBlankEmpty
1557 format.subjectprefix
1566 gc.reflogexpireunreachable
1570 gitcvs.commitmsgannotation
1571 gitcvs.dbTableNamePrefix
1582 gui.copyblamethreshold
1586 gui.matchtrackingbranch
1587 gui.newbranchtemplate
1588 gui.pruneduringfetch
1589 gui.spellingdictionary
1605 i18n.logOutputEncoding
1610 imap.preformattedHTML
1619 interactive.singlekey
1632 mergetool.keepBackup
1635 pack.deltaCacheLimit
1648 receive.denyCurrentBranch
1650 receive.denyNonFastForwards
1653 repack.usedeltabaseoffset
1656 sendemail.aliasesfile
1657 sendemail.aliasesfiletype
1661 sendemail.chainreplyto
1663 sendemail.envelopesender
1665 sendemail.signedoffbycc
1666 sendemail.smtpencryption
1668 sendemail.smtpserver
1669 sendemail.smtpserverport
1671 sendemail.suppresscc
1672 sendemail.suppressfrom
1677 status.relativePaths
1678 status.showUntrackedFiles
1680 transfer.unpackLimit
1692 local subcommands
="add rename rm show prune update set-head"
1693 local subcommand
="$(__git_find_subcommand "$subcommands")"
1694 if [ -z "$subcommand" ]; then
1695 __gitcomp
"$subcommands"
1699 case "$subcommand" in
1700 rename|
rm|show|prune
)
1701 __gitcomp
"$(__git_remotes)"
1704 local i c
='' IFS
=$
'\n'
1705 for i
in $
(git
--git-dir="$(__gitdir)" config
--list); do
1723 __git_has_doubledash
&& return
1725 local cur
="${COMP_WORDS[COMP_CWORD]}"
1728 __gitcomp
"--merge --mixed --hard --soft"
1732 __gitcomp
"$(__git_refs)"
1737 local cur
="${COMP_WORDS[COMP_CWORD]}"
1740 __gitcomp
"--edit --mainline --no-edit --no-commit --signoff"
1744 __gitcomp
"$(__git_refs)"
1749 __git_has_doubledash
&& return
1751 local cur
="${COMP_WORDS[COMP_CWORD]}"
1754 __gitcomp
"--cached --dry-run --ignore-unmatch --quiet"
1763 __git_has_doubledash
&& return
1765 local cur
="${COMP_WORDS[COMP_CWORD]}"
1769 $__git_log_common_options
1770 $__git_log_shortlog_options
1771 --numbered --summary
1776 __git_complete_revlist
1781 __git_has_doubledash
&& return
1783 local cur
="${COMP_WORDS[COMP_CWORD]}"
1786 __gitcomp
"$__git_log_pretty_formats
1787 " "" "${cur##--pretty=}"
1791 __gitcomp
"$__git_log_pretty_formats
1792 " "" "${cur##--format=}"
1796 __gitcomp
"--pretty= --format=
1797 $__git_diff_common_options
1807 local cur
="${COMP_WORDS[COMP_CWORD]}"
1811 --all --remotes --topo-order --current --more=
1812 --list --independent --merge-base --no-name
1813 --sha1-name --topics --reflog
1818 __git_complete_revlist
1823 local subcommands
='save list show apply clear drop pop create branch'
1824 local subcommand
="$(__git_find_subcommand "$subcommands")"
1825 if [ -z "$subcommand" ]; then
1826 __gitcomp
"$subcommands"
1828 local cur
="${COMP_WORDS[COMP_CWORD]}"
1829 case "$subcommand,$cur" in
1831 __gitcomp
"--keep-index"
1836 show
,--*|drop
,--*|pop
,--*|branch
,--*)
1839 show
,*|apply
,*|drop
,*|pop
,*|branch
,*)
1840 __gitcomp
"$(git --git-dir="$
(__gitdir
)" stash list \
1841 | sed -n -e 's/:.*//p')"
1852 __git_has_doubledash
&& return
1854 local subcommands
="add status init update summary foreach sync"
1855 if [ -z "$(__git_find_subcommand "$subcommands")" ]; then
1856 local cur
="${COMP_WORDS[COMP_CWORD]}"
1859 __gitcomp
"--quiet --cached"
1862 __gitcomp
"$subcommands"
1872 init fetch clone rebase dcommit log find-rev
1873 set-tree commit-diff info create-ignore propget
1874 proplist show-ignore show-externals branch tag blame
1877 local subcommand
="$(__git_find_subcommand "$subcommands")"
1878 if [ -z "$subcommand" ]; then
1879 __gitcomp
"$subcommands"
1881 local remote_opts
="--username= --config-dir= --no-auth-cache"
1883 --follow-parent --authors-file= --repack=
1884 --no-metadata --use-svm-props --use-svnsync-props
1885 --log-window-size= --no-checkout --quiet
1886 --repack-flags --use-log-author --localtime
1887 --ignore-paths= $remote_opts
1890 --template= --shared= --trunk= --tags=
1891 --branches= --stdlayout --minimize-url
1892 --no-metadata --use-svm-props --use-svnsync-props
1893 --rewrite-root= --prefix= --use-log-author
1894 --add-author-from $remote_opts
1897 --edit --rmdir --find-copies-harder --copy-similarity=
1900 local cur
="${COMP_WORDS[COMP_CWORD]}"
1901 case "$subcommand,$cur" in
1903 __gitcomp
"--revision= --fetch-all $fc_opts"
1906 __gitcomp
"--revision= $fc_opts $init_opts"
1909 __gitcomp
"$init_opts"
1913 --merge --strategy= --verbose --dry-run
1914 --fetch-all --no-rebase --commit-url
1915 --revision $cmt_opts $fc_opts
1919 __gitcomp
"--stdin $cmt_opts $fc_opts"
1921 create-ignore
,--*|propget
,--*|proplist
,--*|show-ignore
,--*|\
1923 __gitcomp
"--revision="
1927 --limit= --revision= --verbose --incremental
1928 --oneline --show-commit --non-recursive
1929 --authors-file= --color
1934 --merge --verbose --strategy= --local
1935 --fetch-all --dry-run $fc_opts
1939 __gitcomp
"--message= --file= --revision= $cmt_opts"
1945 __gitcomp
"--dry-run --message --tag"
1948 __gitcomp
"--dry-run --message"
1951 __gitcomp
"--git-format"
1955 --config-dir= --ignore-paths= --minimize
1956 --no-auth-cache --username=
1969 while [ $c -lt $COMP_CWORD ]; do
1970 i
="${COMP_WORDS[c]}"
1973 __gitcomp
"$(__git_tags)"
1983 case "${COMP_WORDS[COMP_CWORD-1]}" in
1989 __gitcomp
"$(__git_tags)"
1995 __gitcomp
"$(__git_refs)"
2002 local i c
=1 command __git_dir
2004 while [ $c -lt $COMP_CWORD ]; do
2005 i
="${COMP_WORDS[c]}"
2007 --git-dir=*) __git_dir
="${i#--git-dir=}" ;;
2008 --bare) __git_dir
="." ;;
2009 --version|
-p|
--paginate) ;;
2010 --help) command="help"; break ;;
2011 *) command="$i"; break ;;
2016 if [ -z "$command" ]; then
2017 case "${COMP_WORDS[COMP_CWORD]}" in
2030 *) __gitcomp
"$(__git_porcelain_commands) $(__git_aliases)" ;;
2035 local expansion
=$
(__git_aliased_command
"$command")
2036 [ "$expansion" ] && command="$expansion"
2041 apply
) _git_apply
;;
2042 archive
) _git_archive
;;
2043 bisect
) _git_bisect
;;
2044 bundle
) _git_bundle
;;
2045 branch
) _git_branch
;;
2046 checkout
) _git_checkout
;;
2047 cherry
) _git_cherry
;;
2048 cherry-pick
) _git_cherry_pick
;;
2049 clean
) _git_clean
;;
2050 clone
) _git_clone
;;
2051 commit
) _git_commit
;;
2052 config
) _git_config
;;
2053 describe
) _git_describe
;;
2055 difftool
) _git_difftool
;;
2056 fetch
) _git_fetch
;;
2057 format-patch
) _git_format_patch
;;
2064 ls-files
) _git_ls_files
;;
2065 ls-remote
) _git_ls_remote
;;
2066 ls-tree
) _git_ls_tree
;;
2068 mergetool
) _git_mergetool
;;
2069 merge-base
) _git_merge_base
;;
2071 name-rev
) _git_name_rev
;;
2074 rebase
) _git_rebase
;;
2075 remote
) _git_remote
;;
2076 reset) _git_reset
;;
2077 revert
) _git_revert
;;
2079 send-email
) _git_send_email
;;
2080 shortlog
) _git_shortlog
;;
2082 show-branch
) _git_show_branch
;;
2083 stash
) _git_stash
;;
2085 submodule
) _git_submodule
;;
2088 whatchanged
) _git_log
;;
2095 __git_has_doubledash
&& return
2097 local cur
="${COMP_WORDS[COMP_CWORD]}"
2098 local g
="$(__gitdir)"
2100 if [ -f "$g/MERGE_HEAD" ]; then
2106 $__git_log_common_options
2107 $__git_log_gitk_options
2113 __git_complete_revlist
2116 complete
-o bashdefault
-o default
-o nospace
-F _git git
2>/dev
/null \
2117 || complete
-o default
-o nospace
-F _git git
2118 complete
-o bashdefault
-o default
-o nospace
-F _gitk gitk
2>/dev
/null \
2119 || complete
-o default
-o nospace
-F _gitk gitk
2121 # The following are necessary only for Cygwin, and only are needed
2122 # when the user has tab-completed the executable name and consequently
2123 # included the '.exe' suffix.
2125 if [ Cygwin
= "$(uname -o 2>/dev/null)" ]; then
2126 complete
-o bashdefault
-o default
-o nospace
-F _git git.exe
2>/dev
/null \
2127 || complete
-o default
-o nospace
-F _git git.exe