3 # bash completion support for core Git.
5 # Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
6 # Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
7 # Distributed under the GNU General Public License, version 2.0.
9 # The contained completion routines provide support for completing:
11 # *) local and remote branch names
12 # *) local and remote tag names
13 # *) .git/remotes file names
14 # *) git 'subcommands'
15 # *) tree paths within 'ref:path/to/file' expressions
16 # *) common --long-options
18 # To use these routines:
20 # 1) Copy this file to somewhere (e.g. ~/.git-completion.sh).
21 # 2) Added the following line to your .bashrc:
22 # source ~/.git-completion.sh
24 # 3) You may want to make sure the git executable is available
25 # in your PATH before this script is sourced, as some caching
26 # is performed while the script loads. If git isn't found
27 # at source time then all lookups will be done on demand,
28 # which may be slightly slower.
30 # 4) Consider changing your PS1 to also show the current branch:
31 # PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
33 # The argument to __git_ps1 will be displayed only if you
34 # are currently in a git repository. The %s token will be
35 # the name of the current branch.
37 # In addition, if you set GIT_PS1_SHOWDIRTYSTATE to a nonempty
38 # value, unstaged (*) and staged (+) changes will be shown next
39 # to the branch name. You can configure this per-repository
40 # with the bash.showDirtyState variable, which defaults to true
41 # once GIT_PS1_SHOWDIRTYSTATE is enabled.
45 # *) Read Documentation/SubmittingPatches
46 # *) Send all patches to the current maintainer:
48 # "Shawn O. Pearce" <spearce@spearce.org>
50 # *) Always CC the Git mailing list:
55 case "$COMP_WORDBREAKS" in
57 *) COMP_WORDBREAKS="$COMP_WORDBREAKS:"
60 # __gitdir accepts 0 or 1 arguments (i.e., location)
61 # returns location of .git repo
64 if [ -z "${1-}" ]; then
65 if [ -n "${__git_dir-}" ]; then
67 elif [ -d .git ]; then
70 git rev-parse --git-dir 2>/dev/null
72 elif [ -d "$1/.git" ]; then
79 # __git_ps1 accepts 0 or 1 arguments (i.e., format string)
80 # returns text to add to bash PS1 prompt (includes branch name)
87 if [ -d "$g/rebase-apply" ]; then
88 if [ -f "$g/rebase-apply/rebasing" ]; then
90 elif [ -f "$g/rebase-apply/applying" ]; then
95 b="$(git symbolic-ref HEAD 2>/dev/null)"
96 elif [ -f "$g/rebase-merge/interactive" ]; then
98 b="$(cat "$g/rebase-merge/head-name")"
99 elif [ -d "$g/rebase-merge" ]; then
101 b="$(cat "$g/rebase-merge/head-name")"
102 elif [ -f "$g/MERGE_HEAD" ]; then
104 b="$(git symbolic-ref HEAD 2>/dev/null)"
106 if [ -f "$g/BISECT_LOG" ]; then
109 if ! b="$(git symbolic-ref HEAD 2>/dev/null)"; then
110 if ! b="$(git describe --exact-match HEAD 2>/dev/null)"; then
111 if [ -r "$g/HEAD" ]; then
112 b="$(cut -c1-7 "$g/HEAD")..."
122 if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then
123 if [ "true" = "$(git config --bool core.bare 2>/dev/null)" ]; then
128 elif [ "true" = "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
129 if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ]; then
130 if [ "$(git config --bool bash.showDirtyState)" != "false" ]; then
131 git diff --no-ext-diff --ignore-submodules \
132 --quiet --exit-code || w="*"
133 if git rev-parse --quiet --verify HEAD >/dev/null; then
134 git diff-index --cached --quiet \
135 --ignore-submodules HEAD -- || i="+"
144 if [ -n "${1-}" ]; then
145 printf "$1" "$c${b##refs/heads/}$w$i$r"
147 printf " (%s)" "$c${b##refs/heads/}$w$i$r"
153 # __gitcomp_1 requires 2 arguments
156 local c IFS=' '$'\t'$'\n'
159 --*=*) printf %s$'\n' "$c$2" ;;
160 *.) printf %s$'\n' "$c$2" ;;
161 *) printf %s$'\n' "$c$2 " ;;
166 # __gitcomp accepts 1, 2, 3, or 4 arguments
167 # generates completion reply with compgen
170 local cur="${COMP_WORDS[COMP_CWORD]}"
171 if [ $# -gt 2 ]; then
180 COMPREPLY=($(compgen -P "${2-}" \
181 -W "$(__gitcomp_1 "${1-}" "${4-}")" \
187 # __git_heads accepts 0 or 1 arguments (to pass to __gitdir)
190 local cmd i is_hash=y dir="$(__gitdir "${1-}")"
191 if [ -d "$dir" ]; then
192 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
196 for i in $(git ls-remote "${1-}" 2>/dev/null); do
197 case "$is_hash,$i" in
200 n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
201 n,*) is_hash=y; echo "$i" ;;
206 # __git_tags accepts 0 or 1 arguments (to pass to __gitdir)
209 local cmd i is_hash=y dir="$(__gitdir "${1-}")"
210 if [ -d "$dir" ]; then
211 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
215 for i in $(git ls-remote "${1-}" 2>/dev/null); do
216 case "$is_hash,$i" in
219 n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
220 n,*) is_hash=y; echo "$i" ;;
225 # __git_refs accepts 0 or 1 arguments (to pass to __gitdir)
228 local i is_hash=y dir="$(__gitdir "${1-}")"
229 local cur="${COMP_WORDS[COMP_CWORD]}" format refs
230 if [ -d "$dir" ]; then
237 if [ -e "$dir/HEAD" ]; then echo HEAD; fi
238 format="refname:short"
239 refs="refs/tags refs/heads refs/remotes"
242 git --git-dir="$dir" for-each-ref --format="%($format)" \
246 for i in $(git ls-remote "$dir" 2>/dev/null); do
247 case "$is_hash,$i" in
250 n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
251 n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
252 n,refs/remotes/*) is_hash=y; echo "${i#refs/remotes/}" ;;
253 n,*) is_hash=y; echo "$i" ;;
258 # __git_refs2 requires 1 argument (to pass to __git_refs)
262 for i in $(__git_refs "$1"); do
267 # __git_refs_remotes requires 1 argument (to pass to ls-remote)
268 __git_refs_remotes ()
270 local cmd i is_hash=y
271 for i in $(git ls-remote "$1" 2>/dev/null); do
272 case "$is_hash,$i" in
275 echo "$i:refs/remotes/$1/${i#refs/heads/}"
279 n,refs/tags/*) is_hash=y;;
287 local i ngoff IFS=$'\n' d="$(__gitdir)"
288 shopt -q nullglob || ngoff=1
290 for i in "$d/remotes"/*; do
291 echo ${i#$d/remotes/}
293 [ "$ngoff" ] && shopt -u nullglob
294 for i in $(git --git-dir="$d" config --list); do
304 __git_merge_strategies ()
306 if [ -n "${__git_merge_strategylist-}" ]; then
307 echo "$__git_merge_strategylist"
310 git merge -s help 2>&1 |
311 sed -n -e '/[Aa]vailable strategies are: /,/^$/{
319 __git_merge_strategylist=
320 __git_merge_strategylist=$(__git_merge_strategies 2>/dev/null)
322 __git_complete_file ()
324 local pfx ls ref cur="${COMP_WORDS[COMP_CWORD]}"
341 case "$COMP_WORDBREAKS" in
343 *) pfx="$ref:$pfx" ;;
347 COMPREPLY=($(compgen -P "$pfx" \
348 -W "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \
349 | sed '/^100... blob /{
365 __gitcomp "$(__git_refs)"
370 __git_complete_revlist ()
372 local pfx cur="${COMP_WORDS[COMP_CWORD]}"
377 __gitcomp "$(__git_refs)" "$pfx" "$cur"
382 __gitcomp "$(__git_refs)" "$pfx" "$cur"
385 __gitcomp "$(__git_refs)"
390 __git_complete_remote_or_refspec ()
392 local cmd="${COMP_WORDS[1]}"
393 local cur="${COMP_WORDS[COMP_CWORD]}"
394 local i c=2 remote="" pfx="" lhs=1
395 while [ $c -lt $COMP_CWORD ]; do
399 *) remote="$i"; break ;;
403 if [ -z "$remote" ]; then
404 __gitcomp "$(__git_remotes)"
407 [ "$remote" = "." ] && remote=
410 case "$COMP_WORDBREAKS" in
412 *) pfx="${cur%%:*}:" ;;
424 if [ $lhs = 1 ]; then
425 __gitcomp "$(__git_refs2 "$remote")" "$pfx" "$cur"
427 __gitcomp "$(__git_refs)" "$pfx" "$cur"
431 if [ $lhs = 1 ]; then
432 __gitcomp "$(__git_refs "$remote")" "$pfx" "$cur"
434 __gitcomp "$(__git_refs)" "$pfx" "$cur"
438 if [ $lhs = 1 ]; then
439 __gitcomp "$(__git_refs)" "$pfx" "$cur"
441 __gitcomp "$(__git_refs "$remote")" "$pfx" "$cur"
447 __git_complete_strategy ()
449 case "${COMP_WORDS[COMP_CWORD-1]}" in
451 __gitcomp "$(__git_merge_strategies)"
454 local cur="${COMP_WORDS[COMP_CWORD]}"
457 __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}"
464 __git_all_commands ()
466 if [ -n "${__git_all_commandlist-}" ]; then
467 echo "$__git_all_commandlist"
471 for i in $(git help -a|egrep '^ ')
474 *--*) : helper pattern;;
479 __git_all_commandlist=
480 __git_all_commandlist="$(__git_all_commands 2>/dev/null)"
482 __git_porcelain_commands ()
484 if [ -n "${__git_porcelain_commandlist-}" ]; then
485 echo "$__git_porcelain_commandlist"
489 for i in "help" $(__git_all_commands)
492 *--*) : helper pattern;;
493 applymbox) : ask gittus;;
494 applypatch) : ask gittus;;
495 archimport) : import;;
496 cat-file) : plumbing;;
497 check-attr) : plumbing;;
498 check-ref-format) : plumbing;;
499 checkout-index) : plumbing;;
500 commit-tree) : plumbing;;
501 count-objects) : infrequent;;
502 cvsexportcommit) : export;;
503 cvsimport) : import;;
504 cvsserver) : daemon;;
506 diff-files) : plumbing;;
507 diff-index) : plumbing;;
508 diff-tree) : plumbing;;
509 fast-import) : import;;
510 fast-export) : export;;
511 fsck-objects) : plumbing;;
512 fetch-pack) : plumbing;;
513 fmt-merge-msg) : plumbing;;
514 for-each-ref) : plumbing;;
515 hash-object) : plumbing;;
516 http-*) : transport;;
517 index-pack) : plumbing;;
518 init-db) : deprecated;;
519 local-fetch) : plumbing;;
520 lost-found) : infrequent;;
521 ls-files) : plumbing;;
522 ls-remote) : plumbing;;
523 ls-tree) : plumbing;;
524 mailinfo) : plumbing;;
525 mailsplit) : plumbing;;
526 merge-*) : plumbing;;
529 pack-objects) : plumbing;;
530 pack-redundant) : plumbing;;
531 pack-refs) : plumbing;;
532 parse-remote) : plumbing;;
533 patch-id) : plumbing;;
534 peek-remote) : plumbing;;
536 prune-packed) : plumbing;;
537 quiltimport) : import;;
538 read-tree) : plumbing;;
539 receive-pack) : plumbing;;
541 repo-config) : deprecated;;
543 rev-list) : plumbing;;
544 rev-parse) : plumbing;;
545 runstatus) : plumbing;;
546 sh-setup) : internal;;
548 show-ref) : plumbing;;
549 send-pack) : plumbing;;
550 show-index) : plumbing;;
552 stripspace) : plumbing;;
553 symbolic-ref) : plumbing;;
554 tar-tree) : deprecated;;
555 unpack-file) : plumbing;;
556 unpack-objects) : plumbing;;
557 update-index) : plumbing;;
558 update-ref) : plumbing;;
559 update-server-info) : daemon;;
560 upload-archive) : plumbing;;
561 upload-pack) : plumbing;;
562 write-tree) : plumbing;;
564 verify-pack) : infrequent;;
565 verify-tag) : plumbing;;
570 __git_porcelain_commandlist=
571 __git_porcelain_commandlist="$(__git_porcelain_commands 2>/dev/null)"
576 for i in $(git --git-dir="$(__gitdir)" config --list); do
586 # __git_aliased_command requires 1 argument
587 __git_aliased_command ()
589 local word cmdline=$(git --git-dir="$(__gitdir)" \
590 config --get "alias.$1")
591 for word in $cmdline; do
592 if [ "${word##-*}" ]; then
599 # __git_find_subcommand requires 1 argument
600 __git_find_subcommand ()
602 local word subcommand c=1
604 while [ $c -lt $COMP_CWORD ]; do
605 word="${COMP_WORDS[c]}"
606 for subcommand in $1; do
607 if [ "$subcommand" = "$word" ]; then
616 __git_has_doubledash ()
619 while [ $c -lt $COMP_CWORD ]; do
620 if [ "--" = "${COMP_WORDS[c]}" ]; then
628 __git_whitespacelist="nowarn warn error error-all fix"
632 local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)"
633 if [ -d "$dir"/rebase-apply ]; then
634 __gitcomp "--skip --resolved --abort"
639 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
644 --signoff --utf8 --binary --3way --interactive
654 local cur="${COMP_WORDS[COMP_CWORD]}"
657 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
662 --stat --numstat --summary --check --index
663 --cached --index-info --reverse --reject --unidiff-zero
664 --apply --no-add --exclude=
665 --whitespace= --inaccurate-eof --verbose
674 __git_has_doubledash && return
676 local cur="${COMP_WORDS[COMP_CWORD]}"
680 --interactive --refresh --patch --update --dry-run
681 --ignore-errors --intent-to-add
690 local cur="${COMP_WORDS[COMP_CWORD]}"
693 __gitcomp "$(git archive --list)" "" "${cur##--format=}"
697 __gitcomp "$(__git_remotes)" "" "${cur##--remote=}"
702 --format= --list --verbose
703 --prefix= --remote= --exec=
713 __git_has_doubledash && return
715 local subcommands="start bad good skip reset visualize replay log run"
716 local subcommand="$(__git_find_subcommand "$subcommands")"
717 if [ -z "$subcommand" ]; then
718 __gitcomp "$subcommands"
722 case "$subcommand" in
724 __gitcomp "$(__git_refs)"
734 local i c=1 only_local_ref="n" has_r="n"
736 while [ $c -lt $COMP_CWORD ]; do
739 -d|-m) only_local_ref="y" ;;
745 case "${COMP_WORDS[COMP_CWORD]}" in
748 --color --no-color --verbose --abbrev= --no-abbrev
749 --track --no-track --contains --merged --no-merged
753 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
754 __gitcomp "$(__git_heads)"
756 __gitcomp "$(__git_refs)"
764 local cmd="${COMP_WORDS[2]}"
765 case "$COMP_CWORD" in
767 __gitcomp "create list-heads verify unbundle"
775 __git_complete_revlist
784 __git_has_doubledash && return
786 __gitcomp "$(__git_refs)"
791 __gitcomp "$(__git_refs)"
796 local cur="${COMP_WORDS[COMP_CWORD]}"
799 __gitcomp "--edit --no-commit"
802 __gitcomp "$(__git_refs)"
809 __git_has_doubledash && return
811 local cur="${COMP_WORDS[COMP_CWORD]}"
814 __gitcomp "--dry-run --quiet"
823 local cur="${COMP_WORDS[COMP_CWORD]}"
848 __git_has_doubledash && return
850 local cur="${COMP_WORDS[COMP_CWORD]}"
854 --all --author= --signoff --verify --no-verify
855 --edit --amend --include --only --interactive
864 local cur="${COMP_WORDS[COMP_CWORD]}"
868 --all --tags --contains --abbrev= --candidates=
869 --exact-match --debug --long --match --always
873 __gitcomp "$(__git_refs)"
876 __git_diff_common_options="--stat --numstat --shortstat --summary
877 --patch-with-stat --name-only --name-status --color
878 --no-color --color-words --no-renames --check
879 --full-index --binary --abbrev --diff-filter=
881 --text --ignore-space-at-eol --ignore-space-change
882 --ignore-all-space --exit-code --quiet --ext-diff
884 --no-prefix --src-prefix= --dst-prefix=
885 --inter-hunk-context=
892 __git_has_doubledash && return
894 local cur="${COMP_WORDS[COMP_CWORD]}"
897 __gitcomp "--cached --pickaxe-all --pickaxe-regex
898 --base --ours --theirs
899 $__git_diff_common_options
909 __git_complete_remote_or_refspec
914 local cur="${COMP_WORDS[COMP_CWORD]}"
918 --stdout --attach --thread
920 --numbered --start-number
925 --full-index --binary
928 --no-prefix --src-prefix= --dst-prefix=
929 --inline --suffix= --ignore-if-in-upstream
935 __git_complete_revlist
940 local cur="${COMP_WORDS[COMP_CWORD]}"
943 __gitcomp "--prune --aggressive"
952 __git_has_doubledash && return
954 local cur="${COMP_WORDS[COMP_CWORD]}"
959 --text --ignore-case --word-regexp --invert-match
961 --extended-regexp --basic-regexp --fixed-strings
962 --files-with-matches --name-only
963 --files-without-match
965 --and --or --not --all-match
975 local cur="${COMP_WORDS[COMP_CWORD]}"
978 __gitcomp "--all --info --man --web"
982 __gitcomp "$(__git_all_commands)
983 attributes cli core-tutorial cvs-migration
984 diffcore gitk glossary hooks ignore modules
985 repository-layout tutorial tutorial-2
992 local cur="${COMP_WORDS[COMP_CWORD]}"
996 false true umask group all world everybody
997 " "" "${cur##--shared=}"
1001 __gitcomp "--quiet --bare --template= --shared --shared="
1010 __git_has_doubledash && return
1012 local cur="${COMP_WORDS[COMP_CWORD]}"
1015 __gitcomp "--cached --deleted --modified --others --ignored
1016 --stage --directory --no-empty-directory --unmerged
1017 --killed --exclude= --exclude-from=
1018 --exclude-per-directory= --exclude-standard
1019 --error-unmatch --with-tree= --full-name
1020 --abbrev --ignored --exclude-per-directory
1030 __gitcomp "$(__git_remotes)"
1038 # Options that go well for log, shortlog and gitk
1039 __git_log_common_options="
1041 --branches --tags --remotes
1042 --first-parent --no-merges
1044 --max-age= --since= --after=
1045 --min-age= --until= --before=
1047 # Options that go well for log and gitk (not shortlog)
1048 __git_log_gitk_options="
1049 --dense --sparse --full-history
1050 --simplify-merges --simplify-by-decoration
1053 # Options that go well for log and shortlog (not gitk)
1054 __git_log_shortlog_options="
1055 --author= --committer= --grep=
1059 __git_log_pretty_formats="oneline short medium full fuller email raw format:"
1063 __git_has_doubledash && return
1065 local cur="${COMP_WORDS[COMP_CWORD]}"
1066 local g="$(git rev-parse --git-dir 2>/dev/null)"
1068 if [ -f $g/MERGE_HEAD ]; then
1073 __gitcomp "$__git_log_pretty_formats
1074 " "" "${cur##--pretty=}"
1078 __gitcomp "$__git_log_pretty_formats
1079 " "" "${cur##--format=}"
1084 relative iso8601 rfc2822 short local default
1085 " "" "${cur##--date=}"
1090 $__git_log_common_options
1091 $__git_log_shortlog_options
1092 $__git_log_gitk_options
1093 --root --topo-order --date-order --reverse
1095 --abbrev-commit --abbrev=
1096 --relative-date --date=
1097 --pretty= --format= --oneline
1102 --parents --children
1104 $__git_diff_common_options
1105 --pickaxe-all --pickaxe-regex
1110 __git_complete_revlist
1115 __git_complete_strategy && return
1117 local cur="${COMP_WORDS[COMP_CWORD]}"
1121 --no-commit --no-stat --log --no-log --squash --strategy
1122 --commit --stat --no-squash --ff --no-ff
1126 __gitcomp "$(__git_refs)"
1131 local cur="${COMP_WORDS[COMP_CWORD]}"
1135 kdiff3 tkdiff meld xxdiff emerge
1136 vimdiff gvimdiff ecmerge opendiff
1137 " "" "${cur##--tool=}"
1150 __gitcomp "$(__git_refs)"
1155 local cur="${COMP_WORDS[COMP_CWORD]}"
1158 __gitcomp "--dry-run"
1167 __gitcomp "--tags --all --stdin"
1172 __git_complete_remote_or_refspec
1177 __git_complete_remote_or_refspec
1182 local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)"
1183 if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
1184 __gitcomp "--continue --skip --abort"
1187 __git_complete_strategy && return
1190 __gitcomp "--onto --merge --strategy --interactive"
1193 __gitcomp "$(__git_refs)"
1198 local cur="${COMP_WORDS[COMP_CWORD]}"
1201 __gitcomp "--bcc --cc --cc-cmd --chain-reply-to --compose
1202 --dry-run --envelope-sender --from --identity
1203 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
1204 --no-suppress-from --no-thread --quiet
1205 --signed-off-by-cc --smtp-pass --smtp-server
1206 --smtp-server-port --smtp-ssl --smtp-user --subject
1207 --suppress-cc --suppress-from --thread --to
1208 --validate --no-validate"
1217 local cur="${COMP_WORDS[COMP_CWORD]}"
1218 local prv="${COMP_WORDS[COMP_CWORD-1]}"
1221 __gitcomp "$(__git_remotes)"
1225 __gitcomp "$(__git_refs)"
1229 local remote="${prv#remote.}"
1230 remote="${remote%.fetch}"
1231 __gitcomp "$(__git_refs_remotes "$remote")"
1235 local remote="${prv#remote.}"
1236 remote="${remote%.push}"
1237 __gitcomp "$(git --git-dir="$(__gitdir)" \
1238 for-each-ref --format='%(refname):%(refname)' \
1242 pull.twohead|pull.octopus)
1243 __gitcomp "$(__git_merge_strategies)"
1246 color.branch|color.diff|color.interactive|color.status|color.ui)
1247 __gitcomp "always never auto"
1251 __gitcomp "false true"
1256 normal black red green yellow blue magenta cyan white
1257 bold dim ul blink reverse
1269 --global --system --file=
1270 --list --replace-all
1271 --get --get-all --get-regexp
1272 --add --unset --unset-all
1273 --remove-section --rename-section
1278 local pfx="${cur%.*}."
1280 __gitcomp "remote merge mergeoptions" "$pfx" "$cur"
1284 local pfx="${cur%.*}."
1286 __gitcomp "$(__git_heads)" "$pfx" "$cur" "."
1290 local pfx="${cur%.*}."
1293 url proxy fetch push mirror skipDefaultUpdate
1294 receivepack uploadpack tagopt
1299 local pfx="${cur%.*}."
1301 __gitcomp "$(__git_remotes)" "$pfx" "$cur" "."
1307 branch.autosetupmerge
1308 branch.autosetuprebase
1311 color.branch.current
1322 color.diff.whitespace
1324 color.interactive.header
1325 color.interactive.help
1326 color.interactive.prompt
1330 color.status.changed
1332 color.status.nobranch
1333 color.status.untracked
1334 color.status.updated
1340 core.deltaBaseCacheLimit
1344 core.fsyncobjectfiles
1346 core.ignoreCygwinFSTricks
1348 core.logAllRefUpdates
1349 core.loosecompression
1351 core.packedGitWindowSize
1353 core.preferSymlinkRefs
1356 core.repositoryFormatVersion
1358 core.sharedRepository
1361 core.warnAmbiguousRefs
1364 diff.autorefreshindex
1381 gc.reflogexpireunreachable
1385 gitcvs.dbTableNamePrefix
1395 gui.copyblamethreshold
1399 gui.matchtrackingbranch
1400 gui.newbranchtemplate
1401 gui.pruneduringfetch
1402 gui.spellingdictionary
1418 i18n.logOutputEncoding
1433 mergetool.keepBackup
1435 pack.deltaCacheLimit
1445 receive.denyCurrentBranch
1447 receive.denyNonFastForwards
1450 repack.usedeltabaseoffset
1454 status.relativePaths
1455 status.showUntrackedFiles
1457 transfer.unpackLimit
1468 local subcommands="add rename rm show prune update"
1469 local subcommand="$(__git_find_subcommand "$subcommands")"
1470 if [ -z "$subcommand" ]; then
1471 __gitcomp "$subcommands"
1475 case "$subcommand" in
1476 rename|rm|show|prune)
1477 __gitcomp "$(__git_remotes)"
1480 local i c='' IFS=$'\n'
1481 for i in $(git --git-dir="$(__gitdir)" config --list); do
1499 __git_has_doubledash && return
1501 local cur="${COMP_WORDS[COMP_CWORD]}"
1504 __gitcomp "--merge --mixed --hard --soft"
1508 __gitcomp "$(__git_refs)"
1513 local cur="${COMP_WORDS[COMP_CWORD]}"
1516 __gitcomp "--edit --mainline --no-edit --no-commit --signoff"
1520 __gitcomp "$(__git_refs)"
1525 __git_has_doubledash && return
1527 local cur="${COMP_WORDS[COMP_CWORD]}"
1530 __gitcomp "--cached --dry-run --ignore-unmatch --quiet"
1539 __git_has_doubledash && return
1541 local cur="${COMP_WORDS[COMP_CWORD]}"
1545 $__git_log_common_options
1546 $__git_log_shortlog_options
1547 --numbered --summary
1552 __git_complete_revlist
1557 __git_has_doubledash && return
1559 local cur="${COMP_WORDS[COMP_CWORD]}"
1562 __gitcomp "$__git_log_pretty_formats
1563 " "" "${cur##--pretty=}"
1567 __gitcomp "$__git_log_pretty_formats
1568 " "" "${cur##--format=}"
1572 __gitcomp "--pretty= --format=
1573 $__git_diff_common_options
1583 local cur="${COMP_WORDS[COMP_CWORD]}"
1587 --all --remotes --topo-order --current --more=
1588 --list --independent --merge-base --no-name
1589 --sha1-name --topics --reflog
1594 __git_complete_revlist
1599 local subcommands='save list show apply clear drop pop create branch'
1600 local subcommand="$(__git_find_subcommand "$subcommands")"
1601 if [ -z "$subcommand" ]; then
1602 __gitcomp "$subcommands"
1604 local cur="${COMP_WORDS[COMP_CWORD]}"
1605 case "$subcommand,$cur" in
1607 __gitcomp "--keep-index"
1612 show,--*|drop,--*|pop,--*|branch,--*)
1615 show,*|apply,*|drop,*|pop,*|branch,*)
1616 __gitcomp "$(git --git-dir="$(__gitdir)" stash list \
1617 | sed -n -e 's/:.*//p')"
1628 __git_has_doubledash && return
1630 local subcommands="add status init update summary foreach sync"
1631 if [ -z "$(__git_find_subcommand "$subcommands")" ]; then
1632 local cur="${COMP_WORDS[COMP_CWORD]}"
1635 __gitcomp "--quiet --cached"
1638 __gitcomp "$subcommands"
1648 init fetch clone rebase dcommit log find-rev
1649 set-tree commit-diff info create-ignore propget
1650 proplist show-ignore show-externals branch tag blame
1653 local subcommand="$(__git_find_subcommand "$subcommands")"
1654 if [ -z "$subcommand" ]; then
1655 __gitcomp "$subcommands"
1657 local remote_opts="--username= --config-dir= --no-auth-cache"
1659 --follow-parent --authors-file= --repack=
1660 --no-metadata --use-svm-props --use-svnsync-props
1661 --log-window-size= --no-checkout --quiet
1662 --repack-flags --use-log-author --localtime
1663 --ignore-paths= $remote_opts
1666 --template= --shared= --trunk= --tags=
1667 --branches= --stdlayout --minimize-url
1668 --no-metadata --use-svm-props --use-svnsync-props
1669 --rewrite-root= --prefix= --use-log-author
1670 --add-author-from $remote_opts
1673 --edit --rmdir --find-copies-harder --copy-similarity=
1676 local cur="${COMP_WORDS[COMP_CWORD]}"
1677 case "$subcommand,$cur" in
1679 __gitcomp "--revision= --fetch-all $fc_opts"
1682 __gitcomp "--revision= $fc_opts $init_opts"
1685 __gitcomp "$init_opts"
1689 --merge --strategy= --verbose --dry-run
1690 --fetch-all --no-rebase --commit-url
1691 --revision $cmt_opts $fc_opts
1695 __gitcomp "--stdin $cmt_opts $fc_opts"
1697 create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\
1699 __gitcomp "--revision="
1703 --limit= --revision= --verbose --incremental
1704 --oneline --show-commit --non-recursive
1705 --authors-file= --color
1710 --merge --verbose --strategy= --local
1711 --fetch-all --dry-run $fc_opts
1715 __gitcomp "--message= --file= --revision= $cmt_opts"
1721 __gitcomp "--dry-run --message --tag"
1724 __gitcomp "--dry-run --message"
1727 __gitcomp "--git-format"
1731 --config-dir= --ignore-paths= --minimize
1732 --no-auth-cache --username=
1745 while [ $c -lt $COMP_CWORD ]; do
1746 i="${COMP_WORDS[c]}"
1749 __gitcomp "$(__git_tags)"
1759 case "${COMP_WORDS[COMP_CWORD-1]}" in
1765 __gitcomp "$(__git_tags)"
1771 __gitcomp "$(__git_refs)"
1778 local i c=1 command __git_dir
1780 while [ $c -lt $COMP_CWORD ]; do
1781 i="${COMP_WORDS[c]}"
1783 --git-dir=*) __git_dir="${i#--git-dir=}" ;;
1784 --bare) __git_dir="." ;;
1785 --version|-p|--paginate) ;;
1786 --help) command="help"; break ;;
1787 *) command="$i"; break ;;
1792 if [ -z "$command" ]; then
1793 case "${COMP_WORDS[COMP_CWORD]}" in
1805 *) __gitcomp "$(__git_porcelain_commands) $(__git_aliases)" ;;
1810 local expansion=$(__git_aliased_command "$command")
1811 [ "$expansion" ] && command="$expansion"
1816 apply) _git_apply ;;
1817 archive) _git_archive ;;
1818 bisect) _git_bisect ;;
1819 bundle) _git_bundle ;;
1820 branch) _git_branch ;;
1821 checkout) _git_checkout ;;
1822 cherry) _git_cherry ;;
1823 cherry-pick) _git_cherry_pick ;;
1824 clean) _git_clean ;;
1825 clone) _git_clone ;;
1826 commit) _git_commit ;;
1827 config) _git_config ;;
1828 describe) _git_describe ;;
1830 fetch) _git_fetch ;;
1831 format-patch) _git_format_patch ;;
1837 ls-files) _git_ls_files ;;
1838 ls-remote) _git_ls_remote ;;
1839 ls-tree) _git_ls_tree ;;
1841 mergetool) _git_mergetool;;
1842 merge-base) _git_merge_base ;;
1844 name-rev) _git_name_rev ;;
1847 rebase) _git_rebase ;;
1848 remote) _git_remote ;;
1849 reset) _git_reset ;;
1850 revert) _git_revert ;;
1852 send-email) _git_send_email ;;
1853 shortlog) _git_shortlog ;;
1855 show-branch) _git_show_branch ;;
1856 stash) _git_stash ;;
1858 submodule) _git_submodule ;;
1861 whatchanged) _git_log ;;
1868 __git_has_doubledash && return
1870 local cur="${COMP_WORDS[COMP_CWORD]}"
1871 local g="$(__gitdir)"
1873 if [ -f $g/MERGE_HEAD ]; then
1879 $__git_log_common_options
1880 $__git_log_gitk_options
1886 __git_complete_revlist
1889 complete -o bashdefault -o default -o nospace -F _git git 2>/dev/null \
1890 || complete -o default -o nospace -F _git git
1891 complete -o bashdefault -o default -o nospace -F _gitk gitk 2>/dev/null \
1892 || complete -o default -o nospace -F _gitk gitk
1894 # The following are necessary only for Cygwin, and only are needed
1895 # when the user has tab-completed the executable name and consequently
1896 # included the '.exe' suffix.
1898 if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
1899 complete -o bashdefault -o default -o nospace -F _git git.exe 2>/dev/null \
1900 || complete -o default -o nospace -F _git git.exe