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
890 local cur="${COMP_WORDS[COMP_CWORD]}"
894 false true umask group all world everybody
895 " "" "${cur##--shared=}"
899 __gitcomp "--quiet --bare --template= --shared --shared="
908 __git_has_doubledash && return
910 local cur="${COMP_WORDS[COMP_CWORD]}"
913 __gitcomp "--cached --deleted --modified --others --ignored
914 --stage --directory --no-empty-directory --unmerged
915 --killed --exclude= --exclude-from=
916 --exclude-per-directory= --exclude-standard
917 --error-unmatch --with-tree= --full-name
918 --abbrev --ignored --exclude-per-directory
928 __gitcomp "$(__git_remotes)"
938 __git_has_doubledash && return
940 local cur="${COMP_WORDS[COMP_CWORD]}"
944 oneline short medium full fuller email raw
945 " "" "${cur##--pretty=}"
950 relative iso8601 rfc2822 short local default
951 " "" "${cur##--date=}"
956 --max-count= --max-age= --since= --after=
957 --min-age= --before= --until=
958 --root --topo-order --date-order --reverse
960 --abbrev-commit --abbrev=
961 --relative-date --date=
962 --author= --committer= --grep=
964 --pretty= --name-status --name-only --raw
966 --left-right --cherry-pick
968 --stat --numstat --shortstat
969 --decorate --diff-filter=
970 --color-words --walk-reflogs
971 --parents --children --full-history
977 __git_complete_revlist
982 local cur="${COMP_WORDS[COMP_CWORD]}"
983 case "${COMP_WORDS[COMP_CWORD-1]}" in
985 __gitcomp "$(__git_merge_strategies)"
990 __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}"
995 --no-commit --no-stat --log --no-log --squash --strategy
999 __gitcomp "$(__git_refs)"
1004 local cur="${COMP_WORDS[COMP_CWORD]}"
1008 kdiff3 tkdiff meld xxdiff emerge
1009 vimdiff gvimdiff ecmerge opendiff
1010 " "" "${cur##--tool=}"
1023 __gitcomp "$(__git_refs)"
1028 local cur="${COMP_WORDS[COMP_CWORD]}"
1031 __gitcomp "--dry-run"
1040 __gitcomp "--tags --all --stdin"
1045 local cur="${COMP_WORDS[COMP_CWORD]}"
1047 if [ "$COMP_CWORD" = 2 ]; then
1048 __gitcomp "$(__git_remotes)"
1051 case "${COMP_WORDS[0]}" in
1052 git-pull) remote="${COMP_WORDS[1]}" ;;
1053 git) remote="${COMP_WORDS[2]}" ;;
1055 __gitcomp "$(__git_refs "$remote")"
1061 local cur="${COMP_WORDS[COMP_CWORD]}"
1063 if [ "$COMP_CWORD" = 2 ]; then
1064 __gitcomp "$(__git_remotes)"
1069 case "${COMP_WORDS[0]}" in
1070 git-push) remote="${COMP_WORDS[1]}" ;;
1071 git) remote="${COMP_WORDS[2]}" ;;
1075 case "$COMP_WORDBREAKS" in
1077 *) pfx="${cur%%:*}:" ;;
1080 __gitcomp "$(__git_refs "$remote")" "$pfx" "${cur#*:}"
1083 __gitcomp "$(__git_refs)" + "${cur#+}"
1086 __gitcomp "$(__git_refs)"
1094 local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)"
1095 if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
1096 __gitcomp "--continue --skip --abort"
1099 case "${COMP_WORDS[COMP_CWORD-1]}" in
1101 __gitcomp "$(__git_merge_strategies)"
1106 __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}"
1110 __gitcomp "--onto --merge --strategy --interactive"
1113 __gitcomp "$(__git_refs)"
1118 local cur="${COMP_WORDS[COMP_CWORD]}"
1121 __gitcomp "--bcc --cc --cc-cmd --chain-reply-to --compose
1122 --dry-run --envelope-sender --from --identity
1123 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
1124 --no-suppress-from --no-thread --quiet
1125 --signed-off-by-cc --smtp-pass --smtp-server
1126 --smtp-server-port --smtp-ssl --smtp-user --subject
1127 --suppress-cc --suppress-from --thread --to
1128 --validate --no-validate"
1137 local cur="${COMP_WORDS[COMP_CWORD]}"
1138 local prv="${COMP_WORDS[COMP_CWORD-1]}"
1141 __gitcomp "$(__git_remotes)"
1145 __gitcomp "$(__git_refs)"
1149 local remote="${prv#remote.}"
1150 remote="${remote%.fetch}"
1151 __gitcomp "$(__git_refs_remotes "$remote")"
1155 local remote="${prv#remote.}"
1156 remote="${remote%.push}"
1157 __gitcomp "$(git --git-dir="$(__gitdir)" \
1158 for-each-ref --format='%(refname):%(refname)' \
1162 pull.twohead|pull.octopus)
1163 __gitcomp "$(__git_merge_strategies)"
1166 color.branch|color.diff|color.status)
1167 __gitcomp "always never auto"
1172 black red green yellow blue magenta cyan white
1173 bold dim ul blink reverse
1185 --global --system --file=
1186 --list --replace-all
1187 --get --get-all --get-regexp
1188 --add --unset --unset-all
1189 --remove-section --rename-section
1194 local pfx="${cur%.*}."
1196 __gitcomp "remote merge" "$pfx" "$cur"
1200 local pfx="${cur%.*}."
1202 __gitcomp "$(__git_heads)" "$pfx" "$cur" "."
1206 local pfx="${cur%.*}."
1209 url fetch push skipDefaultUpdate
1210 receivepack uploadpack tagopt
1215 local pfx="${cur%.*}."
1217 __gitcomp "$(__git_remotes)" "$pfx" "$cur" "."
1226 core.preferSymlinkRefs
1227 core.logAllRefUpdates
1228 core.loosecompression
1229 core.repositoryFormatVersion
1230 core.sharedRepository
1231 core.warnAmbiguousRefs
1233 core.packedGitWindowSize
1237 color.branch.current
1248 color.diff.whitespace
1253 color.status.changed
1254 color.status.untracked
1259 format.subjectprefix
1263 gitcvs.dbname gitcvs.dbdriver gitcvs.dbuser gitcvs.dbpass
1264 gitcvs.dbtablenameprefix
1267 gc.reflogexpireunreachable
1280 i18n.logOutputEncoding
1290 pack.deltaCacheLimit
1293 repack.useDeltaBaseOffset
1296 transfer.unpackLimit
1298 receive.denyNonFastForwards
1308 local subcommands="add rm show prune update"
1309 local subcommand="$(__git_find_subcommand "$subcommands")"
1310 if [ -z "$subcommand" ]; then
1311 __gitcomp "$subcommands"
1315 case "$subcommand" in
1317 __gitcomp "$(__git_remotes)"
1320 local i c='' IFS=$'\n'
1321 for i in $(git --git-dir="$(__gitdir)" config --list); do
1339 __git_has_doubledash && return
1341 local cur="${COMP_WORDS[COMP_CWORD]}"
1344 __gitcomp "--mixed --hard --soft"
1348 __gitcomp "$(__git_refs)"
1353 local cur="${COMP_WORDS[COMP_CWORD]}"
1356 __gitcomp "--edit --mainline --no-edit --no-commit --signoff"
1365 __git_has_doubledash && return
1367 local cur="${COMP_WORDS[COMP_CWORD]}"
1370 __gitcomp "--cached --dry-run --ignore-unmatch --quiet"
1379 __git_has_doubledash && return
1381 local cur="${COMP_WORDS[COMP_CWORD]}"
1385 --max-count= --max-age= --since= --after=
1386 --min-age= --before= --until=
1388 --author= --committer= --grep=
1391 --numbered --summary
1396 __git_complete_revlist
1401 local cur="${COMP_WORDS[COMP_CWORD]}"
1405 oneline short medium full fuller email raw
1406 " "" "${cur##--pretty=}"
1410 __gitcomp "--pretty="
1419 local cur="${COMP_WORDS[COMP_CWORD]}"
1423 --all --remotes --topo-order --current --more=
1424 --list --independent --merge-base --no-name
1425 --sha1-name --topics --reflog
1430 __git_complete_revlist
1435 local subcommands='save list show apply clear drop pop create branch'
1436 local subcommand="$(__git_find_subcommand "$subcommands")"
1437 if [ -z "$subcommand" ]; then
1438 __gitcomp "$subcommands"
1440 local cur="${COMP_WORDS[COMP_CWORD]}"
1441 case "$subcommand,$cur" in
1443 __gitcomp "--keep-index"
1448 show,--*|drop,--*|pop,--*|branch,--*)
1451 show,*|apply,*|drop,*|pop,*|branch,*)
1452 __gitcomp "$(git --git-dir="$(__gitdir)" stash list \
1453 | sed -n -e 's/:.*//p')"
1464 __git_has_doubledash && return
1466 local subcommands="add status init update summary foreach sync"
1467 if [ -z "$(__git_find_subcommand "$subcommands")" ]; then
1468 local cur="${COMP_WORDS[COMP_CWORD]}"
1471 __gitcomp "--quiet --cached"
1474 __gitcomp "$subcommands"
1484 init fetch clone rebase dcommit log find-rev
1485 set-tree commit-diff info create-ignore propget
1486 proplist show-ignore show-externals
1488 local subcommand="$(__git_find_subcommand "$subcommands")"
1489 if [ -z "$subcommand" ]; then
1490 __gitcomp "$subcommands"
1492 local remote_opts="--username= --config-dir= --no-auth-cache"
1494 --follow-parent --authors-file= --repack=
1495 --no-metadata --use-svm-props --use-svnsync-props
1496 --log-window-size= --no-checkout --quiet
1497 --repack-flags --user-log-author $remote_opts
1500 --template= --shared= --trunk= --tags=
1501 --branches= --stdlayout --minimize-url
1502 --no-metadata --use-svm-props --use-svnsync-props
1503 --rewrite-root= $remote_opts
1506 --edit --rmdir --find-copies-harder --copy-similarity=
1509 local cur="${COMP_WORDS[COMP_CWORD]}"
1510 case "$subcommand,$cur" in
1512 __gitcomp "--revision= --fetch-all $fc_opts"
1515 __gitcomp "--revision= $fc_opts $init_opts"
1518 __gitcomp "$init_opts"
1522 --merge --strategy= --verbose --dry-run
1523 --fetch-all --no-rebase $cmt_opts $fc_opts
1527 __gitcomp "--stdin $cmt_opts $fc_opts"
1529 create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\
1531 __gitcomp "--revision="
1535 --limit= --revision= --verbose --incremental
1536 --oneline --show-commit --non-recursive
1542 --merge --verbose --strategy= --local
1543 --fetch-all $fc_opts
1547 __gitcomp "--message= --file= --revision= $cmt_opts"
1562 while [ $c -lt $COMP_CWORD ]; do
1563 i="${COMP_WORDS[c]}"
1566 __gitcomp "$(__git_tags)"
1576 case "${COMP_WORDS[COMP_CWORD-1]}" in
1582 __gitcomp "$(__git_tags)"
1588 __gitcomp "$(__git_refs)"
1595 local i c=1 command __git_dir
1597 while [ $c -lt $COMP_CWORD ]; do
1598 i="${COMP_WORDS[c]}"
1600 --git-dir=*) __git_dir="${i#--git-dir=}" ;;
1601 --bare) __git_dir="." ;;
1602 --version|-p|--paginate) ;;
1603 --help) command="help"; break ;;
1604 *) command="$i"; break ;;
1609 if [ -z "$command" ]; then
1610 case "${COMP_WORDS[COMP_CWORD]}" in
1611 --*=*) COMPREPLY=() ;;
1623 *) __gitcomp "$(__git_porcelain_commands) $(__git_aliases)" ;;
1628 local expansion=$(__git_aliased_command "$command")
1629 [ "$expansion" ] && command="$expansion"
1634 apply) _git_apply ;;
1635 archive) _git_archive ;;
1636 bisect) _git_bisect ;;
1637 bundle) _git_bundle ;;
1638 branch) _git_branch ;;
1639 checkout) _git_checkout ;;
1640 cherry) _git_cherry ;;
1641 cherry-pick) _git_cherry_pick ;;
1642 clean) _git_clean ;;
1643 clone) _git_clone ;;
1644 commit) _git_commit ;;
1645 config) _git_config ;;
1646 describe) _git_describe ;;
1648 fetch) _git_fetch ;;
1649 format-patch) _git_format_patch ;;
1655 ls-files) _git_ls_files ;;
1656 ls-remote) _git_ls_remote ;;
1657 ls-tree) _git_ls_tree ;;
1659 mergetool) _git_mergetool;;
1660 merge-base) _git_merge_base ;;
1662 name-rev) _git_name_rev ;;
1665 rebase) _git_rebase ;;
1666 remote) _git_remote ;;
1667 reset) _git_reset ;;
1668 revert) _git_revert ;;
1670 send-email) _git_send_email ;;
1671 shortlog) _git_shortlog ;;
1673 show-branch) _git_show_branch ;;
1674 stash) _git_stash ;;
1675 submodule) _git_submodule ;;
1678 whatchanged) _git_log ;;
1685 __git_has_doubledash && return
1687 local cur="${COMP_WORDS[COMP_CWORD]}"
1688 local g="$(git rev-parse --git-dir 2>/dev/null)"
1690 if [ -f $g/MERGE_HEAD ]; then
1695 __gitcomp "--not --all $merge"
1699 __git_complete_revlist
1702 complete -o default -o nospace -F _git git
1703 complete -o default -o nospace -F _gitk gitk
1705 # The following are necessary only for Cygwin, and only are needed
1706 # when the user has tab-completed the executable name and consequently
1707 # included the '.exe' suffix.
1709 if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
1710 complete -o default -o nospace -F _git git.exe