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 i is_hash
=y dir
="$(__gitdir "$1")"
192 local cur
="${COMP_WORDS[COMP_CWORD]}" format refs
193 if [ -d "$dir" ]; then
200 if [ -e "$dir/HEAD" ]; then echo HEAD
; fi
201 format
="refname:short"
202 refs
="refs/tags refs/heads refs/remotes"
205 git
--git-dir="$dir" for-each-ref
--format="%($format)" \
209 for i
in $
(git ls-remote
"$dir" 2>/dev
/null
); do
210 case "$is_hash,$i" in
213 n
,refs
/tags
/*) is_hash
=y
; echo "${i#refs/tags/}" ;;
214 n
,refs
/heads
/*) is_hash
=y
; echo "${i#refs/heads/}" ;;
215 n
,refs
/remotes
/*) is_hash
=y
; echo "${i#refs/remotes/}" ;;
216 n
,*) is_hash
=y
; echo "$i" ;;
224 for i
in $
(__git_refs
"$1"); do
229 __git_refs_remotes
()
231 local cmd i is_hash
=y
232 for i
in $
(git ls-remote
"$1" 2>/dev
/null
); do
233 case "$is_hash,$i" in
236 echo "$i:refs/remotes/$1/${i#refs/heads/}"
240 n
,refs
/tags
/*) is_hash
=y
;;
248 local i ngoff IFS
=$
'\n' d
="$(__gitdir)"
249 shopt -q nullglob || ngoff
=1
251 for i
in "$d/remotes"/*; do
252 echo ${i#$d/remotes/}
254 [ "$ngoff" ] && shopt -u nullglob
255 for i
in $
(git
--git-dir="$d" config
--list); do
265 __git_merge_strategies
()
267 if [ -n "$__git_merge_strategylist" ]; then
268 echo "$__git_merge_strategylist"
271 git merge
-s help 2>&1 |
272 sed -n -e '/[Aa]vailable strategies are: /,/^$/{
280 __git_merge_strategylist
=
281 __git_merge_strategylist
=$
(__git_merge_strategies
2>/dev
/null
)
283 __git_complete_file
()
285 local pfx
ls ref cur
="${COMP_WORDS[COMP_CWORD]}"
302 case "$COMP_WORDBREAKS" in
304 *) pfx
="$ref:$pfx" ;;
308 COMPREPLY
=($
(compgen
-P "$pfx" \
309 -W "$(git --git-dir="$
(__gitdir
)" ls-tree "$ls" \
310 | sed '/^100... blob /{
326 __gitcomp
"$(__git_refs)"
331 __git_complete_revlist
()
333 local pfx cur
="${COMP_WORDS[COMP_CWORD]}"
338 __gitcomp
"$(__git_refs)" "$pfx" "$cur"
343 __gitcomp
"$(__git_refs)" "$pfx" "$cur"
346 __gitcomp
"$(__git_refs)"
351 __git_all_commands
()
353 if [ -n "$__git_all_commandlist" ]; then
354 echo "$__git_all_commandlist"
358 for i
in $
(git
help -a|
egrep '^ ')
361 *--*) : helper pattern
;;
366 __git_all_commandlist
=
367 __git_all_commandlist
="$(__git_all_commands 2>/dev/null)"
369 __git_porcelain_commands
()
371 if [ -n "$__git_porcelain_commandlist" ]; then
372 echo "$__git_porcelain_commandlist"
376 for i
in "help" $
(__git_all_commands
)
379 *--*) : helper pattern
;;
380 applymbox
) : ask gittus
;;
381 applypatch
) : ask gittus
;;
382 archimport
) : import
;;
383 cat-file
) : plumbing
;;
384 check-attr
) : plumbing
;;
385 check-ref-format
) : plumbing
;;
386 checkout-index
) : plumbing
;;
387 commit-tree
) : plumbing
;;
388 count-objects
) : infrequent
;;
389 cvsexportcommit
) : export;;
390 cvsimport
) : import
;;
391 cvsserver
) : daemon
;;
393 diff-files
) : plumbing
;;
394 diff-index
) : plumbing
;;
395 diff-tree
) : plumbing
;;
396 fast-import
) : import
;;
397 fast-export
) : export;;
398 fsck-objects
) : plumbing
;;
399 fetch-pack
) : plumbing
;;
400 fmt-merge-msg
) : plumbing
;;
401 for-each-ref
) : plumbing
;;
402 hash-object
) : plumbing
;;
403 http-
*) : transport
;;
404 index-pack
) : plumbing
;;
405 init-db
) : deprecated
;;
406 local-fetch
) : plumbing
;;
407 lost-found
) : infrequent
;;
408 ls-files
) : plumbing
;;
409 ls-remote
) : plumbing
;;
410 ls-tree
) : plumbing
;;
411 mailinfo
) : plumbing
;;
412 mailsplit
) : plumbing
;;
413 merge-
*) : plumbing
;;
416 pack-objects
) : plumbing
;;
417 pack-redundant
) : plumbing
;;
418 pack-refs
) : plumbing
;;
419 parse-remote
) : plumbing
;;
420 patch-id
) : plumbing
;;
421 peek-remote
) : plumbing
;;
423 prune-packed
) : plumbing
;;
424 quiltimport
) : import
;;
425 read-tree
) : plumbing
;;
426 receive-pack
) : plumbing
;;
428 repo-config
) : deprecated
;;
430 rev-list
) : plumbing
;;
431 rev-parse
) : plumbing
;;
432 runstatus
) : plumbing
;;
433 sh-setup
) : internal
;;
435 show-ref
) : plumbing
;;
436 send-pack
) : plumbing
;;
437 show-index
) : plumbing
;;
439 stripspace
) : plumbing
;;
440 symbolic-ref
) : plumbing
;;
441 tar-tree
) : deprecated
;;
442 unpack-file
) : plumbing
;;
443 unpack-objects
) : plumbing
;;
444 update-index
) : plumbing
;;
445 update-ref
) : plumbing
;;
446 update-server-info
) : daemon
;;
447 upload-archive
) : plumbing
;;
448 upload-pack
) : plumbing
;;
449 write-tree
) : plumbing
;;
451 verify-pack
) : infrequent
;;
452 verify-tag
) : plumbing
;;
457 __git_porcelain_commandlist
=
458 __git_porcelain_commandlist
="$(__git_porcelain_commands 2>/dev/null)"
463 for i
in $
(git
--git-dir="$(__gitdir)" config
--list); do
473 __git_aliased_command
()
475 local word cmdline
=$
(git
--git-dir="$(__gitdir)" \
476 config
--get "alias.$1")
477 for word
in $cmdline; do
478 if [ "${word##-*}" ]; then
485 __git_find_subcommand
()
487 local word subcommand c
=1
489 while [ $c -lt $COMP_CWORD ]; do
490 word
="${COMP_WORDS[c]}"
491 for subcommand
in $1; do
492 if [ "$subcommand" = "$word" ]; then
501 __git_has_doubledash
()
504 while [ $c -lt $COMP_CWORD ]; do
505 if [ "--" = "${COMP_WORDS[c]}" ]; then
513 __git_whitespacelist
="nowarn warn error error-all fix"
517 local cur
="${COMP_WORDS[COMP_CWORD]}" dir
="$(__gitdir)"
518 if [ -d "$dir"/rebase-apply
]; then
519 __gitcomp
"--skip --resolved --abort"
524 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
529 --signoff --utf8 --binary --3way --interactive
539 local cur
="${COMP_WORDS[COMP_CWORD]}"
542 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
547 --stat --numstat --summary --check --index
548 --cached --index-info --reverse --reject --unidiff-zero
549 --apply --no-add --exclude=
550 --whitespace= --inaccurate-eof --verbose
559 __git_has_doubledash
&& return
561 local cur
="${COMP_WORDS[COMP_CWORD]}"
565 --interactive --refresh --patch --update --dry-run
575 local cur
="${COMP_WORDS[COMP_CWORD]}"
578 __gitcomp
"$(git archive --list)" "" "${cur##--format=}"
582 __gitcomp
"$(__git_remotes)" "" "${cur##--remote=}"
587 --format= --list --verbose
588 --prefix= --remote= --exec=
598 __git_has_doubledash
&& return
600 local subcommands
="start bad good skip reset visualize replay log run"
601 local subcommand
="$(__git_find_subcommand "$subcommands")"
602 if [ -z "$subcommand" ]; then
603 __gitcomp
"$subcommands"
607 case "$subcommand" in
609 __gitcomp
"$(__git_refs)"
619 local i c
=1 only_local_ref
="n" has_r
="n"
621 while [ $c -lt $COMP_CWORD ]; do
624 -d|
-m) only_local_ref
="y" ;;
630 case "${COMP_WORDS[COMP_CWORD]}" in
631 --*=*) COMPREPLY
=() ;;
634 --color --no-color --verbose --abbrev= --no-abbrev
635 --track --no-track --contains --merged --no-merged
639 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
640 __gitcomp
"$(__git_heads)"
642 __gitcomp
"$(__git_refs)"
650 local mycword
="$COMP_CWORD"
651 case "${COMP_WORDS[0]}" in
653 local cmd
="${COMP_WORDS[2]}"
654 mycword
="$((mycword-1))"
657 local cmd
="${COMP_WORDS[1]}"
662 __gitcomp
"create list-heads verify unbundle"
670 __git_complete_revlist
679 __git_has_doubledash
&& return
681 __gitcomp
"$(__git_refs)"
686 __gitcomp
"$(__git_refs)"
691 local cur
="${COMP_WORDS[COMP_CWORD]}"
694 __gitcomp
"--edit --no-commit"
697 __gitcomp
"$(__git_refs)"
704 __git_has_doubledash
&& return
706 local cur
="${COMP_WORDS[COMP_CWORD]}"
709 __gitcomp
"--dry-run --quiet"
718 local cur
="${COMP_WORDS[COMP_CWORD]}"
743 __git_has_doubledash
&& return
745 local cur
="${COMP_WORDS[COMP_CWORD]}"
749 --all --author= --signoff --verify --no-verify
750 --edit --amend --include --only --interactive
759 local cur
="${COMP_WORDS[COMP_CWORD]}"
763 --all --tags --contains --abbrev= --candidates=
764 --exact-match --debug --long --match --always
768 __gitcomp
"$(__git_refs)"
773 __git_has_doubledash
&& return
775 local cur
="${COMP_WORDS[COMP_CWORD]}"
778 __gitcomp
"--cached --stat --numstat --shortstat --summary
779 --patch-with-stat --name-only --name-status --color
780 --no-color --color-words --no-renames --check
781 --full-index --binary --abbrev --diff-filter=
782 --find-copies-harder --pickaxe-all --pickaxe-regex
783 --text --ignore-space-at-eol --ignore-space-change
784 --ignore-all-space --exit-code --quiet --ext-diff
786 --no-prefix --src-prefix= --dst-prefix=
787 --base --ours --theirs
797 local cur
="${COMP_WORDS[COMP_CWORD]}"
799 if [ "$COMP_CWORD" = 2 ]; then
800 __gitcomp
"$(__git_remotes)"
805 case "$COMP_WORDBREAKS" in
807 *) pfx
="${cur%%:*}:" ;;
809 __gitcomp
"$(__git_refs)" "$pfx" "${cur#*:}"
813 case "${COMP_WORDS[0]}" in
814 git-fetch
) remote
="${COMP_WORDS[1]}" ;;
815 git
) remote
="${COMP_WORDS[2]}" ;;
817 __gitcomp
"$(__git_refs2 "$remote")"
825 local cur
="${COMP_WORDS[COMP_CWORD]}"
829 --stdout --attach --thread
831 --numbered --start-number
836 --full-index --binary
839 --no-prefix --src-prefix= --dst-prefix=
844 __git_complete_revlist
849 local cur
="${COMP_WORDS[COMP_CWORD]}"
852 __gitcomp
"--prune --aggressive"
861 __git_has_doubledash
&& return
863 local cur
="${COMP_WORDS[COMP_CWORD]}"
868 --text --ignore-case --word-regexp --invert-match
870 --extended-regexp --basic-regexp --fixed-strings
871 --files-with-matches --name-only
872 --files-without-match
874 --and --or --not --all-match
884 local cur
="${COMP_WORDS[COMP_CWORD]}"
887 __gitcomp
"--all --info --man --web"
891 __gitcomp
"$(__git_all_commands)
892 attributes cli core-tutorial cvs-migration
893 diffcore gitk glossary hooks ignore modules
894 repository-layout tutorial tutorial-2
901 local cur
="${COMP_WORDS[COMP_CWORD]}"
905 false true umask group all world everybody
906 " "" "${cur##--shared=}"
910 __gitcomp
"--quiet --bare --template= --shared --shared="
919 __git_has_doubledash
&& return
921 local cur
="${COMP_WORDS[COMP_CWORD]}"
924 __gitcomp
"--cached --deleted --modified --others --ignored
925 --stage --directory --no-empty-directory --unmerged
926 --killed --exclude= --exclude-from=
927 --exclude-per-directory= --exclude-standard
928 --error-unmatch --with-tree= --full-name
929 --abbrev --ignored --exclude-per-directory
939 __gitcomp
"$(__git_remotes)"
949 __git_has_doubledash
&& return
951 local cur
="${COMP_WORDS[COMP_CWORD]}"
955 oneline short medium full fuller email raw
956 " "" "${cur##--pretty=}"
961 relative iso8601 rfc2822 short local default
962 " "" "${cur##--date=}"
967 --max-count= --max-age= --since= --after=
968 --min-age= --before= --until=
969 --root --topo-order --date-order --reverse
971 --abbrev-commit --abbrev=
972 --relative-date --date=
973 --author= --committer= --grep=
975 --pretty= --name-status --name-only --raw
977 --left-right --cherry-pick
979 --stat --numstat --shortstat
980 --decorate --diff-filter=
981 --color-words --walk-reflogs
982 --parents --children --full-history
988 __git_complete_revlist
993 local cur
="${COMP_WORDS[COMP_CWORD]}"
994 case "${COMP_WORDS[COMP_CWORD-1]}" in
996 __gitcomp
"$(__git_merge_strategies)"
1001 __gitcomp
"$(__git_merge_strategies)" "" "${cur##--strategy=}"
1006 --no-commit --no-stat --log --no-log --squash --strategy
1010 __gitcomp
"$(__git_refs)"
1015 local cur
="${COMP_WORDS[COMP_CWORD]}"
1019 kdiff3 tkdiff meld xxdiff emerge
1020 vimdiff gvimdiff ecmerge opendiff
1021 " "" "${cur##--tool=}"
1034 __gitcomp
"$(__git_refs)"
1039 local cur
="${COMP_WORDS[COMP_CWORD]}"
1042 __gitcomp
"--dry-run"
1051 __gitcomp
"--tags --all --stdin"
1056 local cur
="${COMP_WORDS[COMP_CWORD]}"
1058 if [ "$COMP_CWORD" = 2 ]; then
1059 __gitcomp
"$(__git_remotes)"
1062 case "${COMP_WORDS[0]}" in
1063 git-pull
) remote
="${COMP_WORDS[1]}" ;;
1064 git
) remote
="${COMP_WORDS[2]}" ;;
1066 __gitcomp
"$(__git_refs "$remote")"
1072 local cur
="${COMP_WORDS[COMP_CWORD]}"
1074 if [ "$COMP_CWORD" = 2 ]; then
1075 __gitcomp
"$(__git_remotes)"
1080 case "${COMP_WORDS[0]}" in
1081 git-push
) remote
="${COMP_WORDS[1]}" ;;
1082 git
) remote
="${COMP_WORDS[2]}" ;;
1086 case "$COMP_WORDBREAKS" in
1088 *) pfx
="${cur%%:*}:" ;;
1091 __gitcomp
"$(__git_refs "$remote")" "$pfx" "${cur#*:}"
1094 __gitcomp
"$(__git_refs)" + "${cur#+}"
1097 __gitcomp
"$(__git_refs)"
1105 local cur
="${COMP_WORDS[COMP_CWORD]}" dir
="$(__gitdir)"
1106 if [ -d "$dir"/rebase-apply
] ||
[ -d "$dir"/rebase-merge
]; then
1107 __gitcomp
"--continue --skip --abort"
1110 case "${COMP_WORDS[COMP_CWORD-1]}" in
1112 __gitcomp
"$(__git_merge_strategies)"
1117 __gitcomp
"$(__git_merge_strategies)" "" "${cur##--strategy=}"
1121 __gitcomp
"--onto --merge --strategy --interactive"
1124 __gitcomp
"$(__git_refs)"
1129 local cur
="${COMP_WORDS[COMP_CWORD]}"
1132 __gitcomp
"--bcc --cc --cc-cmd --chain-reply-to --compose
1133 --dry-run --envelope-sender --from --identity
1134 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
1135 --no-suppress-from --no-thread --quiet
1136 --signed-off-by-cc --smtp-pass --smtp-server
1137 --smtp-server-port --smtp-ssl --smtp-user --subject
1138 --suppress-cc --suppress-from --thread --to
1139 --validate --no-validate"
1148 local cur
="${COMP_WORDS[COMP_CWORD]}"
1149 local prv
="${COMP_WORDS[COMP_CWORD-1]}"
1152 __gitcomp
"$(__git_remotes)"
1156 __gitcomp
"$(__git_refs)"
1160 local remote
="${prv#remote.}"
1161 remote
="${remote%.fetch}"
1162 __gitcomp
"$(__git_refs_remotes "$remote")"
1166 local remote
="${prv#remote.}"
1167 remote
="${remote%.push}"
1168 __gitcomp
"$(git --git-dir="$
(__gitdir
)" \
1169 for-each-ref --format='%(refname):%(refname)' \
1173 pull.twohead|pull.octopus
)
1174 __gitcomp
"$(__git_merge_strategies)"
1177 color.branch|color.
diff|color.status
)
1178 __gitcomp
"always never auto"
1183 black red green yellow blue magenta cyan white
1184 bold dim ul blink reverse
1196 --global --system --file=
1197 --list --replace-all
1198 --get --get-all --get-regexp
1199 --add --unset --unset-all
1200 --remove-section --rename-section
1205 local pfx
="${cur%.*}."
1207 __gitcomp
"remote merge" "$pfx" "$cur"
1211 local pfx
="${cur%.*}."
1213 __gitcomp
"$(__git_heads)" "$pfx" "$cur" "."
1217 local pfx
="${cur%.*}."
1220 url fetch push skipDefaultUpdate
1221 receivepack uploadpack tagopt
1226 local pfx
="${cur%.*}."
1228 __gitcomp
"$(__git_remotes)" "$pfx" "$cur" "."
1237 core.preferSymlinkRefs
1238 core.logAllRefUpdates
1239 core.loosecompression
1240 core.repositoryFormatVersion
1241 core.sharedRepository
1242 core.warnAmbiguousRefs
1244 core.packedGitWindowSize
1248 color.branch.current
1259 color.diff.whitespace
1264 color.status.changed
1265 color.status.untracked
1270 format.subjectprefix
1274 gitcvs.dbname gitcvs.dbdriver gitcvs.dbuser gitcvs.dbpass
1275 gitcvs.dbtablenameprefix
1278 gc.reflogexpireunreachable
1291 i18n.logOutputEncoding
1301 pack.deltaCacheLimit
1304 repack.useDeltaBaseOffset
1307 transfer.unpackLimit
1309 receive.denyNonFastForwards
1319 local subcommands
="add rm show prune update"
1320 local subcommand
="$(__git_find_subcommand "$subcommands")"
1321 if [ -z "$subcommand" ]; then
1322 __gitcomp
"$subcommands"
1326 case "$subcommand" in
1328 __gitcomp
"$(__git_remotes)"
1331 local i c
='' IFS
=$
'\n'
1332 for i
in $
(git
--git-dir="$(__gitdir)" config
--list); do
1350 __git_has_doubledash
&& return
1352 local cur
="${COMP_WORDS[COMP_CWORD]}"
1355 __gitcomp
"--mixed --hard --soft"
1359 __gitcomp
"$(__git_refs)"
1364 local cur
="${COMP_WORDS[COMP_CWORD]}"
1367 __gitcomp
"--edit --mainline --no-edit --no-commit --signoff"
1376 __git_has_doubledash
&& return
1378 local cur
="${COMP_WORDS[COMP_CWORD]}"
1381 __gitcomp
"--cached --dry-run --ignore-unmatch --quiet"
1390 __git_has_doubledash
&& return
1392 local cur
="${COMP_WORDS[COMP_CWORD]}"
1396 --max-count= --max-age= --since= --after=
1397 --min-age= --before= --until=
1399 --author= --committer= --grep=
1402 --numbered --summary
1407 __git_complete_revlist
1412 __git_has_doubledash
&& return
1414 local cur
="${COMP_WORDS[COMP_CWORD]}"
1418 oneline short medium full fuller email raw
1419 " "" "${cur##--pretty=}"
1423 __gitcomp
"--pretty="
1432 local cur
="${COMP_WORDS[COMP_CWORD]}"
1436 --all --remotes --topo-order --current --more=
1437 --list --independent --merge-base --no-name
1438 --sha1-name --topics --reflog
1443 __git_complete_revlist
1448 local subcommands
='save list show apply clear drop pop create branch'
1449 local subcommand
="$(__git_find_subcommand "$subcommands")"
1450 if [ -z "$subcommand" ]; then
1451 __gitcomp
"$subcommands"
1453 local cur
="${COMP_WORDS[COMP_CWORD]}"
1454 case "$subcommand,$cur" in
1456 __gitcomp
"--keep-index"
1461 show
,--*|drop
,--*|pop
,--*|branch
,--*)
1464 show
,*|apply
,*|drop
,*|pop
,*|branch
,*)
1465 __gitcomp
"$(git --git-dir="$
(__gitdir
)" stash list \
1466 | sed -n -e 's/:.*//p')"
1477 __git_has_doubledash
&& return
1479 local subcommands
="add status init update summary foreach sync"
1480 if [ -z "$(__git_find_subcommand "$subcommands")" ]; then
1481 local cur
="${COMP_WORDS[COMP_CWORD]}"
1484 __gitcomp
"--quiet --cached"
1487 __gitcomp
"$subcommands"
1497 init fetch clone rebase dcommit log find-rev
1498 set-tree commit-diff info create-ignore propget
1499 proplist show-ignore show-externals
1501 local subcommand
="$(__git_find_subcommand "$subcommands")"
1502 if [ -z "$subcommand" ]; then
1503 __gitcomp
"$subcommands"
1505 local remote_opts
="--username= --config-dir= --no-auth-cache"
1507 --follow-parent --authors-file= --repack=
1508 --no-metadata --use-svm-props --use-svnsync-props
1509 --log-window-size= --no-checkout --quiet
1510 --repack-flags --user-log-author $remote_opts
1513 --template= --shared= --trunk= --tags=
1514 --branches= --stdlayout --minimize-url
1515 --no-metadata --use-svm-props --use-svnsync-props
1516 --rewrite-root= $remote_opts
1519 --edit --rmdir --find-copies-harder --copy-similarity=
1522 local cur
="${COMP_WORDS[COMP_CWORD]}"
1523 case "$subcommand,$cur" in
1525 __gitcomp
"--revision= --fetch-all $fc_opts"
1528 __gitcomp
"--revision= $fc_opts $init_opts"
1531 __gitcomp
"$init_opts"
1535 --merge --strategy= --verbose --dry-run
1536 --fetch-all --no-rebase $cmt_opts $fc_opts
1540 __gitcomp
"--stdin $cmt_opts $fc_opts"
1542 create-ignore
,--*|propget
,--*|proplist
,--*|show-ignore
,--*|\
1544 __gitcomp
"--revision="
1548 --limit= --revision= --verbose --incremental
1549 --oneline --show-commit --non-recursive
1555 --merge --verbose --strategy= --local
1556 --fetch-all $fc_opts
1560 __gitcomp
"--message= --file= --revision= $cmt_opts"
1575 while [ $c -lt $COMP_CWORD ]; do
1576 i
="${COMP_WORDS[c]}"
1579 __gitcomp
"$(__git_tags)"
1589 case "${COMP_WORDS[COMP_CWORD-1]}" in
1595 __gitcomp
"$(__git_tags)"
1601 __gitcomp
"$(__git_refs)"
1608 local i c
=1 command __git_dir
1610 while [ $c -lt $COMP_CWORD ]; do
1611 i
="${COMP_WORDS[c]}"
1613 --git-dir=*) __git_dir
="${i#--git-dir=}" ;;
1614 --bare) __git_dir
="." ;;
1615 --version|
-p|
--paginate) ;;
1616 --help) command="help"; break ;;
1617 *) command="$i"; break ;;
1622 if [ -z "$command" ]; then
1623 case "${COMP_WORDS[COMP_CWORD]}" in
1624 --*=*) COMPREPLY
=() ;;
1636 *) __gitcomp
"$(__git_porcelain_commands) $(__git_aliases)" ;;
1641 local expansion
=$
(__git_aliased_command
"$command")
1642 [ "$expansion" ] && command="$expansion"
1647 apply
) _git_apply
;;
1648 archive
) _git_archive
;;
1649 bisect
) _git_bisect
;;
1650 bundle
) _git_bundle
;;
1651 branch
) _git_branch
;;
1652 checkout
) _git_checkout
;;
1653 cherry
) _git_cherry
;;
1654 cherry-pick
) _git_cherry_pick
;;
1655 clean
) _git_clean
;;
1656 clone
) _git_clone
;;
1657 commit
) _git_commit
;;
1658 config
) _git_config
;;
1659 describe
) _git_describe
;;
1661 fetch
) _git_fetch
;;
1662 format-patch
) _git_format_patch
;;
1668 ls-files
) _git_ls_files
;;
1669 ls-remote
) _git_ls_remote
;;
1670 ls-tree
) _git_ls_tree
;;
1672 mergetool
) _git_mergetool
;;
1673 merge-base
) _git_merge_base
;;
1675 name-rev
) _git_name_rev
;;
1678 rebase
) _git_rebase
;;
1679 remote
) _git_remote
;;
1680 reset) _git_reset
;;
1681 revert
) _git_revert
;;
1683 send-email
) _git_send_email
;;
1684 shortlog
) _git_shortlog
;;
1686 show-branch
) _git_show_branch
;;
1687 stash
) _git_stash
;;
1688 submodule
) _git_submodule
;;
1691 whatchanged
) _git_log
;;
1698 __git_has_doubledash
&& return
1700 local cur
="${COMP_WORDS[COMP_CWORD]}"
1701 local g
="$(git rev-parse --git-dir 2>/dev/null)"
1703 if [ -f $g/MERGE_HEAD
]; then
1708 __gitcomp
"--not --all $merge"
1712 __git_complete_revlist
1715 complete
-o default
-o nospace
-F _git git
1716 complete
-o default
-o nospace
-F _gitk gitk
1718 # The following are necessary only for Cygwin, and only are needed
1719 # when the user has tab-completed the executable name and consequently
1720 # included the '.exe' suffix.
1722 if [ Cygwin
= "$(uname -o 2>/dev/null)" ]; then
1723 complete
-o default
-o nospace
-F _git git.exe