]> git.ipfire.org Git - thirdparty/git.git/blame - contrib/completion/git-completion.bash
Merge branch 'maint'
[thirdparty/git.git] / contrib / completion / git-completion.bash
CommitLineData
a42577d4 1#!bash
690d8824
JH
2#
3# bash completion support for core Git.
4#
c70680ce 5# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
690d8824 6# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
c70680ce 7# Distributed under the GNU General Public License, version 2.0.
690d8824
JH
8#
9# The contained completion routines provide support for completing:
10#
11# *) local and remote branch names
12# *) local and remote tag names
13# *) .git/remotes file names
14# *) git 'subcommands'
15# *) tree paths within 'ref:path/to/file' expressions
c70680ce 16# *) common --long-options
690d8824
JH
17#
18# To use these routines:
19#
20# 1) Copy this file to somewhere (e.g. ~/.git-completion.sh).
21# 2) Added the following line to your .bashrc:
22# source ~/.git-completion.sh
23#
b51ec6bd
SP
24# 3) You may want to make sure the git executable is available
25# in your PATH before this script is sourced, as some caching
26# is performed while the script loads. If git isn't found
27# at source time then all lookups will be done on demand,
28# which may be slightly slower.
29#
30# 4) Consider changing your PS1 to also show the current branch:
d3d717a4
SP
31# PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
32#
33# The argument to __git_ps1 will be displayed only if you
34# are currently in a git repository. The %s token will be
35# the name of the current branch.
36#
a9ee90d7
TP
37# In addition, if you set GIT_PS1_SHOWDIRTYSTATE to a nonempty
38# value, unstaged (*) and staged (+) changes will be shown next
39# to the branch name. You can configure this per-repository
40# with the bash.showDirtyState variable, which defaults to true
41# once GIT_PS1_SHOWDIRTYSTATE is enabled.
738a94a9 42#
c70680ce
SP
43# To submit patches:
44#
45# *) Read Documentation/SubmittingPatches
46# *) Send all patches to the current maintainer:
47#
48# "Shawn O. Pearce" <spearce@spearce.org>
49#
50# *) Always CC the Git mailing list:
51#
52# git@vger.kernel.org
53#
690d8824 54
db8a9ff0
SP
55case "$COMP_WORDBREAKS" in
56*:*) : great ;;
57*) COMP_WORDBREAKS="$COMP_WORDBREAKS:"
58esac
59
a42577d4
TP
60# __gitdir accepts 0 or 1 arguments (i.e., location)
61# returns location of .git repo
873537fa
SP
62__gitdir ()
63{
25a31f81 64 if [ -z "${1-}" ]; then
5c9cc64a 65 if [ -n "${__git_dir-}" ]; then
67ffa114
SP
66 echo "$__git_dir"
67 elif [ -d .git ]; then
68 echo .git
69 else
70 git rev-parse --git-dir 2>/dev/null
71 fi
72 elif [ -d "$1/.git" ]; then
73 echo "$1/.git"
74 else
75 echo "$1"
76 fi
873537fa
SP
77}
78
a42577d4
TP
79# __git_ps1 accepts 0 or 1 arguments (i.e., format string)
80# returns text to add to bash PS1 prompt (includes branch name)
d3d717a4
SP
81__git_ps1 ()
82{
fa26a401 83 local g="$(__gitdir)"
e7520196
RR
84 if [ -n "$g" ]; then
85 local r
86 local b
ad244d25
TP
87 if [ -d "$g/rebase-apply" ]; then
88 if [ -f "$g/rebase-apply/rebasing" ]; then
3041c324 89 r="|REBASE"
ad244d25 90 elif [ -f "$g/rebase-apply/applying" ]; then
3041c324
JH
91 r="|AM"
92 else
93 r="|AM/REBASE"
94 fi
e7520196 95 b="$(git symbolic-ref HEAD 2>/dev/null)"
ad244d25 96 elif [ -f "$g/rebase-merge/interactive" ]; then
e7520196 97 r="|REBASE-i"
28ed6e7b 98 b="$(cat "$g/rebase-merge/head-name")"
ad244d25 99 elif [ -d "$g/rebase-merge" ]; then
e7520196 100 r="|REBASE-m"
28ed6e7b 101 b="$(cat "$g/rebase-merge/head-name")"
ad244d25 102 elif [ -f "$g/MERGE_HEAD" ]; then
e7520196
RR
103 r="|MERGING"
104 b="$(git symbolic-ref HEAD 2>/dev/null)"
105 else
ad244d25 106 if [ -f "$g/BISECT_LOG" ]; then
e7520196
RR
107 r="|BISECTING"
108 fi
ad244d25
TP
109 if ! b="$(git symbolic-ref HEAD 2>/dev/null)"; then
110 if ! b="$(git describe --exact-match HEAD 2>/dev/null)"; then
e5dd864a
TP
111 if [ -r "$g/HEAD" ]; then
112 b="$(cut -c1-7 "$g/HEAD")..."
113 fi
27c57888 114 fi
e7520196
RR
115 fi
116 fi
117
738a94a9
TR
118 local w
119 local i
ddb6d010 120 local c
738a94a9 121
e5dd864a 122 if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then
ddb6d010
MSO
123 if [ "true" = "$(git config --bool core.bare 2>/dev/null)" ]; then
124 c="BARE:"
125 else
126 b="GIT_DIR!"
127 fi
e5dd864a
TP
128 elif [ "true" = "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
129 if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ]; then
130 if [ "$(git config --bool bash.showDirtyState)" != "false" ]; then
131 git diff --no-ext-diff --ignore-submodules \
132 --quiet --exit-code || w="*"
133 if git rev-parse --quiet --verify HEAD >/dev/null; then
134 git diff-index --cached --quiet \
135 --ignore-submodules HEAD -- || i="+"
136 else
137 i="#"
138 fi
738a94a9
TR
139 fi
140 fi
141 fi
142
e5dd864a
TP
143 if [ -n "$b" ]; then
144 if [ -n "${1-}" ]; then
f50edca5 145 printf "$1" "$c${b##refs/heads/}$w$i$r"
e5dd864a 146 else
f50edca5 147 printf " (%s)" "$c${b##refs/heads/}$w$i$r"
e5dd864a 148 fi
d3d717a4
SP
149 fi
150 fi
151}
152
a42577d4 153# __gitcomp_1 requires 2 arguments
ab02dfe5
SP
154__gitcomp_1 ()
155{
156 local c IFS=' '$'\t'$'\n'
157 for c in $1; do
158 case "$c$2" in
159 --*=*) printf %s$'\n' "$c$2" ;;
160 *.) printf %s$'\n' "$c$2" ;;
161 *) printf %s$'\n' "$c$2 " ;;
162 esac
163 done
164}
165
a42577d4
TP
166# __gitcomp accepts 1, 2, 3, or 4 arguments
167# generates completion reply with compgen
72e5e989
SP
168__gitcomp ()
169{
78d4d6a2 170 local cur="${COMP_WORDS[COMP_CWORD]}"
b3391775 171 if [ $# -gt 2 ]; then
78d4d6a2
SP
172 cur="$3"
173 fi
5447aac7
SG
174 case "$cur" in
175 --*=)
176 COMPREPLY=()
5447aac7
SG
177 ;;
178 *)
ab02dfe5 179 local IFS=$'\n'
25a31f81
TP
180 COMPREPLY=($(compgen -P "${2-}" \
181 -W "$(__gitcomp_1 "${1-}" "${4-}")" \
ab02dfe5 182 -- "$cur"))
5447aac7
SG
183 ;;
184 esac
72e5e989
SP
185}
186
a42577d4 187# __git_heads accepts 0 or 1 arguments (to pass to __gitdir)
5de40f59
SP
188__git_heads ()
189{
25a31f81 190 local cmd i is_hash=y dir="$(__gitdir "${1-}")"
5de40f59 191 if [ -d "$dir" ]; then
05e8b3d6
SG
192 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
193 refs/heads
5de40f59
SP
194 return
195 fi
25a31f81 196 for i in $(git ls-remote "${1-}" 2>/dev/null); do
5de40f59
SP
197 case "$is_hash,$i" in
198 y,*) is_hash=n ;;
199 n,*^{}) is_hash=y ;;
200 n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
201 n,*) is_hash=y; echo "$i" ;;
202 esac
203 done
204}
205
a42577d4 206# __git_tags accepts 0 or 1 arguments (to pass to __gitdir)
88e21dc7
SP
207__git_tags ()
208{
25a31f81 209 local cmd i is_hash=y dir="$(__gitdir "${1-}")"
88e21dc7 210 if [ -d "$dir" ]; then
05e8b3d6
SG
211 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
212 refs/tags
88e21dc7
SP
213 return
214 fi
25a31f81 215 for i in $(git ls-remote "${1-}" 2>/dev/null); do
88e21dc7
SP
216 case "$is_hash,$i" in
217 y,*) is_hash=n ;;
218 n,*^{}) is_hash=y ;;
219 n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
220 n,*) is_hash=y; echo "$i" ;;
221 esac
222 done
223}
224
a42577d4 225# __git_refs accepts 0 or 1 arguments (to pass to __gitdir)
690d8824
JH
226__git_refs ()
227{
25a31f81 228 local i is_hash=y dir="$(__gitdir "${1-}")"
608efb87 229 local cur="${COMP_WORDS[COMP_CWORD]}" format refs
873537fa 230 if [ -d "$dir" ]; then
608efb87
SG
231 case "$cur" in
232 refs|refs/*)
233 format="refname"
234 refs="${cur%/*}"
235 ;;
236 *)
237 if [ -e "$dir/HEAD" ]; then echo HEAD; fi
238 format="refname:short"
239 refs="refs/tags refs/heads refs/remotes"
240 ;;
241 esac
242 git --git-dir="$dir" for-each-ref --format="%($format)" \
243 $refs
35e65ecc 244 return
690d8824 245 fi
799596a5 246 for i in $(git ls-remote "$dir" 2>/dev/null); do
690d8824
JH
247 case "$is_hash,$i" in
248 y,*) is_hash=n ;;
249 n,*^{}) is_hash=y ;;
250 n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
251 n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
35e65ecc 252 n,refs/remotes/*) is_hash=y; echo "${i#refs/remotes/}" ;;
690d8824
JH
253 n,*) is_hash=y; echo "$i" ;;
254 esac
255 done
256}
257
a42577d4 258# __git_refs2 requires 1 argument (to pass to __git_refs)
690d8824
JH
259__git_refs2 ()
260{
67ffa114
SP
261 local i
262 for i in $(__git_refs "$1"); do
263 echo "$i:$i"
690d8824
JH
264 done
265}
266
a42577d4 267# __git_refs_remotes requires 1 argument (to pass to ls-remote)
5de40f59
SP
268__git_refs_remotes ()
269{
270 local cmd i is_hash=y
799596a5 271 for i in $(git ls-remote "$1" 2>/dev/null); do
5de40f59
SP
272 case "$is_hash,$i" in
273 n,refs/heads/*)
274 is_hash=y
275 echo "$i:refs/remotes/$1/${i#refs/heads/}"
276 ;;
277 y,*) is_hash=n ;;
278 n,*^{}) is_hash=y ;;
279 n,refs/tags/*) is_hash=y;;
280 n,*) is_hash=y; ;;
281 esac
282 done
283}
284
690d8824
JH
285__git_remotes ()
286{
873537fa 287 local i ngoff IFS=$'\n' d="$(__gitdir)"
56fc25f2 288 shopt -q nullglob || ngoff=1
690d8824 289 shopt -s nullglob
873537fa
SP
290 for i in "$d/remotes"/*; do
291 echo ${i#$d/remotes/}
690d8824 292 done
56fc25f2 293 [ "$ngoff" ] && shopt -u nullglob
e0d10e1c 294 for i in $(git --git-dir="$d" config --list); do
56fc25f2
SP
295 case "$i" in
296 remote.*.url=*)
297 i="${i#remote.}"
298 echo "${i/.url=*/}"
299 ;;
300 esac
301 done
690d8824
JH
302}
303
4ad91321
SP
304__git_merge_strategies ()
305{
5c9cc64a 306 if [ -n "${__git_merge_strategylist-}" ]; then
b51ec6bd
SP
307 echo "$__git_merge_strategylist"
308 return
309 fi
25b3d4d6
JH
310 git merge -s help 2>&1 |
311 sed -n -e '/[Aa]vailable strategies are: /,/^$/{
312 s/\.$//
313 s/.*://
314 s/^[ ]*//
315 s/[ ]*$//
4ad91321 316 p
25b3d4d6 317 }'
4ad91321 318}
b51ec6bd 319__git_merge_strategylist=
25b3d4d6 320__git_merge_strategylist=$(__git_merge_strategies 2>/dev/null)
4ad91321 321
690d8824
JH
322__git_complete_file ()
323{
a79c6551 324 local pfx ls ref cur="${COMP_WORDS[COMP_CWORD]}"
690d8824
JH
325 case "$cur" in
326 ?*:*)
a79c6551
SP
327 ref="${cur%%:*}"
328 cur="${cur#*:}"
690d8824
JH
329 case "$cur" in
330 ?*/*)
a79c6551
SP
331 pfx="${cur%/*}"
332 cur="${cur##*/}"
690d8824
JH
333 ls="$ref:$pfx"
334 pfx="$pfx/"
335 ;;
336 *)
337 ls="$ref"
338 ;;
339 esac
db8a9ff0
SP
340
341 case "$COMP_WORDBREAKS" in
342 *:*) : great ;;
343 *) pfx="$ref:$pfx" ;;
344 esac
345
778306e4 346 local IFS=$'\n'
690d8824 347 COMPREPLY=($(compgen -P "$pfx" \
873537fa 348 -W "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \
778306e4
SP
349 | sed '/^100... blob /{
350 s,^.* ,,
351 s,$, ,
352 }
353 /^120000 blob /{
354 s,^.* ,,
355 s,$, ,
356 }
690d8824
JH
357 /^040000 tree /{
358 s,^.* ,,
359 s,$,/,
360 }
361 s/^.* //')" \
362 -- "$cur"))
363 ;;
364 *)
b3391775 365 __gitcomp "$(__git_refs)"
690d8824
JH
366 ;;
367 esac
368}
369
f53352fb
SP
370__git_complete_revlist ()
371{
372 local pfx cur="${COMP_WORDS[COMP_CWORD]}"
373 case "$cur" in
374 *...*)
375 pfx="${cur%...*}..."
376 cur="${cur#*...}"
b3391775 377 __gitcomp "$(__git_refs)" "$pfx" "$cur"
f53352fb
SP
378 ;;
379 *..*)
380 pfx="${cur%..*}.."
381 cur="${cur#*..}"
b3391775
SP
382 __gitcomp "$(__git_refs)" "$pfx" "$cur"
383 ;;
f53352fb 384 *)
b3391775 385 __gitcomp "$(__git_refs)"
f53352fb
SP
386 ;;
387 esac
388}
389
52d5c3b5
JS
390__git_complete_remote_or_refspec ()
391{
392 local cmd="${COMP_WORDS[1]}"
393 local cur="${COMP_WORDS[COMP_CWORD]}"
0a4e1472 394 local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0
52d5c3b5
JS
395 while [ $c -lt $COMP_CWORD ]; do
396 i="${COMP_WORDS[c]}"
397 case "$i" in
0a4e1472 398 --all|--mirror) [ "$cmd" = "push" ] && no_complete_refspec=1 ;;
52d5c3b5
JS
399 -*) ;;
400 *) remote="$i"; break ;;
401 esac
402 c=$((++c))
403 done
404 if [ -z "$remote" ]; then
405 __gitcomp "$(__git_remotes)"
406 return
407 fi
0a4e1472
JS
408 if [ $no_complete_refspec = 1 ]; then
409 COMPREPLY=()
410 return
411 fi
52d5c3b5
JS
412 [ "$remote" = "." ] && remote=
413 case "$cur" in
414 *:*)
415 case "$COMP_WORDBREAKS" in
416 *:*) : great ;;
417 *) pfx="${cur%%:*}:" ;;
418 esac
419 cur="${cur#*:}"
420 lhs=0
421 ;;
422 +*)
423 pfx="+"
424 cur="${cur#+}"
425 ;;
426 esac
427 case "$cmd" in
428 fetch)
429 if [ $lhs = 1 ]; then
430 __gitcomp "$(__git_refs2 "$remote")" "$pfx" "$cur"
431 else
432 __gitcomp "$(__git_refs)" "$pfx" "$cur"
433 fi
434 ;;
435 pull)
436 if [ $lhs = 1 ]; then
437 __gitcomp "$(__git_refs "$remote")" "$pfx" "$cur"
438 else
439 __gitcomp "$(__git_refs)" "$pfx" "$cur"
440 fi
441 ;;
442 push)
443 if [ $lhs = 1 ]; then
444 __gitcomp "$(__git_refs)" "$pfx" "$cur"
445 else
446 __gitcomp "$(__git_refs "$remote")" "$pfx" "$cur"
447 fi
448 ;;
449 esac
450}
451
3c7b480a
JS
452__git_complete_strategy ()
453{
454 case "${COMP_WORDS[COMP_CWORD-1]}" in
455 -s|--strategy)
456 __gitcomp "$(__git_merge_strategies)"
457 return 0
458 esac
459 local cur="${COMP_WORDS[COMP_CWORD]}"
460 case "$cur" in
461 --strategy=*)
462 __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}"
463 return 0
464 ;;
465 esac
466 return 1
467}
468
1eb7e2f8 469__git_all_commands ()
f2bb9f88 470{
5c9cc64a 471 if [ -n "${__git_all_commandlist-}" ]; then
1eb7e2f8 472 echo "$__git_all_commandlist"
b51ec6bd
SP
473 return
474 fi
f2bb9f88
SP
475 local i IFS=" "$'\n'
476 for i in $(git help -a|egrep '^ ')
1eb7e2f8
LM
477 do
478 case $i in
479 *--*) : helper pattern;;
480 *) echo $i;;
481 esac
482 done
483}
484__git_all_commandlist=
485__git_all_commandlist="$(__git_all_commands 2>/dev/null)"
486
487__git_porcelain_commands ()
488{
5c9cc64a 489 if [ -n "${__git_porcelain_commandlist-}" ]; then
1eb7e2f8
LM
490 echo "$__git_porcelain_commandlist"
491 return
492 fi
493 local i IFS=" "$'\n'
494 for i in "help" $(__git_all_commands)
f2bb9f88
SP
495 do
496 case $i in
718a087a 497 *--*) : helper pattern;;
a925c6f1
SP
498 applymbox) : ask gittus;;
499 applypatch) : ask gittus;;
500 archimport) : import;;
2e3a430a 501 cat-file) : plumbing;;
56d99c67 502 check-attr) : plumbing;;
f2bb9f88 503 check-ref-format) : plumbing;;
ff2549dc 504 checkout-index) : plumbing;;
f2bb9f88 505 commit-tree) : plumbing;;
ff2549dc 506 count-objects) : infrequent;;
a925c6f1
SP
507 cvsexportcommit) : export;;
508 cvsimport) : import;;
f2bb9f88
SP
509 cvsserver) : daemon;;
510 daemon) : daemon;;
5cfb4fe5
SP
511 diff-files) : plumbing;;
512 diff-index) : plumbing;;
513 diff-tree) : plumbing;;
c6ec3b13 514 fast-import) : import;;
ff2549dc 515 fast-export) : export;;
a925c6f1 516 fsck-objects) : plumbing;;
f2bb9f88 517 fetch-pack) : plumbing;;
a925c6f1 518 fmt-merge-msg) : plumbing;;
56d99c67 519 for-each-ref) : plumbing;;
f2bb9f88
SP
520 hash-object) : plumbing;;
521 http-*) : transport;;
522 index-pack) : plumbing;;
a925c6f1 523 init-db) : deprecated;;
f2bb9f88 524 local-fetch) : plumbing;;
ff2549dc
PB
525 lost-found) : infrequent;;
526 ls-files) : plumbing;;
527 ls-remote) : plumbing;;
528 ls-tree) : plumbing;;
f2bb9f88
SP
529 mailinfo) : plumbing;;
530 mailsplit) : plumbing;;
531 merge-*) : plumbing;;
532 mktree) : plumbing;;
533 mktag) : plumbing;;
534 pack-objects) : plumbing;;
535 pack-redundant) : plumbing;;
536 pack-refs) : plumbing;;
537 parse-remote) : plumbing;;
538 patch-id) : plumbing;;
539 peek-remote) : plumbing;;
a925c6f1
SP
540 prune) : plumbing;;
541 prune-packed) : plumbing;;
542 quiltimport) : import;;
f2bb9f88
SP
543 read-tree) : plumbing;;
544 receive-pack) : plumbing;;
2e3a430a 545 reflog) : plumbing;;
5c66d0d4 546 repo-config) : deprecated;;
f2bb9f88
SP
547 rerere) : plumbing;;
548 rev-list) : plumbing;;
549 rev-parse) : plumbing;;
550 runstatus) : plumbing;;
551 sh-setup) : internal;;
552 shell) : daemon;;
ff2549dc 553 show-ref) : plumbing;;
f2bb9f88
SP
554 send-pack) : plumbing;;
555 show-index) : plumbing;;
556 ssh-*) : transport;;
557 stripspace) : plumbing;;
558 symbolic-ref) : plumbing;;
a925c6f1 559 tar-tree) : deprecated;;
f2bb9f88
SP
560 unpack-file) : plumbing;;
561 unpack-objects) : plumbing;;
a925c6f1 562 update-index) : plumbing;;
f2bb9f88
SP
563 update-ref) : plumbing;;
564 update-server-info) : daemon;;
565 upload-archive) : plumbing;;
566 upload-pack) : plumbing;;
567 write-tree) : plumbing;;
ff2549dc
PB
568 var) : infrequent;;
569 verify-pack) : infrequent;;
a925c6f1 570 verify-tag) : plumbing;;
f2bb9f88
SP
571 *) echo $i;;
572 esac
573 done
574}
1eb7e2f8
LM
575__git_porcelain_commandlist=
576__git_porcelain_commandlist="$(__git_porcelain_commands 2>/dev/null)"
f2bb9f88 577
367dce2a
DS
578__git_aliases ()
579{
56fc25f2 580 local i IFS=$'\n'
e0d10e1c 581 for i in $(git --git-dir="$(__gitdir)" config --list); do
56fc25f2
SP
582 case "$i" in
583 alias.*)
584 i="${i#alias.}"
585 echo "${i/=*/}"
586 ;;
587 esac
588 done
367dce2a
DS
589}
590
a42577d4 591# __git_aliased_command requires 1 argument
367dce2a
DS
592__git_aliased_command ()
593{
873537fa 594 local word cmdline=$(git --git-dir="$(__gitdir)" \
e0d10e1c 595 config --get "alias.$1")
367dce2a
DS
596 for word in $cmdline; do
597 if [ "${word##-*}" ]; then
598 echo $word
599 return
600 fi
601 done
602}
603
a42577d4 604# __git_find_subcommand requires 1 argument
3ff1320d
SG
605__git_find_subcommand ()
606{
607 local word subcommand c=1
608
609 while [ $c -lt $COMP_CWORD ]; do
610 word="${COMP_WORDS[c]}"
611 for subcommand in $1; do
612 if [ "$subcommand" = "$word" ]; then
613 echo "$subcommand"
614 return
615 fi
616 done
617 c=$((++c))
618 done
619}
620
d773c631
SG
621__git_has_doubledash ()
622{
623 local c=1
624 while [ $c -lt $COMP_CWORD ]; do
625 if [ "--" = "${COMP_WORDS[c]}" ]; then
626 return 0
627 fi
628 c=$((++c))
629 done
630 return 1
631}
632
7950659d 633__git_whitespacelist="nowarn warn error error-all fix"
88329195
SP
634
635_git_am ()
636{
28ed6e7b 637 local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)"
51ef1daa 638 if [ -d "$dir"/rebase-apply ]; then
a31c00b0 639 __gitcomp "--skip --resolved --abort"
88329195
SP
640 return
641 fi
642 case "$cur" in
643 --whitespace=*)
b3391775 644 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
88329195
SP
645 return
646 ;;
647 --*)
b3391775 648 __gitcomp "
43acdf24
TZ
649 --3way --committer-date-is-author-date --ignore-date
650 --interactive --keep --no-utf8 --signoff --utf8
88329195 651 --whitespace=
b3391775 652 "
88329195
SP
653 return
654 esac
655 COMPREPLY=()
656}
657
658_git_apply ()
659{
660 local cur="${COMP_WORDS[COMP_CWORD]}"
661 case "$cur" in
662 --whitespace=*)
b3391775 663 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
88329195
SP
664 return
665 ;;
666 --*)
b3391775 667 __gitcomp "
88329195
SP
668 --stat --numstat --summary --check --index
669 --cached --index-info --reverse --reject --unidiff-zero
670 --apply --no-add --exclude=
671 --whitespace= --inaccurate-eof --verbose
b3391775 672 "
88329195
SP
673 return
674 esac
675 COMPREPLY=()
676}
677
8435b548
SP
678_git_add ()
679{
d773c631
SG
680 __git_has_doubledash && return
681
8435b548
SP
682 local cur="${COMP_WORDS[COMP_CWORD]}"
683 case "$cur" in
684 --*)
1d284cba
SG
685 __gitcomp "
686 --interactive --refresh --patch --update --dry-run
c9a114b5 687 --ignore-errors --intent-to-add
1d284cba 688 "
8435b548
SP
689 return
690 esac
691 COMPREPLY=()
692}
693
b3191ce2
LM
694_git_archive ()
695{
696 local cur="${COMP_WORDS[COMP_CWORD]}"
697 case "$cur" in
698 --format=*)
699 __gitcomp "$(git archive --list)" "" "${cur##--format=}"
700 return
701 ;;
702 --remote=*)
703 __gitcomp "$(__git_remotes)" "" "${cur##--remote=}"
704 return
705 ;;
706 --*)
707 __gitcomp "
708 --format= --list --verbose
709 --prefix= --remote= --exec=
710 "
711 return
712 ;;
713 esac
714 __git_complete_file
715}
716
b2e69f62
SP
717_git_bisect ()
718{
d773c631
SG
719 __git_has_doubledash && return
720
bf11d461 721 local subcommands="start bad good skip reset visualize replay log run"
3ff1320d
SG
722 local subcommand="$(__git_find_subcommand "$subcommands")"
723 if [ -z "$subcommand" ]; then
724 __gitcomp "$subcommands"
b2e69f62
SP
725 return
726 fi
727
3ff1320d 728 case "$subcommand" in
bf11d461 729 bad|good|reset|skip)
b2e69f62
SP
730 __gitcomp "$(__git_refs)"
731 ;;
732 *)
733 COMPREPLY=()
734 ;;
735 esac
736}
737
690d8824
JH
738_git_branch ()
739{
b9217642
SG
740 local i c=1 only_local_ref="n" has_r="n"
741
742 while [ $c -lt $COMP_CWORD ]; do
743 i="${COMP_WORDS[c]}"
744 case "$i" in
745 -d|-m) only_local_ref="y" ;;
746 -r) has_r="y" ;;
747 esac
748 c=$((++c))
749 done
750
3b376b0c 751 case "${COMP_WORDS[COMP_CWORD]}" in
3b376b0c
SG
752 --*)
753 __gitcomp "
754 --color --no-color --verbose --abbrev= --no-abbrev
50e61025 755 --track --no-track --contains --merged --no-merged
3b376b0c
SG
756 "
757 ;;
b9217642
SG
758 *)
759 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
760 __gitcomp "$(__git_heads)"
761 else
762 __gitcomp "$(__git_refs)"
763 fi
764 ;;
3b376b0c 765 esac
690d8824
JH
766}
767
374a58c9
ML
768_git_bundle ()
769{
8d8163f3
SG
770 local cmd="${COMP_WORDS[2]}"
771 case "$COMP_CWORD" in
772 2)
374a58c9
ML
773 __gitcomp "create list-heads verify unbundle"
774 ;;
8d8163f3 775 3)
374a58c9
ML
776 # looking for a file
777 ;;
778 *)
779 case "$cmd" in
780 create)
781 __git_complete_revlist
782 ;;
783 esac
784 ;;
785 esac
786}
787
690d8824
JH
788_git_checkout ()
789{
c84bb14c
SG
790 __git_has_doubledash && return
791
b3391775 792 __gitcomp "$(__git_refs)"
690d8824
JH
793}
794
d8a9fea5
SP
795_git_cherry ()
796{
797 __gitcomp "$(__git_refs)"
798}
799
1273231e
SP
800_git_cherry_pick ()
801{
802 local cur="${COMP_WORDS[COMP_CWORD]}"
803 case "$cur" in
804 --*)
b3391775 805 __gitcomp "--edit --no-commit"
1273231e
SP
806 ;;
807 *)
b3391775 808 __gitcomp "$(__git_refs)"
1273231e
SP
809 ;;
810 esac
811}
812
4181c7e8
LM
813_git_clean ()
814{
815 __git_has_doubledash && return
816
817 local cur="${COMP_WORDS[COMP_CWORD]}"
818 case "$cur" in
819 --*)
820 __gitcomp "--dry-run --quiet"
821 return
822 ;;
823 esac
824 COMPREPLY=()
825}
826
3eb11012
LM
827_git_clone ()
828{
829 local cur="${COMP_WORDS[COMP_CWORD]}"
830 case "$cur" in
831 --*)
832 __gitcomp "
833 --local
834 --no-hardlinks
835 --shared
836 --reference
837 --quiet
838 --no-checkout
839 --bare
840 --mirror
841 --origin
842 --upload-pack
843 --template=
844 --depth
845 "
846 return
847 ;;
848 esac
849 COMPREPLY=()
850}
851
4548e855
SP
852_git_commit ()
853{
d773c631
SG
854 __git_has_doubledash && return
855
4548e855
SP
856 local cur="${COMP_WORDS[COMP_CWORD]}"
857 case "$cur" in
858 --*)
b3391775 859 __gitcomp "
4548e855 860 --all --author= --signoff --verify --no-verify
aa5735be 861 --edit --amend --include --only --interactive
b3391775 862 "
4548e855
SP
863 return
864 esac
865 COMPREPLY=()
866}
867
217926c0
SP
868_git_describe ()
869{
cbb504c9
TR
870 local cur="${COMP_WORDS[COMP_CWORD]}"
871 case "$cur" in
872 --*)
873 __gitcomp "
874 --all --tags --contains --abbrev= --candidates=
875 --exact-match --debug --long --match --always
876 "
877 return
878 esac
217926c0
SP
879 __gitcomp "$(__git_refs)"
880}
881
20bf7292 882__git_diff_common_options="--stat --numstat --shortstat --summary
b3a4f858
JS
883 --patch-with-stat --name-only --name-status --color
884 --no-color --color-words --no-renames --check
f135aacb 885 --full-index --binary --abbrev --diff-filter=
47d5a8fa 886 --find-copies-harder
b3a4f858
JS
887 --text --ignore-space-at-eol --ignore-space-change
888 --ignore-all-space --exit-code --quiet --ext-diff
aba201c6
PO
889 --no-ext-diff
890 --no-prefix --src-prefix= --dst-prefix=
6d0e674a 891 --inter-hunk-context=
cc545709 892 --patience
20bf7292
TR
893 --raw
894"
895
896_git_diff ()
897{
898 __git_has_doubledash && return
899
900 local cur="${COMP_WORDS[COMP_CWORD]}"
901 case "$cur" in
902 --*)
ebd15bf0 903 __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
20bf7292
TR
904 --base --ours --theirs
905 $__git_diff_common_options
aba201c6 906 "
b3a4f858
JS
907 return
908 ;;
909 esac
690d8824
JH
910 __git_complete_file
911}
912
e2dc2de9
DA
913__git_mergetools_common="diffuse ecmerge emerge kdiff3 meld opendiff
914 tkdiff vimdiff gvimdiff xxdiff
915"
916
917_git_difftool ()
918{
919 local cur="${COMP_WORDS[COMP_CWORD]}"
920 case "$cur" in
921 --tool=*)
922 __gitcomp "$__git_mergetools_common kompare" "" "${cur##--tool=}"
923 return
924 ;;
925 --*)
926 __gitcomp "--tool="
927 return
928 ;;
929 esac
930 COMPREPLY=()
931}
932
0a4e1472
JS
933__git_fetch_options="
934 --quiet --verbose --append --upload-pack --force --keep --depth=
935 --tags --no-tags
936"
937
690d8824
JH
938_git_fetch ()
939{
0a4e1472
JS
940 local cur="${COMP_WORDS[COMP_CWORD]}"
941 case "$cur" in
942 --*)
943 __gitcomp "$__git_fetch_options"
944 return
945 ;;
946 esac
52d5c3b5 947 __git_complete_remote_or_refspec
690d8824
JH
948}
949
f53352fb
SP
950_git_format_patch ()
951{
952 local cur="${COMP_WORDS[COMP_CWORD]}"
953 case "$cur" in
e1d37937
SB
954 --thread=*)
955 __gitcomp "
956 deep shallow
957 " "" "${cur##--thread=}"
958 return
959 ;;
f53352fb 960 --*)
b3391775 961 __gitcomp "
e1d37937 962 --stdout --attach --no-attach --thread --thread=
f53352fb
SP
963 --output-directory
964 --numbered --start-number
47e98eec 965 --numbered-files
f53352fb
SP
966 --keep-subject
967 --signoff
3f7df3a7 968 --in-reply-to= --cc=
f53352fb 969 --full-index --binary
ec804891 970 --not --all
be5f5bf0 971 --cover-letter
aba201c6 972 --no-prefix --src-prefix= --dst-prefix=
81085134
SG
973 --inline --suffix= --ignore-if-in-upstream
974 --subject-prefix=
b3391775 975 "
f53352fb
SP
976 return
977 ;;
978 esac
979 __git_complete_revlist
980}
981
4bca8636
AJ
982_git_fsck ()
983{
984 local cur="${COMP_WORDS[COMP_CWORD]}"
985 case "$cur" in
986 --*)
987 __gitcomp "
988 --tags --root --unreachable --cache --no-reflogs --full
989 --strict --verbose --lost-found
990 "
991 return
992 ;;
993 esac
994 COMPREPLY=()
995}
996
b26c8748
SP
997_git_gc ()
998{
999 local cur="${COMP_WORDS[COMP_CWORD]}"
1000 case "$cur" in
1001 --*)
47e98eec 1002 __gitcomp "--prune --aggressive"
b26c8748
SP
1003 return
1004 ;;
1005 esac
1006 COMPREPLY=()
1007}
1008
c72e0db1
LM
1009_git_grep ()
1010{
1011 __git_has_doubledash && return
1012
1013 local cur="${COMP_WORDS[COMP_CWORD]}"
1014 case "$cur" in
1015 --*)
1016 __gitcomp "
1017 --cached
1018 --text --ignore-case --word-regexp --invert-match
1019 --full-name
1020 --extended-regexp --basic-regexp --fixed-strings
1021 --files-with-matches --name-only
1022 --files-without-match
1023 --count
1024 --and --or --not --all-match
1025 "
1026 return
1027 ;;
1028 esac
1029 COMPREPLY=()
1030}
1031
1eb7e2f8
LM
1032_git_help ()
1033{
1034 local cur="${COMP_WORDS[COMP_CWORD]}"
1035 case "$cur" in
1036 --*)
1037 __gitcomp "--all --info --man --web"
1038 return
1039 ;;
1040 esac
2946cccf
MG
1041 __gitcomp "$(__git_all_commands)
1042 attributes cli core-tutorial cvs-migration
1043 diffcore gitk glossary hooks ignore modules
1044 repository-layout tutorial tutorial-2
99f0b599 1045 workflows
2946cccf 1046 "
1eb7e2f8
LM
1047}
1048
5dad868b
LM
1049_git_init ()
1050{
1051 local cur="${COMP_WORDS[COMP_CWORD]}"
1052 case "$cur" in
1053 --shared=*)
1054 __gitcomp "
1055 false true umask group all world everybody
1056 " "" "${cur##--shared=}"
1057 return
1058 ;;
1059 --*)
1060 __gitcomp "--quiet --bare --template= --shared --shared="
1061 return
1062 ;;
1063 esac
1064 COMPREPLY=()
1065}
1066
b1bc1494
LM
1067_git_ls_files ()
1068{
1069 __git_has_doubledash && return
1070
1071 local cur="${COMP_WORDS[COMP_CWORD]}"
1072 case "$cur" in
1073 --*)
1074 __gitcomp "--cached --deleted --modified --others --ignored
1075 --stage --directory --no-empty-directory --unmerged
1076 --killed --exclude= --exclude-from=
1077 --exclude-per-directory= --exclude-standard
1078 --error-unmatch --with-tree= --full-name
1079 --abbrev --ignored --exclude-per-directory
1080 "
1081 return
1082 ;;
1083 esac
1084 COMPREPLY=()
1085}
1086
690d8824
JH
1087_git_ls_remote ()
1088{
b3391775 1089 __gitcomp "$(__git_remotes)"
690d8824
JH
1090}
1091
1092_git_ls_tree ()
1093{
1094 __git_complete_file
1095}
1096
a393777e
TR
1097# Options that go well for log, shortlog and gitk
1098__git_log_common_options="
1099 --not --all
1100 --branches --tags --remotes
1101 --first-parent --no-merges
1102 --max-count=
1103 --max-age= --since= --after=
1104 --min-age= --until= --before=
1105"
1106# Options that go well for log and gitk (not shortlog)
1107__git_log_gitk_options="
1108 --dense --sparse --full-history
1109 --simplify-merges --simplify-by-decoration
1110 --left-right
1111"
1112# Options that go well for log and shortlog (not gitk)
1113__git_log_shortlog_options="
1114 --author= --committer= --grep=
1115 --all-match
1116"
1117
3d279863 1118__git_log_pretty_formats="oneline short medium full fuller email raw format:"
672c68cb 1119__git_log_date_formats="relative iso8601 rfc2822 short local default raw"
3d279863 1120
690d8824
JH
1121_git_log ()
1122{
d773c631
SG
1123 __git_has_doubledash && return
1124
6e31b866 1125 local cur="${COMP_WORDS[COMP_CWORD]}"
bf3c20f6
TR
1126 local g="$(git rev-parse --git-dir 2>/dev/null)"
1127 local merge=""
ba7906f2 1128 if [ -f "$g/MERGE_HEAD" ]; then
bf3c20f6
TR
1129 merge="--merge"
1130 fi
6e31b866
SP
1131 case "$cur" in
1132 --pretty=*)
3d279863 1133 __gitcomp "$__git_log_pretty_formats
b3391775 1134 " "" "${cur##--pretty=}"
6e31b866
SP
1135 return
1136 ;;
72de29c2
TL
1137 --format=*)
1138 __gitcomp "$__git_log_pretty_formats
1139 " "" "${cur##--format=}"
1140 return
1141 ;;
47e98eec 1142 --date=*)
672c68cb 1143 __gitcomp "$__git_log_date_formats" "" "${cur##--date=}"
47e98eec
SP
1144 return
1145 ;;
6e31b866 1146 --*)
b3391775 1147 __gitcomp "
a393777e
TR
1148 $__git_log_common_options
1149 $__git_log_shortlog_options
1150 $__git_log_gitk_options
8f87fae6 1151 --root --topo-order --date-order --reverse
a393777e 1152 --follow
6e31b866 1153 --abbrev-commit --abbrev=
47e98eec 1154 --relative-date --date=
72de29c2 1155 --pretty= --format= --oneline
a393777e 1156 --cherry-pick
20827d99 1157 --graph
20bf7292
TR
1158 --decorate
1159 --walk-reflogs
a393777e 1160 --parents --children
bf3c20f6 1161 $merge
20bf7292 1162 $__git_diff_common_options
47d5a8fa 1163 --pickaxe-all --pickaxe-regex
b3391775 1164 "
6e31b866
SP
1165 return
1166 ;;
1167 esac
f53352fb 1168 __git_complete_revlist
690d8824
JH
1169}
1170
0a4e1472
JS
1171__git_merge_options="
1172 --no-commit --no-stat --log --no-log --squash --strategy
1173 --commit --stat --no-squash --ff --no-ff
1174"
1175
4ad91321
SP
1176_git_merge ()
1177{
3c7b480a
JS
1178 __git_complete_strategy && return
1179
4ad91321
SP
1180 local cur="${COMP_WORDS[COMP_CWORD]}"
1181 case "$cur" in
1182 --*)
0a4e1472 1183 __gitcomp "$__git_merge_options"
4ad91321
SP
1184 return
1185 esac
b3391775 1186 __gitcomp "$(__git_refs)"
4ad91321
SP
1187}
1188
b4c72162
LM
1189_git_mergetool ()
1190{
1191 local cur="${COMP_WORDS[COMP_CWORD]}"
1192 case "$cur" in
1193 --tool=*)
e2dc2de9 1194 __gitcomp "$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"
b4c72162
LM
1195 return
1196 ;;
1197 --*)
1198 __gitcomp "--tool="
1199 return
1200 ;;
1201 esac
1202 COMPREPLY=()
1203}
1204
690d8824
JH
1205_git_merge_base ()
1206{
b3391775 1207 __gitcomp "$(__git_refs)"
690d8824
JH
1208}
1209
1127c51c
LM
1210_git_mv ()
1211{
1212 local cur="${COMP_WORDS[COMP_CWORD]}"
1213 case "$cur" in
1214 --*)
1215 __gitcomp "--dry-run"
1216 return
1217 ;;
1218 esac
1219 COMPREPLY=()
1220}
1221
d33909bf
SP
1222_git_name_rev ()
1223{
b3391775 1224 __gitcomp "--tags --all --stdin"
d33909bf
SP
1225}
1226
690d8824
JH
1227_git_pull ()
1228{
0a4e1472
JS
1229 __git_complete_strategy && return
1230
1231 local cur="${COMP_WORDS[COMP_CWORD]}"
1232 case "$cur" in
1233 --*)
1234 __gitcomp "
1235 --rebase --no-rebase
1236 $__git_merge_options
1237 $__git_fetch_options
1238 "
1239 return
1240 ;;
1241 esac
52d5c3b5 1242 __git_complete_remote_or_refspec
690d8824
JH
1243}
1244
1245_git_push ()
1246{
0a4e1472
JS
1247 local cur="${COMP_WORDS[COMP_CWORD]}"
1248 case "${COMP_WORDS[COMP_CWORD-1]}" in
1249 --repo)
1250 __gitcomp "$(__git_remotes)"
1251 return
1252 esac
1253 case "$cur" in
1254 --repo=*)
1255 __gitcomp "$(__git_remotes)" "" "${cur##--repo=}"
1256 return
1257 ;;
1258 --*)
1259 __gitcomp "
1260 --all --mirror --tags --dry-run --force --verbose
1261 --receive-pack= --repo=
1262 "
1263 return
1264 ;;
1265 esac
52d5c3b5 1266 __git_complete_remote_or_refspec
690d8824
JH
1267}
1268
61d926a3
SP
1269_git_rebase ()
1270{
51fe1209 1271 local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)"
51ef1daa 1272 if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
b3391775 1273 __gitcomp "--continue --skip --abort"
61d926a3
SP
1274 return
1275 fi
3c7b480a 1276 __git_complete_strategy && return
61d926a3
SP
1277 case "$cur" in
1278 --*)
d9e3b702 1279 __gitcomp "--onto --merge --strategy --interactive"
61d926a3
SP
1280 return
1281 esac
b3391775 1282 __gitcomp "$(__git_refs)"
61d926a3
SP
1283}
1284
ae616de6
SB
1285__git_send_email_confirm_options="always never auto cc compose"
1286__git_send_email_suppresscc_options="author self cc ccbody sob cccmd body all"
1287
25a1f374
TL
1288_git_send_email ()
1289{
1290 local cur="${COMP_WORDS[COMP_CWORD]}"
1291 case "$cur" in
ae616de6
SB
1292 --confirm=*)
1293 __gitcomp "
1294 $__git_send_email_confirm_options
1295 " "" "${cur##--confirm=}"
1296 return
1297 ;;
1298 --suppress-cc=*)
1299 __gitcomp "
1300 $__git_send_email_suppresscc_options
1301 " "" "${cur##--suppress-cc=}"
1302
1303 return
1304 ;;
1305 --smtp-encryption=*)
1306 __gitcomp "ssl tls" "" "${cur##--smtp-encryption=}"
1307 return
1308 ;;
25a1f374 1309 --*)
77813151 1310 __gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to
ae616de6
SB
1311 --compose --confirm= --dry-run --envelope-sender
1312 --from --identity
25a1f374
TL
1313 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
1314 --no-suppress-from --no-thread --quiet
1315 --signed-off-by-cc --smtp-pass --smtp-server
ae616de6
SB
1316 --smtp-server-port --smtp-encryption= --smtp-user
1317 --subject --suppress-cc= --suppress-from --thread --to
fd3a8dcb 1318 --validate --no-validate"
25a1f374
TL
1319 return
1320 ;;
1321 esac
1322 COMPREPLY=()
1323}
1324
e0d10e1c 1325_git_config ()
5de40f59
SP
1326{
1327 local cur="${COMP_WORDS[COMP_CWORD]}"
1328 local prv="${COMP_WORDS[COMP_CWORD-1]}"
1329 case "$prv" in
1330 branch.*.remote)
78d4d6a2 1331 __gitcomp "$(__git_remotes)"
5de40f59
SP
1332 return
1333 ;;
1334 branch.*.merge)
78d4d6a2 1335 __gitcomp "$(__git_refs)"
5de40f59
SP
1336 return
1337 ;;
1338 remote.*.fetch)
1339 local remote="${prv#remote.}"
1340 remote="${remote%.fetch}"
78d4d6a2 1341 __gitcomp "$(__git_refs_remotes "$remote")"
5de40f59
SP
1342 return
1343 ;;
1344 remote.*.push)
1345 local remote="${prv#remote.}"
1346 remote="${remote%.push}"
78d4d6a2 1347 __gitcomp "$(git --git-dir="$(__gitdir)" \
5de40f59 1348 for-each-ref --format='%(refname):%(refname)' \
78d4d6a2
SP
1349 refs/heads)"
1350 return
1351 ;;
1352 pull.twohead|pull.octopus)
1353 __gitcomp "$(__git_merge_strategies)"
1354 return
1355 ;;
901d615c 1356 color.branch|color.diff|color.interactive|color.status|color.ui)
78d4d6a2
SP
1357 __gitcomp "always never auto"
1358 return
1359 ;;
901d615c
MK
1360 color.pager)
1361 __gitcomp "false true"
1362 return
1363 ;;
78d4d6a2
SP
1364 color.*.*)
1365 __gitcomp "
98171a07 1366 normal black red green yellow blue magenta cyan white
78d4d6a2
SP
1367 bold dim ul blink reverse
1368 "
5de40f59
SP
1369 return
1370 ;;
9b82d63b
SB
1371 help.format)
1372 __gitcomp "man info web html"
1373 return
1374 ;;
672c68cb
SB
1375 log.date)
1376 __gitcomp "$__git_log_date_formats"
1377 return
1378 ;;
ae616de6
SB
1379 sendemail.aliasesfiletype)
1380 __gitcomp "mutt mailrc pine elm gnus"
1381 return
1382 ;;
1383 sendemail.confirm)
1384 __gitcomp "$__git_send_email_confirm_options"
1385 return
1386 ;;
1387 sendemail.suppresscc)
1388 __gitcomp "$__git_send_email_suppresscc_options"
1389 return
1390 ;;
5de40f59
SP
1391 *.*)
1392 COMPREPLY=()
1393 return
1394 ;;
1395 esac
1396 case "$cur" in
1397 --*)
78d4d6a2 1398 __gitcomp "
47e98eec 1399 --global --system --file=
12977705 1400 --list --replace-all
5de40f59 1401 --get --get-all --get-regexp
1b71eb35 1402 --add --unset --unset-all
12977705 1403 --remove-section --rename-section
78d4d6a2 1404 "
5de40f59
SP
1405 return
1406 ;;
1407 branch.*.*)
1408 local pfx="${cur%.*}."
1409 cur="${cur##*.}"
98171a07 1410 __gitcomp "remote merge mergeoptions" "$pfx" "$cur"
5de40f59
SP
1411 return
1412 ;;
1413 branch.*)
1414 local pfx="${cur%.*}."
1415 cur="${cur#*.}"
78d4d6a2 1416 __gitcomp "$(__git_heads)" "$pfx" "$cur" "."
5de40f59
SP
1417 return
1418 ;;
0aa62fd0
SB
1419 guitool.*.*)
1420 local pfx="${cur%.*}."
1421 cur="${cur##*.}"
1422 __gitcomp "
1423 argprompt cmd confirm needsfile noconsole norescan
1424 prompt revprompt revunmerged title
1425 " "$pfx" "$cur"
1426 return
1427 ;;
1428 difftool.*.*)
1429 local pfx="${cur%.*}."
1430 cur="${cur##*.}"
1431 __gitcomp "cmd path" "$pfx" "$cur"
1432 return
1433 ;;
1434 man.*.*)
1435 local pfx="${cur%.*}."
1436 cur="${cur##*.}"
1437 __gitcomp "cmd path" "$pfx" "$cur"
1438 return
1439 ;;
1440 mergetool.*.*)
1441 local pfx="${cur%.*}."
1442 cur="${cur##*.}"
1443 __gitcomp "cmd path trustExitCode" "$pfx" "$cur"
1444 return
1445 ;;
1446 pager.*)
1447 local pfx="${cur%.*}."
1448 cur="${cur#*.}"
1449 __gitcomp "$(__git_all_commands)" "$pfx" "$cur"
1450 return
1451 ;;
5de40f59
SP
1452 remote.*.*)
1453 local pfx="${cur%.*}."
1454 cur="${cur##*.}"
12977705 1455 __gitcomp "
98171a07 1456 url proxy fetch push mirror skipDefaultUpdate
12977705
SP
1457 receivepack uploadpack tagopt
1458 " "$pfx" "$cur"
5de40f59
SP
1459 return
1460 ;;
1461 remote.*)
1462 local pfx="${cur%.*}."
1463 cur="${cur#*.}"
78d4d6a2 1464 __gitcomp "$(__git_remotes)" "$pfx" "$cur" "."
5de40f59
SP
1465 return
1466 ;;
0aa62fd0
SB
1467 url.*.*)
1468 local pfx="${cur%.*}."
1469 cur="${cur##*.}"
1470 __gitcomp "insteadof" "$pfx" "$cur"
1471 return
1472 ;;
5de40f59 1473 esac
78d4d6a2 1474 __gitcomp "
226b343c 1475 alias.
5de40f59 1476 apply.whitespace
98171a07
LM
1477 branch.autosetupmerge
1478 branch.autosetuprebase
2122591b 1479 clean.requireForce
78d4d6a2
SP
1480 color.branch
1481 color.branch.current
1482 color.branch.local
78d4d6a2 1483 color.branch.plain
025a1929 1484 color.branch.remote
a159ca0c 1485 color.diff
025a1929 1486 color.diff.commit
78d4d6a2 1487 color.diff.frag
025a1929 1488 color.diff.meta
78d4d6a2 1489 color.diff.new
025a1929
LM
1490 color.diff.old
1491 color.diff.plain
78d4d6a2 1492 color.diff.whitespace
226b343c
SB
1493 color.grep
1494 color.grep.external
1495 color.grep.match
98171a07
LM
1496 color.interactive
1497 color.interactive.header
1498 color.interactive.help
1499 color.interactive.prompt
a159ca0c 1500 color.pager
a159ca0c 1501 color.status
78d4d6a2
SP
1502 color.status.added
1503 color.status.changed
025a1929 1504 color.status.header
98171a07 1505 color.status.nobranch
78d4d6a2 1506 color.status.untracked
98171a07
LM
1507 color.status.updated
1508 color.ui
1509 commit.template
1510 core.autocrlf
1511 core.bare
025a1929 1512 core.compression
226b343c 1513 core.createObject
98171a07
LM
1514 core.deltaBaseCacheLimit
1515 core.editor
1516 core.excludesfile
025a1929 1517 core.fileMode
98171a07 1518 core.fsyncobjectfiles
025a1929 1519 core.gitProxy
98171a07 1520 core.ignoreCygwinFSTricks
025a1929
LM
1521 core.ignoreStat
1522 core.logAllRefUpdates
1523 core.loosecompression
1524 core.packedGitLimit
1525 core.packedGitWindowSize
98171a07 1526 core.pager
025a1929 1527 core.preferSymlinkRefs
98171a07
LM
1528 core.preloadindex
1529 core.quotepath
025a1929 1530 core.repositoryFormatVersion
98171a07 1531 core.safecrlf
025a1929 1532 core.sharedRepository
98171a07
LM
1533 core.symlinks
1534 core.trustctime
025a1929 1535 core.warnAmbiguousRefs
98171a07
LM
1536 core.whitespace
1537 core.worktree
1538 diff.autorefreshindex
1539 diff.external
1540 diff.mnemonicprefix
78d4d6a2 1541 diff.renameLimit
98171a07 1542 diff.renameLimit.
78d4d6a2 1543 diff.renames
226b343c
SB
1544 diff.suppressBlankEmpty
1545 diff.tool
1546 diff.wordRegex
0aa62fd0 1547 difftool.
226b343c 1548 difftool.prompt
78d4d6a2 1549 fetch.unpackLimit
226b343c
SB
1550 format.attach
1551 format.cc
78d4d6a2 1552 format.headers
98171a07
LM
1553 format.numbered
1554 format.pretty
226b343c
SB
1555 format.signoff
1556 format.subjectprefix
98171a07 1557 format.suffix
226b343c 1558 format.thread
98171a07
LM
1559 gc.aggressiveWindow
1560 gc.auto
1561 gc.autopacklimit
12977705 1562 gc.packrefs
98171a07 1563 gc.pruneexpire
78d4d6a2
SP
1564 gc.reflogexpire
1565 gc.reflogexpireunreachable
1566 gc.rerereresolved
1567 gc.rerereunresolved
025a1929 1568 gitcvs.allbinary
226b343c 1569 gitcvs.commitmsgannotation
98171a07 1570 gitcvs.dbTableNamePrefix
025a1929
LM
1571 gitcvs.dbdriver
1572 gitcvs.dbname
1573 gitcvs.dbpass
025a1929
LM
1574 gitcvs.dbuser
1575 gitcvs.enabled
1576 gitcvs.logfile
98171a07 1577 gitcvs.usecrlfattr
0aa62fd0 1578 guitool.
98171a07
LM
1579 gui.blamehistoryctx
1580 gui.commitmsgwidth
1581 gui.copyblamethreshold
1582 gui.diffcontext
1583 gui.encoding
1584 gui.fastcopyblame
1585 gui.matchtrackingbranch
1586 gui.newbranchtemplate
1587 gui.pruneduringfetch
1588 gui.spellingdictionary
1589 gui.trustmtime
1590 help.autocorrect
1591 help.browser
1592 help.format
78d4d6a2
SP
1593 http.lowSpeedLimit
1594 http.lowSpeedTime
025a1929 1595 http.maxRequests
5de40f59 1596 http.noEPSV
98171a07 1597 http.proxy
025a1929
LM
1598 http.sslCAInfo
1599 http.sslCAPath
1600 http.sslCert
1601 http.sslKey
1602 http.sslVerify
78d4d6a2
SP
1603 i18n.commitEncoding
1604 i18n.logOutputEncoding
226b343c
SB
1605 imap.folder
1606 imap.host
1607 imap.pass
1608 imap.port
1609 imap.preformattedHTML
1610 imap.sslverify
1611 imap.tunnel
1612 imap.user
98171a07
LM
1613 instaweb.browser
1614 instaweb.httpd
1615 instaweb.local
1616 instaweb.modulepath
1617 instaweb.port
226b343c 1618 interactive.singlekey
98171a07 1619 log.date
78d4d6a2 1620 log.showroot
226b343c 1621 mailmap.file
0aa62fd0 1622 man.
98171a07
LM
1623 man.viewer
1624 merge.conflictstyle
1625 merge.log
1626 merge.renameLimit
1627 merge.stat
025a1929 1628 merge.tool
78d4d6a2 1629 merge.verbosity
0aa62fd0 1630 mergetool.
98171a07 1631 mergetool.keepBackup
226b343c 1632 mergetool.prompt
47e98eec 1633 pack.compression
47e98eec 1634 pack.deltaCacheLimit
025a1929
LM
1635 pack.deltaCacheSize
1636 pack.depth
98171a07
LM
1637 pack.indexVersion
1638 pack.packSizeLimit
1639 pack.threads
025a1929
LM
1640 pack.window
1641 pack.windowMemory
0aa62fd0 1642 pager.
78d4d6a2
SP
1643 pull.octopus
1644 pull.twohead
226b343c
SB
1645 push.default
1646 rebase.stat
98171a07
LM
1647 receive.denyCurrentBranch
1648 receive.denyDeletes
025a1929 1649 receive.denyNonFastForwards
98171a07 1650 receive.fsckObjects
025a1929 1651 receive.unpackLimit
98171a07
LM
1652 repack.usedeltabaseoffset
1653 rerere.autoupdate
1654 rerere.enabled
226b343c
SB
1655 sendemail.aliasesfile
1656 sendemail.aliasesfiletype
1657 sendemail.bcc
1658 sendemail.cc
1659 sendemail.cccmd
1660 sendemail.chainreplyto
1661 sendemail.confirm
1662 sendemail.envelopesender
1663 sendemail.multiedit
1664 sendemail.signedoffbycc
1665 sendemail.smtpencryption
1666 sendemail.smtppass
1667 sendemail.smtpserver
1668 sendemail.smtpserverport
1669 sendemail.smtpuser
1670 sendemail.suppresscc
1671 sendemail.suppressfrom
1672 sendemail.thread
1673 sendemail.to
1674 sendemail.validate
78d4d6a2 1675 showbranch.default
98171a07
LM
1676 status.relativePaths
1677 status.showUntrackedFiles
78d4d6a2
SP
1678 tar.umask
1679 transfer.unpackLimit
0aa62fd0 1680 url.
78d4d6a2 1681 user.email
025a1929 1682 user.name
78d4d6a2 1683 user.signingkey
98171a07 1684 web.browser
5de40f59 1685 branch. remote.
78d4d6a2 1686 "
5de40f59
SP
1687}
1688
88293c67
SP
1689_git_remote ()
1690{
bc14fac8 1691 local subcommands="add rename rm show prune update set-head"
3ff1320d
SG
1692 local subcommand="$(__git_find_subcommand "$subcommands")"
1693 if [ -z "$subcommand" ]; then
3903c618 1694 __gitcomp "$subcommands"
88293c67
SP
1695 return
1696 fi
1697
3ff1320d 1698 case "$subcommand" in
f135e72d 1699 rename|rm|show|prune)
88293c67
SP
1700 __gitcomp "$(__git_remotes)"
1701 ;;
fb72759b
SP
1702 update)
1703 local i c='' IFS=$'\n'
1704 for i in $(git --git-dir="$(__gitdir)" config --list); do
1705 case "$i" in
1706 remotes.*)
1707 i="${i#remotes.}"
1708 c="$c ${i/=*/}"
1709 ;;
1710 esac
1711 done
1712 __gitcomp "$c"
1713 ;;
88293c67
SP
1714 *)
1715 COMPREPLY=()
1716 ;;
1717 esac
1718}
1719
67e78c3b
SP
1720_git_reset ()
1721{
d773c631
SG
1722 __git_has_doubledash && return
1723
67e78c3b 1724 local cur="${COMP_WORDS[COMP_CWORD]}"
b3391775
SP
1725 case "$cur" in
1726 --*)
e89e2ed7 1727 __gitcomp "--merge --mixed --hard --soft"
b3391775
SP
1728 return
1729 ;;
1730 esac
1731 __gitcomp "$(__git_refs)"
67e78c3b
SP
1732}
1733
a6c2be24
LM
1734_git_revert ()
1735{
1736 local cur="${COMP_WORDS[COMP_CWORD]}"
1737 case "$cur" in
1738 --*)
1739 __gitcomp "--edit --mainline --no-edit --no-commit --signoff"
1740 return
1741 ;;
1742 esac
c0783837 1743 __gitcomp "$(__git_refs)"
a6c2be24
LM
1744}
1745
08c701d4
LM
1746_git_rm ()
1747{
1748 __git_has_doubledash && return
1749
1750 local cur="${COMP_WORDS[COMP_CWORD]}"
1751 case "$cur" in
1752 --*)
1753 __gitcomp "--cached --dry-run --ignore-unmatch --quiet"
1754 return
1755 ;;
1756 esac
1757 COMPREPLY=()
1758}
1759
1fd6bec9
SP
1760_git_shortlog ()
1761{
d773c631
SG
1762 __git_has_doubledash && return
1763
1fd6bec9
SP
1764 local cur="${COMP_WORDS[COMP_CWORD]}"
1765 case "$cur" in
1766 --*)
1767 __gitcomp "
a393777e
TR
1768 $__git_log_common_options
1769 $__git_log_shortlog_options
1fd6bec9
SP
1770 --numbered --summary
1771 "
1772 return
1773 ;;
1774 esac
1775 __git_complete_revlist
1776}
1777
90131924
SP
1778_git_show ()
1779{
41d8cf7d
MH
1780 __git_has_doubledash && return
1781
90131924
SP
1782 local cur="${COMP_WORDS[COMP_CWORD]}"
1783 case "$cur" in
1784 --pretty=*)
3d279863 1785 __gitcomp "$__git_log_pretty_formats
b3391775 1786 " "" "${cur##--pretty=}"
90131924
SP
1787 return
1788 ;;
72de29c2
TL
1789 --format=*)
1790 __gitcomp "$__git_log_pretty_formats
1791 " "" "${cur##--format=}"
1792 return
1793 ;;
90131924 1794 --*)
72de29c2 1795 __gitcomp "--pretty= --format=
20bf7292
TR
1796 $__git_diff_common_options
1797 "
90131924
SP
1798 return
1799 ;;
1800 esac
1801 __git_complete_file
1802}
1803
2ca880fe
TR
1804_git_show_branch ()
1805{
1806 local cur="${COMP_WORDS[COMP_CWORD]}"
1807 case "$cur" in
1808 --*)
1809 __gitcomp "
1810 --all --remotes --topo-order --current --more=
1811 --list --independent --merge-base --no-name
1812 --sha1-name --topics --reflog
1813 "
1814 return
1815 ;;
1816 esac
1817 __git_complete_revlist
1818}
1819
7fd53fce
JH
1820_git_stash ()
1821{
95d43780 1822 local subcommands='save list show apply clear drop pop create branch'
7bedebca
SG
1823 local subcommand="$(__git_find_subcommand "$subcommands")"
1824 if [ -z "$subcommand" ]; then
3ff1320d 1825 __gitcomp "$subcommands"
7bedebca
SG
1826 else
1827 local cur="${COMP_WORDS[COMP_CWORD]}"
1828 case "$subcommand,$cur" in
1829 save,--*)
1830 __gitcomp "--keep-index"
1831 ;;
95d43780
LM
1832 apply,--*)
1833 __gitcomp "--index"
1834 ;;
5a7ebd4f 1835 show,--*|drop,--*|pop,--*|branch,--*)
95d43780
LM
1836 COMPREPLY=()
1837 ;;
1838 show,*|apply,*|drop,*|pop,*|branch,*)
1839 __gitcomp "$(git --git-dir="$(__gitdir)" stash list \
1840 | sed -n -e 's/:.*//p')"
1841 ;;
7bedebca
SG
1842 *)
1843 COMPREPLY=()
1844 ;;
1845 esac
3ff1320d 1846 fi
7fd53fce
JH
1847}
1848
be86f7a0
SP
1849_git_submodule ()
1850{
d773c631
SG
1851 __git_has_doubledash && return
1852
1b0f7978 1853 local subcommands="add status init update summary foreach sync"
3ff1320d 1854 if [ -z "$(__git_find_subcommand "$subcommands")" ]; then
be86f7a0
SP
1855 local cur="${COMP_WORDS[COMP_CWORD]}"
1856 case "$cur" in
1857 --*)
1858 __gitcomp "--quiet --cached"
1859 ;;
1860 *)
3ff1320d 1861 __gitcomp "$subcommands"
be86f7a0
SP
1862 ;;
1863 esac
1864 return
1865 fi
1866}
1867
47f6ee28
SG
1868_git_svn ()
1869{
1870 local subcommands="
1871 init fetch clone rebase dcommit log find-rev
1872 set-tree commit-diff info create-ignore propget
4a5856cb
SG
1873 proplist show-ignore show-externals branch tag blame
1874 migrate
47f6ee28
SG
1875 "
1876 local subcommand="$(__git_find_subcommand "$subcommands")"
1877 if [ -z "$subcommand" ]; then
1878 __gitcomp "$subcommands"
1879 else
1880 local remote_opts="--username= --config-dir= --no-auth-cache"
1881 local fc_opts="
1882 --follow-parent --authors-file= --repack=
1883 --no-metadata --use-svm-props --use-svnsync-props
1884 --log-window-size= --no-checkout --quiet
4a5856cb
SG
1885 --repack-flags --use-log-author --localtime
1886 --ignore-paths= $remote_opts
47f6ee28
SG
1887 "
1888 local init_opts="
1889 --template= --shared= --trunk= --tags=
1890 --branches= --stdlayout --minimize-url
1891 --no-metadata --use-svm-props --use-svnsync-props
4a5856cb
SG
1892 --rewrite-root= --prefix= --use-log-author
1893 --add-author-from $remote_opts
47f6ee28
SG
1894 "
1895 local cmt_opts="
1896 --edit --rmdir --find-copies-harder --copy-similarity=
1897 "
1898
1899 local cur="${COMP_WORDS[COMP_CWORD]}"
1900 case "$subcommand,$cur" in
1901 fetch,--*)
1902 __gitcomp "--revision= --fetch-all $fc_opts"
1903 ;;
1904 clone,--*)
1905 __gitcomp "--revision= $fc_opts $init_opts"
1906 ;;
1907 init,--*)
1908 __gitcomp "$init_opts"
1909 ;;
1910 dcommit,--*)
1911 __gitcomp "
1912 --merge --strategy= --verbose --dry-run
4a5856cb
SG
1913 --fetch-all --no-rebase --commit-url
1914 --revision $cmt_opts $fc_opts
47f6ee28
SG
1915 "
1916 ;;
1917 set-tree,--*)
1918 __gitcomp "--stdin $cmt_opts $fc_opts"
1919 ;;
1920 create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\
1921 show-externals,--*)
1922 __gitcomp "--revision="
1923 ;;
1924 log,--*)
1925 __gitcomp "
1926 --limit= --revision= --verbose --incremental
1927 --oneline --show-commit --non-recursive
4a5856cb 1928 --authors-file= --color
47f6ee28
SG
1929 "
1930 ;;
1931 rebase,--*)
1932 __gitcomp "
1933 --merge --verbose --strategy= --local
4a5856cb 1934 --fetch-all --dry-run $fc_opts
47f6ee28
SG
1935 "
1936 ;;
1937 commit-diff,--*)
1938 __gitcomp "--message= --file= --revision= $cmt_opts"
1939 ;;
1940 info,--*)
1941 __gitcomp "--url"
1942 ;;
4a5856cb
SG
1943 branch,--*)
1944 __gitcomp "--dry-run --message --tag"
1945 ;;
1946 tag,--*)
1947 __gitcomp "--dry-run --message"
1948 ;;
1949 blame,--*)
1950 __gitcomp "--git-format"
1951 ;;
1952 migrate,--*)
1953 __gitcomp "
1954 --config-dir= --ignore-paths= --minimize
1955 --no-auth-cache --username=
1956 "
1957 ;;
47f6ee28
SG
1958 *)
1959 COMPREPLY=()
1960 ;;
1961 esac
1962 fi
1963}
1964
88e21dc7
SP
1965_git_tag ()
1966{
1967 local i c=1 f=0
1968 while [ $c -lt $COMP_CWORD ]; do
1969 i="${COMP_WORDS[c]}"
1970 case "$i" in
1971 -d|-v)
1972 __gitcomp "$(__git_tags)"
1973 return
1974 ;;
1975 -f)
1976 f=1
1977 ;;
1978 esac
1979 c=$((++c))
1980 done
1981
1982 case "${COMP_WORDS[COMP_CWORD-1]}" in
1983 -m|-F)
1984 COMPREPLY=()
1985 ;;
8d8163f3 1986 -*|tag)
88e21dc7
SP
1987 if [ $f = 1 ]; then
1988 __gitcomp "$(__git_tags)"
1989 else
1990 COMPREPLY=()
1991 fi
1992 ;;
1993 *)
1994 __gitcomp "$(__git_refs)"
1995 ;;
1996 esac
1997}
1998
690d8824
JH
1999_git ()
2000{
873537fa
SP
2001 local i c=1 command __git_dir
2002
2003 while [ $c -lt $COMP_CWORD ]; do
2004 i="${COMP_WORDS[c]}"
2005 case "$i" in
2006 --git-dir=*) __git_dir="${i#--git-dir=}" ;;
2007 --bare) __git_dir="." ;;
1eb7e2f8
LM
2008 --version|-p|--paginate) ;;
2009 --help) command="help"; break ;;
873537fa
SP
2010 *) command="$i"; break ;;
2011 esac
2012 c=$((++c))
2013 done
2014
1d17b22e 2015 if [ -z "$command" ]; then
72e5e989 2016 case "${COMP_WORDS[COMP_CWORD]}" in
47e98eec 2017 --*) __gitcomp "
ce5a2c95 2018 --paginate
47e98eec
SP
2019 --no-pager
2020 --git-dir=
2021 --bare
2022 --version
2023 --exec-path
89a56bfb 2024 --html-path
ce5a2c95
TL
2025 --work-tree=
2026 --help
47e98eec
SP
2027 "
2028 ;;
1eb7e2f8 2029 *) __gitcomp "$(__git_porcelain_commands) $(__git_aliases)" ;;
72e5e989
SP
2030 esac
2031 return
873537fa 2032 fi
367dce2a 2033
873537fa
SP
2034 local expansion=$(__git_aliased_command "$command")
2035 [ "$expansion" ] && command="$expansion"
367dce2a 2036
873537fa 2037 case "$command" in
88329195 2038 am) _git_am ;;
8435b548 2039 add) _git_add ;;
88329195 2040 apply) _git_apply ;;
b3191ce2 2041 archive) _git_archive ;;
b2e69f62 2042 bisect) _git_bisect ;;
374a58c9 2043 bundle) _git_bundle ;;
873537fa 2044 branch) _git_branch ;;
873537fa 2045 checkout) _git_checkout ;;
d8a9fea5 2046 cherry) _git_cherry ;;
1273231e 2047 cherry-pick) _git_cherry_pick ;;
4181c7e8 2048 clean) _git_clean ;;
3eb11012 2049 clone) _git_clone ;;
4548e855 2050 commit) _git_commit ;;
e0d10e1c 2051 config) _git_config ;;
217926c0 2052 describe) _git_describe ;;
873537fa 2053 diff) _git_diff ;;
e2dc2de9 2054 difftool) _git_difftool ;;
873537fa 2055 fetch) _git_fetch ;;
f53352fb 2056 format-patch) _git_format_patch ;;
4bca8636 2057 fsck) _git_fsck ;;
b26c8748 2058 gc) _git_gc ;;
c72e0db1 2059 grep) _git_grep ;;
1eb7e2f8 2060 help) _git_help ;;
5dad868b 2061 init) _git_init ;;
873537fa 2062 log) _git_log ;;
b1bc1494 2063 ls-files) _git_ls_files ;;
873537fa
SP
2064 ls-remote) _git_ls_remote ;;
2065 ls-tree) _git_ls_tree ;;
4ad91321 2066 merge) _git_merge;;
b4c72162 2067 mergetool) _git_mergetool;;
873537fa 2068 merge-base) _git_merge_base ;;
1127c51c 2069 mv) _git_mv ;;
d33909bf 2070 name-rev) _git_name_rev ;;
873537fa
SP
2071 pull) _git_pull ;;
2072 push) _git_push ;;
61d926a3 2073 rebase) _git_rebase ;;
88293c67 2074 remote) _git_remote ;;
873537fa 2075 reset) _git_reset ;;
a6c2be24 2076 revert) _git_revert ;;
08c701d4 2077 rm) _git_rm ;;
25a1f374 2078 send-email) _git_send_email ;;
1fd6bec9 2079 shortlog) _git_shortlog ;;
90131924 2080 show) _git_show ;;
2ca880fe 2081 show-branch) _git_show_branch ;;
7fd53fce 2082 stash) _git_stash ;;
df398771 2083 stage) _git_add ;;
be86f7a0 2084 submodule) _git_submodule ;;
47f6ee28 2085 svn) _git_svn ;;
88e21dc7 2086 tag) _git_tag ;;
873537fa
SP
2087 whatchanged) _git_log ;;
2088 *) COMPREPLY=() ;;
2089 esac
690d8824
JH
2090}
2091
2092_gitk ()
2093{
d773c631
SG
2094 __git_has_doubledash && return
2095
690d8824 2096 local cur="${COMP_WORDS[COMP_CWORD]}"
fa26a401 2097 local g="$(__gitdir)"
07ba53f7 2098 local merge=""
ba7906f2 2099 if [ -f "$g/MERGE_HEAD" ]; then
07ba53f7
RQ
2100 merge="--merge"
2101 fi
b3391775
SP
2102 case "$cur" in
2103 --*)
a393777e
TR
2104 __gitcomp "
2105 $__git_log_common_options
2106 $__git_log_gitk_options
2107 $merge
2108 "
b3391775
SP
2109 return
2110 ;;
2111 esac
ec804891 2112 __git_complete_revlist
690d8824
JH
2113}
2114
50e126e1
TP
2115complete -o bashdefault -o default -o nospace -F _git git 2>/dev/null \
2116 || complete -o default -o nospace -F _git git
2117complete -o bashdefault -o default -o nospace -F _gitk gitk 2>/dev/null \
2118 || complete -o default -o nospace -F _gitk gitk
690d8824
JH
2119
2120# The following are necessary only for Cygwin, and only are needed
2121# when the user has tab-completed the executable name and consequently
2122# included the '.exe' suffix.
2123#
76c3eb51 2124if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
50e126e1
TP
2125complete -o bashdefault -o default -o nospace -F _git git.exe 2>/dev/null \
2126 || complete -o default -o nospace -F _git git.exe
76c3eb51 2127fi