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")..."
121 if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then
123 elif [ "true" = "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
124 if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ]; then
125 if [ "$(git config --bool bash.showDirtyState)" != "false" ]; then
126 git diff --no-ext-diff --ignore-submodules \
127 --quiet --exit-code || w="*"
128 if git rev-parse --quiet --verify HEAD >/dev/null; then
129 git diff-index --cached --quiet \
130 --ignore-submodules HEAD -- || i="+"
140 if [ "true" = "$(git config --bool core.bare 2>/dev/null)" ]; then
145 if [ -n "${1-}" ]; then
146 printf "$1" "$c${b##refs/heads/}$w$i$r"
148 printf " (%s)" "$c${b##refs/heads/}$w$i$r"
154 # __gitcomp_1 requires 2 arguments
157 local c IFS=' '$'\t'$'\n'
160 --*=*) printf %s$'\n' "$c$2" ;;
161 *.) printf %s$'\n' "$c$2" ;;
162 *) printf %s$'\n' "$c$2 " ;;
167 # __gitcomp accepts 1, 2, 3, or 4 arguments
168 # generates completion reply with compgen
171 local cur="${COMP_WORDS[COMP_CWORD]}"
172 if [ $# -gt 2 ]; then
181 COMPREPLY=($(compgen -P "${2-}" \
182 -W "$(__gitcomp_1 "${1-}" "${4-}")" \
188 # __git_heads accepts 0 or 1 arguments (to pass to __gitdir)
191 local cmd i is_hash=y dir="$(__gitdir "${1-}")"
192 if [ -d "$dir" ]; then
193 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
197 for i in $(git ls-remote "${1-}" 2>/dev/null); do
198 case "$is_hash,$i" in
201 n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
202 n,*) is_hash=y; echo "$i" ;;
207 # __git_tags accepts 0 or 1 arguments (to pass to __gitdir)
210 local cmd i is_hash=y dir="$(__gitdir "${1-}")"
211 if [ -d "$dir" ]; then
212 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
216 for i in $(git ls-remote "${1-}" 2>/dev/null); do
217 case "$is_hash,$i" in
220 n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
221 n,*) is_hash=y; echo "$i" ;;
226 # __git_refs accepts 0 or 1 arguments (to pass to __gitdir)
229 local i is_hash=y dir="$(__gitdir "${1-}")"
230 local cur="${COMP_WORDS[COMP_CWORD]}" format refs
231 if [ -d "$dir" ]; then
238 if [ -e "$dir/HEAD" ]; then echo HEAD; fi
239 format="refname:short"
240 refs="refs/tags refs/heads refs/remotes"
243 git --git-dir="$dir" for-each-ref --format="%($format)" \
247 for i in $(git ls-remote "$dir" 2>/dev/null); do
248 case "$is_hash,$i" in
251 n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
252 n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
253 n,refs/remotes/*) is_hash=y; echo "${i#refs/remotes/}" ;;
254 n,*) is_hash=y; echo "$i" ;;
259 # __git_refs2 requires 1 argument (to pass to __git_refs)
263 for i in $(__git_refs "$1"); do
268 # __git_refs_remotes requires 1 argument (to pass to ls-remote)
269 __git_refs_remotes ()
271 local cmd i is_hash=y
272 for i in $(git ls-remote "$1" 2>/dev/null); do
273 case "$is_hash,$i" in
276 echo "$i:refs/remotes/$1/${i#refs/heads/}"
280 n,refs/tags/*) is_hash=y;;
288 local i ngoff IFS=$'\n' d="$(__gitdir)"
289 shopt -q nullglob || ngoff=1
291 for i in "$d/remotes"/*; do
292 echo ${i#$d/remotes/}
294 [ "$ngoff" ] && shopt -u nullglob
295 for i in $(git --git-dir="$d" config --list); do
305 __git_merge_strategies ()
307 if [ -n "${__git_merge_strategylist-}" ]; then
308 echo "$__git_merge_strategylist"
311 git merge -s help 2>&1 |
312 sed -n -e '/[Aa]vailable strategies are: /,/^$/{
320 __git_merge_strategylist=
321 __git_merge_strategylist=$(__git_merge_strategies 2>/dev/null)
323 __git_complete_file ()
325 local pfx ls ref cur="${COMP_WORDS[COMP_CWORD]}"
342 case "$COMP_WORDBREAKS" in
344 *) pfx="$ref:$pfx" ;;
348 COMPREPLY=($(compgen -P "$pfx" \
349 -W "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \
350 | sed '/^100... blob /{
366 __gitcomp "$(__git_refs)"
371 __git_complete_revlist ()
373 local pfx cur="${COMP_WORDS[COMP_CWORD]}"
378 __gitcomp "$(__git_refs)" "$pfx" "$cur"
383 __gitcomp "$(__git_refs)" "$pfx" "$cur"
386 __gitcomp "$(__git_refs)"
391 __git_all_commands ()
393 if [ -n "${__git_all_commandlist-}" ]; then
394 echo "$__git_all_commandlist"
398 for i in $(git help -a|egrep '^ ')
401 *--*) : helper pattern;;
406 __git_all_commandlist=
407 __git_all_commandlist="$(__git_all_commands 2>/dev/null)"
409 __git_porcelain_commands ()
411 if [ -n "${__git_porcelain_commandlist-}" ]; then
412 echo "$__git_porcelain_commandlist"
416 for i in "help" $(__git_all_commands)
419 *--*) : helper pattern;;
420 applymbox) : ask gittus;;
421 applypatch) : ask gittus;;
422 archimport) : import;;
423 cat-file) : plumbing;;
424 check-attr) : plumbing;;
425 check-ref-format) : plumbing;;
426 checkout-index) : plumbing;;
427 commit-tree) : plumbing;;
428 count-objects) : infrequent;;
429 cvsexportcommit) : export;;
430 cvsimport) : import;;
431 cvsserver) : daemon;;
433 diff-files) : plumbing;;
434 diff-index) : plumbing;;
435 diff-tree) : plumbing;;
436 fast-import) : import;;
437 fast-export) : export;;
438 fsck-objects) : plumbing;;
439 fetch-pack) : plumbing;;
440 fmt-merge-msg) : plumbing;;
441 for-each-ref) : plumbing;;
442 hash-object) : plumbing;;
443 http-*) : transport;;
444 index-pack) : plumbing;;
445 init-db) : deprecated;;
446 local-fetch) : plumbing;;
447 lost-found) : infrequent;;
448 ls-files) : plumbing;;
449 ls-remote) : plumbing;;
450 ls-tree) : plumbing;;
451 mailinfo) : plumbing;;
452 mailsplit) : plumbing;;
453 merge-*) : plumbing;;
456 pack-objects) : plumbing;;
457 pack-redundant) : plumbing;;
458 pack-refs) : plumbing;;
459 parse-remote) : plumbing;;
460 patch-id) : plumbing;;
461 peek-remote) : plumbing;;
463 prune-packed) : plumbing;;
464 quiltimport) : import;;
465 read-tree) : plumbing;;
466 receive-pack) : plumbing;;
468 repo-config) : deprecated;;
470 rev-list) : plumbing;;
471 rev-parse) : plumbing;;
472 runstatus) : plumbing;;
473 sh-setup) : internal;;
475 show-ref) : plumbing;;
476 send-pack) : plumbing;;
477 show-index) : plumbing;;
479 stripspace) : plumbing;;
480 symbolic-ref) : plumbing;;
481 tar-tree) : deprecated;;
482 unpack-file) : plumbing;;
483 unpack-objects) : plumbing;;
484 update-index) : plumbing;;
485 update-ref) : plumbing;;
486 update-server-info) : daemon;;
487 upload-archive) : plumbing;;
488 upload-pack) : plumbing;;
489 write-tree) : plumbing;;
491 verify-pack) : infrequent;;
492 verify-tag) : plumbing;;
497 __git_porcelain_commandlist=
498 __git_porcelain_commandlist="$(__git_porcelain_commands 2>/dev/null)"
503 for i in $(git --git-dir="$(__gitdir)" config --list); do
513 # __git_aliased_command requires 1 argument
514 __git_aliased_command ()
516 local word cmdline=$(git --git-dir="$(__gitdir)" \
517 config --get "alias.$1")
518 for word in $cmdline; do
519 if [ "${word##-*}" ]; then
526 # __git_find_subcommand requires 1 argument
527 __git_find_subcommand ()
529 local word subcommand c=1
531 while [ $c -lt $COMP_CWORD ]; do
532 word="${COMP_WORDS[c]}"
533 for subcommand in $1; do
534 if [ "$subcommand" = "$word" ]; then
543 __git_has_doubledash ()
546 while [ $c -lt $COMP_CWORD ]; do
547 if [ "--" = "${COMP_WORDS[c]}" ]; then
555 __git_whitespacelist="nowarn warn error error-all fix"
559 local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)"
560 if [ -d "$dir"/rebase-apply ]; then
561 __gitcomp "--skip --resolved --abort"
566 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
571 --signoff --utf8 --binary --3way --interactive
581 local cur="${COMP_WORDS[COMP_CWORD]}"
584 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
589 --stat --numstat --summary --check --index
590 --cached --index-info --reverse --reject --unidiff-zero
591 --apply --no-add --exclude=
592 --whitespace= --inaccurate-eof --verbose
601 __git_has_doubledash && return
603 local cur="${COMP_WORDS[COMP_CWORD]}"
607 --interactive --refresh --patch --update --dry-run
608 --ignore-errors --intent-to-add
617 local cur="${COMP_WORDS[COMP_CWORD]}"
620 __gitcomp "$(git archive --list)" "" "${cur##--format=}"
624 __gitcomp "$(__git_remotes)" "" "${cur##--remote=}"
629 --format= --list --verbose
630 --prefix= --remote= --exec=
640 __git_has_doubledash && return
642 local subcommands="start bad good skip reset visualize replay log run"
643 local subcommand="$(__git_find_subcommand "$subcommands")"
644 if [ -z "$subcommand" ]; then
645 __gitcomp "$subcommands"
649 case "$subcommand" in
651 __gitcomp "$(__git_refs)"
661 local i c=1 only_local_ref="n" has_r="n"
663 while [ $c -lt $COMP_CWORD ]; do
666 -d|-m) only_local_ref="y" ;;
672 case "${COMP_WORDS[COMP_CWORD]}" in
675 --color --no-color --verbose --abbrev= --no-abbrev
676 --track --no-track --contains --merged --no-merged
680 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
681 __gitcomp "$(__git_heads)"
683 __gitcomp "$(__git_refs)"
691 local cmd="${COMP_WORDS[2]}"
692 case "$COMP_CWORD" in
694 __gitcomp "create list-heads verify unbundle"
702 __git_complete_revlist
711 __git_has_doubledash && return
713 __gitcomp "$(__git_refs)"
718 __gitcomp "$(__git_refs)"
723 local cur="${COMP_WORDS[COMP_CWORD]}"
726 __gitcomp "--edit --no-commit"
729 __gitcomp "$(__git_refs)"
736 __git_has_doubledash && return
738 local cur="${COMP_WORDS[COMP_CWORD]}"
741 __gitcomp "--dry-run --quiet"
750 local cur="${COMP_WORDS[COMP_CWORD]}"
775 __git_has_doubledash && return
777 local cur="${COMP_WORDS[COMP_CWORD]}"
781 --all --author= --signoff --verify --no-verify
782 --edit --amend --include --only --interactive
791 local cur="${COMP_WORDS[COMP_CWORD]}"
795 --all --tags --contains --abbrev= --candidates=
796 --exact-match --debug --long --match --always
800 __gitcomp "$(__git_refs)"
803 __git_diff_common_options="--stat --numstat --shortstat --summary
804 --patch-with-stat --name-only --name-status --color
805 --no-color --color-words --no-renames --check
806 --full-index --binary --abbrev --diff-filter=
808 --text --ignore-space-at-eol --ignore-space-change
809 --ignore-all-space --exit-code --quiet --ext-diff
811 --no-prefix --src-prefix= --dst-prefix=
812 --inter-hunk-context=
819 __git_has_doubledash && return
821 local cur="${COMP_WORDS[COMP_CWORD]}"
824 __gitcomp "--cached --pickaxe-all --pickaxe-regex
825 --base --ours --theirs
826 $__git_diff_common_options
836 local cur="${COMP_WORDS[COMP_CWORD]}"
838 if [ "$COMP_CWORD" = 2 ]; then
839 __gitcomp "$(__git_remotes)"
844 case "$COMP_WORDBREAKS" in
846 *) pfx="${cur%%:*}:" ;;
848 __gitcomp "$(__git_refs)" "$pfx" "${cur#*:}"
851 __gitcomp "$(__git_refs2 "${COMP_WORDS[2]}")"
859 local cur="${COMP_WORDS[COMP_CWORD]}"
863 --stdout --attach --thread
865 --numbered --start-number
870 --full-index --binary
873 --no-prefix --src-prefix= --dst-prefix=
874 --inline --suffix= --ignore-if-in-upstream
880 __git_complete_revlist
885 local cur="${COMP_WORDS[COMP_CWORD]}"
888 __gitcomp "--prune --aggressive"
897 __git_has_doubledash && return
899 local cur="${COMP_WORDS[COMP_CWORD]}"
904 --text --ignore-case --word-regexp --invert-match
906 --extended-regexp --basic-regexp --fixed-strings
907 --files-with-matches --name-only
908 --files-without-match
910 --and --or --not --all-match
920 local cur="${COMP_WORDS[COMP_CWORD]}"
923 __gitcomp "--all --info --man --web"
927 __gitcomp "$(__git_all_commands)
928 attributes cli core-tutorial cvs-migration
929 diffcore gitk glossary hooks ignore modules
930 repository-layout tutorial tutorial-2
937 local cur="${COMP_WORDS[COMP_CWORD]}"
941 false true umask group all world everybody
942 " "" "${cur##--shared=}"
946 __gitcomp "--quiet --bare --template= --shared --shared="
955 __git_has_doubledash && return
957 local cur="${COMP_WORDS[COMP_CWORD]}"
960 __gitcomp "--cached --deleted --modified --others --ignored
961 --stage --directory --no-empty-directory --unmerged
962 --killed --exclude= --exclude-from=
963 --exclude-per-directory= --exclude-standard
964 --error-unmatch --with-tree= --full-name
965 --abbrev --ignored --exclude-per-directory
975 __gitcomp "$(__git_remotes)"
983 __git_log_pretty_formats="oneline short medium full fuller email raw format:"
987 __git_has_doubledash && return
989 local cur="${COMP_WORDS[COMP_CWORD]}"
992 __gitcomp "$__git_log_pretty_formats
993 " "" "${cur##--pretty=}"
998 relative iso8601 rfc2822 short local default
999 " "" "${cur##--date=}"
1004 --max-count= --max-age= --since= --after=
1005 --min-age= --before= --until=
1006 --root --topo-order --date-order --reverse
1007 --no-merges --follow
1008 --abbrev-commit --abbrev=
1009 --relative-date --date=
1010 --author= --committer= --grep=
1014 --left-right --cherry-pick
1018 --parents --children --full-history
1020 $__git_diff_common_options
1021 --pickaxe-all --pickaxe-regex
1026 __git_complete_revlist
1031 local cur="${COMP_WORDS[COMP_CWORD]}"
1032 case "${COMP_WORDS[COMP_CWORD-1]}" in
1034 __gitcomp "$(__git_merge_strategies)"
1039 __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}"
1044 --no-commit --no-stat --log --no-log --squash --strategy
1048 __gitcomp "$(__git_refs)"
1053 local cur="${COMP_WORDS[COMP_CWORD]}"
1057 kdiff3 tkdiff meld xxdiff emerge
1058 vimdiff gvimdiff ecmerge opendiff
1059 " "" "${cur##--tool=}"
1072 __gitcomp "$(__git_refs)"
1077 local cur="${COMP_WORDS[COMP_CWORD]}"
1080 __gitcomp "--dry-run"
1089 __gitcomp "--tags --all --stdin"
1094 local cur="${COMP_WORDS[COMP_CWORD]}"
1096 if [ "$COMP_CWORD" = 2 ]; then
1097 __gitcomp "$(__git_remotes)"
1099 __gitcomp "$(__git_refs "${COMP_WORDS[2]}")"
1105 local cur="${COMP_WORDS[COMP_CWORD]}"
1107 if [ "$COMP_CWORD" = 2 ]; then
1108 __gitcomp "$(__git_remotes)"
1113 case "$COMP_WORDBREAKS" in
1115 *) pfx="${cur%%:*}:" ;;
1118 __gitcomp "$(__git_refs "${COMP_WORDS[2]}")" "$pfx" "${cur#*:}"
1121 __gitcomp "$(__git_refs)" + "${cur#+}"
1124 __gitcomp "$(__git_refs)"
1132 local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)"
1133 if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
1134 __gitcomp "--continue --skip --abort"
1137 case "${COMP_WORDS[COMP_CWORD-1]}" in
1139 __gitcomp "$(__git_merge_strategies)"
1144 __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}"
1148 __gitcomp "--onto --merge --strategy --interactive"
1151 __gitcomp "$(__git_refs)"
1156 local cur="${COMP_WORDS[COMP_CWORD]}"
1159 __gitcomp "--bcc --cc --cc-cmd --chain-reply-to --compose
1160 --dry-run --envelope-sender --from --identity
1161 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
1162 --no-suppress-from --no-thread --quiet
1163 --signed-off-by-cc --smtp-pass --smtp-server
1164 --smtp-server-port --smtp-ssl --smtp-user --subject
1165 --suppress-cc --suppress-from --thread --to
1166 --validate --no-validate"
1175 local cur="${COMP_WORDS[COMP_CWORD]}"
1176 local prv="${COMP_WORDS[COMP_CWORD-1]}"
1179 __gitcomp "$(__git_remotes)"
1183 __gitcomp "$(__git_refs)"
1187 local remote="${prv#remote.}"
1188 remote="${remote%.fetch}"
1189 __gitcomp "$(__git_refs_remotes "$remote")"
1193 local remote="${prv#remote.}"
1194 remote="${remote%.push}"
1195 __gitcomp "$(git --git-dir="$(__gitdir)" \
1196 for-each-ref --format='%(refname):%(refname)' \
1200 pull.twohead|pull.octopus)
1201 __gitcomp "$(__git_merge_strategies)"
1204 color.branch|color.diff|color.status)
1205 __gitcomp "always never auto"
1210 normal black red green yellow blue magenta cyan white
1211 bold dim ul blink reverse
1223 --global --system --file=
1224 --list --replace-all
1225 --get --get-all --get-regexp
1226 --add --unset --unset-all
1227 --remove-section --rename-section
1232 local pfx="${cur%.*}."
1234 __gitcomp "remote merge mergeoptions" "$pfx" "$cur"
1238 local pfx="${cur%.*}."
1240 __gitcomp "$(__git_heads)" "$pfx" "$cur" "."
1244 local pfx="${cur%.*}."
1247 url proxy fetch push mirror skipDefaultUpdate
1248 receivepack uploadpack tagopt
1253 local pfx="${cur%.*}."
1255 __gitcomp "$(__git_remotes)" "$pfx" "$cur" "."
1261 branch.autosetupmerge
1262 branch.autosetuprebase
1265 color.branch.current
1276 color.diff.whitespace
1278 color.interactive.header
1279 color.interactive.help
1280 color.interactive.prompt
1284 color.status.changed
1286 color.status.nobranch
1287 color.status.untracked
1288 color.status.updated
1294 core.deltaBaseCacheLimit
1298 core.fsyncobjectfiles
1300 core.ignoreCygwinFSTricks
1302 core.logAllRefUpdates
1303 core.loosecompression
1305 core.packedGitWindowSize
1307 core.preferSymlinkRefs
1310 core.repositoryFormatVersion
1312 core.sharedRepository
1315 core.warnAmbiguousRefs
1318 diff.autorefreshindex
1335 gc.reflogexpireunreachable
1339 gitcvs.dbTableNamePrefix
1349 gui.copyblamethreshold
1353 gui.matchtrackingbranch
1354 gui.newbranchtemplate
1355 gui.pruneduringfetch
1356 gui.spellingdictionary
1372 i18n.logOutputEncoding
1387 mergetool.keepBackup
1389 pack.deltaCacheLimit
1399 receive.denyCurrentBranch
1401 receive.denyNonFastForwards
1404 repack.usedeltabaseoffset
1408 status.relativePaths
1409 status.showUntrackedFiles
1411 transfer.unpackLimit
1422 local subcommands="add rename rm show prune update"
1423 local subcommand="$(__git_find_subcommand "$subcommands")"
1424 if [ -z "$subcommand" ]; then
1425 __gitcomp "$subcommands"
1429 case "$subcommand" in
1430 rename|rm|show|prune)
1431 __gitcomp "$(__git_remotes)"
1434 local i c='' IFS=$'\n'
1435 for i in $(git --git-dir="$(__gitdir)" config --list); do
1453 __git_has_doubledash && return
1455 local cur="${COMP_WORDS[COMP_CWORD]}"
1458 __gitcomp "--merge --mixed --hard --soft"
1462 __gitcomp "$(__git_refs)"
1467 local cur="${COMP_WORDS[COMP_CWORD]}"
1470 __gitcomp "--edit --mainline --no-edit --no-commit --signoff"
1474 __gitcomp "$(__git_refs)"
1479 __git_has_doubledash && return
1481 local cur="${COMP_WORDS[COMP_CWORD]}"
1484 __gitcomp "--cached --dry-run --ignore-unmatch --quiet"
1493 __git_has_doubledash && return
1495 local cur="${COMP_WORDS[COMP_CWORD]}"
1499 --max-count= --max-age= --since= --after=
1500 --min-age= --before= --until=
1502 --author= --committer= --grep=
1505 --numbered --summary
1510 __git_complete_revlist
1515 __git_has_doubledash && return
1517 local cur="${COMP_WORDS[COMP_CWORD]}"
1520 __gitcomp "$__git_log_pretty_formats
1521 " "" "${cur##--pretty=}"
1525 __gitcomp "--pretty=
1526 $__git_diff_common_options
1536 local cur="${COMP_WORDS[COMP_CWORD]}"
1540 --all --remotes --topo-order --current --more=
1541 --list --independent --merge-base --no-name
1542 --sha1-name --topics --reflog
1547 __git_complete_revlist
1552 local subcommands='save list show apply clear drop pop create branch'
1553 local subcommand="$(__git_find_subcommand "$subcommands")"
1554 if [ -z "$subcommand" ]; then
1555 __gitcomp "$subcommands"
1557 local cur="${COMP_WORDS[COMP_CWORD]}"
1558 case "$subcommand,$cur" in
1560 __gitcomp "--keep-index"
1565 show,--*|drop,--*|pop,--*|branch,--*)
1568 show,*|apply,*|drop,*|pop,*|branch,*)
1569 __gitcomp "$(git --git-dir="$(__gitdir)" stash list \
1570 | sed -n -e 's/:.*//p')"
1581 __git_has_doubledash && return
1583 local subcommands="add status init update summary foreach sync"
1584 if [ -z "$(__git_find_subcommand "$subcommands")" ]; then
1585 local cur="${COMP_WORDS[COMP_CWORD]}"
1588 __gitcomp "--quiet --cached"
1591 __gitcomp "$subcommands"
1601 init fetch clone rebase dcommit log find-rev
1602 set-tree commit-diff info create-ignore propget
1603 proplist show-ignore show-externals
1605 local subcommand="$(__git_find_subcommand "$subcommands")"
1606 if [ -z "$subcommand" ]; then
1607 __gitcomp "$subcommands"
1609 local remote_opts="--username= --config-dir= --no-auth-cache"
1611 --follow-parent --authors-file= --repack=
1612 --no-metadata --use-svm-props --use-svnsync-props
1613 --log-window-size= --no-checkout --quiet
1614 --repack-flags --user-log-author --localtime $remote_opts
1617 --template= --shared= --trunk= --tags=
1618 --branches= --stdlayout --minimize-url
1619 --no-metadata --use-svm-props --use-svnsync-props
1620 --rewrite-root= $remote_opts
1623 --edit --rmdir --find-copies-harder --copy-similarity=
1626 local cur="${COMP_WORDS[COMP_CWORD]}"
1627 case "$subcommand,$cur" in
1629 __gitcomp "--revision= --fetch-all $fc_opts"
1632 __gitcomp "--revision= $fc_opts $init_opts"
1635 __gitcomp "$init_opts"
1639 --merge --strategy= --verbose --dry-run
1640 --fetch-all --no-rebase $cmt_opts $fc_opts
1644 __gitcomp "--stdin $cmt_opts $fc_opts"
1646 create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\
1648 __gitcomp "--revision="
1652 --limit= --revision= --verbose --incremental
1653 --oneline --show-commit --non-recursive
1659 --merge --verbose --strategy= --local
1660 --fetch-all $fc_opts
1664 __gitcomp "--message= --file= --revision= $cmt_opts"
1679 while [ $c -lt $COMP_CWORD ]; do
1680 i="${COMP_WORDS[c]}"
1683 __gitcomp "$(__git_tags)"
1693 case "${COMP_WORDS[COMP_CWORD-1]}" in
1699 __gitcomp "$(__git_tags)"
1705 __gitcomp "$(__git_refs)"
1712 local i c=1 command __git_dir
1714 while [ $c -lt $COMP_CWORD ]; do
1715 i="${COMP_WORDS[c]}"
1717 --git-dir=*) __git_dir="${i#--git-dir=}" ;;
1718 --bare) __git_dir="." ;;
1719 --version|-p|--paginate) ;;
1720 --help) command="help"; break ;;
1721 *) command="$i"; break ;;
1726 if [ -z "$command" ]; then
1727 case "${COMP_WORDS[COMP_CWORD]}" in
1739 *) __gitcomp "$(__git_porcelain_commands) $(__git_aliases)" ;;
1744 local expansion=$(__git_aliased_command "$command")
1745 [ "$expansion" ] && command="$expansion"
1750 apply) _git_apply ;;
1751 archive) _git_archive ;;
1752 bisect) _git_bisect ;;
1753 bundle) _git_bundle ;;
1754 branch) _git_branch ;;
1755 checkout) _git_checkout ;;
1756 cherry) _git_cherry ;;
1757 cherry-pick) _git_cherry_pick ;;
1758 clean) _git_clean ;;
1759 clone) _git_clone ;;
1760 commit) _git_commit ;;
1761 config) _git_config ;;
1762 describe) _git_describe ;;
1764 fetch) _git_fetch ;;
1765 format-patch) _git_format_patch ;;
1771 ls-files) _git_ls_files ;;
1772 ls-remote) _git_ls_remote ;;
1773 ls-tree) _git_ls_tree ;;
1775 mergetool) _git_mergetool;;
1776 merge-base) _git_merge_base ;;
1778 name-rev) _git_name_rev ;;
1781 rebase) _git_rebase ;;
1782 remote) _git_remote ;;
1783 reset) _git_reset ;;
1784 revert) _git_revert ;;
1786 send-email) _git_send_email ;;
1787 shortlog) _git_shortlog ;;
1789 show-branch) _git_show_branch ;;
1790 stash) _git_stash ;;
1792 submodule) _git_submodule ;;
1795 whatchanged) _git_log ;;
1802 __git_has_doubledash && return
1804 local cur="${COMP_WORDS[COMP_CWORD]}"
1805 local g="$(__gitdir)"
1807 if [ -f $g/MERGE_HEAD ]; then
1812 __gitcomp "--not --all $merge"
1816 __git_complete_revlist
1819 complete -o bashdefault -o default -o nospace -F _git git 2>/dev/null \
1820 || complete -o default -o nospace -F _git git
1821 complete -o bashdefault -o default -o nospace -F _gitk gitk 2>/dev/null \
1822 || complete -o default -o nospace -F _gitk gitk
1824 # The following are necessary only for Cygwin, and only are needed
1825 # when the user has tab-completed the executable name and consequently
1826 # included the '.exe' suffix.
1828 if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
1829 complete -o bashdefault -o default -o nospace -F _git git.exe 2>/dev/null \
1830 || complete -o default -o nospace -F _git git.exe