2 # bash completion support for core Git.
4 # Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
5 # Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
6 # Distributed under the GNU General Public License, version 2.0.
8 # The contained completion routines provide support for completing:
10 # *) local and remote branch names
11 # *) local and remote tag names
12 # *) .git/remotes file names
13 # *) git 'subcommands'
14 # *) tree paths within 'ref:path/to/file' expressions
15 # *) common --long-options
17 # To use these routines:
19 # 1) Copy this file to somewhere (e.g. ~/.git-completion.sh).
20 # 2) Added the following line to your .bashrc:
21 # source ~/.git-completion.sh
23 # 3) You may want to make sure the git executable is available
24 # in your PATH before this script is sourced, as some caching
25 # is performed while the script loads. If git isn't found
26 # at source time then all lookups will be done on demand,
27 # which may be slightly slower.
29 # 4) Consider changing your PS1 to also show the current branch:
30 # PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
32 # The argument to __git_ps1 will be displayed only if you
33 # are currently in a git repository. The %s token will be
34 # the name of the current branch.
38 # *) Read Documentation/SubmittingPatches
39 # *) Send all patches to the current maintainer:
41 # "Shawn O. Pearce" <spearce@spearce.org>
43 # *) Always CC the Git mailing list:
48 case "$COMP_WORDBREAKS" in
50 *) COMP_WORDBREAKS="$COMP_WORDBREAKS:"
56 if [ -n "$__git_dir" ]; then
58 elif [ -d .git ]; then
61 git rev-parse --git-dir 2>/dev/null
63 elif [ -d "$1/.git" ]; then
72 local g="$(git rev-parse --git-dir 2>/dev/null)"
76 if [ -d "$g/rebase-apply" ]
78 if test -f "$g/rebase-apply/rebasing"
81 elif test -f "$g/rebase-apply/applying"
87 b="$(git symbolic-ref HEAD 2>/dev/null)"
88 elif [ -f "$g/rebase-merge/interactive" ]
91 b="$(cat "$g/rebase-merge/head-name")"
92 elif [ -d "$g/rebase-merge" ]
95 b="$(cat "$g/rebase-merge/head-name")"
96 elif [ -f "$g/MERGE_HEAD" ]
99 b="$(git symbolic-ref HEAD 2>/dev/null)"
101 if [ -f "$g/BISECT_LOG" ]
105 if ! b="$(git symbolic-ref HEAD 2>/dev/null)"
107 if ! b="$(git describe --exact-match HEAD 2>/dev/null)"
109 b="$(cut -c1-7 "$g/HEAD")..."
115 printf "$1" "${b##refs/heads/}$r"
117 printf " (%s)" "${b##refs/heads/}$r"
124 local c IFS=' '$'\t'$'\n'
127 --*=*) printf %s$'\n' "$c$2" ;;
128 *.) printf %s$'\n' "$c$2" ;;
129 *) printf %s$'\n' "$c$2 " ;;
136 local cur="${COMP_WORDS[COMP_CWORD]}"
137 if [ $# -gt 2 ]; then
146 COMPREPLY=($(compgen -P "$2" \
147 -W "$(__gitcomp_1 "$1" "$4")" \
155 local cmd i is_hash=y dir="$(__gitdir "$1")"
156 if [ -d "$dir" ]; then
157 for i in $(git --git-dir="$dir" \
158 for-each-ref --format='%(refname)' \
160 echo "${i#refs/heads/}"
164 for i in $(git ls-remote "$1" 2>/dev/null); do
165 case "$is_hash,$i" in
168 n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
169 n,*) is_hash=y; echo "$i" ;;
176 local cmd i is_hash=y dir="$(__gitdir "$1")"
177 if [ -d "$dir" ]; then
178 for i in $(git --git-dir="$dir" \
179 for-each-ref --format='%(refname)' \
181 echo "${i#refs/tags/}"
185 for i in $(git ls-remote "$1" 2>/dev/null); do
186 case "$is_hash,$i" in
189 n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
190 n,*) is_hash=y; echo "$i" ;;
197 local cmd i is_hash=y dir="$(__gitdir "$1")"
198 if [ -d "$dir" ]; then
199 if [ -e "$dir/HEAD" ]; then echo HEAD; fi
200 for i in $(git --git-dir="$dir" \
201 for-each-ref --format='%(refname)' \
202 refs/tags refs/heads refs/remotes); do
204 refs/tags/*) echo "${i#refs/tags/}" ;;
205 refs/heads/*) echo "${i#refs/heads/}" ;;
206 refs/remotes/*) echo "${i#refs/remotes/}" ;;
212 for i in $(git ls-remote "$dir" 2>/dev/null); do
213 case "$is_hash,$i" in
216 n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
217 n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
218 n,refs/remotes/*) is_hash=y; echo "${i#refs/remotes/}" ;;
219 n,*) is_hash=y; echo "$i" ;;
227 for i in $(__git_refs "$1"); do
232 __git_refs_remotes ()
234 local cmd i is_hash=y
235 for i in $(git ls-remote "$1" 2>/dev/null); do
236 case "$is_hash,$i" in
239 echo "$i:refs/remotes/$1/${i#refs/heads/}"
243 n,refs/tags/*) is_hash=y;;
251 local i ngoff IFS=$'\n' d="$(__gitdir)"
252 shopt -q nullglob || ngoff=1
254 for i in "$d/remotes"/*; do
255 echo ${i#$d/remotes/}
257 [ "$ngoff" ] && shopt -u nullglob
258 for i in $(git --git-dir="$d" config --list); do
268 __git_merge_strategies ()
270 if [ -n "$__git_merge_strategylist" ]; then
271 echo "$__git_merge_strategylist"
274 git merge -s help 2>&1 |
275 sed -n -e '/[Aa]vailable strategies are: /,/^$/{
283 __git_merge_strategylist=
284 __git_merge_strategylist=$(__git_merge_strategies 2>/dev/null)
286 __git_complete_file ()
288 local pfx ls ref cur="${COMP_WORDS[COMP_CWORD]}"
305 case "$COMP_WORDBREAKS" in
307 *) pfx="$ref:$pfx" ;;
311 COMPREPLY=($(compgen -P "$pfx" \
312 -W "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \
313 | sed '/^100... blob /{
329 __gitcomp "$(__git_refs)"
334 __git_complete_revlist ()
336 local pfx cur="${COMP_WORDS[COMP_CWORD]}"
341 __gitcomp "$(__git_refs)" "$pfx" "$cur"
346 __gitcomp "$(__git_refs)" "$pfx" "$cur"
349 __gitcomp "$(__git_refs)"
354 __git_all_commands ()
356 if [ -n "$__git_all_commandlist" ]; then
357 echo "$__git_all_commandlist"
361 for i in $(git help -a|egrep '^ ')
364 *--*) : helper pattern;;
369 __git_all_commandlist=
370 __git_all_commandlist="$(__git_all_commands 2>/dev/null)"
372 __git_porcelain_commands ()
374 if [ -n "$__git_porcelain_commandlist" ]; then
375 echo "$__git_porcelain_commandlist"
379 for i in "help" $(__git_all_commands)
382 *--*) : helper pattern;;
383 applymbox) : ask gittus;;
384 applypatch) : ask gittus;;
385 archimport) : import;;
386 cat-file) : plumbing;;
387 check-attr) : plumbing;;
388 check-ref-format) : plumbing;;
389 commit-tree) : plumbing;;
390 cvsexportcommit) : export;;
391 cvsimport) : import;;
392 cvsserver) : daemon;;
394 diff-files) : plumbing;;
395 diff-index) : plumbing;;
396 diff-tree) : plumbing;;
397 fast-import) : import;;
398 fsck-objects) : plumbing;;
399 fetch-pack) : plumbing;;
400 fmt-merge-msg) : plumbing;;
401 for-each-ref) : plumbing;;
402 hash-object) : plumbing;;
403 http-*) : transport;;
404 index-pack) : plumbing;;
405 init-db) : deprecated;;
406 local-fetch) : plumbing;;
407 mailinfo) : plumbing;;
408 mailsplit) : plumbing;;
409 merge-*) : plumbing;;
412 pack-objects) : plumbing;;
413 pack-redundant) : plumbing;;
414 pack-refs) : plumbing;;
415 parse-remote) : plumbing;;
416 patch-id) : plumbing;;
417 peek-remote) : plumbing;;
419 prune-packed) : plumbing;;
420 quiltimport) : import;;
421 read-tree) : plumbing;;
422 receive-pack) : plumbing;;
424 repo-config) : deprecated;;
426 rev-list) : plumbing;;
427 rev-parse) : plumbing;;
428 runstatus) : plumbing;;
429 sh-setup) : internal;;
431 send-pack) : plumbing;;
432 show-index) : plumbing;;
434 stripspace) : plumbing;;
435 symbolic-ref) : plumbing;;
436 tar-tree) : deprecated;;
437 unpack-file) : plumbing;;
438 unpack-objects) : plumbing;;
439 update-index) : plumbing;;
440 update-ref) : plumbing;;
441 update-server-info) : daemon;;
442 upload-archive) : plumbing;;
443 upload-pack) : plumbing;;
444 write-tree) : plumbing;;
445 verify-tag) : plumbing;;
450 __git_porcelain_commandlist=
451 __git_porcelain_commandlist="$(__git_porcelain_commands 2>/dev/null)"
456 for i in $(git --git-dir="$(__gitdir)" config --list); do
466 __git_aliased_command ()
468 local word cmdline=$(git --git-dir="$(__gitdir)" \
469 config --get "alias.$1")
470 for word in $cmdline; do
471 if [ "${word##-*}" ]; then
478 __git_find_subcommand ()
480 local word subcommand c=1
482 while [ $c -lt $COMP_CWORD ]; do
483 word="${COMP_WORDS[c]}"
484 for subcommand in $1; do
485 if [ "$subcommand" = "$word" ]; then
494 __git_has_doubledash ()
497 while [ $c -lt $COMP_CWORD ]; do
498 if [ "--" = "${COMP_WORDS[c]}" ]; then
506 __git_whitespacelist="nowarn warn error error-all fix"
510 local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)"
511 if [ -d "$dir"/rebase-apply ]; then
512 __gitcomp "--skip --resolved --abort"
517 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
522 --signoff --utf8 --binary --3way --interactive
532 local cur="${COMP_WORDS[COMP_CWORD]}"
535 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
540 --stat --numstat --summary --check --index
541 --cached --index-info --reverse --reject --unidiff-zero
542 --apply --no-add --exclude=
543 --whitespace= --inaccurate-eof --verbose
552 __git_has_doubledash && return
554 local cur="${COMP_WORDS[COMP_CWORD]}"
558 --interactive --refresh --patch --update --dry-run
568 local cur="${COMP_WORDS[COMP_CWORD]}"
571 __gitcomp "$(git archive --list)" "" "${cur##--format=}"
575 __gitcomp "$(__git_remotes)" "" "${cur##--remote=}"
580 --format= --list --verbose
581 --prefix= --remote= --exec=
591 __git_has_doubledash && return
593 local subcommands="start bad good skip reset visualize replay log run"
594 local subcommand="$(__git_find_subcommand "$subcommands")"
595 if [ -z "$subcommand" ]; then
596 __gitcomp "$subcommands"
600 case "$subcommand" in
602 __gitcomp "$(__git_refs)"
612 local i c=1 only_local_ref="n" has_r="n"
614 while [ $c -lt $COMP_CWORD ]; do
617 -d|-m) only_local_ref="y" ;;
623 case "${COMP_WORDS[COMP_CWORD]}" in
624 --*=*) COMPREPLY=() ;;
627 --color --no-color --verbose --abbrev= --no-abbrev
628 --track --no-track --contains --merged --no-merged
632 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
633 __gitcomp "$(__git_heads)"
635 __gitcomp "$(__git_refs)"
643 local mycword="$COMP_CWORD"
644 case "${COMP_WORDS[0]}" in
646 local cmd="${COMP_WORDS[2]}"
647 mycword="$((mycword-1))"
650 local cmd="${COMP_WORDS[1]}"
655 __gitcomp "create list-heads verify unbundle"
663 __git_complete_revlist
672 __git_has_doubledash && return
674 __gitcomp "$(__git_refs)"
679 __gitcomp "$(__git_refs)"
684 local cur="${COMP_WORDS[COMP_CWORD]}"
687 __gitcomp "--edit --no-commit"
690 __gitcomp "$(__git_refs)"
697 __git_has_doubledash && return
699 local cur="${COMP_WORDS[COMP_CWORD]}"
702 __gitcomp "--dry-run --quiet"
711 local cur="${COMP_WORDS[COMP_CWORD]}"
736 __git_has_doubledash && return
738 local cur="${COMP_WORDS[COMP_CWORD]}"
742 --all --author= --signoff --verify --no-verify
743 --edit --amend --include --only
752 local cur="${COMP_WORDS[COMP_CWORD]}"
756 --all --tags --contains --abbrev= --candidates=
757 --exact-match --debug --long --match --always
761 __gitcomp "$(__git_refs)"
766 __git_has_doubledash && return
768 local cur="${COMP_WORDS[COMP_CWORD]}"
771 __gitcomp "--cached --stat --numstat --shortstat --summary
772 --patch-with-stat --name-only --name-status --color
773 --no-color --color-words --no-renames --check
774 --full-index --binary --abbrev --diff-filter=
775 --find-copies-harder --pickaxe-all --pickaxe-regex
776 --text --ignore-space-at-eol --ignore-space-change
777 --ignore-all-space --exit-code --quiet --ext-diff
779 --no-prefix --src-prefix= --dst-prefix=
780 --base --ours --theirs
790 local cur="${COMP_WORDS[COMP_CWORD]}"
792 case "${COMP_WORDS[0]},$COMP_CWORD" in
794 __gitcomp "$(__git_remotes)"
797 __gitcomp "$(__git_remotes)"
803 case "$COMP_WORDBREAKS" in
805 *) pfx="${cur%%:*}:" ;;
807 __gitcomp "$(__git_refs)" "$pfx" "${cur#*:}"
811 case "${COMP_WORDS[0]}" in
812 git-fetch) remote="${COMP_WORDS[1]}" ;;
813 git) remote="${COMP_WORDS[2]}" ;;
815 __gitcomp "$(__git_refs2 "$remote")"
824 local cur="${COMP_WORDS[COMP_CWORD]}"
828 --stdout --attach --thread
830 --numbered --start-number
835 --full-index --binary
838 --no-prefix --src-prefix= --dst-prefix=
843 __git_complete_revlist
848 local cur="${COMP_WORDS[COMP_CWORD]}"
851 __gitcomp "--prune --aggressive"
860 __git_has_doubledash && return
862 local cur="${COMP_WORDS[COMP_CWORD]}"
867 --text --ignore-case --word-regexp --invert-match
869 --extended-regexp --basic-regexp --fixed-strings
870 --files-with-matches --name-only
871 --files-without-match
873 --and --or --not --all-match
883 local cur="${COMP_WORDS[COMP_CWORD]}"
886 __gitcomp "--all --info --man --web"
890 __gitcomp "$(__git_all_commands)
891 attributes cli core-tutorial cvs-migration
892 diffcore gitk glossary hooks ignore modules
893 repository-layout tutorial tutorial-2
899 local cur="${COMP_WORDS[COMP_CWORD]}"
903 false true umask group all world everybody
904 " "" "${cur##--shared=}"
908 __gitcomp "--quiet --bare --template= --shared --shared="
917 __git_has_doubledash && return
919 local cur="${COMP_WORDS[COMP_CWORD]}"
922 __gitcomp "--cached --deleted --modified --others --ignored
923 --stage --directory --no-empty-directory --unmerged
924 --killed --exclude= --exclude-from=
925 --exclude-per-directory= --exclude-standard
926 --error-unmatch --with-tree= --full-name
927 --abbrev --ignored --exclude-per-directory
937 __gitcomp "$(__git_remotes)"
947 __git_has_doubledash && return
949 local cur="${COMP_WORDS[COMP_CWORD]}"
953 oneline short medium full fuller email raw
954 " "" "${cur##--pretty=}"
959 relative iso8601 rfc2822 short local default
960 " "" "${cur##--date=}"
965 --max-count= --max-age= --since= --after=
966 --min-age= --before= --until=
967 --root --topo-order --date-order --reverse
969 --abbrev-commit --abbrev=
970 --relative-date --date=
971 --author= --committer= --grep=
973 --pretty= --name-status --name-only --raw
975 --left-right --cherry-pick
977 --stat --numstat --shortstat
978 --decorate --diff-filter=
979 --color-words --walk-reflogs
980 --parents --children --full-history
986 __git_complete_revlist
991 local cur="${COMP_WORDS[COMP_CWORD]}"
992 case "${COMP_WORDS[COMP_CWORD-1]}" in
994 __gitcomp "$(__git_merge_strategies)"
999 __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}"
1004 --no-commit --no-stat --log --no-log --squash --strategy
1008 __gitcomp "$(__git_refs)"
1013 local cur="${COMP_WORDS[COMP_CWORD]}"
1017 kdiff3 tkdiff meld xxdiff emerge
1018 vimdiff gvimdiff ecmerge opendiff
1019 " "" "${cur##--tool=}"
1032 __gitcomp "$(__git_refs)"
1037 local cur="${COMP_WORDS[COMP_CWORD]}"
1040 __gitcomp "--dry-run"
1049 __gitcomp "--tags --all --stdin"
1054 local cur="${COMP_WORDS[COMP_CWORD]}"
1056 case "${COMP_WORDS[0]},$COMP_CWORD" in
1058 __gitcomp "$(__git_remotes)"
1061 __gitcomp "$(__git_remotes)"
1065 case "${COMP_WORDS[0]}" in
1066 git-pull) remote="${COMP_WORDS[1]}" ;;
1067 git) remote="${COMP_WORDS[2]}" ;;
1069 __gitcomp "$(__git_refs "$remote")"
1076 local cur="${COMP_WORDS[COMP_CWORD]}"
1078 case "${COMP_WORDS[0]},$COMP_CWORD" in
1080 __gitcomp "$(__git_remotes)"
1083 __gitcomp "$(__git_remotes)"
1089 case "${COMP_WORDS[0]}" in
1090 git-push) remote="${COMP_WORDS[1]}" ;;
1091 git) remote="${COMP_WORDS[2]}" ;;
1095 case "$COMP_WORDBREAKS" in
1097 *) pfx="${cur%%:*}:" ;;
1100 __gitcomp "$(__git_refs "$remote")" "$pfx" "${cur#*:}"
1103 __gitcomp "$(__git_refs)" + "${cur#+}"
1106 __gitcomp "$(__git_refs)"
1115 local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)"
1116 if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
1117 __gitcomp "--continue --skip --abort"
1120 case "${COMP_WORDS[COMP_CWORD-1]}" in
1122 __gitcomp "$(__git_merge_strategies)"
1127 __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}"
1131 __gitcomp "--onto --merge --strategy --interactive"
1134 __gitcomp "$(__git_refs)"
1139 local cur="${COMP_WORDS[COMP_CWORD]}"
1142 __gitcomp "--bcc --cc --cc-cmd --chain-reply-to --compose
1143 --dry-run --envelope-sender --from --identity
1144 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
1145 --no-suppress-from --no-thread --quiet
1146 --signed-off-by-cc --smtp-pass --smtp-server
1147 --smtp-server-port --smtp-ssl --smtp-user --subject
1148 --suppress-cc --suppress-from --thread --to"
1157 local cur="${COMP_WORDS[COMP_CWORD]}"
1158 local prv="${COMP_WORDS[COMP_CWORD-1]}"
1161 __gitcomp "$(__git_remotes)"
1165 __gitcomp "$(__git_refs)"
1169 local remote="${prv#remote.}"
1170 remote="${remote%.fetch}"
1171 __gitcomp "$(__git_refs_remotes "$remote")"
1175 local remote="${prv#remote.}"
1176 remote="${remote%.push}"
1177 __gitcomp "$(git --git-dir="$(__gitdir)" \
1178 for-each-ref --format='%(refname):%(refname)' \
1182 pull.twohead|pull.octopus)
1183 __gitcomp "$(__git_merge_strategies)"
1186 color.branch|color.diff|color.status)
1187 __gitcomp "always never auto"
1192 black red green yellow blue magenta cyan white
1193 bold dim ul blink reverse
1205 --global --system --file=
1206 --list --replace-all
1207 --get --get-all --get-regexp
1208 --add --unset --unset-all
1209 --remove-section --rename-section
1214 local pfx="${cur%.*}."
1216 __gitcomp "remote merge" "$pfx" "$cur"
1220 local pfx="${cur%.*}."
1222 __gitcomp "$(__git_heads)" "$pfx" "$cur" "."
1226 local pfx="${cur%.*}."
1229 url fetch push skipDefaultUpdate
1230 receivepack uploadpack tagopt
1235 local pfx="${cur%.*}."
1237 __gitcomp "$(__git_remotes)" "$pfx" "$cur" "."
1246 core.preferSymlinkRefs
1247 core.logAllRefUpdates
1248 core.loosecompression
1249 core.repositoryFormatVersion
1250 core.sharedRepository
1251 core.warnAmbiguousRefs
1253 core.packedGitWindowSize
1257 color.branch.current
1268 color.diff.whitespace
1273 color.status.changed
1274 color.status.untracked
1279 format.subjectprefix
1283 gitcvs.dbname gitcvs.dbdriver gitcvs.dbuser gitcvs.dbpass
1284 gitcvs.dbtablenameprefix
1287 gc.reflogexpireunreachable
1300 i18n.logOutputEncoding
1310 pack.deltaCacheLimit
1313 repack.useDeltaBaseOffset
1316 transfer.unpackLimit
1318 receive.denyNonFastForwards
1328 local subcommands="add rm show prune update"
1329 local subcommand="$(__git_find_subcommand "$subcommands")"
1330 if [ -z "$subcommand" ]; then
1331 __gitcomp "$subcommands"
1335 case "$subcommand" in
1337 __gitcomp "$(__git_remotes)"
1340 local i c='' IFS=$'\n'
1341 for i in $(git --git-dir="$(__gitdir)" config --list); do
1359 __git_has_doubledash && return
1361 local cur="${COMP_WORDS[COMP_CWORD]}"
1364 __gitcomp "--mixed --hard --soft"
1368 __gitcomp "$(__git_refs)"
1373 local cur="${COMP_WORDS[COMP_CWORD]}"
1376 __gitcomp "--edit --mainline --no-edit --no-commit --signoff"
1385 __git_has_doubledash && return
1387 local cur="${COMP_WORDS[COMP_CWORD]}"
1390 __gitcomp "--cached --dry-run --ignore-unmatch --quiet"
1399 __git_has_doubledash && return
1401 local cur="${COMP_WORDS[COMP_CWORD]}"
1405 --max-count= --max-age= --since= --after=
1406 --min-age= --before= --until=
1408 --author= --committer= --grep=
1411 --numbered --summary
1416 __git_complete_revlist
1421 local cur="${COMP_WORDS[COMP_CWORD]}"
1425 oneline short medium full fuller email raw
1426 " "" "${cur##--pretty=}"
1430 __gitcomp "--pretty="
1439 local cur="${COMP_WORDS[COMP_CWORD]}"
1443 --all --remotes --topo-order --current --more=
1444 --list --independent --merge-base --no-name
1445 --sha1-name --topics --reflog
1450 __git_complete_revlist
1455 local subcommands='save list show apply clear drop pop create branch'
1456 local subcommand="$(__git_find_subcommand "$subcommands")"
1457 if [ -z "$subcommand" ]; then
1458 __gitcomp "$subcommands"
1460 local cur="${COMP_WORDS[COMP_CWORD]}"
1461 case "$subcommand,$cur" in
1463 __gitcomp "--keep-index"
1468 show,--*|drop,--*|pop,--*|branch,--*)
1471 show,*|apply,*|drop,*|pop,*|branch,*)
1472 __gitcomp "$(git --git-dir="$(__gitdir)" stash list \
1473 | sed -n -e 's/:.*//p')"
1484 __git_has_doubledash && return
1486 local subcommands="add status init update summary foreach sync"
1487 if [ -z "$(__git_find_subcommand "$subcommands")" ]; then
1488 local cur="${COMP_WORDS[COMP_CWORD]}"
1491 __gitcomp "--quiet --cached"
1494 __gitcomp "$subcommands"
1504 init fetch clone rebase dcommit log find-rev
1505 set-tree commit-diff info create-ignore propget
1506 proplist show-ignore show-externals
1508 local subcommand="$(__git_find_subcommand "$subcommands")"
1509 if [ -z "$subcommand" ]; then
1510 __gitcomp "$subcommands"
1512 local remote_opts="--username= --config-dir= --no-auth-cache"
1514 --follow-parent --authors-file= --repack=
1515 --no-metadata --use-svm-props --use-svnsync-props
1516 --log-window-size= --no-checkout --quiet
1517 --repack-flags --user-log-author $remote_opts
1520 --template= --shared= --trunk= --tags=
1521 --branches= --stdlayout --minimize-url
1522 --no-metadata --use-svm-props --use-svnsync-props
1523 --rewrite-root= $remote_opts
1526 --edit --rmdir --find-copies-harder --copy-similarity=
1529 local cur="${COMP_WORDS[COMP_CWORD]}"
1530 case "$subcommand,$cur" in
1532 __gitcomp "--revision= --fetch-all $fc_opts"
1535 __gitcomp "--revision= $fc_opts $init_opts"
1538 __gitcomp "$init_opts"
1542 --merge --strategy= --verbose --dry-run
1543 --fetch-all --no-rebase $cmt_opts $fc_opts
1547 __gitcomp "--stdin $cmt_opts $fc_opts"
1549 create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\
1551 __gitcomp "--revision="
1555 --limit= --revision= --verbose --incremental
1556 --oneline --show-commit --non-recursive
1562 --merge --verbose --strategy= --local
1563 --fetch-all $fc_opts
1567 __gitcomp "--message= --file= --revision= $cmt_opts"
1582 while [ $c -lt $COMP_CWORD ]; do
1583 i="${COMP_WORDS[c]}"
1586 __gitcomp "$(__git_tags)"
1596 case "${COMP_WORDS[COMP_CWORD-1]}" in
1602 __gitcomp "$(__git_tags)"
1608 __gitcomp "$(__git_refs)"
1615 local i c=1 command __git_dir
1617 while [ $c -lt $COMP_CWORD ]; do
1618 i="${COMP_WORDS[c]}"
1620 --git-dir=*) __git_dir="${i#--git-dir=}" ;;
1621 --bare) __git_dir="." ;;
1622 --version|-p|--paginate) ;;
1623 --help) command="help"; break ;;
1624 *) command="$i"; break ;;
1629 if [ -z "$command" ]; then
1630 case "${COMP_WORDS[COMP_CWORD]}" in
1631 --*=*) COMPREPLY=() ;;
1643 *) __gitcomp "$(__git_porcelain_commands) $(__git_aliases)" ;;
1648 local expansion=$(__git_aliased_command "$command")
1649 [ "$expansion" ] && command="$expansion"
1654 apply) _git_apply ;;
1655 archive) _git_archive ;;
1656 bisect) _git_bisect ;;
1657 bundle) _git_bundle ;;
1658 branch) _git_branch ;;
1659 checkout) _git_checkout ;;
1660 cherry) _git_cherry ;;
1661 cherry-pick) _git_cherry_pick ;;
1662 clean) _git_clean ;;
1663 clone) _git_clone ;;
1664 commit) _git_commit ;;
1665 config) _git_config ;;
1666 describe) _git_describe ;;
1668 fetch) _git_fetch ;;
1669 format-patch) _git_format_patch ;;
1675 ls-files) _git_ls_files ;;
1676 ls-remote) _git_ls_remote ;;
1677 ls-tree) _git_ls_tree ;;
1679 mergetool) _git_mergetool;;
1680 merge-base) _git_merge_base ;;
1682 name-rev) _git_name_rev ;;
1685 rebase) _git_rebase ;;
1686 remote) _git_remote ;;
1687 reset) _git_reset ;;
1688 revert) _git_revert ;;
1690 send-email) _git_send_email ;;
1691 shortlog) _git_shortlog ;;
1693 show-branch) _git_show_branch ;;
1694 stash) _git_stash ;;
1695 submodule) _git_submodule ;;
1698 whatchanged) _git_log ;;
1705 __git_has_doubledash && return
1707 local cur="${COMP_WORDS[COMP_CWORD]}"
1708 local g="$(git rev-parse --git-dir 2>/dev/null)"
1710 if [ -f $g/MERGE_HEAD ]; then
1715 __gitcomp "--not --all $merge"
1719 __git_complete_revlist
1722 complete -o default -o nospace -F _git git
1723 complete -o default -o nospace -F _gitk gitk
1725 # The following are necessary only for Cygwin, and only are needed
1726 # when the user has tab-completed the executable name and consequently
1727 # included the '.exe' suffix.
1729 if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
1730 complete -o default -o nospace -F _git git.exe