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_all_commands ()
449 if [ -n "${__git_all_commandlist-}" ]; then
450 echo "$__git_all_commandlist"
454 for i in $(git help -a|egrep '^ ')
457 *--*) : helper pattern;;
462 __git_all_commandlist=
463 __git_all_commandlist="$(__git_all_commands 2>/dev/null)"
465 __git_porcelain_commands ()
467 if [ -n "${__git_porcelain_commandlist-}" ]; then
468 echo "$__git_porcelain_commandlist"
472 for i in "help" $(__git_all_commands)
475 *--*) : helper pattern;;
476 applymbox) : ask gittus;;
477 applypatch) : ask gittus;;
478 archimport) : import;;
479 cat-file) : plumbing;;
480 check-attr) : plumbing;;
481 check-ref-format) : plumbing;;
482 checkout-index) : plumbing;;
483 commit-tree) : plumbing;;
484 count-objects) : infrequent;;
485 cvsexportcommit) : export;;
486 cvsimport) : import;;
487 cvsserver) : daemon;;
489 diff-files) : plumbing;;
490 diff-index) : plumbing;;
491 diff-tree) : plumbing;;
492 fast-import) : import;;
493 fast-export) : export;;
494 fsck-objects) : plumbing;;
495 fetch-pack) : plumbing;;
496 fmt-merge-msg) : plumbing;;
497 for-each-ref) : plumbing;;
498 hash-object) : plumbing;;
499 http-*) : transport;;
500 index-pack) : plumbing;;
501 init-db) : deprecated;;
502 local-fetch) : plumbing;;
503 lost-found) : infrequent;;
504 ls-files) : plumbing;;
505 ls-remote) : plumbing;;
506 ls-tree) : plumbing;;
507 mailinfo) : plumbing;;
508 mailsplit) : plumbing;;
509 merge-*) : plumbing;;
512 pack-objects) : plumbing;;
513 pack-redundant) : plumbing;;
514 pack-refs) : plumbing;;
515 parse-remote) : plumbing;;
516 patch-id) : plumbing;;
517 peek-remote) : plumbing;;
519 prune-packed) : plumbing;;
520 quiltimport) : import;;
521 read-tree) : plumbing;;
522 receive-pack) : plumbing;;
524 repo-config) : deprecated;;
526 rev-list) : plumbing;;
527 rev-parse) : plumbing;;
528 runstatus) : plumbing;;
529 sh-setup) : internal;;
531 show-ref) : plumbing;;
532 send-pack) : plumbing;;
533 show-index) : plumbing;;
535 stripspace) : plumbing;;
536 symbolic-ref) : plumbing;;
537 tar-tree) : deprecated;;
538 unpack-file) : plumbing;;
539 unpack-objects) : plumbing;;
540 update-index) : plumbing;;
541 update-ref) : plumbing;;
542 update-server-info) : daemon;;
543 upload-archive) : plumbing;;
544 upload-pack) : plumbing;;
545 write-tree) : plumbing;;
547 verify-pack) : infrequent;;
548 verify-tag) : plumbing;;
553 __git_porcelain_commandlist=
554 __git_porcelain_commandlist="$(__git_porcelain_commands 2>/dev/null)"
559 for i in $(git --git-dir="$(__gitdir)" config --list); do
569 # __git_aliased_command requires 1 argument
570 __git_aliased_command ()
572 local word cmdline=$(git --git-dir="$(__gitdir)" \
573 config --get "alias.$1")
574 for word in $cmdline; do
575 if [ "${word##-*}" ]; then
582 # __git_find_subcommand requires 1 argument
583 __git_find_subcommand ()
585 local word subcommand c=1
587 while [ $c -lt $COMP_CWORD ]; do
588 word="${COMP_WORDS[c]}"
589 for subcommand in $1; do
590 if [ "$subcommand" = "$word" ]; then
599 __git_has_doubledash ()
602 while [ $c -lt $COMP_CWORD ]; do
603 if [ "--" = "${COMP_WORDS[c]}" ]; then
611 __git_whitespacelist="nowarn warn error error-all fix"
615 local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)"
616 if [ -d "$dir"/rebase-apply ]; then
617 __gitcomp "--skip --resolved --abort"
622 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
627 --signoff --utf8 --binary --3way --interactive
637 local cur="${COMP_WORDS[COMP_CWORD]}"
640 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
645 --stat --numstat --summary --check --index
646 --cached --index-info --reverse --reject --unidiff-zero
647 --apply --no-add --exclude=
648 --whitespace= --inaccurate-eof --verbose
657 __git_has_doubledash && return
659 local cur="${COMP_WORDS[COMP_CWORD]}"
663 --interactive --refresh --patch --update --dry-run
664 --ignore-errors --intent-to-add
673 local cur="${COMP_WORDS[COMP_CWORD]}"
676 __gitcomp "$(git archive --list)" "" "${cur##--format=}"
680 __gitcomp "$(__git_remotes)" "" "${cur##--remote=}"
685 --format= --list --verbose
686 --prefix= --remote= --exec=
696 __git_has_doubledash && return
698 local subcommands="start bad good skip reset visualize replay log run"
699 local subcommand="$(__git_find_subcommand "$subcommands")"
700 if [ -z "$subcommand" ]; then
701 __gitcomp "$subcommands"
705 case "$subcommand" in
707 __gitcomp "$(__git_refs)"
717 local i c=1 only_local_ref="n" has_r="n"
719 while [ $c -lt $COMP_CWORD ]; do
722 -d|-m) only_local_ref="y" ;;
728 case "${COMP_WORDS[COMP_CWORD]}" in
731 --color --no-color --verbose --abbrev= --no-abbrev
732 --track --no-track --contains --merged --no-merged
736 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
737 __gitcomp "$(__git_heads)"
739 __gitcomp "$(__git_refs)"
747 local cmd="${COMP_WORDS[2]}"
748 case "$COMP_CWORD" in
750 __gitcomp "create list-heads verify unbundle"
758 __git_complete_revlist
767 __git_has_doubledash && return
769 __gitcomp "$(__git_refs)"
774 __gitcomp "$(__git_refs)"
779 local cur="${COMP_WORDS[COMP_CWORD]}"
782 __gitcomp "--edit --no-commit"
785 __gitcomp "$(__git_refs)"
792 __git_has_doubledash && return
794 local cur="${COMP_WORDS[COMP_CWORD]}"
797 __gitcomp "--dry-run --quiet"
806 local cur="${COMP_WORDS[COMP_CWORD]}"
831 __git_has_doubledash && return
833 local cur="${COMP_WORDS[COMP_CWORD]}"
837 --all --author= --signoff --verify --no-verify
838 --edit --amend --include --only --interactive
847 local cur="${COMP_WORDS[COMP_CWORD]}"
851 --all --tags --contains --abbrev= --candidates=
852 --exact-match --debug --long --match --always
856 __gitcomp "$(__git_refs)"
859 __git_diff_common_options="--stat --numstat --shortstat --summary
860 --patch-with-stat --name-only --name-status --color
861 --no-color --color-words --no-renames --check
862 --full-index --binary --abbrev --diff-filter=
864 --text --ignore-space-at-eol --ignore-space-change
865 --ignore-all-space --exit-code --quiet --ext-diff
867 --no-prefix --src-prefix= --dst-prefix=
868 --inter-hunk-context=
875 __git_has_doubledash && return
877 local cur="${COMP_WORDS[COMP_CWORD]}"
880 __gitcomp "--cached --pickaxe-all --pickaxe-regex
881 --base --ours --theirs
882 $__git_diff_common_options
892 __git_complete_remote_or_refspec
897 local cur="${COMP_WORDS[COMP_CWORD]}"
901 --stdout --attach --thread
903 --numbered --start-number
908 --full-index --binary
911 --no-prefix --src-prefix= --dst-prefix=
912 --inline --suffix= --ignore-if-in-upstream
918 __git_complete_revlist
923 local cur="${COMP_WORDS[COMP_CWORD]}"
926 __gitcomp "--prune --aggressive"
935 __git_has_doubledash && return
937 local cur="${COMP_WORDS[COMP_CWORD]}"
942 --text --ignore-case --word-regexp --invert-match
944 --extended-regexp --basic-regexp --fixed-strings
945 --files-with-matches --name-only
946 --files-without-match
948 --and --or --not --all-match
958 local cur="${COMP_WORDS[COMP_CWORD]}"
961 __gitcomp "--all --info --man --web"
965 __gitcomp "$(__git_all_commands)
966 attributes cli core-tutorial cvs-migration
967 diffcore gitk glossary hooks ignore modules
968 repository-layout tutorial tutorial-2
975 local cur="${COMP_WORDS[COMP_CWORD]}"
979 false true umask group all world everybody
980 " "" "${cur##--shared=}"
984 __gitcomp "--quiet --bare --template= --shared --shared="
993 __git_has_doubledash && return
995 local cur="${COMP_WORDS[COMP_CWORD]}"
998 __gitcomp "--cached --deleted --modified --others --ignored
999 --stage --directory --no-empty-directory --unmerged
1000 --killed --exclude= --exclude-from=
1001 --exclude-per-directory= --exclude-standard
1002 --error-unmatch --with-tree= --full-name
1003 --abbrev --ignored --exclude-per-directory
1013 __gitcomp "$(__git_remotes)"
1021 # Options that go well for log, shortlog and gitk
1022 __git_log_common_options="
1024 --branches --tags --remotes
1025 --first-parent --no-merges
1027 --max-age= --since= --after=
1028 --min-age= --until= --before=
1030 # Options that go well for log and gitk (not shortlog)
1031 __git_log_gitk_options="
1032 --dense --sparse --full-history
1033 --simplify-merges --simplify-by-decoration
1036 # Options that go well for log and shortlog (not gitk)
1037 __git_log_shortlog_options="
1038 --author= --committer= --grep=
1042 __git_log_pretty_formats="oneline short medium full fuller email raw format:"
1046 __git_has_doubledash && return
1048 local cur="${COMP_WORDS[COMP_CWORD]}"
1049 local g="$(git rev-parse --git-dir 2>/dev/null)"
1051 if [ -f $g/MERGE_HEAD ]; then
1056 __gitcomp "$__git_log_pretty_formats
1057 " "" "${cur##--pretty=}"
1061 __gitcomp "$__git_log_pretty_formats
1062 " "" "${cur##--format=}"
1067 relative iso8601 rfc2822 short local default
1068 " "" "${cur##--date=}"
1073 $__git_log_common_options
1074 $__git_log_shortlog_options
1075 $__git_log_gitk_options
1076 --root --topo-order --date-order --reverse
1078 --abbrev-commit --abbrev=
1079 --relative-date --date=
1080 --pretty= --format= --oneline
1085 --parents --children
1087 $__git_diff_common_options
1088 --pickaxe-all --pickaxe-regex
1093 __git_complete_revlist
1098 local cur="${COMP_WORDS[COMP_CWORD]}"
1099 case "${COMP_WORDS[COMP_CWORD-1]}" in
1101 __gitcomp "$(__git_merge_strategies)"
1106 __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}"
1111 --no-commit --no-stat --log --no-log --squash --strategy
1112 --commit --stat --no-squash --ff --no-ff
1116 __gitcomp "$(__git_refs)"
1121 local cur="${COMP_WORDS[COMP_CWORD]}"
1125 kdiff3 tkdiff meld xxdiff emerge
1126 vimdiff gvimdiff ecmerge opendiff
1127 " "" "${cur##--tool=}"
1140 __gitcomp "$(__git_refs)"
1145 local cur="${COMP_WORDS[COMP_CWORD]}"
1148 __gitcomp "--dry-run"
1157 __gitcomp "--tags --all --stdin"
1162 __git_complete_remote_or_refspec
1167 __git_complete_remote_or_refspec
1172 local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)"
1173 if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
1174 __gitcomp "--continue --skip --abort"
1177 case "${COMP_WORDS[COMP_CWORD-1]}" in
1179 __gitcomp "$(__git_merge_strategies)"
1184 __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}"
1188 __gitcomp "--onto --merge --strategy --interactive"
1191 __gitcomp "$(__git_refs)"
1196 local cur="${COMP_WORDS[COMP_CWORD]}"
1199 __gitcomp "--bcc --cc --cc-cmd --chain-reply-to --compose
1200 --dry-run --envelope-sender --from --identity
1201 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
1202 --no-suppress-from --no-thread --quiet
1203 --signed-off-by-cc --smtp-pass --smtp-server
1204 --smtp-server-port --smtp-ssl --smtp-user --subject
1205 --suppress-cc --suppress-from --thread --to
1206 --validate --no-validate"
1215 local cur="${COMP_WORDS[COMP_CWORD]}"
1216 local prv="${COMP_WORDS[COMP_CWORD-1]}"
1219 __gitcomp "$(__git_remotes)"
1223 __gitcomp "$(__git_refs)"
1227 local remote="${prv#remote.}"
1228 remote="${remote%.fetch}"
1229 __gitcomp "$(__git_refs_remotes "$remote")"
1233 local remote="${prv#remote.}"
1234 remote="${remote%.push}"
1235 __gitcomp "$(git --git-dir="$(__gitdir)" \
1236 for-each-ref --format='%(refname):%(refname)' \
1240 pull.twohead|pull.octopus)
1241 __gitcomp "$(__git_merge_strategies)"
1244 color.branch|color.diff|color.interactive|color.status|color.ui)
1245 __gitcomp "always never auto"
1249 __gitcomp "false true"
1254 normal black red green yellow blue magenta cyan white
1255 bold dim ul blink reverse
1267 --global --system --file=
1268 --list --replace-all
1269 --get --get-all --get-regexp
1270 --add --unset --unset-all
1271 --remove-section --rename-section
1276 local pfx="${cur%.*}."
1278 __gitcomp "remote merge mergeoptions" "$pfx" "$cur"
1282 local pfx="${cur%.*}."
1284 __gitcomp "$(__git_heads)" "$pfx" "$cur" "."
1288 local pfx="${cur%.*}."
1291 url proxy fetch push mirror skipDefaultUpdate
1292 receivepack uploadpack tagopt
1297 local pfx="${cur%.*}."
1299 __gitcomp "$(__git_remotes)" "$pfx" "$cur" "."
1305 branch.autosetupmerge
1306 branch.autosetuprebase
1309 color.branch.current
1320 color.diff.whitespace
1322 color.interactive.header
1323 color.interactive.help
1324 color.interactive.prompt
1328 color.status.changed
1330 color.status.nobranch
1331 color.status.untracked
1332 color.status.updated
1338 core.deltaBaseCacheLimit
1342 core.fsyncobjectfiles
1344 core.ignoreCygwinFSTricks
1346 core.logAllRefUpdates
1347 core.loosecompression
1349 core.packedGitWindowSize
1351 core.preferSymlinkRefs
1354 core.repositoryFormatVersion
1356 core.sharedRepository
1359 core.warnAmbiguousRefs
1362 diff.autorefreshindex
1379 gc.reflogexpireunreachable
1383 gitcvs.dbTableNamePrefix
1393 gui.copyblamethreshold
1397 gui.matchtrackingbranch
1398 gui.newbranchtemplate
1399 gui.pruneduringfetch
1400 gui.spellingdictionary
1416 i18n.logOutputEncoding
1431 mergetool.keepBackup
1433 pack.deltaCacheLimit
1443 receive.denyCurrentBranch
1445 receive.denyNonFastForwards
1448 repack.usedeltabaseoffset
1452 status.relativePaths
1453 status.showUntrackedFiles
1455 transfer.unpackLimit
1466 local subcommands="add rename rm show prune update"
1467 local subcommand="$(__git_find_subcommand "$subcommands")"
1468 if [ -z "$subcommand" ]; then
1469 __gitcomp "$subcommands"
1473 case "$subcommand" in
1474 rename|rm|show|prune)
1475 __gitcomp "$(__git_remotes)"
1478 local i c='' IFS=$'\n'
1479 for i in $(git --git-dir="$(__gitdir)" config --list); do
1497 __git_has_doubledash && return
1499 local cur="${COMP_WORDS[COMP_CWORD]}"
1502 __gitcomp "--merge --mixed --hard --soft"
1506 __gitcomp "$(__git_refs)"
1511 local cur="${COMP_WORDS[COMP_CWORD]}"
1514 __gitcomp "--edit --mainline --no-edit --no-commit --signoff"
1518 __gitcomp "$(__git_refs)"
1523 __git_has_doubledash && return
1525 local cur="${COMP_WORDS[COMP_CWORD]}"
1528 __gitcomp "--cached --dry-run --ignore-unmatch --quiet"
1537 __git_has_doubledash && return
1539 local cur="${COMP_WORDS[COMP_CWORD]}"
1543 $__git_log_common_options
1544 $__git_log_shortlog_options
1545 --numbered --summary
1550 __git_complete_revlist
1555 __git_has_doubledash && return
1557 local cur="${COMP_WORDS[COMP_CWORD]}"
1560 __gitcomp "$__git_log_pretty_formats
1561 " "" "${cur##--pretty=}"
1565 __gitcomp "$__git_log_pretty_formats
1566 " "" "${cur##--format=}"
1570 __gitcomp "--pretty= --format=
1571 $__git_diff_common_options
1581 local cur="${COMP_WORDS[COMP_CWORD]}"
1585 --all --remotes --topo-order --current --more=
1586 --list --independent --merge-base --no-name
1587 --sha1-name --topics --reflog
1592 __git_complete_revlist
1597 local subcommands='save list show apply clear drop pop create branch'
1598 local subcommand="$(__git_find_subcommand "$subcommands")"
1599 if [ -z "$subcommand" ]; then
1600 __gitcomp "$subcommands"
1602 local cur="${COMP_WORDS[COMP_CWORD]}"
1603 case "$subcommand,$cur" in
1605 __gitcomp "--keep-index"
1610 show,--*|drop,--*|pop,--*|branch,--*)
1613 show,*|apply,*|drop,*|pop,*|branch,*)
1614 __gitcomp "$(git --git-dir="$(__gitdir)" stash list \
1615 | sed -n -e 's/:.*//p')"
1626 __git_has_doubledash && return
1628 local subcommands="add status init update summary foreach sync"
1629 if [ -z "$(__git_find_subcommand "$subcommands")" ]; then
1630 local cur="${COMP_WORDS[COMP_CWORD]}"
1633 __gitcomp "--quiet --cached"
1636 __gitcomp "$subcommands"
1646 init fetch clone rebase dcommit log find-rev
1647 set-tree commit-diff info create-ignore propget
1648 proplist show-ignore show-externals branch tag blame
1651 local subcommand="$(__git_find_subcommand "$subcommands")"
1652 if [ -z "$subcommand" ]; then
1653 __gitcomp "$subcommands"
1655 local remote_opts="--username= --config-dir= --no-auth-cache"
1657 --follow-parent --authors-file= --repack=
1658 --no-metadata --use-svm-props --use-svnsync-props
1659 --log-window-size= --no-checkout --quiet
1660 --repack-flags --use-log-author --localtime
1661 --ignore-paths= $remote_opts
1664 --template= --shared= --trunk= --tags=
1665 --branches= --stdlayout --minimize-url
1666 --no-metadata --use-svm-props --use-svnsync-props
1667 --rewrite-root= --prefix= --use-log-author
1668 --add-author-from $remote_opts
1671 --edit --rmdir --find-copies-harder --copy-similarity=
1674 local cur="${COMP_WORDS[COMP_CWORD]}"
1675 case "$subcommand,$cur" in
1677 __gitcomp "--revision= --fetch-all $fc_opts"
1680 __gitcomp "--revision= $fc_opts $init_opts"
1683 __gitcomp "$init_opts"
1687 --merge --strategy= --verbose --dry-run
1688 --fetch-all --no-rebase --commit-url
1689 --revision $cmt_opts $fc_opts
1693 __gitcomp "--stdin $cmt_opts $fc_opts"
1695 create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\
1697 __gitcomp "--revision="
1701 --limit= --revision= --verbose --incremental
1702 --oneline --show-commit --non-recursive
1703 --authors-file= --color
1708 --merge --verbose --strategy= --local
1709 --fetch-all --dry-run $fc_opts
1713 __gitcomp "--message= --file= --revision= $cmt_opts"
1719 __gitcomp "--dry-run --message --tag"
1722 __gitcomp "--dry-run --message"
1725 __gitcomp "--git-format"
1729 --config-dir= --ignore-paths= --minimize
1730 --no-auth-cache --username=
1743 while [ $c -lt $COMP_CWORD ]; do
1744 i="${COMP_WORDS[c]}"
1747 __gitcomp "$(__git_tags)"
1757 case "${COMP_WORDS[COMP_CWORD-1]}" in
1763 __gitcomp "$(__git_tags)"
1769 __gitcomp "$(__git_refs)"
1776 local i c=1 command __git_dir
1778 while [ $c -lt $COMP_CWORD ]; do
1779 i="${COMP_WORDS[c]}"
1781 --git-dir=*) __git_dir="${i#--git-dir=}" ;;
1782 --bare) __git_dir="." ;;
1783 --version|-p|--paginate) ;;
1784 --help) command="help"; break ;;
1785 *) command="$i"; break ;;
1790 if [ -z "$command" ]; then
1791 case "${COMP_WORDS[COMP_CWORD]}" in
1803 *) __gitcomp "$(__git_porcelain_commands) $(__git_aliases)" ;;
1808 local expansion=$(__git_aliased_command "$command")
1809 [ "$expansion" ] && command="$expansion"
1814 apply) _git_apply ;;
1815 archive) _git_archive ;;
1816 bisect) _git_bisect ;;
1817 bundle) _git_bundle ;;
1818 branch) _git_branch ;;
1819 checkout) _git_checkout ;;
1820 cherry) _git_cherry ;;
1821 cherry-pick) _git_cherry_pick ;;
1822 clean) _git_clean ;;
1823 clone) _git_clone ;;
1824 commit) _git_commit ;;
1825 config) _git_config ;;
1826 describe) _git_describe ;;
1828 fetch) _git_fetch ;;
1829 format-patch) _git_format_patch ;;
1835 ls-files) _git_ls_files ;;
1836 ls-remote) _git_ls_remote ;;
1837 ls-tree) _git_ls_tree ;;
1839 mergetool) _git_mergetool;;
1840 merge-base) _git_merge_base ;;
1842 name-rev) _git_name_rev ;;
1845 rebase) _git_rebase ;;
1846 remote) _git_remote ;;
1847 reset) _git_reset ;;
1848 revert) _git_revert ;;
1850 send-email) _git_send_email ;;
1851 shortlog) _git_shortlog ;;
1853 show-branch) _git_show_branch ;;
1854 stash) _git_stash ;;
1856 submodule) _git_submodule ;;
1859 whatchanged) _git_log ;;
1866 __git_has_doubledash && return
1868 local cur="${COMP_WORDS[COMP_CWORD]}"
1869 local g="$(__gitdir)"
1871 if [ -f $g/MERGE_HEAD ]; then
1877 $__git_log_common_options
1878 $__git_log_gitk_options
1884 __git_complete_revlist
1887 complete -o bashdefault -o default -o nospace -F _git git 2>/dev/null \
1888 || complete -o default -o nospace -F _git git
1889 complete -o bashdefault -o default -o nospace -F _gitk gitk 2>/dev/null \
1890 || complete -o default -o nospace -F _gitk gitk
1892 # The following are necessary only for Cygwin, and only are needed
1893 # when the user has tab-completed the executable name and consequently
1894 # included the '.exe' suffix.
1896 if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
1897 complete -o bashdefault -o default -o nospace -F _git git.exe 2>/dev/null \
1898 || complete -o default -o nospace -F _git git.exe