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 # None of this will work if git isn't available.
63 if [ -z "$GIT_EXISTS" ]; then
64 if [ -z "$(git version 2>/dev/null)" ]; then
71 [ "$GIT_EXISTS" = "yes" ]
75 # __gitdir accepts 0 or 1 arguments (i.e., location)
76 # returns location of .git repo
81 elif [ -z "${1-}" ]; then
82 if [ -n "${__git_dir-}" ]; then
84 elif [ -d .git ]; then
87 git rev-parse --git-dir 2>/dev/null
89 elif [ -d "$1/.git" ]; then
96 # __git_ps1 accepts 0 or 1 arguments (i.e., format string)
97 # returns text to add to bash PS1 prompt (includes branch name)
100 local g="$(__gitdir)"
104 if [ -d "$g/rebase-apply" ]; then
105 if [ -f "$g/rebase-apply/rebasing" ]; then
107 elif [ -f "$g/rebase-apply/applying" ]; then
112 b="$(git symbolic-ref HEAD 2>/dev/null)"
113 elif [ -f "$g/rebase-merge/interactive" ]; then
115 b="$(cat "$g/rebase-merge/head-name")"
116 elif [ -d "$g/rebase-merge" ]; then
118 b="$(cat "$g/rebase-merge/head-name")"
119 elif [ -f "$g/MERGE_HEAD" ]; then
121 b="$(git symbolic-ref HEAD 2>/dev/null)"
123 if [ -f "$g/BISECT_LOG" ]; then
126 if ! b="$(git symbolic-ref HEAD 2>/dev/null)"; then
127 if ! b="$(git describe --exact-match HEAD 2>/dev/null)"; then
128 if [ -r "$g/HEAD" ]; then
129 b="$(cut -c1-7 "$g/HEAD")..."
139 if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then
140 if [ "true" = "$(git config --bool core.bare 2>/dev/null)" ]; then
145 elif [ "true" = "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
146 if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ]; then
147 if [ "$(git config --bool bash.showDirtyState)" != "false" ]; then
148 git diff --no-ext-diff --ignore-submodules \
149 --quiet --exit-code || w="*"
150 if git rev-parse --quiet --verify HEAD >/dev/null; then
151 git diff-index --cached --quiet \
152 --ignore-submodules HEAD -- || i="+"
161 if [ -n "${1-}" ]; then
162 printf "$1" "$c${b##refs/heads/}$w$i$r"
164 printf " (%s)" "$c${b##refs/heads/}$w$i$r"
170 # __gitcomp_1 requires 2 arguments
173 local c IFS=' '$'\t'$'\n'
176 --*=*) printf %s$'\n' "$c$2" ;;
177 *.) printf %s$'\n' "$c$2" ;;
178 *) printf %s$'\n' "$c$2 " ;;
183 # __gitcomp accepts 1, 2, 3, or 4 arguments
184 # generates completion reply with compgen
187 local cur="${COMP_WORDS[COMP_CWORD]}"
188 if [ $# -gt 2 ]; then
197 COMPREPLY=($(compgen -P "${2-}" \
198 -W "$(__gitcomp_1 "${1-}" "${4-}")" \
204 # __git_heads accepts 0 or 1 arguments (to pass to __gitdir)
207 local cmd i is_hash=y dir="$(__gitdir "${1-}")"
208 if [ -d "$dir" ]; then
209 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
213 for i in $(git ls-remote "${1-}" 2>/dev/null); do
214 case "$is_hash,$i" in
217 n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
218 n,*) is_hash=y; echo "$i" ;;
223 # __git_tags accepts 0 or 1 arguments (to pass to __gitdir)
226 local cmd i is_hash=y dir="$(__gitdir "${1-}")"
227 if [ -d "$dir" ]; then
228 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
232 for i in $(git ls-remote "${1-}" 2>/dev/null); do
233 case "$is_hash,$i" in
236 n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
237 n,*) is_hash=y; echo "$i" ;;
242 # __git_refs accepts 0 or 1 arguments (to pass to __gitdir)
245 local i is_hash=y dir="$(__gitdir "${1-}")"
246 local cur="${COMP_WORDS[COMP_CWORD]}" format refs
247 if [ -d "$dir" ]; then
254 if [ -e "$dir/HEAD" ]; then echo HEAD; fi
255 format="refname:short"
256 refs="refs/tags refs/heads refs/remotes"
259 git --git-dir="$dir" for-each-ref --format="%($format)" \
263 for i in $(git ls-remote "$dir" 2>/dev/null); do
264 case "$is_hash,$i" in
267 n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
268 n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
269 n,refs/remotes/*) is_hash=y; echo "${i#refs/remotes/}" ;;
270 n,*) is_hash=y; echo "$i" ;;
275 # __git_refs2 requires 1 argument (to pass to __git_refs)
279 for i in $(__git_refs "$1"); do
284 # __git_refs_remotes requires 1 argument (to pass to ls-remote)
285 __git_refs_remotes ()
287 local cmd i is_hash=y
288 for i in $(git ls-remote "$1" 2>/dev/null); do
289 case "$is_hash,$i" in
292 echo "$i:refs/remotes/$1/${i#refs/heads/}"
296 n,refs/tags/*) is_hash=y;;
304 local i ngoff IFS=$'\n' d="$(__gitdir)"
305 shopt -q nullglob || ngoff=1
307 for i in "$d/remotes"/*; do
308 echo ${i#$d/remotes/}
310 [ "$ngoff" ] && shopt -u nullglob
311 for i in $(git --git-dir="$d" config --list); do
321 __git_merge_strategies ()
323 if [ -n "${__git_merge_strategylist-}" ]; then
324 echo "$__git_merge_strategylist"
327 git merge -s help 2>&1 |
328 sed -n -e '/[Aa]vailable strategies are: /,/^$/{
336 __git_merge_strategylist=
337 __git_merge_strategylist=$(__git_merge_strategies 2>/dev/null)
339 __git_complete_file ()
341 local pfx ls ref cur="${COMP_WORDS[COMP_CWORD]}"
358 case "$COMP_WORDBREAKS" in
360 *) pfx="$ref:$pfx" ;;
364 COMPREPLY=($(compgen -P "$pfx" \
365 -W "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \
366 | sed '/^100... blob /{
382 __gitcomp "$(__git_refs)"
387 __git_complete_revlist ()
389 local pfx cur="${COMP_WORDS[COMP_CWORD]}"
394 __gitcomp "$(__git_refs)" "$pfx" "$cur"
399 __gitcomp "$(__git_refs)" "$pfx" "$cur"
402 __gitcomp "$(__git_refs)"
407 __git_complete_remote_or_refspec ()
409 local cmd="${COMP_WORDS[1]}"
410 local cur="${COMP_WORDS[COMP_CWORD]}"
411 local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0
412 while [ $c -lt $COMP_CWORD ]; do
415 --all|--mirror) [ "$cmd" = "push" ] && no_complete_refspec=1 ;;
417 *) remote="$i"; break ;;
421 if [ -z "$remote" ]; then
422 __gitcomp "$(__git_remotes)"
425 if [ $no_complete_refspec = 1 ]; then
429 [ "$remote" = "." ] && remote=
432 case "$COMP_WORDBREAKS" in
434 *) pfx="${cur%%:*}:" ;;
446 if [ $lhs = 1 ]; then
447 __gitcomp "$(__git_refs2 "$remote")" "$pfx" "$cur"
449 __gitcomp "$(__git_refs)" "$pfx" "$cur"
453 if [ $lhs = 1 ]; then
454 __gitcomp "$(__git_refs "$remote")" "$pfx" "$cur"
456 __gitcomp "$(__git_refs)" "$pfx" "$cur"
460 if [ $lhs = 1 ]; then
461 __gitcomp "$(__git_refs)" "$pfx" "$cur"
463 __gitcomp "$(__git_refs "$remote")" "$pfx" "$cur"
469 __git_complete_strategy ()
471 case "${COMP_WORDS[COMP_CWORD-1]}" in
473 __gitcomp "$(__git_merge_strategies)"
476 local cur="${COMP_WORDS[COMP_CWORD]}"
479 __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}"
486 __git_all_commands ()
488 if [ -n "${__git_all_commandlist-}" ]; then
489 echo "$__git_all_commandlist"
493 for i in $(git help -a|egrep '^ ')
496 *--*) : helper pattern;;
501 __git_all_commandlist=
502 __git_all_commandlist="$(__git_all_commands 2>/dev/null)"
504 __git_porcelain_commands ()
506 if [ -n "${__git_porcelain_commandlist-}" ]; then
507 echo "$__git_porcelain_commandlist"
511 for i in "help" $(__git_all_commands)
514 *--*) : helper pattern;;
515 applymbox) : ask gittus;;
516 applypatch) : ask gittus;;
517 archimport) : import;;
518 cat-file) : plumbing;;
519 check-attr) : plumbing;;
520 check-ref-format) : plumbing;;
521 checkout-index) : plumbing;;
522 commit-tree) : plumbing;;
523 count-objects) : infrequent;;
524 cvsexportcommit) : export;;
525 cvsimport) : import;;
526 cvsserver) : daemon;;
528 diff-files) : plumbing;;
529 diff-index) : plumbing;;
530 diff-tree) : plumbing;;
531 fast-import) : import;;
532 fast-export) : export;;
533 fsck-objects) : plumbing;;
534 fetch-pack) : plumbing;;
535 fmt-merge-msg) : plumbing;;
536 for-each-ref) : plumbing;;
537 hash-object) : plumbing;;
538 http-*) : transport;;
539 index-pack) : plumbing;;
540 init-db) : deprecated;;
541 local-fetch) : plumbing;;
542 lost-found) : infrequent;;
543 ls-files) : plumbing;;
544 ls-remote) : plumbing;;
545 ls-tree) : plumbing;;
546 mailinfo) : plumbing;;
547 mailsplit) : plumbing;;
548 merge-*) : plumbing;;
551 pack-objects) : plumbing;;
552 pack-redundant) : plumbing;;
553 pack-refs) : plumbing;;
554 parse-remote) : plumbing;;
555 patch-id) : plumbing;;
556 peek-remote) : plumbing;;
558 prune-packed) : plumbing;;
559 quiltimport) : import;;
560 read-tree) : plumbing;;
561 receive-pack) : plumbing;;
563 repo-config) : deprecated;;
565 rev-list) : plumbing;;
566 rev-parse) : plumbing;;
567 runstatus) : plumbing;;
568 sh-setup) : internal;;
570 show-ref) : plumbing;;
571 send-pack) : plumbing;;
572 show-index) : plumbing;;
574 stripspace) : plumbing;;
575 symbolic-ref) : plumbing;;
576 tar-tree) : deprecated;;
577 unpack-file) : plumbing;;
578 unpack-objects) : plumbing;;
579 update-index) : plumbing;;
580 update-ref) : plumbing;;
581 update-server-info) : daemon;;
582 upload-archive) : plumbing;;
583 upload-pack) : plumbing;;
584 write-tree) : plumbing;;
586 verify-pack) : infrequent;;
587 verify-tag) : plumbing;;
592 __git_porcelain_commandlist=
593 __git_porcelain_commandlist="$(__git_porcelain_commands 2>/dev/null)"
598 for i in $(git --git-dir="$(__gitdir)" config --list); do
608 # __git_aliased_command requires 1 argument
609 __git_aliased_command ()
611 local word cmdline=$(git --git-dir="$(__gitdir)" \
612 config --get "alias.$1")
613 for word in $cmdline; do
614 if [ "${word##-*}" ]; then
621 # __git_find_subcommand requires 1 argument
622 __git_find_subcommand ()
624 local word subcommand c=1
626 while [ $c -lt $COMP_CWORD ]; do
627 word="${COMP_WORDS[c]}"
628 for subcommand in $1; do
629 if [ "$subcommand" = "$word" ]; then
638 __git_has_doubledash ()
641 while [ $c -lt $COMP_CWORD ]; do
642 if [ "--" = "${COMP_WORDS[c]}" ]; then
650 __git_whitespacelist="nowarn warn error error-all fix"
654 local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)"
655 if [ -d "$dir"/rebase-apply ]; then
656 __gitcomp "--skip --resolved --abort"
661 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
666 --3way --committer-date-is-author-date --ignore-date
667 --interactive --keep --no-utf8 --signoff --utf8
677 local cur="${COMP_WORDS[COMP_CWORD]}"
680 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
685 --stat --numstat --summary --check --index
686 --cached --index-info --reverse --reject --unidiff-zero
687 --apply --no-add --exclude=
688 --whitespace= --inaccurate-eof --verbose
697 __git_has_doubledash && return
699 local cur="${COMP_WORDS[COMP_CWORD]}"
703 --interactive --refresh --patch --update --dry-run
704 --ignore-errors --intent-to-add
713 local cur="${COMP_WORDS[COMP_CWORD]}"
716 __gitcomp "$(git archive --list)" "" "${cur##--format=}"
720 __gitcomp "$(__git_remotes)" "" "${cur##--remote=}"
725 --format= --list --verbose
726 --prefix= --remote= --exec=
736 __git_has_doubledash && return
738 local subcommands="start bad good skip reset visualize replay log run"
739 local subcommand="$(__git_find_subcommand "$subcommands")"
740 if [ -z "$subcommand" ]; then
741 __gitcomp "$subcommands"
745 case "$subcommand" in
747 __gitcomp "$(__git_refs)"
757 local i c=1 only_local_ref="n" has_r="n"
759 while [ $c -lt $COMP_CWORD ]; do
762 -d|-m) only_local_ref="y" ;;
768 case "${COMP_WORDS[COMP_CWORD]}" in
771 --color --no-color --verbose --abbrev= --no-abbrev
772 --track --no-track --contains --merged --no-merged
776 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
777 __gitcomp "$(__git_heads)"
779 __gitcomp "$(__git_refs)"
787 local cmd="${COMP_WORDS[2]}"
788 case "$COMP_CWORD" in
790 __gitcomp "create list-heads verify unbundle"
798 __git_complete_revlist
807 __git_has_doubledash && return
809 __gitcomp "$(__git_refs)"
814 __gitcomp "$(__git_refs)"
819 local cur="${COMP_WORDS[COMP_CWORD]}"
822 __gitcomp "--edit --no-commit"
825 __gitcomp "$(__git_refs)"
832 __git_has_doubledash && return
834 local cur="${COMP_WORDS[COMP_CWORD]}"
837 __gitcomp "--dry-run --quiet"
846 local cur="${COMP_WORDS[COMP_CWORD]}"
871 __git_has_doubledash && return
873 local cur="${COMP_WORDS[COMP_CWORD]}"
877 --all --author= --signoff --verify --no-verify
878 --edit --amend --include --only --interactive
887 local cur="${COMP_WORDS[COMP_CWORD]}"
891 --all --tags --contains --abbrev= --candidates=
892 --exact-match --debug --long --match --always
896 __gitcomp "$(__git_refs)"
899 __git_diff_common_options="--stat --numstat --shortstat --summary
900 --patch-with-stat --name-only --name-status --color
901 --no-color --color-words --no-renames --check
902 --full-index --binary --abbrev --diff-filter=
904 --text --ignore-space-at-eol --ignore-space-change
905 --ignore-all-space --exit-code --quiet --ext-diff
907 --no-prefix --src-prefix= --dst-prefix=
908 --inter-hunk-context=
915 __git_has_doubledash && return
917 local cur="${COMP_WORDS[COMP_CWORD]}"
920 __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
921 --base --ours --theirs
922 $__git_diff_common_options
930 __git_mergetools_common="diffuse ecmerge emerge kdiff3 meld opendiff
931 tkdiff vimdiff gvimdiff xxdiff
936 local cur="${COMP_WORDS[COMP_CWORD]}"
939 __gitcomp "$__git_mergetools_common kompare" "" "${cur##--tool=}"
950 __git_fetch_options="
951 --quiet --verbose --append --upload-pack --force --keep --depth=
957 local cur="${COMP_WORDS[COMP_CWORD]}"
960 __gitcomp "$__git_fetch_options"
964 __git_complete_remote_or_refspec
969 local cur="${COMP_WORDS[COMP_CWORD]}"
974 " "" "${cur##--thread=}"
979 --stdout --attach --no-attach --thread --thread=
981 --numbered --start-number
986 --full-index --binary
989 --no-prefix --src-prefix= --dst-prefix=
990 --inline --suffix= --ignore-if-in-upstream
996 __git_complete_revlist
1001 local cur="${COMP_WORDS[COMP_CWORD]}"
1005 --tags --root --unreachable --cache --no-reflogs --full
1006 --strict --verbose --lost-found
1016 local cur="${COMP_WORDS[COMP_CWORD]}"
1019 __gitcomp "--prune --aggressive"
1028 __git_has_doubledash && return
1030 local cur="${COMP_WORDS[COMP_CWORD]}"
1035 --text --ignore-case --word-regexp --invert-match
1037 --extended-regexp --basic-regexp --fixed-strings
1038 --files-with-matches --name-only
1039 --files-without-match
1041 --and --or --not --all-match
1051 local cur="${COMP_WORDS[COMP_CWORD]}"
1054 __gitcomp "--all --info --man --web"
1058 __gitcomp "$(__git_all_commands)
1059 attributes cli core-tutorial cvs-migration
1060 diffcore gitk glossary hooks ignore modules
1061 repository-layout tutorial tutorial-2
1068 local cur="${COMP_WORDS[COMP_CWORD]}"
1072 false true umask group all world everybody
1073 " "" "${cur##--shared=}"
1077 __gitcomp "--quiet --bare --template= --shared --shared="
1086 __git_has_doubledash && return
1088 local cur="${COMP_WORDS[COMP_CWORD]}"
1091 __gitcomp "--cached --deleted --modified --others --ignored
1092 --stage --directory --no-empty-directory --unmerged
1093 --killed --exclude= --exclude-from=
1094 --exclude-per-directory= --exclude-standard
1095 --error-unmatch --with-tree= --full-name
1096 --abbrev --ignored --exclude-per-directory
1106 __gitcomp "$(__git_remotes)"
1114 # Options that go well for log, shortlog and gitk
1115 __git_log_common_options="
1117 --branches --tags --remotes
1118 --first-parent --no-merges
1120 --max-age= --since= --after=
1121 --min-age= --until= --before=
1123 # Options that go well for log and gitk (not shortlog)
1124 __git_log_gitk_options="
1125 --dense --sparse --full-history
1126 --simplify-merges --simplify-by-decoration
1129 # Options that go well for log and shortlog (not gitk)
1130 __git_log_shortlog_options="
1131 --author= --committer= --grep=
1135 __git_log_pretty_formats="oneline short medium full fuller email raw format:"
1139 __git_has_doubledash && return
1141 local cur="${COMP_WORDS[COMP_CWORD]}"
1142 local g="$(git rev-parse --git-dir 2>/dev/null)"
1144 if [ -f "$g/MERGE_HEAD" ]; then
1149 __gitcomp "$__git_log_pretty_formats
1150 " "" "${cur##--pretty=}"
1154 __gitcomp "$__git_log_pretty_formats
1155 " "" "${cur##--format=}"
1160 relative iso8601 rfc2822 short local default
1161 " "" "${cur##--date=}"
1166 $__git_log_common_options
1167 $__git_log_shortlog_options
1168 $__git_log_gitk_options
1169 --root --topo-order --date-order --reverse
1171 --abbrev-commit --abbrev=
1172 --relative-date --date=
1173 --pretty= --format= --oneline
1178 --parents --children
1180 $__git_diff_common_options
1181 --pickaxe-all --pickaxe-regex
1186 __git_complete_revlist
1189 __git_merge_options="
1190 --no-commit --no-stat --log --no-log --squash --strategy
1191 --commit --stat --no-squash --ff --no-ff
1196 __git_complete_strategy && return
1198 local cur="${COMP_WORDS[COMP_CWORD]}"
1201 __gitcomp "$__git_merge_options"
1204 __gitcomp "$(__git_refs)"
1209 local cur="${COMP_WORDS[COMP_CWORD]}"
1212 __gitcomp "$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"
1225 __gitcomp "$(__git_refs)"
1230 local cur="${COMP_WORDS[COMP_CWORD]}"
1233 __gitcomp "--dry-run"
1242 __gitcomp "--tags --all --stdin"
1247 __git_complete_strategy && return
1249 local cur="${COMP_WORDS[COMP_CWORD]}"
1253 --rebase --no-rebase
1254 $__git_merge_options
1255 $__git_fetch_options
1260 __git_complete_remote_or_refspec
1265 local cur="${COMP_WORDS[COMP_CWORD]}"
1266 case "${COMP_WORDS[COMP_CWORD-1]}" in
1268 __gitcomp "$(__git_remotes)"
1273 __gitcomp "$(__git_remotes)" "" "${cur##--repo=}"
1278 --all --mirror --tags --dry-run --force --verbose
1279 --receive-pack= --repo=
1284 __git_complete_remote_or_refspec
1289 local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)"
1290 if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
1291 __gitcomp "--continue --skip --abort"
1294 __git_complete_strategy && return
1297 __gitcomp "--onto --merge --strategy --interactive"
1300 __gitcomp "$(__git_refs)"
1305 local cur="${COMP_WORDS[COMP_CWORD]}"
1308 __gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to
1309 --compose --dry-run --envelope-sender --from --identity
1310 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
1311 --no-suppress-from --no-thread --quiet
1312 --signed-off-by-cc --smtp-pass --smtp-server
1313 --smtp-server-port --smtp-ssl --smtp-user --subject
1314 --suppress-cc --suppress-from --thread --to
1315 --validate --no-validate"
1324 local cur="${COMP_WORDS[COMP_CWORD]}"
1325 local prv="${COMP_WORDS[COMP_CWORD-1]}"
1328 __gitcomp "$(__git_remotes)"
1332 __gitcomp "$(__git_refs)"
1336 local remote="${prv#remote.}"
1337 remote="${remote%.fetch}"
1338 __gitcomp "$(__git_refs_remotes "$remote")"
1342 local remote="${prv#remote.}"
1343 remote="${remote%.push}"
1344 __gitcomp "$(git --git-dir="$(__gitdir)" \
1345 for-each-ref --format='%(refname):%(refname)' \
1349 pull.twohead|pull.octopus)
1350 __gitcomp "$(__git_merge_strategies)"
1353 color.branch|color.diff|color.interactive|color.status|color.ui)
1354 __gitcomp "always never auto"
1358 __gitcomp "false true"
1363 normal black red green yellow blue magenta cyan white
1364 bold dim ul blink reverse
1376 --global --system --file=
1377 --list --replace-all
1378 --get --get-all --get-regexp
1379 --add --unset --unset-all
1380 --remove-section --rename-section
1385 local pfx="${cur%.*}."
1387 __gitcomp "remote merge mergeoptions" "$pfx" "$cur"
1391 local pfx="${cur%.*}."
1393 __gitcomp "$(__git_heads)" "$pfx" "$cur" "."
1397 local pfx="${cur%.*}."
1400 url proxy fetch push mirror skipDefaultUpdate
1401 receivepack uploadpack tagopt
1406 local pfx="${cur%.*}."
1408 __gitcomp "$(__git_remotes)" "$pfx" "$cur" "."
1414 branch.autosetupmerge
1415 branch.autosetuprebase
1418 color.branch.current
1429 color.diff.whitespace
1431 color.interactive.header
1432 color.interactive.help
1433 color.interactive.prompt
1437 color.status.changed
1439 color.status.nobranch
1440 color.status.untracked
1441 color.status.updated
1447 core.deltaBaseCacheLimit
1451 core.fsyncobjectfiles
1453 core.ignoreCygwinFSTricks
1455 core.logAllRefUpdates
1456 core.loosecompression
1458 core.packedGitWindowSize
1460 core.preferSymlinkRefs
1463 core.repositoryFormatVersion
1465 core.sharedRepository
1468 core.warnAmbiguousRefs
1471 diff.autorefreshindex
1488 gc.reflogexpireunreachable
1492 gitcvs.dbTableNamePrefix
1502 gui.copyblamethreshold
1506 gui.matchtrackingbranch
1507 gui.newbranchtemplate
1508 gui.pruneduringfetch
1509 gui.spellingdictionary
1525 i18n.logOutputEncoding
1540 mergetool.keepBackup
1542 pack.deltaCacheLimit
1552 receive.denyCurrentBranch
1554 receive.denyNonFastForwards
1557 repack.usedeltabaseoffset
1561 status.relativePaths
1562 status.showUntrackedFiles
1564 transfer.unpackLimit
1575 local subcommands="add rename rm show prune update set-head"
1576 local subcommand="$(__git_find_subcommand "$subcommands")"
1577 if [ -z "$subcommand" ]; then
1578 __gitcomp "$subcommands"
1582 case "$subcommand" in
1583 rename|rm|show|prune)
1584 __gitcomp "$(__git_remotes)"
1587 local i c='' IFS=$'\n'
1588 for i in $(git --git-dir="$(__gitdir)" config --list); do
1606 __git_has_doubledash && return
1608 local cur="${COMP_WORDS[COMP_CWORD]}"
1611 __gitcomp "--merge --mixed --hard --soft"
1615 __gitcomp "$(__git_refs)"
1620 local cur="${COMP_WORDS[COMP_CWORD]}"
1623 __gitcomp "--edit --mainline --no-edit --no-commit --signoff"
1627 __gitcomp "$(__git_refs)"
1632 __git_has_doubledash && return
1634 local cur="${COMP_WORDS[COMP_CWORD]}"
1637 __gitcomp "--cached --dry-run --ignore-unmatch --quiet"
1646 __git_has_doubledash && return
1648 local cur="${COMP_WORDS[COMP_CWORD]}"
1652 $__git_log_common_options
1653 $__git_log_shortlog_options
1654 --numbered --summary
1659 __git_complete_revlist
1664 __git_has_doubledash && return
1666 local cur="${COMP_WORDS[COMP_CWORD]}"
1669 __gitcomp "$__git_log_pretty_formats
1670 " "" "${cur##--pretty=}"
1674 __gitcomp "$__git_log_pretty_formats
1675 " "" "${cur##--format=}"
1679 __gitcomp "--pretty= --format=
1680 $__git_diff_common_options
1690 local cur="${COMP_WORDS[COMP_CWORD]}"
1694 --all --remotes --topo-order --current --more=
1695 --list --independent --merge-base --no-name
1696 --sha1-name --topics --reflog
1701 __git_complete_revlist
1706 local subcommands='save list show apply clear drop pop create branch'
1707 local subcommand="$(__git_find_subcommand "$subcommands")"
1708 if [ -z "$subcommand" ]; then
1709 __gitcomp "$subcommands"
1711 local cur="${COMP_WORDS[COMP_CWORD]}"
1712 case "$subcommand,$cur" in
1714 __gitcomp "--keep-index"
1719 show,--*|drop,--*|pop,--*|branch,--*)
1722 show,*|apply,*|drop,*|pop,*|branch,*)
1723 __gitcomp "$(git --git-dir="$(__gitdir)" stash list \
1724 | sed -n -e 's/:.*//p')"
1735 __git_has_doubledash && return
1737 local subcommands="add status init update summary foreach sync"
1738 if [ -z "$(__git_find_subcommand "$subcommands")" ]; then
1739 local cur="${COMP_WORDS[COMP_CWORD]}"
1742 __gitcomp "--quiet --cached"
1745 __gitcomp "$subcommands"
1755 init fetch clone rebase dcommit log find-rev
1756 set-tree commit-diff info create-ignore propget
1757 proplist show-ignore show-externals branch tag blame
1760 local subcommand="$(__git_find_subcommand "$subcommands")"
1761 if [ -z "$subcommand" ]; then
1762 __gitcomp "$subcommands"
1764 local remote_opts="--username= --config-dir= --no-auth-cache"
1766 --follow-parent --authors-file= --repack=
1767 --no-metadata --use-svm-props --use-svnsync-props
1768 --log-window-size= --no-checkout --quiet
1769 --repack-flags --use-log-author --localtime
1770 --ignore-paths= $remote_opts
1773 --template= --shared= --trunk= --tags=
1774 --branches= --stdlayout --minimize-url
1775 --no-metadata --use-svm-props --use-svnsync-props
1776 --rewrite-root= --prefix= --use-log-author
1777 --add-author-from $remote_opts
1780 --edit --rmdir --find-copies-harder --copy-similarity=
1783 local cur="${COMP_WORDS[COMP_CWORD]}"
1784 case "$subcommand,$cur" in
1786 __gitcomp "--revision= --fetch-all $fc_opts"
1789 __gitcomp "--revision= $fc_opts $init_opts"
1792 __gitcomp "$init_opts"
1796 --merge --strategy= --verbose --dry-run
1797 --fetch-all --no-rebase --commit-url
1798 --revision $cmt_opts $fc_opts
1802 __gitcomp "--stdin $cmt_opts $fc_opts"
1804 create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\
1806 __gitcomp "--revision="
1810 --limit= --revision= --verbose --incremental
1811 --oneline --show-commit --non-recursive
1812 --authors-file= --color
1817 --merge --verbose --strategy= --local
1818 --fetch-all --dry-run $fc_opts
1822 __gitcomp "--message= --file= --revision= $cmt_opts"
1828 __gitcomp "--dry-run --message --tag"
1831 __gitcomp "--dry-run --message"
1834 __gitcomp "--git-format"
1838 --config-dir= --ignore-paths= --minimize
1839 --no-auth-cache --username=
1852 while [ $c -lt $COMP_CWORD ]; do
1853 i="${COMP_WORDS[c]}"
1856 __gitcomp "$(__git_tags)"
1866 case "${COMP_WORDS[COMP_CWORD-1]}" in
1872 __gitcomp "$(__git_tags)"
1878 __gitcomp "$(__git_refs)"
1885 local i c=1 command __git_dir
1887 while [ $c -lt $COMP_CWORD ]; do
1888 i="${COMP_WORDS[c]}"
1890 --git-dir=*) __git_dir="${i#--git-dir=}" ;;
1891 --bare) __git_dir="." ;;
1892 --version|-p|--paginate) ;;
1893 --help) command="help"; break ;;
1894 *) command="$i"; break ;;
1899 if [ -z "$command" ]; then
1900 case "${COMP_WORDS[COMP_CWORD]}" in
1913 *) __gitcomp "$(__git_porcelain_commands) $(__git_aliases)" ;;
1918 local expansion=$(__git_aliased_command "$command")
1919 [ "$expansion" ] && command="$expansion"
1924 apply) _git_apply ;;
1925 archive) _git_archive ;;
1926 bisect) _git_bisect ;;
1927 bundle) _git_bundle ;;
1928 branch) _git_branch ;;
1929 checkout) _git_checkout ;;
1930 cherry) _git_cherry ;;
1931 cherry-pick) _git_cherry_pick ;;
1932 clean) _git_clean ;;
1933 clone) _git_clone ;;
1934 commit) _git_commit ;;
1935 config) _git_config ;;
1936 describe) _git_describe ;;
1938 difftool) _git_difftool ;;
1939 fetch) _git_fetch ;;
1940 format-patch) _git_format_patch ;;
1947 ls-files) _git_ls_files ;;
1948 ls-remote) _git_ls_remote ;;
1949 ls-tree) _git_ls_tree ;;
1951 mergetool) _git_mergetool;;
1952 merge-base) _git_merge_base ;;
1954 name-rev) _git_name_rev ;;
1957 rebase) _git_rebase ;;
1958 remote) _git_remote ;;
1959 reset) _git_reset ;;
1960 revert) _git_revert ;;
1962 send-email) _git_send_email ;;
1963 shortlog) _git_shortlog ;;
1965 show-branch) _git_show_branch ;;
1966 stash) _git_stash ;;
1968 submodule) _git_submodule ;;
1971 whatchanged) _git_log ;;
1978 __git_has_doubledash && return
1980 local cur="${COMP_WORDS[COMP_CWORD]}"
1981 local g="$(__gitdir)"
1983 if [ -f "$g/MERGE_HEAD" ]; then
1989 $__git_log_common_options
1990 $__git_log_gitk_options
1996 __git_complete_revlist
1999 # Cache whether git exists.
2002 if [ $BASH_VERSINFO -gt 2 ]; then
2003 complete -o bashdefault -o default -o nospace -F _git git 2>/dev/null \
2004 || complete -o default -o nospace -F _git git
2005 complete -o bashdefault -o default -o nospace -F _gitk gitk 2>/dev/null \
2006 || complete -o default -o nospace -F _gitk gitk
2009 # The following are necessary only for Cygwin, and only are needed
2010 # when the user has tab-completed the executable name and consequently
2011 # included the '.exe' suffix.
2013 if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
2014 complete -o bashdefault -o default -o nospace -F _git git.exe 2>/dev/null \
2015 || complete -o default -o nospace -F _git git.exe