3 # bash completion support for core Git.
5 # Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
6 # Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
7 # Distributed under the GNU General Public License, version 2.0.
9 # The contained completion routines provide support for completing:
11 # *) local and remote branch names
12 # *) local and remote tag names
13 # *) .git/remotes file names
14 # *) git 'subcommands'
15 # *) tree paths within 'ref:path/to/file' expressions
16 # *) common --long-options
18 # To use these routines:
20 # 1) Copy this file to somewhere (e.g. ~/.git-completion.sh).
21 # 2) Added the following line to your .bashrc:
22 # source ~/.git-completion.sh
24 # 3) You may want to make sure the git executable is available
25 # in your PATH before this script is sourced, as some caching
26 # is performed while the script loads. If git isn't found
27 # at source time then all lookups will be done on demand,
28 # which may be slightly slower.
30 # 4) Consider changing your PS1 to also show the current branch:
31 # PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
33 # The argument to __git_ps1 will be displayed only if you
34 # are currently in a git repository. The %s token will be
35 # the name of the current branch.
39 # *) Read Documentation/SubmittingPatches
40 # *) Send all patches to the current maintainer:
42 # "Shawn O. Pearce" <spearce@spearce.org>
44 # *) Always CC the Git mailing list:
49 case "$COMP_WORDBREAKS" in
51 *) COMP_WORDBREAKS
="$COMP_WORDBREAKS:"
54 # __gitdir accepts 0 or 1 arguments (i.e., location)
55 # returns location of .git repo
58 if [ -z "${1-}" ]; then
59 if [ -n "$__git_dir" ]; then
61 elif [ -d .git
]; then
64 git rev-parse
--git-dir 2>/dev
/null
66 elif [ -d "$1/.git" ]; then
73 # __git_ps1 accepts 0 or 1 arguments (i.e., format string)
74 # returns text to add to bash PS1 prompt (includes branch name)
77 local g
="$(git rev-parse --git-dir 2>/dev/null)"
81 if [ -d "$g/rebase-apply" ]
83 if test -f "$g/rebase-apply/rebasing"
86 elif test -f "$g/rebase-apply/applying"
92 b
="$(git symbolic-ref HEAD 2>/dev/null)"
93 elif [ -f "$g/rebase-merge/interactive" ]
96 b
="$(cat "$g/rebase-merge
/head-name
")"
97 elif [ -d "$g/rebase-merge" ]
100 b
="$(cat "$g/rebase-merge
/head-name
")"
101 elif [ -f "$g/MERGE_HEAD" ]
104 b
="$(git symbolic-ref HEAD 2>/dev/null)"
106 if [ -f "$g/BISECT_LOG" ]
110 if ! b
="$(git symbolic-ref HEAD 2>/dev/null)"
112 if ! b
="$(git describe --exact-match HEAD 2>/dev/null)"
114 b
="$(cut -c1-7 "$g/HEAD
")..."
119 if [ -n "${1-}" ]; then
120 printf "$1" "${b##refs/heads/}$r"
122 printf " (%s)" "${b##refs/heads/}$r"
127 # __gitcomp_1 requires 2 arguments
130 local c IFS
=' '$
'\t'$
'\n'
133 --*=*) printf %s$
'\n' "$c$2" ;;
134 *.
) printf %s$
'\n' "$c$2" ;;
135 *) printf %s$
'\n' "$c$2 " ;;
140 # __gitcomp accepts 1, 2, 3, or 4 arguments
141 # generates completion reply with compgen
144 local cur
="${COMP_WORDS[COMP_CWORD]}"
145 if [ $# -gt 2 ]; then
154 COMPREPLY
=($
(compgen
-P "${2-}" \
155 -W "$(__gitcomp_1 "${1-}" "${4-}")" \
161 # __git_heads accepts 0 or 1 arguments (to pass to __gitdir)
164 local cmd i is_hash
=y dir
="$(__gitdir "${1-}")"
165 if [ -d "$dir" ]; then
166 git
--git-dir="$dir" for-each-ref
--format='%(refname:short)' \
170 for i
in $
(git ls-remote
"${1-}" 2>/dev
/null
); do
171 case "$is_hash,$i" in
174 n
,refs
/heads
/*) is_hash
=y
; echo "${i#refs/heads/}" ;;
175 n
,*) is_hash
=y
; echo "$i" ;;
180 # __git_tags accepts 0 or 1 arguments (to pass to __gitdir)
183 local cmd i is_hash
=y dir
="$(__gitdir "${1-}")"
184 if [ -d "$dir" ]; then
185 git
--git-dir="$dir" for-each-ref
--format='%(refname:short)' \
189 for i
in $
(git ls-remote
"${1-}" 2>/dev
/null
); do
190 case "$is_hash,$i" in
193 n
,refs
/tags
/*) is_hash
=y
; echo "${i#refs/tags/}" ;;
194 n
,*) is_hash
=y
; echo "$i" ;;
199 # __git_refs accepts 0 or 1 arguments (to pass to __gitdir)
202 local i is_hash
=y dir
="$(__gitdir "${1-}")"
203 local cur
="${COMP_WORDS[COMP_CWORD]}" format refs
204 if [ -d "$dir" ]; then
211 if [ -e "$dir/HEAD" ]; then echo HEAD
; fi
212 format
="refname:short"
213 refs
="refs/tags refs/heads refs/remotes"
216 git
--git-dir="$dir" for-each-ref
--format="%($format)" \
220 for i
in $
(git ls-remote
"$dir" 2>/dev
/null
); do
221 case "$is_hash,$i" in
224 n
,refs
/tags
/*) is_hash
=y
; echo "${i#refs/tags/}" ;;
225 n
,refs
/heads
/*) is_hash
=y
; echo "${i#refs/heads/}" ;;
226 n
,refs
/remotes
/*) is_hash
=y
; echo "${i#refs/remotes/}" ;;
227 n
,*) is_hash
=y
; echo "$i" ;;
232 # __git_refs2 requires 1 argument (to pass to __git_refs)
236 for i
in $
(__git_refs
"$1"); do
241 # __git_refs_remotes requires 1 argument (to pass to ls-remote)
242 __git_refs_remotes
()
244 local cmd i is_hash
=y
245 for i
in $
(git ls-remote
"$1" 2>/dev
/null
); do
246 case "$is_hash,$i" in
249 echo "$i:refs/remotes/$1/${i#refs/heads/}"
253 n
,refs
/tags
/*) is_hash
=y
;;
261 local i ngoff IFS
=$
'\n' d
="$(__gitdir)"
262 shopt -q nullglob || ngoff
=1
264 for i
in "$d/remotes"/*; do
265 echo ${i#$d/remotes/}
267 [ "$ngoff" ] && shopt -u nullglob
268 for i
in $
(git
--git-dir="$d" config
--list); do
278 __git_merge_strategies
()
280 if [ -n "$__git_merge_strategylist" ]; then
281 echo "$__git_merge_strategylist"
284 git merge
-s help 2>&1 |
285 sed -n -e '/[Aa]vailable strategies are: /,/^$/{
293 __git_merge_strategylist
=
294 __git_merge_strategylist
=$
(__git_merge_strategies
2>/dev
/null
)
296 __git_complete_file
()
298 local pfx
ls ref cur
="${COMP_WORDS[COMP_CWORD]}"
315 case "$COMP_WORDBREAKS" in
317 *) pfx
="$ref:$pfx" ;;
321 COMPREPLY
=($
(compgen
-P "$pfx" \
322 -W "$(git --git-dir="$
(__gitdir
)" ls-tree "$ls" \
323 | sed '/^100... blob /{
339 __gitcomp
"$(__git_refs)"
344 __git_complete_revlist
()
346 local pfx cur
="${COMP_WORDS[COMP_CWORD]}"
351 __gitcomp
"$(__git_refs)" "$pfx" "$cur"
356 __gitcomp
"$(__git_refs)" "$pfx" "$cur"
359 __gitcomp
"$(__git_refs)"
364 __git_all_commands
()
366 if [ -n "$__git_all_commandlist" ]; then
367 echo "$__git_all_commandlist"
371 for i
in $
(git
help -a|
egrep '^ ')
374 *--*) : helper pattern
;;
379 __git_all_commandlist
=
380 __git_all_commandlist
="$(__git_all_commands 2>/dev/null)"
382 __git_porcelain_commands
()
384 if [ -n "$__git_porcelain_commandlist" ]; then
385 echo "$__git_porcelain_commandlist"
389 for i
in "help" $
(__git_all_commands
)
392 *--*) : helper pattern
;;
393 applymbox
) : ask gittus
;;
394 applypatch
) : ask gittus
;;
395 archimport
) : import
;;
396 cat-file
) : plumbing
;;
397 check-attr
) : plumbing
;;
398 check-ref-format
) : plumbing
;;
399 checkout-index
) : plumbing
;;
400 commit-tree
) : plumbing
;;
401 count-objects
) : infrequent
;;
402 cvsexportcommit
) : export;;
403 cvsimport
) : import
;;
404 cvsserver
) : daemon
;;
406 diff-files
) : plumbing
;;
407 diff-index
) : plumbing
;;
408 diff-tree
) : plumbing
;;
409 fast-import
) : import
;;
410 fast-export
) : export;;
411 fsck-objects
) : plumbing
;;
412 fetch-pack
) : plumbing
;;
413 fmt-merge-msg
) : plumbing
;;
414 for-each-ref
) : plumbing
;;
415 hash-object
) : plumbing
;;
416 http-
*) : transport
;;
417 index-pack
) : plumbing
;;
418 init-db
) : deprecated
;;
419 local-fetch
) : plumbing
;;
420 lost-found
) : infrequent
;;
421 ls-files
) : plumbing
;;
422 ls-remote
) : plumbing
;;
423 ls-tree
) : plumbing
;;
424 mailinfo
) : plumbing
;;
425 mailsplit
) : plumbing
;;
426 merge-
*) : plumbing
;;
429 pack-objects
) : plumbing
;;
430 pack-redundant
) : plumbing
;;
431 pack-refs
) : plumbing
;;
432 parse-remote
) : plumbing
;;
433 patch-id
) : plumbing
;;
434 peek-remote
) : plumbing
;;
436 prune-packed
) : plumbing
;;
437 quiltimport
) : import
;;
438 read-tree
) : plumbing
;;
439 receive-pack
) : plumbing
;;
441 repo-config
) : deprecated
;;
443 rev-list
) : plumbing
;;
444 rev-parse
) : plumbing
;;
445 runstatus
) : plumbing
;;
446 sh-setup
) : internal
;;
448 show-ref
) : plumbing
;;
449 send-pack
) : plumbing
;;
450 show-index
) : plumbing
;;
452 stripspace
) : plumbing
;;
453 symbolic-ref
) : plumbing
;;
454 tar-tree
) : deprecated
;;
455 unpack-file
) : plumbing
;;
456 unpack-objects
) : plumbing
;;
457 update-index
) : plumbing
;;
458 update-ref
) : plumbing
;;
459 update-server-info
) : daemon
;;
460 upload-archive
) : plumbing
;;
461 upload-pack
) : plumbing
;;
462 write-tree
) : plumbing
;;
464 verify-pack
) : infrequent
;;
465 verify-tag
) : plumbing
;;
470 __git_porcelain_commandlist
=
471 __git_porcelain_commandlist
="$(__git_porcelain_commands 2>/dev/null)"
476 for i
in $
(git
--git-dir="$(__gitdir)" config
--list); do
486 # __git_aliased_command requires 1 argument
487 __git_aliased_command
()
489 local word cmdline
=$
(git
--git-dir="$(__gitdir)" \
490 config
--get "alias.$1")
491 for word
in $cmdline; do
492 if [ "${word##-*}" ]; then
499 # __git_find_subcommand requires 1 argument
500 __git_find_subcommand
()
502 local word subcommand c
=1
504 while [ $c -lt $COMP_CWORD ]; do
505 word
="${COMP_WORDS[c]}"
506 for subcommand
in $1; do
507 if [ "$subcommand" = "$word" ]; then
516 __git_has_doubledash
()
519 while [ $c -lt $COMP_CWORD ]; do
520 if [ "--" = "${COMP_WORDS[c]}" ]; then
528 __git_whitespacelist
="nowarn warn error error-all fix"
532 local cur
="${COMP_WORDS[COMP_CWORD]}" dir
="$(__gitdir)"
533 if [ -d "$dir"/rebase-apply
]; then
534 __gitcomp
"--skip --resolved --abort"
539 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
544 --signoff --utf8 --binary --3way --interactive
554 local cur
="${COMP_WORDS[COMP_CWORD]}"
557 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
562 --stat --numstat --summary --check --index
563 --cached --index-info --reverse --reject --unidiff-zero
564 --apply --no-add --exclude=
565 --whitespace= --inaccurate-eof --verbose
574 __git_has_doubledash
&& return
576 local cur
="${COMP_WORDS[COMP_CWORD]}"
580 --interactive --refresh --patch --update --dry-run
581 --ignore-errors --intent-to-add
590 local cur
="${COMP_WORDS[COMP_CWORD]}"
593 __gitcomp
"$(git archive --list)" "" "${cur##--format=}"
597 __gitcomp
"$(__git_remotes)" "" "${cur##--remote=}"
602 --format= --list --verbose
603 --prefix= --remote= --exec=
613 __git_has_doubledash
&& return
615 local subcommands
="start bad good skip reset visualize replay log run"
616 local subcommand
="$(__git_find_subcommand "$subcommands")"
617 if [ -z "$subcommand" ]; then
618 __gitcomp
"$subcommands"
622 case "$subcommand" in
624 __gitcomp
"$(__git_refs)"
634 local i c
=1 only_local_ref
="n" has_r
="n"
636 while [ $c -lt $COMP_CWORD ]; do
639 -d|
-m) only_local_ref
="y" ;;
645 case "${COMP_WORDS[COMP_CWORD]}" in
648 --color --no-color --verbose --abbrev= --no-abbrev
649 --track --no-track --contains --merged --no-merged
653 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
654 __gitcomp
"$(__git_heads)"
656 __gitcomp
"$(__git_refs)"
664 local cmd
="${COMP_WORDS[2]}"
665 case "$COMP_CWORD" in
667 __gitcomp
"create list-heads verify unbundle"
675 __git_complete_revlist
684 __git_has_doubledash
&& return
686 __gitcomp
"$(__git_refs)"
691 __gitcomp
"$(__git_refs)"
696 local cur
="${COMP_WORDS[COMP_CWORD]}"
699 __gitcomp
"--edit --no-commit"
702 __gitcomp
"$(__git_refs)"
709 __git_has_doubledash
&& return
711 local cur
="${COMP_WORDS[COMP_CWORD]}"
714 __gitcomp
"--dry-run --quiet"
723 local cur
="${COMP_WORDS[COMP_CWORD]}"
748 __git_has_doubledash
&& return
750 local cur
="${COMP_WORDS[COMP_CWORD]}"
754 --all --author= --signoff --verify --no-verify
755 --edit --amend --include --only --interactive
764 local cur
="${COMP_WORDS[COMP_CWORD]}"
768 --all --tags --contains --abbrev= --candidates=
769 --exact-match --debug --long --match --always
773 __gitcomp
"$(__git_refs)"
776 __git_diff_common_options
="--stat --numstat --shortstat --summary
777 --patch-with-stat --name-only --name-status --color
778 --no-color --color-words --no-renames --check
779 --full-index --binary --abbrev --diff-filter=
781 --text --ignore-space-at-eol --ignore-space-change
782 --ignore-all-space --exit-code --quiet --ext-diff
784 --no-prefix --src-prefix= --dst-prefix=
785 --inter-hunk-context=
792 __git_has_doubledash
&& return
794 local cur
="${COMP_WORDS[COMP_CWORD]}"
797 __gitcomp
"--cached --pickaxe-all --pickaxe-regex
798 --base --ours --theirs
799 $__git_diff_common_options
809 local cur
="${COMP_WORDS[COMP_CWORD]}"
811 if [ "$COMP_CWORD" = 2 ]; then
812 __gitcomp
"$(__git_remotes)"
817 case "$COMP_WORDBREAKS" in
819 *) pfx
="${cur%%:*}:" ;;
821 __gitcomp
"$(__git_refs)" "$pfx" "${cur#*:}"
824 __gitcomp
"$(__git_refs2 "${COMP_WORDS[2]}")"
832 local cur
="${COMP_WORDS[COMP_CWORD]}"
836 --stdout --attach --thread
838 --numbered --start-number
843 --full-index --binary
846 --no-prefix --src-prefix= --dst-prefix=
847 --inline --suffix= --ignore-if-in-upstream
853 __git_complete_revlist
858 local cur
="${COMP_WORDS[COMP_CWORD]}"
861 __gitcomp
"--prune --aggressive"
870 __git_has_doubledash
&& return
872 local cur
="${COMP_WORDS[COMP_CWORD]}"
877 --text --ignore-case --word-regexp --invert-match
879 --extended-regexp --basic-regexp --fixed-strings
880 --files-with-matches --name-only
881 --files-without-match
883 --and --or --not --all-match
893 local cur
="${COMP_WORDS[COMP_CWORD]}"
896 __gitcomp
"--all --info --man --web"
900 __gitcomp
"$(__git_all_commands)
901 attributes cli core-tutorial cvs-migration
902 diffcore gitk glossary hooks ignore modules
903 repository-layout tutorial tutorial-2
910 local cur
="${COMP_WORDS[COMP_CWORD]}"
914 false true umask group all world everybody
915 " "" "${cur##--shared=}"
919 __gitcomp
"--quiet --bare --template= --shared --shared="
928 __git_has_doubledash
&& return
930 local cur
="${COMP_WORDS[COMP_CWORD]}"
933 __gitcomp
"--cached --deleted --modified --others --ignored
934 --stage --directory --no-empty-directory --unmerged
935 --killed --exclude= --exclude-from=
936 --exclude-per-directory= --exclude-standard
937 --error-unmatch --with-tree= --full-name
938 --abbrev --ignored --exclude-per-directory
948 __gitcomp
"$(__git_remotes)"
956 __git_log_pretty_formats
="oneline short medium full fuller email raw format:"
960 __git_has_doubledash
&& return
962 local cur
="${COMP_WORDS[COMP_CWORD]}"
965 __gitcomp
"$__git_log_pretty_formats
966 " "" "${cur##--pretty=}"
971 relative iso8601 rfc2822 short local default
972 " "" "${cur##--date=}"
977 --max-count= --max-age= --since= --after=
978 --min-age= --before= --until=
979 --root --topo-order --date-order --reverse
981 --abbrev-commit --abbrev=
982 --relative-date --date=
983 --author= --committer= --grep=
987 --left-right --cherry-pick
991 --parents --children --full-history
993 $__git_diff_common_options
994 --pickaxe-all --pickaxe-regex
999 __git_complete_revlist
1004 local cur
="${COMP_WORDS[COMP_CWORD]}"
1005 case "${COMP_WORDS[COMP_CWORD-1]}" in
1007 __gitcomp
"$(__git_merge_strategies)"
1012 __gitcomp
"$(__git_merge_strategies)" "" "${cur##--strategy=}"
1017 --no-commit --no-stat --log --no-log --squash --strategy
1021 __gitcomp
"$(__git_refs)"
1026 local cur
="${COMP_WORDS[COMP_CWORD]}"
1030 kdiff3 tkdiff meld xxdiff emerge
1031 vimdiff gvimdiff ecmerge opendiff
1032 " "" "${cur##--tool=}"
1045 __gitcomp
"$(__git_refs)"
1050 local cur
="${COMP_WORDS[COMP_CWORD]}"
1053 __gitcomp
"--dry-run"
1062 __gitcomp
"--tags --all --stdin"
1067 local cur
="${COMP_WORDS[COMP_CWORD]}"
1069 if [ "$COMP_CWORD" = 2 ]; then
1070 __gitcomp
"$(__git_remotes)"
1072 __gitcomp
"$(__git_refs "${COMP_WORDS[2]}")"
1078 local cur
="${COMP_WORDS[COMP_CWORD]}"
1080 if [ "$COMP_CWORD" = 2 ]; then
1081 __gitcomp
"$(__git_remotes)"
1086 case "$COMP_WORDBREAKS" in
1088 *) pfx
="${cur%%:*}:" ;;
1091 __gitcomp
"$(__git_refs "${COMP_WORDS[2]}")" "$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 normal 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 mergeoptions" "$pfx" "$cur"
1211 local pfx
="${cur%.*}."
1213 __gitcomp
"$(__git_heads)" "$pfx" "$cur" "."
1217 local pfx
="${cur%.*}."
1220 url proxy fetch push mirror skipDefaultUpdate
1221 receivepack uploadpack tagopt
1226 local pfx
="${cur%.*}."
1228 __gitcomp
"$(__git_remotes)" "$pfx" "$cur" "."
1234 branch.autosetupmerge
1235 branch.autosetuprebase
1238 color.branch.current
1249 color.diff.whitespace
1251 color.interactive.header
1252 color.interactive.help
1253 color.interactive.prompt
1257 color.status.changed
1259 color.status.nobranch
1260 color.status.untracked
1261 color.status.updated
1267 core.deltaBaseCacheLimit
1271 core.fsyncobjectfiles
1273 core.ignoreCygwinFSTricks
1275 core.logAllRefUpdates
1276 core.loosecompression
1278 core.packedGitWindowSize
1280 core.preferSymlinkRefs
1283 core.repositoryFormatVersion
1285 core.sharedRepository
1288 core.warnAmbiguousRefs
1291 diff.autorefreshindex
1308 gc.reflogexpireunreachable
1312 gitcvs.dbTableNamePrefix
1322 gui.copyblamethreshold
1326 gui.matchtrackingbranch
1327 gui.newbranchtemplate
1328 gui.pruneduringfetch
1329 gui.spellingdictionary
1345 i18n.logOutputEncoding
1360 mergetool.keepBackup
1362 pack.deltaCacheLimit
1372 receive.denyCurrentBranch
1374 receive.denyNonFastForwards
1377 repack.usedeltabaseoffset
1381 status.relativePaths
1382 status.showUntrackedFiles
1384 transfer.unpackLimit
1395 local subcommands
="add rename rm show prune update"
1396 local subcommand
="$(__git_find_subcommand "$subcommands")"
1397 if [ -z "$subcommand" ]; then
1398 __gitcomp
"$subcommands"
1402 case "$subcommand" in
1403 rename|
rm|show|prune
)
1404 __gitcomp
"$(__git_remotes)"
1407 local i c
='' IFS
=$
'\n'
1408 for i
in $
(git
--git-dir="$(__gitdir)" config
--list); do
1426 __git_has_doubledash
&& return
1428 local cur
="${COMP_WORDS[COMP_CWORD]}"
1431 __gitcomp
"--merge --mixed --hard --soft"
1435 __gitcomp
"$(__git_refs)"
1440 local cur
="${COMP_WORDS[COMP_CWORD]}"
1443 __gitcomp
"--edit --mainline --no-edit --no-commit --signoff"
1447 __gitcomp
"$(__git_refs)"
1452 __git_has_doubledash
&& return
1454 local cur
="${COMP_WORDS[COMP_CWORD]}"
1457 __gitcomp
"--cached --dry-run --ignore-unmatch --quiet"
1466 __git_has_doubledash
&& return
1468 local cur
="${COMP_WORDS[COMP_CWORD]}"
1472 --max-count= --max-age= --since= --after=
1473 --min-age= --before= --until=
1475 --author= --committer= --grep=
1478 --numbered --summary
1483 __git_complete_revlist
1488 __git_has_doubledash
&& return
1490 local cur
="${COMP_WORDS[COMP_CWORD]}"
1493 __gitcomp
"$__git_log_pretty_formats
1494 " "" "${cur##--pretty=}"
1498 __gitcomp
"--pretty=
1499 $__git_diff_common_options
1509 local cur
="${COMP_WORDS[COMP_CWORD]}"
1513 --all --remotes --topo-order --current --more=
1514 --list --independent --merge-base --no-name
1515 --sha1-name --topics --reflog
1520 __git_complete_revlist
1525 local subcommands
='save list show apply clear drop pop create branch'
1526 local subcommand
="$(__git_find_subcommand "$subcommands")"
1527 if [ -z "$subcommand" ]; then
1528 __gitcomp
"$subcommands"
1530 local cur
="${COMP_WORDS[COMP_CWORD]}"
1531 case "$subcommand,$cur" in
1533 __gitcomp
"--keep-index"
1538 show
,--*|drop
,--*|pop
,--*|branch
,--*)
1541 show
,*|apply
,*|drop
,*|pop
,*|branch
,*)
1542 __gitcomp
"$(git --git-dir="$
(__gitdir
)" stash list \
1543 | sed -n -e 's/:.*//p')"
1554 __git_has_doubledash
&& return
1556 local subcommands
="add status init update summary foreach sync"
1557 if [ -z "$(__git_find_subcommand "$subcommands")" ]; then
1558 local cur
="${COMP_WORDS[COMP_CWORD]}"
1561 __gitcomp
"--quiet --cached"
1564 __gitcomp
"$subcommands"
1574 init fetch clone rebase dcommit log find-rev
1575 set-tree commit-diff info create-ignore propget
1576 proplist show-ignore show-externals
1578 local subcommand
="$(__git_find_subcommand "$subcommands")"
1579 if [ -z "$subcommand" ]; then
1580 __gitcomp
"$subcommands"
1582 local remote_opts
="--username= --config-dir= --no-auth-cache"
1584 --follow-parent --authors-file= --repack=
1585 --no-metadata --use-svm-props --use-svnsync-props
1586 --log-window-size= --no-checkout --quiet
1587 --repack-flags --user-log-author --localtime $remote_opts
1590 --template= --shared= --trunk= --tags=
1591 --branches= --stdlayout --minimize-url
1592 --no-metadata --use-svm-props --use-svnsync-props
1593 --rewrite-root= $remote_opts
1596 --edit --rmdir --find-copies-harder --copy-similarity=
1599 local cur
="${COMP_WORDS[COMP_CWORD]}"
1600 case "$subcommand,$cur" in
1602 __gitcomp
"--revision= --fetch-all $fc_opts"
1605 __gitcomp
"--revision= $fc_opts $init_opts"
1608 __gitcomp
"$init_opts"
1612 --merge --strategy= --verbose --dry-run
1613 --fetch-all --no-rebase $cmt_opts $fc_opts
1617 __gitcomp
"--stdin $cmt_opts $fc_opts"
1619 create-ignore
,--*|propget
,--*|proplist
,--*|show-ignore
,--*|\
1621 __gitcomp
"--revision="
1625 --limit= --revision= --verbose --incremental
1626 --oneline --show-commit --non-recursive
1632 --merge --verbose --strategy= --local
1633 --fetch-all $fc_opts
1637 __gitcomp
"--message= --file= --revision= $cmt_opts"
1652 while [ $c -lt $COMP_CWORD ]; do
1653 i
="${COMP_WORDS[c]}"
1656 __gitcomp
"$(__git_tags)"
1666 case "${COMP_WORDS[COMP_CWORD-1]}" in
1672 __gitcomp
"$(__git_tags)"
1678 __gitcomp
"$(__git_refs)"
1685 local i c
=1 command __git_dir
1687 while [ $c -lt $COMP_CWORD ]; do
1688 i
="${COMP_WORDS[c]}"
1690 --git-dir=*) __git_dir
="${i#--git-dir=}" ;;
1691 --bare) __git_dir
="." ;;
1692 --version|
-p|
--paginate) ;;
1693 --help) command="help"; break ;;
1694 *) command="$i"; break ;;
1699 if [ -z "$command" ]; then
1700 case "${COMP_WORDS[COMP_CWORD]}" in
1712 *) __gitcomp
"$(__git_porcelain_commands) $(__git_aliases)" ;;
1717 local expansion
=$
(__git_aliased_command
"$command")
1718 [ "$expansion" ] && command="$expansion"
1723 apply
) _git_apply
;;
1724 archive
) _git_archive
;;
1725 bisect
) _git_bisect
;;
1726 bundle
) _git_bundle
;;
1727 branch
) _git_branch
;;
1728 checkout
) _git_checkout
;;
1729 cherry
) _git_cherry
;;
1730 cherry-pick
) _git_cherry_pick
;;
1731 clean
) _git_clean
;;
1732 clone
) _git_clone
;;
1733 commit
) _git_commit
;;
1734 config
) _git_config
;;
1735 describe
) _git_describe
;;
1737 fetch
) _git_fetch
;;
1738 format-patch
) _git_format_patch
;;
1744 ls-files
) _git_ls_files
;;
1745 ls-remote
) _git_ls_remote
;;
1746 ls-tree
) _git_ls_tree
;;
1748 mergetool
) _git_mergetool
;;
1749 merge-base
) _git_merge_base
;;
1751 name-rev
) _git_name_rev
;;
1754 rebase
) _git_rebase
;;
1755 remote
) _git_remote
;;
1756 reset) _git_reset
;;
1757 revert
) _git_revert
;;
1759 send-email
) _git_send_email
;;
1760 shortlog
) _git_shortlog
;;
1762 show-branch
) _git_show_branch
;;
1763 stash
) _git_stash
;;
1765 submodule
) _git_submodule
;;
1768 whatchanged
) _git_log
;;
1775 __git_has_doubledash
&& return
1777 local cur
="${COMP_WORDS[COMP_CWORD]}"
1778 local g
="$(git rev-parse --git-dir 2>/dev/null)"
1780 if [ -f $g/MERGE_HEAD
]; then
1785 __gitcomp
"--not --all $merge"
1789 __git_complete_revlist
1792 complete
-o bashdefault
-o default
-o nospace
-F _git git
2>/dev
/null \
1793 || complete
-o default
-o nospace
-F _git git
1794 complete
-o bashdefault
-o default
-o nospace
-F _gitk gitk
2>/dev
/null \
1795 || complete
-o default
-o nospace
-F _gitk gitk
1797 # The following are necessary only for Cygwin, and only are needed
1798 # when the user has tab-completed the executable name and consequently
1799 # included the '.exe' suffix.
1801 if [ Cygwin
= "$(uname -o 2>/dev/null)" ]; then
1802 complete
-o bashdefault
-o default
-o nospace
-F _git git.exe
2>/dev
/null \
1803 || complete
-o default
-o nospace
-F _git git.exe