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.
37 # In addition, if you set GIT_PS1_SHOWDIRTYSTATE to a nonempty
38 # value, unstaged (*) and staged (+) changes will be shown next
39 # to the branch name. You can configure this per-repository
40 # with the bash.showDirtyState variable, which defaults to true
41 # once GIT_PS1_SHOWDIRTYSTATE is enabled.
43 # You can also see if currently something is stashed, by setting
44 # GIT_PS1_SHOWSTASHSTATE to a nonempty value. If something is stashed,
45 # then a '$' will be shown next to the branch name.
47 # If you would like to see if there're untracked files, then you can
48 # set GIT_PS1_SHOWUNTRACKEDFILES to a nonempty value. If there're
49 # untracked files, then a '%' will be shown next to the branch name.
53 # *) Read Documentation/SubmittingPatches
54 # *) Send all patches to the current maintainer:
56 # "Shawn O. Pearce" <spearce@spearce.org>
58 # *) Always CC the Git mailing list:
63 case "$COMP_WORDBREAKS" in
65 *) COMP_WORDBREAKS
="$COMP_WORDBREAKS:"
68 # __gitdir accepts 0 or 1 arguments (i.e., location)
69 # returns location of .git repo
72 if [ -z "${1-}" ]; then
73 if [ -n "${__git_dir-}" ]; then
75 elif [ -d .git
]; then
78 git rev-parse
--git-dir 2>/dev
/null
80 elif [ -d "$1/.git" ]; then
87 # __git_ps1 accepts 0 or 1 arguments (i.e., format string)
88 # returns text to add to bash PS1 prompt (includes branch name)
95 if [ -f "$g/rebase-merge/interactive" ]; then
97 b
="$(cat "$g/rebase-merge
/head-name
")"
98 elif [ -d "$g/rebase-merge" ]; then
100 b
="$(cat "$g/rebase-merge
/head-name
")"
102 if [ -d "$g/rebase-apply" ]; then
103 if [ -f "$g/rebase-apply/rebasing" ]; then
105 elif [ -f "$g/rebase-apply/applying" ]; then
110 elif [ -f "$g/MERGE_HEAD" ]; then
112 elif [ -f "$g/BISECT_LOG" ]; then
116 b
="$(git symbolic-ref HEAD 2>/dev/null)" ||
{
119 case "${GIT_PS1_DESCRIBE_STYLE-}" in
121 git describe --contains HEAD ;;
123 git describe --contains --all HEAD ;;
127 git describe --exact-match HEAD ;;
128 esac 2>/dev/null)" ||
130 b
="$(cut -c1-7 "$g/HEAD
" 2>/dev/null)..." ||
142 if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then
143 if [ "true" = "$(git rev-parse --is-bare-repository 2>/dev/null)" ]; then
148 elif [ "true" = "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
149 if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ]; then
150 if [ "$(git config --bool bash.showDirtyState)" != "false" ]; then
151 git
diff --no-ext-diff --ignore-submodules \
152 --quiet --exit-code || w
="*"
153 if git rev-parse
--quiet --verify HEAD
>/dev
/null
; then
154 git diff-index
--cached --quiet \
155 --ignore-submodules HEAD
-- || i
="+"
161 if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ]; then
162 git rev-parse
--verify refs
/stash
>/dev
/null
2>&1 && s
="$"
165 if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ]; then
166 if [ -n "$(git ls-files --others --exclude-standard)" ]; then
172 if [ -n "${1-}" ]; then
173 printf "$1" "$c${b##refs/heads/}$w$i$s$u$r"
175 printf " (%s)" "$c${b##refs/heads/}$w$i$s$u$r"
180 # __gitcomp_1 requires 2 arguments
183 local c IFS
=' '$
'\t'$
'\n'
186 --*=*) printf %s$
'\n' "$c$2" ;;
187 *.
) printf %s$
'\n' "$c$2" ;;
188 *) printf %s$
'\n' "$c$2 " ;;
193 # __gitcomp accepts 1, 2, 3, or 4 arguments
194 # generates completion reply with compgen
197 local cur
="${COMP_WORDS[COMP_CWORD]}"
198 if [ $# -gt 2 ]; then
207 COMPREPLY
=($
(compgen
-P "${2-}" \
208 -W "$(__gitcomp_1 "${1-}" "${4-}")" \
214 # __git_heads accepts 0 or 1 arguments (to pass to __gitdir)
217 local cmd i is_hash
=y dir
="$(__gitdir "${1-}")"
218 if [ -d "$dir" ]; then
219 git
--git-dir="$dir" for-each-ref
--format='%(refname:short)' \
223 for i
in $
(git ls-remote
"${1-}" 2>/dev
/null
); do
224 case "$is_hash,$i" in
227 n
,refs
/heads
/*) is_hash
=y
; echo "${i#refs/heads/}" ;;
228 n
,*) is_hash
=y
; echo "$i" ;;
233 # __git_tags accepts 0 or 1 arguments (to pass to __gitdir)
236 local cmd i is_hash
=y dir
="$(__gitdir "${1-}")"
237 if [ -d "$dir" ]; then
238 git
--git-dir="$dir" for-each-ref
--format='%(refname:short)' \
242 for i
in $
(git ls-remote
"${1-}" 2>/dev
/null
); do
243 case "$is_hash,$i" in
246 n
,refs
/tags
/*) is_hash
=y
; echo "${i#refs/tags/}" ;;
247 n
,*) is_hash
=y
; echo "$i" ;;
252 # __git_refs accepts 0 or 1 arguments (to pass to __gitdir)
255 local i is_hash
=y dir
="$(__gitdir "${1-}")"
256 local cur
="${COMP_WORDS[COMP_CWORD]}" format refs
257 if [ -d "$dir" ]; then
264 if [ -e "$dir/HEAD" ]; then echo HEAD
; fi
265 format
="refname:short"
266 refs
="refs/tags refs/heads refs/remotes"
269 git
--git-dir="$dir" for-each-ref
--format="%($format)" \
273 for i
in $
(git ls-remote
"$dir" 2>/dev
/null
); do
274 case "$is_hash,$i" in
277 n
,refs
/tags
/*) is_hash
=y
; echo "${i#refs/tags/}" ;;
278 n
,refs
/heads
/*) is_hash
=y
; echo "${i#refs/heads/}" ;;
279 n
,refs
/remotes
/*) is_hash
=y
; echo "${i#refs/remotes/}" ;;
280 n
,*) is_hash
=y
; echo "$i" ;;
285 # __git_refs2 requires 1 argument (to pass to __git_refs)
289 for i
in $
(__git_refs
"$1"); do
294 # __git_refs_remotes requires 1 argument (to pass to ls-remote)
295 __git_refs_remotes
()
297 local cmd i is_hash
=y
298 for i
in $
(git ls-remote
"$1" 2>/dev
/null
); do
299 case "$is_hash,$i" in
302 echo "$i:refs/remotes/$1/${i#refs/heads/}"
306 n
,refs
/tags
/*) is_hash
=y
;;
314 local i ngoff IFS
=$
'\n' d
="$(__gitdir)"
315 shopt -q nullglob || ngoff
=1
317 for i
in "$d/remotes"/*; do
318 echo ${i#$d/remotes/}
320 [ "$ngoff" ] && shopt -u nullglob
321 for i
in $
(git
--git-dir="$d" config
--get-regexp 'remote\..*\.url' 2>/dev
/null
); do
327 __git_merge_strategies
()
329 if [ -n "${__git_merge_strategylist-}" ]; then
330 echo "$__git_merge_strategylist"
333 git merge
-s help 2>&1 |
334 sed -n -e '/[Aa]vailable strategies are: /,/^$/{
342 __git_merge_strategylist
=
343 __git_merge_strategylist
=$
(__git_merge_strategies
2>/dev
/null
)
345 __git_complete_file
()
347 local pfx
ls ref cur
="${COMP_WORDS[COMP_CWORD]}"
364 case "$COMP_WORDBREAKS" in
366 *) pfx
="$ref:$pfx" ;;
370 COMPREPLY
=($
(compgen
-P "$pfx" \
371 -W "$(git --git-dir="$
(__gitdir
)" ls-tree "$ls" \
372 | sed '/^100... blob /{
388 __gitcomp
"$(__git_refs)"
393 __git_complete_revlist
()
395 local pfx cur
="${COMP_WORDS[COMP_CWORD]}"
400 __gitcomp
"$(__git_refs)" "$pfx" "$cur"
405 __gitcomp
"$(__git_refs)" "$pfx" "$cur"
408 __gitcomp
"$(__git_refs)"
413 __git_complete_remote_or_refspec
()
415 local cmd
="${COMP_WORDS[1]}"
416 local cur
="${COMP_WORDS[COMP_CWORD]}"
417 local i c
=2 remote
="" pfx
="" lhs
=1 no_complete_refspec
=0
418 while [ $c -lt $COMP_CWORD ]; do
421 --all|
--mirror) [ "$cmd" = "push" ] && no_complete_refspec
=1 ;;
423 *) remote
="$i"; break ;;
427 if [ -z "$remote" ]; then
428 __gitcomp
"$(__git_remotes)"
431 if [ $no_complete_refspec = 1 ]; then
435 [ "$remote" = "." ] && remote
=
438 case "$COMP_WORDBREAKS" in
440 *) pfx
="${cur%%:*}:" ;;
452 if [ $lhs = 1 ]; then
453 __gitcomp
"$(__git_refs2 "$remote")" "$pfx" "$cur"
455 __gitcomp
"$(__git_refs)" "$pfx" "$cur"
459 if [ $lhs = 1 ]; then
460 __gitcomp
"$(__git_refs "$remote")" "$pfx" "$cur"
462 __gitcomp
"$(__git_refs)" "$pfx" "$cur"
466 if [ $lhs = 1 ]; then
467 __gitcomp
"$(__git_refs)" "$pfx" "$cur"
469 __gitcomp
"$(__git_refs "$remote")" "$pfx" "$cur"
475 __git_complete_strategy
()
477 case "${COMP_WORDS[COMP_CWORD-1]}" in
479 __gitcomp
"$(__git_merge_strategies)"
482 local cur
="${COMP_WORDS[COMP_CWORD]}"
485 __gitcomp
"$(__git_merge_strategies)" "" "${cur##--strategy=}"
492 __git_all_commands
()
494 if [ -n "${__git_all_commandlist-}" ]; then
495 echo "$__git_all_commandlist"
499 for i
in $
(git
help -a|
egrep '^ ')
502 *--*) : helper pattern
;;
507 __git_all_commandlist
=
508 __git_all_commandlist
="$(__git_all_commands 2>/dev/null)"
510 __git_porcelain_commands
()
512 if [ -n "${__git_porcelain_commandlist-}" ]; then
513 echo "$__git_porcelain_commandlist"
517 for i
in "help" $
(__git_all_commands
)
520 *--*) : helper pattern
;;
521 applymbox
) : ask gittus
;;
522 applypatch
) : ask gittus
;;
523 archimport
) : import
;;
524 cat-file
) : plumbing
;;
525 check-attr
) : plumbing
;;
526 check-ref-format
) : plumbing
;;
527 checkout-index
) : plumbing
;;
528 commit-tree
) : plumbing
;;
529 count-objects
) : infrequent
;;
530 cvsexportcommit
) : export;;
531 cvsimport
) : import
;;
532 cvsserver
) : daemon
;;
534 diff-files
) : plumbing
;;
535 diff-index
) : plumbing
;;
536 diff-tree
) : plumbing
;;
537 fast-import
) : import
;;
538 fast-export
) : export;;
539 fsck-objects
) : plumbing
;;
540 fetch-pack
) : plumbing
;;
541 fmt-merge-msg
) : plumbing
;;
542 for-each-ref
) : plumbing
;;
543 hash-object
) : plumbing
;;
544 http-
*) : transport
;;
545 index-pack
) : plumbing
;;
546 init-db
) : deprecated
;;
547 local-fetch
) : plumbing
;;
548 lost-found
) : infrequent
;;
549 ls-files
) : plumbing
;;
550 ls-remote
) : plumbing
;;
551 ls-tree
) : plumbing
;;
552 mailinfo
) : plumbing
;;
553 mailsplit
) : plumbing
;;
554 merge-
*) : plumbing
;;
557 pack-objects
) : plumbing
;;
558 pack-redundant
) : plumbing
;;
559 pack-refs
) : plumbing
;;
560 parse-remote
) : plumbing
;;
561 patch-id
) : plumbing
;;
562 peek-remote
) : plumbing
;;
564 prune-packed
) : plumbing
;;
565 quiltimport
) : import
;;
566 read-tree
) : plumbing
;;
567 receive-pack
) : plumbing
;;
569 repo-config
) : deprecated
;;
571 rev-list
) : plumbing
;;
572 rev-parse
) : plumbing
;;
573 runstatus
) : plumbing
;;
574 sh-setup
) : internal
;;
576 show-ref
) : plumbing
;;
577 send-pack
) : plumbing
;;
578 show-index
) : plumbing
;;
580 stripspace
) : plumbing
;;
581 symbolic-ref
) : plumbing
;;
582 tar-tree
) : deprecated
;;
583 unpack-file
) : plumbing
;;
584 unpack-objects
) : plumbing
;;
585 update-index
) : plumbing
;;
586 update-ref
) : plumbing
;;
587 update-server-info
) : daemon
;;
588 upload-archive
) : plumbing
;;
589 upload-pack
) : plumbing
;;
590 write-tree
) : plumbing
;;
592 verify-pack
) : infrequent
;;
593 verify-tag
) : plumbing
;;
598 __git_porcelain_commandlist
=
599 __git_porcelain_commandlist
="$(__git_porcelain_commands 2>/dev/null)"
604 for i
in $
(git
--git-dir="$(__gitdir)" config
--get-regexp "alias\..*" 2>/dev
/null
); do
610 # __git_aliased_command requires 1 argument
611 __git_aliased_command
()
613 local word cmdline
=$
(git
--git-dir="$(__gitdir)" \
614 config
--get "alias.$1")
615 for word
in $cmdline; do
616 if [ "${word##-*}" ]; then
623 # __git_find_on_cmdline requires 1 argument
624 __git_find_on_cmdline
()
626 local word subcommand c
=1
628 while [ $c -lt $COMP_CWORD ]; do
629 word
="${COMP_WORDS[c]}"
630 for subcommand
in $1; do
631 if [ "$subcommand" = "$word" ]; then
640 __git_has_doubledash
()
643 while [ $c -lt $COMP_CWORD ]; do
644 if [ "--" = "${COMP_WORDS[c]}" ]; then
652 __git_whitespacelist
="nowarn warn error error-all fix"
656 local cur
="${COMP_WORDS[COMP_CWORD]}" dir
="$(__gitdir)"
657 if [ -d "$dir"/rebase-apply
]; then
658 __gitcomp
"--skip --resolved --abort"
663 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
668 --3way --committer-date-is-author-date --ignore-date
669 --ignore-whitespace --ignore-space-change
670 --interactive --keep --no-utf8 --signoff --utf8
671 --whitespace= --scissors
680 local cur
="${COMP_WORDS[COMP_CWORD]}"
683 __gitcomp
"$__git_whitespacelist" "" "${cur##--whitespace=}"
688 --stat --numstat --summary --check --index
689 --cached --index-info --reverse --reject --unidiff-zero
690 --apply --no-add --exclude=
691 --ignore-whitespace --ignore-space-change
692 --whitespace= --inaccurate-eof --verbose
701 __git_has_doubledash
&& return
703 local cur
="${COMP_WORDS[COMP_CWORD]}"
707 --interactive --refresh --patch --update --dry-run
708 --ignore-errors --intent-to-add
717 local cur
="${COMP_WORDS[COMP_CWORD]}"
720 __gitcomp
"$(git archive --list)" "" "${cur##--format=}"
724 __gitcomp
"$(__git_remotes)" "" "${cur##--remote=}"
729 --format= --list --verbose
730 --prefix= --remote= --exec=
740 __git_has_doubledash
&& return
742 local subcommands
="start bad good skip reset visualize replay log run"
743 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
744 if [ -z "$subcommand" ]; then
745 __gitcomp
"$subcommands"
749 case "$subcommand" in
751 __gitcomp
"$(__git_refs)"
761 local i c
=1 only_local_ref
="n" has_r
="n"
763 while [ $c -lt $COMP_CWORD ]; do
766 -d|
-m) only_local_ref
="y" ;;
772 case "${COMP_WORDS[COMP_CWORD]}" in
775 --color --no-color --verbose --abbrev= --no-abbrev
776 --track --no-track --contains --merged --no-merged
780 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
781 __gitcomp
"$(__git_heads)"
783 __gitcomp
"$(__git_refs)"
791 local cmd
="${COMP_WORDS[2]}"
792 case "$COMP_CWORD" in
794 __gitcomp
"create list-heads verify unbundle"
802 __git_complete_revlist
811 __git_has_doubledash
&& return
813 local cur
="${COMP_WORDS[COMP_CWORD]}"
816 __gitcomp
"diff3 merge" "" "${cur##--conflict=}"
820 --quiet --ours --theirs --track --no-track --merge
825 __gitcomp
"$(__git_refs)"
832 __gitcomp
"$(__git_refs)"
837 local cur
="${COMP_WORDS[COMP_CWORD]}"
840 __gitcomp
"--edit --no-commit"
843 __gitcomp
"$(__git_refs)"
850 __git_has_doubledash
&& return
852 local cur
="${COMP_WORDS[COMP_CWORD]}"
855 __gitcomp
"--dry-run --quiet"
864 local cur
="${COMP_WORDS[COMP_CWORD]}"
889 __git_has_doubledash
&& return
891 local cur
="${COMP_WORDS[COMP_CWORD]}"
895 --all --author= --signoff --verify --no-verify
896 --edit --amend --include --only --interactive
906 local cur
="${COMP_WORDS[COMP_CWORD]}"
910 --all --tags --contains --abbrev= --candidates=
911 --exact-match --debug --long --match --always
915 __gitcomp
"$(__git_refs)"
918 __git_diff_common_options
="--stat --numstat --shortstat --summary
919 --patch-with-stat --name-only --name-status --color
920 --no-color --color-words --no-renames --check
921 --full-index --binary --abbrev --diff-filter=
923 --text --ignore-space-at-eol --ignore-space-change
924 --ignore-all-space --exit-code --quiet --ext-diff
926 --no-prefix --src-prefix= --dst-prefix=
927 --inter-hunk-context=
930 --dirstat --dirstat= --dirstat-by-file
931 --dirstat-by-file= --cumulative
936 __git_has_doubledash
&& return
938 local cur
="${COMP_WORDS[COMP_CWORD]}"
941 __gitcomp
"--cached --staged --pickaxe-all --pickaxe-regex
942 --base --ours --theirs
943 $__git_diff_common_options
951 __git_mergetools_common
="diffuse ecmerge emerge kdiff3 meld opendiff
952 tkdiff vimdiff gvimdiff xxdiff araxis
957 local cur
="${COMP_WORDS[COMP_CWORD]}"
960 __gitcomp
"$__git_mergetools_common kompare" "" "${cur##--tool=}"
971 __git_fetch_options
="
972 --quiet --verbose --append --upload-pack --force --keep --depth=
978 local cur
="${COMP_WORDS[COMP_CWORD]}"
981 __gitcomp
"$__git_fetch_options"
985 __git_complete_remote_or_refspec
990 local cur
="${COMP_WORDS[COMP_CWORD]}"
995 " "" "${cur##--thread=}"
1000 --stdout --attach --no-attach --thread --thread=
1002 --numbered --start-number
1006 --in-reply-to= --cc=
1007 --full-index --binary
1010 --no-prefix --src-prefix= --dst-prefix=
1011 --inline --suffix= --ignore-if-in-upstream
1017 __git_complete_revlist
1022 local cur
="${COMP_WORDS[COMP_CWORD]}"
1026 --tags --root --unreachable --cache --no-reflogs --full
1027 --strict --verbose --lost-found
1037 local cur
="${COMP_WORDS[COMP_CWORD]}"
1040 __gitcomp
"--prune --aggressive"
1049 __git_has_doubledash
&& return
1051 local cur
="${COMP_WORDS[COMP_CWORD]}"
1056 --text --ignore-case --word-regexp --invert-match
1058 --extended-regexp --basic-regexp --fixed-strings
1059 --files-with-matches --name-only
1060 --files-without-match
1063 --and --or --not --all-match
1073 local cur
="${COMP_WORDS[COMP_CWORD]}"
1076 __gitcomp
"--all --info --man --web"
1080 __gitcomp
"$(__git_all_commands)
1081 attributes cli core-tutorial cvs-migration
1082 diffcore gitk glossary hooks ignore modules
1083 repository-layout tutorial tutorial-2
1090 local cur
="${COMP_WORDS[COMP_CWORD]}"
1094 false true umask group all world everybody
1095 " "" "${cur##--shared=}"
1099 __gitcomp
"--quiet --bare --template= --shared --shared="
1108 __git_has_doubledash
&& return
1110 local cur
="${COMP_WORDS[COMP_CWORD]}"
1113 __gitcomp
"--cached --deleted --modified --others --ignored
1114 --stage --directory --no-empty-directory --unmerged
1115 --killed --exclude= --exclude-from=
1116 --exclude-per-directory= --exclude-standard
1117 --error-unmatch --with-tree= --full-name
1118 --abbrev --ignored --exclude-per-directory
1128 __gitcomp
"$(__git_remotes)"
1136 # Options that go well for log, shortlog and gitk
1137 __git_log_common_options
="
1139 --branches --tags --remotes
1140 --first-parent --merges --no-merges
1142 --max-age= --since= --after=
1143 --min-age= --until= --before=
1145 # Options that go well for log and gitk (not shortlog)
1146 __git_log_gitk_options
="
1147 --dense --sparse --full-history
1148 --simplify-merges --simplify-by-decoration
1151 # Options that go well for log and shortlog (not gitk)
1152 __git_log_shortlog_options
="
1153 --author= --committer= --grep=
1157 __git_log_pretty_formats
="oneline short medium full fuller email raw format:"
1158 __git_log_date_formats
="relative iso8601 rfc2822 short local default raw"
1162 __git_has_doubledash
&& return
1164 local cur
="${COMP_WORDS[COMP_CWORD]}"
1165 local g
="$(git rev-parse --git-dir 2>/dev/null)"
1167 if [ -f "$g/MERGE_HEAD" ]; then
1172 __gitcomp
"$__git_log_pretty_formats
1173 " "" "${cur##--pretty=}"
1177 __gitcomp
"$__git_log_pretty_formats
1178 " "" "${cur##--format=}"
1182 __gitcomp
"$__git_log_date_formats" "" "${cur##--date=}"
1186 __gitcomp
"long short" "" "${cur##--decorate=}"
1191 $__git_log_common_options
1192 $__git_log_shortlog_options
1193 $__git_log_gitk_options
1194 --root --topo-order --date-order --reverse
1195 --follow --full-diff
1196 --abbrev-commit --abbrev=
1197 --relative-date --date=
1198 --pretty= --format= --oneline
1201 --decorate --decorate=
1203 --parents --children
1205 $__git_diff_common_options
1206 --pickaxe-all --pickaxe-regex
1211 __git_complete_revlist
1214 __git_merge_options
="
1215 --no-commit --no-stat --log --no-log --squash --strategy
1216 --commit --stat --no-squash --ff --no-ff
1221 __git_complete_strategy
&& return
1223 local cur
="${COMP_WORDS[COMP_CWORD]}"
1226 __gitcomp
"$__git_merge_options"
1229 __gitcomp
"$(__git_refs)"
1234 local cur
="${COMP_WORDS[COMP_CWORD]}"
1237 __gitcomp
"$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"
1250 __gitcomp
"$(__git_refs)"
1255 local cur
="${COMP_WORDS[COMP_CWORD]}"
1258 __gitcomp
"--dry-run"
1267 __gitcomp
"--tags --all --stdin"
1272 __git_complete_strategy
&& return
1274 local cur
="${COMP_WORDS[COMP_CWORD]}"
1278 --rebase --no-rebase
1279 $__git_merge_options
1280 $__git_fetch_options
1285 __git_complete_remote_or_refspec
1290 local cur
="${COMP_WORDS[COMP_CWORD]}"
1291 case "${COMP_WORDS[COMP_CWORD-1]}" in
1293 __gitcomp
"$(__git_remotes)"
1298 __gitcomp
"$(__git_remotes)" "" "${cur##--repo=}"
1303 --all --mirror --tags --dry-run --force --verbose
1304 --receive-pack= --repo=
1309 __git_complete_remote_or_refspec
1314 local cur
="${COMP_WORDS[COMP_CWORD]}" dir
="$(__gitdir)"
1315 if [ -d "$dir"/rebase-apply
] ||
[ -d "$dir"/rebase-merge
]; then
1316 __gitcomp
"--continue --skip --abort"
1319 __git_complete_strategy
&& return
1322 __gitcomp
"--onto --merge --strategy --interactive"
1325 __gitcomp
"$(__git_refs)"
1328 __git_send_email_confirm_options
="always never auto cc compose"
1329 __git_send_email_suppresscc_options
="author self cc bodycc sob cccmd body all"
1333 local cur
="${COMP_WORDS[COMP_CWORD]}"
1337 $__git_send_email_confirm_options
1338 " "" "${cur##--confirm=}"
1343 $__git_send_email_suppresscc_options
1344 " "" "${cur##--suppress-cc=}"
1348 --smtp-encryption=*)
1349 __gitcomp
"ssl tls" "" "${cur##--smtp-encryption=}"
1353 __gitcomp
"--annotate --bcc --cc --cc-cmd --chain-reply-to
1354 --compose --confirm= --dry-run --envelope-sender
1356 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
1357 --no-suppress-from --no-thread --quiet
1358 --signed-off-by-cc --smtp-pass --smtp-server
1359 --smtp-server-port --smtp-encryption= --smtp-user
1360 --subject --suppress-cc= --suppress-from --thread --to
1361 --validate --no-validate"
1368 __git_config_get_set_variables
()
1370 local prevword word config_file
= c
=$COMP_CWORD
1371 while [ $c -gt 1 ]; do
1372 word
="${COMP_WORDS[c]}"
1374 --global|
--system|
--file=*)
1379 config_file
="$word $prevword"
1387 git
--git-dir="$(__gitdir)" config
$config_file --list 2>/dev
/null |
1400 local cur
="${COMP_WORDS[COMP_CWORD]}"
1401 local prv
="${COMP_WORDS[COMP_CWORD-1]}"
1404 __gitcomp
"$(__git_remotes)"
1408 __gitcomp
"$(__git_refs)"
1412 local remote
="${prv#remote.}"
1413 remote
="${remote%.fetch}"
1414 __gitcomp
"$(__git_refs_remotes "$remote")"
1418 local remote
="${prv#remote.}"
1419 remote
="${remote%.push}"
1420 __gitcomp
"$(git --git-dir="$
(__gitdir
)" \
1421 for-each-ref --format='%(refname):%(refname)' \
1425 pull.twohead|pull.octopus
)
1426 __gitcomp
"$(__git_merge_strategies)"
1429 color.branch|color.
diff|color.interactive|\
1430 color.showbranch|color.status|color.ui
)
1431 __gitcomp
"always never auto"
1435 __gitcomp
"false true"
1440 normal black red green yellow blue magenta cyan white
1441 bold dim ul blink reverse
1446 __gitcomp
"man info web html"
1450 __gitcomp
"$__git_log_date_formats"
1453 sendemail.aliasesfiletype
)
1454 __gitcomp
"mutt mailrc pine elm gnus"
1458 __gitcomp
"$__git_send_email_confirm_options"
1461 sendemail.suppresscc
)
1462 __gitcomp
"$__git_send_email_suppresscc_options"
1465 --get|
--get-all|
--unset|
--unset-all)
1466 __gitcomp
"$(__git_config_get_set_variables)"
1477 --global --system --file=
1478 --list --replace-all
1479 --get --get-all --get-regexp
1480 --add --unset --unset-all
1481 --remove-section --rename-section
1486 local pfx
="${cur%.*}."
1488 __gitcomp
"remote merge mergeoptions rebase" "$pfx" "$cur"
1492 local pfx
="${cur%.*}."
1494 __gitcomp
"$(__git_heads)" "$pfx" "$cur" "."
1498 local pfx
="${cur%.*}."
1501 argprompt cmd confirm needsfile noconsole norescan
1502 prompt revprompt revunmerged title
1507 local pfx
="${cur%.*}."
1509 __gitcomp
"cmd path" "$pfx" "$cur"
1513 local pfx
="${cur%.*}."
1515 __gitcomp
"cmd path" "$pfx" "$cur"
1519 local pfx
="${cur%.*}."
1521 __gitcomp
"cmd path trustExitCode" "$pfx" "$cur"
1525 local pfx
="${cur%.*}."
1527 __gitcomp
"$(__git_all_commands)" "$pfx" "$cur"
1531 local pfx
="${cur%.*}."
1534 url proxy fetch push mirror skipDefaultUpdate
1535 receivepack uploadpack tagopt pushurl
1540 local pfx
="${cur%.*}."
1542 __gitcomp
"$(__git_remotes)" "$pfx" "$cur" "."
1546 local pfx
="${cur%.*}."
1548 __gitcomp
"insteadOf pushInsteadOf" "$pfx" "$cur"
1555 apply.ignorewhitespace
1557 branch.autosetupmerge
1558 branch.autosetuprebase
1561 color.branch.current
1572 color.diff.whitespace
1577 color.interactive.header
1578 color.interactive.help
1579 color.interactive.prompt
1584 color.status.changed
1586 color.status.nobranch
1587 color.status.untracked
1588 color.status.updated
1595 core.deltaBaseCacheLimit
1599 core.fsyncobjectfiles
1601 core.ignoreCygwinFSTricks
1603 core.logAllRefUpdates
1604 core.loosecompression
1606 core.packedGitWindowSize
1608 core.preferSymlinkRefs
1611 core.repositoryFormatVersion
1613 core.sharedRepository
1616 core.warnAmbiguousRefs
1619 diff.autorefreshindex
1625 diff.suppressBlankEmpty
1637 format.subjectprefix
1646 gc.reflogexpireunreachable
1650 gitcvs.commitmsgannotation
1651 gitcvs.dbTableNamePrefix
1662 gui.copyblamethreshold
1666 gui.matchtrackingbranch
1667 gui.newbranchtemplate
1668 gui.pruneduringfetch
1669 gui.spellingdictionary
1685 i18n.logOutputEncoding
1690 imap.preformattedHTML
1699 interactive.singlekey
1712 mergetool.keepBackup
1715 pack.deltaCacheLimit
1728 receive.denyCurrentBranch
1730 receive.denyNonFastForwards
1733 repack.usedeltabaseoffset
1736 sendemail.aliasesfile
1737 sendemail.aliasesfiletype
1741 sendemail.chainreplyto
1743 sendemail.envelopesender
1745 sendemail.signedoffbycc
1746 sendemail.smtpencryption
1748 sendemail.smtpserver
1749 sendemail.smtpserverport
1751 sendemail.suppresscc
1752 sendemail.suppressfrom
1757 status.relativePaths
1758 status.showUntrackedFiles
1760 transfer.unpackLimit
1772 local subcommands
="add rename rm show prune update set-head"
1773 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
1774 if [ -z "$subcommand" ]; then
1775 __gitcomp
"$subcommands"
1779 case "$subcommand" in
1780 rename|
rm|show|prune
)
1781 __gitcomp
"$(__git_remotes)"
1784 local i c
='' IFS
=$
'\n'
1785 for i
in $
(git
--git-dir="$(__gitdir)" config
--get-regexp "remotes\..*" 2>/dev
/null
); do
1799 __git_has_doubledash
&& return
1801 local cur
="${COMP_WORDS[COMP_CWORD]}"
1804 __gitcomp
"--merge --mixed --hard --soft --patch"
1808 __gitcomp
"$(__git_refs)"
1813 local cur
="${COMP_WORDS[COMP_CWORD]}"
1816 __gitcomp
"--edit --mainline --no-edit --no-commit --signoff"
1820 __gitcomp
"$(__git_refs)"
1825 __git_has_doubledash
&& return
1827 local cur
="${COMP_WORDS[COMP_CWORD]}"
1830 __gitcomp
"--cached --dry-run --ignore-unmatch --quiet"
1839 __git_has_doubledash
&& return
1841 local cur
="${COMP_WORDS[COMP_CWORD]}"
1845 $__git_log_common_options
1846 $__git_log_shortlog_options
1847 --numbered --summary
1852 __git_complete_revlist
1857 __git_has_doubledash
&& return
1859 local cur
="${COMP_WORDS[COMP_CWORD]}"
1862 __gitcomp
"$__git_log_pretty_formats
1863 " "" "${cur##--pretty=}"
1867 __gitcomp
"$__git_log_pretty_formats
1868 " "" "${cur##--format=}"
1872 __gitcomp
"--pretty= --format= --abbrev-commit --oneline
1873 $__git_diff_common_options
1883 local cur
="${COMP_WORDS[COMP_CWORD]}"
1887 --all --remotes --topo-order --current --more=
1888 --list --independent --merge-base --no-name
1890 --sha1-name --sparse --topics --reflog
1895 __git_complete_revlist
1900 local cur
="${COMP_WORDS[COMP_CWORD]}"
1901 local save_opts
='--keep-index --no-keep-index --quiet --patch'
1902 local subcommands
='save list show apply clear drop pop create branch'
1903 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
1904 if [ -z "$subcommand" ]; then
1907 __gitcomp
"$save_opts"
1910 if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then
1911 __gitcomp
"$subcommands"
1918 case "$subcommand,$cur" in
1920 __gitcomp
"$save_opts"
1923 __gitcomp
"--index --quiet"
1925 show
,--*|drop
,--*|branch
,--*)
1928 show
,*|apply
,*|drop
,*|pop
,*|branch
,*)
1929 __gitcomp
"$(git --git-dir="$
(__gitdir
)" stash list \
1930 | sed -n -e 's/:.*//p')"
1941 __git_has_doubledash
&& return
1943 local subcommands
="add status init update summary foreach sync"
1944 if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then
1945 local cur
="${COMP_WORDS[COMP_CWORD]}"
1948 __gitcomp
"--quiet --cached"
1951 __gitcomp
"$subcommands"
1961 init fetch clone rebase dcommit log find-rev
1962 set-tree commit-diff info create-ignore propget
1963 proplist show-ignore show-externals branch tag blame
1966 local subcommand
="$(__git_find_on_cmdline "$subcommands")"
1967 if [ -z "$subcommand" ]; then
1968 __gitcomp
"$subcommands"
1970 local remote_opts
="--username= --config-dir= --no-auth-cache"
1972 --follow-parent --authors-file= --repack=
1973 --no-metadata --use-svm-props --use-svnsync-props
1974 --log-window-size= --no-checkout --quiet
1975 --repack-flags --use-log-author --localtime
1976 --ignore-paths= $remote_opts
1979 --template= --shared= --trunk= --tags=
1980 --branches= --stdlayout --minimize-url
1981 --no-metadata --use-svm-props --use-svnsync-props
1982 --rewrite-root= --prefix= --use-log-author
1983 --add-author-from $remote_opts
1986 --edit --rmdir --find-copies-harder --copy-similarity=
1989 local cur
="${COMP_WORDS[COMP_CWORD]}"
1990 case "$subcommand,$cur" in
1992 __gitcomp
"--revision= --fetch-all $fc_opts"
1995 __gitcomp
"--revision= $fc_opts $init_opts"
1998 __gitcomp
"$init_opts"
2002 --merge --strategy= --verbose --dry-run
2003 --fetch-all --no-rebase --commit-url
2004 --revision $cmt_opts $fc_opts
2008 __gitcomp
"--stdin $cmt_opts $fc_opts"
2010 create-ignore
,--*|propget
,--*|proplist
,--*|show-ignore
,--*|\
2012 __gitcomp
"--revision="
2016 --limit= --revision= --verbose --incremental
2017 --oneline --show-commit --non-recursive
2018 --authors-file= --color
2023 --merge --verbose --strategy= --local
2024 --fetch-all --dry-run $fc_opts
2028 __gitcomp
"--message= --file= --revision= $cmt_opts"
2034 __gitcomp
"--dry-run --message --tag"
2037 __gitcomp
"--dry-run --message"
2040 __gitcomp
"--git-format"
2044 --config-dir= --ignore-paths= --minimize
2045 --no-auth-cache --username=
2058 while [ $c -lt $COMP_CWORD ]; do
2059 i
="${COMP_WORDS[c]}"
2062 __gitcomp
"$(__git_tags)"
2072 case "${COMP_WORDS[COMP_CWORD-1]}" in
2078 __gitcomp
"$(__git_tags)"
2084 __gitcomp
"$(__git_refs)"
2091 local i c
=1 command __git_dir
2093 while [ $c -lt $COMP_CWORD ]; do
2094 i
="${COMP_WORDS[c]}"
2096 --git-dir=*) __git_dir
="${i#--git-dir=}" ;;
2097 --bare) __git_dir
="." ;;
2098 --version|
-p|
--paginate) ;;
2099 --help) command="help"; break ;;
2100 *) command="$i"; break ;;
2105 if [ -z "$command" ]; then
2106 case "${COMP_WORDS[COMP_CWORD]}" in
2119 *) __gitcomp
"$(__git_porcelain_commands) $(__git_aliases)" ;;
2124 local expansion
=$
(__git_aliased_command
"$command")
2125 [ "$expansion" ] && command="$expansion"
2130 apply
) _git_apply
;;
2131 archive
) _git_archive
;;
2132 bisect
) _git_bisect
;;
2133 bundle
) _git_bundle
;;
2134 branch
) _git_branch
;;
2135 checkout
) _git_checkout
;;
2136 cherry
) _git_cherry
;;
2137 cherry-pick
) _git_cherry_pick
;;
2138 clean
) _git_clean
;;
2139 clone
) _git_clone
;;
2140 commit
) _git_commit
;;
2141 config
) _git_config
;;
2142 describe
) _git_describe
;;
2144 difftool
) _git_difftool
;;
2145 fetch
) _git_fetch
;;
2146 format-patch
) _git_format_patch
;;
2153 ls-files
) _git_ls_files
;;
2154 ls-remote
) _git_ls_remote
;;
2155 ls-tree
) _git_ls_tree
;;
2157 mergetool
) _git_mergetool
;;
2158 merge-base
) _git_merge_base
;;
2160 name-rev
) _git_name_rev
;;
2163 rebase
) _git_rebase
;;
2164 remote
) _git_remote
;;
2165 reset) _git_reset
;;
2166 revert
) _git_revert
;;
2168 send-email
) _git_send_email
;;
2169 shortlog
) _git_shortlog
;;
2171 show-branch
) _git_show_branch
;;
2172 stash
) _git_stash
;;
2174 submodule
) _git_submodule
;;
2177 whatchanged
) _git_log
;;
2184 __git_has_doubledash
&& return
2186 local cur
="${COMP_WORDS[COMP_CWORD]}"
2187 local g
="$(__gitdir)"
2189 if [ -f "$g/MERGE_HEAD" ]; then
2195 $__git_log_common_options
2196 $__git_log_gitk_options
2202 __git_complete_revlist
2205 complete
-o bashdefault
-o default
-o nospace
-F _git git
2>/dev
/null \
2206 || complete
-o default
-o nospace
-F _git git
2207 complete
-o bashdefault
-o default
-o nospace
-F _gitk gitk
2>/dev
/null \
2208 || complete
-o default
-o nospace
-F _gitk gitk
2210 # The following are necessary only for Cygwin, and only are needed
2211 # when the user has tab-completed the executable name and consequently
2212 # included the '.exe' suffix.
2214 if [ Cygwin
= "$(uname -o 2>/dev/null)" ]; then
2215 complete
-o bashdefault
-o default
-o nospace
-F _git git.exe
2>/dev
/null \
2216 || complete
-o default
-o nospace
-F _git git.exe