Start preparing release notes for 1.5.6.3
[git/git.git] / contrib / completion / git-completion.bash
CommitLineData
690d8824
JH
1#
2# bash completion support for core Git.
3#
c70680ce 4# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
690d8824 5# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
c70680ce 6# Distributed under the GNU General Public License, version 2.0.
690d8824
JH
7#
8# The contained completion routines provide support for completing:
9#
10# *) local and remote branch names
11# *) local and remote tag names
12# *) .git/remotes file names
13# *) git 'subcommands'
14# *) tree paths within 'ref:path/to/file' expressions
c70680ce 15# *) common --long-options
690d8824
JH
16#
17# To use these routines:
18#
19# 1) Copy this file to somewhere (e.g. ~/.git-completion.sh).
20# 2) Added the following line to your .bashrc:
21# source ~/.git-completion.sh
22#
b51ec6bd
SP
23# 3) You may want to make sure the git executable is available
24# in your PATH before this script is sourced, as some caching
25# is performed while the script loads. If git isn't found
26# at source time then all lookups will be done on demand,
27# which may be slightly slower.
28#
29# 4) Consider changing your PS1 to also show the current branch:
d3d717a4
SP
30# PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
31#
32# The argument to __git_ps1 will be displayed only if you
33# are currently in a git repository. The %s token will be
34# the name of the current branch.
35#
c70680ce
SP
36# To submit patches:
37#
38# *) Read Documentation/SubmittingPatches
39# *) Send all patches to the current maintainer:
40#
41# "Shawn O. Pearce" <spearce@spearce.org>
42#
43# *) Always CC the Git mailing list:
44#
45# git@vger.kernel.org
46#
690d8824 47
873537fa
SP
48__gitdir ()
49{
67ffa114
SP
50 if [ -z "$1" ]; then
51 if [ -n "$__git_dir" ]; then
52 echo "$__git_dir"
53 elif [ -d .git ]; then
54 echo .git
55 else
56 git rev-parse --git-dir 2>/dev/null
57 fi
58 elif [ -d "$1/.git" ]; then
59 echo "$1/.git"
60 else
61 echo "$1"
62 fi
873537fa
SP
63}
64
d3d717a4
SP
65__git_ps1 ()
66{
e7520196
RR
67 local g="$(git rev-parse --git-dir 2>/dev/null)"
68 if [ -n "$g" ]; then
69 local r
70 local b
71 if [ -d "$g/../.dotest" ]
72 then
3041c324
JH
73 if test -f "$g/../.dotest/rebasing"
74 then
75 r="|REBASE"
76 elif test -f "$g/../.dotest/applying"
77 then
78 r="|AM"
79 else
80 r="|AM/REBASE"
81 fi
e7520196
RR
82 b="$(git symbolic-ref HEAD 2>/dev/null)"
83 elif [ -f "$g/.dotest-merge/interactive" ]
84 then
85 r="|REBASE-i"
a5c4f85b 86 b="$(cat "$g/.dotest-merge/head-name")"
e7520196
RR
87 elif [ -d "$g/.dotest-merge" ]
88 then
89 r="|REBASE-m"
a5c4f85b 90 b="$(cat "$g/.dotest-merge/head-name")"
e7520196
RR
91 elif [ -f "$g/MERGE_HEAD" ]
92 then
93 r="|MERGING"
94 b="$(git symbolic-ref HEAD 2>/dev/null)"
95 else
a5c4f85b 96 if [ -f "$g/BISECT_LOG" ]
e7520196
RR
97 then
98 r="|BISECTING"
99 fi
100 if ! b="$(git symbolic-ref HEAD 2>/dev/null)"
101 then
27c57888
SP
102 if ! b="$(git describe --exact-match HEAD 2>/dev/null)"
103 then
a5c4f85b 104 b="$(cut -c1-7 "$g/HEAD")..."
27c57888 105 fi
e7520196
RR
106 fi
107 fi
108
d3d717a4 109 if [ -n "$1" ]; then
e7520196 110 printf "$1" "${b##refs/heads/}$r"
d3d717a4 111 else
e7520196 112 printf " (%s)" "${b##refs/heads/}$r"
d3d717a4
SP
113 fi
114 fi
115}
116
72e5e989
SP
117__gitcomp ()
118{
119 local all c s=$'\n' IFS=' '$'\t'$'\n'
78d4d6a2 120 local cur="${COMP_WORDS[COMP_CWORD]}"
b3391775 121 if [ $# -gt 2 ]; then
78d4d6a2
SP
122 cur="$3"
123 fi
5447aac7
SG
124 case "$cur" in
125 --*=)
126 COMPREPLY=()
127 return
128 ;;
129 *)
130 for c in $1; do
131 case "$c$4" in
132 --*=*) all="$all$c$4$s" ;;
133 *.) all="$all$c$4$s" ;;
134 *) all="$all$c$4 $s" ;;
135 esac
136 done
137 ;;
138 esac
72e5e989 139 IFS=$s
78d4d6a2 140 COMPREPLY=($(compgen -P "$2" -W "$all" -- "$cur"))
72e5e989
SP
141 return
142}
143
5de40f59
SP
144__git_heads ()
145{
67ffa114 146 local cmd i is_hash=y dir="$(__gitdir "$1")"
5de40f59
SP
147 if [ -d "$dir" ]; then
148 for i in $(git --git-dir="$dir" \
149 for-each-ref --format='%(refname)' \
150 refs/heads ); do
151 echo "${i#refs/heads/}"
152 done
153 return
154 fi
799596a5 155 for i in $(git ls-remote "$1" 2>/dev/null); do
5de40f59
SP
156 case "$is_hash,$i" in
157 y,*) is_hash=n ;;
158 n,*^{}) is_hash=y ;;
159 n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
160 n,*) is_hash=y; echo "$i" ;;
161 esac
162 done
163}
164
88e21dc7
SP
165__git_tags ()
166{
167 local cmd i is_hash=y dir="$(__gitdir "$1")"
168 if [ -d "$dir" ]; then
169 for i in $(git --git-dir="$dir" \
170 for-each-ref --format='%(refname)' \
171 refs/tags ); do
172 echo "${i#refs/tags/}"
173 done
174 return
175 fi
799596a5 176 for i in $(git ls-remote "$1" 2>/dev/null); do
88e21dc7
SP
177 case "$is_hash,$i" in
178 y,*) is_hash=n ;;
179 n,*^{}) is_hash=y ;;
180 n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
181 n,*) is_hash=y; echo "$i" ;;
182 esac
183 done
184}
185
690d8824
JH
186__git_refs ()
187{
67ffa114 188 local cmd i is_hash=y dir="$(__gitdir "$1")"
873537fa 189 if [ -d "$dir" ]; then
35e65ecc
SP
190 if [ -e "$dir/HEAD" ]; then echo HEAD; fi
191 for i in $(git --git-dir="$dir" \
192 for-each-ref --format='%(refname)' \
193 refs/tags refs/heads refs/remotes); do
194 case "$i" in
195 refs/tags/*) echo "${i#refs/tags/}" ;;
196 refs/heads/*) echo "${i#refs/heads/}" ;;
197 refs/remotes/*) echo "${i#refs/remotes/}" ;;
198 *) echo "$i" ;;
199 esac
200 done
201 return
690d8824 202 fi
799596a5 203 for i in $(git ls-remote "$dir" 2>/dev/null); do
690d8824
JH
204 case "$is_hash,$i" in
205 y,*) is_hash=n ;;
206 n,*^{}) is_hash=y ;;
207 n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
208 n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
35e65ecc 209 n,refs/remotes/*) is_hash=y; echo "${i#refs/remotes/}" ;;
690d8824
JH
210 n,*) is_hash=y; echo "$i" ;;
211 esac
212 done
213}
214
215__git_refs2 ()
216{
67ffa114
SP
217 local i
218 for i in $(__git_refs "$1"); do
219 echo "$i:$i"
690d8824
JH
220 done
221}
222
5de40f59
SP
223__git_refs_remotes ()
224{
225 local cmd i is_hash=y
799596a5 226 for i in $(git ls-remote "$1" 2>/dev/null); do
5de40f59
SP
227 case "$is_hash,$i" in
228 n,refs/heads/*)
229 is_hash=y
230 echo "$i:refs/remotes/$1/${i#refs/heads/}"
231 ;;
232 y,*) is_hash=n ;;
233 n,*^{}) is_hash=y ;;
234 n,refs/tags/*) is_hash=y;;
235 n,*) is_hash=y; ;;
236 esac
237 done
238}
239
690d8824
JH
240__git_remotes ()
241{
873537fa 242 local i ngoff IFS=$'\n' d="$(__gitdir)"
56fc25f2 243 shopt -q nullglob || ngoff=1
690d8824 244 shopt -s nullglob
873537fa
SP
245 for i in "$d/remotes"/*; do
246 echo ${i#$d/remotes/}
690d8824 247 done
56fc25f2 248 [ "$ngoff" ] && shopt -u nullglob
e0d10e1c 249 for i in $(git --git-dir="$d" config --list); do
56fc25f2
SP
250 case "$i" in
251 remote.*.url=*)
252 i="${i#remote.}"
253 echo "${i/.url=*/}"
254 ;;
255 esac
256 done
690d8824
JH
257}
258
4ad91321
SP
259__git_merge_strategies ()
260{
b51ec6bd
SP
261 if [ -n "$__git_merge_strategylist" ]; then
262 echo "$__git_merge_strategylist"
263 return
264 fi
4ad91321
SP
265 sed -n "/^all_strategies='/{
266 s/^all_strategies='//
267 s/'//
268 p
269 q
270 }" "$(git --exec-path)/git-merge"
271}
b51ec6bd
SP
272__git_merge_strategylist=
273__git_merge_strategylist="$(__git_merge_strategies 2>/dev/null)"
4ad91321 274
690d8824
JH
275__git_complete_file ()
276{
a79c6551 277 local pfx ls ref cur="${COMP_WORDS[COMP_CWORD]}"
690d8824
JH
278 case "$cur" in
279 ?*:*)
a79c6551
SP
280 ref="${cur%%:*}"
281 cur="${cur#*:}"
690d8824
JH
282 case "$cur" in
283 ?*/*)
a79c6551
SP
284 pfx="${cur%/*}"
285 cur="${cur##*/}"
690d8824
JH
286 ls="$ref:$pfx"
287 pfx="$pfx/"
288 ;;
289 *)
290 ls="$ref"
291 ;;
292 esac
293 COMPREPLY=($(compgen -P "$pfx" \
873537fa 294 -W "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \
690d8824
JH
295 | sed '/^100... blob /s,^.* ,,
296 /^040000 tree /{
297 s,^.* ,,
298 s,$,/,
299 }
300 s/^.* //')" \
301 -- "$cur"))
302 ;;
303 *)
b3391775 304 __gitcomp "$(__git_refs)"
690d8824
JH
305 ;;
306 esac
307}
308
f53352fb
SP
309__git_complete_revlist ()
310{
311 local pfx cur="${COMP_WORDS[COMP_CWORD]}"
312 case "$cur" in
313 *...*)
314 pfx="${cur%...*}..."
315 cur="${cur#*...}"
b3391775 316 __gitcomp "$(__git_refs)" "$pfx" "$cur"
f53352fb
SP
317 ;;
318 *..*)
319 pfx="${cur%..*}.."
320 cur="${cur#*..}"
b3391775
SP
321 __gitcomp "$(__git_refs)" "$pfx" "$cur"
322 ;;
323 *.)
324 __gitcomp "$cur."
f53352fb
SP
325 ;;
326 *)
b3391775 327 __gitcomp "$(__git_refs)"
f53352fb
SP
328 ;;
329 esac
330}
331
f2bb9f88
SP
332__git_commands ()
333{
b51ec6bd
SP
334 if [ -n "$__git_commandlist" ]; then
335 echo "$__git_commandlist"
336 return
337 fi
f2bb9f88
SP
338 local i IFS=" "$'\n'
339 for i in $(git help -a|egrep '^ ')
340 do
341 case $i in
718a087a 342 *--*) : helper pattern;;
a925c6f1
SP
343 applymbox) : ask gittus;;
344 applypatch) : ask gittus;;
345 archimport) : import;;
2e3a430a 346 cat-file) : plumbing;;
56d99c67 347 check-attr) : plumbing;;
f2bb9f88
SP
348 check-ref-format) : plumbing;;
349 commit-tree) : plumbing;;
a925c6f1
SP
350 cvsexportcommit) : export;;
351 cvsimport) : import;;
f2bb9f88
SP
352 cvsserver) : daemon;;
353 daemon) : daemon;;
5cfb4fe5
SP
354 diff-files) : plumbing;;
355 diff-index) : plumbing;;
356 diff-tree) : plumbing;;
c6ec3b13 357 fast-import) : import;;
a925c6f1 358 fsck-objects) : plumbing;;
f2bb9f88 359 fetch-pack) : plumbing;;
a925c6f1 360 fmt-merge-msg) : plumbing;;
56d99c67 361 for-each-ref) : plumbing;;
f2bb9f88
SP
362 hash-object) : plumbing;;
363 http-*) : transport;;
364 index-pack) : plumbing;;
a925c6f1 365 init-db) : deprecated;;
f2bb9f88
SP
366 local-fetch) : plumbing;;
367 mailinfo) : plumbing;;
368 mailsplit) : plumbing;;
369 merge-*) : plumbing;;
370 mktree) : plumbing;;
371 mktag) : plumbing;;
372 pack-objects) : plumbing;;
373 pack-redundant) : plumbing;;
374 pack-refs) : plumbing;;
375 parse-remote) : plumbing;;
376 patch-id) : plumbing;;
377 peek-remote) : plumbing;;
a925c6f1
SP
378 prune) : plumbing;;
379 prune-packed) : plumbing;;
380 quiltimport) : import;;
f2bb9f88
SP
381 read-tree) : plumbing;;
382 receive-pack) : plumbing;;
2e3a430a 383 reflog) : plumbing;;
5c66d0d4 384 repo-config) : deprecated;;
f2bb9f88
SP
385 rerere) : plumbing;;
386 rev-list) : plumbing;;
387 rev-parse) : plumbing;;
388 runstatus) : plumbing;;
389 sh-setup) : internal;;
390 shell) : daemon;;
391 send-pack) : plumbing;;
392 show-index) : plumbing;;
393 ssh-*) : transport;;
394 stripspace) : plumbing;;
395 symbolic-ref) : plumbing;;
a925c6f1 396 tar-tree) : deprecated;;
f2bb9f88
SP
397 unpack-file) : plumbing;;
398 unpack-objects) : plumbing;;
a925c6f1 399 update-index) : plumbing;;
f2bb9f88
SP
400 update-ref) : plumbing;;
401 update-server-info) : daemon;;
402 upload-archive) : plumbing;;
403 upload-pack) : plumbing;;
404 write-tree) : plumbing;;
a925c6f1 405 verify-tag) : plumbing;;
f2bb9f88
SP
406 *) echo $i;;
407 esac
408 done
409}
b51ec6bd
SP
410__git_commandlist=
411__git_commandlist="$(__git_commands 2>/dev/null)"
f2bb9f88 412
367dce2a
DS
413__git_aliases ()
414{
56fc25f2 415 local i IFS=$'\n'
e0d10e1c 416 for i in $(git --git-dir="$(__gitdir)" config --list); do
56fc25f2
SP
417 case "$i" in
418 alias.*)
419 i="${i#alias.}"
420 echo "${i/=*/}"
421 ;;
422 esac
423 done
367dce2a
DS
424}
425
426__git_aliased_command ()
427{
873537fa 428 local word cmdline=$(git --git-dir="$(__gitdir)" \
e0d10e1c 429 config --get "alias.$1")
367dce2a
DS
430 for word in $cmdline; do
431 if [ "${word##-*}" ]; then
432 echo $word
433 return
434 fi
435 done
436}
437
3ff1320d
SG
438__git_find_subcommand ()
439{
440 local word subcommand c=1
441
442 while [ $c -lt $COMP_CWORD ]; do
443 word="${COMP_WORDS[c]}"
444 for subcommand in $1; do
445 if [ "$subcommand" = "$word" ]; then
446 echo "$subcommand"
447 return
448 fi
449 done
450 c=$((++c))
451 done
452}
453
d773c631
SG
454__git_has_doubledash ()
455{
456 local c=1
457 while [ $c -lt $COMP_CWORD ]; do
458 if [ "--" = "${COMP_WORDS[c]}" ]; then
459 return 0
460 fi
461 c=$((++c))
462 done
463 return 1
464}
465
88329195
SP
466__git_whitespacelist="nowarn warn error error-all strip"
467
468_git_am ()
469{
470 local cur="${COMP_WORDS[COMP_CWORD]}"
471 if [ -d .dotest ]; then
b3391775 472 __gitcomp "--skip --resolved"
88329195
SP
473 return
474 fi
475 case "$cur" in
476 --whitespace=*)
b3391775 477 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
88329195
SP
478 return
479 ;;
480 --*)
b3391775 481 __gitcomp "
88329195
SP
482 --signoff --utf8 --binary --3way --interactive
483 --whitespace=
b3391775 484 "
88329195
SP
485 return
486 esac
487 COMPREPLY=()
488}
489
490_git_apply ()
491{
492 local cur="${COMP_WORDS[COMP_CWORD]}"
493 case "$cur" in
494 --whitespace=*)
b3391775 495 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
88329195
SP
496 return
497 ;;
498 --*)
b3391775 499 __gitcomp "
88329195
SP
500 --stat --numstat --summary --check --index
501 --cached --index-info --reverse --reject --unidiff-zero
502 --apply --no-add --exclude=
503 --whitespace= --inaccurate-eof --verbose
b3391775 504 "
88329195
SP
505 return
506 esac
507 COMPREPLY=()
508}
509
8435b548
SP
510_git_add ()
511{
d773c631
SG
512 __git_has_doubledash && return
513
8435b548
SP
514 local cur="${COMP_WORDS[COMP_CWORD]}"
515 case "$cur" in
516 --*)
1d284cba
SG
517 __gitcomp "
518 --interactive --refresh --patch --update --dry-run
519 --ignore-errors
520 "
8435b548
SP
521 return
522 esac
523 COMPREPLY=()
524}
525
b2e69f62
SP
526_git_bisect ()
527{
d773c631
SG
528 __git_has_doubledash && return
529
3ff1320d
SG
530 local subcommands="start bad good reset visualize replay log"
531 local subcommand="$(__git_find_subcommand "$subcommands")"
532 if [ -z "$subcommand" ]; then
533 __gitcomp "$subcommands"
b2e69f62
SP
534 return
535 fi
536
3ff1320d 537 case "$subcommand" in
b2e69f62
SP
538 bad|good|reset)
539 __gitcomp "$(__git_refs)"
540 ;;
541 *)
542 COMPREPLY=()
543 ;;
544 esac
545}
546
690d8824
JH
547_git_branch ()
548{
b9217642
SG
549 local i c=1 only_local_ref="n" has_r="n"
550
551 while [ $c -lt $COMP_CWORD ]; do
552 i="${COMP_WORDS[c]}"
553 case "$i" in
554 -d|-m) only_local_ref="y" ;;
555 -r) has_r="y" ;;
556 esac
557 c=$((++c))
558 done
559
3b376b0c
SG
560 case "${COMP_WORDS[COMP_CWORD]}" in
561 --*=*) COMPREPLY=() ;;
562 --*)
563 __gitcomp "
564 --color --no-color --verbose --abbrev= --no-abbrev
565 --track --no-track
566 "
567 ;;
b9217642
SG
568 *)
569 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
570 __gitcomp "$(__git_heads)"
571 else
572 __gitcomp "$(__git_refs)"
573 fi
574 ;;
3b376b0c 575 esac
690d8824
JH
576}
577
374a58c9
ML
578_git_bundle ()
579{
580 local mycword="$COMP_CWORD"
581 case "${COMP_WORDS[0]}" in
582 git)
583 local cmd="${COMP_WORDS[2]}"
584 mycword="$((mycword-1))"
585 ;;
586 git-bundle*)
587 local cmd="${COMP_WORDS[1]}"
588 ;;
589 esac
590 case "$mycword" in
591 1)
592 __gitcomp "create list-heads verify unbundle"
593 ;;
594 2)
595 # looking for a file
596 ;;
597 *)
598 case "$cmd" in
599 create)
600 __git_complete_revlist
601 ;;
602 esac
603 ;;
604 esac
605}
606
690d8824
JH
607_git_checkout ()
608{
b3391775 609 __gitcomp "$(__git_refs)"
690d8824
JH
610}
611
d8a9fea5
SP
612_git_cherry ()
613{
614 __gitcomp "$(__git_refs)"
615}
616
1273231e
SP
617_git_cherry_pick ()
618{
619 local cur="${COMP_WORDS[COMP_CWORD]}"
620 case "$cur" in
621 --*)
b3391775 622 __gitcomp "--edit --no-commit"
1273231e
SP
623 ;;
624 *)
b3391775 625 __gitcomp "$(__git_refs)"
1273231e
SP
626 ;;
627 esac
628}
629
4548e855
SP
630_git_commit ()
631{
d773c631
SG
632 __git_has_doubledash && return
633
4548e855
SP
634 local cur="${COMP_WORDS[COMP_CWORD]}"
635 case "$cur" in
636 --*)
b3391775 637 __gitcomp "
4548e855
SP
638 --all --author= --signoff --verify --no-verify
639 --edit --amend --include --only
b3391775 640 "
4548e855
SP
641 return
642 esac
643 COMPREPLY=()
644}
645
217926c0
SP
646_git_describe ()
647{
648 __gitcomp "$(__git_refs)"
649}
650
690d8824
JH
651_git_diff ()
652{
d773c631
SG
653 __git_has_doubledash && return
654
b3a4f858
JS
655 local cur="${COMP_WORDS[COMP_CWORD]}"
656 case "$cur" in
657 --*)
658 __gitcomp "--cached --stat --numstat --shortstat --summary
659 --patch-with-stat --name-only --name-status --color
660 --no-color --color-words --no-renames --check
661 --full-index --binary --abbrev --diff-filter
662 --find-copies-harder --pickaxe-all --pickaxe-regex
663 --text --ignore-space-at-eol --ignore-space-change
664 --ignore-all-space --exit-code --quiet --ext-diff
aba201c6
PO
665 --no-ext-diff
666 --no-prefix --src-prefix= --dst-prefix=
f4574139 667 --base --ours --theirs
aba201c6 668 "
b3a4f858
JS
669 return
670 ;;
671 esac
690d8824
JH
672 __git_complete_file
673}
674
675_git_diff_tree ()
676{
b3391775 677 __gitcomp "$(__git_refs)"
690d8824
JH
678}
679
680_git_fetch ()
681{
682 local cur="${COMP_WORDS[COMP_CWORD]}"
683
684 case "${COMP_WORDS[0]},$COMP_CWORD" in
685 git-fetch*,1)
b3391775 686 __gitcomp "$(__git_remotes)"
690d8824
JH
687 ;;
688 git,2)
b3391775 689 __gitcomp "$(__git_remotes)"
690d8824
JH
690 ;;
691 *)
692 case "$cur" in
693 *:*)
b3391775 694 __gitcomp "$(__git_refs)" "" "${cur#*:}"
690d8824
JH
695 ;;
696 *)
697 local remote
698 case "${COMP_WORDS[0]}" in
699 git-fetch) remote="${COMP_WORDS[1]}" ;;
700 git) remote="${COMP_WORDS[2]}" ;;
701 esac
b3391775 702 __gitcomp "$(__git_refs2 "$remote")"
690d8824
JH
703 ;;
704 esac
705 ;;
706 esac
707}
708
f53352fb
SP
709_git_format_patch ()
710{
711 local cur="${COMP_WORDS[COMP_CWORD]}"
712 case "$cur" in
713 --*)
b3391775 714 __gitcomp "
f53352fb
SP
715 --stdout --attach --thread
716 --output-directory
717 --numbered --start-number
47e98eec 718 --numbered-files
f53352fb
SP
719 --keep-subject
720 --signoff
721 --in-reply-to=
722 --full-index --binary
ec804891 723 --not --all
be5f5bf0 724 --cover-letter
aba201c6 725 --no-prefix --src-prefix= --dst-prefix=
b3391775 726 "
f53352fb
SP
727 return
728 ;;
729 esac
730 __git_complete_revlist
731}
732
b26c8748
SP
733_git_gc ()
734{
735 local cur="${COMP_WORDS[COMP_CWORD]}"
736 case "$cur" in
737 --*)
47e98eec 738 __gitcomp "--prune --aggressive"
b26c8748
SP
739 return
740 ;;
741 esac
742 COMPREPLY=()
743}
744
690d8824
JH
745_git_ls_remote ()
746{
b3391775 747 __gitcomp "$(__git_remotes)"
690d8824
JH
748}
749
750_git_ls_tree ()
751{
752 __git_complete_file
753}
754
755_git_log ()
756{
d773c631
SG
757 __git_has_doubledash && return
758
6e31b866
SP
759 local cur="${COMP_WORDS[COMP_CWORD]}"
760 case "$cur" in
761 --pretty=*)
b3391775 762 __gitcomp "
6e31b866 763 oneline short medium full fuller email raw
b3391775 764 " "" "${cur##--pretty=}"
6e31b866
SP
765 return
766 ;;
47e98eec
SP
767 --date=*)
768 __gitcomp "
769 relative iso8601 rfc2822 short local default
770 " "" "${cur##--date=}"
771 return
772 ;;
6e31b866 773 --*)
b3391775 774 __gitcomp "
6e31b866
SP
775 --max-count= --max-age= --since= --after=
776 --min-age= --before= --until=
8f87fae6 777 --root --topo-order --date-order --reverse
47e98eec 778 --no-merges --follow
6e31b866 779 --abbrev-commit --abbrev=
47e98eec 780 --relative-date --date=
6e31b866
SP
781 --author= --committer= --grep=
782 --all-match
8f87fae6 783 --pretty= --name-status --name-only --raw
ec804891 784 --not --all
7d37b5bf 785 --left-right --cherry-pick
20827d99 786 --graph
b3391775 787 "
6e31b866
SP
788 return
789 ;;
790 esac
f53352fb 791 __git_complete_revlist
690d8824
JH
792}
793
4ad91321
SP
794_git_merge ()
795{
796 local cur="${COMP_WORDS[COMP_CWORD]}"
ce1e39d2
SP
797 case "${COMP_WORDS[COMP_CWORD-1]}" in
798 -s|--strategy)
b3391775 799 __gitcomp "$(__git_merge_strategies)"
ce1e39d2
SP
800 return
801 esac
4ad91321 802 case "$cur" in
ce1e39d2 803 --strategy=*)
b3391775 804 __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}"
ce1e39d2
SP
805 return
806 ;;
4ad91321 807 --*)
b3391775 808 __gitcomp "
efb779f8 809 --no-commit --no-stat --log --no-log --squash --strategy
b3391775 810 "
4ad91321
SP
811 return
812 esac
b3391775 813 __gitcomp "$(__git_refs)"
4ad91321
SP
814}
815
690d8824
JH
816_git_merge_base ()
817{
b3391775 818 __gitcomp "$(__git_refs)"
690d8824
JH
819}
820
d33909bf
SP
821_git_name_rev ()
822{
b3391775 823 __gitcomp "--tags --all --stdin"
d33909bf
SP
824}
825
690d8824
JH
826_git_pull ()
827{
828 local cur="${COMP_WORDS[COMP_CWORD]}"
829
830 case "${COMP_WORDS[0]},$COMP_CWORD" in
831 git-pull*,1)
b3391775 832 __gitcomp "$(__git_remotes)"
690d8824
JH
833 ;;
834 git,2)
b3391775 835 __gitcomp "$(__git_remotes)"
690d8824
JH
836 ;;
837 *)
838 local remote
839 case "${COMP_WORDS[0]}" in
840 git-pull) remote="${COMP_WORDS[1]}" ;;
841 git) remote="${COMP_WORDS[2]}" ;;
842 esac
b3391775 843 __gitcomp "$(__git_refs "$remote")"
690d8824
JH
844 ;;
845 esac
846}
847
848_git_push ()
849{
850 local cur="${COMP_WORDS[COMP_CWORD]}"
851
852 case "${COMP_WORDS[0]},$COMP_CWORD" in
853 git-push*,1)
b3391775 854 __gitcomp "$(__git_remotes)"
690d8824
JH
855 ;;
856 git,2)
b3391775 857 __gitcomp "$(__git_remotes)"
690d8824
JH
858 ;;
859 *)
860 case "$cur" in
861 *:*)
862 local remote
863 case "${COMP_WORDS[0]}" in
864 git-push) remote="${COMP_WORDS[1]}" ;;
865 git) remote="${COMP_WORDS[2]}" ;;
866 esac
b3391775 867 __gitcomp "$(__git_refs "$remote")" "" "${cur#*:}"
690d8824 868 ;;
161fea83
SP
869 +*)
870 __gitcomp "$(__git_refs)" + "${cur#+}"
871 ;;
690d8824 872 *)
92d7c8e3 873 __gitcomp "$(__git_refs)"
690d8824
JH
874 ;;
875 esac
876 ;;
877 esac
878}
879
61d926a3
SP
880_git_rebase ()
881{
51fe1209
SG
882 local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)"
883 if [ -d .dotest ] || [ -d "$dir"/.dotest-merge ]; then
b3391775 884 __gitcomp "--continue --skip --abort"
61d926a3
SP
885 return
886 fi
ce1e39d2
SP
887 case "${COMP_WORDS[COMP_CWORD-1]}" in
888 -s|--strategy)
b3391775 889 __gitcomp "$(__git_merge_strategies)"
ce1e39d2
SP
890 return
891 esac
61d926a3 892 case "$cur" in
ce1e39d2 893 --strategy=*)
b3391775 894 __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}"
ce1e39d2
SP
895 return
896 ;;
61d926a3 897 --*)
d9e3b702 898 __gitcomp "--onto --merge --strategy --interactive"
61d926a3
SP
899 return
900 esac
b3391775 901 __gitcomp "$(__git_refs)"
61d926a3
SP
902}
903
e0d10e1c 904_git_config ()
5de40f59
SP
905{
906 local cur="${COMP_WORDS[COMP_CWORD]}"
907 local prv="${COMP_WORDS[COMP_CWORD-1]}"
908 case "$prv" in
909 branch.*.remote)
78d4d6a2 910 __gitcomp "$(__git_remotes)"
5de40f59
SP
911 return
912 ;;
913 branch.*.merge)
78d4d6a2 914 __gitcomp "$(__git_refs)"
5de40f59
SP
915 return
916 ;;
917 remote.*.fetch)
918 local remote="${prv#remote.}"
919 remote="${remote%.fetch}"
78d4d6a2 920 __gitcomp "$(__git_refs_remotes "$remote")"
5de40f59
SP
921 return
922 ;;
923 remote.*.push)
924 local remote="${prv#remote.}"
925 remote="${remote%.push}"
78d4d6a2 926 __gitcomp "$(git --git-dir="$(__gitdir)" \
5de40f59 927 for-each-ref --format='%(refname):%(refname)' \
78d4d6a2
SP
928 refs/heads)"
929 return
930 ;;
931 pull.twohead|pull.octopus)
932 __gitcomp "$(__git_merge_strategies)"
933 return
934 ;;
935 color.branch|color.diff|color.status)
936 __gitcomp "always never auto"
937 return
938 ;;
939 color.*.*)
940 __gitcomp "
941 black red green yellow blue magenta cyan white
942 bold dim ul blink reverse
943 "
5de40f59
SP
944 return
945 ;;
946 *.*)
947 COMPREPLY=()
948 return
949 ;;
950 esac
951 case "$cur" in
952 --*)
78d4d6a2 953 __gitcomp "
47e98eec 954 --global --system --file=
12977705 955 --list --replace-all
5de40f59 956 --get --get-all --get-regexp
1b71eb35 957 --add --unset --unset-all
12977705 958 --remove-section --rename-section
78d4d6a2 959 "
5de40f59
SP
960 return
961 ;;
962 branch.*.*)
963 local pfx="${cur%.*}."
964 cur="${cur##*.}"
78d4d6a2 965 __gitcomp "remote merge" "$pfx" "$cur"
5de40f59
SP
966 return
967 ;;
968 branch.*)
969 local pfx="${cur%.*}."
970 cur="${cur#*.}"
78d4d6a2 971 __gitcomp "$(__git_heads)" "$pfx" "$cur" "."
5de40f59
SP
972 return
973 ;;
974 remote.*.*)
975 local pfx="${cur%.*}."
976 cur="${cur##*.}"
12977705
SP
977 __gitcomp "
978 url fetch push skipDefaultUpdate
979 receivepack uploadpack tagopt
980 " "$pfx" "$cur"
5de40f59
SP
981 return
982 ;;
983 remote.*)
984 local pfx="${cur%.*}."
985 cur="${cur#*.}"
78d4d6a2 986 __gitcomp "$(__git_remotes)" "$pfx" "$cur" "."
5de40f59
SP
987 return
988 ;;
989 esac
78d4d6a2 990 __gitcomp "
5de40f59
SP
991 apply.whitespace
992 core.fileMode
993 core.gitProxy
994 core.ignoreStat
995 core.preferSymlinkRefs
996 core.logAllRefUpdates
47e98eec 997 core.loosecompression
5de40f59
SP
998 core.repositoryFormatVersion
999 core.sharedRepository
1000 core.warnAmbiguousRefs
1001 core.compression
78d4d6a2
SP
1002 core.packedGitWindowSize
1003 core.packedGitLimit
2122591b 1004 clean.requireForce
78d4d6a2
SP
1005 color.branch
1006 color.branch.current
1007 color.branch.local
1008 color.branch.remote
1009 color.branch.plain
a159ca0c 1010 color.diff
78d4d6a2
SP
1011 color.diff.plain
1012 color.diff.meta
1013 color.diff.frag
1014 color.diff.old
1015 color.diff.new
1016 color.diff.commit
1017 color.diff.whitespace
a159ca0c 1018 color.pager
a159ca0c 1019 color.status
78d4d6a2
SP
1020 color.status.header
1021 color.status.added
1022 color.status.changed
1023 color.status.untracked
1024 diff.renameLimit
1025 diff.renames
1026 fetch.unpackLimit
1027 format.headers
47e98eec 1028 format.subjectprefix
78d4d6a2
SP
1029 gitcvs.enabled
1030 gitcvs.logfile
12977705 1031 gitcvs.allbinary
6aeeffd1
JE
1032 gitcvs.dbname gitcvs.dbdriver gitcvs.dbuser gitcvs.dbpass
1033 gitcvs.dbtablenameprefix
12977705 1034 gc.packrefs
78d4d6a2
SP
1035 gc.reflogexpire
1036 gc.reflogexpireunreachable
1037 gc.rerereresolved
1038 gc.rerereunresolved
5de40f59
SP
1039 http.sslVerify
1040 http.sslCert
1041 http.sslKey
1042 http.sslCAInfo
1043 http.sslCAPath
1044 http.maxRequests
78d4d6a2
SP
1045 http.lowSpeedLimit
1046 http.lowSpeedTime
5de40f59 1047 http.noEPSV
78d4d6a2
SP
1048 i18n.commitEncoding
1049 i18n.logOutputEncoding
1050 log.showroot
12977705 1051 merge.tool
78d4d6a2
SP
1052 merge.summary
1053 merge.verbosity
5de40f59 1054 pack.window
12977705 1055 pack.depth
47e98eec
SP
1056 pack.windowMemory
1057 pack.compression
1058 pack.deltaCacheSize
1059 pack.deltaCacheLimit
78d4d6a2
SP
1060 pull.octopus
1061 pull.twohead
5de40f59 1062 repack.useDeltaBaseOffset
78d4d6a2
SP
1063 show.difftree
1064 showbranch.default
1065 tar.umask
1066 transfer.unpackLimit
5de40f59
SP
1067 receive.unpackLimit
1068 receive.denyNonFastForwards
78d4d6a2
SP
1069 user.name
1070 user.email
1071 user.signingkey
1072 whatchanged.difftree
5de40f59 1073 branch. remote.
78d4d6a2 1074 "
5de40f59
SP
1075}
1076
88293c67
SP
1077_git_remote ()
1078{
3ff1320d
SG
1079 local subcommands="add rm show prune update"
1080 local subcommand="$(__git_find_subcommand "$subcommands")"
1081 if [ -z "$subcommand" ]; then
3903c618 1082 __gitcomp "$subcommands"
88293c67
SP
1083 return
1084 fi
1085
3ff1320d 1086 case "$subcommand" in
a3b811a4 1087 rm|show|prune)
88293c67
SP
1088 __gitcomp "$(__git_remotes)"
1089 ;;
fb72759b
SP
1090 update)
1091 local i c='' IFS=$'\n'
1092 for i in $(git --git-dir="$(__gitdir)" config --list); do
1093 case "$i" in
1094 remotes.*)
1095 i="${i#remotes.}"
1096 c="$c ${i/=*/}"
1097 ;;
1098 esac
1099 done
1100 __gitcomp "$c"
1101 ;;
88293c67
SP
1102 *)
1103 COMPREPLY=()
1104 ;;
1105 esac
1106}
1107
67e78c3b
SP
1108_git_reset ()
1109{
d773c631
SG
1110 __git_has_doubledash && return
1111
67e78c3b 1112 local cur="${COMP_WORDS[COMP_CWORD]}"
b3391775
SP
1113 case "$cur" in
1114 --*)
1115 __gitcomp "--mixed --hard --soft"
1116 return
1117 ;;
1118 esac
1119 __gitcomp "$(__git_refs)"
67e78c3b
SP
1120}
1121
1fd6bec9
SP
1122_git_shortlog ()
1123{
d773c631
SG
1124 __git_has_doubledash && return
1125
1fd6bec9
SP
1126 local cur="${COMP_WORDS[COMP_CWORD]}"
1127 case "$cur" in
1128 --*)
1129 __gitcomp "
1130 --max-count= --max-age= --since= --after=
1131 --min-age= --before= --until=
1132 --no-merges
1133 --author= --committer= --grep=
1134 --all-match
1135 --not --all
1136 --numbered --summary
1137 "
1138 return
1139 ;;
1140 esac
1141 __git_complete_revlist
1142}
1143
90131924
SP
1144_git_show ()
1145{
1146 local cur="${COMP_WORDS[COMP_CWORD]}"
1147 case "$cur" in
1148 --pretty=*)
b3391775 1149 __gitcomp "
90131924 1150 oneline short medium full fuller email raw
b3391775 1151 " "" "${cur##--pretty=}"
90131924
SP
1152 return
1153 ;;
1154 --*)
b3391775 1155 __gitcomp "--pretty="
90131924
SP
1156 return
1157 ;;
1158 esac
1159 __git_complete_file
1160}
1161
7fd53fce
JH
1162_git_stash ()
1163{
88b302f5 1164 local subcommands='save list show apply clear drop pop create'
3ff1320d
SG
1165 if [ -z "$(__git_find_subcommand "$subcommands")" ]; then
1166 __gitcomp "$subcommands"
1167 fi
7fd53fce
JH
1168}
1169
be86f7a0
SP
1170_git_submodule ()
1171{
d773c631
SG
1172 __git_has_doubledash && return
1173
3ff1320d
SG
1174 local subcommands="add status init update"
1175 if [ -z "$(__git_find_subcommand "$subcommands")" ]; then
be86f7a0
SP
1176 local cur="${COMP_WORDS[COMP_CWORD]}"
1177 case "$cur" in
1178 --*)
1179 __gitcomp "--quiet --cached"
1180 ;;
1181 *)
3ff1320d 1182 __gitcomp "$subcommands"
be86f7a0
SP
1183 ;;
1184 esac
1185 return
1186 fi
1187}
1188
47f6ee28
SG
1189_git_svn ()
1190{
1191 local subcommands="
1192 init fetch clone rebase dcommit log find-rev
1193 set-tree commit-diff info create-ignore propget
1194 proplist show-ignore show-externals
1195 "
1196 local subcommand="$(__git_find_subcommand "$subcommands")"
1197 if [ -z "$subcommand" ]; then
1198 __gitcomp "$subcommands"
1199 else
1200 local remote_opts="--username= --config-dir= --no-auth-cache"
1201 local fc_opts="
1202 --follow-parent --authors-file= --repack=
1203 --no-metadata --use-svm-props --use-svnsync-props
1204 --log-window-size= --no-checkout --quiet
1205 --repack-flags --user-log-author $remote_opts
1206 "
1207 local init_opts="
1208 --template= --shared= --trunk= --tags=
1209 --branches= --stdlayout --minimize-url
1210 --no-metadata --use-svm-props --use-svnsync-props
1211 --rewrite-root= $remote_opts
1212 "
1213 local cmt_opts="
1214 --edit --rmdir --find-copies-harder --copy-similarity=
1215 "
1216
1217 local cur="${COMP_WORDS[COMP_CWORD]}"
1218 case "$subcommand,$cur" in
1219 fetch,--*)
1220 __gitcomp "--revision= --fetch-all $fc_opts"
1221 ;;
1222 clone,--*)
1223 __gitcomp "--revision= $fc_opts $init_opts"
1224 ;;
1225 init,--*)
1226 __gitcomp "$init_opts"
1227 ;;
1228 dcommit,--*)
1229 __gitcomp "
1230 --merge --strategy= --verbose --dry-run
1231 --fetch-all --no-rebase $cmt_opts $fc_opts
1232 "
1233 ;;
1234 set-tree,--*)
1235 __gitcomp "--stdin $cmt_opts $fc_opts"
1236 ;;
1237 create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\
1238 show-externals,--*)
1239 __gitcomp "--revision="
1240 ;;
1241 log,--*)
1242 __gitcomp "
1243 --limit= --revision= --verbose --incremental
1244 --oneline --show-commit --non-recursive
1245 --authors-file=
1246 "
1247 ;;
1248 rebase,--*)
1249 __gitcomp "
1250 --merge --verbose --strategy= --local
1251 --fetch-all $fc_opts
1252 "
1253 ;;
1254 commit-diff,--*)
1255 __gitcomp "--message= --file= --revision= $cmt_opts"
1256 ;;
1257 info,--*)
1258 __gitcomp "--url"
1259 ;;
1260 *)
1261 COMPREPLY=()
1262 ;;
1263 esac
1264 fi
1265}
1266
88e21dc7
SP
1267_git_tag ()
1268{
1269 local i c=1 f=0
1270 while [ $c -lt $COMP_CWORD ]; do
1271 i="${COMP_WORDS[c]}"
1272 case "$i" in
1273 -d|-v)
1274 __gitcomp "$(__git_tags)"
1275 return
1276 ;;
1277 -f)
1278 f=1
1279 ;;
1280 esac
1281 c=$((++c))
1282 done
1283
1284 case "${COMP_WORDS[COMP_CWORD-1]}" in
1285 -m|-F)
1286 COMPREPLY=()
1287 ;;
1288 -*|tag|git-tag)
1289 if [ $f = 1 ]; then
1290 __gitcomp "$(__git_tags)"
1291 else
1292 COMPREPLY=()
1293 fi
1294 ;;
1295 *)
1296 __gitcomp "$(__git_refs)"
1297 ;;
1298 esac
1299}
1300
690d8824
JH
1301_git ()
1302{
873537fa
SP
1303 local i c=1 command __git_dir
1304
1305 while [ $c -lt $COMP_CWORD ]; do
1306 i="${COMP_WORDS[c]}"
1307 case "$i" in
1308 --git-dir=*) __git_dir="${i#--git-dir=}" ;;
1309 --bare) __git_dir="." ;;
1310 --version|--help|-p|--paginate) ;;
1311 *) command="$i"; break ;;
1312 esac
1313 c=$((++c))
1314 done
1315
1d17b22e 1316 if [ -z "$command" ]; then
72e5e989
SP
1317 case "${COMP_WORDS[COMP_CWORD]}" in
1318 --*=*) COMPREPLY=() ;;
47e98eec 1319 --*) __gitcomp "
ce5a2c95 1320 --paginate
47e98eec
SP
1321 --no-pager
1322 --git-dir=
1323 --bare
1324 --version
1325 --exec-path
ce5a2c95
TL
1326 --work-tree=
1327 --help
47e98eec
SP
1328 "
1329 ;;
72e5e989
SP
1330 *) __gitcomp "$(__git_commands) $(__git_aliases)" ;;
1331 esac
1332 return
873537fa 1333 fi
367dce2a 1334
873537fa
SP
1335 local expansion=$(__git_aliased_command "$command")
1336 [ "$expansion" ] && command="$expansion"
367dce2a 1337
873537fa 1338 case "$command" in
88329195 1339 am) _git_am ;;
8435b548 1340 add) _git_add ;;
88329195 1341 apply) _git_apply ;;
b2e69f62 1342 bisect) _git_bisect ;;
374a58c9 1343 bundle) _git_bundle ;;
873537fa 1344 branch) _git_branch ;;
873537fa 1345 checkout) _git_checkout ;;
d8a9fea5 1346 cherry) _git_cherry ;;
1273231e 1347 cherry-pick) _git_cherry_pick ;;
4548e855 1348 commit) _git_commit ;;
e0d10e1c 1349 config) _git_config ;;
217926c0 1350 describe) _git_describe ;;
873537fa 1351 diff) _git_diff ;;
873537fa 1352 fetch) _git_fetch ;;
f53352fb 1353 format-patch) _git_format_patch ;;
b26c8748 1354 gc) _git_gc ;;
873537fa
SP
1355 log) _git_log ;;
1356 ls-remote) _git_ls_remote ;;
1357 ls-tree) _git_ls_tree ;;
4ad91321 1358 merge) _git_merge;;
873537fa 1359 merge-base) _git_merge_base ;;
d33909bf 1360 name-rev) _git_name_rev ;;
873537fa
SP
1361 pull) _git_pull ;;
1362 push) _git_push ;;
61d926a3 1363 rebase) _git_rebase ;;
88293c67 1364 remote) _git_remote ;;
873537fa 1365 reset) _git_reset ;;
1fd6bec9 1366 shortlog) _git_shortlog ;;
90131924 1367 show) _git_show ;;
873537fa 1368 show-branch) _git_log ;;
7fd53fce 1369 stash) _git_stash ;;
be86f7a0 1370 submodule) _git_submodule ;;
47f6ee28 1371 svn) _git_svn ;;
88e21dc7 1372 tag) _git_tag ;;
873537fa
SP
1373 whatchanged) _git_log ;;
1374 *) COMPREPLY=() ;;
1375 esac
690d8824
JH
1376}
1377
1378_gitk ()
1379{
d773c631
SG
1380 __git_has_doubledash && return
1381
690d8824 1382 local cur="${COMP_WORDS[COMP_CWORD]}"
07ba53f7
RQ
1383 local g="$(git rev-parse --git-dir 2>/dev/null)"
1384 local merge=""
1385 if [ -f $g/MERGE_HEAD ]; then
1386 merge="--merge"
1387 fi
b3391775
SP
1388 case "$cur" in
1389 --*)
07ba53f7 1390 __gitcomp "--not --all $merge"
b3391775
SP
1391 return
1392 ;;
1393 esac
ec804891 1394 __git_complete_revlist
690d8824
JH
1395}
1396
1397complete -o default -o nospace -F _git git
b3391775
SP
1398complete -o default -o nospace -F _gitk gitk
1399complete -o default -o nospace -F _git_am git-am
1400complete -o default -o nospace -F _git_apply git-apply
b2e69f62 1401complete -o default -o nospace -F _git_bisect git-bisect
b3391775 1402complete -o default -o nospace -F _git_branch git-branch
374a58c9 1403complete -o default -o nospace -F _git_bundle git-bundle
b3391775 1404complete -o default -o nospace -F _git_checkout git-checkout
d8a9fea5 1405complete -o default -o nospace -F _git_cherry git-cherry
b3391775
SP
1406complete -o default -o nospace -F _git_cherry_pick git-cherry-pick
1407complete -o default -o nospace -F _git_commit git-commit
217926c0 1408complete -o default -o nospace -F _git_describe git-describe
690d8824 1409complete -o default -o nospace -F _git_diff git-diff
690d8824 1410complete -o default -o nospace -F _git_fetch git-fetch
f53352fb 1411complete -o default -o nospace -F _git_format_patch git-format-patch
b26c8748 1412complete -o default -o nospace -F _git_gc git-gc
690d8824 1413complete -o default -o nospace -F _git_log git-log
b3391775 1414complete -o default -o nospace -F _git_ls_remote git-ls-remote
690d8824 1415complete -o default -o nospace -F _git_ls_tree git-ls-tree
b3391775
SP
1416complete -o default -o nospace -F _git_merge git-merge
1417complete -o default -o nospace -F _git_merge_base git-merge-base
1418complete -o default -o nospace -F _git_name_rev git-name-rev
690d8824
JH
1419complete -o default -o nospace -F _git_pull git-pull
1420complete -o default -o nospace -F _git_push git-push
b3391775
SP
1421complete -o default -o nospace -F _git_rebase git-rebase
1422complete -o default -o nospace -F _git_config git-config
88293c67 1423complete -o default -o nospace -F _git_remote git-remote
b3391775 1424complete -o default -o nospace -F _git_reset git-reset
1fd6bec9 1425complete -o default -o nospace -F _git_shortlog git-shortlog
90131924 1426complete -o default -o nospace -F _git_show git-show
7fd53fce 1427complete -o default -o nospace -F _git_stash git-stash
be86f7a0 1428complete -o default -o nospace -F _git_submodule git-submodule
47f6ee28 1429complete -o default -o nospace -F _git_svn git-svn
144d33de 1430complete -o default -o nospace -F _git_log git-show-branch
88e21dc7 1431complete -o default -o nospace -F _git_tag git-tag
690d8824
JH
1432complete -o default -o nospace -F _git_log git-whatchanged
1433
1434# The following are necessary only for Cygwin, and only are needed
1435# when the user has tab-completed the executable name and consequently
1436# included the '.exe' suffix.
1437#
76c3eb51 1438if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
b3391775
SP
1439complete -o default -o nospace -F _git_add git-add.exe
1440complete -o default -o nospace -F _git_apply git-apply.exe
144d33de 1441complete -o default -o nospace -F _git git.exe
b3391775 1442complete -o default -o nospace -F _git_branch git-branch.exe
374a58c9 1443complete -o default -o nospace -F _git_bundle git-bundle.exe
d8a9fea5 1444complete -o default -o nospace -F _git_cherry git-cherry.exe
217926c0 1445complete -o default -o nospace -F _git_describe git-describe.exe
690d8824 1446complete -o default -o nospace -F _git_diff git-diff.exe
f53352fb 1447complete -o default -o nospace -F _git_format_patch git-format-patch.exe
690d8824
JH
1448complete -o default -o nospace -F _git_log git-log.exe
1449complete -o default -o nospace -F _git_ls_tree git-ls-tree.exe
b3391775
SP
1450complete -o default -o nospace -F _git_merge_base git-merge-base.exe
1451complete -o default -o nospace -F _git_name_rev git-name-rev.exe
690d8824 1452complete -o default -o nospace -F _git_push git-push.exe
b3391775 1453complete -o default -o nospace -F _git_config git-config
1fd6bec9 1454complete -o default -o nospace -F _git_shortlog git-shortlog.exe
90131924 1455complete -o default -o nospace -F _git_show git-show.exe
144d33de 1456complete -o default -o nospace -F _git_log git-show-branch.exe
88e21dc7 1457complete -o default -o nospace -F _git_tag git-tag.exe
690d8824 1458complete -o default -o nospace -F _git_log git-whatchanged.exe
76c3eb51 1459fi