]> git.ipfire.org Git - thirdparty/git.git/blame - contrib/completion/git-completion.bash
bash: Complete long options to git-add.
[thirdparty/git.git] / contrib / completion / git-completion.bash
CommitLineData
690d8824
JH
1#
2# bash completion support for core Git.
3#
2e3a430a 4# Copyright (C) 2006,2007 Shawn Pearce
690d8824
JH
5# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
6#
7# The contained completion routines provide support for completing:
8#
9# *) local and remote branch names
10# *) local and remote tag names
11# *) .git/remotes file names
12# *) git 'subcommands'
13# *) tree paths within 'ref:path/to/file' expressions
14#
15# To use these routines:
16#
17# 1) Copy this file to somewhere (e.g. ~/.git-completion.sh).
18# 2) Added the following line to your .bashrc:
19# source ~/.git-completion.sh
20#
b51ec6bd
SP
21# 3) You may want to make sure the git executable is available
22# in your PATH before this script is sourced, as some caching
23# is performed while the script loads. If git isn't found
24# at source time then all lookups will be done on demand,
25# which may be slightly slower.
26#
27# 4) Consider changing your PS1 to also show the current branch:
d3d717a4
SP
28# PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
29#
30# The argument to __git_ps1 will be displayed only if you
31# are currently in a git repository. The %s token will be
32# the name of the current branch.
33#
690d8824 34
873537fa
SP
35__gitdir ()
36{
67ffa114
SP
37 if [ -z "$1" ]; then
38 if [ -n "$__git_dir" ]; then
39 echo "$__git_dir"
40 elif [ -d .git ]; then
41 echo .git
42 else
43 git rev-parse --git-dir 2>/dev/null
44 fi
45 elif [ -d "$1/.git" ]; then
46 echo "$1/.git"
47 else
48 echo "$1"
49 fi
873537fa
SP
50}
51
d3d717a4
SP
52__git_ps1 ()
53{
54 local b="$(git symbolic-ref HEAD 2>/dev/null)"
55 if [ -n "$b" ]; then
56 if [ -n "$1" ]; then
57 printf "$1" "${b##refs/heads/}"
58 else
59 printf " (%s)" "${b##refs/heads/}"
60 fi
61 fi
62}
63
5de40f59
SP
64__git_heads ()
65{
67ffa114 66 local cmd i is_hash=y dir="$(__gitdir "$1")"
5de40f59
SP
67 if [ -d "$dir" ]; then
68 for i in $(git --git-dir="$dir" \
69 for-each-ref --format='%(refname)' \
70 refs/heads ); do
71 echo "${i#refs/heads/}"
72 done
73 return
74 fi
67ffa114 75 for i in $(git-ls-remote "$1" 2>/dev/null); do
5de40f59
SP
76 case "$is_hash,$i" in
77 y,*) is_hash=n ;;
78 n,*^{}) is_hash=y ;;
79 n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
80 n,*) is_hash=y; echo "$i" ;;
81 esac
82 done
83}
84
690d8824
JH
85__git_refs ()
86{
67ffa114 87 local cmd i is_hash=y dir="$(__gitdir "$1")"
873537fa 88 if [ -d "$dir" ]; then
35e65ecc
SP
89 if [ -e "$dir/HEAD" ]; then echo HEAD; fi
90 for i in $(git --git-dir="$dir" \
91 for-each-ref --format='%(refname)' \
92 refs/tags refs/heads refs/remotes); do
93 case "$i" in
94 refs/tags/*) echo "${i#refs/tags/}" ;;
95 refs/heads/*) echo "${i#refs/heads/}" ;;
96 refs/remotes/*) echo "${i#refs/remotes/}" ;;
97 *) echo "$i" ;;
98 esac
99 done
100 return
690d8824 101 fi
35e65ecc 102 for i in $(git-ls-remote "$dir" 2>/dev/null); do
690d8824
JH
103 case "$is_hash,$i" in
104 y,*) is_hash=n ;;
105 n,*^{}) is_hash=y ;;
106 n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
107 n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
35e65ecc 108 n,refs/remotes/*) is_hash=y; echo "${i#refs/remotes/}" ;;
690d8824
JH
109 n,*) is_hash=y; echo "$i" ;;
110 esac
111 done
112}
113
114__git_refs2 ()
115{
67ffa114
SP
116 local i
117 for i in $(__git_refs "$1"); do
118 echo "$i:$i"
690d8824
JH
119 done
120}
121
5de40f59
SP
122__git_refs_remotes ()
123{
124 local cmd i is_hash=y
125 for i in $(git-ls-remote "$1" 2>/dev/null); do
126 case "$is_hash,$i" in
127 n,refs/heads/*)
128 is_hash=y
129 echo "$i:refs/remotes/$1/${i#refs/heads/}"
130 ;;
131 y,*) is_hash=n ;;
132 n,*^{}) is_hash=y ;;
133 n,refs/tags/*) is_hash=y;;
134 n,*) is_hash=y; ;;
135 esac
136 done
137}
138
690d8824
JH
139__git_remotes ()
140{
873537fa 141 local i ngoff IFS=$'\n' d="$(__gitdir)"
56fc25f2 142 shopt -q nullglob || ngoff=1
690d8824 143 shopt -s nullglob
873537fa
SP
144 for i in "$d/remotes"/*; do
145 echo ${i#$d/remotes/}
690d8824 146 done
56fc25f2 147 [ "$ngoff" ] && shopt -u nullglob
e0d10e1c 148 for i in $(git --git-dir="$d" config --list); do
56fc25f2
SP
149 case "$i" in
150 remote.*.url=*)
151 i="${i#remote.}"
152 echo "${i/.url=*/}"
153 ;;
154 esac
155 done
690d8824
JH
156}
157
4ad91321
SP
158__git_merge_strategies ()
159{
b51ec6bd
SP
160 if [ -n "$__git_merge_strategylist" ]; then
161 echo "$__git_merge_strategylist"
162 return
163 fi
4ad91321
SP
164 sed -n "/^all_strategies='/{
165 s/^all_strategies='//
166 s/'//
167 p
168 q
169 }" "$(git --exec-path)/git-merge"
170}
b51ec6bd
SP
171__git_merge_strategylist=
172__git_merge_strategylist="$(__git_merge_strategies 2>/dev/null)"
4ad91321 173
690d8824
JH
174__git_complete_file ()
175{
a79c6551 176 local pfx ls ref cur="${COMP_WORDS[COMP_CWORD]}"
690d8824
JH
177 case "$cur" in
178 ?*:*)
a79c6551
SP
179 ref="${cur%%:*}"
180 cur="${cur#*:}"
690d8824
JH
181 case "$cur" in
182 ?*/*)
a79c6551
SP
183 pfx="${cur%/*}"
184 cur="${cur##*/}"
690d8824
JH
185 ls="$ref:$pfx"
186 pfx="$pfx/"
187 ;;
188 *)
189 ls="$ref"
190 ;;
191 esac
192 COMPREPLY=($(compgen -P "$pfx" \
873537fa 193 -W "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \
690d8824
JH
194 | sed '/^100... blob /s,^.* ,,
195 /^040000 tree /{
196 s,^.* ,,
197 s,$,/,
198 }
199 s/^.* //')" \
200 -- "$cur"))
201 ;;
202 *)
873537fa 203 COMPREPLY=($(compgen -W "$(__git_refs)" -- "$cur"))
690d8824
JH
204 ;;
205 esac
206}
207
f53352fb
SP
208__git_complete_revlist ()
209{
210 local pfx cur="${COMP_WORDS[COMP_CWORD]}"
211 case "$cur" in
212 *...*)
213 pfx="${cur%...*}..."
214 cur="${cur#*...}"
215 COMPREPLY=($(compgen -P "$pfx" -W "$(__git_refs)" -- "$cur"))
216 ;;
217 *..*)
218 pfx="${cur%..*}.."
219 cur="${cur#*..}"
220 COMPREPLY=($(compgen -P "$pfx" -W "$(__git_refs)" -- "$cur"))
221 ;;
222 *)
223 COMPREPLY=($(compgen -W "$(__git_refs)" -- "$cur"))
224 ;;
225 esac
226}
227
f2bb9f88
SP
228__git_commands ()
229{
b51ec6bd
SP
230 if [ -n "$__git_commandlist" ]; then
231 echo "$__git_commandlist"
232 return
233 fi
f2bb9f88
SP
234 local i IFS=" "$'\n'
235 for i in $(git help -a|egrep '^ ')
236 do
237 case $i in
8435b548 238 add--interactive) : plumbing;;
2e3a430a 239 cat-file) : plumbing;;
f2bb9f88
SP
240 check-ref-format) : plumbing;;
241 commit-tree) : plumbing;;
242 convert-objects) : plumbing;;
243 cvsserver) : daemon;;
244 daemon) : daemon;;
245 fetch-pack) : plumbing;;
246 hash-object) : plumbing;;
247 http-*) : transport;;
248 index-pack) : plumbing;;
249 local-fetch) : plumbing;;
250 mailinfo) : plumbing;;
251 mailsplit) : plumbing;;
252 merge-*) : plumbing;;
253 mktree) : plumbing;;
254 mktag) : plumbing;;
255 pack-objects) : plumbing;;
256 pack-redundant) : plumbing;;
257 pack-refs) : plumbing;;
258 parse-remote) : plumbing;;
259 patch-id) : plumbing;;
260 peek-remote) : plumbing;;
261 read-tree) : plumbing;;
262 receive-pack) : plumbing;;
2e3a430a 263 reflog) : plumbing;;
f2bb9f88
SP
264 rerere) : plumbing;;
265 rev-list) : plumbing;;
266 rev-parse) : plumbing;;
267 runstatus) : plumbing;;
268 sh-setup) : internal;;
269 shell) : daemon;;
270 send-pack) : plumbing;;
271 show-index) : plumbing;;
272 ssh-*) : transport;;
273 stripspace) : plumbing;;
274 symbolic-ref) : plumbing;;
275 unpack-file) : plumbing;;
276 unpack-objects) : plumbing;;
277 update-ref) : plumbing;;
278 update-server-info) : daemon;;
279 upload-archive) : plumbing;;
280 upload-pack) : plumbing;;
281 write-tree) : plumbing;;
282 *) echo $i;;
283 esac
284 done
285}
b51ec6bd
SP
286__git_commandlist=
287__git_commandlist="$(__git_commands 2>/dev/null)"
f2bb9f88 288
367dce2a
DS
289__git_aliases ()
290{
56fc25f2 291 local i IFS=$'\n'
e0d10e1c 292 for i in $(git --git-dir="$(__gitdir)" config --list); do
56fc25f2
SP
293 case "$i" in
294 alias.*)
295 i="${i#alias.}"
296 echo "${i/=*/}"
297 ;;
298 esac
299 done
367dce2a
DS
300}
301
302__git_aliased_command ()
303{
873537fa 304 local word cmdline=$(git --git-dir="$(__gitdir)" \
e0d10e1c 305 config --get "alias.$1")
367dce2a
DS
306 for word in $cmdline; do
307 if [ "${word##-*}" ]; then
308 echo $word
309 return
310 fi
311 done
312}
313
88329195
SP
314__git_whitespacelist="nowarn warn error error-all strip"
315
316_git_am ()
317{
318 local cur="${COMP_WORDS[COMP_CWORD]}"
319 if [ -d .dotest ]; then
320 COMPREPLY=($(compgen -W "
321 --skip --resolved
322 " -- "$cur"))
323 return
324 fi
325 case "$cur" in
326 --whitespace=*)
327 COMPREPLY=($(compgen -W "$__git_whitespacelist" \
328 -- "${cur##--whitespace=}"))
329 return
330 ;;
331 --*)
332 COMPREPLY=($(compgen -W "
333 --signoff --utf8 --binary --3way --interactive
334 --whitespace=
335 " -- "$cur"))
336 return
337 esac
338 COMPREPLY=()
339}
340
341_git_apply ()
342{
343 local cur="${COMP_WORDS[COMP_CWORD]}"
344 case "$cur" in
345 --whitespace=*)
346 COMPREPLY=($(compgen -W "$__git_whitespacelist" \
347 -- "${cur##--whitespace=}"))
348 return
349 ;;
350 --*)
351 COMPREPLY=($(compgen -W "
352 --stat --numstat --summary --check --index
353 --cached --index-info --reverse --reject --unidiff-zero
354 --apply --no-add --exclude=
355 --whitespace= --inaccurate-eof --verbose
356 " -- "$cur"))
357 return
358 esac
359 COMPREPLY=()
360}
361
8435b548
SP
362_git_add ()
363{
364 local cur="${COMP_WORDS[COMP_CWORD]}"
365 case "$cur" in
366 --*)
367 COMPREPLY=($(compgen -W "
368 --interactive
369 " -- "$cur"))
370 return
371 esac
372 COMPREPLY=()
373}
374
690d8824
JH
375_git_branch ()
376{
377 local cur="${COMP_WORDS[COMP_CWORD]}"
9f4cc6f7 378 COMPREPLY=($(compgen -W "$(__git_refs)" -- "$cur"))
690d8824
JH
379}
380
690d8824
JH
381_git_checkout ()
382{
383 local cur="${COMP_WORDS[COMP_CWORD]}"
9f4cc6f7 384 COMPREPLY=($(compgen -W "$(__git_refs)" -- "$cur"))
690d8824
JH
385}
386
1273231e
SP
387_git_cherry_pick ()
388{
389 local cur="${COMP_WORDS[COMP_CWORD]}"
390 case "$cur" in
391 --*)
392 COMPREPLY=($(compgen -W "
393 --edit --no-commit
394 " -- "$cur"))
395 ;;
396 *)
397 COMPREPLY=($(compgen -W "$(__git_refs)" -- "$cur"))
398 ;;
399 esac
400}
401
4548e855
SP
402_git_commit ()
403{
404 local cur="${COMP_WORDS[COMP_CWORD]}"
405 case "$cur" in
406 --*)
407 COMPREPLY=($(compgen -W "
408 --all --author= --signoff --verify --no-verify
409 --edit --amend --include --only
410 " -- "$cur"))
411 return
412 esac
413 COMPREPLY=()
414}
415
690d8824
JH
416_git_diff ()
417{
418 __git_complete_file
419}
420
421_git_diff_tree ()
422{
423 local cur="${COMP_WORDS[COMP_CWORD]}"
9f4cc6f7 424 COMPREPLY=($(compgen -W "$(__git_refs)" -- "$cur"))
690d8824
JH
425}
426
427_git_fetch ()
428{
429 local cur="${COMP_WORDS[COMP_CWORD]}"
430
431 case "${COMP_WORDS[0]},$COMP_CWORD" in
432 git-fetch*,1)
433 COMPREPLY=($(compgen -W "$(__git_remotes)" -- "$cur"))
434 ;;
435 git,2)
436 COMPREPLY=($(compgen -W "$(__git_remotes)" -- "$cur"))
437 ;;
438 *)
439 case "$cur" in
440 *:*)
a79c6551 441 cur="${cur#*:}"
873537fa 442 COMPREPLY=($(compgen -W "$(__git_refs)" -- "$cur"))
690d8824
JH
443 ;;
444 *)
445 local remote
446 case "${COMP_WORDS[0]}" in
447 git-fetch) remote="${COMP_WORDS[1]}" ;;
448 git) remote="${COMP_WORDS[2]}" ;;
449 esac
450 COMPREPLY=($(compgen -W "$(__git_refs2 "$remote")" -- "$cur"))
451 ;;
452 esac
453 ;;
454 esac
455}
456
f53352fb
SP
457_git_format_patch ()
458{
459 local cur="${COMP_WORDS[COMP_CWORD]}"
460 case "$cur" in
461 --*)
462 COMPREPLY=($(compgen -W "
463 --stdout --attach --thread
464 --output-directory
465 --numbered --start-number
466 --keep-subject
467 --signoff
468 --in-reply-to=
469 --full-index --binary
470 " -- "$cur"))
471 return
472 ;;
473 esac
474 __git_complete_revlist
475}
476
690d8824
JH
477_git_ls_remote ()
478{
479 local cur="${COMP_WORDS[COMP_CWORD]}"
480 COMPREPLY=($(compgen -W "$(__git_remotes)" -- "$cur"))
481}
482
483_git_ls_tree ()
484{
485 __git_complete_file
486}
487
488_git_log ()
489{
6e31b866
SP
490 local cur="${COMP_WORDS[COMP_CWORD]}"
491 case "$cur" in
492 --pretty=*)
493 COMPREPLY=($(compgen -W "
494 oneline short medium full fuller email raw
495 " -- "${cur##--pretty=}"))
496 return
497 ;;
498 --*)
499 COMPREPLY=($(compgen -W "
500 --max-count= --max-age= --since= --after=
501 --min-age= --before= --until=
502 --root --not --topo-order --date-order
503 --no-merges
504 --abbrev-commit --abbrev=
505 --relative-date
506 --author= --committer= --grep=
507 --all-match
508 --pretty= --name-status --name-only
509 " -- "$cur"))
510 return
511 ;;
512 esac
f53352fb 513 __git_complete_revlist
690d8824
JH
514}
515
4ad91321
SP
516_git_merge ()
517{
518 local cur="${COMP_WORDS[COMP_CWORD]}"
ce1e39d2
SP
519 case "${COMP_WORDS[COMP_CWORD-1]}" in
520 -s|--strategy)
521 COMPREPLY=($(compgen -W "$(__git_merge_strategies)" -- "$cur"))
522 return
523 esac
4ad91321 524 case "$cur" in
ce1e39d2
SP
525 --strategy=*)
526 COMPREPLY=($(compgen -W "$(__git_merge_strategies)" \
527 -- "${cur##--strategy=}"))
528 return
529 ;;
4ad91321
SP
530 --*)
531 COMPREPLY=($(compgen -W "
61d926a3 532 --no-commit --no-summary --squash --strategy
4ad91321
SP
533 " -- "$cur"))
534 return
535 esac
61d926a3 536 COMPREPLY=($(compgen -W "$(__git_refs)" -- "$cur"))
4ad91321
SP
537}
538
690d8824
JH
539_git_merge_base ()
540{
541 local cur="${COMP_WORDS[COMP_CWORD]}"
873537fa 542 COMPREPLY=($(compgen -W "$(__git_refs)" -- "$cur"))
690d8824
JH
543}
544
d33909bf
SP
545_git_name_rev ()
546{
547 local cur="${COMP_WORDS[COMP_CWORD]}"
548 COMPREPLY=($(compgen -W "--tags --all --stdin" -- "$cur"))
549}
550
690d8824
JH
551_git_pull ()
552{
553 local cur="${COMP_WORDS[COMP_CWORD]}"
554
555 case "${COMP_WORDS[0]},$COMP_CWORD" in
556 git-pull*,1)
557 COMPREPLY=($(compgen -W "$(__git_remotes)" -- "$cur"))
558 ;;
559 git,2)
560 COMPREPLY=($(compgen -W "$(__git_remotes)" -- "$cur"))
561 ;;
562 *)
563 local remote
564 case "${COMP_WORDS[0]}" in
565 git-pull) remote="${COMP_WORDS[1]}" ;;
566 git) remote="${COMP_WORDS[2]}" ;;
567 esac
568 COMPREPLY=($(compgen -W "$(__git_refs "$remote")" -- "$cur"))
569 ;;
570 esac
571}
572
573_git_push ()
574{
575 local cur="${COMP_WORDS[COMP_CWORD]}"
576
577 case "${COMP_WORDS[0]},$COMP_CWORD" in
578 git-push*,1)
579 COMPREPLY=($(compgen -W "$(__git_remotes)" -- "$cur"))
580 ;;
581 git,2)
582 COMPREPLY=($(compgen -W "$(__git_remotes)" -- "$cur"))
583 ;;
584 *)
585 case "$cur" in
586 *:*)
587 local remote
588 case "${COMP_WORDS[0]}" in
589 git-push) remote="${COMP_WORDS[1]}" ;;
590 git) remote="${COMP_WORDS[2]}" ;;
591 esac
a79c6551 592 cur="${cur#*:}"
690d8824
JH
593 COMPREPLY=($(compgen -W "$(__git_refs "$remote")" -- "$cur"))
594 ;;
595 *)
873537fa 596 COMPREPLY=($(compgen -W "$(__git_refs2)" -- "$cur"))
690d8824
JH
597 ;;
598 esac
599 ;;
600 esac
601}
602
61d926a3
SP
603_git_rebase ()
604{
605 local cur="${COMP_WORDS[COMP_CWORD]}"
606 if [ -d .dotest ]; then
607 COMPREPLY=($(compgen -W "
608 --continue --skip --abort
609 " -- "$cur"))
610 return
611 fi
ce1e39d2
SP
612 case "${COMP_WORDS[COMP_CWORD-1]}" in
613 -s|--strategy)
614 COMPREPLY=($(compgen -W "$(__git_merge_strategies)" -- "$cur"))
615 return
616 esac
61d926a3 617 case "$cur" in
ce1e39d2
SP
618 --strategy=*)
619 COMPREPLY=($(compgen -W "$(__git_merge_strategies)" \
620 -- "${cur##--strategy=}"))
621 return
622 ;;
61d926a3
SP
623 --*)
624 COMPREPLY=($(compgen -W "
625 --onto --merge --strategy
626 " -- "$cur"))
627 return
628 esac
61d926a3
SP
629 COMPREPLY=($(compgen -W "$(__git_refs)" -- "$cur"))
630}
631
e0d10e1c 632_git_config ()
5de40f59
SP
633{
634 local cur="${COMP_WORDS[COMP_CWORD]}"
635 local prv="${COMP_WORDS[COMP_CWORD-1]}"
636 case "$prv" in
637 branch.*.remote)
638 COMPREPLY=($(compgen -W "$(__git_remotes)" -- "$cur"))
639 return
640 ;;
641 branch.*.merge)
642 COMPREPLY=($(compgen -W "$(__git_refs)" -- "$cur"))
643 return
644 ;;
645 remote.*.fetch)
646 local remote="${prv#remote.}"
647 remote="${remote%.fetch}"
648 COMPREPLY=($(compgen -W "$(__git_refs_remotes "$remote")" \
649 -- "$cur"))
650 return
651 ;;
652 remote.*.push)
653 local remote="${prv#remote.}"
654 remote="${remote%.push}"
655 COMPREPLY=($(compgen -W "$(git --git-dir="$(__gitdir)" \
656 for-each-ref --format='%(refname):%(refname)' \
657 refs/heads)" -- "$cur"))
658 return
659 ;;
660 *.*)
661 COMPREPLY=()
662 return
663 ;;
664 esac
665 case "$cur" in
666 --*)
667 COMPREPLY=($(compgen -W "
668 --global --list --replace-all
669 --get --get-all --get-regexp
670 --unset --unset-all
671 " -- "$cur"))
672 return
673 ;;
674 branch.*.*)
675 local pfx="${cur%.*}."
676 cur="${cur##*.}"
677 COMPREPLY=($(compgen -P "$pfx" -W "remote merge" -- "$cur"))
678 return
679 ;;
680 branch.*)
681 local pfx="${cur%.*}."
682 cur="${cur#*.}"
683 COMPREPLY=($(compgen -P "$pfx" -S . \
684 -W "$(__git_heads)" -- "$cur"))
685 return
686 ;;
687 remote.*.*)
688 local pfx="${cur%.*}."
689 cur="${cur##*.}"
690 COMPREPLY=($(compgen -P "$pfx" -W "url fetch push" -- "$cur"))
691 return
692 ;;
693 remote.*)
694 local pfx="${cur%.*}."
695 cur="${cur#*.}"
696 COMPREPLY=($(compgen -P "$pfx" -S . \
697 -W "$(__git_remotes)" -- "$cur"))
698 return
699 ;;
700 esac
701 COMPREPLY=($(compgen -W "
702 apply.whitespace
703 core.fileMode
704 core.gitProxy
705 core.ignoreStat
706 core.preferSymlinkRefs
707 core.logAllRefUpdates
708 core.repositoryFormatVersion
709 core.sharedRepository
710 core.warnAmbiguousRefs
711 core.compression
712 core.legacyHeaders
713 i18n.commitEncoding
d2c11a38 714 i18n.logOutputEncoding
5de40f59 715 diff.color
a159ca0c 716 color.diff
5de40f59
SP
717 diff.renameLimit
718 diff.renames
719 pager.color
a159ca0c 720 color.pager
5de40f59 721 status.color
a159ca0c 722 color.status
5de40f59
SP
723 log.showroot
724 show.difftree
725 showbranch.default
726 whatchanged.difftree
727 http.sslVerify
728 http.sslCert
729 http.sslKey
730 http.sslCAInfo
731 http.sslCAPath
732 http.maxRequests
733 http.lowSpeedLimit http.lowSpeedTime
734 http.noEPSV
735 pack.window
736 repack.useDeltaBaseOffset
737 pull.octopus pull.twohead
738 merge.summary
739 receive.unpackLimit
740 receive.denyNonFastForwards
741 user.name user.email
742 tar.umask
743 gitcvs.enabled
744 gitcvs.logfile
745 branch. remote.
746 " -- "$cur"))
747}
748
67e78c3b
SP
749_git_reset ()
750{
751 local cur="${COMP_WORDS[COMP_CWORD]}"
752 local opt="--mixed --hard --soft"
873537fa 753 COMPREPLY=($(compgen -W "$opt $(__git_refs)" -- "$cur"))
67e78c3b
SP
754}
755
90131924
SP
756_git_show ()
757{
758 local cur="${COMP_WORDS[COMP_CWORD]}"
759 case "$cur" in
760 --pretty=*)
761 COMPREPLY=($(compgen -W "
762 oneline short medium full fuller email raw
763 " -- "${cur##--pretty=}"))
764 return
765 ;;
766 --*)
767 COMPREPLY=($(compgen -W "--pretty=" -- "$cur"))
768 return
769 ;;
770 esac
771 __git_complete_file
772}
773
690d8824
JH
774_git ()
775{
873537fa
SP
776 local i c=1 command __git_dir
777
778 while [ $c -lt $COMP_CWORD ]; do
779 i="${COMP_WORDS[c]}"
780 case "$i" in
781 --git-dir=*) __git_dir="${i#--git-dir=}" ;;
782 --bare) __git_dir="." ;;
783 --version|--help|-p|--paginate) ;;
784 *) command="$i"; break ;;
785 esac
786 c=$((++c))
787 done
788
789 if [ $c -eq $COMP_CWORD -a -z "$command" ]; then
f2bb9f88
SP
790 COMPREPLY=($(compgen -W "
791 --git-dir= --version --exec-path
792 $(__git_commands)
793 $(__git_aliases)
794 " -- "${COMP_WORDS[COMP_CWORD]}"))
873537fa
SP
795 return;
796 fi
367dce2a 797
873537fa
SP
798 local expansion=$(__git_aliased_command "$command")
799 [ "$expansion" ] && command="$expansion"
367dce2a 800
873537fa 801 case "$command" in
88329195 802 am) _git_am ;;
8435b548 803 add) _git_add ;;
88329195 804 apply) _git_apply ;;
873537fa 805 branch) _git_branch ;;
873537fa 806 checkout) _git_checkout ;;
1273231e 807 cherry-pick) _git_cherry_pick ;;
4548e855 808 commit) _git_commit ;;
e0d10e1c 809 config) _git_config ;;
873537fa
SP
810 diff) _git_diff ;;
811 diff-tree) _git_diff_tree ;;
812 fetch) _git_fetch ;;
f53352fb 813 format-patch) _git_format_patch ;;
873537fa
SP
814 log) _git_log ;;
815 ls-remote) _git_ls_remote ;;
816 ls-tree) _git_ls_tree ;;
4ad91321 817 merge) _git_merge;;
873537fa 818 merge-base) _git_merge_base ;;
d33909bf 819 name-rev) _git_name_rev ;;
873537fa
SP
820 pull) _git_pull ;;
821 push) _git_push ;;
61d926a3 822 rebase) _git_rebase ;;
e0d10e1c 823 repo-config) _git_config ;;
873537fa 824 reset) _git_reset ;;
90131924 825 show) _git_show ;;
873537fa
SP
826 show-branch) _git_log ;;
827 whatchanged) _git_log ;;
828 *) COMPREPLY=() ;;
829 esac
690d8824
JH
830}
831
832_gitk ()
833{
834 local cur="${COMP_WORDS[COMP_CWORD]}"
873537fa 835 COMPREPLY=($(compgen -W "--all $(__git_refs)" -- "$cur"))
690d8824
JH
836}
837
838complete -o default -o nospace -F _git git
839complete -o default -F _gitk gitk
88329195
SP
840complete -o default -F _git_am git-am
841complete -o default -F _git_apply git-apply
690d8824 842complete -o default -F _git_branch git-branch
690d8824 843complete -o default -F _git_checkout git-checkout
1273231e 844complete -o default -F _git_cherry_pick git-cherry-pick
4548e855 845complete -o default -F _git_commit git-commit
690d8824
JH
846complete -o default -o nospace -F _git_diff git-diff
847complete -o default -F _git_diff_tree git-diff-tree
848complete -o default -o nospace -F _git_fetch git-fetch
f53352fb 849complete -o default -o nospace -F _git_format_patch git-format-patch
690d8824
JH
850complete -o default -o nospace -F _git_log git-log
851complete -o default -F _git_ls_remote git-ls-remote
852complete -o default -o nospace -F _git_ls_tree git-ls-tree
4ad91321 853complete -o default -F _git_merge git-merge
690d8824 854complete -o default -F _git_merge_base git-merge-base
d33909bf 855complete -o default -F _git_name_rev git-name-rev
690d8824
JH
856complete -o default -o nospace -F _git_pull git-pull
857complete -o default -o nospace -F _git_push git-push
61d926a3 858complete -o default -F _git_rebase git-rebase
e0d10e1c 859complete -o default -F _git_config git-config
67e78c3b 860complete -o default -F _git_reset git-reset
90131924 861complete -o default -o nospace -F _git_show git-show
144d33de 862complete -o default -o nospace -F _git_log git-show-branch
690d8824
JH
863complete -o default -o nospace -F _git_log git-whatchanged
864
865# The following are necessary only for Cygwin, and only are needed
866# when the user has tab-completed the executable name and consequently
867# included the '.exe' suffix.
868#
76c3eb51 869if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
8435b548 870complete -o default -F _git_add git-add.exe
88329195 871complete -o default -F _git_apply git-apply.exe
144d33de 872complete -o default -o nospace -F _git git.exe
dfb96092 873complete -o default -F _git_branch git-branch.exe
690d8824
JH
874complete -o default -o nospace -F _git_diff git-diff.exe
875complete -o default -o nospace -F _git_diff_tree git-diff-tree.exe
f53352fb 876complete -o default -o nospace -F _git_format_patch git-format-patch.exe
690d8824
JH
877complete -o default -o nospace -F _git_log git-log.exe
878complete -o default -o nospace -F _git_ls_tree git-ls-tree.exe
879complete -o default -F _git_merge_base git-merge-base.exe
d33909bf 880complete -o default -F _git_name_rev git-name-rev.exe
690d8824 881complete -o default -o nospace -F _git_push git-push.exe
e0d10e1c 882complete -o default -F _git_config git-config
90131924 883complete -o default -o nospace -F _git_show git-show.exe
144d33de 884complete -o default -o nospace -F _git_log git-show-branch.exe
690d8824 885complete -o default -o nospace -F _git_log git-whatchanged.exe
76c3eb51 886fi