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 case "${COMP_WORDS[0]},$COMP_CWORD" in
790 __gitcomp
"$(__git_remotes)"
793 __gitcomp
"$(__git_remotes)"
799 case "$COMP_WORDBREAKS" in
801 *) pfx
="${cur%%:*}:" ;;
803 __gitcomp
"$(__git_refs)" "$pfx" "${cur#*:}"
807 case "${COMP_WORDS[0]}" in
808 git-fetch
) remote
="${COMP_WORDS[1]}" ;;
809 git
) remote
="${COMP_WORDS[2]}" ;;
811 __gitcomp
"$(__git_refs2 "$remote")"
820 local cur
="${COMP_WORDS[COMP_CWORD]}"
824 --stdout --attach --thread
826 --numbered --start-number
831 --full-index --binary
834 --no-prefix --src-prefix= --dst-prefix=
839 __git_complete_revlist
844 local cur
="${COMP_WORDS[COMP_CWORD]}"
847 __gitcomp
"--prune --aggressive"
856 __git_has_doubledash
&& return
858 local cur
="${COMP_WORDS[COMP_CWORD]}"
863 --text --ignore-case --word-regexp --invert-match
865 --extended-regexp --basic-regexp --fixed-strings
866 --files-with-matches --name-only
867 --files-without-match
869 --and --or --not --all-match
879 local cur
="${COMP_WORDS[COMP_CWORD]}"
882 __gitcomp
"--all --info --man --web"
886 __gitcomp
"$(__git_all_commands)
887 attributes cli core-tutorial cvs-migration
888 diffcore gitk glossary hooks ignore modules
889 repository-layout tutorial tutorial-2
895 local cur
="${COMP_WORDS[COMP_CWORD]}"
899 false true umask group all world everybody
900 " "" "${cur##--shared=}"
904 __gitcomp
"--quiet --bare --template= --shared --shared="
913 __git_has_doubledash
&& return
915 local cur
="${COMP_WORDS[COMP_CWORD]}"
918 __gitcomp
"--cached --deleted --modified --others --ignored
919 --stage --directory --no-empty-directory --unmerged
920 --killed --exclude= --exclude-from=
921 --exclude-per-directory= --exclude-standard
922 --error-unmatch --with-tree= --full-name
923 --abbrev --ignored --exclude-per-directory
933 __gitcomp
"$(__git_remotes)"
943 __git_has_doubledash
&& return
945 local cur
="${COMP_WORDS[COMP_CWORD]}"
949 oneline short medium full fuller email raw
950 " "" "${cur##--pretty=}"
955 relative iso8601 rfc2822 short local default
956 " "" "${cur##--date=}"
961 --max-count= --max-age= --since= --after=
962 --min-age= --before= --until=
963 --root --topo-order --date-order --reverse
965 --abbrev-commit --abbrev=
966 --relative-date --date=
967 --author= --committer= --grep=
969 --pretty= --name-status --name-only --raw
971 --left-right --cherry-pick
973 --stat --numstat --shortstat
974 --decorate --diff-filter=
975 --color-words --walk-reflogs
976 --parents --children --full-history
982 __git_complete_revlist
987 local cur
="${COMP_WORDS[COMP_CWORD]}"
988 case "${COMP_WORDS[COMP_CWORD-1]}" in
990 __gitcomp
"$(__git_merge_strategies)"
995 __gitcomp
"$(__git_merge_strategies)" "" "${cur##--strategy=}"
1000 --no-commit --no-stat --log --no-log --squash --strategy
1004 __gitcomp
"$(__git_refs)"
1009 local cur
="${COMP_WORDS[COMP_CWORD]}"
1013 kdiff3 tkdiff meld xxdiff emerge
1014 vimdiff gvimdiff ecmerge opendiff
1015 " "" "${cur##--tool=}"
1028 __gitcomp
"$(__git_refs)"
1033 local cur
="${COMP_WORDS[COMP_CWORD]}"
1036 __gitcomp
"--dry-run"
1045 __gitcomp
"--tags --all --stdin"
1050 local cur
="${COMP_WORDS[COMP_CWORD]}"
1052 case "${COMP_WORDS[0]},$COMP_CWORD" in
1054 __gitcomp
"$(__git_remotes)"
1057 __gitcomp
"$(__git_remotes)"
1061 case "${COMP_WORDS[0]}" in
1062 git-pull
) remote
="${COMP_WORDS[1]}" ;;
1063 git
) remote
="${COMP_WORDS[2]}" ;;
1065 __gitcomp
"$(__git_refs "$remote")"
1072 local cur
="${COMP_WORDS[COMP_CWORD]}"
1074 case "${COMP_WORDS[0]},$COMP_CWORD" in
1076 __gitcomp
"$(__git_remotes)"
1079 __gitcomp
"$(__git_remotes)"
1085 case "${COMP_WORDS[0]}" in
1086 git-push
) remote
="${COMP_WORDS[1]}" ;;
1087 git
) remote
="${COMP_WORDS[2]}" ;;
1091 case "$COMP_WORDBREAKS" in
1093 *) pfx
="${cur%%:*}:" ;;
1096 __gitcomp
"$(__git_refs "$remote")" "$pfx" "${cur#*:}"
1099 __gitcomp
"$(__git_refs)" + "${cur#+}"
1102 __gitcomp
"$(__git_refs)"
1111 local cur
="${COMP_WORDS[COMP_CWORD]}" dir
="$(__gitdir)"
1112 if [ -d "$dir"/rebase-apply
] ||
[ -d "$dir"/rebase-merge
]; then
1113 __gitcomp
"--continue --skip --abort"
1116 case "${COMP_WORDS[COMP_CWORD-1]}" in
1118 __gitcomp
"$(__git_merge_strategies)"
1123 __gitcomp
"$(__git_merge_strategies)" "" "${cur##--strategy=}"
1127 __gitcomp
"--onto --merge --strategy --interactive"
1130 __gitcomp
"$(__git_refs)"
1135 local cur
="${COMP_WORDS[COMP_CWORD]}"
1138 __gitcomp
"--bcc --cc --cc-cmd --chain-reply-to --compose
1139 --dry-run --envelope-sender --from --identity
1140 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
1141 --no-suppress-from --no-thread --quiet
1142 --signed-off-by-cc --smtp-pass --smtp-server
1143 --smtp-server-port --smtp-ssl --smtp-user --subject
1144 --suppress-cc --suppress-from --thread --to
1145 --validate --no-validate"
1154 local cur
="${COMP_WORDS[COMP_CWORD]}"
1155 local prv
="${COMP_WORDS[COMP_CWORD-1]}"
1158 __gitcomp
"$(__git_remotes)"
1162 __gitcomp
"$(__git_refs)"
1166 local remote
="${prv#remote.}"
1167 remote
="${remote%.fetch}"
1168 __gitcomp
"$(__git_refs_remotes "$remote")"
1172 local remote
="${prv#remote.}"
1173 remote
="${remote%.push}"
1174 __gitcomp
"$(git --git-dir="$
(__gitdir
)" \
1175 for-each-ref --format='%(refname):%(refname)' \
1179 pull.twohead|pull.octopus
)
1180 __gitcomp
"$(__git_merge_strategies)"
1183 color.branch|color.
diff|color.status
)
1184 __gitcomp
"always never auto"
1189 black red green yellow blue magenta cyan white
1190 bold dim ul blink reverse
1202 --global --system --file=
1203 --list --replace-all
1204 --get --get-all --get-regexp
1205 --add --unset --unset-all
1206 --remove-section --rename-section
1211 local pfx
="${cur%.*}."
1213 __gitcomp
"remote merge" "$pfx" "$cur"
1217 local pfx
="${cur%.*}."
1219 __gitcomp
"$(__git_heads)" "$pfx" "$cur" "."
1223 local pfx
="${cur%.*}."
1226 url fetch push skipDefaultUpdate
1227 receivepack uploadpack tagopt
1232 local pfx
="${cur%.*}."
1234 __gitcomp
"$(__git_remotes)" "$pfx" "$cur" "."
1243 core.preferSymlinkRefs
1244 core.logAllRefUpdates
1245 core.loosecompression
1246 core.repositoryFormatVersion
1247 core.sharedRepository
1248 core.warnAmbiguousRefs
1250 core.packedGitWindowSize
1254 color.branch.current
1265 color.diff.whitespace
1270 color.status.changed
1271 color.status.untracked
1276 format.subjectprefix
1280 gitcvs.dbname gitcvs.dbdriver gitcvs.dbuser gitcvs.dbpass
1281 gitcvs.dbtablenameprefix
1284 gc.reflogexpireunreachable
1297 i18n.logOutputEncoding
1307 pack.deltaCacheLimit
1310 repack.useDeltaBaseOffset
1313 transfer.unpackLimit
1315 receive.denyNonFastForwards
1325 local subcommands
="add rm show prune update"
1326 local subcommand
="$(__git_find_subcommand "$subcommands")"
1327 if [ -z "$subcommand" ]; then
1328 __gitcomp
"$subcommands"
1332 case "$subcommand" in
1334 __gitcomp
"$(__git_remotes)"
1337 local i c
='' IFS
=$
'\n'
1338 for i
in $
(git
--git-dir="$(__gitdir)" config
--list); do
1356 __git_has_doubledash
&& return
1358 local cur
="${COMP_WORDS[COMP_CWORD]}"
1361 __gitcomp
"--mixed --hard --soft"
1365 __gitcomp
"$(__git_refs)"
1370 local cur
="${COMP_WORDS[COMP_CWORD]}"
1373 __gitcomp
"--edit --mainline --no-edit --no-commit --signoff"
1382 __git_has_doubledash
&& return
1384 local cur
="${COMP_WORDS[COMP_CWORD]}"
1387 __gitcomp
"--cached --dry-run --ignore-unmatch --quiet"
1396 __git_has_doubledash
&& return
1398 local cur
="${COMP_WORDS[COMP_CWORD]}"
1402 --max-count= --max-age= --since= --after=
1403 --min-age= --before= --until=
1405 --author= --committer= --grep=
1408 --numbered --summary
1413 __git_complete_revlist
1418 local cur
="${COMP_WORDS[COMP_CWORD]}"
1422 oneline short medium full fuller email raw
1423 " "" "${cur##--pretty=}"
1427 __gitcomp
"--pretty="
1436 local cur
="${COMP_WORDS[COMP_CWORD]}"
1440 --all --remotes --topo-order --current --more=
1441 --list --independent --merge-base --no-name
1442 --sha1-name --topics --reflog
1447 __git_complete_revlist
1452 local subcommands
='save list show apply clear drop pop create branch'
1453 local subcommand
="$(__git_find_subcommand "$subcommands")"
1454 if [ -z "$subcommand" ]; then
1455 __gitcomp
"$subcommands"
1457 local cur
="${COMP_WORDS[COMP_CWORD]}"
1458 case "$subcommand,$cur" in
1460 __gitcomp
"--keep-index"
1465 show
,--*|drop
,--*|pop
,--*|branch
,--*)
1468 show
,*|apply
,*|drop
,*|pop
,*|branch
,*)
1469 __gitcomp
"$(git --git-dir="$
(__gitdir
)" stash list \
1470 | sed -n -e 's/:.*//p')"
1481 __git_has_doubledash
&& return
1483 local subcommands
="add status init update summary foreach sync"
1484 if [ -z "$(__git_find_subcommand "$subcommands")" ]; then
1485 local cur
="${COMP_WORDS[COMP_CWORD]}"
1488 __gitcomp
"--quiet --cached"
1491 __gitcomp
"$subcommands"
1501 init fetch clone rebase dcommit log find-rev
1502 set-tree commit-diff info create-ignore propget
1503 proplist show-ignore show-externals
1505 local subcommand
="$(__git_find_subcommand "$subcommands")"
1506 if [ -z "$subcommand" ]; then
1507 __gitcomp
"$subcommands"
1509 local remote_opts
="--username= --config-dir= --no-auth-cache"
1511 --follow-parent --authors-file= --repack=
1512 --no-metadata --use-svm-props --use-svnsync-props
1513 --log-window-size= --no-checkout --quiet
1514 --repack-flags --user-log-author $remote_opts
1517 --template= --shared= --trunk= --tags=
1518 --branches= --stdlayout --minimize-url
1519 --no-metadata --use-svm-props --use-svnsync-props
1520 --rewrite-root= $remote_opts
1523 --edit --rmdir --find-copies-harder --copy-similarity=
1526 local cur
="${COMP_WORDS[COMP_CWORD]}"
1527 case "$subcommand,$cur" in
1529 __gitcomp
"--revision= --fetch-all $fc_opts"
1532 __gitcomp
"--revision= $fc_opts $init_opts"
1535 __gitcomp
"$init_opts"
1539 --merge --strategy= --verbose --dry-run
1540 --fetch-all --no-rebase $cmt_opts $fc_opts
1544 __gitcomp
"--stdin $cmt_opts $fc_opts"
1546 create-ignore
,--*|propget
,--*|proplist
,--*|show-ignore
,--*|\
1548 __gitcomp
"--revision="
1552 --limit= --revision= --verbose --incremental
1553 --oneline --show-commit --non-recursive
1559 --merge --verbose --strategy= --local
1560 --fetch-all $fc_opts
1564 __gitcomp
"--message= --file= --revision= $cmt_opts"
1579 while [ $c -lt $COMP_CWORD ]; do
1580 i
="${COMP_WORDS[c]}"
1583 __gitcomp
"$(__git_tags)"
1593 case "${COMP_WORDS[COMP_CWORD-1]}" in
1599 __gitcomp
"$(__git_tags)"
1605 __gitcomp
"$(__git_refs)"
1612 local i c
=1 command __git_dir
1614 while [ $c -lt $COMP_CWORD ]; do
1615 i
="${COMP_WORDS[c]}"
1617 --git-dir=*) __git_dir
="${i#--git-dir=}" ;;
1618 --bare) __git_dir
="." ;;
1619 --version|
-p|
--paginate) ;;
1620 --help) command="help"; break ;;
1621 *) command="$i"; break ;;
1626 if [ -z "$command" ]; then
1627 case "${COMP_WORDS[COMP_CWORD]}" in
1628 --*=*) COMPREPLY
=() ;;
1640 *) __gitcomp
"$(__git_porcelain_commands) $(__git_aliases)" ;;
1645 local expansion
=$
(__git_aliased_command
"$command")
1646 [ "$expansion" ] && command="$expansion"
1651 apply
) _git_apply
;;
1652 archive
) _git_archive
;;
1653 bisect
) _git_bisect
;;
1654 bundle
) _git_bundle
;;
1655 branch
) _git_branch
;;
1656 checkout
) _git_checkout
;;
1657 cherry
) _git_cherry
;;
1658 cherry-pick
) _git_cherry_pick
;;
1659 clean
) _git_clean
;;
1660 clone
) _git_clone
;;
1661 commit
) _git_commit
;;
1662 config
) _git_config
;;
1663 describe
) _git_describe
;;
1665 fetch
) _git_fetch
;;
1666 format-patch
) _git_format_patch
;;
1672 ls-files
) _git_ls_files
;;
1673 ls-remote
) _git_ls_remote
;;
1674 ls-tree
) _git_ls_tree
;;
1676 mergetool
) _git_mergetool
;;
1677 merge-base
) _git_merge_base
;;
1679 name-rev
) _git_name_rev
;;
1682 rebase
) _git_rebase
;;
1683 remote
) _git_remote
;;
1684 reset) _git_reset
;;
1685 revert
) _git_revert
;;
1687 send-email
) _git_send_email
;;
1688 shortlog
) _git_shortlog
;;
1690 show-branch
) _git_show_branch
;;
1691 stash
) _git_stash
;;
1692 submodule
) _git_submodule
;;
1695 whatchanged
) _git_log
;;
1702 __git_has_doubledash
&& return
1704 local cur
="${COMP_WORDS[COMP_CWORD]}"
1705 local g
="$(git rev-parse --git-dir 2>/dev/null)"
1707 if [ -f $g/MERGE_HEAD
]; then
1712 __gitcomp
"--not --all $merge"
1716 __git_complete_revlist
1719 complete
-o default
-o nospace
-F _git git
1720 complete
-o default
-o nospace
-F _gitk gitk
1722 # The following are necessary only for Cygwin, and only are needed
1723 # when the user has tab-completed the executable name and consequently
1724 # included the '.exe' suffix.
1726 if [ Cygwin
= "$(uname -o 2>/dev/null)" ]; then
1727 complete
-o default
-o nospace
-F _git git.exe