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 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
161 for i in $(git ls-remote "$1" 2>/dev/null); do
162 case "$is_hash,$i" in
165 n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
166 n,*) is_hash=y; echo "$i" ;;
173 local cmd i is_hash=y dir="$(__gitdir "$1")"
174 if [ -d "$dir" ]; then
175 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
179 for i in $(git ls-remote "$1" 2>/dev/null); do
180 case "$is_hash,$i" in
183 n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
184 n,*) is_hash=y; echo "$i" ;;
191 local cmd i is_hash=y dir="$(__gitdir "$1")"
192 if [ -d "$dir" ]; then
193 if [ -e "$dir/HEAD" ]; then echo HEAD; fi
194 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
195 refs/tags refs/heads refs/remotes
198 for i in $(git ls-remote "$dir" 2>/dev/null); do
199 case "$is_hash,$i" in
202 n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
203 n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
204 n,refs/remotes/*) is_hash=y; echo "${i#refs/remotes/}" ;;
205 n,*) is_hash=y; echo "$i" ;;
213 for i in $(__git_refs "$1"); do
218 __git_refs_remotes ()
220 local cmd i is_hash=y
221 for i in $(git ls-remote "$1" 2>/dev/null); do
222 case "$is_hash,$i" in
225 echo "$i:refs/remotes/$1/${i#refs/heads/}"
229 n,refs/tags/*) is_hash=y;;
237 local i ngoff IFS=$'\n' d="$(__gitdir)"
238 shopt -q nullglob || ngoff=1
240 for i in "$d/remotes"/*; do
241 echo ${i#$d/remotes/}
243 [ "$ngoff" ] && shopt -u nullglob
244 for i in $(git --git-dir="$d" config --list); do
254 __git_merge_strategies ()
256 if [ -n "$__git_merge_strategylist" ]; then
257 echo "$__git_merge_strategylist"
260 git merge -s help 2>&1 |
261 sed -n -e '/[Aa]vailable strategies are: /,/^$/{
269 __git_merge_strategylist=
270 __git_merge_strategylist=$(__git_merge_strategies 2>/dev/null)
272 __git_complete_file ()
274 local pfx ls ref cur="${COMP_WORDS[COMP_CWORD]}"
291 case "$COMP_WORDBREAKS" in
293 *) pfx="$ref:$pfx" ;;
297 COMPREPLY=($(compgen -P "$pfx" \
298 -W "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \
299 | sed '/^100... blob /{
315 __gitcomp "$(__git_refs)"
320 __git_complete_revlist ()
322 local pfx cur="${COMP_WORDS[COMP_CWORD]}"
327 __gitcomp "$(__git_refs)" "$pfx" "$cur"
332 __gitcomp "$(__git_refs)" "$pfx" "$cur"
335 __gitcomp "$(__git_refs)"
340 __git_all_commands ()
342 if [ -n "$__git_all_commandlist" ]; then
343 echo "$__git_all_commandlist"
347 for i in $(git help -a|egrep '^ ')
350 *--*) : helper pattern;;
355 __git_all_commandlist=
356 __git_all_commandlist="$(__git_all_commands 2>/dev/null)"
358 __git_porcelain_commands ()
360 if [ -n "$__git_porcelain_commandlist" ]; then
361 echo "$__git_porcelain_commandlist"
365 for i in "help" $(__git_all_commands)
368 *--*) : helper pattern;;
369 applymbox) : ask gittus;;
370 applypatch) : ask gittus;;
371 archimport) : import;;
372 cat-file) : plumbing;;
373 check-attr) : plumbing;;
374 check-ref-format) : plumbing;;
375 checkout-index) : plumbing;;
376 commit-tree) : plumbing;;
377 count-objects) : infrequent;;
378 cvsexportcommit) : export;;
379 cvsimport) : import;;
380 cvsserver) : daemon;;
382 diff-files) : plumbing;;
383 diff-index) : plumbing;;
384 diff-tree) : plumbing;;
385 fast-import) : import;;
386 fast-export) : export;;
387 fsck-objects) : plumbing;;
388 fetch-pack) : plumbing;;
389 fmt-merge-msg) : plumbing;;
390 for-each-ref) : plumbing;;
391 hash-object) : plumbing;;
392 http-*) : transport;;
393 index-pack) : plumbing;;
394 init-db) : deprecated;;
395 local-fetch) : plumbing;;
396 lost-found) : infrequent;;
397 ls-files) : plumbing;;
398 ls-remote) : plumbing;;
399 ls-tree) : plumbing;;
400 mailinfo) : plumbing;;
401 mailsplit) : plumbing;;
402 merge-*) : plumbing;;
405 pack-objects) : plumbing;;
406 pack-redundant) : plumbing;;
407 pack-refs) : plumbing;;
408 parse-remote) : plumbing;;
409 patch-id) : plumbing;;
410 peek-remote) : plumbing;;
412 prune-packed) : plumbing;;
413 quiltimport) : import;;
414 read-tree) : plumbing;;
415 receive-pack) : plumbing;;
417 repo-config) : deprecated;;
419 rev-list) : plumbing;;
420 rev-parse) : plumbing;;
421 runstatus) : plumbing;;
422 sh-setup) : internal;;
424 show-ref) : plumbing;;
425 send-pack) : plumbing;;
426 show-index) : plumbing;;
428 stripspace) : plumbing;;
429 symbolic-ref) : plumbing;;
430 tar-tree) : deprecated;;
431 unpack-file) : plumbing;;
432 unpack-objects) : plumbing;;
433 update-index) : plumbing;;
434 update-ref) : plumbing;;
435 update-server-info) : daemon;;
436 upload-archive) : plumbing;;
437 upload-pack) : plumbing;;
438 write-tree) : plumbing;;
440 verify-pack) : infrequent;;
441 verify-tag) : plumbing;;
446 __git_porcelain_commandlist=
447 __git_porcelain_commandlist="$(__git_porcelain_commands 2>/dev/null)"
452 for i in $(git --git-dir="$(__gitdir)" config --list); do
462 __git_aliased_command ()
464 local word cmdline=$(git --git-dir="$(__gitdir)" \
465 config --get "alias.$1")
466 for word in $cmdline; do
467 if [ "${word##-*}" ]; then
474 __git_find_subcommand ()
476 local word subcommand c=1
478 while [ $c -lt $COMP_CWORD ]; do
479 word="${COMP_WORDS[c]}"
480 for subcommand in $1; do
481 if [ "$subcommand" = "$word" ]; then
490 __git_has_doubledash ()
493 while [ $c -lt $COMP_CWORD ]; do
494 if [ "--" = "${COMP_WORDS[c]}" ]; then
502 __git_whitespacelist="nowarn warn error error-all fix"
506 local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)"
507 if [ -d "$dir"/rebase-apply ]; then
508 __gitcomp "--skip --resolved --abort"
513 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
518 --signoff --utf8 --binary --3way --interactive
528 local cur="${COMP_WORDS[COMP_CWORD]}"
531 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
536 --stat --numstat --summary --check --index
537 --cached --index-info --reverse --reject --unidiff-zero
538 --apply --no-add --exclude=
539 --whitespace= --inaccurate-eof --verbose
548 __git_has_doubledash && return
550 local cur="${COMP_WORDS[COMP_CWORD]}"
554 --interactive --refresh --patch --update --dry-run
564 local cur="${COMP_WORDS[COMP_CWORD]}"
567 __gitcomp "$(git archive --list)" "" "${cur##--format=}"
571 __gitcomp "$(__git_remotes)" "" "${cur##--remote=}"
576 --format= --list --verbose
577 --prefix= --remote= --exec=
587 __git_has_doubledash && return
589 local subcommands="start bad good skip reset visualize replay log run"
590 local subcommand="$(__git_find_subcommand "$subcommands")"
591 if [ -z "$subcommand" ]; then
592 __gitcomp "$subcommands"
596 case "$subcommand" in
598 __gitcomp "$(__git_refs)"
608 local i c=1 only_local_ref="n" has_r="n"
610 while [ $c -lt $COMP_CWORD ]; do
613 -d|-m) only_local_ref="y" ;;
619 case "${COMP_WORDS[COMP_CWORD]}" in
620 --*=*) COMPREPLY=() ;;
623 --color --no-color --verbose --abbrev= --no-abbrev
624 --track --no-track --contains --merged --no-merged
628 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
629 __gitcomp "$(__git_heads)"
631 __gitcomp "$(__git_refs)"
639 local mycword="$COMP_CWORD"
640 case "${COMP_WORDS[0]}" in
642 local cmd="${COMP_WORDS[2]}"
643 mycword="$((mycword-1))"
646 local cmd="${COMP_WORDS[1]}"
651 __gitcomp "create list-heads verify unbundle"
659 __git_complete_revlist
668 __git_has_doubledash && return
670 __gitcomp "$(__git_refs)"
675 __gitcomp "$(__git_refs)"
680 local cur="${COMP_WORDS[COMP_CWORD]}"
683 __gitcomp "--edit --no-commit"
686 __gitcomp "$(__git_refs)"
693 __git_has_doubledash && return
695 local cur="${COMP_WORDS[COMP_CWORD]}"
698 __gitcomp "--dry-run --quiet"
707 local cur="${COMP_WORDS[COMP_CWORD]}"
732 __git_has_doubledash && return
734 local cur="${COMP_WORDS[COMP_CWORD]}"
738 --all --author= --signoff --verify --no-verify
739 --edit --amend --include --only --interactive
748 local cur="${COMP_WORDS[COMP_CWORD]}"
752 --all --tags --contains --abbrev= --candidates=
753 --exact-match --debug --long --match --always
757 __gitcomp "$(__git_refs)"
762 __git_has_doubledash && return
764 local cur="${COMP_WORDS[COMP_CWORD]}"
767 __gitcomp "--cached --stat --numstat --shortstat --summary
768 --patch-with-stat --name-only --name-status --color
769 --no-color --color-words --no-renames --check
770 --full-index --binary --abbrev --diff-filter=
771 --find-copies-harder --pickaxe-all --pickaxe-regex
772 --text --ignore-space-at-eol --ignore-space-change
773 --ignore-all-space --exit-code --quiet --ext-diff
775 --no-prefix --src-prefix= --dst-prefix=
776 --base --ours --theirs
786 local cur="${COMP_WORDS[COMP_CWORD]}"
788 if [ "$COMP_CWORD" = 2 ]; then
789 __gitcomp "$(__git_remotes)"
794 case "$COMP_WORDBREAKS" in
796 *) pfx="${cur%%:*}:" ;;
798 __gitcomp "$(__git_refs)" "$pfx" "${cur#*:}"
802 case "${COMP_WORDS[0]}" in
803 git-fetch) remote="${COMP_WORDS[1]}" ;;
804 git) remote="${COMP_WORDS[2]}" ;;
806 __gitcomp "$(__git_refs2 "$remote")"
814 local cur="${COMP_WORDS[COMP_CWORD]}"
818 --stdout --attach --thread
820 --numbered --start-number
825 --full-index --binary
828 --no-prefix --src-prefix= --dst-prefix=
833 __git_complete_revlist
838 local cur="${COMP_WORDS[COMP_CWORD]}"
841 __gitcomp "--prune --aggressive"
850 __git_has_doubledash && return
852 local cur="${COMP_WORDS[COMP_CWORD]}"
857 --text --ignore-case --word-regexp --invert-match
859 --extended-regexp --basic-regexp --fixed-strings
860 --files-with-matches --name-only
861 --files-without-match
863 --and --or --not --all-match
873 local cur="${COMP_WORDS[COMP_CWORD]}"
876 __gitcomp "--all --info --man --web"
880 __gitcomp "$(__git_all_commands)
881 attributes cli core-tutorial cvs-migration
882 diffcore gitk glossary hooks ignore modules
883 repository-layout tutorial tutorial-2
889 local cur="${COMP_WORDS[COMP_CWORD]}"
893 false true umask group all world everybody
894 " "" "${cur##--shared=}"
898 __gitcomp "--quiet --bare --template= --shared --shared="
907 __git_has_doubledash && return
909 local cur="${COMP_WORDS[COMP_CWORD]}"
912 __gitcomp "--cached --deleted --modified --others --ignored
913 --stage --directory --no-empty-directory --unmerged
914 --killed --exclude= --exclude-from=
915 --exclude-per-directory= --exclude-standard
916 --error-unmatch --with-tree= --full-name
917 --abbrev --ignored --exclude-per-directory
927 __gitcomp "$(__git_remotes)"
937 __git_has_doubledash && return
939 local cur="${COMP_WORDS[COMP_CWORD]}"
943 oneline short medium full fuller email raw
944 " "" "${cur##--pretty=}"
949 relative iso8601 rfc2822 short local default
950 " "" "${cur##--date=}"
955 --max-count= --max-age= --since= --after=
956 --min-age= --before= --until=
957 --root --topo-order --date-order --reverse
959 --abbrev-commit --abbrev=
960 --relative-date --date=
961 --author= --committer= --grep=
963 --pretty= --name-status --name-only --raw
965 --left-right --cherry-pick
967 --stat --numstat --shortstat
968 --decorate --diff-filter=
969 --color-words --walk-reflogs
970 --parents --children --full-history
976 __git_complete_revlist
981 local cur="${COMP_WORDS[COMP_CWORD]}"
982 case "${COMP_WORDS[COMP_CWORD-1]}" in
984 __gitcomp "$(__git_merge_strategies)"
989 __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}"
994 --no-commit --no-stat --log --no-log --squash --strategy
998 __gitcomp "$(__git_refs)"
1003 local cur="${COMP_WORDS[COMP_CWORD]}"
1007 kdiff3 tkdiff meld xxdiff emerge
1008 vimdiff gvimdiff ecmerge opendiff
1009 " "" "${cur##--tool=}"
1022 __gitcomp "$(__git_refs)"
1027 local cur="${COMP_WORDS[COMP_CWORD]}"
1030 __gitcomp "--dry-run"
1039 __gitcomp "--tags --all --stdin"
1044 local cur="${COMP_WORDS[COMP_CWORD]}"
1046 if [ "$COMP_CWORD" = 2 ]; then
1047 __gitcomp "$(__git_remotes)"
1050 case "${COMP_WORDS[0]}" in
1051 git-pull) remote="${COMP_WORDS[1]}" ;;
1052 git) remote="${COMP_WORDS[2]}" ;;
1054 __gitcomp "$(__git_refs "$remote")"
1060 local cur="${COMP_WORDS[COMP_CWORD]}"
1062 if [ "$COMP_CWORD" = 2 ]; then
1063 __gitcomp "$(__git_remotes)"
1068 case "${COMP_WORDS[0]}" in
1069 git-push) remote="${COMP_WORDS[1]}" ;;
1070 git) remote="${COMP_WORDS[2]}" ;;
1074 case "$COMP_WORDBREAKS" in
1076 *) pfx="${cur%%:*}:" ;;
1079 __gitcomp "$(__git_refs "$remote")" "$pfx" "${cur#*:}"
1082 __gitcomp "$(__git_refs)" + "${cur#+}"
1085 __gitcomp "$(__git_refs)"
1093 local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)"
1094 if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
1095 __gitcomp "--continue --skip --abort"
1098 case "${COMP_WORDS[COMP_CWORD-1]}" in
1100 __gitcomp "$(__git_merge_strategies)"
1105 __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}"
1109 __gitcomp "--onto --merge --strategy --interactive"
1112 __gitcomp "$(__git_refs)"
1117 local cur="${COMP_WORDS[COMP_CWORD]}"
1120 __gitcomp "--bcc --cc --cc-cmd --chain-reply-to --compose
1121 --dry-run --envelope-sender --from --identity
1122 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
1123 --no-suppress-from --no-thread --quiet
1124 --signed-off-by-cc --smtp-pass --smtp-server
1125 --smtp-server-port --smtp-ssl --smtp-user --subject
1126 --suppress-cc --suppress-from --thread --to"
1135 local cur="${COMP_WORDS[COMP_CWORD]}"
1136 local prv="${COMP_WORDS[COMP_CWORD-1]}"
1139 __gitcomp "$(__git_remotes)"
1143 __gitcomp "$(__git_refs)"
1147 local remote="${prv#remote.}"
1148 remote="${remote%.fetch}"
1149 __gitcomp "$(__git_refs_remotes "$remote")"
1153 local remote="${prv#remote.}"
1154 remote="${remote%.push}"
1155 __gitcomp "$(git --git-dir="$(__gitdir)" \
1156 for-each-ref --format='%(refname):%(refname)' \
1160 pull.twohead|pull.octopus)
1161 __gitcomp "$(__git_merge_strategies)"
1164 color.branch|color.diff|color.status)
1165 __gitcomp "always never auto"
1170 black red green yellow blue magenta cyan white
1171 bold dim ul blink reverse
1183 --global --system --file=
1184 --list --replace-all
1185 --get --get-all --get-regexp
1186 --add --unset --unset-all
1187 --remove-section --rename-section
1192 local pfx="${cur%.*}."
1194 __gitcomp "remote merge" "$pfx" "$cur"
1198 local pfx="${cur%.*}."
1200 __gitcomp "$(__git_heads)" "$pfx" "$cur" "."
1204 local pfx="${cur%.*}."
1207 url fetch push skipDefaultUpdate
1208 receivepack uploadpack tagopt
1213 local pfx="${cur%.*}."
1215 __gitcomp "$(__git_remotes)" "$pfx" "$cur" "."
1224 core.preferSymlinkRefs
1225 core.logAllRefUpdates
1226 core.loosecompression
1227 core.repositoryFormatVersion
1228 core.sharedRepository
1229 core.warnAmbiguousRefs
1231 core.packedGitWindowSize
1235 color.branch.current
1246 color.diff.whitespace
1251 color.status.changed
1252 color.status.untracked
1257 format.subjectprefix
1261 gitcvs.dbname gitcvs.dbdriver gitcvs.dbuser gitcvs.dbpass
1262 gitcvs.dbtablenameprefix
1265 gc.reflogexpireunreachable
1278 i18n.logOutputEncoding
1288 pack.deltaCacheLimit
1291 repack.useDeltaBaseOffset
1294 transfer.unpackLimit
1296 receive.denyNonFastForwards
1306 local subcommands="add rm show prune update"
1307 local subcommand="$(__git_find_subcommand "$subcommands")"
1308 if [ -z "$subcommand" ]; then
1309 __gitcomp "$subcommands"
1313 case "$subcommand" in
1315 __gitcomp "$(__git_remotes)"
1318 local i c='' IFS=$'\n'
1319 for i in $(git --git-dir="$(__gitdir)" config --list); do
1337 __git_has_doubledash && return
1339 local cur="${COMP_WORDS[COMP_CWORD]}"
1342 __gitcomp "--mixed --hard --soft"
1346 __gitcomp "$(__git_refs)"
1351 local cur="${COMP_WORDS[COMP_CWORD]}"
1354 __gitcomp "--edit --mainline --no-edit --no-commit --signoff"
1363 __git_has_doubledash && return
1365 local cur="${COMP_WORDS[COMP_CWORD]}"
1368 __gitcomp "--cached --dry-run --ignore-unmatch --quiet"
1377 __git_has_doubledash && return
1379 local cur="${COMP_WORDS[COMP_CWORD]}"
1383 --max-count= --max-age= --since= --after=
1384 --min-age= --before= --until=
1386 --author= --committer= --grep=
1389 --numbered --summary
1394 __git_complete_revlist
1399 local cur="${COMP_WORDS[COMP_CWORD]}"
1403 oneline short medium full fuller email raw
1404 " "" "${cur##--pretty=}"
1408 __gitcomp "--pretty="
1417 local cur="${COMP_WORDS[COMP_CWORD]}"
1421 --all --remotes --topo-order --current --more=
1422 --list --independent --merge-base --no-name
1423 --sha1-name --topics --reflog
1428 __git_complete_revlist
1433 local subcommands='save list show apply clear drop pop create branch'
1434 local subcommand="$(__git_find_subcommand "$subcommands")"
1435 if [ -z "$subcommand" ]; then
1436 __gitcomp "$subcommands"
1438 local cur="${COMP_WORDS[COMP_CWORD]}"
1439 case "$subcommand,$cur" in
1441 __gitcomp "--keep-index"
1446 show,--*|drop,--*|pop,--*|branch,--*)
1449 show,*|apply,*|drop,*|pop,*|branch,*)
1450 __gitcomp "$(git --git-dir="$(__gitdir)" stash list \
1451 | sed -n -e 's/:.*//p')"
1462 __git_has_doubledash && return
1464 local subcommands="add status init update summary foreach sync"
1465 if [ -z "$(__git_find_subcommand "$subcommands")" ]; then
1466 local cur="${COMP_WORDS[COMP_CWORD]}"
1469 __gitcomp "--quiet --cached"
1472 __gitcomp "$subcommands"
1482 init fetch clone rebase dcommit log find-rev
1483 set-tree commit-diff info create-ignore propget
1484 proplist show-ignore show-externals
1486 local subcommand="$(__git_find_subcommand "$subcommands")"
1487 if [ -z "$subcommand" ]; then
1488 __gitcomp "$subcommands"
1490 local remote_opts="--username= --config-dir= --no-auth-cache"
1492 --follow-parent --authors-file= --repack=
1493 --no-metadata --use-svm-props --use-svnsync-props
1494 --log-window-size= --no-checkout --quiet
1495 --repack-flags --user-log-author $remote_opts
1498 --template= --shared= --trunk= --tags=
1499 --branches= --stdlayout --minimize-url
1500 --no-metadata --use-svm-props --use-svnsync-props
1501 --rewrite-root= $remote_opts
1504 --edit --rmdir --find-copies-harder --copy-similarity=
1507 local cur="${COMP_WORDS[COMP_CWORD]}"
1508 case "$subcommand,$cur" in
1510 __gitcomp "--revision= --fetch-all $fc_opts"
1513 __gitcomp "--revision= $fc_opts $init_opts"
1516 __gitcomp "$init_opts"
1520 --merge --strategy= --verbose --dry-run
1521 --fetch-all --no-rebase $cmt_opts $fc_opts
1525 __gitcomp "--stdin $cmt_opts $fc_opts"
1527 create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\
1529 __gitcomp "--revision="
1533 --limit= --revision= --verbose --incremental
1534 --oneline --show-commit --non-recursive
1540 --merge --verbose --strategy= --local
1541 --fetch-all $fc_opts
1545 __gitcomp "--message= --file= --revision= $cmt_opts"
1560 while [ $c -lt $COMP_CWORD ]; do
1561 i="${COMP_WORDS[c]}"
1564 __gitcomp "$(__git_tags)"
1574 case "${COMP_WORDS[COMP_CWORD-1]}" in
1580 __gitcomp "$(__git_tags)"
1586 __gitcomp "$(__git_refs)"
1593 local i c=1 command __git_dir
1595 while [ $c -lt $COMP_CWORD ]; do
1596 i="${COMP_WORDS[c]}"
1598 --git-dir=*) __git_dir="${i#--git-dir=}" ;;
1599 --bare) __git_dir="." ;;
1600 --version|-p|--paginate) ;;
1601 --help) command="help"; break ;;
1602 *) command="$i"; break ;;
1607 if [ -z "$command" ]; then
1608 case "${COMP_WORDS[COMP_CWORD]}" in
1609 --*=*) COMPREPLY=() ;;
1621 *) __gitcomp "$(__git_porcelain_commands) $(__git_aliases)" ;;
1626 local expansion=$(__git_aliased_command "$command")
1627 [ "$expansion" ] && command="$expansion"
1632 apply) _git_apply ;;
1633 archive) _git_archive ;;
1634 bisect) _git_bisect ;;
1635 bundle) _git_bundle ;;
1636 branch) _git_branch ;;
1637 checkout) _git_checkout ;;
1638 cherry) _git_cherry ;;
1639 cherry-pick) _git_cherry_pick ;;
1640 clean) _git_clean ;;
1641 clone) _git_clone ;;
1642 commit) _git_commit ;;
1643 config) _git_config ;;
1644 describe) _git_describe ;;
1646 fetch) _git_fetch ;;
1647 format-patch) _git_format_patch ;;
1653 ls-files) _git_ls_files ;;
1654 ls-remote) _git_ls_remote ;;
1655 ls-tree) _git_ls_tree ;;
1657 mergetool) _git_mergetool;;
1658 merge-base) _git_merge_base ;;
1660 name-rev) _git_name_rev ;;
1663 rebase) _git_rebase ;;
1664 remote) _git_remote ;;
1665 reset) _git_reset ;;
1666 revert) _git_revert ;;
1668 send-email) _git_send_email ;;
1669 shortlog) _git_shortlog ;;
1671 show-branch) _git_show_branch ;;
1672 stash) _git_stash ;;
1673 submodule) _git_submodule ;;
1676 whatchanged) _git_log ;;
1683 __git_has_doubledash && return
1685 local cur="${COMP_WORDS[COMP_CWORD]}"
1686 local g="$(git rev-parse --git-dir 2>/dev/null)"
1688 if [ -f $g/MERGE_HEAD ]; then
1693 __gitcomp "--not --all $merge"
1697 __git_complete_revlist
1700 complete -o default -o nospace -F _git git
1701 complete -o default -o nospace -F _gitk gitk
1703 # The following are necessary only for Cygwin, and only are needed
1704 # when the user has tab-completed the executable name and consequently
1705 # included the '.exe' suffix.
1707 if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
1708 complete -o default -o nospace -F _git git.exe