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="+"
139 if [ -n "${1-}" ]; then
140 printf "$1" "${b##refs/heads/}$w$i$r"
142 printf " (%s)" "${b##refs/heads/}$w$i$r"
148 # __gitcomp_1 requires 2 arguments
151 local c IFS=' '$'\t'$'\n'
154 --*=*) printf %s$'\n' "$c$2" ;;
155 *.) printf %s$'\n' "$c$2" ;;
156 *) printf %s$'\n' "$c$2 " ;;
161 # __gitcomp accepts 1, 2, 3, or 4 arguments
162 # generates completion reply with compgen
165 local cur="${COMP_WORDS[COMP_CWORD]}"
166 if [ $# -gt 2 ]; then
175 COMPREPLY=($(compgen -P "${2-}" \
176 -W "$(__gitcomp_1 "${1-}" "${4-}")" \
182 # __git_heads accepts 0 or 1 arguments (to pass to __gitdir)
185 local cmd i is_hash=y dir="$(__gitdir "${1-}")"
186 if [ -d "$dir" ]; then
187 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
191 for i in $(git ls-remote "${1-}" 2>/dev/null); do
192 case "$is_hash,$i" in
195 n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
196 n,*) is_hash=y; echo "$i" ;;
201 # __git_tags accepts 0 or 1 arguments (to pass to __gitdir)
204 local cmd i is_hash=y dir="$(__gitdir "${1-}")"
205 if [ -d "$dir" ]; then
206 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
210 for i in $(git ls-remote "${1-}" 2>/dev/null); do
211 case "$is_hash,$i" in
214 n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
215 n,*) is_hash=y; echo "$i" ;;
220 # __git_refs accepts 0 or 1 arguments (to pass to __gitdir)
223 local i is_hash=y dir="$(__gitdir "${1-}")"
224 local cur="${COMP_WORDS[COMP_CWORD]}" format refs
225 if [ -d "$dir" ]; then
232 if [ -e "$dir/HEAD" ]; then echo HEAD; fi
233 format="refname:short"
234 refs="refs/tags refs/heads refs/remotes"
237 git --git-dir="$dir" for-each-ref --format="%($format)" \
241 for i in $(git ls-remote "$dir" 2>/dev/null); do
242 case "$is_hash,$i" in
245 n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
246 n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
247 n,refs/remotes/*) is_hash=y; echo "${i#refs/remotes/}" ;;
248 n,*) is_hash=y; echo "$i" ;;
253 # __git_refs2 requires 1 argument (to pass to __git_refs)
257 for i in $(__git_refs "$1"); do
262 # __git_refs_remotes requires 1 argument (to pass to ls-remote)
263 __git_refs_remotes ()
265 local cmd i is_hash=y
266 for i in $(git ls-remote "$1" 2>/dev/null); do
267 case "$is_hash,$i" in
270 echo "$i:refs/remotes/$1/${i#refs/heads/}"
274 n,refs/tags/*) is_hash=y;;
282 local i ngoff IFS=$'\n' d="$(__gitdir)"
283 shopt -q nullglob || ngoff=1
285 for i in "$d/remotes"/*; do
286 echo ${i#$d/remotes/}
288 [ "$ngoff" ] && shopt -u nullglob
289 for i in $(git --git-dir="$d" config --list); do
299 __git_merge_strategies ()
301 if [ -n "${__git_merge_strategylist-}" ]; then
302 echo "$__git_merge_strategylist"
305 git merge -s help 2>&1 |
306 sed -n -e '/[Aa]vailable strategies are: /,/^$/{
314 __git_merge_strategylist=
315 __git_merge_strategylist=$(__git_merge_strategies 2>/dev/null)
317 __git_complete_file ()
319 local pfx ls ref cur="${COMP_WORDS[COMP_CWORD]}"
336 case "$COMP_WORDBREAKS" in
338 *) pfx="$ref:$pfx" ;;
342 COMPREPLY=($(compgen -P "$pfx" \
343 -W "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \
344 | sed '/^100... blob /{
360 __gitcomp "$(__git_refs)"
365 __git_complete_revlist ()
367 local pfx cur="${COMP_WORDS[COMP_CWORD]}"
372 __gitcomp "$(__git_refs)" "$pfx" "$cur"
377 __gitcomp "$(__git_refs)" "$pfx" "$cur"
380 __gitcomp "$(__git_refs)"
385 __git_all_commands ()
387 if [ -n "${__git_all_commandlist-}" ]; then
388 echo "$__git_all_commandlist"
392 for i in $(git help -a|egrep '^ ')
395 *--*) : helper pattern;;
400 __git_all_commandlist=
401 __git_all_commandlist="$(__git_all_commands 2>/dev/null)"
403 __git_porcelain_commands ()
405 if [ -n "${__git_porcelain_commandlist-}" ]; then
406 echo "$__git_porcelain_commandlist"
410 for i in "help" $(__git_all_commands)
413 *--*) : helper pattern;;
414 applymbox) : ask gittus;;
415 applypatch) : ask gittus;;
416 archimport) : import;;
417 cat-file) : plumbing;;
418 check-attr) : plumbing;;
419 check-ref-format) : plumbing;;
420 checkout-index) : plumbing;;
421 commit-tree) : plumbing;;
422 count-objects) : infrequent;;
423 cvsexportcommit) : export;;
424 cvsimport) : import;;
425 cvsserver) : daemon;;
427 diff-files) : plumbing;;
428 diff-index) : plumbing;;
429 diff-tree) : plumbing;;
430 fast-import) : import;;
431 fast-export) : export;;
432 fsck-objects) : plumbing;;
433 fetch-pack) : plumbing;;
434 fmt-merge-msg) : plumbing;;
435 for-each-ref) : plumbing;;
436 hash-object) : plumbing;;
437 http-*) : transport;;
438 index-pack) : plumbing;;
439 init-db) : deprecated;;
440 local-fetch) : plumbing;;
441 lost-found) : infrequent;;
442 ls-files) : plumbing;;
443 ls-remote) : plumbing;;
444 ls-tree) : plumbing;;
445 mailinfo) : plumbing;;
446 mailsplit) : plumbing;;
447 merge-*) : plumbing;;
450 pack-objects) : plumbing;;
451 pack-redundant) : plumbing;;
452 pack-refs) : plumbing;;
453 parse-remote) : plumbing;;
454 patch-id) : plumbing;;
455 peek-remote) : plumbing;;
457 prune-packed) : plumbing;;
458 quiltimport) : import;;
459 read-tree) : plumbing;;
460 receive-pack) : plumbing;;
462 repo-config) : deprecated;;
464 rev-list) : plumbing;;
465 rev-parse) : plumbing;;
466 runstatus) : plumbing;;
467 sh-setup) : internal;;
469 show-ref) : plumbing;;
470 send-pack) : plumbing;;
471 show-index) : plumbing;;
473 stripspace) : plumbing;;
474 symbolic-ref) : plumbing;;
475 tar-tree) : deprecated;;
476 unpack-file) : plumbing;;
477 unpack-objects) : plumbing;;
478 update-index) : plumbing;;
479 update-ref) : plumbing;;
480 update-server-info) : daemon;;
481 upload-archive) : plumbing;;
482 upload-pack) : plumbing;;
483 write-tree) : plumbing;;
485 verify-pack) : infrequent;;
486 verify-tag) : plumbing;;
491 __git_porcelain_commandlist=
492 __git_porcelain_commandlist="$(__git_porcelain_commands 2>/dev/null)"
497 for i in $(git --git-dir="$(__gitdir)" config --list); do
507 # __git_aliased_command requires 1 argument
508 __git_aliased_command ()
510 local word cmdline=$(git --git-dir="$(__gitdir)" \
511 config --get "alias.$1")
512 for word in $cmdline; do
513 if [ "${word##-*}" ]; then
520 # __git_find_subcommand requires 1 argument
521 __git_find_subcommand ()
523 local word subcommand c=1
525 while [ $c -lt $COMP_CWORD ]; do
526 word="${COMP_WORDS[c]}"
527 for subcommand in $1; do
528 if [ "$subcommand" = "$word" ]; then
537 __git_has_doubledash ()
540 while [ $c -lt $COMP_CWORD ]; do
541 if [ "--" = "${COMP_WORDS[c]}" ]; then
549 __git_whitespacelist="nowarn warn error error-all fix"
553 local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)"
554 if [ -d "$dir"/rebase-apply ]; then
555 __gitcomp "--skip --resolved --abort"
560 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
565 --signoff --utf8 --binary --3way --interactive
575 local cur="${COMP_WORDS[COMP_CWORD]}"
578 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
583 --stat --numstat --summary --check --index
584 --cached --index-info --reverse --reject --unidiff-zero
585 --apply --no-add --exclude=
586 --whitespace= --inaccurate-eof --verbose
595 __git_has_doubledash && return
597 local cur="${COMP_WORDS[COMP_CWORD]}"
601 --interactive --refresh --patch --update --dry-run
602 --ignore-errors --intent-to-add
611 local cur="${COMP_WORDS[COMP_CWORD]}"
614 __gitcomp "$(git archive --list)" "" "${cur##--format=}"
618 __gitcomp "$(__git_remotes)" "" "${cur##--remote=}"
623 --format= --list --verbose
624 --prefix= --remote= --exec=
634 __git_has_doubledash && return
636 local subcommands="start bad good skip reset visualize replay log run"
637 local subcommand="$(__git_find_subcommand "$subcommands")"
638 if [ -z "$subcommand" ]; then
639 __gitcomp "$subcommands"
643 case "$subcommand" in
645 __gitcomp "$(__git_refs)"
655 local i c=1 only_local_ref="n" has_r="n"
657 while [ $c -lt $COMP_CWORD ]; do
660 -d|-m) only_local_ref="y" ;;
666 case "${COMP_WORDS[COMP_CWORD]}" in
669 --color --no-color --verbose --abbrev= --no-abbrev
670 --track --no-track --contains --merged --no-merged
674 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
675 __gitcomp "$(__git_heads)"
677 __gitcomp "$(__git_refs)"
685 local cmd="${COMP_WORDS[2]}"
686 case "$COMP_CWORD" in
688 __gitcomp "create list-heads verify unbundle"
696 __git_complete_revlist
705 __git_has_doubledash && return
707 __gitcomp "$(__git_refs)"
712 __gitcomp "$(__git_refs)"
717 local cur="${COMP_WORDS[COMP_CWORD]}"
720 __gitcomp "--edit --no-commit"
723 __gitcomp "$(__git_refs)"
730 __git_has_doubledash && return
732 local cur="${COMP_WORDS[COMP_CWORD]}"
735 __gitcomp "--dry-run --quiet"
744 local cur="${COMP_WORDS[COMP_CWORD]}"
769 __git_has_doubledash && return
771 local cur="${COMP_WORDS[COMP_CWORD]}"
775 --all --author= --signoff --verify --no-verify
776 --edit --amend --include --only --interactive
785 local cur="${COMP_WORDS[COMP_CWORD]}"
789 --all --tags --contains --abbrev= --candidates=
790 --exact-match --debug --long --match --always
794 __gitcomp "$(__git_refs)"
797 __git_diff_common_options="--stat --numstat --shortstat --summary
798 --patch-with-stat --name-only --name-status --color
799 --no-color --color-words --no-renames --check
800 --full-index --binary --abbrev --diff-filter=
802 --text --ignore-space-at-eol --ignore-space-change
803 --ignore-all-space --exit-code --quiet --ext-diff
805 --no-prefix --src-prefix= --dst-prefix=
806 --inter-hunk-context=
813 __git_has_doubledash && return
815 local cur="${COMP_WORDS[COMP_CWORD]}"
818 __gitcomp "--cached --pickaxe-all --pickaxe-regex
819 --base --ours --theirs
820 $__git_diff_common_options
830 local cur="${COMP_WORDS[COMP_CWORD]}"
832 if [ "$COMP_CWORD" = 2 ]; then
833 __gitcomp "$(__git_remotes)"
838 case "$COMP_WORDBREAKS" in
840 *) pfx="${cur%%:*}:" ;;
842 __gitcomp "$(__git_refs)" "$pfx" "${cur#*:}"
845 __gitcomp "$(__git_refs2 "${COMP_WORDS[2]}")"
853 local cur="${COMP_WORDS[COMP_CWORD]}"
857 --stdout --attach --thread
859 --numbered --start-number
864 --full-index --binary
867 --no-prefix --src-prefix= --dst-prefix=
868 --inline --suffix= --ignore-if-in-upstream
874 __git_complete_revlist
879 local cur="${COMP_WORDS[COMP_CWORD]}"
882 __gitcomp "--prune --aggressive"
891 __git_has_doubledash && return
893 local cur="${COMP_WORDS[COMP_CWORD]}"
898 --text --ignore-case --word-regexp --invert-match
900 --extended-regexp --basic-regexp --fixed-strings
901 --files-with-matches --name-only
902 --files-without-match
904 --and --or --not --all-match
914 local cur="${COMP_WORDS[COMP_CWORD]}"
917 __gitcomp "--all --info --man --web"
921 __gitcomp "$(__git_all_commands)
922 attributes cli core-tutorial cvs-migration
923 diffcore gitk glossary hooks ignore modules
924 repository-layout tutorial tutorial-2
931 local cur="${COMP_WORDS[COMP_CWORD]}"
935 false true umask group all world everybody
936 " "" "${cur##--shared=}"
940 __gitcomp "--quiet --bare --template= --shared --shared="
949 __git_has_doubledash && return
951 local cur="${COMP_WORDS[COMP_CWORD]}"
954 __gitcomp "--cached --deleted --modified --others --ignored
955 --stage --directory --no-empty-directory --unmerged
956 --killed --exclude= --exclude-from=
957 --exclude-per-directory= --exclude-standard
958 --error-unmatch --with-tree= --full-name
959 --abbrev --ignored --exclude-per-directory
969 __gitcomp "$(__git_remotes)"
977 __git_log_pretty_formats="oneline short medium full fuller email raw format:"
981 __git_has_doubledash && return
983 local cur="${COMP_WORDS[COMP_CWORD]}"
986 __gitcomp "$__git_log_pretty_formats
987 " "" "${cur##--pretty=}"
992 relative iso8601 rfc2822 short local default
993 " "" "${cur##--date=}"
998 --max-count= --max-age= --since= --after=
999 --min-age= --before= --until=
1000 --root --topo-order --date-order --reverse
1001 --no-merges --follow
1002 --abbrev-commit --abbrev=
1003 --relative-date --date=
1004 --author= --committer= --grep=
1008 --left-right --cherry-pick
1012 --parents --children --full-history
1014 $__git_diff_common_options
1015 --pickaxe-all --pickaxe-regex
1020 __git_complete_revlist
1025 local cur="${COMP_WORDS[COMP_CWORD]}"
1026 case "${COMP_WORDS[COMP_CWORD-1]}" in
1028 __gitcomp "$(__git_merge_strategies)"
1033 __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}"
1038 --no-commit --no-stat --log --no-log --squash --strategy
1042 __gitcomp "$(__git_refs)"
1047 local cur="${COMP_WORDS[COMP_CWORD]}"
1051 kdiff3 tkdiff meld xxdiff emerge
1052 vimdiff gvimdiff ecmerge opendiff
1053 " "" "${cur##--tool=}"
1066 __gitcomp "$(__git_refs)"
1071 local cur="${COMP_WORDS[COMP_CWORD]}"
1074 __gitcomp "--dry-run"
1083 __gitcomp "--tags --all --stdin"
1088 local cur="${COMP_WORDS[COMP_CWORD]}"
1090 if [ "$COMP_CWORD" = 2 ]; then
1091 __gitcomp "$(__git_remotes)"
1093 __gitcomp "$(__git_refs "${COMP_WORDS[2]}")"
1099 local cur="${COMP_WORDS[COMP_CWORD]}"
1101 if [ "$COMP_CWORD" = 2 ]; then
1102 __gitcomp "$(__git_remotes)"
1107 case "$COMP_WORDBREAKS" in
1109 *) pfx="${cur%%:*}:" ;;
1112 __gitcomp "$(__git_refs "${COMP_WORDS[2]}")" "$pfx" "${cur#*:}"
1115 __gitcomp "$(__git_refs)" + "${cur#+}"
1118 __gitcomp "$(__git_refs)"
1126 local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)"
1127 if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
1128 __gitcomp "--continue --skip --abort"
1131 case "${COMP_WORDS[COMP_CWORD-1]}" in
1133 __gitcomp "$(__git_merge_strategies)"
1138 __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}"
1142 __gitcomp "--onto --merge --strategy --interactive"
1145 __gitcomp "$(__git_refs)"
1150 local cur="${COMP_WORDS[COMP_CWORD]}"
1153 __gitcomp "--bcc --cc --cc-cmd --chain-reply-to --compose
1154 --dry-run --envelope-sender --from --identity
1155 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
1156 --no-suppress-from --no-thread --quiet
1157 --signed-off-by-cc --smtp-pass --smtp-server
1158 --smtp-server-port --smtp-ssl --smtp-user --subject
1159 --suppress-cc --suppress-from --thread --to
1160 --validate --no-validate"
1169 local cur="${COMP_WORDS[COMP_CWORD]}"
1170 local prv="${COMP_WORDS[COMP_CWORD-1]}"
1173 __gitcomp "$(__git_remotes)"
1177 __gitcomp "$(__git_refs)"
1181 local remote="${prv#remote.}"
1182 remote="${remote%.fetch}"
1183 __gitcomp "$(__git_refs_remotes "$remote")"
1187 local remote="${prv#remote.}"
1188 remote="${remote%.push}"
1189 __gitcomp "$(git --git-dir="$(__gitdir)" \
1190 for-each-ref --format='%(refname):%(refname)' \
1194 pull.twohead|pull.octopus)
1195 __gitcomp "$(__git_merge_strategies)"
1198 color.branch|color.diff|color.status)
1199 __gitcomp "always never auto"
1204 normal black red green yellow blue magenta cyan white
1205 bold dim ul blink reverse
1217 --global --system --file=
1218 --list --replace-all
1219 --get --get-all --get-regexp
1220 --add --unset --unset-all
1221 --remove-section --rename-section
1226 local pfx="${cur%.*}."
1228 __gitcomp "remote merge mergeoptions" "$pfx" "$cur"
1232 local pfx="${cur%.*}."
1234 __gitcomp "$(__git_heads)" "$pfx" "$cur" "."
1238 local pfx="${cur%.*}."
1241 url proxy fetch push mirror skipDefaultUpdate
1242 receivepack uploadpack tagopt
1247 local pfx="${cur%.*}."
1249 __gitcomp "$(__git_remotes)" "$pfx" "$cur" "."
1255 branch.autosetupmerge
1256 branch.autosetuprebase
1259 color.branch.current
1270 color.diff.whitespace
1272 color.interactive.header
1273 color.interactive.help
1274 color.interactive.prompt
1278 color.status.changed
1280 color.status.nobranch
1281 color.status.untracked
1282 color.status.updated
1288 core.deltaBaseCacheLimit
1292 core.fsyncobjectfiles
1294 core.ignoreCygwinFSTricks
1296 core.logAllRefUpdates
1297 core.loosecompression
1299 core.packedGitWindowSize
1301 core.preferSymlinkRefs
1304 core.repositoryFormatVersion
1306 core.sharedRepository
1309 core.warnAmbiguousRefs
1312 diff.autorefreshindex
1329 gc.reflogexpireunreachable
1333 gitcvs.dbTableNamePrefix
1343 gui.copyblamethreshold
1347 gui.matchtrackingbranch
1348 gui.newbranchtemplate
1349 gui.pruneduringfetch
1350 gui.spellingdictionary
1366 i18n.logOutputEncoding
1381 mergetool.keepBackup
1383 pack.deltaCacheLimit
1393 receive.denyCurrentBranch
1395 receive.denyNonFastForwards
1398 repack.usedeltabaseoffset
1402 status.relativePaths
1403 status.showUntrackedFiles
1405 transfer.unpackLimit
1416 local subcommands="add rename rm show prune update"
1417 local subcommand="$(__git_find_subcommand "$subcommands")"
1418 if [ -z "$subcommand" ]; then
1419 __gitcomp "$subcommands"
1423 case "$subcommand" in
1424 rename|rm|show|prune)
1425 __gitcomp "$(__git_remotes)"
1428 local i c='' IFS=$'\n'
1429 for i in $(git --git-dir="$(__gitdir)" config --list); do
1447 __git_has_doubledash && return
1449 local cur="${COMP_WORDS[COMP_CWORD]}"
1452 __gitcomp "--merge --mixed --hard --soft"
1456 __gitcomp "$(__git_refs)"
1461 local cur="${COMP_WORDS[COMP_CWORD]}"
1464 __gitcomp "--edit --mainline --no-edit --no-commit --signoff"
1468 __gitcomp "$(__git_refs)"
1473 __git_has_doubledash && return
1475 local cur="${COMP_WORDS[COMP_CWORD]}"
1478 __gitcomp "--cached --dry-run --ignore-unmatch --quiet"
1487 __git_has_doubledash && return
1489 local cur="${COMP_WORDS[COMP_CWORD]}"
1493 --max-count= --max-age= --since= --after=
1494 --min-age= --before= --until=
1496 --author= --committer= --grep=
1499 --numbered --summary
1504 __git_complete_revlist
1509 __git_has_doubledash && return
1511 local cur="${COMP_WORDS[COMP_CWORD]}"
1514 __gitcomp "$__git_log_pretty_formats
1515 " "" "${cur##--pretty=}"
1519 __gitcomp "--pretty=
1520 $__git_diff_common_options
1530 local cur="${COMP_WORDS[COMP_CWORD]}"
1534 --all --remotes --topo-order --current --more=
1535 --list --independent --merge-base --no-name
1536 --sha1-name --topics --reflog
1541 __git_complete_revlist
1546 local subcommands='save list show apply clear drop pop create branch'
1547 local subcommand="$(__git_find_subcommand "$subcommands")"
1548 if [ -z "$subcommand" ]; then
1549 __gitcomp "$subcommands"
1551 local cur="${COMP_WORDS[COMP_CWORD]}"
1552 case "$subcommand,$cur" in
1554 __gitcomp "--keep-index"
1559 show,--*|drop,--*|pop,--*|branch,--*)
1562 show,*|apply,*|drop,*|pop,*|branch,*)
1563 __gitcomp "$(git --git-dir="$(__gitdir)" stash list \
1564 | sed -n -e 's/:.*//p')"
1575 __git_has_doubledash && return
1577 local subcommands="add status init update summary foreach sync"
1578 if [ -z "$(__git_find_subcommand "$subcommands")" ]; then
1579 local cur="${COMP_WORDS[COMP_CWORD]}"
1582 __gitcomp "--quiet --cached"
1585 __gitcomp "$subcommands"
1595 init fetch clone rebase dcommit log find-rev
1596 set-tree commit-diff info create-ignore propget
1597 proplist show-ignore show-externals
1599 local subcommand="$(__git_find_subcommand "$subcommands")"
1600 if [ -z "$subcommand" ]; then
1601 __gitcomp "$subcommands"
1603 local remote_opts="--username= --config-dir= --no-auth-cache"
1605 --follow-parent --authors-file= --repack=
1606 --no-metadata --use-svm-props --use-svnsync-props
1607 --log-window-size= --no-checkout --quiet
1608 --repack-flags --user-log-author --localtime $remote_opts
1611 --template= --shared= --trunk= --tags=
1612 --branches= --stdlayout --minimize-url
1613 --no-metadata --use-svm-props --use-svnsync-props
1614 --rewrite-root= $remote_opts
1617 --edit --rmdir --find-copies-harder --copy-similarity=
1620 local cur="${COMP_WORDS[COMP_CWORD]}"
1621 case "$subcommand,$cur" in
1623 __gitcomp "--revision= --fetch-all $fc_opts"
1626 __gitcomp "--revision= $fc_opts $init_opts"
1629 __gitcomp "$init_opts"
1633 --merge --strategy= --verbose --dry-run
1634 --fetch-all --no-rebase $cmt_opts $fc_opts
1638 __gitcomp "--stdin $cmt_opts $fc_opts"
1640 create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\
1642 __gitcomp "--revision="
1646 --limit= --revision= --verbose --incremental
1647 --oneline --show-commit --non-recursive
1653 --merge --verbose --strategy= --local
1654 --fetch-all $fc_opts
1658 __gitcomp "--message= --file= --revision= $cmt_opts"
1673 while [ $c -lt $COMP_CWORD ]; do
1674 i="${COMP_WORDS[c]}"
1677 __gitcomp "$(__git_tags)"
1687 case "${COMP_WORDS[COMP_CWORD-1]}" in
1693 __gitcomp "$(__git_tags)"
1699 __gitcomp "$(__git_refs)"
1706 local i c=1 command __git_dir
1708 while [ $c -lt $COMP_CWORD ]; do
1709 i="${COMP_WORDS[c]}"
1711 --git-dir=*) __git_dir="${i#--git-dir=}" ;;
1712 --bare) __git_dir="." ;;
1713 --version|-p|--paginate) ;;
1714 --help) command="help"; break ;;
1715 *) command="$i"; break ;;
1720 if [ -z "$command" ]; then
1721 case "${COMP_WORDS[COMP_CWORD]}" in
1733 *) __gitcomp "$(__git_porcelain_commands) $(__git_aliases)" ;;
1738 local expansion=$(__git_aliased_command "$command")
1739 [ "$expansion" ] && command="$expansion"
1744 apply) _git_apply ;;
1745 archive) _git_archive ;;
1746 bisect) _git_bisect ;;
1747 bundle) _git_bundle ;;
1748 branch) _git_branch ;;
1749 checkout) _git_checkout ;;
1750 cherry) _git_cherry ;;
1751 cherry-pick) _git_cherry_pick ;;
1752 clean) _git_clean ;;
1753 clone) _git_clone ;;
1754 commit) _git_commit ;;
1755 config) _git_config ;;
1756 describe) _git_describe ;;
1758 fetch) _git_fetch ;;
1759 format-patch) _git_format_patch ;;
1765 ls-files) _git_ls_files ;;
1766 ls-remote) _git_ls_remote ;;
1767 ls-tree) _git_ls_tree ;;
1769 mergetool) _git_mergetool;;
1770 merge-base) _git_merge_base ;;
1772 name-rev) _git_name_rev ;;
1775 rebase) _git_rebase ;;
1776 remote) _git_remote ;;
1777 reset) _git_reset ;;
1778 revert) _git_revert ;;
1780 send-email) _git_send_email ;;
1781 shortlog) _git_shortlog ;;
1783 show-branch) _git_show_branch ;;
1784 stash) _git_stash ;;
1786 submodule) _git_submodule ;;
1789 whatchanged) _git_log ;;
1796 __git_has_doubledash && return
1798 local cur="${COMP_WORDS[COMP_CWORD]}"
1799 local g="$(__gitdir)"
1801 if [ -f $g/MERGE_HEAD ]; then
1806 __gitcomp "--not --all $merge"
1810 __git_complete_revlist
1813 complete -o bashdefault -o default -o nospace -F _git git 2>/dev/null \
1814 || complete -o default -o nospace -F _git git
1815 complete -o bashdefault -o default -o nospace -F _gitk gitk 2>/dev/null \
1816 || complete -o default -o nospace -F _gitk gitk
1818 # The following are necessary only for Cygwin, and only are needed
1819 # when the user has tab-completed the executable name and consequently
1820 # included the '.exe' suffix.
1822 if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
1823 complete -o bashdefault -o default -o nospace -F _git git.exe 2>/dev/null \
1824 || complete -o default -o nospace -F _git git.exe