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"
1153 local cur
="${COMP_WORDS[COMP_CWORD]}"
1154 local prv
="${COMP_WORDS[COMP_CWORD-1]}"
1157 __gitcomp
"$(__git_remotes)"
1161 __gitcomp
"$(__git_refs)"
1165 local remote
="${prv#remote.}"
1166 remote
="${remote%.fetch}"
1167 __gitcomp
"$(__git_refs_remotes "$remote")"
1171 local remote
="${prv#remote.}"
1172 remote
="${remote%.push}"
1173 __gitcomp
"$(git --git-dir="$
(__gitdir
)" \
1174 for-each-ref --format='%(refname):%(refname)' \
1178 pull.twohead|pull.octopus
)
1179 __gitcomp
"$(__git_merge_strategies)"
1182 color.branch|color.
diff|color.status
)
1183 __gitcomp
"always never auto"
1188 black red green yellow blue magenta cyan white
1189 bold dim ul blink reverse
1201 --global --system --file=
1202 --list --replace-all
1203 --get --get-all --get-regexp
1204 --add --unset --unset-all
1205 --remove-section --rename-section
1210 local pfx
="${cur%.*}."
1212 __gitcomp
"remote merge" "$pfx" "$cur"
1216 local pfx
="${cur%.*}."
1218 __gitcomp
"$(__git_heads)" "$pfx" "$cur" "."
1222 local pfx
="${cur%.*}."
1225 url fetch push skipDefaultUpdate
1226 receivepack uploadpack tagopt
1231 local pfx
="${cur%.*}."
1233 __gitcomp
"$(__git_remotes)" "$pfx" "$cur" "."
1242 core.preferSymlinkRefs
1243 core.logAllRefUpdates
1244 core.loosecompression
1245 core.repositoryFormatVersion
1246 core.sharedRepository
1247 core.warnAmbiguousRefs
1249 core.packedGitWindowSize
1253 color.branch.current
1264 color.diff.whitespace
1269 color.status.changed
1270 color.status.untracked
1275 format.subjectprefix
1279 gitcvs.dbname gitcvs.dbdriver gitcvs.dbuser gitcvs.dbpass
1280 gitcvs.dbtablenameprefix
1283 gc.reflogexpireunreachable
1296 i18n.logOutputEncoding
1306 pack.deltaCacheLimit
1309 repack.useDeltaBaseOffset
1312 transfer.unpackLimit
1314 receive.denyNonFastForwards
1324 local subcommands
="add rm show prune update"
1325 local subcommand
="$(__git_find_subcommand "$subcommands")"
1326 if [ -z "$subcommand" ]; then
1327 __gitcomp
"$subcommands"
1331 case "$subcommand" in
1333 __gitcomp
"$(__git_remotes)"
1336 local i c
='' IFS
=$
'\n'
1337 for i
in $
(git
--git-dir="$(__gitdir)" config
--list); do
1355 __git_has_doubledash
&& return
1357 local cur
="${COMP_WORDS[COMP_CWORD]}"
1360 __gitcomp
"--mixed --hard --soft"
1364 __gitcomp
"$(__git_refs)"
1369 local cur
="${COMP_WORDS[COMP_CWORD]}"
1372 __gitcomp
"--edit --mainline --no-edit --no-commit --signoff"
1381 __git_has_doubledash
&& return
1383 local cur
="${COMP_WORDS[COMP_CWORD]}"
1386 __gitcomp
"--cached --dry-run --ignore-unmatch --quiet"
1395 __git_has_doubledash
&& return
1397 local cur
="${COMP_WORDS[COMP_CWORD]}"
1401 --max-count= --max-age= --since= --after=
1402 --min-age= --before= --until=
1404 --author= --committer= --grep=
1407 --numbered --summary
1412 __git_complete_revlist
1417 local cur
="${COMP_WORDS[COMP_CWORD]}"
1421 oneline short medium full fuller email raw
1422 " "" "${cur##--pretty=}"
1426 __gitcomp
"--pretty="
1435 local cur
="${COMP_WORDS[COMP_CWORD]}"
1439 --all --remotes --topo-order --current --more=
1440 --list --independent --merge-base --no-name
1441 --sha1-name --topics --reflog
1446 __git_complete_revlist
1451 local subcommands
='save list show apply clear drop pop create branch'
1452 local subcommand
="$(__git_find_subcommand "$subcommands")"
1453 if [ -z "$subcommand" ]; then
1454 __gitcomp
"$subcommands"
1456 local cur
="${COMP_WORDS[COMP_CWORD]}"
1457 case "$subcommand,$cur" in
1459 __gitcomp
"--keep-index"
1464 show
,--*|drop
,--*|pop
,--*|branch
,--*)
1467 show
,*|apply
,*|drop
,*|pop
,*|branch
,*)
1468 __gitcomp
"$(git --git-dir="$
(__gitdir
)" stash list \
1469 | sed -n -e 's/:.*//p')"
1480 __git_has_doubledash
&& return
1482 local subcommands
="add status init update summary foreach sync"
1483 if [ -z "$(__git_find_subcommand "$subcommands")" ]; then
1484 local cur
="${COMP_WORDS[COMP_CWORD]}"
1487 __gitcomp
"--quiet --cached"
1490 __gitcomp
"$subcommands"
1500 init fetch clone rebase dcommit log find-rev
1501 set-tree commit-diff info create-ignore propget
1502 proplist show-ignore show-externals
1504 local subcommand
="$(__git_find_subcommand "$subcommands")"
1505 if [ -z "$subcommand" ]; then
1506 __gitcomp
"$subcommands"
1508 local remote_opts
="--username= --config-dir= --no-auth-cache"
1510 --follow-parent --authors-file= --repack=
1511 --no-metadata --use-svm-props --use-svnsync-props
1512 --log-window-size= --no-checkout --quiet
1513 --repack-flags --user-log-author $remote_opts
1516 --template= --shared= --trunk= --tags=
1517 --branches= --stdlayout --minimize-url
1518 --no-metadata --use-svm-props --use-svnsync-props
1519 --rewrite-root= $remote_opts
1522 --edit --rmdir --find-copies-harder --copy-similarity=
1525 local cur
="${COMP_WORDS[COMP_CWORD]}"
1526 case "$subcommand,$cur" in
1528 __gitcomp
"--revision= --fetch-all $fc_opts"
1531 __gitcomp
"--revision= $fc_opts $init_opts"
1534 __gitcomp
"$init_opts"
1538 --merge --strategy= --verbose --dry-run
1539 --fetch-all --no-rebase $cmt_opts $fc_opts
1543 __gitcomp
"--stdin $cmt_opts $fc_opts"
1545 create-ignore
,--*|propget
,--*|proplist
,--*|show-ignore
,--*|\
1547 __gitcomp
"--revision="
1551 --limit= --revision= --verbose --incremental
1552 --oneline --show-commit --non-recursive
1558 --merge --verbose --strategy= --local
1559 --fetch-all $fc_opts
1563 __gitcomp
"--message= --file= --revision= $cmt_opts"
1578 while [ $c -lt $COMP_CWORD ]; do
1579 i
="${COMP_WORDS[c]}"
1582 __gitcomp
"$(__git_tags)"
1592 case "${COMP_WORDS[COMP_CWORD-1]}" in
1598 __gitcomp
"$(__git_tags)"
1604 __gitcomp
"$(__git_refs)"
1611 local i c
=1 command __git_dir
1613 while [ $c -lt $COMP_CWORD ]; do
1614 i
="${COMP_WORDS[c]}"
1616 --git-dir=*) __git_dir
="${i#--git-dir=}" ;;
1617 --bare) __git_dir
="." ;;
1618 --version|
-p|
--paginate) ;;
1619 --help) command="help"; break ;;
1620 *) command="$i"; break ;;
1625 if [ -z "$command" ]; then
1626 case "${COMP_WORDS[COMP_CWORD]}" in
1627 --*=*) COMPREPLY
=() ;;
1639 *) __gitcomp
"$(__git_porcelain_commands) $(__git_aliases)" ;;
1644 local expansion
=$
(__git_aliased_command
"$command")
1645 [ "$expansion" ] && command="$expansion"
1650 apply
) _git_apply
;;
1651 archive
) _git_archive
;;
1652 bisect
) _git_bisect
;;
1653 bundle
) _git_bundle
;;
1654 branch
) _git_branch
;;
1655 checkout
) _git_checkout
;;
1656 cherry
) _git_cherry
;;
1657 cherry-pick
) _git_cherry_pick
;;
1658 clean
) _git_clean
;;
1659 clone
) _git_clone
;;
1660 commit
) _git_commit
;;
1661 config
) _git_config
;;
1662 describe
) _git_describe
;;
1664 fetch
) _git_fetch
;;
1665 format-patch
) _git_format_patch
;;
1671 ls-files
) _git_ls_files
;;
1672 ls-remote
) _git_ls_remote
;;
1673 ls-tree
) _git_ls_tree
;;
1675 mergetool
) _git_mergetool
;;
1676 merge-base
) _git_merge_base
;;
1678 name-rev
) _git_name_rev
;;
1681 rebase
) _git_rebase
;;
1682 remote
) _git_remote
;;
1683 reset) _git_reset
;;
1684 revert
) _git_revert
;;
1686 send-email
) _git_send_email
;;
1687 shortlog
) _git_shortlog
;;
1689 show-branch
) _git_show_branch
;;
1690 stash
) _git_stash
;;
1691 submodule
) _git_submodule
;;
1694 whatchanged
) _git_log
;;
1701 __git_has_doubledash
&& return
1703 local cur
="${COMP_WORDS[COMP_CWORD]}"
1704 local g
="$(git rev-parse --git-dir 2>/dev/null)"
1706 if [ -f $g/MERGE_HEAD
]; then
1711 __gitcomp
"--not --all $merge"
1715 __git_complete_revlist
1718 complete
-o default
-o nospace
-F _git git
1719 complete
-o default
-o nospace
-F _gitk gitk
1721 # The following are necessary only for Cygwin, and only are needed
1722 # when the user has tab-completed the executable name and consequently
1723 # included the '.exe' suffix.
1725 if [ Cygwin
= "$(uname -o 2>/dev/null)" ]; then
1726 complete
-o default
-o nospace
-F _git git.exe