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) Consider changing your PS1 to also show the current branch:
25 # PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
27 # The argument to __git_ps1 will be displayed only if you
28 # are currently in a git repository. The %s token will be
29 # the name of the current branch.
31 # In addition, if you set GIT_PS1_SHOWDIRTYSTATE to a nonempty
32 # value, unstaged (*) and staged (+) changes will be shown next
33 # to the branch name. You can configure this per-repository
34 # with the bash.showDirtyState variable, which defaults to true
35 # once GIT_PS1_SHOWDIRTYSTATE is enabled.
37 # You can also see if currently something is stashed, by setting
38 # GIT_PS1_SHOWSTASHSTATE to a nonempty value. If something is stashed,
39 # then a '$' will be shown next to the branch name.
41 # If you would like to see if there're untracked files, then you can
42 # set GIT_PS1_SHOWUNTRACKEDFILES to a nonempty value. If there're
43 # untracked files, then a '%' will be shown next to the branch name.
47 # *) Read Documentation/SubmittingPatches
48 # *) Send all patches to the current maintainer:
50 # "Shawn O. Pearce" <spearce@spearce.org>
52 # *) Always CC the Git mailing list:
57 case "$COMP_WORDBREAKS" in
59 *) COMP_WORDBREAKS="$COMP_WORDBREAKS:"
62 # __gitdir accepts 0 or 1 arguments (i.e., location)
63 # returns location of .git repo
66 if [ -z "${1-}" ]; then
67 if [ -n "${__git_dir-}" ]; then
69 elif [ -d .git ]; then
72 git rev-parse --git-dir 2>/dev/null
74 elif [ -d "$1/.git" ]; then
81 # __git_ps1 accepts 0 or 1 arguments (i.e., format string)
82 # returns text to add to bash PS1 prompt (includes branch name)
89 if [ -f "$g/rebase-merge/interactive" ]; then
91 b="$(cat "$g/rebase-merge/head-name")"
92 elif [ -d "$g/rebase-merge" ]; then
94 b="$(cat "$g/rebase-merge/head-name")"
96 if [ -d "$g/rebase-apply" ]; then
97 if [ -f "$g/rebase-apply/rebasing" ]; then
99 elif [ -f "$g/rebase-apply/applying" ]; then
104 elif [ -f "$g/MERGE_HEAD" ]; then
106 elif [ -f "$g/BISECT_LOG" ]; then
110 b="$(git symbolic-ref HEAD 2>/dev/null)" || {
113 case "${GIT_PS1_DESCRIBE_STYLE-}" in
115 git describe --contains HEAD ;;
117 git describe --contains --all HEAD ;;
121 git describe --exact-match HEAD ;;
122 esac 2>/dev/null)" ||
124 b="$(cut -c1-7 "$g/HEAD" 2>/dev/null)..." ||
136 if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then
137 if [ "true" = "$(git rev-parse --is-bare-repository 2>/dev/null)" ]; then
142 elif [ "true" = "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
143 if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ]; then
144 if [ "$(git config --bool bash.showDirtyState)" != "false" ]; then
145 git diff --no-ext-diff --ignore-submodules \
146 --quiet --exit-code || w="*"
147 if git rev-parse --quiet --verify HEAD >/dev/null; then
148 git diff-index --cached --quiet \
149 --ignore-submodules HEAD -- || i="+"
155 if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ]; then
156 git rev-parse --verify refs/stash >/dev/null 2>&1 && s="$"
159 if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ]; then
160 if [ -n "$(git ls-files --others --exclude-standard)" ]; then
166 if [ -n "${1-}" ]; then
167 printf "$1" "$c${b##refs/heads/}$w$i$s$u$r"
169 printf " (%s)" "$c${b##refs/heads/}$w$i$s$u$r"
174 # __gitcomp_1 requires 2 arguments
177 local c IFS=' '$'\t'$'\n'
180 --*=*) printf %s$'\n' "$c$2" ;;
181 *.) printf %s$'\n' "$c$2" ;;
182 *) printf %s$'\n' "$c$2 " ;;
187 # __gitcomp accepts 1, 2, 3, or 4 arguments
188 # generates completion reply with compgen
191 local cur="${COMP_WORDS[COMP_CWORD]}"
192 if [ $# -gt 2 ]; then
201 COMPREPLY=($(compgen -P "${2-}" \
202 -W "$(__gitcomp_1 "${1-}" "${4-}")" \
208 # __git_heads accepts 0 or 1 arguments (to pass to __gitdir)
211 local cmd i is_hash=y dir="$(__gitdir "${1-}")"
212 if [ -d "$dir" ]; then
213 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
217 for i in $(git ls-remote "${1-}" 2>/dev/null); do
218 case "$is_hash,$i" in
221 n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
222 n,*) is_hash=y; echo "$i" ;;
227 # __git_tags accepts 0 or 1 arguments (to pass to __gitdir)
230 local cmd i is_hash=y dir="$(__gitdir "${1-}")"
231 if [ -d "$dir" ]; then
232 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
236 for i in $(git ls-remote "${1-}" 2>/dev/null); do
237 case "$is_hash,$i" in
240 n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
241 n,*) is_hash=y; echo "$i" ;;
246 # __git_refs accepts 0 or 1 arguments (to pass to __gitdir)
249 local i is_hash=y dir="$(__gitdir "${1-}")"
250 local cur="${COMP_WORDS[COMP_CWORD]}" format refs
251 if [ -d "$dir" ]; then
258 if [ -e "$dir/HEAD" ]; then echo HEAD; fi
259 format="refname:short"
260 refs="refs/tags refs/heads refs/remotes"
263 git --git-dir="$dir" for-each-ref --format="%($format)" \
267 for i in $(git ls-remote "$dir" 2>/dev/null); do
268 case "$is_hash,$i" in
271 n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
272 n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
273 n,refs/remotes/*) is_hash=y; echo "${i#refs/remotes/}" ;;
274 n,*) is_hash=y; echo "$i" ;;
279 # __git_refs2 requires 1 argument (to pass to __git_refs)
283 for i in $(__git_refs "$1"); do
288 # __git_refs_remotes requires 1 argument (to pass to ls-remote)
289 __git_refs_remotes ()
291 local cmd i is_hash=y
292 for i in $(git ls-remote "$1" 2>/dev/null); do
293 case "$is_hash,$i" in
296 echo "$i:refs/remotes/$1/${i#refs/heads/}"
300 n,refs/tags/*) is_hash=y;;
308 local i ngoff IFS=$'\n' d="$(__gitdir)"
309 shopt -q nullglob || ngoff=1
311 for i in "$d/remotes"/*; do
312 echo ${i#$d/remotes/}
314 [ "$ngoff" ] && shopt -u nullglob
315 for i in $(git --git-dir="$d" config --get-regexp 'remote\..*\.url' 2>/dev/null); do
321 __git_list_merge_strategies ()
323 git merge -s help 2>&1 |
324 sed -n -e '/[Aa]vailable strategies are: /,/^$/{
333 __git_merge_strategies=
334 # 'git merge -s help' (and thus detection of the merge strategy
335 # list) fails, unfortunately, if run outside of any git working
336 # tree. __git_merge_strategies is set to the empty string in
337 # that case, and the detection will be repeated the next time it
339 __git_compute_merge_strategies ()
341 : ${__git_merge_strategies:=$(__git_list_merge_strategies)}
344 __git_complete_file ()
346 local pfx ls ref cur="${COMP_WORDS[COMP_CWORD]}"
363 case "$COMP_WORDBREAKS" in
365 *) pfx="$ref:$pfx" ;;
369 COMPREPLY=($(compgen -P "$pfx" \
370 -W "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \
371 | sed '/^100... blob /{
387 __gitcomp "$(__git_refs)"
392 __git_complete_revlist ()
394 local pfx cur="${COMP_WORDS[COMP_CWORD]}"
399 __gitcomp "$(__git_refs)" "$pfx" "$cur"
404 __gitcomp "$(__git_refs)" "$pfx" "$cur"
407 __gitcomp "$(__git_refs)"
412 __git_complete_remote_or_refspec ()
414 local cmd="${COMP_WORDS[1]}"
415 local cur="${COMP_WORDS[COMP_CWORD]}"
416 local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0
417 while [ $c -lt $COMP_CWORD ]; do
420 --mirror) [ "$cmd" = "push" ] && no_complete_refspec=1 ;;
423 push) no_complete_refspec=1 ;;
432 *) remote="$i"; break ;;
436 if [ -z "$remote" ]; then
437 __gitcomp "$(__git_remotes)"
440 if [ $no_complete_refspec = 1 ]; then
444 [ "$remote" = "." ] && remote=
447 case "$COMP_WORDBREAKS" in
449 *) pfx="${cur%%:*}:" ;;
461 if [ $lhs = 1 ]; then
462 __gitcomp "$(__git_refs2 "$remote")" "$pfx" "$cur"
464 __gitcomp "$(__git_refs)" "$pfx" "$cur"
468 if [ $lhs = 1 ]; then
469 __gitcomp "$(__git_refs "$remote")" "$pfx" "$cur"
471 __gitcomp "$(__git_refs)" "$pfx" "$cur"
475 if [ $lhs = 1 ]; then
476 __gitcomp "$(__git_refs)" "$pfx" "$cur"
478 __gitcomp "$(__git_refs "$remote")" "$pfx" "$cur"
484 __git_complete_strategy ()
486 __git_compute_merge_strategies
487 case "${COMP_WORDS[COMP_CWORD-1]}" in
489 __gitcomp "$__git_merge_strategies"
492 local cur="${COMP_WORDS[COMP_CWORD]}"
495 __gitcomp "$__git_merge_strategies" "" "${cur##--strategy=}"
502 __git_list_all_commands ()
505 for i in $(git help -a|egrep '^ [a-zA-Z0-9]')
508 *--*) : helper pattern;;
515 __git_compute_all_commands ()
517 : ${__git_all_commands:=$(__git_list_all_commands)}
520 __git_list_porcelain_commands ()
523 __git_compute_all_commands
524 for i in "help" $__git_all_commands
527 *--*) : helper pattern;;
528 applymbox) : ask gittus;;
529 applypatch) : ask gittus;;
530 archimport) : import;;
531 cat-file) : plumbing;;
532 check-attr) : plumbing;;
533 check-ref-format) : plumbing;;
534 checkout-index) : plumbing;;
535 commit-tree) : plumbing;;
536 count-objects) : infrequent;;
537 cvsexportcommit) : export;;
538 cvsimport) : import;;
539 cvsserver) : daemon;;
541 diff-files) : plumbing;;
542 diff-index) : plumbing;;
543 diff-tree) : plumbing;;
544 fast-import) : import;;
545 fast-export) : export;;
546 fsck-objects) : plumbing;;
547 fetch-pack) : plumbing;;
548 fmt-merge-msg) : plumbing;;
549 for-each-ref) : plumbing;;
550 hash-object) : plumbing;;
551 http-*) : transport;;
552 index-pack) : plumbing;;
553 init-db) : deprecated;;
554 local-fetch) : plumbing;;
555 lost-found) : infrequent;;
556 ls-files) : plumbing;;
557 ls-remote) : plumbing;;
558 ls-tree) : plumbing;;
559 mailinfo) : plumbing;;
560 mailsplit) : plumbing;;
561 merge-*) : plumbing;;
564 pack-objects) : plumbing;;
565 pack-redundant) : plumbing;;
566 pack-refs) : plumbing;;
567 parse-remote) : plumbing;;
568 patch-id) : plumbing;;
569 peek-remote) : plumbing;;
571 prune-packed) : plumbing;;
572 quiltimport) : import;;
573 read-tree) : plumbing;;
574 receive-pack) : plumbing;;
576 repo-config) : deprecated;;
578 rev-list) : plumbing;;
579 rev-parse) : plumbing;;
580 runstatus) : plumbing;;
581 sh-setup) : internal;;
583 show-ref) : plumbing;;
584 send-pack) : plumbing;;
585 show-index) : plumbing;;
587 stripspace) : plumbing;;
588 symbolic-ref) : plumbing;;
589 tar-tree) : deprecated;;
590 unpack-file) : plumbing;;
591 unpack-objects) : plumbing;;
592 update-index) : plumbing;;
593 update-ref) : plumbing;;
594 update-server-info) : daemon;;
595 upload-archive) : plumbing;;
596 upload-pack) : plumbing;;
597 write-tree) : plumbing;;
599 verify-pack) : infrequent;;
600 verify-tag) : plumbing;;
606 __git_porcelain_commands=
607 __git_compute_porcelain_commands ()
609 __git_compute_all_commands
610 : ${__git_porcelain_commands:=$(__git_list_porcelain_commands)}
616 for i in $(git --git-dir="$(__gitdir)" config --get-regexp "alias\..*" 2>/dev/null); do
626 # __git_aliased_command requires 1 argument
627 __git_aliased_command ()
629 local word cmdline=$(git --git-dir="$(__gitdir)" \
630 config --get "alias.$1")
631 for word in $cmdline; do
632 if [ "${word##-*}" ]; then
639 # __git_find_on_cmdline requires 1 argument
640 __git_find_on_cmdline ()
642 local word subcommand c=1
644 while [ $c -lt $COMP_CWORD ]; do
645 word="${COMP_WORDS[c]}"
646 for subcommand in $1; do
647 if [ "$subcommand" = "$word" ]; then
656 __git_has_doubledash ()
659 while [ $c -lt $COMP_CWORD ]; do
660 if [ "--" = "${COMP_WORDS[c]}" ]; then
668 __git_whitespacelist="nowarn warn error error-all fix"
672 local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)"
673 if [ -d "$dir"/rebase-apply ]; then
674 __gitcomp "--skip --resolved --abort"
679 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
684 --3way --committer-date-is-author-date --ignore-date
685 --ignore-whitespace --ignore-space-change
686 --interactive --keep --no-utf8 --signoff --utf8
687 --whitespace= --scissors
696 local cur="${COMP_WORDS[COMP_CWORD]}"
699 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
704 --stat --numstat --summary --check --index
705 --cached --index-info --reverse --reject --unidiff-zero
706 --apply --no-add --exclude=
707 --ignore-whitespace --ignore-space-change
708 --whitespace= --inaccurate-eof --verbose
717 __git_has_doubledash && return
719 local cur="${COMP_WORDS[COMP_CWORD]}"
723 --interactive --refresh --patch --update --dry-run
724 --ignore-errors --intent-to-add
733 local cur="${COMP_WORDS[COMP_CWORD]}"
736 __gitcomp "$(git archive --list)" "" "${cur##--format=}"
740 __gitcomp "$(__git_remotes)" "" "${cur##--remote=}"
745 --format= --list --verbose
746 --prefix= --remote= --exec=
756 __git_has_doubledash && return
758 local subcommands="start bad good skip reset visualize replay log run"
759 local subcommand="$(__git_find_on_cmdline "$subcommands")"
760 if [ -z "$subcommand" ]; then
761 __gitcomp "$subcommands"
765 case "$subcommand" in
767 __gitcomp "$(__git_refs)"
777 local i c=1 only_local_ref="n" has_r="n"
779 while [ $c -lt $COMP_CWORD ]; do
782 -d|-m) only_local_ref="y" ;;
788 case "${COMP_WORDS[COMP_CWORD]}" in
791 --color --no-color --verbose --abbrev= --no-abbrev
792 --track --no-track --contains --merged --no-merged
796 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
797 __gitcomp "$(__git_heads)"
799 __gitcomp "$(__git_refs)"
807 local cmd="${COMP_WORDS[2]}"
808 case "$COMP_CWORD" in
810 __gitcomp "create list-heads verify unbundle"
818 __git_complete_revlist
827 __git_has_doubledash && return
829 local cur="${COMP_WORDS[COMP_CWORD]}"
832 __gitcomp "diff3 merge" "" "${cur##--conflict=}"
836 --quiet --ours --theirs --track --no-track --merge
841 __gitcomp "$(__git_refs)"
848 __gitcomp "$(__git_refs)"
853 local cur="${COMP_WORDS[COMP_CWORD]}"
856 __gitcomp "--edit --no-commit"
859 __gitcomp "$(__git_refs)"
866 __git_has_doubledash && return
868 local cur="${COMP_WORDS[COMP_CWORD]}"
871 __gitcomp "--dry-run --quiet"
880 local cur="${COMP_WORDS[COMP_CWORD]}"
905 __git_has_doubledash && return
907 local cur="${COMP_WORDS[COMP_CWORD]}"
910 __gitcomp "default strip verbatim whitespace
911 " "" "${cur##--cleanup=}"
915 __gitcomp "$(__git_refs)" "" "${cur##--reuse-message=}"
919 __gitcomp "$(__git_refs)" "" "${cur##--reedit-message=}"
923 __gitcomp "all no normal" "" "${cur##--untracked-files=}"
928 --all --author= --signoff --verify --no-verify
929 --edit --amend --include --only --interactive
930 --dry-run --reuse-message= --reedit-message=
931 --reset-author --file= --message= --template=
932 --cleanup= --untracked-files --untracked-files=
942 local cur="${COMP_WORDS[COMP_CWORD]}"
946 --all --tags --contains --abbrev= --candidates=
947 --exact-match --debug --long --match --always
951 __gitcomp "$(__git_refs)"
954 __git_diff_common_options="--stat --numstat --shortstat --summary
955 --patch-with-stat --name-only --name-status --color
956 --no-color --color-words --no-renames --check
957 --full-index --binary --abbrev --diff-filter=
959 --text --ignore-space-at-eol --ignore-space-change
960 --ignore-all-space --exit-code --quiet --ext-diff
962 --no-prefix --src-prefix= --dst-prefix=
963 --inter-hunk-context=
966 --dirstat --dirstat= --dirstat-by-file
967 --dirstat-by-file= --cumulative
972 __git_has_doubledash && return
974 local cur="${COMP_WORDS[COMP_CWORD]}"
977 __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
978 --base --ours --theirs
979 $__git_diff_common_options
987 __git_mergetools_common="diffuse ecmerge emerge kdiff3 meld opendiff
988 tkdiff vimdiff gvimdiff xxdiff araxis p4merge
993 __git_has_doubledash && return
995 local cur="${COMP_WORDS[COMP_CWORD]}"
998 __gitcomp "$__git_mergetools_common kompare" "" "${cur##--tool=}"
1002 __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
1003 --base --ours --theirs
1004 --no-renames --diff-filter= --find-copies-harder
1005 --relative --ignore-submodules
1013 __git_fetch_options="
1014 --quiet --verbose --append --upload-pack --force --keep --depth=
1015 --tags --no-tags --all --prune --dry-run
1020 local cur="${COMP_WORDS[COMP_CWORD]}"
1023 __gitcomp "$__git_fetch_options"
1027 __git_complete_remote_or_refspec
1030 _git_format_patch ()
1032 local cur="${COMP_WORDS[COMP_CWORD]}"
1037 " "" "${cur##--thread=}"
1042 --stdout --attach --no-attach --thread --thread=
1044 --numbered --start-number
1048 --in-reply-to= --cc=
1049 --full-index --binary
1052 --no-prefix --src-prefix= --dst-prefix=
1053 --inline --suffix= --ignore-if-in-upstream
1059 __git_complete_revlist
1064 local cur="${COMP_WORDS[COMP_CWORD]}"
1068 --tags --root --unreachable --cache --no-reflogs --full
1069 --strict --verbose --lost-found
1079 local cur="${COMP_WORDS[COMP_CWORD]}"
1082 __gitcomp "--prune --aggressive"
1091 __git_has_doubledash && return
1093 local cur="${COMP_WORDS[COMP_CWORD]}"
1098 --text --ignore-case --word-regexp --invert-match
1100 --extended-regexp --basic-regexp --fixed-strings
1101 --files-with-matches --name-only
1102 --files-without-match
1105 --and --or --not --all-match
1111 __gitcomp "$(__git_refs)"
1116 local cur="${COMP_WORDS[COMP_CWORD]}"
1119 __gitcomp "--all --info --man --web"
1123 __git_compute_all_commands
1124 __gitcomp "$__git_all_commands
1125 attributes cli core-tutorial cvs-migration
1126 diffcore gitk glossary hooks ignore modules
1127 repository-layout tutorial tutorial-2
1134 local cur="${COMP_WORDS[COMP_CWORD]}"
1138 false true umask group all world everybody
1139 " "" "${cur##--shared=}"
1143 __gitcomp "--quiet --bare --template= --shared --shared="
1152 __git_has_doubledash && return
1154 local cur="${COMP_WORDS[COMP_CWORD]}"
1157 __gitcomp "--cached --deleted --modified --others --ignored
1158 --stage --directory --no-empty-directory --unmerged
1159 --killed --exclude= --exclude-from=
1160 --exclude-per-directory= --exclude-standard
1161 --error-unmatch --with-tree= --full-name
1162 --abbrev --ignored --exclude-per-directory
1172 __gitcomp "$(__git_remotes)"
1180 # Options that go well for log, shortlog and gitk
1181 __git_log_common_options="
1183 --branches --tags --remotes
1184 --first-parent --merges --no-merges
1186 --max-age= --since= --after=
1187 --min-age= --until= --before=
1189 # Options that go well for log and gitk (not shortlog)
1190 __git_log_gitk_options="
1191 --dense --sparse --full-history
1192 --simplify-merges --simplify-by-decoration
1195 # Options that go well for log and shortlog (not gitk)
1196 __git_log_shortlog_options="
1197 --author= --committer= --grep=
1201 __git_log_pretty_formats="oneline short medium full fuller email raw format:"
1202 __git_log_date_formats="relative iso8601 rfc2822 short local default raw"
1206 __git_has_doubledash && return
1208 local cur="${COMP_WORDS[COMP_CWORD]}"
1209 local g="$(git rev-parse --git-dir 2>/dev/null)"
1211 if [ -f "$g/MERGE_HEAD" ]; then
1216 __gitcomp "$__git_log_pretty_formats
1217 " "" "${cur##--pretty=}"
1221 __gitcomp "$__git_log_pretty_formats
1222 " "" "${cur##--format=}"
1226 __gitcomp "$__git_log_date_formats" "" "${cur##--date=}"
1230 __gitcomp "long short" "" "${cur##--decorate=}"
1235 $__git_log_common_options
1236 $__git_log_shortlog_options
1237 $__git_log_gitk_options
1238 --root --topo-order --date-order --reverse
1239 --follow --full-diff
1240 --abbrev-commit --abbrev=
1241 --relative-date --date=
1242 --pretty= --format= --oneline
1245 --decorate --decorate=
1247 --parents --children
1249 $__git_diff_common_options
1250 --pickaxe-all --pickaxe-regex
1255 __git_complete_revlist
1258 __git_merge_options="
1259 --no-commit --no-stat --log --no-log --squash --strategy
1260 --commit --stat --no-squash --ff --no-ff --ff-only
1265 __git_complete_strategy && return
1267 local cur="${COMP_WORDS[COMP_CWORD]}"
1270 __gitcomp "$__git_merge_options"
1273 __gitcomp "$(__git_refs)"
1278 local cur="${COMP_WORDS[COMP_CWORD]}"
1281 __gitcomp "$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"
1294 __gitcomp "$(__git_refs)"
1299 local cur="${COMP_WORDS[COMP_CWORD]}"
1302 __gitcomp "--dry-run"
1311 __gitcomp "--tags --all --stdin"
1316 __git_complete_strategy && return
1318 local cur="${COMP_WORDS[COMP_CWORD]}"
1322 --rebase --no-rebase
1323 $__git_merge_options
1324 $__git_fetch_options
1329 __git_complete_remote_or_refspec
1334 local cur="${COMP_WORDS[COMP_CWORD]}"
1335 case "${COMP_WORDS[COMP_CWORD-1]}" in
1337 __gitcomp "$(__git_remotes)"
1342 __gitcomp "$(__git_remotes)" "" "${cur##--repo=}"
1347 --all --mirror --tags --dry-run --force --verbose
1348 --receive-pack= --repo=
1353 __git_complete_remote_or_refspec
1358 local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)"
1359 if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
1360 __gitcomp "--continue --skip --abort"
1363 __git_complete_strategy && return
1366 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
1371 --onto --merge --strategy --interactive
1372 --preserve-merges --stat --no-stat
1373 --committer-date-is-author-date --ignore-date
1374 --ignore-whitespace --whitespace=
1379 __gitcomp "$(__git_refs)"
1382 __git_send_email_confirm_options="always never auto cc compose"
1383 __git_send_email_suppresscc_options="author self cc bodycc sob cccmd body all"
1387 local cur="${COMP_WORDS[COMP_CWORD]}"
1391 $__git_send_email_confirm_options
1392 " "" "${cur##--confirm=}"
1397 $__git_send_email_suppresscc_options
1398 " "" "${cur##--suppress-cc=}"
1402 --smtp-encryption=*)
1403 __gitcomp "ssl tls" "" "${cur##--smtp-encryption=}"
1407 __gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to
1408 --compose --confirm= --dry-run --envelope-sender
1410 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
1411 --no-suppress-from --no-thread --quiet
1412 --signed-off-by-cc --smtp-pass --smtp-server
1413 --smtp-server-port --smtp-encryption= --smtp-user
1414 --subject --suppress-cc= --suppress-from --thread --to
1415 --validate --no-validate"
1422 __git_config_get_set_variables ()
1424 local prevword word config_file= c=$COMP_CWORD
1425 while [ $c -gt 1 ]; do
1426 word="${COMP_WORDS[c]}"
1428 --global|--system|--file=*)
1433 config_file="$word $prevword"
1441 git --git-dir="$(__gitdir)" config $config_file --list 2>/dev/null |
1454 local cur="${COMP_WORDS[COMP_CWORD]}"
1455 local prv="${COMP_WORDS[COMP_CWORD-1]}"
1458 __gitcomp "$(__git_remotes)"
1462 __gitcomp "$(__git_refs)"
1466 local remote="${prv#remote.}"
1467 remote="${remote%.fetch}"
1468 __gitcomp "$(__git_refs_remotes "$remote")"
1472 local remote="${prv#remote.}"
1473 remote="${remote%.push}"
1474 __gitcomp "$(git --git-dir="$(__gitdir)" \
1475 for-each-ref --format='%(refname):%(refname)' \
1479 pull.twohead|pull.octopus)
1480 __git_compute_merge_strategies
1481 __gitcomp "$__git_merge_strategies"
1484 color.branch|color.diff|color.interactive|\
1485 color.showbranch|color.status|color.ui)
1486 __gitcomp "always never auto"
1490 __gitcomp "false true"
1495 normal black red green yellow blue magenta cyan white
1496 bold dim ul blink reverse
1501 __gitcomp "man info web html"
1505 __gitcomp "$__git_log_date_formats"
1508 sendemail.aliasesfiletype)
1509 __gitcomp "mutt mailrc pine elm gnus"
1513 __gitcomp "$__git_send_email_confirm_options"
1516 sendemail.suppresscc)
1517 __gitcomp "$__git_send_email_suppresscc_options"
1520 --get|--get-all|--unset|--unset-all)
1521 __gitcomp "$(__git_config_get_set_variables)"
1532 --global --system --file=
1533 --list --replace-all
1534 --get --get-all --get-regexp
1535 --add --unset --unset-all
1536 --remove-section --rename-section
1541 local pfx="${cur%.*}."
1543 __gitcomp "remote merge mergeoptions rebase" "$pfx" "$cur"
1547 local pfx="${cur%.*}."
1549 __gitcomp "$(__git_heads)" "$pfx" "$cur" "."
1553 local pfx="${cur%.*}."
1556 argprompt cmd confirm needsfile noconsole norescan
1557 prompt revprompt revunmerged title
1562 local pfx="${cur%.*}."
1564 __gitcomp "cmd path" "$pfx" "$cur"
1568 local pfx="${cur%.*}."
1570 __gitcomp "cmd path" "$pfx" "$cur"
1574 local pfx="${cur%.*}."
1576 __gitcomp "cmd path trustExitCode" "$pfx" "$cur"
1580 local pfx="${cur%.*}."
1582 __git_compute_all_commands
1583 __gitcomp "$__git_all_commands" "$pfx" "$cur"
1587 local pfx="${cur%.*}."
1590 url proxy fetch push mirror skipDefaultUpdate
1591 receivepack uploadpack tagopt pushurl
1596 local pfx="${cur%.*}."
1598 __gitcomp "$(__git_remotes)" "$pfx" "$cur" "."
1602 local pfx="${cur%.*}."
1604 __gitcomp "insteadOf pushInsteadOf" "$pfx" "$cur"
1611 apply.ignorewhitespace
1613 branch.autosetupmerge
1614 branch.autosetuprebase
1617 color.branch.current
1628 color.diff.whitespace
1633 color.interactive.header
1634 color.interactive.help
1635 color.interactive.prompt
1640 color.status.changed
1642 color.status.nobranch
1643 color.status.untracked
1644 color.status.updated
1651 core.deltaBaseCacheLimit
1655 core.fsyncobjectfiles
1657 core.ignoreCygwinFSTricks
1659 core.logAllRefUpdates
1660 core.loosecompression
1662 core.packedGitWindowSize
1664 core.preferSymlinkRefs
1667 core.repositoryFormatVersion
1669 core.sharedRepository
1672 core.warnAmbiguousRefs
1675 diff.autorefreshindex
1681 diff.suppressBlankEmpty
1693 format.subjectprefix
1702 gc.reflogexpireunreachable
1706 gitcvs.commitmsgannotation
1707 gitcvs.dbTableNamePrefix
1718 gui.copyblamethreshold
1722 gui.matchtrackingbranch
1723 gui.newbranchtemplate
1724 gui.pruneduringfetch
1725 gui.spellingdictionary
1741 i18n.logOutputEncoding
1746 imap.preformattedHTML
1755 interactive.singlekey
1768 mergetool.keepBackup
1771 pack.deltaCacheLimit
1784 receive.denyCurrentBranch
1786 receive.denyNonFastForwards
1789 repack.usedeltabaseoffset
1792 sendemail.aliasesfile
1793 sendemail.aliasesfiletype
1797 sendemail.chainreplyto
1799 sendemail.envelopesender
1801 sendemail.signedoffbycc
1802 sendemail.smtpencryption
1804 sendemail.smtpserver
1805 sendemail.smtpserverport
1807 sendemail.suppresscc
1808 sendemail.suppressfrom
1813 status.relativePaths
1814 status.showUntrackedFiles
1816 transfer.unpackLimit
1828 local subcommands="add rename rm show prune update set-head"
1829 local subcommand="$(__git_find_on_cmdline "$subcommands")"
1830 if [ -z "$subcommand" ]; then
1831 __gitcomp "$subcommands"
1835 case "$subcommand" in
1836 rename|rm|show|prune)
1837 __gitcomp "$(__git_remotes)"
1840 local i c='' IFS=$'\n'
1841 for i in $(git --git-dir="$(__gitdir)" config --get-regexp "remotes\..*" 2>/dev/null); do
1855 __gitcomp "$(__git_refs)"
1860 __git_has_doubledash && return
1862 local cur="${COMP_WORDS[COMP_CWORD]}"
1865 __gitcomp "--merge --mixed --hard --soft --patch"
1869 __gitcomp "$(__git_refs)"
1874 local cur="${COMP_WORDS[COMP_CWORD]}"
1877 __gitcomp "--edit --mainline --no-edit --no-commit --signoff"
1881 __gitcomp "$(__git_refs)"
1886 __git_has_doubledash && return
1888 local cur="${COMP_WORDS[COMP_CWORD]}"
1891 __gitcomp "--cached --dry-run --ignore-unmatch --quiet"
1900 __git_has_doubledash && return
1902 local cur="${COMP_WORDS[COMP_CWORD]}"
1906 $__git_log_common_options
1907 $__git_log_shortlog_options
1908 --numbered --summary
1913 __git_complete_revlist
1918 __git_has_doubledash && return
1920 local cur="${COMP_WORDS[COMP_CWORD]}"
1923 __gitcomp "$__git_log_pretty_formats
1924 " "" "${cur##--pretty=}"
1928 __gitcomp "$__git_log_pretty_formats
1929 " "" "${cur##--format=}"
1933 __gitcomp "--pretty= --format= --abbrev-commit --oneline
1934 $__git_diff_common_options
1944 local cur="${COMP_WORDS[COMP_CWORD]}"
1948 --all --remotes --topo-order --current --more=
1949 --list --independent --merge-base --no-name
1951 --sha1-name --sparse --topics --reflog
1956 __git_complete_revlist
1961 local cur="${COMP_WORDS[COMP_CWORD]}"
1962 local save_opts='--keep-index --no-keep-index --quiet --patch'
1963 local subcommands='save list show apply clear drop pop create branch'
1964 local subcommand="$(__git_find_on_cmdline "$subcommands")"
1965 if [ -z "$subcommand" ]; then
1968 __gitcomp "$save_opts"
1971 if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then
1972 __gitcomp "$subcommands"
1979 case "$subcommand,$cur" in
1981 __gitcomp "$save_opts"
1984 __gitcomp "--index --quiet"
1986 show,--*|drop,--*|branch,--*)
1989 show,*|apply,*|drop,*|pop,*|branch,*)
1990 __gitcomp "$(git --git-dir="$(__gitdir)" stash list \
1991 | sed -n -e 's/:.*//p')"
2002 __git_has_doubledash && return
2004 local subcommands="add status init update summary foreach sync"
2005 if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then
2006 local cur="${COMP_WORDS[COMP_CWORD]}"
2009 __gitcomp "--quiet --cached"
2012 __gitcomp "$subcommands"
2022 init fetch clone rebase dcommit log find-rev
2023 set-tree commit-diff info create-ignore propget
2024 proplist show-ignore show-externals branch tag blame
2027 local subcommand="$(__git_find_on_cmdline "$subcommands")"
2028 if [ -z "$subcommand" ]; then
2029 __gitcomp "$subcommands"
2031 local remote_opts="--username= --config-dir= --no-auth-cache"
2033 --follow-parent --authors-file= --repack=
2034 --no-metadata --use-svm-props --use-svnsync-props
2035 --log-window-size= --no-checkout --quiet
2036 --repack-flags --use-log-author --localtime
2037 --ignore-paths= $remote_opts
2040 --template= --shared= --trunk= --tags=
2041 --branches= --stdlayout --minimize-url
2042 --no-metadata --use-svm-props --use-svnsync-props
2043 --rewrite-root= --prefix= --use-log-author
2044 --add-author-from $remote_opts
2047 --edit --rmdir --find-copies-harder --copy-similarity=
2050 local cur="${COMP_WORDS[COMP_CWORD]}"
2051 case "$subcommand,$cur" in
2053 __gitcomp "--revision= --fetch-all $fc_opts"
2056 __gitcomp "--revision= $fc_opts $init_opts"
2059 __gitcomp "$init_opts"
2063 --merge --strategy= --verbose --dry-run
2064 --fetch-all --no-rebase --commit-url
2065 --revision $cmt_opts $fc_opts
2069 __gitcomp "--stdin $cmt_opts $fc_opts"
2071 create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\
2073 __gitcomp "--revision="
2077 --limit= --revision= --verbose --incremental
2078 --oneline --show-commit --non-recursive
2079 --authors-file= --color
2084 --merge --verbose --strategy= --local
2085 --fetch-all --dry-run $fc_opts
2089 __gitcomp "--message= --file= --revision= $cmt_opts"
2095 __gitcomp "--dry-run --message --tag"
2098 __gitcomp "--dry-run --message"
2101 __gitcomp "--git-format"
2105 --config-dir= --ignore-paths= --minimize
2106 --no-auth-cache --username=
2119 while [ $c -lt $COMP_CWORD ]; do
2120 i="${COMP_WORDS[c]}"
2123 __gitcomp "$(__git_tags)"
2133 case "${COMP_WORDS[COMP_CWORD-1]}" in
2139 __gitcomp "$(__git_tags)"
2145 __gitcomp "$(__git_refs)"
2152 local i c=1 command __git_dir
2154 while [ $c -lt $COMP_CWORD ]; do
2155 i="${COMP_WORDS[c]}"
2157 --git-dir=*) __git_dir="${i#--git-dir=}" ;;
2158 --bare) __git_dir="." ;;
2159 --version|-p|--paginate) ;;
2160 --help) command="help"; break ;;
2161 *) command="$i"; break ;;
2166 if [ -z "$command" ]; then
2167 case "${COMP_WORDS[COMP_CWORD]}" in
2180 *) __git_compute_porcelain_commands
2181 __gitcomp "$__git_porcelain_commands $(__git_aliases)" ;;
2186 local expansion=$(__git_aliased_command "$command")
2187 [ "$expansion" ] && command="$expansion"
2192 apply) _git_apply ;;
2193 archive) _git_archive ;;
2194 bisect) _git_bisect ;;
2195 bundle) _git_bundle ;;
2196 branch) _git_branch ;;
2197 checkout) _git_checkout ;;
2198 cherry) _git_cherry ;;
2199 cherry-pick) _git_cherry_pick ;;
2200 clean) _git_clean ;;
2201 clone) _git_clone ;;
2202 commit) _git_commit ;;
2203 config) _git_config ;;
2204 describe) _git_describe ;;
2206 difftool) _git_difftool ;;
2207 fetch) _git_fetch ;;
2208 format-patch) _git_format_patch ;;
2215 ls-files) _git_ls_files ;;
2216 ls-remote) _git_ls_remote ;;
2217 ls-tree) _git_ls_tree ;;
2219 mergetool) _git_mergetool;;
2220 merge-base) _git_merge_base ;;
2222 name-rev) _git_name_rev ;;
2225 rebase) _git_rebase ;;
2226 remote) _git_remote ;;
2227 replace) _git_replace ;;
2228 reset) _git_reset ;;
2229 revert) _git_revert ;;
2231 send-email) _git_send_email ;;
2232 shortlog) _git_shortlog ;;
2234 show-branch) _git_show_branch ;;
2235 stash) _git_stash ;;
2237 submodule) _git_submodule ;;
2240 whatchanged) _git_log ;;
2247 __git_has_doubledash && return
2249 local cur="${COMP_WORDS[COMP_CWORD]}"
2250 local g="$(__gitdir)"
2252 if [ -f "$g/MERGE_HEAD" ]; then
2258 $__git_log_common_options
2259 $__git_log_gitk_options
2265 __git_complete_revlist
2268 complete -o bashdefault -o default -o nospace -F _git git 2>/dev/null \
2269 || complete -o default -o nospace -F _git git
2270 complete -o bashdefault -o default -o nospace -F _gitk gitk 2>/dev/null \
2271 || complete -o default -o nospace -F _gitk gitk
2273 # The following are necessary only for Cygwin, and only are needed
2274 # when the user has tab-completed the executable name and consequently
2275 # included the '.exe' suffix.
2277 if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
2278 complete -o bashdefault -o default -o nospace -F _git git.exe 2>/dev/null \
2279 || complete -o default -o nospace -F _git git.exe