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