Add a rename + D/F conflict testcase
[git/dscho.git] / contrib / completion / git-completion.bash
blob545bd4b38368e3c2a3958133bbeef6a19e831fff
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
803 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
804 __gitcomp "$(__git_heads)"
805 else
806 __gitcomp "$(__git_refs)"
809 esac
812 _git_bundle ()
814 local cmd="${COMP_WORDS[2]}"
815 case "$COMP_CWORD" in
817 __gitcomp "create list-heads verify unbundle"
820 # looking for a file
823 case "$cmd" in
824 create)
825 __git_complete_revlist
827 esac
829 esac
832 _git_checkout ()
834 __git_has_doubledash && return
836 local cur="${COMP_WORDS[COMP_CWORD]}"
837 case "$cur" in
838 --conflict=*)
839 __gitcomp "diff3 merge" "" "${cur##--conflict=}"
841 --*)
842 __gitcomp "
843 --quiet --ours --theirs --track --no-track --merge
844 --conflict= --patch
848 __gitcomp "$(__git_refs)"
850 esac
853 _git_cherry ()
855 __gitcomp "$(__git_refs)"
858 _git_cherry_pick ()
860 local cur="${COMP_WORDS[COMP_CWORD]}"
861 case "$cur" in
862 --*)
863 __gitcomp "--edit --no-commit"
866 __gitcomp "$(__git_refs)"
868 esac
871 _git_clean ()
873 __git_has_doubledash && return
875 local cur="${COMP_WORDS[COMP_CWORD]}"
876 case "$cur" in
877 --*)
878 __gitcomp "--dry-run --quiet"
879 return
881 esac
882 COMPREPLY=()
885 _git_clone ()
887 local cur="${COMP_WORDS[COMP_CWORD]}"
888 case "$cur" in
889 --*)
890 __gitcomp "
891 --local
892 --no-hardlinks
893 --shared
894 --reference
895 --quiet
896 --no-checkout
897 --bare
898 --mirror
899 --origin
900 --upload-pack
901 --template=
902 --depth
904 return
906 esac
907 COMPREPLY=()
910 _git_commit ()
912 __git_has_doubledash && return
914 local cur="${COMP_WORDS[COMP_CWORD]}"
915 case "$cur" in
916 --cleanup=*)
917 __gitcomp "default strip verbatim whitespace
918 " "" "${cur##--cleanup=}"
919 return
921 --reuse-message=*)
922 __gitcomp "$(__git_refs)" "" "${cur##--reuse-message=}"
923 return
925 --reedit-message=*)
926 __gitcomp "$(__git_refs)" "" "${cur##--reedit-message=}"
927 return
929 --untracked-files=*)
930 __gitcomp "all no normal" "" "${cur##--untracked-files=}"
931 return
933 --*)
934 __gitcomp "
935 --all --author= --signoff --verify --no-verify
936 --edit --amend --include --only --interactive
937 --dry-run --reuse-message= --reedit-message=
938 --reset-author --file= --message= --template=
939 --cleanup= --untracked-files --untracked-files=
940 --verbose --quiet
942 return
943 esac
944 COMPREPLY=()
947 _git_describe ()
949 local cur="${COMP_WORDS[COMP_CWORD]}"
950 case "$cur" in
951 --*)
952 __gitcomp "
953 --all --tags --contains --abbrev= --candidates=
954 --exact-match --debug --long --match --always
956 return
957 esac
958 __gitcomp "$(__git_refs)"
961 __git_diff_common_options="--stat --numstat --shortstat --summary
962 --patch-with-stat --name-only --name-status --color
963 --no-color --color-words --no-renames --check
964 --full-index --binary --abbrev --diff-filter=
965 --find-copies-harder
966 --text --ignore-space-at-eol --ignore-space-change
967 --ignore-all-space --exit-code --quiet --ext-diff
968 --no-ext-diff
969 --no-prefix --src-prefix= --dst-prefix=
970 --inter-hunk-context=
971 --patience
972 --raw
973 --dirstat --dirstat= --dirstat-by-file
974 --dirstat-by-file= --cumulative
977 _git_diff ()
979 __git_has_doubledash && return
981 local cur="${COMP_WORDS[COMP_CWORD]}"
982 case "$cur" in
983 --*)
984 __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
985 --base --ours --theirs
986 $__git_diff_common_options
988 return
990 esac
991 __git_complete_file
994 __git_mergetools_common="diffuse ecmerge emerge kdiff3 meld opendiff
995 tkdiff vimdiff gvimdiff xxdiff araxis p4merge
998 _git_difftool ()
1000 __git_has_doubledash && return
1002 local cur="${COMP_WORDS[COMP_CWORD]}"
1003 case "$cur" in
1004 --tool=*)
1005 __gitcomp "$__git_mergetools_common kompare" "" "${cur##--tool=}"
1006 return
1008 --*)
1009 __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
1010 --base --ours --theirs
1011 --no-renames --diff-filter= --find-copies-harder
1012 --relative --ignore-submodules
1013 --tool="
1014 return
1016 esac
1017 __git_complete_file
1020 __git_fetch_options="
1021 --quiet --verbose --append --upload-pack --force --keep --depth=
1022 --tags --no-tags --all --prune --dry-run
1025 _git_fetch ()
1027 local cur="${COMP_WORDS[COMP_CWORD]}"
1028 case "$cur" in
1029 --*)
1030 __gitcomp "$__git_fetch_options"
1031 return
1033 esac
1034 __git_complete_remote_or_refspec
1037 _git_format_patch ()
1039 local cur="${COMP_WORDS[COMP_CWORD]}"
1040 case "$cur" in
1041 --thread=*)
1042 __gitcomp "
1043 deep shallow
1044 " "" "${cur##--thread=}"
1045 return
1047 --*)
1048 __gitcomp "
1049 --stdout --attach --no-attach --thread --thread=
1050 --output-directory
1051 --numbered --start-number
1052 --numbered-files
1053 --keep-subject
1054 --signoff
1055 --in-reply-to= --cc=
1056 --full-index --binary
1057 --not --all
1058 --cover-letter
1059 --no-prefix --src-prefix= --dst-prefix=
1060 --inline --suffix= --ignore-if-in-upstream
1061 --subject-prefix=
1063 return
1065 esac
1066 __git_complete_revlist
1069 _git_fsck ()
1071 local cur="${COMP_WORDS[COMP_CWORD]}"
1072 case "$cur" in
1073 --*)
1074 __gitcomp "
1075 --tags --root --unreachable --cache --no-reflogs --full
1076 --strict --verbose --lost-found
1078 return
1080 esac
1081 COMPREPLY=()
1084 _git_gc ()
1086 local cur="${COMP_WORDS[COMP_CWORD]}"
1087 case "$cur" in
1088 --*)
1089 __gitcomp "--prune --aggressive"
1090 return
1092 esac
1093 COMPREPLY=()
1096 _git_gitk ()
1098 _gitk
1101 _git_grep ()
1103 __git_has_doubledash && return
1105 local cur="${COMP_WORDS[COMP_CWORD]}"
1106 case "$cur" in
1107 --*)
1108 __gitcomp "
1109 --cached
1110 --text --ignore-case --word-regexp --invert-match
1111 --full-name
1112 --extended-regexp --basic-regexp --fixed-strings
1113 --files-with-matches --name-only
1114 --files-without-match
1115 --max-depth
1116 --count
1117 --and --or --not --all-match
1119 return
1121 esac
1123 __gitcomp "$(__git_refs)"
1126 _git_help ()
1128 local cur="${COMP_WORDS[COMP_CWORD]}"
1129 case "$cur" in
1130 --*)
1131 __gitcomp "--all --info --man --web"
1132 return
1134 esac
1135 __git_compute_all_commands
1136 __gitcomp "$__git_all_commands
1137 attributes cli core-tutorial cvs-migration
1138 diffcore gitk glossary hooks ignore modules
1139 repository-layout tutorial tutorial-2
1140 workflows
1144 _git_init ()
1146 local cur="${COMP_WORDS[COMP_CWORD]}"
1147 case "$cur" in
1148 --shared=*)
1149 __gitcomp "
1150 false true umask group all world everybody
1151 " "" "${cur##--shared=}"
1152 return
1154 --*)
1155 __gitcomp "--quiet --bare --template= --shared --shared="
1156 return
1158 esac
1159 COMPREPLY=()
1162 _git_ls_files ()
1164 __git_has_doubledash && return
1166 local cur="${COMP_WORDS[COMP_CWORD]}"
1167 case "$cur" in
1168 --*)
1169 __gitcomp "--cached --deleted --modified --others --ignored
1170 --stage --directory --no-empty-directory --unmerged
1171 --killed --exclude= --exclude-from=
1172 --exclude-per-directory= --exclude-standard
1173 --error-unmatch --with-tree= --full-name
1174 --abbrev --ignored --exclude-per-directory
1176 return
1178 esac
1179 COMPREPLY=()
1182 _git_ls_remote ()
1184 __gitcomp "$(__git_remotes)"
1187 _git_ls_tree ()
1189 __git_complete_file
1192 # Options that go well for log, shortlog and gitk
1193 __git_log_common_options="
1194 --not --all
1195 --branches --tags --remotes
1196 --first-parent --merges --no-merges
1197 --max-count=
1198 --max-age= --since= --after=
1199 --min-age= --until= --before=
1201 # Options that go well for log and gitk (not shortlog)
1202 __git_log_gitk_options="
1203 --dense --sparse --full-history
1204 --simplify-merges --simplify-by-decoration
1205 --left-right
1207 # Options that go well for log and shortlog (not gitk)
1208 __git_log_shortlog_options="
1209 --author= --committer= --grep=
1210 --all-match
1213 __git_log_pretty_formats="oneline short medium full fuller email raw format:"
1214 __git_log_date_formats="relative iso8601 rfc2822 short local default raw"
1216 _git_log ()
1218 __git_has_doubledash && return
1220 local cur="${COMP_WORDS[COMP_CWORD]}"
1221 local g="$(git rev-parse --git-dir 2>/dev/null)"
1222 local merge=""
1223 if [ -f "$g/MERGE_HEAD" ]; then
1224 merge="--merge"
1226 case "$cur" in
1227 --pretty=*)
1228 __gitcomp "$__git_log_pretty_formats
1229 " "" "${cur##--pretty=}"
1230 return
1232 --format=*)
1233 __gitcomp "$__git_log_pretty_formats
1234 " "" "${cur##--format=}"
1235 return
1237 --date=*)
1238 __gitcomp "$__git_log_date_formats" "" "${cur##--date=}"
1239 return
1241 --decorate=*)
1242 __gitcomp "long short" "" "${cur##--decorate=}"
1243 return
1245 --*)
1246 __gitcomp "
1247 $__git_log_common_options
1248 $__git_log_shortlog_options
1249 $__git_log_gitk_options
1250 --root --topo-order --date-order --reverse
1251 --follow --full-diff
1252 --abbrev-commit --abbrev=
1253 --relative-date --date=
1254 --pretty= --format= --oneline
1255 --cherry-pick
1256 --graph
1257 --decorate --decorate=
1258 --walk-reflogs
1259 --parents --children
1260 $merge
1261 $__git_diff_common_options
1262 --pickaxe-all --pickaxe-regex
1264 return
1266 esac
1267 __git_complete_revlist
1270 __git_merge_options="
1271 --no-commit --no-stat --log --no-log --squash --strategy
1272 --commit --stat --no-squash --ff --no-ff --ff-only
1275 _git_merge ()
1277 __git_complete_strategy && return
1279 local cur="${COMP_WORDS[COMP_CWORD]}"
1280 case "$cur" in
1281 --*)
1282 __gitcomp "$__git_merge_options"
1283 return
1284 esac
1285 __gitcomp "$(__git_refs)"
1288 _git_mergetool ()
1290 local cur="${COMP_WORDS[COMP_CWORD]}"
1291 case "$cur" in
1292 --tool=*)
1293 __gitcomp "$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"
1294 return
1296 --*)
1297 __gitcomp "--tool="
1298 return
1300 esac
1301 COMPREPLY=()
1304 _git_merge_base ()
1306 __gitcomp "$(__git_refs)"
1309 _git_mv ()
1311 local cur="${COMP_WORDS[COMP_CWORD]}"
1312 case "$cur" in
1313 --*)
1314 __gitcomp "--dry-run"
1315 return
1317 esac
1318 COMPREPLY=()
1321 _git_name_rev ()
1323 __gitcomp "--tags --all --stdin"
1326 _git_notes ()
1328 local subcommands="edit show"
1329 if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then
1330 __gitcomp "$subcommands"
1331 return
1334 case "${COMP_WORDS[COMP_CWORD-1]}" in
1335 -m|-F)
1336 COMPREPLY=()
1339 __gitcomp "$(__git_refs)"
1341 esac
1344 _git_pull ()
1346 __git_complete_strategy && return
1348 local cur="${COMP_WORDS[COMP_CWORD]}"
1349 case "$cur" in
1350 --*)
1351 __gitcomp "
1352 --rebase --no-rebase
1353 $__git_merge_options
1354 $__git_fetch_options
1356 return
1358 esac
1359 __git_complete_remote_or_refspec
1362 _git_push ()
1364 local cur="${COMP_WORDS[COMP_CWORD]}"
1365 case "${COMP_WORDS[COMP_CWORD-1]}" in
1366 --repo)
1367 __gitcomp "$(__git_remotes)"
1368 return
1369 esac
1370 case "$cur" in
1371 --repo=*)
1372 __gitcomp "$(__git_remotes)" "" "${cur##--repo=}"
1373 return
1375 --*)
1376 __gitcomp "
1377 --all --mirror --tags --dry-run --force --verbose
1378 --receive-pack= --repo=
1380 return
1382 esac
1383 __git_complete_remote_or_refspec
1386 _git_rebase ()
1388 local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)"
1389 if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
1390 __gitcomp "--continue --skip --abort"
1391 return
1393 __git_complete_strategy && return
1394 case "$cur" in
1395 --whitespace=*)
1396 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
1397 return
1399 --*)
1400 __gitcomp "
1401 --onto --merge --strategy --interactive
1402 --preserve-merges --stat --no-stat
1403 --committer-date-is-author-date --ignore-date
1404 --ignore-whitespace --whitespace=
1405 --autosquash
1408 return
1409 esac
1410 __gitcomp "$(__git_refs)"
1413 __git_send_email_confirm_options="always never auto cc compose"
1414 __git_send_email_suppresscc_options="author self cc bodycc sob cccmd body all"
1416 _git_send_email ()
1418 local cur="${COMP_WORDS[COMP_CWORD]}"
1419 case "$cur" in
1420 --confirm=*)
1421 __gitcomp "
1422 $__git_send_email_confirm_options
1423 " "" "${cur##--confirm=}"
1424 return
1426 --suppress-cc=*)
1427 __gitcomp "
1428 $__git_send_email_suppresscc_options
1429 " "" "${cur##--suppress-cc=}"
1431 return
1433 --smtp-encryption=*)
1434 __gitcomp "ssl tls" "" "${cur##--smtp-encryption=}"
1435 return
1437 --*)
1438 __gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to
1439 --compose --confirm= --dry-run --envelope-sender
1440 --from --identity
1441 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
1442 --no-suppress-from --no-thread --quiet
1443 --signed-off-by-cc --smtp-pass --smtp-server
1444 --smtp-server-port --smtp-encryption= --smtp-user
1445 --subject --suppress-cc= --suppress-from --thread --to
1446 --validate --no-validate"
1447 return
1449 esac
1450 COMPREPLY=()
1453 _git_stage ()
1455 _git_add
1458 __git_config_get_set_variables ()
1460 local prevword word config_file= c=$COMP_CWORD
1461 while [ $c -gt 1 ]; do
1462 word="${COMP_WORDS[c]}"
1463 case "$word" in
1464 --global|--system|--file=*)
1465 config_file="$word"
1466 break
1468 -f|--file)
1469 config_file="$word $prevword"
1470 break
1472 esac
1473 prevword=$word
1474 c=$((--c))
1475 done
1477 git --git-dir="$(__gitdir)" config $config_file --list 2>/dev/null |
1478 while read line
1480 case "$line" in
1481 *.*=*)
1482 echo "${line/=*/}"
1484 esac
1485 done
1488 _git_config ()
1490 local cur="${COMP_WORDS[COMP_CWORD]}"
1491 local prv="${COMP_WORDS[COMP_CWORD-1]}"
1492 case "$prv" in
1493 branch.*.remote)
1494 __gitcomp "$(__git_remotes)"
1495 return
1497 branch.*.merge)
1498 __gitcomp "$(__git_refs)"
1499 return
1501 remote.*.fetch)
1502 local remote="${prv#remote.}"
1503 remote="${remote%.fetch}"
1504 __gitcomp "$(__git_refs_remotes "$remote")"
1505 return
1507 remote.*.push)
1508 local remote="${prv#remote.}"
1509 remote="${remote%.push}"
1510 __gitcomp "$(git --git-dir="$(__gitdir)" \
1511 for-each-ref --format='%(refname):%(refname)' \
1512 refs/heads)"
1513 return
1515 pull.twohead|pull.octopus)
1516 __git_compute_merge_strategies
1517 __gitcomp "$__git_merge_strategies"
1518 return
1520 color.branch|color.diff|color.interactive|\
1521 color.showbranch|color.status|color.ui)
1522 __gitcomp "always never auto"
1523 return
1525 color.pager)
1526 __gitcomp "false true"
1527 return
1529 color.*.*)
1530 __gitcomp "
1531 normal black red green yellow blue magenta cyan white
1532 bold dim ul blink reverse
1534 return
1536 help.format)
1537 __gitcomp "man info web html"
1538 return
1540 log.date)
1541 __gitcomp "$__git_log_date_formats"
1542 return
1544 sendemail.aliasesfiletype)
1545 __gitcomp "mutt mailrc pine elm gnus"
1546 return
1548 sendemail.confirm)
1549 __gitcomp "$__git_send_email_confirm_options"
1550 return
1552 sendemail.suppresscc)
1553 __gitcomp "$__git_send_email_suppresscc_options"
1554 return
1556 --get|--get-all|--unset|--unset-all)
1557 __gitcomp "$(__git_config_get_set_variables)"
1558 return
1560 *.*)
1561 COMPREPLY=()
1562 return
1564 esac
1565 case "$cur" in
1566 --*)
1567 __gitcomp "
1568 --global --system --file=
1569 --list --replace-all
1570 --get --get-all --get-regexp
1571 --add --unset --unset-all
1572 --remove-section --rename-section
1574 return
1576 branch.*.*)
1577 local pfx="${cur%.*}."
1578 cur="${cur##*.}"
1579 __gitcomp "remote merge mergeoptions rebase" "$pfx" "$cur"
1580 return
1582 branch.*)
1583 local pfx="${cur%.*}."
1584 cur="${cur#*.}"
1585 __gitcomp "$(__git_heads)" "$pfx" "$cur" "."
1586 return
1588 guitool.*.*)
1589 local pfx="${cur%.*}."
1590 cur="${cur##*.}"
1591 __gitcomp "
1592 argprompt cmd confirm needsfile noconsole norescan
1593 prompt revprompt revunmerged title
1594 " "$pfx" "$cur"
1595 return
1597 difftool.*.*)
1598 local pfx="${cur%.*}."
1599 cur="${cur##*.}"
1600 __gitcomp "cmd path" "$pfx" "$cur"
1601 return
1603 man.*.*)
1604 local pfx="${cur%.*}."
1605 cur="${cur##*.}"
1606 __gitcomp "cmd path" "$pfx" "$cur"
1607 return
1609 mergetool.*.*)
1610 local pfx="${cur%.*}."
1611 cur="${cur##*.}"
1612 __gitcomp "cmd path trustExitCode" "$pfx" "$cur"
1613 return
1615 pager.*)
1616 local pfx="${cur%.*}."
1617 cur="${cur#*.}"
1618 __git_compute_all_commands
1619 __gitcomp "$__git_all_commands" "$pfx" "$cur"
1620 return
1622 remote.*.*)
1623 local pfx="${cur%.*}."
1624 cur="${cur##*.}"
1625 __gitcomp "
1626 url proxy fetch push mirror skipDefaultUpdate
1627 receivepack uploadpack tagopt pushurl
1628 " "$pfx" "$cur"
1629 return
1631 remote.*)
1632 local pfx="${cur%.*}."
1633 cur="${cur#*.}"
1634 __gitcomp "$(__git_remotes)" "$pfx" "$cur" "."
1635 return
1637 url.*.*)
1638 local pfx="${cur%.*}."
1639 cur="${cur##*.}"
1640 __gitcomp "insteadOf pushInsteadOf" "$pfx" "$cur"
1641 return
1643 esac
1644 __gitcomp "
1645 add.ignore-errors
1646 alias.
1647 apply.ignorewhitespace
1648 apply.whitespace
1649 branch.autosetupmerge
1650 branch.autosetuprebase
1651 clean.requireForce
1652 color.branch
1653 color.branch.current
1654 color.branch.local
1655 color.branch.plain
1656 color.branch.remote
1657 color.diff
1658 color.diff.commit
1659 color.diff.frag
1660 color.diff.meta
1661 color.diff.new
1662 color.diff.old
1663 color.diff.plain
1664 color.diff.whitespace
1665 color.grep
1666 color.grep.external
1667 color.grep.match
1668 color.interactive
1669 color.interactive.header
1670 color.interactive.help
1671 color.interactive.prompt
1672 color.pager
1673 color.showbranch
1674 color.status
1675 color.status.added
1676 color.status.changed
1677 color.status.header
1678 color.status.nobranch
1679 color.status.untracked
1680 color.status.updated
1681 color.ui
1682 commit.template
1683 core.autocrlf
1684 core.bare
1685 core.compression
1686 core.createObject
1687 core.deltaBaseCacheLimit
1688 core.editor
1689 core.excludesfile
1690 core.fileMode
1691 core.fsyncobjectfiles
1692 core.gitProxy
1693 core.ignoreCygwinFSTricks
1694 core.ignoreStat
1695 core.logAllRefUpdates
1696 core.loosecompression
1697 core.packedGitLimit
1698 core.packedGitWindowSize
1699 core.pager
1700 core.preferSymlinkRefs
1701 core.preloadindex
1702 core.quotepath
1703 core.repositoryFormatVersion
1704 core.safecrlf
1705 core.sharedRepository
1706 core.symlinks
1707 core.trustctime
1708 core.warnAmbiguousRefs
1709 core.whitespace
1710 core.worktree
1711 diff.autorefreshindex
1712 diff.external
1713 diff.mnemonicprefix
1714 diff.renameLimit
1715 diff.renameLimit.
1716 diff.renames
1717 diff.suppressBlankEmpty
1718 diff.tool
1719 diff.wordRegex
1720 difftool.
1721 difftool.prompt
1722 fetch.unpackLimit
1723 format.attach
1724 format.cc
1725 format.headers
1726 format.numbered
1727 format.pretty
1728 format.signoff
1729 format.subjectprefix
1730 format.suffix
1731 format.thread
1732 gc.aggressiveWindow
1733 gc.auto
1734 gc.autopacklimit
1735 gc.packrefs
1736 gc.pruneexpire
1737 gc.reflogexpire
1738 gc.reflogexpireunreachable
1739 gc.rerereresolved
1740 gc.rerereunresolved
1741 gitcvs.allbinary
1742 gitcvs.commitmsgannotation
1743 gitcvs.dbTableNamePrefix
1744 gitcvs.dbdriver
1745 gitcvs.dbname
1746 gitcvs.dbpass
1747 gitcvs.dbuser
1748 gitcvs.enabled
1749 gitcvs.logfile
1750 gitcvs.usecrlfattr
1751 guitool.
1752 gui.blamehistoryctx
1753 gui.commitmsgwidth
1754 gui.copyblamethreshold
1755 gui.diffcontext
1756 gui.encoding
1757 gui.fastcopyblame
1758 gui.matchtrackingbranch
1759 gui.newbranchtemplate
1760 gui.pruneduringfetch
1761 gui.spellingdictionary
1762 gui.trustmtime
1763 help.autocorrect
1764 help.browser
1765 help.format
1766 http.lowSpeedLimit
1767 http.lowSpeedTime
1768 http.maxRequests
1769 http.noEPSV
1770 http.proxy
1771 http.sslCAInfo
1772 http.sslCAPath
1773 http.sslCert
1774 http.sslKey
1775 http.sslVerify
1776 i18n.commitEncoding
1777 i18n.logOutputEncoding
1778 imap.folder
1779 imap.host
1780 imap.pass
1781 imap.port
1782 imap.preformattedHTML
1783 imap.sslverify
1784 imap.tunnel
1785 imap.user
1786 instaweb.browser
1787 instaweb.httpd
1788 instaweb.local
1789 instaweb.modulepath
1790 instaweb.port
1791 interactive.singlekey
1792 log.date
1793 log.showroot
1794 mailmap.file
1795 man.
1796 man.viewer
1797 merge.conflictstyle
1798 merge.log
1799 merge.renameLimit
1800 merge.stat
1801 merge.tool
1802 merge.verbosity
1803 mergetool.
1804 mergetool.keepBackup
1805 mergetool.prompt
1806 pack.compression
1807 pack.deltaCacheLimit
1808 pack.deltaCacheSize
1809 pack.depth
1810 pack.indexVersion
1811 pack.packSizeLimit
1812 pack.threads
1813 pack.window
1814 pack.windowMemory
1815 pager.
1816 pull.octopus
1817 pull.twohead
1818 push.default
1819 rebase.stat
1820 receive.denyCurrentBranch
1821 receive.denyDeletes
1822 receive.denyNonFastForwards
1823 receive.fsckObjects
1824 receive.unpackLimit
1825 repack.usedeltabaseoffset
1826 rerere.autoupdate
1827 rerere.enabled
1828 sendemail.aliasesfile
1829 sendemail.aliasesfiletype
1830 sendemail.bcc
1831 sendemail.cc
1832 sendemail.cccmd
1833 sendemail.chainreplyto
1834 sendemail.confirm
1835 sendemail.envelopesender
1836 sendemail.multiedit
1837 sendemail.signedoffbycc
1838 sendemail.smtpencryption
1839 sendemail.smtppass
1840 sendemail.smtpserver
1841 sendemail.smtpserverport
1842 sendemail.smtpuser
1843 sendemail.suppresscc
1844 sendemail.suppressfrom
1845 sendemail.thread
1846 sendemail.to
1847 sendemail.validate
1848 showbranch.default
1849 status.relativePaths
1850 status.showUntrackedFiles
1851 tar.umask
1852 transfer.unpackLimit
1853 url.
1854 user.email
1855 user.name
1856 user.signingkey
1857 web.browser
1858 branch. remote.
1862 _git_remote ()
1864 local subcommands="add rename rm show prune update set-head"
1865 local subcommand="$(__git_find_on_cmdline "$subcommands")"
1866 if [ -z "$subcommand" ]; then
1867 __gitcomp "$subcommands"
1868 return
1871 case "$subcommand" in
1872 rename|rm|show|prune)
1873 __gitcomp "$(__git_remotes)"
1875 update)
1876 local i c='' IFS=$'\n'
1877 for i in $(git --git-dir="$(__gitdir)" config --get-regexp "remotes\..*" 2>/dev/null); do
1878 i="${i#remotes.}"
1879 c="$c ${i/ */}"
1880 done
1881 __gitcomp "$c"
1884 COMPREPLY=()
1886 esac
1889 _git_replace ()
1891 __gitcomp "$(__git_refs)"
1894 _git_reset ()
1896 __git_has_doubledash && return
1898 local cur="${COMP_WORDS[COMP_CWORD]}"
1899 case "$cur" in
1900 --*)
1901 __gitcomp "--merge --mixed --hard --soft --patch"
1902 return
1904 esac
1905 __gitcomp "$(__git_refs)"
1908 _git_revert ()
1910 local cur="${COMP_WORDS[COMP_CWORD]}"
1911 case "$cur" in
1912 --*)
1913 __gitcomp "--edit --mainline --no-edit --no-commit --signoff"
1914 return
1916 esac
1917 __gitcomp "$(__git_refs)"
1920 _git_rm ()
1922 __git_has_doubledash && return
1924 local cur="${COMP_WORDS[COMP_CWORD]}"
1925 case "$cur" in
1926 --*)
1927 __gitcomp "--cached --dry-run --ignore-unmatch --quiet"
1928 return
1930 esac
1931 COMPREPLY=()
1934 _git_shortlog ()
1936 __git_has_doubledash && return
1938 local cur="${COMP_WORDS[COMP_CWORD]}"
1939 case "$cur" in
1940 --*)
1941 __gitcomp "
1942 $__git_log_common_options
1943 $__git_log_shortlog_options
1944 --numbered --summary
1946 return
1948 esac
1949 __git_complete_revlist
1952 _git_show ()
1954 __git_has_doubledash && return
1956 local cur="${COMP_WORDS[COMP_CWORD]}"
1957 case "$cur" in
1958 --pretty=*)
1959 __gitcomp "$__git_log_pretty_formats
1960 " "" "${cur##--pretty=}"
1961 return
1963 --format=*)
1964 __gitcomp "$__git_log_pretty_formats
1965 " "" "${cur##--format=}"
1966 return
1968 --*)
1969 __gitcomp "--pretty= --format= --abbrev-commit --oneline
1970 $__git_diff_common_options
1972 return
1974 esac
1975 __git_complete_file
1978 _git_show_branch ()
1980 local cur="${COMP_WORDS[COMP_CWORD]}"
1981 case "$cur" in
1982 --*)
1983 __gitcomp "
1984 --all --remotes --topo-order --current --more=
1985 --list --independent --merge-base --no-name
1986 --color --no-color
1987 --sha1-name --sparse --topics --reflog
1989 return
1991 esac
1992 __git_complete_revlist
1995 _git_stash ()
1997 local cur="${COMP_WORDS[COMP_CWORD]}"
1998 local save_opts='--keep-index --no-keep-index --quiet --patch'
1999 local subcommands='save list show apply clear drop pop create branch'
2000 local subcommand="$(__git_find_on_cmdline "$subcommands")"
2001 if [ -z "$subcommand" ]; then
2002 case "$cur" in
2003 --*)
2004 __gitcomp "$save_opts"
2007 if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then
2008 __gitcomp "$subcommands"
2009 else
2010 COMPREPLY=()
2013 esac
2014 else
2015 case "$subcommand,$cur" in
2016 save,--*)
2017 __gitcomp "$save_opts"
2019 apply,--*|pop,--*)
2020 __gitcomp "--index --quiet"
2022 show,--*|drop,--*|branch,--*)
2023 COMPREPLY=()
2025 show,*|apply,*|drop,*|pop,*|branch,*)
2026 __gitcomp "$(git --git-dir="$(__gitdir)" stash list \
2027 | sed -n -e 's/:.*//p')"
2030 COMPREPLY=()
2032 esac
2036 _git_submodule ()
2038 __git_has_doubledash && return
2040 local subcommands="add status init update summary foreach sync"
2041 if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then
2042 local cur="${COMP_WORDS[COMP_CWORD]}"
2043 case "$cur" in
2044 --*)
2045 __gitcomp "--quiet --cached"
2048 __gitcomp "$subcommands"
2050 esac
2051 return
2055 _git_svn ()
2057 local subcommands="
2058 init fetch clone rebase dcommit log find-rev
2059 set-tree commit-diff info create-ignore propget
2060 proplist show-ignore show-externals branch tag blame
2061 migrate mkdirs reset gc
2063 local subcommand="$(__git_find_on_cmdline "$subcommands")"
2064 if [ -z "$subcommand" ]; then
2065 __gitcomp "$subcommands"
2066 else
2067 local remote_opts="--username= --config-dir= --no-auth-cache"
2068 local fc_opts="
2069 --follow-parent --authors-file= --repack=
2070 --no-metadata --use-svm-props --use-svnsync-props
2071 --log-window-size= --no-checkout --quiet
2072 --repack-flags --use-log-author --localtime
2073 --ignore-paths= $remote_opts
2075 local init_opts="
2076 --template= --shared= --trunk= --tags=
2077 --branches= --stdlayout --minimize-url
2078 --no-metadata --use-svm-props --use-svnsync-props
2079 --rewrite-root= --prefix= --use-log-author
2080 --add-author-from $remote_opts
2082 local cmt_opts="
2083 --edit --rmdir --find-copies-harder --copy-similarity=
2086 local cur="${COMP_WORDS[COMP_CWORD]}"
2087 case "$subcommand,$cur" in
2088 fetch,--*)
2089 __gitcomp "--revision= --fetch-all $fc_opts"
2091 clone,--*)
2092 __gitcomp "--revision= $fc_opts $init_opts"
2094 init,--*)
2095 __gitcomp "$init_opts"
2097 dcommit,--*)
2098 __gitcomp "
2099 --merge --strategy= --verbose --dry-run
2100 --fetch-all --no-rebase --commit-url
2101 --revision $cmt_opts $fc_opts
2104 set-tree,--*)
2105 __gitcomp "--stdin $cmt_opts $fc_opts"
2107 create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\
2108 show-externals,--*|mkdirs,--*)
2109 __gitcomp "--revision="
2111 log,--*)
2112 __gitcomp "
2113 --limit= --revision= --verbose --incremental
2114 --oneline --show-commit --non-recursive
2115 --authors-file= --color
2118 rebase,--*)
2119 __gitcomp "
2120 --merge --verbose --strategy= --local
2121 --fetch-all --dry-run $fc_opts
2124 commit-diff,--*)
2125 __gitcomp "--message= --file= --revision= $cmt_opts"
2127 info,--*)
2128 __gitcomp "--url"
2130 branch,--*)
2131 __gitcomp "--dry-run --message --tag"
2133 tag,--*)
2134 __gitcomp "--dry-run --message"
2136 blame,--*)
2137 __gitcomp "--git-format"
2139 migrate,--*)
2140 __gitcomp "
2141 --config-dir= --ignore-paths= --minimize
2142 --no-auth-cache --username=
2145 reset,--*)
2146 __gitcomp "--revision= --parent"
2149 COMPREPLY=()
2151 esac
2155 _git_tag ()
2157 local i c=1 f=0
2158 while [ $c -lt $COMP_CWORD ]; do
2159 i="${COMP_WORDS[c]}"
2160 case "$i" in
2161 -d|-v)
2162 __gitcomp "$(__git_tags)"
2163 return
2168 esac
2169 c=$((++c))
2170 done
2172 case "${COMP_WORDS[COMP_CWORD-1]}" in
2173 -m|-F)
2174 COMPREPLY=()
2176 -*|tag)
2177 if [ $f = 1 ]; then
2178 __gitcomp "$(__git_tags)"
2179 else
2180 COMPREPLY=()
2184 __gitcomp "$(__git_refs)"
2186 esac
2189 _git_whatchanged ()
2191 _git_log
2194 _git ()
2196 local i c=1 command __git_dir
2198 while [ $c -lt $COMP_CWORD ]; do
2199 i="${COMP_WORDS[c]}"
2200 case "$i" in
2201 --git-dir=*) __git_dir="${i#--git-dir=}" ;;
2202 --bare) __git_dir="." ;;
2203 --version|-p|--paginate) ;;
2204 --help) command="help"; break ;;
2205 *) command="$i"; break ;;
2206 esac
2207 c=$((++c))
2208 done
2210 if [ -z "$command" ]; then
2211 case "${COMP_WORDS[COMP_CWORD]}" in
2212 --*) __gitcomp "
2213 --paginate
2214 --no-pager
2215 --git-dir=
2216 --bare
2217 --version
2218 --exec-path
2219 --html-path
2220 --work-tree=
2221 --help
2224 *) __git_compute_porcelain_commands
2225 __gitcomp "$__git_porcelain_commands $(__git_aliases)" ;;
2226 esac
2227 return
2230 local completion_func="_git_${command//-/_}"
2231 declare -F $completion_func >/dev/null && $completion_func && return
2233 local expansion=$(__git_aliased_command "$command")
2234 if [ -n "$expansion" ]; then
2235 completion_func="_git_${expansion//-/_}"
2236 declare -F $completion_func >/dev/null && $completion_func
2240 _gitk ()
2242 __git_has_doubledash && return
2244 local cur="${COMP_WORDS[COMP_CWORD]}"
2245 local g="$(__gitdir)"
2246 local merge=""
2247 if [ -f "$g/MERGE_HEAD" ]; then
2248 merge="--merge"
2250 case "$cur" in
2251 --*)
2252 __gitcomp "
2253 $__git_log_common_options
2254 $__git_log_gitk_options
2255 $merge
2257 return
2259 esac
2260 __git_complete_revlist
2263 complete -o bashdefault -o default -o nospace -F _git git 2>/dev/null \
2264 || complete -o default -o nospace -F _git git
2265 complete -o bashdefault -o default -o nospace -F _gitk gitk 2>/dev/null \
2266 || complete -o default -o nospace -F _gitk gitk
2268 # The following are necessary only for Cygwin, and only are needed
2269 # when the user has tab-completed the executable name and consequently
2270 # included the '.exe' suffix.
2272 if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
2273 complete -o bashdefault -o default -o nospace -F _git git.exe 2>/dev/null \
2274 || complete -o default -o nospace -F _git git.exe