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
")"
102 elif [ -f "$g/MERGE_HEAD" ]; then
104 b
="$(git symbolic-ref HEAD 2>/dev/null)"
106 if [ -f "$g/BISECT_LOG" ]; then
109 if ! b
="$(git symbolic-ref HEAD 2>/dev/null)"; then
110 if ! b
="$(git describe --exact-match HEAD 2>/dev/null)"; then
111 if [ -r "$g/HEAD" ]; then
112 b
="$(cut -c1-7 "$g/HEAD
")..."
122 if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then
123 if [ "true" = "$(git config --bool core.bare 2>/dev/null)" ]; then
128 elif [ "true" = "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
129 if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ]; then
130 if [ "$(git config --bool bash.showDirtyState)" != "false" ]; then
131 git
diff --no-ext-diff --ignore-submodules \
132 --quiet --exit-code || w
="*"
133 if git rev-parse
--quiet --verify HEAD
>/dev
/null
; then
134 git diff-index
--cached --quiet \
135 --ignore-submodules HEAD
-- || i
="+"
144 if [ -n "${1-}" ]; then
145 printf "$1" "$c${b##refs/heads/}$w$i$r"
147 printf " (%s)" "$c${b##refs/heads/}$w$i$r"
153 # __gitcomp_1 requires 2 arguments
156 local c IFS
=' '$
'\t'$
'\n'
159 --*=*) printf %s$
'\n' "$c$2" ;;
160 *.
) printf %s$
'\n' "$c$2" ;;
161 *) printf %s$
'\n' "$c$2 " ;;
166 # __gitcomp accepts 1, 2, 3, or 4 arguments
167 # generates completion reply with compgen
170 local cur
="${COMP_WORDS[COMP_CWORD]}"
171 if [ $# -gt 2 ]; then
180 COMPREPLY
=($
(compgen
-P "${2-}" \
181 -W "$(__gitcomp_1 "${1-}" "${4-}")" \
187 # __git_heads accepts 0 or 1 arguments (to pass to __gitdir)
190 local cmd i is_hash
=y dir
="$(__gitdir "${1-}")"
191 if [ -d "$dir" ]; then
192 git
--git-dir="$dir" for-each-ref
--format='%(refname:short)' \
196 for i
in $
(git ls-remote
"${1-}" 2>/dev
/null
); do
197 case "$is_hash,$i" in
200 n
,refs
/heads
/*) is_hash
=y
; echo "${i#refs/heads/}" ;;
201 n
,*) is_hash
=y
; echo "$i" ;;
206 # __git_tags accepts 0 or 1 arguments (to pass to __gitdir)
209 local cmd i is_hash
=y dir
="$(__gitdir "${1-}")"
210 if [ -d "$dir" ]; then
211 git
--git-dir="$dir" for-each-ref
--format='%(refname:short)' \
215 for i
in $
(git ls-remote
"${1-}" 2>/dev
/null
); do
216 case "$is_hash,$i" in
219 n
,refs
/tags
/*) is_hash
=y
; echo "${i#refs/tags/}" ;;
220 n
,*) is_hash
=y
; echo "$i" ;;
225 # __git_refs accepts 0 or 1 arguments (to pass to __gitdir)
228 local i is_hash
=y dir
="$(__gitdir "${1-}")"
229 local cur
="${COMP_WORDS[COMP_CWORD]}" format refs
230 if [ -d "$dir" ]; then
237 if [ -e "$dir/HEAD" ]; then echo HEAD
; fi
238 format
="refname:short"
239 refs
="refs/tags refs/heads refs/remotes"
242 git
--git-dir="$dir" for-each-ref
--format="%($format)" \
246 for i
in $
(git ls-remote
"$dir" 2>/dev
/null
); do
247 case "$is_hash,$i" in
250 n
,refs
/tags
/*) is_hash
=y
; echo "${i#refs/tags/}" ;;
251 n
,refs
/heads
/*) is_hash
=y
; echo "${i#refs/heads/}" ;;
252 n
,refs
/remotes
/*) is_hash
=y
; echo "${i#refs/remotes/}" ;;
253 n
,*) is_hash
=y
; echo "$i" ;;
258 # __git_refs2 requires 1 argument (to pass to __git_refs)
262 for i
in $
(__git_refs
"$1"); do
267 # __git_refs_remotes requires 1 argument (to pass to ls-remote)
268 __git_refs_remotes
()
270 local cmd i is_hash
=y
271 for i
in $
(git ls-remote
"$1" 2>/dev
/null
); do
272 case "$is_hash,$i" in
275 echo "$i:refs/remotes/$1/${i#refs/heads/}"
279 n
,refs
/tags
/*) is_hash
=y
;;
287 local i ngoff IFS
=$
'\n' d
="$(__gitdir)"
288 shopt -q nullglob || ngoff
=1
290 for i
in "$d/remotes"/*; do
291 echo ${i#$d/remotes/}
293 [ "$ngoff" ] && shopt -u nullglob
294 for i
in $
(git
--git-dir="$d" config
--list); do
304 __git_merge_strategies
()
306 if [ -n "${__git_merge_strategylist-}" ]; then
307 echo "$__git_merge_strategylist"
310 git merge
-s help 2>&1 |
311 sed -n -e '/[Aa]vailable strategies are: /,/^$/{
319 __git_merge_strategylist
=
320 __git_merge_strategylist
=$
(__git_merge_strategies
2>/dev
/null
)
322 __git_complete_file
()
324 local pfx
ls ref cur
="${COMP_WORDS[COMP_CWORD]}"
341 case "$COMP_WORDBREAKS" in
343 *) pfx
="$ref:$pfx" ;;
347 COMPREPLY
=($
(compgen
-P "$pfx" \
348 -W "$(git --git-dir="$
(__gitdir
)" ls-tree "$ls" \
349 | sed '/^100... blob /{
365 __gitcomp
"$(__git_refs)"
370 __git_complete_revlist
()
372 local pfx cur
="${COMP_WORDS[COMP_CWORD]}"
377 __gitcomp
"$(__git_refs)" "$pfx" "$cur"
382 __gitcomp
"$(__git_refs)" "$pfx" "$cur"
385 __gitcomp
"$(__git_refs)"
390 __git_complete_remote_or_refspec
()
392 local cmd
="${COMP_WORDS[1]}"
393 local cur
="${COMP_WORDS[COMP_CWORD]}"
394 local i c
=2 remote
="" pfx
="" lhs
=1 no_complete_refspec
=0
395 while [ $c -lt $COMP_CWORD ]; do
398 --all|
--mirror) [ "$cmd" = "push" ] && no_complete_refspec
=1 ;;
400 *) remote
="$i"; break ;;
404 if [ -z "$remote" ]; then
405 __gitcomp
"$(__git_remotes)"
408 if [ $no_complete_refspec = 1 ]; then
412 [ "$remote" = "." ] && remote
=
415 case "$COMP_WORDBREAKS" in
417 *) pfx
="${cur%%:*}:" ;;
429 if [ $lhs = 1 ]; then
430 __gitcomp
"$(__git_refs2 "$remote")" "$pfx" "$cur"
432 __gitcomp
"$(__git_refs)" "$pfx" "$cur"
436 if [ $lhs = 1 ]; then
437 __gitcomp
"$(__git_refs "$remote")" "$pfx" "$cur"
439 __gitcomp
"$(__git_refs)" "$pfx" "$cur"
443 if [ $lhs = 1 ]; then
444 __gitcomp
"$(__git_refs)" "$pfx" "$cur"
446 __gitcomp
"$(__git_refs "$remote")" "$pfx" "$cur"
452 __git_complete_strategy
()
454 case "${COMP_WORDS[COMP_CWORD-1]}" in
456 __gitcomp
"$(__git_merge_strategies)"
459 local cur
="${COMP_WORDS[COMP_CWORD]}"
462 __gitcomp
"$(__git_merge_strategies)" "" "${cur##--strategy=}"
469 __git_all_commands
()
471 if [ -n "${__git_all_commandlist-}" ]; then
472 echo "$__git_all_commandlist"
476 for i
in $
(git
help -a|
egrep '^ ')
479 *--*) : helper pattern
;;
484 __git_all_commandlist
=
485 __git_all_commandlist
="$(__git_all_commands 2>/dev/null)"
487 __git_porcelain_commands
()
489 if [ -n "${__git_porcelain_commandlist-}" ]; then
490 echo "$__git_porcelain_commandlist"
494 for i
in "help" $
(__git_all_commands
)
497 *--*) : helper pattern
;;
498 applymbox
) : ask gittus
;;
499 applypatch
) : ask gittus
;;
500 archimport
) : import
;;
501 cat-file
) : plumbing
;;
502 check-attr
) : plumbing
;;
503 check-ref-format
) : plumbing
;;
504 checkout-index
) : plumbing
;;
505 commit-tree
) : plumbing
;;
506 count-objects
) : infrequent
;;
507 cvsexportcommit
) : export;;
508 cvsimport
) : import
;;
509 cvsserver
) : daemon
;;
511 diff-files
) : plumbing
;;
512 diff-index
) : plumbing
;;
513 diff-tree
) : plumbing
;;
514 fast-import
) : import
;;
515 fast-export
) : export;;
516 fsck-objects
) : plumbing
;;
517 fetch-pack
) : plumbing
;;
518 fmt-merge-msg
) : plumbing
;;
519 for-each-ref
) : plumbing
;;
520 hash-object
) : plumbing
;;
521 http-
*) : transport
;;
522 index-pack
) : plumbing
;;
523 init-db
) : deprecated
;;
524 local-fetch
) : plumbing
;;
525 lost-found
) : infrequent
;;
526 ls-files
) : plumbing
;;
527 ls-remote
) : plumbing
;;
528 ls-tree
) : plumbing
;;
529 mailinfo
) : plumbing
;;
530 mailsplit
) : plumbing
;;
531 merge-
*) : plumbing
;;
534 pack-objects
) : plumbing
;;
535 pack-redundant
) : plumbing
;;
536 pack-refs
) : plumbing
;;
537 parse-remote
) : plumbing
;;
538 patch-id
) : plumbing
;;
539 peek-remote
) : plumbing
;;
541 prune-packed
) : plumbing
;;
542 quiltimport
) : import
;;
543 read-tree
) : plumbing
;;
544 receive-pack
) : plumbing
;;
546 repo-config
) : deprecated
;;
548 rev-list
) : plumbing
;;
549 rev-parse
) : plumbing
;;
550 runstatus
) : plumbing
;;
551 sh-setup
) : internal
;;
553 show-ref
) : plumbing
;;
554 send-pack
) : plumbing
;;
555 show-index
) : plumbing
;;
557 stripspace
) : plumbing
;;
558 symbolic-ref
) : plumbing
;;
559 tar-tree
) : deprecated
;;
560 unpack-file
) : plumbing
;;
561 unpack-objects
) : plumbing
;;
562 update-index
) : plumbing
;;
563 update-ref
) : plumbing
;;
564 update-server-info
) : daemon
;;
565 upload-archive
) : plumbing
;;
566 upload-pack
) : plumbing
;;
567 write-tree
) : plumbing
;;
569 verify-pack
) : infrequent
;;
570 verify-tag
) : plumbing
;;
575 __git_porcelain_commandlist
=
576 __git_porcelain_commandlist
="$(__git_porcelain_commands 2>/dev/null)"
581 for i
in $
(git
--git-dir="$(__gitdir)" config
--list); do
591 # __git_aliased_command requires 1 argument
592 __git_aliased_command
()
594 local word cmdline
=$
(git
--git-dir="$(__gitdir)" \
595 config
--get "alias.$1")
596 for word
in $cmdline; do
597 if [ "${word##-*}" ]; then
604 # __git_find_subcommand requires 1 argument
605 __git_find_subcommand
()
607 local word subcommand c
=1
609 while [ $c -lt $COMP_CWORD ]; do
610 word
="${COMP_WORDS[c]}"
611 for subcommand
in $1; do
612 if [ "$subcommand" = "$word" ]; then
621 __git_has_doubledash
()
624 while [ $c -lt $COMP_CWORD ]; do
625 if [ "--" = "${COMP_WORDS[c]}" ]; then
633 __git_whitespacelist
="nowarn warn error error-all fix"
637 local cur
="${COMP_WORDS[COMP_CWORD]}" dir
="$(__gitdir)"
638 if [ -d "$dir"/rebase-apply
]; then
639 __gitcomp
"--skip --resolved --abort"
644 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
649 --3way --committer-date-is-author-date --ignore-date
650 --interactive --keep --no-utf8 --signoff --utf8
660 local cur
="${COMP_WORDS[COMP_CWORD]}"
663 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
668 --stat --numstat --summary --check --index
669 --cached --index-info --reverse --reject --unidiff-zero
670 --apply --no-add --exclude=
671 --whitespace= --inaccurate-eof --verbose
680 __git_has_doubledash
&& return
682 local cur
="${COMP_WORDS[COMP_CWORD]}"
686 --interactive --refresh --patch --update --dry-run
687 --ignore-errors --intent-to-add
696 local cur
="${COMP_WORDS[COMP_CWORD]}"
699 __gitcomp
"$(git archive --list)" "" "${cur##--format=}"
703 __gitcomp
"$(__git_remotes)" "" "${cur##--remote=}"
708 --format= --list --verbose
709 --prefix= --remote= --exec=
719 __git_has_doubledash
&& return
721 local subcommands
="start bad good skip reset visualize replay log run"
722 local subcommand
="$(__git_find_subcommand "$subcommands")"
723 if [ -z "$subcommand" ]; then
724 __gitcomp
"$subcommands"
728 case "$subcommand" in
730 __gitcomp
"$(__git_refs)"
740 local i c
=1 only_local_ref
="n" has_r
="n"
742 while [ $c -lt $COMP_CWORD ]; do
745 -d|
-m) only_local_ref
="y" ;;
751 case "${COMP_WORDS[COMP_CWORD]}" in
754 --color --no-color --verbose --abbrev= --no-abbrev
755 --track --no-track --contains --merged --no-merged
759 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
760 __gitcomp
"$(__git_heads)"
762 __gitcomp
"$(__git_refs)"
770 local cmd
="${COMP_WORDS[2]}"
771 case "$COMP_CWORD" in
773 __gitcomp
"create list-heads verify unbundle"
781 __git_complete_revlist
790 __git_has_doubledash
&& return
792 __gitcomp
"$(__git_refs)"
797 __gitcomp
"$(__git_refs)"
802 local cur
="${COMP_WORDS[COMP_CWORD]}"
805 __gitcomp
"--edit --no-commit"
808 __gitcomp
"$(__git_refs)"
815 __git_has_doubledash
&& return
817 local cur
="${COMP_WORDS[COMP_CWORD]}"
820 __gitcomp
"--dry-run --quiet"
829 local cur
="${COMP_WORDS[COMP_CWORD]}"
854 __git_has_doubledash
&& return
856 local cur
="${COMP_WORDS[COMP_CWORD]}"
860 --all --author= --signoff --verify --no-verify
861 --edit --amend --include --only --interactive
870 local cur
="${COMP_WORDS[COMP_CWORD]}"
874 --all --tags --contains --abbrev= --candidates=
875 --exact-match --debug --long --match --always
879 __gitcomp
"$(__git_refs)"
882 __git_diff_common_options
="--stat --numstat --shortstat --summary
883 --patch-with-stat --name-only --name-status --color
884 --no-color --color-words --no-renames --check
885 --full-index --binary --abbrev --diff-filter=
887 --text --ignore-space-at-eol --ignore-space-change
888 --ignore-all-space --exit-code --quiet --ext-diff
890 --no-prefix --src-prefix= --dst-prefix=
891 --inter-hunk-context=
898 __git_has_doubledash
&& return
900 local cur
="${COMP_WORDS[COMP_CWORD]}"
903 __gitcomp
"--cached --staged --pickaxe-all --pickaxe-regex
904 --base --ours --theirs
905 $__git_diff_common_options
913 __git_mergetools_common
="diffuse ecmerge emerge kdiff3 meld opendiff
914 tkdiff vimdiff gvimdiff xxdiff
919 local cur
="${COMP_WORDS[COMP_CWORD]}"
922 __gitcomp
"$__git_mergetools_common kompare" "" "${cur##--tool=}"
933 __git_fetch_options
="
934 --quiet --verbose --append --upload-pack --force --keep --depth=
940 local cur
="${COMP_WORDS[COMP_CWORD]}"
943 __gitcomp
"$__git_fetch_options"
947 __git_complete_remote_or_refspec
952 local cur
="${COMP_WORDS[COMP_CWORD]}"
957 " "" "${cur##--thread=}"
962 --stdout --attach --no-attach --thread --thread=
964 --numbered --start-number
969 --full-index --binary
972 --no-prefix --src-prefix= --dst-prefix=
973 --inline --suffix= --ignore-if-in-upstream
979 __git_complete_revlist
984 local cur
="${COMP_WORDS[COMP_CWORD]}"
988 --tags --root --unreachable --cache --no-reflogs --full
989 --strict --verbose --lost-found
999 local cur
="${COMP_WORDS[COMP_CWORD]}"
1002 __gitcomp
"--prune --aggressive"
1011 __git_has_doubledash
&& return
1013 local cur
="${COMP_WORDS[COMP_CWORD]}"
1018 --text --ignore-case --word-regexp --invert-match
1020 --extended-regexp --basic-regexp --fixed-strings
1021 --files-with-matches --name-only
1022 --files-without-match
1024 --and --or --not --all-match
1034 local cur
="${COMP_WORDS[COMP_CWORD]}"
1037 __gitcomp
"--all --info --man --web"
1041 __gitcomp
"$(__git_all_commands)
1042 attributes cli core-tutorial cvs-migration
1043 diffcore gitk glossary hooks ignore modules
1044 repository-layout tutorial tutorial-2
1051 local cur
="${COMP_WORDS[COMP_CWORD]}"
1055 false true umask group all world everybody
1056 " "" "${cur##--shared=}"
1060 __gitcomp
"--quiet --bare --template= --shared --shared="
1069 __git_has_doubledash
&& return
1071 local cur
="${COMP_WORDS[COMP_CWORD]}"
1074 __gitcomp
"--cached --deleted --modified --others --ignored
1075 --stage --directory --no-empty-directory --unmerged
1076 --killed --exclude= --exclude-from=
1077 --exclude-per-directory= --exclude-standard
1078 --error-unmatch --with-tree= --full-name
1079 --abbrev --ignored --exclude-per-directory
1089 __gitcomp
"$(__git_remotes)"
1097 # Options that go well for log, shortlog and gitk
1098 __git_log_common_options
="
1100 --branches --tags --remotes
1101 --first-parent --no-merges
1103 --max-age= --since= --after=
1104 --min-age= --until= --before=
1106 # Options that go well for log and gitk (not shortlog)
1107 __git_log_gitk_options
="
1108 --dense --sparse --full-history
1109 --simplify-merges --simplify-by-decoration
1112 # Options that go well for log and shortlog (not gitk)
1113 __git_log_shortlog_options
="
1114 --author= --committer= --grep=
1118 __git_log_pretty_formats
="oneline short medium full fuller email raw format:"
1122 __git_has_doubledash
&& return
1124 local cur
="${COMP_WORDS[COMP_CWORD]}"
1125 local g
="$(git rev-parse --git-dir 2>/dev/null)"
1127 if [ -f "$g/MERGE_HEAD" ]; then
1132 __gitcomp
"$__git_log_pretty_formats
1133 " "" "${cur##--pretty=}"
1137 __gitcomp
"$__git_log_pretty_formats
1138 " "" "${cur##--format=}"
1143 relative iso8601 rfc2822 short local default
1144 " "" "${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)"
1288 local cur
="${COMP_WORDS[COMP_CWORD]}"
1291 __gitcomp
"--annotate --bcc --cc --cc-cmd --chain-reply-to
1292 --compose --dry-run --envelope-sender --from --identity
1293 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
1294 --no-suppress-from --no-thread --quiet
1295 --signed-off-by-cc --smtp-pass --smtp-server
1296 --smtp-server-port --smtp-ssl --smtp-user --subject
1297 --suppress-cc --suppress-from --thread --to
1298 --validate --no-validate"
1307 local cur
="${COMP_WORDS[COMP_CWORD]}"
1308 local prv
="${COMP_WORDS[COMP_CWORD-1]}"
1311 __gitcomp
"$(__git_remotes)"
1315 __gitcomp
"$(__git_refs)"
1319 local remote
="${prv#remote.}"
1320 remote
="${remote%.fetch}"
1321 __gitcomp
"$(__git_refs_remotes "$remote")"
1325 local remote
="${prv#remote.}"
1326 remote
="${remote%.push}"
1327 __gitcomp
"$(git --git-dir="$
(__gitdir
)" \
1328 for-each-ref --format='%(refname):%(refname)' \
1332 pull.twohead|pull.octopus
)
1333 __gitcomp
"$(__git_merge_strategies)"
1336 color.branch|color.
diff|color.interactive|color.status|color.ui
)
1337 __gitcomp
"always never auto"
1341 __gitcomp
"false true"
1346 normal black red green yellow blue magenta cyan white
1347 bold dim ul blink reverse
1359 --global --system --file=
1360 --list --replace-all
1361 --get --get-all --get-regexp
1362 --add --unset --unset-all
1363 --remove-section --rename-section
1368 local pfx
="${cur%.*}."
1370 __gitcomp
"remote merge mergeoptions" "$pfx" "$cur"
1374 local pfx
="${cur%.*}."
1376 __gitcomp
"$(__git_heads)" "$pfx" "$cur" "."
1380 local pfx
="${cur%.*}."
1383 url proxy fetch push mirror skipDefaultUpdate
1384 receivepack uploadpack tagopt
1389 local pfx
="${cur%.*}."
1391 __gitcomp
"$(__git_remotes)" "$pfx" "$cur" "."
1398 branch.autosetupmerge
1399 branch.autosetuprebase
1402 color.branch.current
1413 color.diff.whitespace
1418 color.interactive.header
1419 color.interactive.help
1420 color.interactive.prompt
1424 color.status.changed
1426 color.status.nobranch
1427 color.status.untracked
1428 color.status.updated
1435 core.deltaBaseCacheLimit
1439 core.fsyncobjectfiles
1441 core.ignoreCygwinFSTricks
1443 core.logAllRefUpdates
1444 core.loosecompression
1446 core.packedGitWindowSize
1448 core.preferSymlinkRefs
1451 core.repositoryFormatVersion
1453 core.sharedRepository
1456 core.warnAmbiguousRefs
1459 diff.autorefreshindex
1465 diff.suppressBlankEmpty
1476 format.subjectprefix
1485 gc.reflogexpireunreachable
1489 gitcvs.commitmsgannotation
1490 gitcvs.dbTableNamePrefix
1500 gui.copyblamethreshold
1504 gui.matchtrackingbranch
1505 gui.newbranchtemplate
1506 gui.pruneduringfetch
1507 gui.spellingdictionary
1523 i18n.logOutputEncoding
1528 imap.preformattedHTML
1537 interactive.singlekey
1548 mergetool.keepBackup
1551 pack.deltaCacheLimit
1563 receive.denyCurrentBranch
1565 receive.denyNonFastForwards
1568 repack.usedeltabaseoffset
1571 sendemail.aliasesfile
1572 sendemail.aliasesfiletype
1576 sendemail.chainreplyto
1578 sendemail.envelopesender
1580 sendemail.signedoffbycc
1581 sendemail.smtpencryption
1583 sendemail.smtpserver
1584 sendemail.smtpserverport
1586 sendemail.suppresscc
1587 sendemail.suppressfrom
1592 status.relativePaths
1593 status.showUntrackedFiles
1595 transfer.unpackLimit
1606 local subcommands
="add rename rm show prune update set-head"
1607 local subcommand
="$(__git_find_subcommand "$subcommands")"
1608 if [ -z "$subcommand" ]; then
1609 __gitcomp
"$subcommands"
1613 case "$subcommand" in
1614 rename|
rm|show|prune
)
1615 __gitcomp
"$(__git_remotes)"
1618 local i c
='' IFS
=$
'\n'
1619 for i
in $
(git
--git-dir="$(__gitdir)" config
--list); do
1637 __git_has_doubledash
&& return
1639 local cur
="${COMP_WORDS[COMP_CWORD]}"
1642 __gitcomp
"--merge --mixed --hard --soft"
1646 __gitcomp
"$(__git_refs)"
1651 local cur
="${COMP_WORDS[COMP_CWORD]}"
1654 __gitcomp
"--edit --mainline --no-edit --no-commit --signoff"
1658 __gitcomp
"$(__git_refs)"
1663 __git_has_doubledash
&& return
1665 local cur
="${COMP_WORDS[COMP_CWORD]}"
1668 __gitcomp
"--cached --dry-run --ignore-unmatch --quiet"
1677 __git_has_doubledash
&& return
1679 local cur
="${COMP_WORDS[COMP_CWORD]}"
1683 $__git_log_common_options
1684 $__git_log_shortlog_options
1685 --numbered --summary
1690 __git_complete_revlist
1695 __git_has_doubledash
&& return
1697 local cur
="${COMP_WORDS[COMP_CWORD]}"
1700 __gitcomp
"$__git_log_pretty_formats
1701 " "" "${cur##--pretty=}"
1705 __gitcomp
"$__git_log_pretty_formats
1706 " "" "${cur##--format=}"
1710 __gitcomp
"--pretty= --format=
1711 $__git_diff_common_options
1721 local cur
="${COMP_WORDS[COMP_CWORD]}"
1725 --all --remotes --topo-order --current --more=
1726 --list --independent --merge-base --no-name
1727 --sha1-name --topics --reflog
1732 __git_complete_revlist
1737 local subcommands
='save list show apply clear drop pop create branch'
1738 local subcommand
="$(__git_find_subcommand "$subcommands")"
1739 if [ -z "$subcommand" ]; then
1740 __gitcomp
"$subcommands"
1742 local cur
="${COMP_WORDS[COMP_CWORD]}"
1743 case "$subcommand,$cur" in
1745 __gitcomp
"--keep-index"
1750 show
,--*|drop
,--*|pop
,--*|branch
,--*)
1753 show
,*|apply
,*|drop
,*|pop
,*|branch
,*)
1754 __gitcomp
"$(git --git-dir="$
(__gitdir
)" stash list \
1755 | sed -n -e 's/:.*//p')"
1766 __git_has_doubledash
&& return
1768 local subcommands
="add status init update summary foreach sync"
1769 if [ -z "$(__git_find_subcommand "$subcommands")" ]; then
1770 local cur
="${COMP_WORDS[COMP_CWORD]}"
1773 __gitcomp
"--quiet --cached"
1776 __gitcomp
"$subcommands"
1786 init fetch clone rebase dcommit log find-rev
1787 set-tree commit-diff info create-ignore propget
1788 proplist show-ignore show-externals branch tag blame
1791 local subcommand
="$(__git_find_subcommand "$subcommands")"
1792 if [ -z "$subcommand" ]; then
1793 __gitcomp
"$subcommands"
1795 local remote_opts
="--username= --config-dir= --no-auth-cache"
1797 --follow-parent --authors-file= --repack=
1798 --no-metadata --use-svm-props --use-svnsync-props
1799 --log-window-size= --no-checkout --quiet
1800 --repack-flags --use-log-author --localtime
1801 --ignore-paths= $remote_opts
1804 --template= --shared= --trunk= --tags=
1805 --branches= --stdlayout --minimize-url
1806 --no-metadata --use-svm-props --use-svnsync-props
1807 --rewrite-root= --prefix= --use-log-author
1808 --add-author-from $remote_opts
1811 --edit --rmdir --find-copies-harder --copy-similarity=
1814 local cur
="${COMP_WORDS[COMP_CWORD]}"
1815 case "$subcommand,$cur" in
1817 __gitcomp
"--revision= --fetch-all $fc_opts"
1820 __gitcomp
"--revision= $fc_opts $init_opts"
1823 __gitcomp
"$init_opts"
1827 --merge --strategy= --verbose --dry-run
1828 --fetch-all --no-rebase --commit-url
1829 --revision $cmt_opts $fc_opts
1833 __gitcomp
"--stdin $cmt_opts $fc_opts"
1835 create-ignore
,--*|propget
,--*|proplist
,--*|show-ignore
,--*|\
1837 __gitcomp
"--revision="
1841 --limit= --revision= --verbose --incremental
1842 --oneline --show-commit --non-recursive
1843 --authors-file= --color
1848 --merge --verbose --strategy= --local
1849 --fetch-all --dry-run $fc_opts
1853 __gitcomp
"--message= --file= --revision= $cmt_opts"
1859 __gitcomp
"--dry-run --message --tag"
1862 __gitcomp
"--dry-run --message"
1865 __gitcomp
"--git-format"
1869 --config-dir= --ignore-paths= --minimize
1870 --no-auth-cache --username=
1883 while [ $c -lt $COMP_CWORD ]; do
1884 i
="${COMP_WORDS[c]}"
1887 __gitcomp
"$(__git_tags)"
1897 case "${COMP_WORDS[COMP_CWORD-1]}" in
1903 __gitcomp
"$(__git_tags)"
1909 __gitcomp
"$(__git_refs)"
1916 local i c
=1 command __git_dir
1918 while [ $c -lt $COMP_CWORD ]; do
1919 i
="${COMP_WORDS[c]}"
1921 --git-dir=*) __git_dir
="${i#--git-dir=}" ;;
1922 --bare) __git_dir
="." ;;
1923 --version|
-p|
--paginate) ;;
1924 --help) command="help"; break ;;
1925 *) command="$i"; break ;;
1930 if [ -z "$command" ]; then
1931 case "${COMP_WORDS[COMP_CWORD]}" in
1944 *) __gitcomp
"$(__git_porcelain_commands) $(__git_aliases)" ;;
1949 local expansion
=$
(__git_aliased_command
"$command")
1950 [ "$expansion" ] && command="$expansion"
1955 apply
) _git_apply
;;
1956 archive
) _git_archive
;;
1957 bisect
) _git_bisect
;;
1958 bundle
) _git_bundle
;;
1959 branch
) _git_branch
;;
1960 checkout
) _git_checkout
;;
1961 cherry
) _git_cherry
;;
1962 cherry-pick
) _git_cherry_pick
;;
1963 clean
) _git_clean
;;
1964 clone
) _git_clone
;;
1965 commit
) _git_commit
;;
1966 config
) _git_config
;;
1967 describe
) _git_describe
;;
1969 difftool
) _git_difftool
;;
1970 fetch
) _git_fetch
;;
1971 format-patch
) _git_format_patch
;;
1978 ls-files
) _git_ls_files
;;
1979 ls-remote
) _git_ls_remote
;;
1980 ls-tree
) _git_ls_tree
;;
1982 mergetool
) _git_mergetool
;;
1983 merge-base
) _git_merge_base
;;
1985 name-rev
) _git_name_rev
;;
1988 rebase
) _git_rebase
;;
1989 remote
) _git_remote
;;
1990 reset) _git_reset
;;
1991 revert
) _git_revert
;;
1993 send-email
) _git_send_email
;;
1994 shortlog
) _git_shortlog
;;
1996 show-branch
) _git_show_branch
;;
1997 stash
) _git_stash
;;
1999 submodule
) _git_submodule
;;
2002 whatchanged
) _git_log
;;
2009 __git_has_doubledash
&& return
2011 local cur
="${COMP_WORDS[COMP_CWORD]}"
2012 local g
="$(__gitdir)"
2014 if [ -f "$g/MERGE_HEAD" ]; then
2020 $__git_log_common_options
2021 $__git_log_gitk_options
2027 __git_complete_revlist
2030 complete
-o bashdefault
-o default
-o nospace
-F _git git
2>/dev
/null \
2031 || complete
-o default
-o nospace
-F _git git
2032 complete
-o bashdefault
-o default
-o nospace
-F _gitk gitk
2>/dev
/null \
2033 || complete
-o default
-o nospace
-F _gitk gitk
2035 # The following are necessary only for Cygwin, and only are needed
2036 # when the user has tab-completed the executable name and consequently
2037 # included the '.exe' suffix.
2039 if [ Cygwin
= "$(uname -o 2>/dev/null)" ]; then
2040 complete
-o bashdefault
-o default
-o nospace
-F _git git.exe
2>/dev
/null \
2041 || complete
-o default
-o nospace
-F _git git.exe