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="+"
154 if [ -n "${1-}" ]; then
155 printf "$1" "$c${b##refs/heads/}$w$i$r"
157 printf " (%s)" "$c${b##refs/heads/}$w$i$r"
163 # __gitcomp_1 requires 2 arguments
166 local c IFS=' '$'\t'$'\n'
169 --*=*) printf %s$'\n' "$c$2" ;;
170 *.) printf %s$'\n' "$c$2" ;;
171 *) printf %s$'\n' "$c$2 " ;;
176 # __gitcomp accepts 1, 2, 3, or 4 arguments
177 # generates completion reply with compgen
180 local cur="${COMP_WORDS[COMP_CWORD]}"
181 if [ $# -gt 2 ]; then
190 COMPREPLY=($(compgen -P "${2-}" \
191 -W "$(__gitcomp_1 "${1-}" "${4-}")" \
197 # __git_heads accepts 0 or 1 arguments (to pass to __gitdir)
200 local cmd i is_hash=y dir="$(__gitdir "${1-}")"
201 if [ -d "$dir" ]; then
202 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
206 for i in $(git ls-remote "${1-}" 2>/dev/null); do
207 case "$is_hash,$i" in
210 n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
211 n,*) is_hash=y; echo "$i" ;;
216 # __git_tags accepts 0 or 1 arguments (to pass to __gitdir)
219 local cmd i is_hash=y dir="$(__gitdir "${1-}")"
220 if [ -d "$dir" ]; then
221 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
225 for i in $(git ls-remote "${1-}" 2>/dev/null); do
226 case "$is_hash,$i" in
229 n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
230 n,*) is_hash=y; echo "$i" ;;
235 # __git_refs accepts 0 or 1 arguments (to pass to __gitdir)
238 local i is_hash=y dir="$(__gitdir "${1-}")"
239 local cur="${COMP_WORDS[COMP_CWORD]}" format refs
240 if [ -d "$dir" ]; then
247 if [ -e "$dir/HEAD" ]; then echo HEAD; fi
248 format="refname:short"
249 refs="refs/tags refs/heads refs/remotes"
252 git --git-dir="$dir" for-each-ref --format="%($format)" \
256 for i in $(git ls-remote "$dir" 2>/dev/null); do
257 case "$is_hash,$i" in
260 n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
261 n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
262 n,refs/remotes/*) is_hash=y; echo "${i#refs/remotes/}" ;;
263 n,*) is_hash=y; echo "$i" ;;
268 # __git_refs2 requires 1 argument (to pass to __git_refs)
272 for i in $(__git_refs "$1"); do
277 # __git_refs_remotes requires 1 argument (to pass to ls-remote)
278 __git_refs_remotes ()
280 local cmd i is_hash=y
281 for i in $(git ls-remote "$1" 2>/dev/null); do
282 case "$is_hash,$i" in
285 echo "$i:refs/remotes/$1/${i#refs/heads/}"
289 n,refs/tags/*) is_hash=y;;
297 local i ngoff IFS=$'\n' d="$(__gitdir)"
298 shopt -q nullglob || ngoff=1
300 for i in "$d/remotes"/*; do
301 echo ${i#$d/remotes/}
303 [ "$ngoff" ] && shopt -u nullglob
304 for i in $(git --git-dir="$d" config --list); do
314 __git_merge_strategies ()
316 if [ -n "${__git_merge_strategylist-}" ]; then
317 echo "$__git_merge_strategylist"
320 git merge -s help 2>&1 |
321 sed -n -e '/[Aa]vailable strategies are: /,/^$/{
329 __git_merge_strategylist=
330 __git_merge_strategylist=$(__git_merge_strategies 2>/dev/null)
332 __git_complete_file ()
334 local pfx ls ref cur="${COMP_WORDS[COMP_CWORD]}"
351 case "$COMP_WORDBREAKS" in
353 *) pfx="$ref:$pfx" ;;
357 COMPREPLY=($(compgen -P "$pfx" \
358 -W "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \
359 | sed '/^100... blob /{
375 __gitcomp "$(__git_refs)"
380 __git_complete_revlist ()
382 local pfx cur="${COMP_WORDS[COMP_CWORD]}"
387 __gitcomp "$(__git_refs)" "$pfx" "$cur"
392 __gitcomp "$(__git_refs)" "$pfx" "$cur"
395 __gitcomp "$(__git_refs)"
400 __git_complete_remote_or_refspec ()
402 local cmd="${COMP_WORDS[1]}"
403 local cur="${COMP_WORDS[COMP_CWORD]}"
404 local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0
405 while [ $c -lt $COMP_CWORD ]; do
408 --all|--mirror) [ "$cmd" = "push" ] && no_complete_refspec=1 ;;
410 *) remote="$i"; break ;;
414 if [ -z "$remote" ]; then
415 __gitcomp "$(__git_remotes)"
418 if [ $no_complete_refspec = 1 ]; then
422 [ "$remote" = "." ] && remote=
425 case "$COMP_WORDBREAKS" in
427 *) pfx="${cur%%:*}:" ;;
439 if [ $lhs = 1 ]; then
440 __gitcomp "$(__git_refs2 "$remote")" "$pfx" "$cur"
442 __gitcomp "$(__git_refs)" "$pfx" "$cur"
446 if [ $lhs = 1 ]; then
447 __gitcomp "$(__git_refs "$remote")" "$pfx" "$cur"
449 __gitcomp "$(__git_refs)" "$pfx" "$cur"
453 if [ $lhs = 1 ]; then
454 __gitcomp "$(__git_refs)" "$pfx" "$cur"
456 __gitcomp "$(__git_refs "$remote")" "$pfx" "$cur"
462 __git_complete_strategy ()
464 case "${COMP_WORDS[COMP_CWORD-1]}" in
466 __gitcomp "$(__git_merge_strategies)"
469 local cur="${COMP_WORDS[COMP_CWORD]}"
472 __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}"
479 __git_all_commands ()
481 if [ -n "${__git_all_commandlist-}" ]; then
482 echo "$__git_all_commandlist"
486 for i in $(git help -a|egrep '^ ')
489 *--*) : helper pattern;;
494 __git_all_commandlist=
495 __git_all_commandlist="$(__git_all_commands 2>/dev/null)"
497 __git_porcelain_commands ()
499 if [ -n "${__git_porcelain_commandlist-}" ]; then
500 echo "$__git_porcelain_commandlist"
504 for i in "help" $(__git_all_commands)
507 *--*) : helper pattern;;
508 applymbox) : ask gittus;;
509 applypatch) : ask gittus;;
510 archimport) : import;;
511 cat-file) : plumbing;;
512 check-attr) : plumbing;;
513 check-ref-format) : plumbing;;
514 checkout-index) : plumbing;;
515 commit-tree) : plumbing;;
516 count-objects) : infrequent;;
517 cvsexportcommit) : export;;
518 cvsimport) : import;;
519 cvsserver) : daemon;;
521 diff-files) : plumbing;;
522 diff-index) : plumbing;;
523 diff-tree) : plumbing;;
524 fast-import) : import;;
525 fast-export) : export;;
526 fsck-objects) : plumbing;;
527 fetch-pack) : plumbing;;
528 fmt-merge-msg) : plumbing;;
529 for-each-ref) : plumbing;;
530 hash-object) : plumbing;;
531 http-*) : transport;;
532 index-pack) : plumbing;;
533 init-db) : deprecated;;
534 local-fetch) : plumbing;;
535 lost-found) : infrequent;;
536 ls-files) : plumbing;;
537 ls-remote) : plumbing;;
538 ls-tree) : plumbing;;
539 mailinfo) : plumbing;;
540 mailsplit) : plumbing;;
541 merge-*) : plumbing;;
544 pack-objects) : plumbing;;
545 pack-redundant) : plumbing;;
546 pack-refs) : plumbing;;
547 parse-remote) : plumbing;;
548 patch-id) : plumbing;;
549 peek-remote) : plumbing;;
551 prune-packed) : plumbing;;
552 quiltimport) : import;;
553 read-tree) : plumbing;;
554 receive-pack) : plumbing;;
556 repo-config) : deprecated;;
558 rev-list) : plumbing;;
559 rev-parse) : plumbing;;
560 runstatus) : plumbing;;
561 sh-setup) : internal;;
563 show-ref) : plumbing;;
564 send-pack) : plumbing;;
565 show-index) : plumbing;;
567 stripspace) : plumbing;;
568 symbolic-ref) : plumbing;;
569 tar-tree) : deprecated;;
570 unpack-file) : plumbing;;
571 unpack-objects) : plumbing;;
572 update-index) : plumbing;;
573 update-ref) : plumbing;;
574 update-server-info) : daemon;;
575 upload-archive) : plumbing;;
576 upload-pack) : plumbing;;
577 write-tree) : plumbing;;
579 verify-pack) : infrequent;;
580 verify-tag) : plumbing;;
585 __git_porcelain_commandlist=
586 __git_porcelain_commandlist="$(__git_porcelain_commands 2>/dev/null)"
591 for i in $(git --git-dir="$(__gitdir)" config --list); do
601 # __git_aliased_command requires 1 argument
602 __git_aliased_command ()
604 local word cmdline=$(git --git-dir="$(__gitdir)" \
605 config --get "alias.$1")
606 for word in $cmdline; do
607 if [ "${word##-*}" ]; then
614 # __git_find_subcommand requires 1 argument
615 __git_find_subcommand ()
617 local word subcommand c=1
619 while [ $c -lt $COMP_CWORD ]; do
620 word="${COMP_WORDS[c]}"
621 for subcommand in $1; do
622 if [ "$subcommand" = "$word" ]; then
631 __git_has_doubledash ()
634 while [ $c -lt $COMP_CWORD ]; do
635 if [ "--" = "${COMP_WORDS[c]}" ]; then
643 __git_whitespacelist="nowarn warn error error-all fix"
647 local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)"
648 if [ -d "$dir"/rebase-apply ]; then
649 __gitcomp "--skip --resolved --abort"
654 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
659 --3way --committer-date-is-author-date --ignore-date
660 --interactive --keep --no-utf8 --signoff --utf8
670 local cur="${COMP_WORDS[COMP_CWORD]}"
673 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
678 --stat --numstat --summary --check --index
679 --cached --index-info --reverse --reject --unidiff-zero
680 --apply --no-add --exclude=
681 --whitespace= --inaccurate-eof --verbose
690 __git_has_doubledash && return
692 local cur="${COMP_WORDS[COMP_CWORD]}"
696 --interactive --refresh --patch --update --dry-run
697 --ignore-errors --intent-to-add
706 local cur="${COMP_WORDS[COMP_CWORD]}"
709 __gitcomp "$(git archive --list)" "" "${cur##--format=}"
713 __gitcomp "$(__git_remotes)" "" "${cur##--remote=}"
718 --format= --list --verbose
719 --prefix= --remote= --exec=
729 __git_has_doubledash && return
731 local subcommands="start bad good skip reset visualize replay log run"
732 local subcommand="$(__git_find_subcommand "$subcommands")"
733 if [ -z "$subcommand" ]; then
734 __gitcomp "$subcommands"
738 case "$subcommand" in
740 __gitcomp "$(__git_refs)"
750 local i c=1 only_local_ref="n" has_r="n"
752 while [ $c -lt $COMP_CWORD ]; do
755 -d|-m) only_local_ref="y" ;;
761 case "${COMP_WORDS[COMP_CWORD]}" in
764 --color --no-color --verbose --abbrev= --no-abbrev
765 --track --no-track --contains --merged --no-merged
769 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
770 __gitcomp "$(__git_heads)"
772 __gitcomp "$(__git_refs)"
780 local cmd="${COMP_WORDS[2]}"
781 case "$COMP_CWORD" in
783 __gitcomp "create list-heads verify unbundle"
791 __git_complete_revlist
800 __git_has_doubledash && return
802 __gitcomp "$(__git_refs)"
807 __gitcomp "$(__git_refs)"
812 local cur="${COMP_WORDS[COMP_CWORD]}"
815 __gitcomp "--edit --no-commit"
818 __gitcomp "$(__git_refs)"
825 __git_has_doubledash && return
827 local cur="${COMP_WORDS[COMP_CWORD]}"
830 __gitcomp "--dry-run --quiet"
839 local cur="${COMP_WORDS[COMP_CWORD]}"
864 __git_has_doubledash && return
866 local cur="${COMP_WORDS[COMP_CWORD]}"
870 --all --author= --signoff --verify --no-verify
871 --edit --amend --include --only --interactive
880 local cur="${COMP_WORDS[COMP_CWORD]}"
884 --all --tags --contains --abbrev= --candidates=
885 --exact-match --debug --long --match --always
889 __gitcomp "$(__git_refs)"
892 __git_diff_common_options="--stat --numstat --shortstat --summary
893 --patch-with-stat --name-only --name-status --color
894 --no-color --color-words --no-renames --check
895 --full-index --binary --abbrev --diff-filter=
897 --text --ignore-space-at-eol --ignore-space-change
898 --ignore-all-space --exit-code --quiet --ext-diff
900 --no-prefix --src-prefix= --dst-prefix=
901 --inter-hunk-context=
908 __git_has_doubledash && return
910 local cur="${COMP_WORDS[COMP_CWORD]}"
913 __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
914 --base --ours --theirs
915 $__git_diff_common_options
923 __git_mergetools_common="diffuse ecmerge emerge kdiff3 meld opendiff
924 tkdiff vimdiff gvimdiff xxdiff
929 local cur="${COMP_WORDS[COMP_CWORD]}"
932 __gitcomp "$__git_mergetools_common kompare" "" "${cur##--tool=}"
943 __git_fetch_options="
944 --quiet --verbose --append --upload-pack --force --keep --depth=
950 local cur="${COMP_WORDS[COMP_CWORD]}"
953 __gitcomp "$__git_fetch_options"
957 __git_complete_remote_or_refspec
962 local cur="${COMP_WORDS[COMP_CWORD]}"
967 " "" "${cur##--thread=}"
972 --stdout --attach --no-attach --thread --thread=
974 --numbered --start-number
979 --full-index --binary
982 --no-prefix --src-prefix= --dst-prefix=
983 --inline --suffix= --ignore-if-in-upstream
989 __git_complete_revlist
994 local cur="${COMP_WORDS[COMP_CWORD]}"
998 --tags --root --unreachable --cache --no-reflogs --full
999 --strict --verbose --lost-found
1009 local cur="${COMP_WORDS[COMP_CWORD]}"
1012 __gitcomp "--prune --aggressive"
1021 __git_has_doubledash && return
1023 local cur="${COMP_WORDS[COMP_CWORD]}"
1028 --text --ignore-case --word-regexp --invert-match
1030 --extended-regexp --basic-regexp --fixed-strings
1031 --files-with-matches --name-only
1032 --files-without-match
1034 --and --or --not --all-match
1044 local cur="${COMP_WORDS[COMP_CWORD]}"
1047 __gitcomp "--all --info --man --web"
1051 __gitcomp "$(__git_all_commands)
1052 attributes cli core-tutorial cvs-migration
1053 diffcore gitk glossary hooks ignore modules
1054 repository-layout tutorial tutorial-2
1061 local cur="${COMP_WORDS[COMP_CWORD]}"
1065 false true umask group all world everybody
1066 " "" "${cur##--shared=}"
1070 __gitcomp "--quiet --bare --template= --shared --shared="
1079 __git_has_doubledash && return
1081 local cur="${COMP_WORDS[COMP_CWORD]}"
1084 __gitcomp "--cached --deleted --modified --others --ignored
1085 --stage --directory --no-empty-directory --unmerged
1086 --killed --exclude= --exclude-from=
1087 --exclude-per-directory= --exclude-standard
1088 --error-unmatch --with-tree= --full-name
1089 --abbrev --ignored --exclude-per-directory
1099 __gitcomp "$(__git_remotes)"
1107 # Options that go well for log, shortlog and gitk
1108 __git_log_common_options="
1110 --branches --tags --remotes
1111 --first-parent --no-merges
1113 --max-age= --since= --after=
1114 --min-age= --until= --before=
1116 # Options that go well for log and gitk (not shortlog)
1117 __git_log_gitk_options="
1118 --dense --sparse --full-history
1119 --simplify-merges --simplify-by-decoration
1122 # Options that go well for log and shortlog (not gitk)
1123 __git_log_shortlog_options="
1124 --author= --committer= --grep=
1128 __git_log_pretty_formats="oneline short medium full fuller email raw format:"
1129 __git_log_date_formats="relative iso8601 rfc2822 short local default raw"
1133 __git_has_doubledash && return
1135 local cur="${COMP_WORDS[COMP_CWORD]}"
1136 local g="$(git rev-parse --git-dir 2>/dev/null)"
1138 if [ -f "$g/MERGE_HEAD" ]; then
1143 __gitcomp "$__git_log_pretty_formats
1144 " "" "${cur##--pretty=}"
1148 __gitcomp "$__git_log_pretty_formats
1149 " "" "${cur##--format=}"
1153 __gitcomp "$__git_log_date_formats" "" "${cur##--date=}"
1158 $__git_log_common_options
1159 $__git_log_shortlog_options
1160 $__git_log_gitk_options
1161 --root --topo-order --date-order --reverse
1163 --abbrev-commit --abbrev=
1164 --relative-date --date=
1165 --pretty= --format= --oneline
1170 --parents --children
1172 $__git_diff_common_options
1173 --pickaxe-all --pickaxe-regex
1178 __git_complete_revlist
1181 __git_merge_options="
1182 --no-commit --no-stat --log --no-log --squash --strategy
1183 --commit --stat --no-squash --ff --no-ff
1188 __git_complete_strategy && return
1190 local cur="${COMP_WORDS[COMP_CWORD]}"
1193 __gitcomp "$__git_merge_options"
1196 __gitcomp "$(__git_refs)"
1201 local cur="${COMP_WORDS[COMP_CWORD]}"
1204 __gitcomp "$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"
1217 __gitcomp "$(__git_refs)"
1222 local cur="${COMP_WORDS[COMP_CWORD]}"
1225 __gitcomp "--dry-run"
1234 __gitcomp "--tags --all --stdin"
1239 __git_complete_strategy && return
1241 local cur="${COMP_WORDS[COMP_CWORD]}"
1245 --rebase --no-rebase
1246 $__git_merge_options
1247 $__git_fetch_options
1252 __git_complete_remote_or_refspec
1257 local cur="${COMP_WORDS[COMP_CWORD]}"
1258 case "${COMP_WORDS[COMP_CWORD-1]}" in
1260 __gitcomp "$(__git_remotes)"
1265 __gitcomp "$(__git_remotes)" "" "${cur##--repo=}"
1270 --all --mirror --tags --dry-run --force --verbose
1271 --receive-pack= --repo=
1276 __git_complete_remote_or_refspec
1281 local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)"
1282 if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
1283 __gitcomp "--continue --skip --abort"
1286 __git_complete_strategy && return
1289 __gitcomp "--onto --merge --strategy --interactive"
1292 __gitcomp "$(__git_refs)"
1295 __git_send_email_confirm_options="always never auto cc compose"
1296 __git_send_email_suppresscc_options="author self cc ccbody sob cccmd body all"
1300 local cur="${COMP_WORDS[COMP_CWORD]}"
1304 $__git_send_email_confirm_options
1305 " "" "${cur##--confirm=}"
1310 $__git_send_email_suppresscc_options
1311 " "" "${cur##--suppress-cc=}"
1315 --smtp-encryption=*)
1316 __gitcomp "ssl tls" "" "${cur##--smtp-encryption=}"
1320 __gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to
1321 --compose --confirm= --dry-run --envelope-sender
1323 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
1324 --no-suppress-from --no-thread --quiet
1325 --signed-off-by-cc --smtp-pass --smtp-server
1326 --smtp-server-port --smtp-encryption= --smtp-user
1327 --subject --suppress-cc= --suppress-from --thread --to
1328 --validate --no-validate"
1335 __git_config_get_set_variables ()
1337 local prevword word config_file= c=$COMP_CWORD
1338 while [ $c -gt 1 ]; do
1339 word="${COMP_WORDS[c]}"
1341 --global|--system|--file=*)
1346 config_file="$word $prevword"
1354 for i in $(git --git-dir="$(__gitdir)" config $config_file --list \
1366 local cur="${COMP_WORDS[COMP_CWORD]}"
1367 local prv="${COMP_WORDS[COMP_CWORD-1]}"
1370 __gitcomp "$(__git_remotes)"
1374 __gitcomp "$(__git_refs)"
1378 local remote="${prv#remote.}"
1379 remote="${remote%.fetch}"
1380 __gitcomp "$(__git_refs_remotes "$remote")"
1384 local remote="${prv#remote.}"
1385 remote="${remote%.push}"
1386 __gitcomp "$(git --git-dir="$(__gitdir)" \
1387 for-each-ref --format='%(refname):%(refname)' \
1391 pull.twohead|pull.octopus)
1392 __gitcomp "$(__git_merge_strategies)"
1395 color.branch|color.diff|color.interactive|\
1396 color.showbranch|color.status|color.ui)
1397 __gitcomp "always never auto"
1401 __gitcomp "false true"
1406 normal black red green yellow blue magenta cyan white
1407 bold dim ul blink reverse
1412 __gitcomp "man info web html"
1416 __gitcomp "$__git_log_date_formats"
1419 sendemail.aliasesfiletype)
1420 __gitcomp "mutt mailrc pine elm gnus"
1424 __gitcomp "$__git_send_email_confirm_options"
1427 sendemail.suppresscc)
1428 __gitcomp "$__git_send_email_suppresscc_options"
1431 --get|--get-all|--unset|--unset-all)
1432 __gitcomp "$(__git_config_get_set_variables)"
1443 --global --system --file=
1444 --list --replace-all
1445 --get --get-all --get-regexp
1446 --add --unset --unset-all
1447 --remove-section --rename-section
1452 local pfx="${cur%.*}."
1454 __gitcomp "remote merge mergeoptions" "$pfx" "$cur"
1458 local pfx="${cur%.*}."
1460 __gitcomp "$(__git_heads)" "$pfx" "$cur" "."
1464 local pfx="${cur%.*}."
1467 argprompt cmd confirm needsfile noconsole norescan
1468 prompt revprompt revunmerged title
1473 local pfx="${cur%.*}."
1475 __gitcomp "cmd path" "$pfx" "$cur"
1479 local pfx="${cur%.*}."
1481 __gitcomp "cmd path" "$pfx" "$cur"
1485 local pfx="${cur%.*}."
1487 __gitcomp "cmd path trustExitCode" "$pfx" "$cur"
1491 local pfx="${cur%.*}."
1493 __gitcomp "$(__git_all_commands)" "$pfx" "$cur"
1497 local pfx="${cur%.*}."
1500 url proxy fetch push mirror skipDefaultUpdate
1501 receivepack uploadpack tagopt
1506 local pfx="${cur%.*}."
1508 __gitcomp "$(__git_remotes)" "$pfx" "$cur" "."
1512 local pfx="${cur%.*}."
1514 __gitcomp "insteadof" "$pfx" "$cur"
1521 branch.autosetupmerge
1522 branch.autosetuprebase
1525 color.branch.current
1536 color.diff.whitespace
1541 color.interactive.header
1542 color.interactive.help
1543 color.interactive.prompt
1548 color.status.changed
1550 color.status.nobranch
1551 color.status.untracked
1552 color.status.updated
1559 core.deltaBaseCacheLimit
1563 core.fsyncobjectfiles
1565 core.ignoreCygwinFSTricks
1567 core.logAllRefUpdates
1568 core.loosecompression
1570 core.packedGitWindowSize
1572 core.preferSymlinkRefs
1575 core.repositoryFormatVersion
1577 core.sharedRepository
1580 core.warnAmbiguousRefs
1583 diff.autorefreshindex
1589 diff.suppressBlankEmpty
1601 format.subjectprefix
1610 gc.reflogexpireunreachable
1614 gitcvs.commitmsgannotation
1615 gitcvs.dbTableNamePrefix
1626 gui.copyblamethreshold
1630 gui.matchtrackingbranch
1631 gui.newbranchtemplate
1632 gui.pruneduringfetch
1633 gui.spellingdictionary
1649 i18n.logOutputEncoding
1654 imap.preformattedHTML
1663 interactive.singlekey
1676 mergetool.keepBackup
1679 pack.deltaCacheLimit
1692 receive.denyCurrentBranch
1694 receive.denyNonFastForwards
1697 repack.usedeltabaseoffset
1700 sendemail.aliasesfile
1701 sendemail.aliasesfiletype
1705 sendemail.chainreplyto
1707 sendemail.envelopesender
1709 sendemail.signedoffbycc
1710 sendemail.smtpencryption
1712 sendemail.smtpserver
1713 sendemail.smtpserverport
1715 sendemail.suppresscc
1716 sendemail.suppressfrom
1721 status.relativePaths
1722 status.showUntrackedFiles
1724 transfer.unpackLimit
1736 local subcommands="add rename rm show prune update set-head"
1737 local subcommand="$(__git_find_subcommand "$subcommands")"
1738 if [ -z "$subcommand" ]; then
1739 __gitcomp "$subcommands"
1743 case "$subcommand" in
1744 rename|rm|show|prune)
1745 __gitcomp "$(__git_remotes)"
1748 local i c='' IFS=$'\n'
1749 for i in $(git --git-dir="$(__gitdir)" config --list); do
1767 __git_has_doubledash && return
1769 local cur="${COMP_WORDS[COMP_CWORD]}"
1772 __gitcomp "--merge --mixed --hard --soft"
1776 __gitcomp "$(__git_refs)"
1781 local cur="${COMP_WORDS[COMP_CWORD]}"
1784 __gitcomp "--edit --mainline --no-edit --no-commit --signoff"
1788 __gitcomp "$(__git_refs)"
1793 __git_has_doubledash && return
1795 local cur="${COMP_WORDS[COMP_CWORD]}"
1798 __gitcomp "--cached --dry-run --ignore-unmatch --quiet"
1807 __git_has_doubledash && return
1809 local cur="${COMP_WORDS[COMP_CWORD]}"
1813 $__git_log_common_options
1814 $__git_log_shortlog_options
1815 --numbered --summary
1820 __git_complete_revlist
1825 __git_has_doubledash && return
1827 local cur="${COMP_WORDS[COMP_CWORD]}"
1830 __gitcomp "$__git_log_pretty_formats
1831 " "" "${cur##--pretty=}"
1835 __gitcomp "$__git_log_pretty_formats
1836 " "" "${cur##--format=}"
1840 __gitcomp "--pretty= --format= --abbrev-commit --oneline
1841 $__git_diff_common_options
1851 local cur="${COMP_WORDS[COMP_CWORD]}"
1855 --all --remotes --topo-order --current --more=
1856 --list --independent --merge-base --no-name
1858 --sha1-name --sparse --topics --reflog
1863 __git_complete_revlist
1868 local subcommands='save list show apply clear drop pop create branch'
1869 local subcommand="$(__git_find_subcommand "$subcommands")"
1870 if [ -z "$subcommand" ]; then
1871 __gitcomp "$subcommands"
1873 local cur="${COMP_WORDS[COMP_CWORD]}"
1874 case "$subcommand,$cur" in
1876 __gitcomp "--keep-index"
1881 show,--*|drop,--*|pop,--*|branch,--*)
1884 show,*|apply,*|drop,*|pop,*|branch,*)
1885 __gitcomp "$(git --git-dir="$(__gitdir)" stash list \
1886 | sed -n -e 's/:.*//p')"
1897 __git_has_doubledash && return
1899 local subcommands="add status init update summary foreach sync"
1900 if [ -z "$(__git_find_subcommand "$subcommands")" ]; then
1901 local cur="${COMP_WORDS[COMP_CWORD]}"
1904 __gitcomp "--quiet --cached"
1907 __gitcomp "$subcommands"
1917 init fetch clone rebase dcommit log find-rev
1918 set-tree commit-diff info create-ignore propget
1919 proplist show-ignore show-externals branch tag blame
1922 local subcommand="$(__git_find_subcommand "$subcommands")"
1923 if [ -z "$subcommand" ]; then
1924 __gitcomp "$subcommands"
1926 local remote_opts="--username= --config-dir= --no-auth-cache"
1928 --follow-parent --authors-file= --repack=
1929 --no-metadata --use-svm-props --use-svnsync-props
1930 --log-window-size= --no-checkout --quiet
1931 --repack-flags --use-log-author --localtime
1932 --ignore-paths= $remote_opts
1935 --template= --shared= --trunk= --tags=
1936 --branches= --stdlayout --minimize-url
1937 --no-metadata --use-svm-props --use-svnsync-props
1938 --rewrite-root= --prefix= --use-log-author
1939 --add-author-from $remote_opts
1942 --edit --rmdir --find-copies-harder --copy-similarity=
1945 local cur="${COMP_WORDS[COMP_CWORD]}"
1946 case "$subcommand,$cur" in
1948 __gitcomp "--revision= --fetch-all $fc_opts"
1951 __gitcomp "--revision= $fc_opts $init_opts"
1954 __gitcomp "$init_opts"
1958 --merge --strategy= --verbose --dry-run
1959 --fetch-all --no-rebase --commit-url
1960 --revision $cmt_opts $fc_opts
1964 __gitcomp "--stdin $cmt_opts $fc_opts"
1966 create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\
1968 __gitcomp "--revision="
1972 --limit= --revision= --verbose --incremental
1973 --oneline --show-commit --non-recursive
1974 --authors-file= --color
1979 --merge --verbose --strategy= --local
1980 --fetch-all --dry-run $fc_opts
1984 __gitcomp "--message= --file= --revision= $cmt_opts"
1990 __gitcomp "--dry-run --message --tag"
1993 __gitcomp "--dry-run --message"
1996 __gitcomp "--git-format"
2000 --config-dir= --ignore-paths= --minimize
2001 --no-auth-cache --username=
2014 while [ $c -lt $COMP_CWORD ]; do
2015 i="${COMP_WORDS[c]}"
2018 __gitcomp "$(__git_tags)"
2028 case "${COMP_WORDS[COMP_CWORD-1]}" in
2034 __gitcomp "$(__git_tags)"
2040 __gitcomp "$(__git_refs)"
2047 local i c=1 command __git_dir
2049 while [ $c -lt $COMP_CWORD ]; do
2050 i="${COMP_WORDS[c]}"
2052 --git-dir=*) __git_dir="${i#--git-dir=}" ;;
2053 --bare) __git_dir="." ;;
2054 --version|-p|--paginate) ;;
2055 --help) command="help"; break ;;
2056 *) command="$i"; break ;;
2061 if [ -z "$command" ]; then
2062 case "${COMP_WORDS[COMP_CWORD]}" in
2075 *) __gitcomp "$(__git_porcelain_commands) $(__git_aliases)" ;;
2080 local expansion=$(__git_aliased_command "$command")
2081 [ "$expansion" ] && command="$expansion"
2086 apply) _git_apply ;;
2087 archive) _git_archive ;;
2088 bisect) _git_bisect ;;
2089 bundle) _git_bundle ;;
2090 branch) _git_branch ;;
2091 checkout) _git_checkout ;;
2092 cherry) _git_cherry ;;
2093 cherry-pick) _git_cherry_pick ;;
2094 clean) _git_clean ;;
2095 clone) _git_clone ;;
2096 commit) _git_commit ;;
2097 config) _git_config ;;
2098 describe) _git_describe ;;
2100 difftool) _git_difftool ;;
2101 fetch) _git_fetch ;;
2102 format-patch) _git_format_patch ;;
2109 ls-files) _git_ls_files ;;
2110 ls-remote) _git_ls_remote ;;
2111 ls-tree) _git_ls_tree ;;
2113 mergetool) _git_mergetool;;
2114 merge-base) _git_merge_base ;;
2116 name-rev) _git_name_rev ;;
2119 rebase) _git_rebase ;;
2120 remote) _git_remote ;;
2121 reset) _git_reset ;;
2122 revert) _git_revert ;;
2124 send-email) _git_send_email ;;
2125 shortlog) _git_shortlog ;;
2127 show-branch) _git_show_branch ;;
2128 stash) _git_stash ;;
2130 submodule) _git_submodule ;;
2133 whatchanged) _git_log ;;
2140 __git_has_doubledash && return
2142 local cur="${COMP_WORDS[COMP_CWORD]}"
2143 local g="$(__gitdir)"
2145 if [ -f "$g/MERGE_HEAD" ]; then
2151 $__git_log_common_options
2152 $__git_log_gitk_options
2158 __git_complete_revlist
2161 complete -o bashdefault -o default -o nospace -F _git git 2>/dev/null \
2162 || complete -o default -o nospace -F _git git
2163 complete -o bashdefault -o default -o nospace -F _gitk gitk 2>/dev/null \
2164 || complete -o default -o nospace -F _gitk gitk
2166 # The following are necessary only for Cygwin, and only are needed
2167 # when the user has tab-completed the executable name and consequently
2168 # included the '.exe' suffix.
2170 if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
2171 complete -o bashdefault -o default -o nospace -F _git git.exe 2>/dev/null \
2172 || complete -o default -o nospace -F _git git.exe