]> git.ipfire.org Git - thirdparty/git.git/blame - contrib/completion/git-completion.bash
git add: add long equivalents of '-u' and '-f' options
[thirdparty/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
88329195
SP
454__git_whitespacelist="nowarn warn error error-all strip"
455
456_git_am ()
457{
458 local cur="${COMP_WORDS[COMP_CWORD]}"
459 if [ -d .dotest ]; then
b3391775 460 __gitcomp "--skip --resolved"
88329195
SP
461 return
462 fi
463 case "$cur" in
464 --whitespace=*)
b3391775 465 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
88329195
SP
466 return
467 ;;
468 --*)
b3391775 469 __gitcomp "
88329195
SP
470 --signoff --utf8 --binary --3way --interactive
471 --whitespace=
b3391775 472 "
88329195
SP
473 return
474 esac
475 COMPREPLY=()
476}
477
478_git_apply ()
479{
480 local cur="${COMP_WORDS[COMP_CWORD]}"
481 case "$cur" in
482 --whitespace=*)
b3391775 483 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
88329195
SP
484 return
485 ;;
486 --*)
b3391775 487 __gitcomp "
88329195
SP
488 --stat --numstat --summary --check --index
489 --cached --index-info --reverse --reject --unidiff-zero
490 --apply --no-add --exclude=
491 --whitespace= --inaccurate-eof --verbose
b3391775 492 "
88329195
SP
493 return
494 esac
495 COMPREPLY=()
496}
497
8435b548
SP
498_git_add ()
499{
500 local cur="${COMP_WORDS[COMP_CWORD]}"
501 case "$cur" in
502 --*)
47e98eec 503 __gitcomp "--interactive --refresh"
8435b548
SP
504 return
505 esac
506 COMPREPLY=()
507}
508
b2e69f62
SP
509_git_bisect ()
510{
3ff1320d
SG
511 local subcommands="start bad good reset visualize replay log"
512 local subcommand="$(__git_find_subcommand "$subcommands")"
513 if [ -z "$subcommand" ]; then
514 __gitcomp "$subcommands"
b2e69f62
SP
515 return
516 fi
517
3ff1320d 518 case "$subcommand" in
b2e69f62
SP
519 bad|good|reset)
520 __gitcomp "$(__git_refs)"
521 ;;
522 *)
523 COMPREPLY=()
524 ;;
525 esac
526}
527
690d8824
JH
528_git_branch ()
529{
b9217642
SG
530 local i c=1 only_local_ref="n" has_r="n"
531
532 while [ $c -lt $COMP_CWORD ]; do
533 i="${COMP_WORDS[c]}"
534 case "$i" in
535 -d|-m) only_local_ref="y" ;;
536 -r) has_r="y" ;;
537 esac
538 c=$((++c))
539 done
540
3b376b0c
SG
541 case "${COMP_WORDS[COMP_CWORD]}" in
542 --*=*) COMPREPLY=() ;;
543 --*)
544 __gitcomp "
545 --color --no-color --verbose --abbrev= --no-abbrev
546 --track --no-track
547 "
548 ;;
b9217642
SG
549 *)
550 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
551 __gitcomp "$(__git_heads)"
552 else
553 __gitcomp "$(__git_refs)"
554 fi
555 ;;
3b376b0c 556 esac
690d8824
JH
557}
558
374a58c9
ML
559_git_bundle ()
560{
561 local mycword="$COMP_CWORD"
562 case "${COMP_WORDS[0]}" in
563 git)
564 local cmd="${COMP_WORDS[2]}"
565 mycword="$((mycword-1))"
566 ;;
567 git-bundle*)
568 local cmd="${COMP_WORDS[1]}"
569 ;;
570 esac
571 case "$mycword" in
572 1)
573 __gitcomp "create list-heads verify unbundle"
574 ;;
575 2)
576 # looking for a file
577 ;;
578 *)
579 case "$cmd" in
580 create)
581 __git_complete_revlist
582 ;;
583 esac
584 ;;
585 esac
586}
587
690d8824
JH
588_git_checkout ()
589{
b3391775 590 __gitcomp "$(__git_refs)"
690d8824
JH
591}
592
d8a9fea5
SP
593_git_cherry ()
594{
595 __gitcomp "$(__git_refs)"
596}
597
1273231e
SP
598_git_cherry_pick ()
599{
600 local cur="${COMP_WORDS[COMP_CWORD]}"
601 case "$cur" in
602 --*)
b3391775 603 __gitcomp "--edit --no-commit"
1273231e
SP
604 ;;
605 *)
b3391775 606 __gitcomp "$(__git_refs)"
1273231e
SP
607 ;;
608 esac
609}
610
4548e855
SP
611_git_commit ()
612{
613 local cur="${COMP_WORDS[COMP_CWORD]}"
614 case "$cur" in
615 --*)
b3391775 616 __gitcomp "
4548e855
SP
617 --all --author= --signoff --verify --no-verify
618 --edit --amend --include --only
b3391775 619 "
4548e855
SP
620 return
621 esac
622 COMPREPLY=()
623}
624
217926c0
SP
625_git_describe ()
626{
627 __gitcomp "$(__git_refs)"
628}
629
690d8824
JH
630_git_diff ()
631{
b3a4f858
JS
632 local cur="${COMP_WORDS[COMP_CWORD]}"
633 case "$cur" in
634 --*)
635 __gitcomp "--cached --stat --numstat --shortstat --summary
636 --patch-with-stat --name-only --name-status --color
637 --no-color --color-words --no-renames --check
638 --full-index --binary --abbrev --diff-filter
639 --find-copies-harder --pickaxe-all --pickaxe-regex
640 --text --ignore-space-at-eol --ignore-space-change
641 --ignore-all-space --exit-code --quiet --ext-diff
aba201c6
PO
642 --no-ext-diff
643 --no-prefix --src-prefix= --dst-prefix=
f4574139 644 --base --ours --theirs
aba201c6 645 "
b3a4f858
JS
646 return
647 ;;
648 esac
690d8824
JH
649 __git_complete_file
650}
651
652_git_diff_tree ()
653{
b3391775 654 __gitcomp "$(__git_refs)"
690d8824
JH
655}
656
657_git_fetch ()
658{
659 local cur="${COMP_WORDS[COMP_CWORD]}"
660
661 case "${COMP_WORDS[0]},$COMP_CWORD" in
662 git-fetch*,1)
b3391775 663 __gitcomp "$(__git_remotes)"
690d8824
JH
664 ;;
665 git,2)
b3391775 666 __gitcomp "$(__git_remotes)"
690d8824
JH
667 ;;
668 *)
669 case "$cur" in
670 *:*)
b3391775 671 __gitcomp "$(__git_refs)" "" "${cur#*:}"
690d8824
JH
672 ;;
673 *)
674 local remote
675 case "${COMP_WORDS[0]}" in
676 git-fetch) remote="${COMP_WORDS[1]}" ;;
677 git) remote="${COMP_WORDS[2]}" ;;
678 esac
b3391775 679 __gitcomp "$(__git_refs2 "$remote")"
690d8824
JH
680 ;;
681 esac
682 ;;
683 esac
684}
685
f53352fb
SP
686_git_format_patch ()
687{
688 local cur="${COMP_WORDS[COMP_CWORD]}"
689 case "$cur" in
690 --*)
b3391775 691 __gitcomp "
f53352fb
SP
692 --stdout --attach --thread
693 --output-directory
694 --numbered --start-number
47e98eec 695 --numbered-files
f53352fb
SP
696 --keep-subject
697 --signoff
698 --in-reply-to=
699 --full-index --binary
ec804891 700 --not --all
be5f5bf0 701 --cover-letter
aba201c6 702 --no-prefix --src-prefix= --dst-prefix=
b3391775 703 "
f53352fb
SP
704 return
705 ;;
706 esac
707 __git_complete_revlist
708}
709
b26c8748
SP
710_git_gc ()
711{
712 local cur="${COMP_WORDS[COMP_CWORD]}"
713 case "$cur" in
714 --*)
47e98eec 715 __gitcomp "--prune --aggressive"
b26c8748
SP
716 return
717 ;;
718 esac
719 COMPREPLY=()
720}
721
690d8824
JH
722_git_ls_remote ()
723{
b3391775 724 __gitcomp "$(__git_remotes)"
690d8824
JH
725}
726
727_git_ls_tree ()
728{
729 __git_complete_file
730}
731
732_git_log ()
733{
6e31b866
SP
734 local cur="${COMP_WORDS[COMP_CWORD]}"
735 case "$cur" in
736 --pretty=*)
b3391775 737 __gitcomp "
6e31b866 738 oneline short medium full fuller email raw
b3391775 739 " "" "${cur##--pretty=}"
6e31b866
SP
740 return
741 ;;
47e98eec
SP
742 --date=*)
743 __gitcomp "
744 relative iso8601 rfc2822 short local default
745 " "" "${cur##--date=}"
746 return
747 ;;
6e31b866 748 --*)
b3391775 749 __gitcomp "
6e31b866
SP
750 --max-count= --max-age= --since= --after=
751 --min-age= --before= --until=
8f87fae6 752 --root --topo-order --date-order --reverse
47e98eec 753 --no-merges --follow
6e31b866 754 --abbrev-commit --abbrev=
47e98eec 755 --relative-date --date=
6e31b866
SP
756 --author= --committer= --grep=
757 --all-match
8f87fae6 758 --pretty= --name-status --name-only --raw
ec804891 759 --not --all
7d37b5bf 760 --left-right --cherry-pick
b3391775 761 "
6e31b866
SP
762 return
763 ;;
764 esac
f53352fb 765 __git_complete_revlist
690d8824
JH
766}
767
4ad91321
SP
768_git_merge ()
769{
770 local cur="${COMP_WORDS[COMP_CWORD]}"
ce1e39d2
SP
771 case "${COMP_WORDS[COMP_CWORD-1]}" in
772 -s|--strategy)
b3391775 773 __gitcomp "$(__git_merge_strategies)"
ce1e39d2
SP
774 return
775 esac
4ad91321 776 case "$cur" in
ce1e39d2 777 --strategy=*)
b3391775 778 __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}"
ce1e39d2
SP
779 return
780 ;;
4ad91321 781 --*)
b3391775 782 __gitcomp "
efb779f8 783 --no-commit --no-stat --log --no-log --squash --strategy
b3391775 784 "
4ad91321
SP
785 return
786 esac
b3391775 787 __gitcomp "$(__git_refs)"
4ad91321
SP
788}
789
690d8824
JH
790_git_merge_base ()
791{
b3391775 792 __gitcomp "$(__git_refs)"
690d8824
JH
793}
794
d33909bf
SP
795_git_name_rev ()
796{
b3391775 797 __gitcomp "--tags --all --stdin"
d33909bf
SP
798}
799
690d8824
JH
800_git_pull ()
801{
802 local cur="${COMP_WORDS[COMP_CWORD]}"
803
804 case "${COMP_WORDS[0]},$COMP_CWORD" in
805 git-pull*,1)
b3391775 806 __gitcomp "$(__git_remotes)"
690d8824
JH
807 ;;
808 git,2)
b3391775 809 __gitcomp "$(__git_remotes)"
690d8824
JH
810 ;;
811 *)
812 local remote
813 case "${COMP_WORDS[0]}" in
814 git-pull) remote="${COMP_WORDS[1]}" ;;
815 git) remote="${COMP_WORDS[2]}" ;;
816 esac
b3391775 817 __gitcomp "$(__git_refs "$remote")"
690d8824
JH
818 ;;
819 esac
820}
821
822_git_push ()
823{
824 local cur="${COMP_WORDS[COMP_CWORD]}"
825
826 case "${COMP_WORDS[0]},$COMP_CWORD" in
827 git-push*,1)
b3391775 828 __gitcomp "$(__git_remotes)"
690d8824
JH
829 ;;
830 git,2)
b3391775 831 __gitcomp "$(__git_remotes)"
690d8824
JH
832 ;;
833 *)
834 case "$cur" in
835 *:*)
836 local remote
837 case "${COMP_WORDS[0]}" in
838 git-push) remote="${COMP_WORDS[1]}" ;;
839 git) remote="${COMP_WORDS[2]}" ;;
840 esac
b3391775 841 __gitcomp "$(__git_refs "$remote")" "" "${cur#*:}"
690d8824 842 ;;
161fea83
SP
843 +*)
844 __gitcomp "$(__git_refs)" + "${cur#+}"
845 ;;
690d8824 846 *)
92d7c8e3 847 __gitcomp "$(__git_refs)"
690d8824
JH
848 ;;
849 esac
850 ;;
851 esac
852}
853
61d926a3
SP
854_git_rebase ()
855{
51fe1209
SG
856 local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)"
857 if [ -d .dotest ] || [ -d "$dir"/.dotest-merge ]; then
b3391775 858 __gitcomp "--continue --skip --abort"
61d926a3
SP
859 return
860 fi
ce1e39d2
SP
861 case "${COMP_WORDS[COMP_CWORD-1]}" in
862 -s|--strategy)
b3391775 863 __gitcomp "$(__git_merge_strategies)"
ce1e39d2
SP
864 return
865 esac
61d926a3 866 case "$cur" in
ce1e39d2 867 --strategy=*)
b3391775 868 __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}"
ce1e39d2
SP
869 return
870 ;;
61d926a3 871 --*)
d9e3b702 872 __gitcomp "--onto --merge --strategy --interactive"
61d926a3
SP
873 return
874 esac
b3391775 875 __gitcomp "$(__git_refs)"
61d926a3
SP
876}
877
e0d10e1c 878_git_config ()
5de40f59
SP
879{
880 local cur="${COMP_WORDS[COMP_CWORD]}"
881 local prv="${COMP_WORDS[COMP_CWORD-1]}"
882 case "$prv" in
883 branch.*.remote)
78d4d6a2 884 __gitcomp "$(__git_remotes)"
5de40f59
SP
885 return
886 ;;
887 branch.*.merge)
78d4d6a2 888 __gitcomp "$(__git_refs)"
5de40f59
SP
889 return
890 ;;
891 remote.*.fetch)
892 local remote="${prv#remote.}"
893 remote="${remote%.fetch}"
78d4d6a2 894 __gitcomp "$(__git_refs_remotes "$remote")"
5de40f59
SP
895 return
896 ;;
897 remote.*.push)
898 local remote="${prv#remote.}"
899 remote="${remote%.push}"
78d4d6a2 900 __gitcomp "$(git --git-dir="$(__gitdir)" \
5de40f59 901 for-each-ref --format='%(refname):%(refname)' \
78d4d6a2
SP
902 refs/heads)"
903 return
904 ;;
905 pull.twohead|pull.octopus)
906 __gitcomp "$(__git_merge_strategies)"
907 return
908 ;;
909 color.branch|color.diff|color.status)
910 __gitcomp "always never auto"
911 return
912 ;;
913 color.*.*)
914 __gitcomp "
915 black red green yellow blue magenta cyan white
916 bold dim ul blink reverse
917 "
5de40f59
SP
918 return
919 ;;
920 *.*)
921 COMPREPLY=()
922 return
923 ;;
924 esac
925 case "$cur" in
926 --*)
78d4d6a2 927 __gitcomp "
47e98eec 928 --global --system --file=
12977705 929 --list --replace-all
5de40f59 930 --get --get-all --get-regexp
1b71eb35 931 --add --unset --unset-all
12977705 932 --remove-section --rename-section
78d4d6a2 933 "
5de40f59
SP
934 return
935 ;;
936 branch.*.*)
937 local pfx="${cur%.*}."
938 cur="${cur##*.}"
78d4d6a2 939 __gitcomp "remote merge" "$pfx" "$cur"
5de40f59
SP
940 return
941 ;;
942 branch.*)
943 local pfx="${cur%.*}."
944 cur="${cur#*.}"
78d4d6a2 945 __gitcomp "$(__git_heads)" "$pfx" "$cur" "."
5de40f59
SP
946 return
947 ;;
948 remote.*.*)
949 local pfx="${cur%.*}."
950 cur="${cur##*.}"
12977705
SP
951 __gitcomp "
952 url fetch push skipDefaultUpdate
953 receivepack uploadpack tagopt
954 " "$pfx" "$cur"
5de40f59
SP
955 return
956 ;;
957 remote.*)
958 local pfx="${cur%.*}."
959 cur="${cur#*.}"
78d4d6a2 960 __gitcomp "$(__git_remotes)" "$pfx" "$cur" "."
5de40f59
SP
961 return
962 ;;
963 esac
78d4d6a2 964 __gitcomp "
5de40f59
SP
965 apply.whitespace
966 core.fileMode
967 core.gitProxy
968 core.ignoreStat
969 core.preferSymlinkRefs
970 core.logAllRefUpdates
47e98eec 971 core.loosecompression
5de40f59
SP
972 core.repositoryFormatVersion
973 core.sharedRepository
974 core.warnAmbiguousRefs
975 core.compression
78d4d6a2
SP
976 core.packedGitWindowSize
977 core.packedGitLimit
2122591b 978 clean.requireForce
78d4d6a2
SP
979 color.branch
980 color.branch.current
981 color.branch.local
982 color.branch.remote
983 color.branch.plain
a159ca0c 984 color.diff
78d4d6a2
SP
985 color.diff.plain
986 color.diff.meta
987 color.diff.frag
988 color.diff.old
989 color.diff.new
990 color.diff.commit
991 color.diff.whitespace
a159ca0c 992 color.pager
a159ca0c 993 color.status
78d4d6a2
SP
994 color.status.header
995 color.status.added
996 color.status.changed
997 color.status.untracked
998 diff.renameLimit
999 diff.renames
1000 fetch.unpackLimit
1001 format.headers
47e98eec 1002 format.subjectprefix
78d4d6a2
SP
1003 gitcvs.enabled
1004 gitcvs.logfile
12977705 1005 gitcvs.allbinary
6aeeffd1
JE
1006 gitcvs.dbname gitcvs.dbdriver gitcvs.dbuser gitcvs.dbpass
1007 gitcvs.dbtablenameprefix
12977705 1008 gc.packrefs
78d4d6a2
SP
1009 gc.reflogexpire
1010 gc.reflogexpireunreachable
1011 gc.rerereresolved
1012 gc.rerereunresolved
5de40f59
SP
1013 http.sslVerify
1014 http.sslCert
1015 http.sslKey
1016 http.sslCAInfo
1017 http.sslCAPath
1018 http.maxRequests
78d4d6a2
SP
1019 http.lowSpeedLimit
1020 http.lowSpeedTime
5de40f59 1021 http.noEPSV
78d4d6a2
SP
1022 i18n.commitEncoding
1023 i18n.logOutputEncoding
1024 log.showroot
12977705 1025 merge.tool
78d4d6a2
SP
1026 merge.summary
1027 merge.verbosity
5de40f59 1028 pack.window
12977705 1029 pack.depth
47e98eec
SP
1030 pack.windowMemory
1031 pack.compression
1032 pack.deltaCacheSize
1033 pack.deltaCacheLimit
78d4d6a2
SP
1034 pull.octopus
1035 pull.twohead
5de40f59 1036 repack.useDeltaBaseOffset
78d4d6a2
SP
1037 show.difftree
1038 showbranch.default
1039 tar.umask
1040 transfer.unpackLimit
5de40f59
SP
1041 receive.unpackLimit
1042 receive.denyNonFastForwards
78d4d6a2
SP
1043 user.name
1044 user.email
1045 user.signingkey
1046 whatchanged.difftree
5de40f59 1047 branch. remote.
78d4d6a2 1048 "
5de40f59
SP
1049}
1050
88293c67
SP
1051_git_remote ()
1052{
3ff1320d
SG
1053 local subcommands="add rm show prune update"
1054 local subcommand="$(__git_find_subcommand "$subcommands")"
1055 if [ -z "$subcommand" ]; then
3903c618 1056 __gitcomp "$subcommands"
88293c67
SP
1057 return
1058 fi
1059
3ff1320d 1060 case "$subcommand" in
a3b811a4 1061 rm|show|prune)
88293c67
SP
1062 __gitcomp "$(__git_remotes)"
1063 ;;
fb72759b
SP
1064 update)
1065 local i c='' IFS=$'\n'
1066 for i in $(git --git-dir="$(__gitdir)" config --list); do
1067 case "$i" in
1068 remotes.*)
1069 i="${i#remotes.}"
1070 c="$c ${i/=*/}"
1071 ;;
1072 esac
1073 done
1074 __gitcomp "$c"
1075 ;;
88293c67
SP
1076 *)
1077 COMPREPLY=()
1078 ;;
1079 esac
1080}
1081
67e78c3b
SP
1082_git_reset ()
1083{
1084 local cur="${COMP_WORDS[COMP_CWORD]}"
b3391775
SP
1085 case "$cur" in
1086 --*)
1087 __gitcomp "--mixed --hard --soft"
1088 return
1089 ;;
1090 esac
1091 __gitcomp "$(__git_refs)"
67e78c3b
SP
1092}
1093
1fd6bec9
SP
1094_git_shortlog ()
1095{
1096 local cur="${COMP_WORDS[COMP_CWORD]}"
1097 case "$cur" in
1098 --*)
1099 __gitcomp "
1100 --max-count= --max-age= --since= --after=
1101 --min-age= --before= --until=
1102 --no-merges
1103 --author= --committer= --grep=
1104 --all-match
1105 --not --all
1106 --numbered --summary
1107 "
1108 return
1109 ;;
1110 esac
1111 __git_complete_revlist
1112}
1113
90131924
SP
1114_git_show ()
1115{
1116 local cur="${COMP_WORDS[COMP_CWORD]}"
1117 case "$cur" in
1118 --pretty=*)
b3391775 1119 __gitcomp "
90131924 1120 oneline short medium full fuller email raw
b3391775 1121 " "" "${cur##--pretty=}"
90131924
SP
1122 return
1123 ;;
1124 --*)
b3391775 1125 __gitcomp "--pretty="
90131924
SP
1126 return
1127 ;;
1128 esac
1129 __git_complete_file
1130}
1131
7fd53fce
JH
1132_git_stash ()
1133{
88b302f5 1134 local subcommands='save list show apply clear drop pop create'
3ff1320d
SG
1135 if [ -z "$(__git_find_subcommand "$subcommands")" ]; then
1136 __gitcomp "$subcommands"
1137 fi
7fd53fce
JH
1138}
1139
be86f7a0
SP
1140_git_submodule ()
1141{
3ff1320d
SG
1142 local subcommands="add status init update"
1143 if [ -z "$(__git_find_subcommand "$subcommands")" ]; then
be86f7a0
SP
1144 local cur="${COMP_WORDS[COMP_CWORD]}"
1145 case "$cur" in
1146 --*)
1147 __gitcomp "--quiet --cached"
1148 ;;
1149 *)
3ff1320d 1150 __gitcomp "$subcommands"
be86f7a0
SP
1151 ;;
1152 esac
1153 return
1154 fi
1155}
1156
47f6ee28
SG
1157_git_svn ()
1158{
1159 local subcommands="
1160 init fetch clone rebase dcommit log find-rev
1161 set-tree commit-diff info create-ignore propget
1162 proplist show-ignore show-externals
1163 "
1164 local subcommand="$(__git_find_subcommand "$subcommands")"
1165 if [ -z "$subcommand" ]; then
1166 __gitcomp "$subcommands"
1167 else
1168 local remote_opts="--username= --config-dir= --no-auth-cache"
1169 local fc_opts="
1170 --follow-parent --authors-file= --repack=
1171 --no-metadata --use-svm-props --use-svnsync-props
1172 --log-window-size= --no-checkout --quiet
1173 --repack-flags --user-log-author $remote_opts
1174 "
1175 local init_opts="
1176 --template= --shared= --trunk= --tags=
1177 --branches= --stdlayout --minimize-url
1178 --no-metadata --use-svm-props --use-svnsync-props
1179 --rewrite-root= $remote_opts
1180 "
1181 local cmt_opts="
1182 --edit --rmdir --find-copies-harder --copy-similarity=
1183 "
1184
1185 local cur="${COMP_WORDS[COMP_CWORD]}"
1186 case "$subcommand,$cur" in
1187 fetch,--*)
1188 __gitcomp "--revision= --fetch-all $fc_opts"
1189 ;;
1190 clone,--*)
1191 __gitcomp "--revision= $fc_opts $init_opts"
1192 ;;
1193 init,--*)
1194 __gitcomp "$init_opts"
1195 ;;
1196 dcommit,--*)
1197 __gitcomp "
1198 --merge --strategy= --verbose --dry-run
1199 --fetch-all --no-rebase $cmt_opts $fc_opts
1200 "
1201 ;;
1202 set-tree,--*)
1203 __gitcomp "--stdin $cmt_opts $fc_opts"
1204 ;;
1205 create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\
1206 show-externals,--*)
1207 __gitcomp "--revision="
1208 ;;
1209 log,--*)
1210 __gitcomp "
1211 --limit= --revision= --verbose --incremental
1212 --oneline --show-commit --non-recursive
1213 --authors-file=
1214 "
1215 ;;
1216 rebase,--*)
1217 __gitcomp "
1218 --merge --verbose --strategy= --local
1219 --fetch-all $fc_opts
1220 "
1221 ;;
1222 commit-diff,--*)
1223 __gitcomp "--message= --file= --revision= $cmt_opts"
1224 ;;
1225 info,--*)
1226 __gitcomp "--url"
1227 ;;
1228 *)
1229 COMPREPLY=()
1230 ;;
1231 esac
1232 fi
1233}
1234
88e21dc7
SP
1235_git_tag ()
1236{
1237 local i c=1 f=0
1238 while [ $c -lt $COMP_CWORD ]; do
1239 i="${COMP_WORDS[c]}"
1240 case "$i" in
1241 -d|-v)
1242 __gitcomp "$(__git_tags)"
1243 return
1244 ;;
1245 -f)
1246 f=1
1247 ;;
1248 esac
1249 c=$((++c))
1250 done
1251
1252 case "${COMP_WORDS[COMP_CWORD-1]}" in
1253 -m|-F)
1254 COMPREPLY=()
1255 ;;
1256 -*|tag|git-tag)
1257 if [ $f = 1 ]; then
1258 __gitcomp "$(__git_tags)"
1259 else
1260 COMPREPLY=()
1261 fi
1262 ;;
1263 *)
1264 __gitcomp "$(__git_refs)"
1265 ;;
1266 esac
1267}
1268
690d8824
JH
1269_git ()
1270{
873537fa
SP
1271 local i c=1 command __git_dir
1272
1273 while [ $c -lt $COMP_CWORD ]; do
1274 i="${COMP_WORDS[c]}"
1275 case "$i" in
1276 --git-dir=*) __git_dir="${i#--git-dir=}" ;;
1277 --bare) __git_dir="." ;;
1278 --version|--help|-p|--paginate) ;;
1279 *) command="$i"; break ;;
1280 esac
1281 c=$((++c))
1282 done
1283
1d17b22e 1284 if [ -z "$command" ]; then
72e5e989
SP
1285 case "${COMP_WORDS[COMP_CWORD]}" in
1286 --*=*) COMPREPLY=() ;;
47e98eec 1287 --*) __gitcomp "
ce5a2c95 1288 --paginate
47e98eec
SP
1289 --no-pager
1290 --git-dir=
1291 --bare
1292 --version
1293 --exec-path
ce5a2c95
TL
1294 --work-tree=
1295 --help
47e98eec
SP
1296 "
1297 ;;
72e5e989
SP
1298 *) __gitcomp "$(__git_commands) $(__git_aliases)" ;;
1299 esac
1300 return
873537fa 1301 fi
367dce2a 1302
873537fa
SP
1303 local expansion=$(__git_aliased_command "$command")
1304 [ "$expansion" ] && command="$expansion"
367dce2a 1305
873537fa 1306 case "$command" in
88329195 1307 am) _git_am ;;
8435b548 1308 add) _git_add ;;
88329195 1309 apply) _git_apply ;;
b2e69f62 1310 bisect) _git_bisect ;;
374a58c9 1311 bundle) _git_bundle ;;
873537fa 1312 branch) _git_branch ;;
873537fa 1313 checkout) _git_checkout ;;
d8a9fea5 1314 cherry) _git_cherry ;;
1273231e 1315 cherry-pick) _git_cherry_pick ;;
4548e855 1316 commit) _git_commit ;;
e0d10e1c 1317 config) _git_config ;;
217926c0 1318 describe) _git_describe ;;
873537fa 1319 diff) _git_diff ;;
873537fa 1320 fetch) _git_fetch ;;
f53352fb 1321 format-patch) _git_format_patch ;;
b26c8748 1322 gc) _git_gc ;;
873537fa
SP
1323 log) _git_log ;;
1324 ls-remote) _git_ls_remote ;;
1325 ls-tree) _git_ls_tree ;;
4ad91321 1326 merge) _git_merge;;
873537fa 1327 merge-base) _git_merge_base ;;
d33909bf 1328 name-rev) _git_name_rev ;;
873537fa
SP
1329 pull) _git_pull ;;
1330 push) _git_push ;;
61d926a3 1331 rebase) _git_rebase ;;
88293c67 1332 remote) _git_remote ;;
873537fa 1333 reset) _git_reset ;;
1fd6bec9 1334 shortlog) _git_shortlog ;;
90131924 1335 show) _git_show ;;
873537fa 1336 show-branch) _git_log ;;
7fd53fce 1337 stash) _git_stash ;;
be86f7a0 1338 submodule) _git_submodule ;;
47f6ee28 1339 svn) _git_svn ;;
88e21dc7 1340 tag) _git_tag ;;
873537fa
SP
1341 whatchanged) _git_log ;;
1342 *) COMPREPLY=() ;;
1343 esac
690d8824
JH
1344}
1345
1346_gitk ()
1347{
1348 local cur="${COMP_WORDS[COMP_CWORD]}"
07ba53f7
RQ
1349 local g="$(git rev-parse --git-dir 2>/dev/null)"
1350 local merge=""
1351 if [ -f $g/MERGE_HEAD ]; then
1352 merge="--merge"
1353 fi
b3391775
SP
1354 case "$cur" in
1355 --*)
07ba53f7 1356 __gitcomp "--not --all $merge"
b3391775
SP
1357 return
1358 ;;
1359 esac
ec804891 1360 __git_complete_revlist
690d8824
JH
1361}
1362
1363complete -o default -o nospace -F _git git
b3391775
SP
1364complete -o default -o nospace -F _gitk gitk
1365complete -o default -o nospace -F _git_am git-am
1366complete -o default -o nospace -F _git_apply git-apply
b2e69f62 1367complete -o default -o nospace -F _git_bisect git-bisect
b3391775 1368complete -o default -o nospace -F _git_branch git-branch
374a58c9 1369complete -o default -o nospace -F _git_bundle git-bundle
b3391775 1370complete -o default -o nospace -F _git_checkout git-checkout
d8a9fea5 1371complete -o default -o nospace -F _git_cherry git-cherry
b3391775
SP
1372complete -o default -o nospace -F _git_cherry_pick git-cherry-pick
1373complete -o default -o nospace -F _git_commit git-commit
217926c0 1374complete -o default -o nospace -F _git_describe git-describe
690d8824 1375complete -o default -o nospace -F _git_diff git-diff
690d8824 1376complete -o default -o nospace -F _git_fetch git-fetch
f53352fb 1377complete -o default -o nospace -F _git_format_patch git-format-patch
b26c8748 1378complete -o default -o nospace -F _git_gc git-gc
690d8824 1379complete -o default -o nospace -F _git_log git-log
b3391775 1380complete -o default -o nospace -F _git_ls_remote git-ls-remote
690d8824 1381complete -o default -o nospace -F _git_ls_tree git-ls-tree
b3391775
SP
1382complete -o default -o nospace -F _git_merge git-merge
1383complete -o default -o nospace -F _git_merge_base git-merge-base
1384complete -o default -o nospace -F _git_name_rev git-name-rev
690d8824
JH
1385complete -o default -o nospace -F _git_pull git-pull
1386complete -o default -o nospace -F _git_push git-push
b3391775
SP
1387complete -o default -o nospace -F _git_rebase git-rebase
1388complete -o default -o nospace -F _git_config git-config
88293c67 1389complete -o default -o nospace -F _git_remote git-remote
b3391775 1390complete -o default -o nospace -F _git_reset git-reset
1fd6bec9 1391complete -o default -o nospace -F _git_shortlog git-shortlog
90131924 1392complete -o default -o nospace -F _git_show git-show
7fd53fce 1393complete -o default -o nospace -F _git_stash git-stash
be86f7a0 1394complete -o default -o nospace -F _git_submodule git-submodule
47f6ee28 1395complete -o default -o nospace -F _git_svn git-svn
144d33de 1396complete -o default -o nospace -F _git_log git-show-branch
88e21dc7 1397complete -o default -o nospace -F _git_tag git-tag
690d8824
JH
1398complete -o default -o nospace -F _git_log git-whatchanged
1399
1400# The following are necessary only for Cygwin, and only are needed
1401# when the user has tab-completed the executable name and consequently
1402# included the '.exe' suffix.
1403#
76c3eb51 1404if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
b3391775
SP
1405complete -o default -o nospace -F _git_add git-add.exe
1406complete -o default -o nospace -F _git_apply git-apply.exe
144d33de 1407complete -o default -o nospace -F _git git.exe
b3391775 1408complete -o default -o nospace -F _git_branch git-branch.exe
374a58c9 1409complete -o default -o nospace -F _git_bundle git-bundle.exe
d8a9fea5 1410complete -o default -o nospace -F _git_cherry git-cherry.exe
217926c0 1411complete -o default -o nospace -F _git_describe git-describe.exe
690d8824 1412complete -o default -o nospace -F _git_diff git-diff.exe
f53352fb 1413complete -o default -o nospace -F _git_format_patch git-format-patch.exe
690d8824
JH
1414complete -o default -o nospace -F _git_log git-log.exe
1415complete -o default -o nospace -F _git_ls_tree git-ls-tree.exe
b3391775
SP
1416complete -o default -o nospace -F _git_merge_base git-merge-base.exe
1417complete -o default -o nospace -F _git_name_rev git-name-rev.exe
690d8824 1418complete -o default -o nospace -F _git_push git-push.exe
b3391775 1419complete -o default -o nospace -F _git_config git-config
1fd6bec9 1420complete -o default -o nospace -F _git_shortlog git-shortlog.exe
90131924 1421complete -o default -o nospace -F _git_show git-show.exe
144d33de 1422complete -o default -o nospace -F _git_log git-show-branch.exe
88e21dc7 1423complete -o default -o nospace -F _git_tag git-tag.exe
690d8824 1424complete -o default -o nospace -F _git_log git-whatchanged.exe
76c3eb51 1425fi