Merge branch 'sb/format-patch-signature'
[git/dscho.git] / contrib / completion / git-completion.bash
blob14874377afca6de0629814240086c64ff19df26d
1 #!bash
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) Consider changing your PS1 to also show the current branch:
25 # PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
27 # The argument to __git_ps1 will be displayed only if you
28 # are currently in a git repository. The %s token will be
29 # the name of the current branch.
31 # In addition, if you set GIT_PS1_SHOWDIRTYSTATE to a nonempty
32 # value, unstaged (*) and staged (+) changes will be shown next
33 # to the branch name. You can configure this per-repository
34 # with the bash.showDirtyState variable, which defaults to true
35 # once GIT_PS1_SHOWDIRTYSTATE is enabled.
37 # You can also see if currently something is stashed, by setting
38 # GIT_PS1_SHOWSTASHSTATE to a nonempty value. If something is stashed,
39 # then a '$' will be shown next to the branch name.
41 # If you would like to see if there're untracked files, then you can
42 # set GIT_PS1_SHOWUNTRACKEDFILES to a nonempty value. If there're
43 # untracked files, then a '%' will be shown next to the branch name.
45 # To submit patches:
47 # *) Read Documentation/SubmittingPatches
48 # *) Send all patches to the current maintainer:
50 # "Shawn O. Pearce" <spearce@spearce.org>
52 # *) Always CC the Git mailing list:
54 # git@vger.kernel.org
57 case "$COMP_WORDBREAKS" in
58 *:*) : great ;;
59 *) COMP_WORDBREAKS="$COMP_WORDBREAKS:"
60 esac
62 # __gitdir accepts 0 or 1 arguments (i.e., location)
63 # returns location of .git repo
64 __gitdir ()
66 if [ -z "${1-}" ]; then
67 if [ -n "${__git_dir-}" ]; then
68 echo "$__git_dir"
69 elif [ -d .git ]; then
70 echo .git
71 else
72 git rev-parse --git-dir 2>/dev/null
74 elif [ -d "$1/.git" ]; then
75 echo "$1/.git"
76 else
77 echo "$1"
81 # __git_ps1 accepts 0 or 1 arguments (i.e., format string)
82 # returns text to add to bash PS1 prompt (includes branch name)
83 __git_ps1 ()
85 local g="$(__gitdir)"
86 if [ -n "$g" ]; then
87 local r
88 local b
89 if [ -f "$g/rebase-merge/interactive" ]; then
90 r="|REBASE-i"
91 b="$(cat "$g/rebase-merge/head-name")"
92 elif [ -d "$g/rebase-merge" ]; then
93 r="|REBASE-m"
94 b="$(cat "$g/rebase-merge/head-name")"
95 else
96 if [ -d "$g/rebase-apply" ]; then
97 if [ -f "$g/rebase-apply/rebasing" ]; then
98 r="|REBASE"
99 elif [ -f "$g/rebase-apply/applying" ]; then
100 r="|AM"
101 else
102 r="|AM/REBASE"
104 elif [ -f "$g/MERGE_HEAD" ]; then
105 r="|MERGING"
106 elif [ -f "$g/BISECT_LOG" ]; then
107 r="|BISECTING"
110 b="$(git symbolic-ref HEAD 2>/dev/null)" || {
112 b="$(
113 case "${GIT_PS1_DESCRIBE_STYLE-}" in
114 (contains)
115 git describe --contains HEAD ;;
116 (branch)
117 git describe --contains --all HEAD ;;
118 (describe)
119 git describe HEAD ;;
120 (* | default)
121 git describe --exact-match HEAD ;;
122 esac 2>/dev/null)" ||
124 b="$(cut -c1-7 "$g/HEAD" 2>/dev/null)..." ||
125 b="unknown"
126 b="($b)"
130 local w
131 local i
132 local s
133 local u
134 local c
136 if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then
137 if [ "true" = "$(git rev-parse --is-bare-repository 2>/dev/null)" ]; then
138 c="BARE:"
139 else
140 b="GIT_DIR!"
142 elif [ "true" = "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
143 if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ]; then
144 if [ "$(git config --bool bash.showDirtyState)" != "false" ]; then
145 git diff --no-ext-diff --quiet --exit-code || w="*"
146 if git rev-parse --quiet --verify HEAD >/dev/null; then
147 git diff-index --cached --quiet HEAD -- || i="+"
148 else
149 i="#"
153 if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ]; then
154 git rev-parse --verify refs/stash >/dev/null 2>&1 && s="$"
157 if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ]; then
158 if [ -n "$(git ls-files --others --exclude-standard)" ]; then
159 u="%"
164 local f="$w$i$s$u"
165 printf "${1:- (%s)}" "$c${b##refs/heads/}${f:+ $f}$r"
169 # __gitcomp_1 requires 2 arguments
170 __gitcomp_1 ()
172 local c IFS=' '$'\t'$'\n'
173 for c in $1; do
174 case "$c$2" in
175 --*=*) printf %s$'\n' "$c$2" ;;
176 *.) printf %s$'\n' "$c$2" ;;
177 *) printf %s$'\n' "$c$2 " ;;
178 esac
179 done
182 # __gitcomp accepts 1, 2, 3, or 4 arguments
183 # generates completion reply with compgen
184 __gitcomp ()
186 local cur="${COMP_WORDS[COMP_CWORD]}"
187 if [ $# -gt 2 ]; then
188 cur="$3"
190 case "$cur" in
191 --*=)
192 COMPREPLY=()
195 local IFS=$'\n'
196 COMPREPLY=($(compgen -P "${2-}" \
197 -W "$(__gitcomp_1 "${1-}" "${4-}")" \
198 -- "$cur"))
200 esac
203 # __git_heads accepts 0 or 1 arguments (to pass to __gitdir)
204 __git_heads ()
206 local cmd i is_hash=y dir="$(__gitdir "${1-}")"
207 if [ -d "$dir" ]; then
208 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
209 refs/heads
210 return
212 for i in $(git ls-remote "${1-}" 2>/dev/null); do
213 case "$is_hash,$i" in
214 y,*) is_hash=n ;;
215 n,*^{}) is_hash=y ;;
216 n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
217 n,*) is_hash=y; echo "$i" ;;
218 esac
219 done
222 # __git_tags accepts 0 or 1 arguments (to pass to __gitdir)
223 __git_tags ()
225 local cmd i is_hash=y dir="$(__gitdir "${1-}")"
226 if [ -d "$dir" ]; then
227 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
228 refs/tags
229 return
231 for i in $(git ls-remote "${1-}" 2>/dev/null); do
232 case "$is_hash,$i" in
233 y,*) is_hash=n ;;
234 n,*^{}) is_hash=y ;;
235 n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
236 n,*) is_hash=y; echo "$i" ;;
237 esac
238 done
241 # __git_refs accepts 0 or 1 arguments (to pass to __gitdir)
242 __git_refs ()
244 local i is_hash=y dir="$(__gitdir "${1-}")"
245 local cur="${COMP_WORDS[COMP_CWORD]}" format refs
246 if [ -d "$dir" ]; then
247 case "$cur" in
248 refs|refs/*)
249 format="refname"
250 refs="${cur%/*}"
253 for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do
254 if [ -e "$dir/$i" ]; then echo $i; fi
255 done
256 format="refname:short"
257 refs="refs/tags refs/heads refs/remotes"
259 esac
260 git --git-dir="$dir" for-each-ref --format="%($format)" \
261 $refs
262 return
264 for i in $(git ls-remote "$dir" 2>/dev/null); do
265 case "$is_hash,$i" in
266 y,*) is_hash=n ;;
267 n,*^{}) is_hash=y ;;
268 n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
269 n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
270 n,refs/remotes/*) is_hash=y; echo "${i#refs/remotes/}" ;;
271 n,*) is_hash=y; echo "$i" ;;
272 esac
273 done
276 # __git_refs2 requires 1 argument (to pass to __git_refs)
277 __git_refs2 ()
279 local i
280 for i in $(__git_refs "$1"); do
281 echo "$i:$i"
282 done
285 # __git_refs_remotes requires 1 argument (to pass to ls-remote)
286 __git_refs_remotes ()
288 local cmd i is_hash=y
289 for i in $(git ls-remote "$1" 2>/dev/null); do
290 case "$is_hash,$i" in
291 n,refs/heads/*)
292 is_hash=y
293 echo "$i:refs/remotes/$1/${i#refs/heads/}"
295 y,*) is_hash=n ;;
296 n,*^{}) is_hash=y ;;
297 n,refs/tags/*) is_hash=y;;
298 n,*) is_hash=y; ;;
299 esac
300 done
303 __git_remotes ()
305 local i ngoff IFS=$'\n' d="$(__gitdir)"
306 shopt -q nullglob || ngoff=1
307 shopt -s nullglob
308 for i in "$d/remotes"/*; do
309 echo ${i#$d/remotes/}
310 done
311 [ "$ngoff" ] && shopt -u nullglob
312 for i in $(git --git-dir="$d" config --get-regexp 'remote\..*\.url' 2>/dev/null); do
313 i="${i#remote.}"
314 echo "${i/.url*/}"
315 done
318 __git_list_merge_strategies ()
320 git merge -s help 2>&1 |
321 sed -n -e '/[Aa]vailable strategies are: /,/^$/{
322 s/\.$//
323 s/.*://
324 s/^[ ]*//
325 s/[ ]*$//
330 __git_merge_strategies=
331 # 'git merge -s help' (and thus detection of the merge strategy
332 # list) fails, unfortunately, if run outside of any git working
333 # tree. __git_merge_strategies is set to the empty string in
334 # that case, and the detection will be repeated the next time it
335 # is needed.
336 __git_compute_merge_strategies ()
338 : ${__git_merge_strategies:=$(__git_list_merge_strategies)}
341 __git_complete_file ()
343 local pfx ls ref cur="${COMP_WORDS[COMP_CWORD]}"
344 case "$cur" in
345 ?*:*)
346 ref="${cur%%:*}"
347 cur="${cur#*:}"
348 case "$cur" in
349 ?*/*)
350 pfx="${cur%/*}"
351 cur="${cur##*/}"
352 ls="$ref:$pfx"
353 pfx="$pfx/"
356 ls="$ref"
358 esac
360 case "$COMP_WORDBREAKS" in
361 *:*) : great ;;
362 *) pfx="$ref:$pfx" ;;
363 esac
365 local IFS=$'\n'
366 COMPREPLY=($(compgen -P "$pfx" \
367 -W "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \
368 | sed '/^100... blob /{
369 s,^.* ,,
370 s,$, ,
372 /^120000 blob /{
373 s,^.* ,,
374 s,$, ,
376 /^040000 tree /{
377 s,^.* ,,
378 s,$,/,
380 s/^.* //')" \
381 -- "$cur"))
384 __gitcomp "$(__git_refs)"
386 esac
389 __git_complete_revlist ()
391 local pfx cur="${COMP_WORDS[COMP_CWORD]}"
392 case "$cur" in
393 *...*)
394 pfx="${cur%...*}..."
395 cur="${cur#*...}"
396 __gitcomp "$(__git_refs)" "$pfx" "$cur"
398 *..*)
399 pfx="${cur%..*}.."
400 cur="${cur#*..}"
401 __gitcomp "$(__git_refs)" "$pfx" "$cur"
404 __gitcomp "$(__git_refs)"
406 esac
409 __git_complete_remote_or_refspec ()
411 local cmd="${COMP_WORDS[1]}"
412 local cur="${COMP_WORDS[COMP_CWORD]}"
413 local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0
414 while [ $c -lt $COMP_CWORD ]; do
415 i="${COMP_WORDS[c]}"
416 case "$i" in
417 --mirror) [ "$cmd" = "push" ] && no_complete_refspec=1 ;;
418 --all)
419 case "$cmd" in
420 push) no_complete_refspec=1 ;;
421 fetch)
422 COMPREPLY=()
423 return
425 *) ;;
426 esac
428 -*) ;;
429 *) remote="$i"; break ;;
430 esac
431 c=$((++c))
432 done
433 if [ -z "$remote" ]; then
434 __gitcomp "$(__git_remotes)"
435 return
437 if [ $no_complete_refspec = 1 ]; then
438 COMPREPLY=()
439 return
441 [ "$remote" = "." ] && remote=
442 case "$cur" in
443 *:*)
444 case "$COMP_WORDBREAKS" in
445 *:*) : great ;;
446 *) pfx="${cur%%:*}:" ;;
447 esac
448 cur="${cur#*:}"
449 lhs=0
452 pfx="+"
453 cur="${cur#+}"
455 esac
456 case "$cmd" in
457 fetch)
458 if [ $lhs = 1 ]; then
459 __gitcomp "$(__git_refs2 "$remote")" "$pfx" "$cur"
460 else
461 __gitcomp "$(__git_refs)" "$pfx" "$cur"
464 pull)
465 if [ $lhs = 1 ]; then
466 __gitcomp "$(__git_refs "$remote")" "$pfx" "$cur"
467 else
468 __gitcomp "$(__git_refs)" "$pfx" "$cur"
471 push)
472 if [ $lhs = 1 ]; then
473 __gitcomp "$(__git_refs)" "$pfx" "$cur"
474 else
475 __gitcomp "$(__git_refs "$remote")" "$pfx" "$cur"
478 esac
481 __git_complete_strategy ()
483 __git_compute_merge_strategies
484 case "${COMP_WORDS[COMP_CWORD-1]}" in
485 -s|--strategy)
486 __gitcomp "$__git_merge_strategies"
487 return 0
488 esac
489 local cur="${COMP_WORDS[COMP_CWORD]}"
490 case "$cur" in
491 --strategy=*)
492 __gitcomp "$__git_merge_strategies" "" "${cur##--strategy=}"
493 return 0
495 esac
496 return 1
499 __git_list_all_commands ()
501 local i IFS=" "$'\n'
502 for i in $(git help -a|egrep '^ [a-zA-Z0-9]')
504 case $i in
505 *--*) : helper pattern;;
506 *) echo $i;;
507 esac
508 done
511 __git_all_commands=
512 __git_compute_all_commands ()
514 : ${__git_all_commands:=$(__git_list_all_commands)}
517 __git_list_porcelain_commands ()
519 local i IFS=" "$'\n'
520 __git_compute_all_commands
521 for i in "help" $__git_all_commands
523 case $i in
524 *--*) : helper pattern;;
525 applymbox) : ask gittus;;
526 applypatch) : ask gittus;;
527 archimport) : import;;
528 cat-file) : plumbing;;
529 check-attr) : plumbing;;
530 check-ref-format) : plumbing;;
531 checkout-index) : plumbing;;
532 commit-tree) : plumbing;;
533 count-objects) : infrequent;;
534 cvsexportcommit) : export;;
535 cvsimport) : import;;
536 cvsserver) : daemon;;
537 daemon) : daemon;;
538 diff-files) : plumbing;;
539 diff-index) : plumbing;;
540 diff-tree) : plumbing;;
541 fast-import) : import;;
542 fast-export) : export;;
543 fsck-objects) : plumbing;;
544 fetch-pack) : plumbing;;
545 fmt-merge-msg) : plumbing;;
546 for-each-ref) : plumbing;;
547 hash-object) : plumbing;;
548 http-*) : transport;;
549 index-pack) : plumbing;;
550 init-db) : deprecated;;
551 local-fetch) : plumbing;;
552 lost-found) : infrequent;;
553 ls-files) : plumbing;;
554 ls-remote) : plumbing;;
555 ls-tree) : plumbing;;
556 mailinfo) : plumbing;;
557 mailsplit) : plumbing;;
558 merge-*) : plumbing;;
559 mktree) : plumbing;;
560 mktag) : plumbing;;
561 pack-objects) : plumbing;;
562 pack-redundant) : plumbing;;
563 pack-refs) : plumbing;;
564 parse-remote) : plumbing;;
565 patch-id) : plumbing;;
566 peek-remote) : plumbing;;
567 prune) : plumbing;;
568 prune-packed) : plumbing;;
569 quiltimport) : import;;
570 read-tree) : plumbing;;
571 receive-pack) : plumbing;;
572 reflog) : plumbing;;
573 remote-*) : transport;;
574 repo-config) : deprecated;;
575 rerere) : plumbing;;
576 rev-list) : plumbing;;
577 rev-parse) : plumbing;;
578 runstatus) : plumbing;;
579 sh-setup) : internal;;
580 shell) : daemon;;
581 show-ref) : plumbing;;
582 send-pack) : plumbing;;
583 show-index) : plumbing;;
584 ssh-*) : transport;;
585 stripspace) : plumbing;;
586 symbolic-ref) : plumbing;;
587 tar-tree) : deprecated;;
588 unpack-file) : plumbing;;
589 unpack-objects) : plumbing;;
590 update-index) : plumbing;;
591 update-ref) : plumbing;;
592 update-server-info) : daemon;;
593 upload-archive) : plumbing;;
594 upload-pack) : plumbing;;
595 write-tree) : plumbing;;
596 var) : infrequent;;
597 verify-pack) : infrequent;;
598 verify-tag) : plumbing;;
599 *) echo $i;;
600 esac
601 done
604 __git_porcelain_commands=
605 __git_compute_porcelain_commands ()
607 __git_compute_all_commands
608 : ${__git_porcelain_commands:=$(__git_list_porcelain_commands)}
611 __git_aliases ()
613 local i IFS=$'\n'
614 for i in $(git --git-dir="$(__gitdir)" config --get-regexp "alias\..*" 2>/dev/null); do
615 case "$i" in
616 alias.*)
617 i="${i#alias.}"
618 echo "${i/ */}"
620 esac
621 done
624 # __git_aliased_command requires 1 argument
625 __git_aliased_command ()
627 local word cmdline=$(git --git-dir="$(__gitdir)" \
628 config --get "alias.$1")
629 for word in $cmdline; do
630 case "$word" in
631 \!gitk|gitk)
632 echo "gitk"
633 return
635 \!*) : shell command alias ;;
636 -*) : option ;;
637 *=*) : setting env ;;
638 git) : git itself ;;
640 echo "$word"
641 return
642 esac
643 done
646 # __git_find_on_cmdline requires 1 argument
647 __git_find_on_cmdline ()
649 local word subcommand c=1
651 while [ $c -lt $COMP_CWORD ]; do
652 word="${COMP_WORDS[c]}"
653 for subcommand in $1; do
654 if [ "$subcommand" = "$word" ]; then
655 echo "$subcommand"
656 return
658 done
659 c=$((++c))
660 done
663 __git_has_doubledash ()
665 local c=1
666 while [ $c -lt $COMP_CWORD ]; do
667 if [ "--" = "${COMP_WORDS[c]}" ]; then
668 return 0
670 c=$((++c))
671 done
672 return 1
675 __git_whitespacelist="nowarn warn error error-all fix"
677 _git_am ()
679 local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)"
680 if [ -d "$dir"/rebase-apply ]; then
681 __gitcomp "--skip --continue --resolved --abort"
682 return
684 case "$cur" in
685 --whitespace=*)
686 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
687 return
689 --*)
690 __gitcomp "
691 --3way --committer-date-is-author-date --ignore-date
692 --ignore-whitespace --ignore-space-change
693 --interactive --keep --no-utf8 --signoff --utf8
694 --whitespace= --scissors
696 return
697 esac
698 COMPREPLY=()
701 _git_apply ()
703 local cur="${COMP_WORDS[COMP_CWORD]}"
704 case "$cur" in
705 --whitespace=*)
706 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
707 return
709 --*)
710 __gitcomp "
711 --stat --numstat --summary --check --index
712 --cached --index-info --reverse --reject --unidiff-zero
713 --apply --no-add --exclude=
714 --ignore-whitespace --ignore-space-change
715 --whitespace= --inaccurate-eof --verbose
717 return
718 esac
719 COMPREPLY=()
722 _git_add ()
724 __git_has_doubledash && return
726 local cur="${COMP_WORDS[COMP_CWORD]}"
727 case "$cur" in
728 --*)
729 __gitcomp "
730 --interactive --refresh --patch --update --dry-run
731 --ignore-errors --intent-to-add
733 return
734 esac
735 COMPREPLY=()
738 _git_archive ()
740 local cur="${COMP_WORDS[COMP_CWORD]}"
741 case "$cur" in
742 --format=*)
743 __gitcomp "$(git archive --list)" "" "${cur##--format=}"
744 return
746 --remote=*)
747 __gitcomp "$(__git_remotes)" "" "${cur##--remote=}"
748 return
750 --*)
751 __gitcomp "
752 --format= --list --verbose
753 --prefix= --remote= --exec=
755 return
757 esac
758 __git_complete_file
761 _git_bisect ()
763 __git_has_doubledash && return
765 local subcommands="start bad good skip reset visualize replay log run"
766 local subcommand="$(__git_find_on_cmdline "$subcommands")"
767 if [ -z "$subcommand" ]; then
768 __gitcomp "$subcommands"
769 return
772 case "$subcommand" in
773 bad|good|reset|skip)
774 __gitcomp "$(__git_refs)"
777 COMPREPLY=()
779 esac
782 _git_branch ()
784 local i c=1 only_local_ref="n" has_r="n"
786 while [ $c -lt $COMP_CWORD ]; do
787 i="${COMP_WORDS[c]}"
788 case "$i" in
789 -d|-m) only_local_ref="y" ;;
790 -r) has_r="y" ;;
791 esac
792 c=$((++c))
793 done
795 case "${COMP_WORDS[COMP_CWORD]}" in
796 --*)
797 __gitcomp "
798 --color --no-color --verbose --abbrev= --no-abbrev
799 --track --no-track --contains --merged --no-merged
800 --set-upstream
804 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
805 __gitcomp "$(__git_heads)"
806 else
807 __gitcomp "$(__git_refs)"
810 esac
813 _git_bundle ()
815 local cmd="${COMP_WORDS[2]}"
816 case "$COMP_CWORD" in
818 __gitcomp "create list-heads verify unbundle"
821 # looking for a file
824 case "$cmd" in
825 create)
826 __git_complete_revlist
828 esac
830 esac
833 _git_checkout ()
835 __git_has_doubledash && return
837 local cur="${COMP_WORDS[COMP_CWORD]}"
838 case "$cur" in
839 --conflict=*)
840 __gitcomp "diff3 merge" "" "${cur##--conflict=}"
842 --*)
843 __gitcomp "
844 --quiet --ours --theirs --track --no-track --merge
845 --conflict= --orphan --patch
849 __gitcomp "$(__git_refs)"
851 esac
854 _git_cherry ()
856 __gitcomp "$(__git_refs)"
859 _git_cherry_pick ()
861 local cur="${COMP_WORDS[COMP_CWORD]}"
862 case "$cur" in
863 --*)
864 __gitcomp "--edit --no-commit"
867 __gitcomp "$(__git_refs)"
869 esac
872 _git_clean ()
874 __git_has_doubledash && return
876 local cur="${COMP_WORDS[COMP_CWORD]}"
877 case "$cur" in
878 --*)
879 __gitcomp "--dry-run --quiet"
880 return
882 esac
883 COMPREPLY=()
886 _git_clone ()
888 local cur="${COMP_WORDS[COMP_CWORD]}"
889 case "$cur" in
890 --*)
891 __gitcomp "
892 --local
893 --no-hardlinks
894 --shared
895 --reference
896 --quiet
897 --no-checkout
898 --bare
899 --mirror
900 --origin
901 --upload-pack
902 --template=
903 --depth
905 return
907 esac
908 COMPREPLY=()
911 _git_commit ()
913 __git_has_doubledash && return
915 local cur="${COMP_WORDS[COMP_CWORD]}"
916 case "$cur" in
917 --cleanup=*)
918 __gitcomp "default strip verbatim whitespace
919 " "" "${cur##--cleanup=}"
920 return
922 --reuse-message=*)
923 __gitcomp "$(__git_refs)" "" "${cur##--reuse-message=}"
924 return
926 --reedit-message=*)
927 __gitcomp "$(__git_refs)" "" "${cur##--reedit-message=}"
928 return
930 --untracked-files=*)
931 __gitcomp "all no normal" "" "${cur##--untracked-files=}"
932 return
934 --*)
935 __gitcomp "
936 --all --author= --signoff --verify --no-verify
937 --edit --amend --include --only --interactive
938 --dry-run --reuse-message= --reedit-message=
939 --reset-author --file= --message= --template=
940 --cleanup= --untracked-files --untracked-files=
941 --verbose --quiet
943 return
944 esac
945 COMPREPLY=()
948 _git_describe ()
950 local cur="${COMP_WORDS[COMP_CWORD]}"
951 case "$cur" in
952 --*)
953 __gitcomp "
954 --all --tags --contains --abbrev= --candidates=
955 --exact-match --debug --long --match --always
957 return
958 esac
959 __gitcomp "$(__git_refs)"
962 __git_diff_common_options="--stat --numstat --shortstat --summary
963 --patch-with-stat --name-only --name-status --color
964 --no-color --color-words --no-renames --check
965 --full-index --binary --abbrev --diff-filter=
966 --find-copies-harder
967 --text --ignore-space-at-eol --ignore-space-change
968 --ignore-all-space --exit-code --quiet --ext-diff
969 --no-ext-diff
970 --no-prefix --src-prefix= --dst-prefix=
971 --inter-hunk-context=
972 --patience
973 --raw
974 --dirstat --dirstat= --dirstat-by-file
975 --dirstat-by-file= --cumulative
978 _git_diff ()
980 __git_has_doubledash && return
982 local cur="${COMP_WORDS[COMP_CWORD]}"
983 case "$cur" in
984 --*)
985 __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
986 --base --ours --theirs
987 $__git_diff_common_options
989 return
991 esac
992 __git_complete_file
995 __git_mergetools_common="diffuse ecmerge emerge kdiff3 meld opendiff
996 tkdiff vimdiff gvimdiff xxdiff araxis p4merge
999 _git_difftool ()
1001 __git_has_doubledash && return
1003 local cur="${COMP_WORDS[COMP_CWORD]}"
1004 case "$cur" in
1005 --tool=*)
1006 __gitcomp "$__git_mergetools_common kompare" "" "${cur##--tool=}"
1007 return
1009 --*)
1010 __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
1011 --base --ours --theirs
1012 --no-renames --diff-filter= --find-copies-harder
1013 --relative --ignore-submodules
1014 --tool="
1015 return
1017 esac
1018 __git_complete_file
1021 __git_fetch_options="
1022 --quiet --verbose --append --upload-pack --force --keep --depth=
1023 --tags --no-tags --all --prune --dry-run
1026 _git_fetch ()
1028 local cur="${COMP_WORDS[COMP_CWORD]}"
1029 case "$cur" in
1030 --*)
1031 __gitcomp "$__git_fetch_options"
1032 return
1034 esac
1035 __git_complete_remote_or_refspec
1038 _git_format_patch ()
1040 local cur="${COMP_WORDS[COMP_CWORD]}"
1041 case "$cur" in
1042 --thread=*)
1043 __gitcomp "
1044 deep shallow
1045 " "" "${cur##--thread=}"
1046 return
1048 --*)
1049 __gitcomp "
1050 --stdout --attach --no-attach --thread --thread=
1051 --output-directory
1052 --numbered --start-number
1053 --numbered-files
1054 --keep-subject
1055 --signoff --signature --no-signature
1056 --in-reply-to= --cc=
1057 --full-index --binary
1058 --not --all
1059 --cover-letter
1060 --no-prefix --src-prefix= --dst-prefix=
1061 --inline --suffix= --ignore-if-in-upstream
1062 --subject-prefix=
1064 return
1066 esac
1067 __git_complete_revlist
1070 _git_fsck ()
1072 local cur="${COMP_WORDS[COMP_CWORD]}"
1073 case "$cur" in
1074 --*)
1075 __gitcomp "
1076 --tags --root --unreachable --cache --no-reflogs --full
1077 --strict --verbose --lost-found
1079 return
1081 esac
1082 COMPREPLY=()
1085 _git_gc ()
1087 local cur="${COMP_WORDS[COMP_CWORD]}"
1088 case "$cur" in
1089 --*)
1090 __gitcomp "--prune --aggressive"
1091 return
1093 esac
1094 COMPREPLY=()
1097 _git_gitk ()
1099 _gitk
1102 _git_grep ()
1104 __git_has_doubledash && return
1106 local cur="${COMP_WORDS[COMP_CWORD]}"
1107 case "$cur" in
1108 --*)
1109 __gitcomp "
1110 --cached
1111 --text --ignore-case --word-regexp --invert-match
1112 --full-name
1113 --extended-regexp --basic-regexp --fixed-strings
1114 --files-with-matches --name-only
1115 --files-without-match
1116 --max-depth
1117 --count
1118 --and --or --not --all-match
1120 return
1122 esac
1124 __gitcomp "$(__git_refs)"
1127 _git_help ()
1129 local cur="${COMP_WORDS[COMP_CWORD]}"
1130 case "$cur" in
1131 --*)
1132 __gitcomp "--all --info --man --web"
1133 return
1135 esac
1136 __git_compute_all_commands
1137 __gitcomp "$__git_all_commands
1138 attributes cli core-tutorial cvs-migration
1139 diffcore gitk glossary hooks ignore modules
1140 repository-layout tutorial tutorial-2
1141 workflows
1145 _git_init ()
1147 local cur="${COMP_WORDS[COMP_CWORD]}"
1148 case "$cur" in
1149 --shared=*)
1150 __gitcomp "
1151 false true umask group all world everybody
1152 " "" "${cur##--shared=}"
1153 return
1155 --*)
1156 __gitcomp "--quiet --bare --template= --shared --shared="
1157 return
1159 esac
1160 COMPREPLY=()
1163 _git_ls_files ()
1165 __git_has_doubledash && return
1167 local cur="${COMP_WORDS[COMP_CWORD]}"
1168 case "$cur" in
1169 --*)
1170 __gitcomp "--cached --deleted --modified --others --ignored
1171 --stage --directory --no-empty-directory --unmerged
1172 --killed --exclude= --exclude-from=
1173 --exclude-per-directory= --exclude-standard
1174 --error-unmatch --with-tree= --full-name
1175 --abbrev --ignored --exclude-per-directory
1177 return
1179 esac
1180 COMPREPLY=()
1183 _git_ls_remote ()
1185 __gitcomp "$(__git_remotes)"
1188 _git_ls_tree ()
1190 __git_complete_file
1193 # Options that go well for log, shortlog and gitk
1194 __git_log_common_options="
1195 --not --all
1196 --branches --tags --remotes
1197 --first-parent --merges --no-merges
1198 --max-count=
1199 --max-age= --since= --after=
1200 --min-age= --until= --before=
1202 # Options that go well for log and gitk (not shortlog)
1203 __git_log_gitk_options="
1204 --dense --sparse --full-history
1205 --simplify-merges --simplify-by-decoration
1206 --left-right
1208 # Options that go well for log and shortlog (not gitk)
1209 __git_log_shortlog_options="
1210 --author= --committer= --grep=
1211 --all-match
1214 __git_log_pretty_formats="oneline short medium full fuller email raw format:"
1215 __git_log_date_formats="relative iso8601 rfc2822 short local default raw"
1217 _git_log ()
1219 __git_has_doubledash && return
1221 local cur="${COMP_WORDS[COMP_CWORD]}"
1222 local g="$(git rev-parse --git-dir 2>/dev/null)"
1223 local merge=""
1224 if [ -f "$g/MERGE_HEAD" ]; then
1225 merge="--merge"
1227 case "$cur" in
1228 --pretty=*)
1229 __gitcomp "$__git_log_pretty_formats
1230 " "" "${cur##--pretty=}"
1231 return
1233 --format=*)
1234 __gitcomp "$__git_log_pretty_formats
1235 " "" "${cur##--format=}"
1236 return
1238 --date=*)
1239 __gitcomp "$__git_log_date_formats" "" "${cur##--date=}"
1240 return
1242 --decorate=*)
1243 __gitcomp "long short" "" "${cur##--decorate=}"
1244 return
1246 --*)
1247 __gitcomp "
1248 $__git_log_common_options
1249 $__git_log_shortlog_options
1250 $__git_log_gitk_options
1251 --root --topo-order --date-order --reverse
1252 --follow --full-diff
1253 --abbrev-commit --abbrev=
1254 --relative-date --date=
1255 --pretty= --format= --oneline
1256 --cherry-pick
1257 --graph
1258 --decorate --decorate=
1259 --walk-reflogs
1260 --parents --children
1261 $merge
1262 $__git_diff_common_options
1263 --pickaxe-all --pickaxe-regex
1265 return
1267 esac
1268 __git_complete_revlist
1271 __git_merge_options="
1272 --no-commit --no-stat --log --no-log --squash --strategy
1273 --commit --stat --no-squash --ff --no-ff --ff-only
1276 _git_merge ()
1278 __git_complete_strategy && return
1280 local cur="${COMP_WORDS[COMP_CWORD]}"
1281 case "$cur" in
1282 --*)
1283 __gitcomp "$__git_merge_options"
1284 return
1285 esac
1286 __gitcomp "$(__git_refs)"
1289 _git_mergetool ()
1291 local cur="${COMP_WORDS[COMP_CWORD]}"
1292 case "$cur" in
1293 --tool=*)
1294 __gitcomp "$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"
1295 return
1297 --*)
1298 __gitcomp "--tool="
1299 return
1301 esac
1302 COMPREPLY=()
1305 _git_merge_base ()
1307 __gitcomp "$(__git_refs)"
1310 _git_mv ()
1312 local cur="${COMP_WORDS[COMP_CWORD]}"
1313 case "$cur" in
1314 --*)
1315 __gitcomp "--dry-run"
1316 return
1318 esac
1319 COMPREPLY=()
1322 _git_name_rev ()
1324 __gitcomp "--tags --all --stdin"
1327 _git_notes ()
1329 local subcommands="edit show"
1330 if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then
1331 __gitcomp "$subcommands"
1332 return
1335 case "${COMP_WORDS[COMP_CWORD-1]}" in
1336 -m|-F)
1337 COMPREPLY=()
1340 __gitcomp "$(__git_refs)"
1342 esac
1345 _git_pull ()
1347 __git_complete_strategy && return
1349 local cur="${COMP_WORDS[COMP_CWORD]}"
1350 case "$cur" in
1351 --*)
1352 __gitcomp "
1353 --rebase --no-rebase
1354 $__git_merge_options
1355 $__git_fetch_options
1357 return
1359 esac
1360 __git_complete_remote_or_refspec
1363 _git_push ()
1365 local cur="${COMP_WORDS[COMP_CWORD]}"
1366 case "${COMP_WORDS[COMP_CWORD-1]}" in
1367 --repo)
1368 __gitcomp "$(__git_remotes)"
1369 return
1370 esac
1371 case "$cur" in
1372 --repo=*)
1373 __gitcomp "$(__git_remotes)" "" "${cur##--repo=}"
1374 return
1376 --*)
1377 __gitcomp "
1378 --all --mirror --tags --dry-run --force --verbose
1379 --receive-pack= --repo=
1381 return
1383 esac
1384 __git_complete_remote_or_refspec
1387 _git_rebase ()
1389 local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)"
1390 if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
1391 __gitcomp "--continue --skip --abort"
1392 return
1394 __git_complete_strategy && return
1395 case "$cur" in
1396 --whitespace=*)
1397 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
1398 return
1400 --*)
1401 __gitcomp "
1402 --onto --merge --strategy --interactive
1403 --preserve-merges --stat --no-stat
1404 --committer-date-is-author-date --ignore-date
1405 --ignore-whitespace --whitespace=
1406 --autosquash
1409 return
1410 esac
1411 __gitcomp "$(__git_refs)"
1414 __git_send_email_confirm_options="always never auto cc compose"
1415 __git_send_email_suppresscc_options="author self cc bodycc sob cccmd body all"
1417 _git_send_email ()
1419 local cur="${COMP_WORDS[COMP_CWORD]}"
1420 case "$cur" in
1421 --confirm=*)
1422 __gitcomp "
1423 $__git_send_email_confirm_options
1424 " "" "${cur##--confirm=}"
1425 return
1427 --suppress-cc=*)
1428 __gitcomp "
1429 $__git_send_email_suppresscc_options
1430 " "" "${cur##--suppress-cc=}"
1432 return
1434 --smtp-encryption=*)
1435 __gitcomp "ssl tls" "" "${cur##--smtp-encryption=}"
1436 return
1438 --*)
1439 __gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to
1440 --compose --confirm= --dry-run --envelope-sender
1441 --from --identity
1442 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
1443 --no-suppress-from --no-thread --quiet
1444 --signed-off-by-cc --smtp-pass --smtp-server
1445 --smtp-server-port --smtp-encryption= --smtp-user
1446 --subject --suppress-cc= --suppress-from --thread --to
1447 --validate --no-validate"
1448 return
1450 esac
1451 COMPREPLY=()
1454 _git_stage ()
1456 _git_add
1459 __git_config_get_set_variables ()
1461 local prevword word config_file= c=$COMP_CWORD
1462 while [ $c -gt 1 ]; do
1463 word="${COMP_WORDS[c]}"
1464 case "$word" in
1465 --global|--system|--file=*)
1466 config_file="$word"
1467 break
1469 -f|--file)
1470 config_file="$word $prevword"
1471 break
1473 esac
1474 prevword=$word
1475 c=$((--c))
1476 done
1478 git --git-dir="$(__gitdir)" config $config_file --list 2>/dev/null |
1479 while read line
1481 case "$line" in
1482 *.*=*)
1483 echo "${line/=*/}"
1485 esac
1486 done
1489 _git_config ()
1491 local cur="${COMP_WORDS[COMP_CWORD]}"
1492 local prv="${COMP_WORDS[COMP_CWORD-1]}"
1493 case "$prv" in
1494 branch.*.remote)
1495 __gitcomp "$(__git_remotes)"
1496 return
1498 branch.*.merge)
1499 __gitcomp "$(__git_refs)"
1500 return
1502 remote.*.fetch)
1503 local remote="${prv#remote.}"
1504 remote="${remote%.fetch}"
1505 __gitcomp "$(__git_refs_remotes "$remote")"
1506 return
1508 remote.*.push)
1509 local remote="${prv#remote.}"
1510 remote="${remote%.push}"
1511 __gitcomp "$(git --git-dir="$(__gitdir)" \
1512 for-each-ref --format='%(refname):%(refname)' \
1513 refs/heads)"
1514 return
1516 pull.twohead|pull.octopus)
1517 __git_compute_merge_strategies
1518 __gitcomp "$__git_merge_strategies"
1519 return
1521 color.branch|color.diff|color.interactive|\
1522 color.showbranch|color.status|color.ui)
1523 __gitcomp "always never auto"
1524 return
1526 color.pager)
1527 __gitcomp "false true"
1528 return
1530 color.*.*)
1531 __gitcomp "
1532 normal black red green yellow blue magenta cyan white
1533 bold dim ul blink reverse
1535 return
1537 help.format)
1538 __gitcomp "man info web html"
1539 return
1541 log.date)
1542 __gitcomp "$__git_log_date_formats"
1543 return
1545 sendemail.aliasesfiletype)
1546 __gitcomp "mutt mailrc pine elm gnus"
1547 return
1549 sendemail.confirm)
1550 __gitcomp "$__git_send_email_confirm_options"
1551 return
1553 sendemail.suppresscc)
1554 __gitcomp "$__git_send_email_suppresscc_options"
1555 return
1557 --get|--get-all|--unset|--unset-all)
1558 __gitcomp "$(__git_config_get_set_variables)"
1559 return
1561 *.*)
1562 COMPREPLY=()
1563 return
1565 esac
1566 case "$cur" in
1567 --*)
1568 __gitcomp "
1569 --global --system --file=
1570 --list --replace-all
1571 --get --get-all --get-regexp
1572 --add --unset --unset-all
1573 --remove-section --rename-section
1575 return
1577 branch.*.*)
1578 local pfx="${cur%.*}."
1579 cur="${cur##*.}"
1580 __gitcomp "remote merge mergeoptions rebase" "$pfx" "$cur"
1581 return
1583 branch.*)
1584 local pfx="${cur%.*}."
1585 cur="${cur#*.}"
1586 __gitcomp "$(__git_heads)" "$pfx" "$cur" "."
1587 return
1589 guitool.*.*)
1590 local pfx="${cur%.*}."
1591 cur="${cur##*.}"
1592 __gitcomp "
1593 argprompt cmd confirm needsfile noconsole norescan
1594 prompt revprompt revunmerged title
1595 " "$pfx" "$cur"
1596 return
1598 difftool.*.*)
1599 local pfx="${cur%.*}."
1600 cur="${cur##*.}"
1601 __gitcomp "cmd path" "$pfx" "$cur"
1602 return
1604 man.*.*)
1605 local pfx="${cur%.*}."
1606 cur="${cur##*.}"
1607 __gitcomp "cmd path" "$pfx" "$cur"
1608 return
1610 mergetool.*.*)
1611 local pfx="${cur%.*}."
1612 cur="${cur##*.}"
1613 __gitcomp "cmd path trustExitCode" "$pfx" "$cur"
1614 return
1616 pager.*)
1617 local pfx="${cur%.*}."
1618 cur="${cur#*.}"
1619 __git_compute_all_commands
1620 __gitcomp "$__git_all_commands" "$pfx" "$cur"
1621 return
1623 remote.*.*)
1624 local pfx="${cur%.*}."
1625 cur="${cur##*.}"
1626 __gitcomp "
1627 url proxy fetch push mirror skipDefaultUpdate
1628 receivepack uploadpack tagopt pushurl
1629 " "$pfx" "$cur"
1630 return
1632 remote.*)
1633 local pfx="${cur%.*}."
1634 cur="${cur#*.}"
1635 __gitcomp "$(__git_remotes)" "$pfx" "$cur" "."
1636 return
1638 url.*.*)
1639 local pfx="${cur%.*}."
1640 cur="${cur##*.}"
1641 __gitcomp "insteadOf pushInsteadOf" "$pfx" "$cur"
1642 return
1644 esac
1645 __gitcomp "
1646 add.ignore-errors
1647 alias.
1648 apply.ignorewhitespace
1649 apply.whitespace
1650 branch.autosetupmerge
1651 branch.autosetuprebase
1652 clean.requireForce
1653 color.branch
1654 color.branch.current
1655 color.branch.local
1656 color.branch.plain
1657 color.branch.remote
1658 color.diff
1659 color.diff.commit
1660 color.diff.frag
1661 color.diff.meta
1662 color.diff.new
1663 color.diff.old
1664 color.diff.plain
1665 color.diff.whitespace
1666 color.grep
1667 color.grep.external
1668 color.grep.match
1669 color.interactive
1670 color.interactive.header
1671 color.interactive.help
1672 color.interactive.prompt
1673 color.pager
1674 color.showbranch
1675 color.status
1676 color.status.added
1677 color.status.changed
1678 color.status.header
1679 color.status.nobranch
1680 color.status.untracked
1681 color.status.updated
1682 color.ui
1683 commit.template
1684 core.autocrlf
1685 core.bare
1686 core.compression
1687 core.createObject
1688 core.deltaBaseCacheLimit
1689 core.editor
1690 core.excludesfile
1691 core.fileMode
1692 core.fsyncobjectfiles
1693 core.gitProxy
1694 core.ignoreCygwinFSTricks
1695 core.ignoreStat
1696 core.logAllRefUpdates
1697 core.loosecompression
1698 core.packedGitLimit
1699 core.packedGitWindowSize
1700 core.pager
1701 core.preferSymlinkRefs
1702 core.preloadindex
1703 core.quotepath
1704 core.repositoryFormatVersion
1705 core.safecrlf
1706 core.sharedRepository
1707 core.symlinks
1708 core.trustctime
1709 core.warnAmbiguousRefs
1710 core.whitespace
1711 core.worktree
1712 diff.autorefreshindex
1713 diff.external
1714 diff.mnemonicprefix
1715 diff.renameLimit
1716 diff.renameLimit.
1717 diff.renames
1718 diff.suppressBlankEmpty
1719 diff.tool
1720 diff.wordRegex
1721 difftool.
1722 difftool.prompt
1723 fetch.unpackLimit
1724 format.attach
1725 format.cc
1726 format.headers
1727 format.numbered
1728 format.pretty
1729 format.signature
1730 format.signoff
1731 format.subjectprefix
1732 format.suffix
1733 format.thread
1734 gc.aggressiveWindow
1735 gc.auto
1736 gc.autopacklimit
1737 gc.packrefs
1738 gc.pruneexpire
1739 gc.reflogexpire
1740 gc.reflogexpireunreachable
1741 gc.rerereresolved
1742 gc.rerereunresolved
1743 gitcvs.allbinary
1744 gitcvs.commitmsgannotation
1745 gitcvs.dbTableNamePrefix
1746 gitcvs.dbdriver
1747 gitcvs.dbname
1748 gitcvs.dbpass
1749 gitcvs.dbuser
1750 gitcvs.enabled
1751 gitcvs.logfile
1752 gitcvs.usecrlfattr
1753 guitool.
1754 gui.blamehistoryctx
1755 gui.commitmsgwidth
1756 gui.copyblamethreshold
1757 gui.diffcontext
1758 gui.encoding
1759 gui.fastcopyblame
1760 gui.matchtrackingbranch
1761 gui.newbranchtemplate
1762 gui.pruneduringfetch
1763 gui.spellingdictionary
1764 gui.trustmtime
1765 help.autocorrect
1766 help.browser
1767 help.format
1768 http.lowSpeedLimit
1769 http.lowSpeedTime
1770 http.maxRequests
1771 http.noEPSV
1772 http.proxy
1773 http.sslCAInfo
1774 http.sslCAPath
1775 http.sslCert
1776 http.sslKey
1777 http.sslVerify
1778 i18n.commitEncoding
1779 i18n.logOutputEncoding
1780 imap.folder
1781 imap.host
1782 imap.pass
1783 imap.port
1784 imap.preformattedHTML
1785 imap.sslverify
1786 imap.tunnel
1787 imap.user
1788 instaweb.browser
1789 instaweb.httpd
1790 instaweb.local
1791 instaweb.modulepath
1792 instaweb.port
1793 interactive.singlekey
1794 log.date
1795 log.showroot
1796 mailmap.file
1797 man.
1798 man.viewer
1799 merge.conflictstyle
1800 merge.log
1801 merge.renameLimit
1802 merge.stat
1803 merge.tool
1804 merge.verbosity
1805 mergetool.
1806 mergetool.keepBackup
1807 mergetool.prompt
1808 pack.compression
1809 pack.deltaCacheLimit
1810 pack.deltaCacheSize
1811 pack.depth
1812 pack.indexVersion
1813 pack.packSizeLimit
1814 pack.threads
1815 pack.window
1816 pack.windowMemory
1817 pager.
1818 pull.octopus
1819 pull.twohead
1820 push.default
1821 rebase.stat
1822 receive.denyCurrentBranch
1823 receive.denyDeletes
1824 receive.denyNonFastForwards
1825 receive.fsckObjects
1826 receive.unpackLimit
1827 repack.usedeltabaseoffset
1828 rerere.autoupdate
1829 rerere.enabled
1830 sendemail.aliasesfile
1831 sendemail.aliasesfiletype
1832 sendemail.bcc
1833 sendemail.cc
1834 sendemail.cccmd
1835 sendemail.chainreplyto
1836 sendemail.confirm
1837 sendemail.envelopesender
1838 sendemail.multiedit
1839 sendemail.signedoffbycc
1840 sendemail.smtpencryption
1841 sendemail.smtppass
1842 sendemail.smtpserver
1843 sendemail.smtpserverport
1844 sendemail.smtpuser
1845 sendemail.suppresscc
1846 sendemail.suppressfrom
1847 sendemail.thread
1848 sendemail.to
1849 sendemail.validate
1850 showbranch.default
1851 status.relativePaths
1852 status.showUntrackedFiles
1853 tar.umask
1854 transfer.unpackLimit
1855 url.
1856 user.email
1857 user.name
1858 user.signingkey
1859 web.browser
1860 branch. remote.
1864 _git_remote ()
1866 local subcommands="add rename rm show prune update set-head"
1867 local subcommand="$(__git_find_on_cmdline "$subcommands")"
1868 if [ -z "$subcommand" ]; then
1869 __gitcomp "$subcommands"
1870 return
1873 case "$subcommand" in
1874 rename|rm|show|prune)
1875 __gitcomp "$(__git_remotes)"
1877 update)
1878 local i c='' IFS=$'\n'
1879 for i in $(git --git-dir="$(__gitdir)" config --get-regexp "remotes\..*" 2>/dev/null); do
1880 i="${i#remotes.}"
1881 c="$c ${i/ */}"
1882 done
1883 __gitcomp "$c"
1886 COMPREPLY=()
1888 esac
1891 _git_replace ()
1893 __gitcomp "$(__git_refs)"
1896 _git_reset ()
1898 __git_has_doubledash && return
1900 local cur="${COMP_WORDS[COMP_CWORD]}"
1901 case "$cur" in
1902 --*)
1903 __gitcomp "--merge --mixed --hard --soft --patch"
1904 return
1906 esac
1907 __gitcomp "$(__git_refs)"
1910 _git_revert ()
1912 local cur="${COMP_WORDS[COMP_CWORD]}"
1913 case "$cur" in
1914 --*)
1915 __gitcomp "--edit --mainline --no-edit --no-commit --signoff"
1916 return
1918 esac
1919 __gitcomp "$(__git_refs)"
1922 _git_rm ()
1924 __git_has_doubledash && return
1926 local cur="${COMP_WORDS[COMP_CWORD]}"
1927 case "$cur" in
1928 --*)
1929 __gitcomp "--cached --dry-run --ignore-unmatch --quiet"
1930 return
1932 esac
1933 COMPREPLY=()
1936 _git_shortlog ()
1938 __git_has_doubledash && return
1940 local cur="${COMP_WORDS[COMP_CWORD]}"
1941 case "$cur" in
1942 --*)
1943 __gitcomp "
1944 $__git_log_common_options
1945 $__git_log_shortlog_options
1946 --numbered --summary
1948 return
1950 esac
1951 __git_complete_revlist
1954 _git_show ()
1956 __git_has_doubledash && return
1958 local cur="${COMP_WORDS[COMP_CWORD]}"
1959 case "$cur" in
1960 --pretty=*)
1961 __gitcomp "$__git_log_pretty_formats
1962 " "" "${cur##--pretty=}"
1963 return
1965 --format=*)
1966 __gitcomp "$__git_log_pretty_formats
1967 " "" "${cur##--format=}"
1968 return
1970 --*)
1971 __gitcomp "--pretty= --format= --abbrev-commit --oneline
1972 $__git_diff_common_options
1974 return
1976 esac
1977 __git_complete_file
1980 _git_show_branch ()
1982 local cur="${COMP_WORDS[COMP_CWORD]}"
1983 case "$cur" in
1984 --*)
1985 __gitcomp "
1986 --all --remotes --topo-order --current --more=
1987 --list --independent --merge-base --no-name
1988 --color --no-color
1989 --sha1-name --sparse --topics --reflog
1991 return
1993 esac
1994 __git_complete_revlist
1997 _git_stash ()
1999 local cur="${COMP_WORDS[COMP_CWORD]}"
2000 local save_opts='--keep-index --no-keep-index --quiet --patch'
2001 local subcommands='save list show apply clear drop pop create branch'
2002 local subcommand="$(__git_find_on_cmdline "$subcommands")"
2003 if [ -z "$subcommand" ]; then
2004 case "$cur" in
2005 --*)
2006 __gitcomp "$save_opts"
2009 if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then
2010 __gitcomp "$subcommands"
2011 else
2012 COMPREPLY=()
2015 esac
2016 else
2017 case "$subcommand,$cur" in
2018 save,--*)
2019 __gitcomp "$save_opts"
2021 apply,--*|pop,--*)
2022 __gitcomp "--index --quiet"
2024 show,--*|drop,--*|branch,--*)
2025 COMPREPLY=()
2027 show,*|apply,*|drop,*|pop,*|branch,*)
2028 __gitcomp "$(git --git-dir="$(__gitdir)" stash list \
2029 | sed -n -e 's/:.*//p')"
2032 COMPREPLY=()
2034 esac
2038 _git_submodule ()
2040 __git_has_doubledash && return
2042 local subcommands="add status init update summary foreach sync"
2043 if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then
2044 local cur="${COMP_WORDS[COMP_CWORD]}"
2045 case "$cur" in
2046 --*)
2047 __gitcomp "--quiet --cached"
2050 __gitcomp "$subcommands"
2052 esac
2053 return
2057 _git_svn ()
2059 local subcommands="
2060 init fetch clone rebase dcommit log find-rev
2061 set-tree commit-diff info create-ignore propget
2062 proplist show-ignore show-externals branch tag blame
2063 migrate mkdirs reset gc
2065 local subcommand="$(__git_find_on_cmdline "$subcommands")"
2066 if [ -z "$subcommand" ]; then
2067 __gitcomp "$subcommands"
2068 else
2069 local remote_opts="--username= --config-dir= --no-auth-cache"
2070 local fc_opts="
2071 --follow-parent --authors-file= --repack=
2072 --no-metadata --use-svm-props --use-svnsync-props
2073 --log-window-size= --no-checkout --quiet
2074 --repack-flags --use-log-author --localtime
2075 --ignore-paths= $remote_opts
2077 local init_opts="
2078 --template= --shared= --trunk= --tags=
2079 --branches= --stdlayout --minimize-url
2080 --no-metadata --use-svm-props --use-svnsync-props
2081 --rewrite-root= --prefix= --use-log-author
2082 --add-author-from $remote_opts
2084 local cmt_opts="
2085 --edit --rmdir --find-copies-harder --copy-similarity=
2088 local cur="${COMP_WORDS[COMP_CWORD]}"
2089 case "$subcommand,$cur" in
2090 fetch,--*)
2091 __gitcomp "--revision= --fetch-all $fc_opts"
2093 clone,--*)
2094 __gitcomp "--revision= $fc_opts $init_opts"
2096 init,--*)
2097 __gitcomp "$init_opts"
2099 dcommit,--*)
2100 __gitcomp "
2101 --merge --strategy= --verbose --dry-run
2102 --fetch-all --no-rebase --commit-url
2103 --revision $cmt_opts $fc_opts
2106 set-tree,--*)
2107 __gitcomp "--stdin $cmt_opts $fc_opts"
2109 create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\
2110 show-externals,--*|mkdirs,--*)
2111 __gitcomp "--revision="
2113 log,--*)
2114 __gitcomp "
2115 --limit= --revision= --verbose --incremental
2116 --oneline --show-commit --non-recursive
2117 --authors-file= --color
2120 rebase,--*)
2121 __gitcomp "
2122 --merge --verbose --strategy= --local
2123 --fetch-all --dry-run $fc_opts
2126 commit-diff,--*)
2127 __gitcomp "--message= --file= --revision= $cmt_opts"
2129 info,--*)
2130 __gitcomp "--url"
2132 branch,--*)
2133 __gitcomp "--dry-run --message --tag"
2135 tag,--*)
2136 __gitcomp "--dry-run --message"
2138 blame,--*)
2139 __gitcomp "--git-format"
2141 migrate,--*)
2142 __gitcomp "
2143 --config-dir= --ignore-paths= --minimize
2144 --no-auth-cache --username=
2147 reset,--*)
2148 __gitcomp "--revision= --parent"
2151 COMPREPLY=()
2153 esac
2157 _git_tag ()
2159 local i c=1 f=0
2160 while [ $c -lt $COMP_CWORD ]; do
2161 i="${COMP_WORDS[c]}"
2162 case "$i" in
2163 -d|-v)
2164 __gitcomp "$(__git_tags)"
2165 return
2170 esac
2171 c=$((++c))
2172 done
2174 case "${COMP_WORDS[COMP_CWORD-1]}" in
2175 -m|-F)
2176 COMPREPLY=()
2178 -*|tag)
2179 if [ $f = 1 ]; then
2180 __gitcomp "$(__git_tags)"
2181 else
2182 COMPREPLY=()
2186 __gitcomp "$(__git_refs)"
2188 esac
2191 _git_whatchanged ()
2193 _git_log
2196 _git ()
2198 local i c=1 command __git_dir
2200 while [ $c -lt $COMP_CWORD ]; do
2201 i="${COMP_WORDS[c]}"
2202 case "$i" in
2203 --git-dir=*) __git_dir="${i#--git-dir=}" ;;
2204 --bare) __git_dir="." ;;
2205 --version|-p|--paginate) ;;
2206 --help) command="help"; break ;;
2207 *) command="$i"; break ;;
2208 esac
2209 c=$((++c))
2210 done
2212 if [ -z "$command" ]; then
2213 case "${COMP_WORDS[COMP_CWORD]}" in
2214 --*) __gitcomp "
2215 --paginate
2216 --no-pager
2217 --git-dir=
2218 --bare
2219 --version
2220 --exec-path
2221 --html-path
2222 --work-tree=
2223 --help
2226 *) __git_compute_porcelain_commands
2227 __gitcomp "$__git_porcelain_commands $(__git_aliases)" ;;
2228 esac
2229 return
2232 local completion_func="_git_${command//-/_}"
2233 declare -F $completion_func >/dev/null && $completion_func && return
2235 local expansion=$(__git_aliased_command "$command")
2236 if [ -n "$expansion" ]; then
2237 completion_func="_git_${expansion//-/_}"
2238 declare -F $completion_func >/dev/null && $completion_func
2242 _gitk ()
2244 __git_has_doubledash && return
2246 local cur="${COMP_WORDS[COMP_CWORD]}"
2247 local g="$(__gitdir)"
2248 local merge=""
2249 if [ -f "$g/MERGE_HEAD" ]; then
2250 merge="--merge"
2252 case "$cur" in
2253 --*)
2254 __gitcomp "
2255 $__git_log_common_options
2256 $__git_log_gitk_options
2257 $merge
2259 return
2261 esac
2262 __git_complete_revlist
2265 complete -o bashdefault -o default -o nospace -F _git git 2>/dev/null \
2266 || complete -o default -o nospace -F _git git
2267 complete -o bashdefault -o default -o nospace -F _gitk gitk 2>/dev/null \
2268 || complete -o default -o nospace -F _gitk gitk
2270 # The following are necessary only for Cygwin, and only are needed
2271 # when the user has tab-completed the executable name and consequently
2272 # included the '.exe' suffix.
2274 if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
2275 complete -o bashdefault -o default -o nospace -F _git git.exe 2>/dev/null \
2276 || complete -o default -o nospace -F _git git.exe