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
1127 --validate --no-validate"
1136 local cur
="${COMP_WORDS[COMP_CWORD]}"
1137 local prv
="${COMP_WORDS[COMP_CWORD-1]}"
1140 __gitcomp
"$(__git_remotes)"
1144 __gitcomp
"$(__git_refs)"
1148 local remote
="${prv#remote.}"
1149 remote
="${remote%.fetch}"
1150 __gitcomp
"$(__git_refs_remotes "$remote")"
1154 local remote
="${prv#remote.}"
1155 remote
="${remote%.push}"
1156 __gitcomp
"$(git --git-dir="$
(__gitdir
)" \
1157 for-each-ref --format='%(refname):%(refname)' \
1161 pull.twohead|pull.octopus
)
1162 __gitcomp
"$(__git_merge_strategies)"
1165 color.branch|color.
diff|color.status
)
1166 __gitcomp
"always never auto"
1171 black red green yellow blue magenta cyan white
1172 bold dim ul blink reverse
1184 --global --system --file=
1185 --list --replace-all
1186 --get --get-all --get-regexp
1187 --add --unset --unset-all
1188 --remove-section --rename-section
1193 local pfx
="${cur%.*}."
1195 __gitcomp
"remote merge" "$pfx" "$cur"
1199 local pfx
="${cur%.*}."
1201 __gitcomp
"$(__git_heads)" "$pfx" "$cur" "."
1205 local pfx
="${cur%.*}."
1208 url fetch push skipDefaultUpdate
1209 receivepack uploadpack tagopt
1214 local pfx
="${cur%.*}."
1216 __gitcomp
"$(__git_remotes)" "$pfx" "$cur" "."
1225 core.preferSymlinkRefs
1226 core.logAllRefUpdates
1227 core.loosecompression
1228 core.repositoryFormatVersion
1229 core.sharedRepository
1230 core.warnAmbiguousRefs
1232 core.packedGitWindowSize
1236 color.branch.current
1247 color.diff.whitespace
1252 color.status.changed
1253 color.status.untracked
1258 format.subjectprefix
1262 gitcvs.dbname gitcvs.dbdriver gitcvs.dbuser gitcvs.dbpass
1263 gitcvs.dbtablenameprefix
1266 gc.reflogexpireunreachable
1279 i18n.logOutputEncoding
1289 pack.deltaCacheLimit
1292 repack.useDeltaBaseOffset
1295 transfer.unpackLimit
1297 receive.denyNonFastForwards
1307 local subcommands
="add rm show prune update"
1308 local subcommand
="$(__git_find_subcommand "$subcommands")"
1309 if [ -z "$subcommand" ]; then
1310 __gitcomp
"$subcommands"
1314 case "$subcommand" in
1316 __gitcomp
"$(__git_remotes)"
1319 local i c
='' IFS
=$
'\n'
1320 for i
in $
(git
--git-dir="$(__gitdir)" config
--list); do
1338 __git_has_doubledash
&& return
1340 local cur
="${COMP_WORDS[COMP_CWORD]}"
1343 __gitcomp
"--mixed --hard --soft"
1347 __gitcomp
"$(__git_refs)"
1352 local cur
="${COMP_WORDS[COMP_CWORD]}"
1355 __gitcomp
"--edit --mainline --no-edit --no-commit --signoff"
1364 __git_has_doubledash
&& return
1366 local cur
="${COMP_WORDS[COMP_CWORD]}"
1369 __gitcomp
"--cached --dry-run --ignore-unmatch --quiet"
1378 __git_has_doubledash
&& return
1380 local cur
="${COMP_WORDS[COMP_CWORD]}"
1384 --max-count= --max-age= --since= --after=
1385 --min-age= --before= --until=
1387 --author= --committer= --grep=
1390 --numbered --summary
1395 __git_complete_revlist
1400 local cur
="${COMP_WORDS[COMP_CWORD]}"
1404 oneline short medium full fuller email raw
1405 " "" "${cur##--pretty=}"
1409 __gitcomp
"--pretty="
1418 local cur
="${COMP_WORDS[COMP_CWORD]}"
1422 --all --remotes --topo-order --current --more=
1423 --list --independent --merge-base --no-name
1424 --sha1-name --topics --reflog
1429 __git_complete_revlist
1434 local subcommands
='save list show apply clear drop pop create branch'
1435 local subcommand
="$(__git_find_subcommand "$subcommands")"
1436 if [ -z "$subcommand" ]; then
1437 __gitcomp
"$subcommands"
1439 local cur
="${COMP_WORDS[COMP_CWORD]}"
1440 case "$subcommand,$cur" in
1442 __gitcomp
"--keep-index"
1447 show
,--*|drop
,--*|pop
,--*|branch
,--*)
1450 show
,*|apply
,*|drop
,*|pop
,*|branch
,*)
1451 __gitcomp
"$(git --git-dir="$
(__gitdir
)" stash list \
1452 | sed -n -e 's/:.*//p')"
1463 __git_has_doubledash
&& return
1465 local subcommands
="add status init update summary foreach sync"
1466 if [ -z "$(__git_find_subcommand "$subcommands")" ]; then
1467 local cur
="${COMP_WORDS[COMP_CWORD]}"
1470 __gitcomp
"--quiet --cached"
1473 __gitcomp
"$subcommands"
1483 init fetch clone rebase dcommit log find-rev
1484 set-tree commit-diff info create-ignore propget
1485 proplist show-ignore show-externals
1487 local subcommand
="$(__git_find_subcommand "$subcommands")"
1488 if [ -z "$subcommand" ]; then
1489 __gitcomp
"$subcommands"
1491 local remote_opts
="--username= --config-dir= --no-auth-cache"
1493 --follow-parent --authors-file= --repack=
1494 --no-metadata --use-svm-props --use-svnsync-props
1495 --log-window-size= --no-checkout --quiet
1496 --repack-flags --user-log-author $remote_opts
1499 --template= --shared= --trunk= --tags=
1500 --branches= --stdlayout --minimize-url
1501 --no-metadata --use-svm-props --use-svnsync-props
1502 --rewrite-root= $remote_opts
1505 --edit --rmdir --find-copies-harder --copy-similarity=
1508 local cur
="${COMP_WORDS[COMP_CWORD]}"
1509 case "$subcommand,$cur" in
1511 __gitcomp
"--revision= --fetch-all $fc_opts"
1514 __gitcomp
"--revision= $fc_opts $init_opts"
1517 __gitcomp
"$init_opts"
1521 --merge --strategy= --verbose --dry-run
1522 --fetch-all --no-rebase $cmt_opts $fc_opts
1526 __gitcomp
"--stdin $cmt_opts $fc_opts"
1528 create-ignore
,--*|propget
,--*|proplist
,--*|show-ignore
,--*|\
1530 __gitcomp
"--revision="
1534 --limit= --revision= --verbose --incremental
1535 --oneline --show-commit --non-recursive
1541 --merge --verbose --strategy= --local
1542 --fetch-all $fc_opts
1546 __gitcomp
"--message= --file= --revision= $cmt_opts"
1561 while [ $c -lt $COMP_CWORD ]; do
1562 i
="${COMP_WORDS[c]}"
1565 __gitcomp
"$(__git_tags)"
1575 case "${COMP_WORDS[COMP_CWORD-1]}" in
1581 __gitcomp
"$(__git_tags)"
1587 __gitcomp
"$(__git_refs)"
1594 local i c
=1 command __git_dir
1596 while [ $c -lt $COMP_CWORD ]; do
1597 i
="${COMP_WORDS[c]}"
1599 --git-dir=*) __git_dir
="${i#--git-dir=}" ;;
1600 --bare) __git_dir
="." ;;
1601 --version|
-p|
--paginate) ;;
1602 --help) command="help"; break ;;
1603 *) command="$i"; break ;;
1608 if [ -z "$command" ]; then
1609 case "${COMP_WORDS[COMP_CWORD]}" in
1610 --*=*) COMPREPLY
=() ;;
1622 *) __gitcomp
"$(__git_porcelain_commands) $(__git_aliases)" ;;
1627 local expansion
=$
(__git_aliased_command
"$command")
1628 [ "$expansion" ] && command="$expansion"
1633 apply
) _git_apply
;;
1634 archive
) _git_archive
;;
1635 bisect
) _git_bisect
;;
1636 bundle
) _git_bundle
;;
1637 branch
) _git_branch
;;
1638 checkout
) _git_checkout
;;
1639 cherry
) _git_cherry
;;
1640 cherry-pick
) _git_cherry_pick
;;
1641 clean
) _git_clean
;;
1642 clone
) _git_clone
;;
1643 commit
) _git_commit
;;
1644 config
) _git_config
;;
1645 describe
) _git_describe
;;
1647 fetch
) _git_fetch
;;
1648 format-patch
) _git_format_patch
;;
1654 ls-files
) _git_ls_files
;;
1655 ls-remote
) _git_ls_remote
;;
1656 ls-tree
) _git_ls_tree
;;
1658 mergetool
) _git_mergetool
;;
1659 merge-base
) _git_merge_base
;;
1661 name-rev
) _git_name_rev
;;
1664 rebase
) _git_rebase
;;
1665 remote
) _git_remote
;;
1666 reset) _git_reset
;;
1667 revert
) _git_revert
;;
1669 send-email
) _git_send_email
;;
1670 shortlog
) _git_shortlog
;;
1672 show-branch
) _git_show_branch
;;
1673 stash
) _git_stash
;;
1674 submodule
) _git_submodule
;;
1677 whatchanged
) _git_log
;;
1684 __git_has_doubledash
&& return
1686 local cur
="${COMP_WORDS[COMP_CWORD]}"
1687 local g
="$(git rev-parse --git-dir 2>/dev/null)"
1689 if [ -f $g/MERGE_HEAD
]; then
1694 __gitcomp
"--not --all $merge"
1698 __git_complete_revlist
1701 complete
-o default
-o nospace
-F _git git
1702 complete
-o default
-o nospace
-F _gitk gitk
1704 # The following are necessary only for Cygwin, and only are needed
1705 # when the user has tab-completed the executable name and consequently
1706 # included the '.exe' suffix.
1708 if [ Cygwin
= "$(uname -o 2>/dev/null)" ]; then
1709 complete
-o default
-o nospace
-F _git git.exe