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 [ -f "$g/rebase-merge/interactive" ]; then
89 b
="$(cat "$g/rebase-merge
/head-name
")"
90 elif [ -d "$g/rebase-merge" ]; then
92 b
="$(cat "$g/rebase-merge
/head-name
")"
94 if [ -d "$g/rebase-apply" ]; then
95 if [ -f "$g/rebase-apply/rebasing" ]; then
97 elif [ -f "$g/rebase-apply/applying" ]; then
102 elif [ -f "$g/MERGE_HEAD" ]; then
104 elif [ -f "$g/BISECT_LOG" ]; then
108 b
="$(git symbolic-ref HEAD 2>/dev/null)" ||
{
111 case "${GIT_PS1_DESCRIBE_STYLE-}" in
113 git describe --contains HEAD ;;
115 git describe --contains --all HEAD ;;
119 git describe --exact-match HEAD ;;
120 esac 2>/dev/null)" ||
122 b
="$(cut -c1-7 "$g/HEAD
" 2>/dev/null)..." ||
132 if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then
133 if [ "true" = "$(git rev-parse --is-bare-repository 2>/dev/null)" ]; then
138 elif [ "true" = "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
139 if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ]; then
140 if [ "$(git config --bool bash.showDirtyState)" != "false" ]; then
141 git
diff --no-ext-diff --ignore-submodules \
142 --quiet --exit-code || w
="*"
143 if git rev-parse
--quiet --verify HEAD
>/dev
/null
; then
144 git diff-index
--cached --quiet \
145 --ignore-submodules HEAD
-- || i
="+"
153 if [ -n "${1-}" ]; then
154 printf "$1" "$c${b##refs/heads/}$w$i$r"
156 printf " (%s)" "$c${b##refs/heads/}$w$i$r"
161 # __gitcomp_1 requires 2 arguments
164 local c IFS
=' '$
'\t'$
'\n'
167 --*=*) printf %s$
'\n' "$c$2" ;;
168 *.
) printf %s$
'\n' "$c$2" ;;
169 *) printf %s$
'\n' "$c$2 " ;;
174 # __gitcomp accepts 1, 2, 3, or 4 arguments
175 # generates completion reply with compgen
178 local cur
="${COMP_WORDS[COMP_CWORD]}"
179 if [ $# -gt 2 ]; then
188 COMPREPLY
=($
(compgen
-P "${2-}" \
189 -W "$(__gitcomp_1 "${1-}" "${4-}")" \
195 # __git_heads accepts 0 or 1 arguments (to pass to __gitdir)
198 local cmd i is_hash
=y dir
="$(__gitdir "${1-}")"
199 if [ -d "$dir" ]; then
200 git
--git-dir="$dir" for-each-ref
--format='%(refname:short)' \
204 for i
in $
(git ls-remote
"${1-}" 2>/dev
/null
); do
205 case "$is_hash,$i" in
208 n
,refs
/heads
/*) is_hash
=y
; echo "${i#refs/heads/}" ;;
209 n
,*) is_hash
=y
; echo "$i" ;;
214 # __git_tags accepts 0 or 1 arguments (to pass to __gitdir)
217 local cmd i is_hash
=y dir
="$(__gitdir "${1-}")"
218 if [ -d "$dir" ]; then
219 git
--git-dir="$dir" for-each-ref
--format='%(refname:short)' \
223 for i
in $
(git ls-remote
"${1-}" 2>/dev
/null
); do
224 case "$is_hash,$i" in
227 n
,refs
/tags
/*) is_hash
=y
; echo "${i#refs/tags/}" ;;
228 n
,*) is_hash
=y
; echo "$i" ;;
233 # __git_refs accepts 0 or 1 arguments (to pass to __gitdir)
236 local i is_hash
=y dir
="$(__gitdir "${1-}")"
237 local cur
="${COMP_WORDS[COMP_CWORD]}" format refs
238 if [ -d "$dir" ]; then
245 if [ -e "$dir/HEAD" ]; then echo HEAD
; fi
246 format
="refname:short"
247 refs
="refs/tags refs/heads refs/remotes"
250 git
--git-dir="$dir" for-each-ref
--format="%($format)" \
254 for i
in $
(git ls-remote
"$dir" 2>/dev
/null
); do
255 case "$is_hash,$i" in
258 n
,refs
/tags
/*) is_hash
=y
; echo "${i#refs/tags/}" ;;
259 n
,refs
/heads
/*) is_hash
=y
; echo "${i#refs/heads/}" ;;
260 n
,refs
/remotes
/*) is_hash
=y
; echo "${i#refs/remotes/}" ;;
261 n
,*) is_hash
=y
; echo "$i" ;;
266 # __git_refs2 requires 1 argument (to pass to __git_refs)
270 for i
in $
(__git_refs
"$1"); do
275 # __git_refs_remotes requires 1 argument (to pass to ls-remote)
276 __git_refs_remotes
()
278 local cmd i is_hash
=y
279 for i
in $
(git ls-remote
"$1" 2>/dev
/null
); do
280 case "$is_hash,$i" in
283 echo "$i:refs/remotes/$1/${i#refs/heads/}"
287 n
,refs
/tags
/*) is_hash
=y
;;
295 local i ngoff IFS
=$
'\n' d
="$(__gitdir)"
296 shopt -q nullglob || ngoff
=1
298 for i
in "$d/remotes"/*; do
299 echo ${i#$d/remotes/}
301 [ "$ngoff" ] && shopt -u nullglob
302 for i
in $
(git
--git-dir="$d" config
--list); do
312 __git_merge_strategies
()
314 if [ -n "${__git_merge_strategylist-}" ]; then
315 echo "$__git_merge_strategylist"
318 git merge
-s help 2>&1 |
319 sed -n -e '/[Aa]vailable strategies are: /,/^$/{
327 __git_merge_strategylist
=
328 __git_merge_strategylist
=$
(__git_merge_strategies
2>/dev
/null
)
330 __git_complete_file
()
332 local pfx
ls ref cur
="${COMP_WORDS[COMP_CWORD]}"
349 case "$COMP_WORDBREAKS" in
351 *) pfx
="$ref:$pfx" ;;
355 COMPREPLY
=($
(compgen
-P "$pfx" \
356 -W "$(git --git-dir="$
(__gitdir
)" ls-tree "$ls" \
357 | sed '/^100... blob /{
373 __gitcomp
"$(__git_refs)"
378 __git_complete_revlist
()
380 local pfx cur
="${COMP_WORDS[COMP_CWORD]}"
385 __gitcomp
"$(__git_refs)" "$pfx" "$cur"
390 __gitcomp
"$(__git_refs)" "$pfx" "$cur"
393 __gitcomp
"$(__git_refs)"
398 __git_complete_remote_or_refspec
()
400 local cmd
="${COMP_WORDS[1]}"
401 local cur
="${COMP_WORDS[COMP_CWORD]}"
402 local i c
=2 remote
="" pfx
="" lhs
=1 no_complete_refspec
=0
403 while [ $c -lt $COMP_CWORD ]; do
406 --all|
--mirror) [ "$cmd" = "push" ] && no_complete_refspec
=1 ;;
408 *) remote
="$i"; break ;;
412 if [ -z "$remote" ]; then
413 __gitcomp
"$(__git_remotes)"
416 if [ $no_complete_refspec = 1 ]; then
420 [ "$remote" = "." ] && remote
=
423 case "$COMP_WORDBREAKS" in
425 *) pfx
="${cur%%:*}:" ;;
437 if [ $lhs = 1 ]; then
438 __gitcomp
"$(__git_refs2 "$remote")" "$pfx" "$cur"
440 __gitcomp
"$(__git_refs)" "$pfx" "$cur"
444 if [ $lhs = 1 ]; then
445 __gitcomp
"$(__git_refs "$remote")" "$pfx" "$cur"
447 __gitcomp
"$(__git_refs)" "$pfx" "$cur"
451 if [ $lhs = 1 ]; then
452 __gitcomp
"$(__git_refs)" "$pfx" "$cur"
454 __gitcomp
"$(__git_refs "$remote")" "$pfx" "$cur"
460 __git_complete_strategy
()
462 case "${COMP_WORDS[COMP_CWORD-1]}" in
464 __gitcomp
"$(__git_merge_strategies)"
467 local cur
="${COMP_WORDS[COMP_CWORD]}"
470 __gitcomp
"$(__git_merge_strategies)" "" "${cur##--strategy=}"
477 __git_all_commands
()
479 if [ -n "${__git_all_commandlist-}" ]; then
480 echo "$__git_all_commandlist"
484 for i
in $
(git
help -a|
egrep '^ ')
487 *--*) : helper pattern
;;
492 __git_all_commandlist
=
493 __git_all_commandlist
="$(__git_all_commands 2>/dev/null)"
495 __git_porcelain_commands
()
497 if [ -n "${__git_porcelain_commandlist-}" ]; then
498 echo "$__git_porcelain_commandlist"
502 for i
in "help" $
(__git_all_commands
)
505 *--*) : helper pattern
;;
506 applymbox
) : ask gittus
;;
507 applypatch
) : ask gittus
;;
508 archimport
) : import
;;
509 cat-file
) : plumbing
;;
510 check-attr
) : plumbing
;;
511 check-ref-format
) : plumbing
;;
512 checkout-index
) : plumbing
;;
513 commit-tree
) : plumbing
;;
514 count-objects
) : infrequent
;;
515 cvsexportcommit
) : export;;
516 cvsimport
) : import
;;
517 cvsserver
) : daemon
;;
519 diff-files
) : plumbing
;;
520 diff-index
) : plumbing
;;
521 diff-tree
) : plumbing
;;
522 fast-import
) : import
;;
523 fast-export
) : export;;
524 fsck-objects
) : plumbing
;;
525 fetch-pack
) : plumbing
;;
526 fmt-merge-msg
) : plumbing
;;
527 for-each-ref
) : plumbing
;;
528 hash-object
) : plumbing
;;
529 http-
*) : transport
;;
530 index-pack
) : plumbing
;;
531 init-db
) : deprecated
;;
532 local-fetch
) : plumbing
;;
533 lost-found
) : infrequent
;;
534 ls-files
) : plumbing
;;
535 ls-remote
) : plumbing
;;
536 ls-tree
) : plumbing
;;
537 mailinfo
) : plumbing
;;
538 mailsplit
) : plumbing
;;
539 merge-
*) : plumbing
;;
542 pack-objects
) : plumbing
;;
543 pack-redundant
) : plumbing
;;
544 pack-refs
) : plumbing
;;
545 parse-remote
) : plumbing
;;
546 patch-id
) : plumbing
;;
547 peek-remote
) : plumbing
;;
549 prune-packed
) : plumbing
;;
550 quiltimport
) : import
;;
551 read-tree
) : plumbing
;;
552 receive-pack
) : plumbing
;;
554 repo-config
) : deprecated
;;
556 rev-list
) : plumbing
;;
557 rev-parse
) : plumbing
;;
558 runstatus
) : plumbing
;;
559 sh-setup
) : internal
;;
561 show-ref
) : plumbing
;;
562 send-pack
) : plumbing
;;
563 show-index
) : plumbing
;;
565 stripspace
) : plumbing
;;
566 symbolic-ref
) : plumbing
;;
567 tar-tree
) : deprecated
;;
568 unpack-file
) : plumbing
;;
569 unpack-objects
) : plumbing
;;
570 update-index
) : plumbing
;;
571 update-ref
) : plumbing
;;
572 update-server-info
) : daemon
;;
573 upload-archive
) : plumbing
;;
574 upload-pack
) : plumbing
;;
575 write-tree
) : plumbing
;;
577 verify-pack
) : infrequent
;;
578 verify-tag
) : plumbing
;;
583 __git_porcelain_commandlist
=
584 __git_porcelain_commandlist
="$(__git_porcelain_commands 2>/dev/null)"
589 for i
in $
(git
--git-dir="$(__gitdir)" config
--list); do
599 # __git_aliased_command requires 1 argument
600 __git_aliased_command
()
602 local word cmdline
=$
(git
--git-dir="$(__gitdir)" \
603 config
--get "alias.$1")
604 for word
in $cmdline; do
605 if [ "${word##-*}" ]; then
612 # __git_find_subcommand requires 1 argument
613 __git_find_subcommand
()
615 local word subcommand c
=1
617 while [ $c -lt $COMP_CWORD ]; do
618 word
="${COMP_WORDS[c]}"
619 for subcommand
in $1; do
620 if [ "$subcommand" = "$word" ]; then
629 __git_has_doubledash
()
632 while [ $c -lt $COMP_CWORD ]; do
633 if [ "--" = "${COMP_WORDS[c]}" ]; then
641 __git_whitespacelist
="nowarn warn error error-all fix"
645 local cur
="${COMP_WORDS[COMP_CWORD]}" dir
="$(__gitdir)"
646 if [ -d "$dir"/rebase-apply
]; then
647 __gitcomp
"--skip --resolved --abort"
652 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
657 --3way --committer-date-is-author-date --ignore-date
658 --interactive --keep --no-utf8 --signoff --utf8
668 local cur
="${COMP_WORDS[COMP_CWORD]}"
671 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
676 --stat --numstat --summary --check --index
677 --cached --index-info --reverse --reject --unidiff-zero
678 --apply --no-add --exclude=
679 --whitespace= --inaccurate-eof --verbose
688 __git_has_doubledash
&& return
690 local cur
="${COMP_WORDS[COMP_CWORD]}"
694 --interactive --refresh --patch --update --dry-run
695 --ignore-errors --intent-to-add
704 local cur
="${COMP_WORDS[COMP_CWORD]}"
707 __gitcomp
"$(git archive --list)" "" "${cur##--format=}"
711 __gitcomp
"$(__git_remotes)" "" "${cur##--remote=}"
716 --format= --list --verbose
717 --prefix= --remote= --exec=
727 __git_has_doubledash
&& return
729 local subcommands
="start bad good skip reset visualize replay log run"
730 local subcommand
="$(__git_find_subcommand "$subcommands")"
731 if [ -z "$subcommand" ]; then
732 __gitcomp
"$subcommands"
736 case "$subcommand" in
738 __gitcomp
"$(__git_refs)"
748 local i c
=1 only_local_ref
="n" has_r
="n"
750 while [ $c -lt $COMP_CWORD ]; do
753 -d|
-m) only_local_ref
="y" ;;
759 case "${COMP_WORDS[COMP_CWORD]}" in
762 --color --no-color --verbose --abbrev= --no-abbrev
763 --track --no-track --contains --merged --no-merged
767 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
768 __gitcomp
"$(__git_heads)"
770 __gitcomp
"$(__git_refs)"
778 local cmd
="${COMP_WORDS[2]}"
779 case "$COMP_CWORD" in
781 __gitcomp
"create list-heads verify unbundle"
789 __git_complete_revlist
798 __git_has_doubledash
&& return
800 __gitcomp
"$(__git_refs)"
805 __gitcomp
"$(__git_refs)"
810 local cur
="${COMP_WORDS[COMP_CWORD]}"
813 __gitcomp
"--edit --no-commit"
816 __gitcomp
"$(__git_refs)"
823 __git_has_doubledash
&& return
825 local cur
="${COMP_WORDS[COMP_CWORD]}"
828 __gitcomp
"--dry-run --quiet"
837 local cur
="${COMP_WORDS[COMP_CWORD]}"
862 __git_has_doubledash
&& return
864 local cur
="${COMP_WORDS[COMP_CWORD]}"
868 --all --author= --signoff --verify --no-verify
869 --edit --amend --include --only --interactive
878 local cur
="${COMP_WORDS[COMP_CWORD]}"
882 --all --tags --contains --abbrev= --candidates=
883 --exact-match --debug --long --match --always
887 __gitcomp
"$(__git_refs)"
890 __git_diff_common_options
="--stat --numstat --shortstat --summary
891 --patch-with-stat --name-only --name-status --color
892 --no-color --color-words --no-renames --check
893 --full-index --binary --abbrev --diff-filter=
895 --text --ignore-space-at-eol --ignore-space-change
896 --ignore-all-space --exit-code --quiet --ext-diff
898 --no-prefix --src-prefix= --dst-prefix=
899 --inter-hunk-context=
906 __git_has_doubledash
&& return
908 local cur
="${COMP_WORDS[COMP_CWORD]}"
911 __gitcomp
"--cached --staged --pickaxe-all --pickaxe-regex
912 --base --ours --theirs
913 $__git_diff_common_options
921 __git_mergetools_common
="diffuse ecmerge emerge kdiff3 meld opendiff
922 tkdiff vimdiff gvimdiff xxdiff
927 local cur
="${COMP_WORDS[COMP_CWORD]}"
930 __gitcomp
"$__git_mergetools_common kompare" "" "${cur##--tool=}"
941 __git_fetch_options
="
942 --quiet --verbose --append --upload-pack --force --keep --depth=
948 local cur
="${COMP_WORDS[COMP_CWORD]}"
951 __gitcomp
"$__git_fetch_options"
955 __git_complete_remote_or_refspec
960 local cur
="${COMP_WORDS[COMP_CWORD]}"
965 " "" "${cur##--thread=}"
970 --stdout --attach --no-attach --thread --thread=
972 --numbered --start-number
977 --full-index --binary
980 --no-prefix --src-prefix= --dst-prefix=
981 --inline --suffix= --ignore-if-in-upstream
987 __git_complete_revlist
992 local cur
="${COMP_WORDS[COMP_CWORD]}"
996 --tags --root --unreachable --cache --no-reflogs --full
997 --strict --verbose --lost-found
1007 local cur
="${COMP_WORDS[COMP_CWORD]}"
1010 __gitcomp
"--prune --aggressive"
1019 __git_has_doubledash
&& return
1021 local cur
="${COMP_WORDS[COMP_CWORD]}"
1026 --text --ignore-case --word-regexp --invert-match
1028 --extended-regexp --basic-regexp --fixed-strings
1029 --files-with-matches --name-only
1030 --files-without-match
1032 --and --or --not --all-match
1042 local cur
="${COMP_WORDS[COMP_CWORD]}"
1045 __gitcomp
"--all --info --man --web"
1049 __gitcomp
"$(__git_all_commands)
1050 attributes cli core-tutorial cvs-migration
1051 diffcore gitk glossary hooks ignore modules
1052 repository-layout tutorial tutorial-2
1059 local cur
="${COMP_WORDS[COMP_CWORD]}"
1063 false true umask group all world everybody
1064 " "" "${cur##--shared=}"
1068 __gitcomp
"--quiet --bare --template= --shared --shared="
1077 __git_has_doubledash
&& return
1079 local cur
="${COMP_WORDS[COMP_CWORD]}"
1082 __gitcomp
"--cached --deleted --modified --others --ignored
1083 --stage --directory --no-empty-directory --unmerged
1084 --killed --exclude= --exclude-from=
1085 --exclude-per-directory= --exclude-standard
1086 --error-unmatch --with-tree= --full-name
1087 --abbrev --ignored --exclude-per-directory
1097 __gitcomp
"$(__git_remotes)"
1105 # Options that go well for log, shortlog and gitk
1106 __git_log_common_options
="
1108 --branches --tags --remotes
1109 --first-parent --no-merges
1111 --max-age= --since= --after=
1112 --min-age= --until= --before=
1114 # Options that go well for log and gitk (not shortlog)
1115 __git_log_gitk_options
="
1116 --dense --sparse --full-history
1117 --simplify-merges --simplify-by-decoration
1120 # Options that go well for log and shortlog (not gitk)
1121 __git_log_shortlog_options
="
1122 --author= --committer= --grep=
1126 __git_log_pretty_formats
="oneline short medium full fuller email raw format:"
1127 __git_log_date_formats
="relative iso8601 rfc2822 short local default raw"
1131 __git_has_doubledash
&& return
1133 local cur
="${COMP_WORDS[COMP_CWORD]}"
1134 local g
="$(git rev-parse --git-dir 2>/dev/null)"
1136 if [ -f "$g/MERGE_HEAD" ]; then
1141 __gitcomp
"$__git_log_pretty_formats
1142 " "" "${cur##--pretty=}"
1146 __gitcomp
"$__git_log_pretty_formats
1147 " "" "${cur##--format=}"
1151 __gitcomp
"$__git_log_date_formats" "" "${cur##--date=}"
1156 $__git_log_common_options
1157 $__git_log_shortlog_options
1158 $__git_log_gitk_options
1159 --root --topo-order --date-order --reverse
1161 --abbrev-commit --abbrev=
1162 --relative-date --date=
1163 --pretty= --format= --oneline
1168 --parents --children
1170 $__git_diff_common_options
1171 --pickaxe-all --pickaxe-regex
1176 __git_complete_revlist
1179 __git_merge_options
="
1180 --no-commit --no-stat --log --no-log --squash --strategy
1181 --commit --stat --no-squash --ff --no-ff
1186 __git_complete_strategy
&& return
1188 local cur
="${COMP_WORDS[COMP_CWORD]}"
1191 __gitcomp
"$__git_merge_options"
1194 __gitcomp
"$(__git_refs)"
1199 local cur
="${COMP_WORDS[COMP_CWORD]}"
1202 __gitcomp
"$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"
1215 __gitcomp
"$(__git_refs)"
1220 local cur
="${COMP_WORDS[COMP_CWORD]}"
1223 __gitcomp
"--dry-run"
1232 __gitcomp
"--tags --all --stdin"
1237 __git_complete_strategy
&& return
1239 local cur
="${COMP_WORDS[COMP_CWORD]}"
1243 --rebase --no-rebase
1244 $__git_merge_options
1245 $__git_fetch_options
1250 __git_complete_remote_or_refspec
1255 local cur
="${COMP_WORDS[COMP_CWORD]}"
1256 case "${COMP_WORDS[COMP_CWORD-1]}" in
1258 __gitcomp
"$(__git_remotes)"
1263 __gitcomp
"$(__git_remotes)" "" "${cur##--repo=}"
1268 --all --mirror --tags --dry-run --force --verbose
1269 --receive-pack= --repo=
1274 __git_complete_remote_or_refspec
1279 local cur
="${COMP_WORDS[COMP_CWORD]}" dir
="$(__gitdir)"
1280 if [ -d "$dir"/rebase-apply
] ||
[ -d "$dir"/rebase-merge
]; then
1281 __gitcomp
"--continue --skip --abort"
1284 __git_complete_strategy
&& return
1287 __gitcomp
"--onto --merge --strategy --interactive"
1290 __gitcomp
"$(__git_refs)"
1293 __git_send_email_confirm_options
="always never auto cc compose"
1294 __git_send_email_suppresscc_options
="author self cc ccbody sob cccmd body all"
1298 local cur
="${COMP_WORDS[COMP_CWORD]}"
1302 $__git_send_email_confirm_options
1303 " "" "${cur##--confirm=}"
1308 $__git_send_email_suppresscc_options
1309 " "" "${cur##--suppress-cc=}"
1313 --smtp-encryption=*)
1314 __gitcomp
"ssl tls" "" "${cur##--smtp-encryption=}"
1318 __gitcomp
"--annotate --bcc --cc --cc-cmd --chain-reply-to
1319 --compose --confirm= --dry-run --envelope-sender
1321 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
1322 --no-suppress-from --no-thread --quiet
1323 --signed-off-by-cc --smtp-pass --smtp-server
1324 --smtp-server-port --smtp-encryption= --smtp-user
1325 --subject --suppress-cc= --suppress-from --thread --to
1326 --validate --no-validate"
1333 __git_config_get_set_variables
()
1335 local prevword word config_file
= c
=$COMP_CWORD
1336 while [ $c -gt 1 ]; do
1337 word
="${COMP_WORDS[c]}"
1339 --global|
--system|
--file=*)
1344 config_file
="$word $prevword"
1352 for i
in $
(git
--git-dir="$(__gitdir)" config
$config_file --list \
1364 local cur
="${COMP_WORDS[COMP_CWORD]}"
1365 local prv
="${COMP_WORDS[COMP_CWORD-1]}"
1368 __gitcomp
"$(__git_remotes)"
1372 __gitcomp
"$(__git_refs)"
1376 local remote
="${prv#remote.}"
1377 remote
="${remote%.fetch}"
1378 __gitcomp
"$(__git_refs_remotes "$remote")"
1382 local remote
="${prv#remote.}"
1383 remote
="${remote%.push}"
1384 __gitcomp
"$(git --git-dir="$
(__gitdir
)" \
1385 for-each-ref --format='%(refname):%(refname)' \
1389 pull.twohead|pull.octopus
)
1390 __gitcomp
"$(__git_merge_strategies)"
1393 color.branch|color.
diff|color.interactive|\
1394 color.showbranch|color.status|color.ui
)
1395 __gitcomp
"always never auto"
1399 __gitcomp
"false true"
1404 normal black red green yellow blue magenta cyan white
1405 bold dim ul blink reverse
1410 __gitcomp
"man info web html"
1414 __gitcomp
"$__git_log_date_formats"
1417 sendemail.aliasesfiletype
)
1418 __gitcomp
"mutt mailrc pine elm gnus"
1422 __gitcomp
"$__git_send_email_confirm_options"
1425 sendemail.suppresscc
)
1426 __gitcomp
"$__git_send_email_suppresscc_options"
1429 --get|
--get-all|
--unset|
--unset-all)
1430 __gitcomp
"$(__git_config_get_set_variables)"
1441 --global --system --file=
1442 --list --replace-all
1443 --get --get-all --get-regexp
1444 --add --unset --unset-all
1445 --remove-section --rename-section
1450 local pfx
="${cur%.*}."
1452 __gitcomp
"remote merge mergeoptions" "$pfx" "$cur"
1456 local pfx
="${cur%.*}."
1458 __gitcomp
"$(__git_heads)" "$pfx" "$cur" "."
1462 local pfx
="${cur%.*}."
1465 argprompt cmd confirm needsfile noconsole norescan
1466 prompt revprompt revunmerged title
1471 local pfx
="${cur%.*}."
1473 __gitcomp
"cmd path" "$pfx" "$cur"
1477 local pfx
="${cur%.*}."
1479 __gitcomp
"cmd path" "$pfx" "$cur"
1483 local pfx
="${cur%.*}."
1485 __gitcomp
"cmd path trustExitCode" "$pfx" "$cur"
1489 local pfx
="${cur%.*}."
1491 __gitcomp
"$(__git_all_commands)" "$pfx" "$cur"
1495 local pfx
="${cur%.*}."
1498 url proxy fetch push mirror skipDefaultUpdate
1499 receivepack uploadpack tagopt
1504 local pfx
="${cur%.*}."
1506 __gitcomp
"$(__git_remotes)" "$pfx" "$cur" "."
1510 local pfx
="${cur%.*}."
1512 __gitcomp
"insteadof" "$pfx" "$cur"
1519 branch.autosetupmerge
1520 branch.autosetuprebase
1523 color.branch.current
1534 color.diff.whitespace
1539 color.interactive.header
1540 color.interactive.help
1541 color.interactive.prompt
1546 color.status.changed
1548 color.status.nobranch
1549 color.status.untracked
1550 color.status.updated
1557 core.deltaBaseCacheLimit
1561 core.fsyncobjectfiles
1563 core.ignoreCygwinFSTricks
1565 core.logAllRefUpdates
1566 core.loosecompression
1568 core.packedGitWindowSize
1570 core.preferSymlinkRefs
1573 core.repositoryFormatVersion
1575 core.sharedRepository
1578 core.warnAmbiguousRefs
1581 diff.autorefreshindex
1587 diff.suppressBlankEmpty
1599 format.subjectprefix
1608 gc.reflogexpireunreachable
1612 gitcvs.commitmsgannotation
1613 gitcvs.dbTableNamePrefix
1624 gui.copyblamethreshold
1628 gui.matchtrackingbranch
1629 gui.newbranchtemplate
1630 gui.pruneduringfetch
1631 gui.spellingdictionary
1647 i18n.logOutputEncoding
1652 imap.preformattedHTML
1661 interactive.singlekey
1674 mergetool.keepBackup
1677 pack.deltaCacheLimit
1690 receive.denyCurrentBranch
1692 receive.denyNonFastForwards
1695 repack.usedeltabaseoffset
1698 sendemail.aliasesfile
1699 sendemail.aliasesfiletype
1703 sendemail.chainreplyto
1705 sendemail.envelopesender
1707 sendemail.signedoffbycc
1708 sendemail.smtpencryption
1710 sendemail.smtpserver
1711 sendemail.smtpserverport
1713 sendemail.suppresscc
1714 sendemail.suppressfrom
1719 status.relativePaths
1720 status.showUntrackedFiles
1722 transfer.unpackLimit
1734 local subcommands
="add rename rm show prune update set-head"
1735 local subcommand
="$(__git_find_subcommand "$subcommands")"
1736 if [ -z "$subcommand" ]; then
1737 __gitcomp
"$subcommands"
1741 case "$subcommand" in
1742 rename|
rm|show|prune
)
1743 __gitcomp
"$(__git_remotes)"
1746 local i c
='' IFS
=$
'\n'
1747 for i
in $
(git
--git-dir="$(__gitdir)" config
--list); do
1765 __git_has_doubledash
&& return
1767 local cur
="${COMP_WORDS[COMP_CWORD]}"
1770 __gitcomp
"--merge --mixed --hard --soft"
1774 __gitcomp
"$(__git_refs)"
1779 local cur
="${COMP_WORDS[COMP_CWORD]}"
1782 __gitcomp
"--edit --mainline --no-edit --no-commit --signoff"
1786 __gitcomp
"$(__git_refs)"
1791 __git_has_doubledash
&& return
1793 local cur
="${COMP_WORDS[COMP_CWORD]}"
1796 __gitcomp
"--cached --dry-run --ignore-unmatch --quiet"
1805 __git_has_doubledash
&& return
1807 local cur
="${COMP_WORDS[COMP_CWORD]}"
1811 $__git_log_common_options
1812 $__git_log_shortlog_options
1813 --numbered --summary
1818 __git_complete_revlist
1823 __git_has_doubledash
&& return
1825 local cur
="${COMP_WORDS[COMP_CWORD]}"
1828 __gitcomp
"$__git_log_pretty_formats
1829 " "" "${cur##--pretty=}"
1833 __gitcomp
"$__git_log_pretty_formats
1834 " "" "${cur##--format=}"
1838 __gitcomp
"--pretty= --format= --abbrev-commit --oneline
1839 $__git_diff_common_options
1849 local cur
="${COMP_WORDS[COMP_CWORD]}"
1853 --all --remotes --topo-order --current --more=
1854 --list --independent --merge-base --no-name
1856 --sha1-name --sparse --topics --reflog
1861 __git_complete_revlist
1866 local subcommands
='save list show apply clear drop pop create branch'
1867 local subcommand
="$(__git_find_subcommand "$subcommands")"
1868 if [ -z "$subcommand" ]; then
1869 __gitcomp
"$subcommands"
1871 local cur
="${COMP_WORDS[COMP_CWORD]}"
1872 case "$subcommand,$cur" in
1874 __gitcomp
"--keep-index"
1879 show
,--*|drop
,--*|pop
,--*|branch
,--*)
1882 show
,*|apply
,*|drop
,*|pop
,*|branch
,*)
1883 __gitcomp
"$(git --git-dir="$
(__gitdir
)" stash list \
1884 | sed -n -e 's/:.*//p')"
1895 __git_has_doubledash
&& return
1897 local subcommands
="add status init update summary foreach sync"
1898 if [ -z "$(__git_find_subcommand "$subcommands")" ]; then
1899 local cur
="${COMP_WORDS[COMP_CWORD]}"
1902 __gitcomp
"--quiet --cached"
1905 __gitcomp
"$subcommands"
1915 init fetch clone rebase dcommit log find-rev
1916 set-tree commit-diff info create-ignore propget
1917 proplist show-ignore show-externals branch tag blame
1920 local subcommand
="$(__git_find_subcommand "$subcommands")"
1921 if [ -z "$subcommand" ]; then
1922 __gitcomp
"$subcommands"
1924 local remote_opts
="--username= --config-dir= --no-auth-cache"
1926 --follow-parent --authors-file= --repack=
1927 --no-metadata --use-svm-props --use-svnsync-props
1928 --log-window-size= --no-checkout --quiet
1929 --repack-flags --use-log-author --localtime
1930 --ignore-paths= $remote_opts
1933 --template= --shared= --trunk= --tags=
1934 --branches= --stdlayout --minimize-url
1935 --no-metadata --use-svm-props --use-svnsync-props
1936 --rewrite-root= --prefix= --use-log-author
1937 --add-author-from $remote_opts
1940 --edit --rmdir --find-copies-harder --copy-similarity=
1943 local cur
="${COMP_WORDS[COMP_CWORD]}"
1944 case "$subcommand,$cur" in
1946 __gitcomp
"--revision= --fetch-all $fc_opts"
1949 __gitcomp
"--revision= $fc_opts $init_opts"
1952 __gitcomp
"$init_opts"
1956 --merge --strategy= --verbose --dry-run
1957 --fetch-all --no-rebase --commit-url
1958 --revision $cmt_opts $fc_opts
1962 __gitcomp
"--stdin $cmt_opts $fc_opts"
1964 create-ignore
,--*|propget
,--*|proplist
,--*|show-ignore
,--*|\
1966 __gitcomp
"--revision="
1970 --limit= --revision= --verbose --incremental
1971 --oneline --show-commit --non-recursive
1972 --authors-file= --color
1977 --merge --verbose --strategy= --local
1978 --fetch-all --dry-run $fc_opts
1982 __gitcomp
"--message= --file= --revision= $cmt_opts"
1988 __gitcomp
"--dry-run --message --tag"
1991 __gitcomp
"--dry-run --message"
1994 __gitcomp
"--git-format"
1998 --config-dir= --ignore-paths= --minimize
1999 --no-auth-cache --username=
2012 while [ $c -lt $COMP_CWORD ]; do
2013 i
="${COMP_WORDS[c]}"
2016 __gitcomp
"$(__git_tags)"
2026 case "${COMP_WORDS[COMP_CWORD-1]}" in
2032 __gitcomp
"$(__git_tags)"
2038 __gitcomp
"$(__git_refs)"
2045 local i c
=1 command __git_dir
2047 while [ $c -lt $COMP_CWORD ]; do
2048 i
="${COMP_WORDS[c]}"
2050 --git-dir=*) __git_dir
="${i#--git-dir=}" ;;
2051 --bare) __git_dir
="." ;;
2052 --version|
-p|
--paginate) ;;
2053 --help) command="help"; break ;;
2054 *) command="$i"; break ;;
2059 if [ -z "$command" ]; then
2060 case "${COMP_WORDS[COMP_CWORD]}" in
2073 *) __gitcomp
"$(__git_porcelain_commands) $(__git_aliases)" ;;
2078 local expansion
=$
(__git_aliased_command
"$command")
2079 [ "$expansion" ] && command="$expansion"
2084 apply
) _git_apply
;;
2085 archive
) _git_archive
;;
2086 bisect
) _git_bisect
;;
2087 bundle
) _git_bundle
;;
2088 branch
) _git_branch
;;
2089 checkout
) _git_checkout
;;
2090 cherry
) _git_cherry
;;
2091 cherry-pick
) _git_cherry_pick
;;
2092 clean
) _git_clean
;;
2093 clone
) _git_clone
;;
2094 commit
) _git_commit
;;
2095 config
) _git_config
;;
2096 describe
) _git_describe
;;
2098 difftool
) _git_difftool
;;
2099 fetch
) _git_fetch
;;
2100 format-patch
) _git_format_patch
;;
2107 ls-files
) _git_ls_files
;;
2108 ls-remote
) _git_ls_remote
;;
2109 ls-tree
) _git_ls_tree
;;
2111 mergetool
) _git_mergetool
;;
2112 merge-base
) _git_merge_base
;;
2114 name-rev
) _git_name_rev
;;
2117 rebase
) _git_rebase
;;
2118 remote
) _git_remote
;;
2119 reset) _git_reset
;;
2120 revert
) _git_revert
;;
2122 send-email
) _git_send_email
;;
2123 shortlog
) _git_shortlog
;;
2125 show-branch
) _git_show_branch
;;
2126 stash
) _git_stash
;;
2128 submodule
) _git_submodule
;;
2131 whatchanged
) _git_log
;;
2138 __git_has_doubledash
&& return
2140 local cur
="${COMP_WORDS[COMP_CWORD]}"
2141 local g
="$(__gitdir)"
2143 if [ -f "$g/MERGE_HEAD" ]; then
2149 $__git_log_common_options
2150 $__git_log_gitk_options
2156 __git_complete_revlist
2159 complete
-o bashdefault
-o default
-o nospace
-F _git git
2>/dev
/null \
2160 || complete
-o default
-o nospace
-F _git git
2161 complete
-o bashdefault
-o default
-o nospace
-F _gitk gitk
2>/dev
/null \
2162 || complete
-o default
-o nospace
-F _gitk gitk
2164 # The following are necessary only for Cygwin, and only are needed
2165 # when the user has tab-completed the executable name and consequently
2166 # included the '.exe' suffix.
2168 if [ Cygwin
= "$(uname -o 2>/dev/null)" ]; then
2169 complete
-o bashdefault
-o default
-o nospace
-F _git git.exe
2>/dev
/null \
2170 || complete
-o default
-o nospace
-F _git git.exe