]> git.ipfire.org Git - thirdparty/git.git/blame - contrib/completion/git-completion.bash
completion; remove unuseful comments
[thirdparty/git.git] / contrib / completion / git-completion.bash
CommitLineData
a42577d4 1#!bash
690d8824 2#
b5a49471 3# bash/zsh completion support for core Git.
690d8824 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
fea16b47 16# *) file paths within current working directory and index
c70680ce 17# *) common --long-options
690d8824
JH
18#
19# To use these routines:
20#
21# 1) Copy this file to somewhere (e.g. ~/.git-completion.sh).
b5a49471 22# 2) Add the following line to your .bashrc/.zshrc:
06f44c3c 23# source ~/.git-completion.sh
af31a456
FC
24# 3) Consider changing your PS1 to also show the current branch,
25# see git-prompt.sh for details.
690d8824 26
db8a9ff0
SP
27case "$COMP_WORDBREAKS" in
28*:*) : great ;;
29*) COMP_WORDBREAKS="$COMP_WORDBREAKS:"
30esac
31
a42577d4
TP
32# __gitdir accepts 0 or 1 arguments (i.e., location)
33# returns location of .git repo
873537fa
SP
34__gitdir ()
35{
ac3eb1c3
JH
36 # Note: this function is duplicated in git-prompt.sh
37 # When updating it, make sure you update the other one to match.
25a31f81 38 if [ -z "${1-}" ]; then
5c9cc64a 39 if [ -n "${__git_dir-}" ]; then
67ffa114 40 echo "$__git_dir"
b7be4366
SG
41 elif [ -n "${GIT_DIR-}" ]; then
42 test -d "${GIT_DIR-}" || return 1
43 echo "$GIT_DIR"
67ffa114
SP
44 elif [ -d .git ]; then
45 echo .git
46 else
47 git rev-parse --git-dir 2>/dev/null
48 fi
49 elif [ -d "$1/.git" ]; then
50 echo "$1/.git"
51 else
52 echo "$1"
53 fi
873537fa
SP
54}
55
dbda3b10
JN
56# The following function is based on code from:
57#
58# bash_completion - programmable completion functions for bash 3.2+
59#
60# Copyright © 2006-2008, Ian Macdonald <ian@caliban.org>
61# © 2009-2010, Bash Completion Maintainers
62# <bash-completion-devel@lists.alioth.debian.org>
63#
64# This program is free software; you can redistribute it and/or modify
65# it under the terms of the GNU General Public License as published by
66# the Free Software Foundation; either version 2, or (at your option)
67# any later version.
68#
69# This program is distributed in the hope that it will be useful,
70# but WITHOUT ANY WARRANTY; without even the implied warranty of
71# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
72# GNU General Public License for more details.
73#
74# You should have received a copy of the GNU General Public License
75# along with this program; if not, write to the Free Software Foundation,
76# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
77#
78# The latest version of this software can be obtained here:
79#
80# http://bash-completion.alioth.debian.org/
81#
82# RELEASE: 2.x
83
84# This function can be used to access a tokenized list of words
85# on the command line:
86#
87# __git_reassemble_comp_words_by_ref '=:'
88# if test "${words_[cword_-1]}" = -w
89# then
90# ...
91# fi
92#
93# The argument should be a collection of characters from the list of
94# word completion separators (COMP_WORDBREAKS) to treat as ordinary
95# characters.
96#
97# This is roughly equivalent to going back in time and setting
98# COMP_WORDBREAKS to exclude those characters. The intent is to
99# make option types like --date=<type> and <rev>:<path> easy to
100# recognize by treating each shell word as a single token.
101#
102# It is best not to set COMP_WORDBREAKS directly because the value is
103# shared with other completion scripts. By the time the completion
104# function gets called, COMP_WORDS has already been populated so local
105# changes to COMP_WORDBREAKS have no effect.
106#
107# Output: words_, cword_, cur_.
108
109__git_reassemble_comp_words_by_ref()
110{
111 local exclude i j first
112 # Which word separators to exclude?
113 exclude="${1//[^$COMP_WORDBREAKS]}"
114 cword_=$COMP_CWORD
115 if [ -z "$exclude" ]; then
116 words_=("${COMP_WORDS[@]}")
117 return
118 fi
119 # List of word completion separators has shrunk;
120 # re-assemble words to complete.
121 for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)); do
122 # Append each nonempty word consisting of just
123 # word separator characters to the current word.
124 first=t
125 while
126 [ $i -gt 0 ] &&
127 [ -n "${COMP_WORDS[$i]}" ] &&
128 # word consists of excluded word separators
129 [ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ]
130 do
131 # Attach to the previous token,
132 # unless the previous token is the command name.
133 if [ $j -ge 2 ] && [ -n "$first" ]; then
134 ((j--))
135 fi
136 first=
137 words_[$j]=${words_[j]}${COMP_WORDS[i]}
138 if [ $i = $COMP_CWORD ]; then
139 cword_=$j
140 fi
141 if (($i < ${#COMP_WORDS[@]} - 1)); then
142 ((i++))
143 else
144 # Done.
145 return
146 fi
147 done
148 words_[$j]=${words_[j]}${COMP_WORDS[i]}
149 if [ $i = $COMP_CWORD ]; then
150 cword_=$j
151 fi
152 done
153}
154
da48616f
PD
155if ! type _get_comp_words_by_ref >/dev/null 2>&1; then
156_get_comp_words_by_ref ()
157{
dbda3b10
JN
158 local exclude cur_ words_ cword_
159 if [ "$1" = "-n" ]; then
160 exclude=$2
161 shift 2
162 fi
163 __git_reassemble_comp_words_by_ref "$exclude"
164 cur_=${words_[cword_]}
da48616f
PD
165 while [ $# -gt 0 ]; do
166 case "$1" in
167 cur)
dbda3b10 168 cur=$cur_
da48616f
PD
169 ;;
170 prev)
dbda3b10 171 prev=${words_[$cword_-1]}
da48616f
PD
172 ;;
173 words)
dbda3b10 174 words=("${words_[@]}")
da48616f
PD
175 ;;
176 cword)
dbda3b10 177 cword=$cword_
da48616f
PD
178 ;;
179 esac
180 shift
181 done
182}
183fi
184
1ce23aad
FC
185__gitcompadd ()
186{
7d13e0a3
FC
187 local i=0
188 for x in $1; do
189 if [[ "$x" == "$3"* ]]; then
190 COMPREPLY[i++]="$2$x$4"
191 fi
192 done
1ce23aad
FC
193}
194
7d13e0a3
FC
195# Generates completion reply, appending a space to possible completion words,
196# if necessary.
f674bb80
SG
197# It accepts 1 to 4 arguments:
198# 1: List of possible completion words.
199# 2: A prefix to be added to each possible completion word (optional).
200# 3: Generate possible completion matches for this word (optional).
201# 4: A suffix to be appended to each possible completion word (optional).
72e5e989
SP
202__gitcomp ()
203{
583e4d57 204 local cur_="${3-$cur}"
9244d69b 205
9244d69b 206 case "$cur_" in
5447aac7 207 --*=)
5447aac7
SG
208 ;;
209 *)
b4cfbc96
FC
210 local c i=0 IFS=$' \t\n'
211 for c in $1; do
212 c="$c${4-}"
b4cfbc96 213 if [[ $c == "$cur_"* ]]; then
ddc996d7
FC
214 case $c in
215 --*=*|*.) ;;
216 *) c="$c " ;;
217 esac
b4cfbc96
FC
218 COMPREPLY[i++]="${2-}$c"
219 fi
220 done
5447aac7
SG
221 ;;
222 esac
72e5e989
SP
223}
224
7d13e0a3
FC
225# Generates completion reply from newline-separated possible completion words
226# by appending a space to all of them.
a31e6262
SG
227# It accepts 1 to 4 arguments:
228# 1: List of possible completion words, separated by a single newline.
229# 2: A prefix to be added to each possible completion word (optional).
230# 3: Generate possible completion matches for this word (optional).
231# 4: A suffix to be appended to each possible completion word instead of
232# the default space (optional). If specified but empty, nothing is
233# appended.
234__gitcomp_nl ()
235{
583e4d57 236 local IFS=$'\n'
1ce23aad 237 __gitcompadd "$1" "${2-}" "${3-$cur}" "${4- }"
a31e6262
SG
238}
239
fea16b47
MP
240# Generates completion reply with compgen from newline-separated possible
241# completion filenames.
242# It accepts 1 to 3 arguments:
243# 1: List of possible completion filenames, separated by a single newline.
244# 2: A directory prefix to be added to each possible completion filename
245# (optional).
246# 3: Generate possible completion matches for this word (optional).
247__gitcomp_file ()
248{
249 local IFS=$'\n'
250
251 # XXX does not work when the directory prefix contains a tilde,
252 # since tilde expansion is not applied.
253 # This means that COMPREPLY will be empty and Bash default
254 # completion will be used.
255 COMPREPLY=($(compgen -P "${2-}" -W "$1" -- "${3-$cur}"))
256
257 # Tell Bash that compspec generates filenames.
258 compopt -o filenames 2>/dev/null
259}
260
261__git_index_file_list_filter_compat ()
262{
263 local path
264
265 while read -r path; do
266 case "$path" in
267 ?*/*) echo "${path%%/*}/" ;;
268 *) echo "$path" ;;
269 esac
270 done
271}
272
273__git_index_file_list_filter_bash ()
274{
275 local path
276
277 while read -r path; do
278 case "$path" in
279 ?*/*)
280 # XXX if we append a slash to directory names when using
281 # `compopt -o filenames`, Bash will append another slash.
282 # This is pretty stupid, and this the reason why we have to
283 # define a compatible version for this function.
284 echo "${path%%/*}" ;;
285 *)
286 echo "$path" ;;
287 esac
288 done
289}
290
291# Process path list returned by "ls-files" and "diff-index --name-only"
292# commands, in order to list only file names relative to a specified
293# directory, and append a slash to directory names.
294__git_index_file_list_filter ()
295{
296 # Default to Bash >= 4.x
297 __git_index_file_list_filter_bash
298}
299
300# Execute git ls-files, returning paths relative to the directory
301# specified in the first argument, and using the options specified in
302# the second argument.
303__git_ls_files_helper ()
304{
35ba83cc
MM
305 (
306 test -n "${CDPATH+set}" && unset CDPATH
307 # NOTE: $2 is not quoted in order to support multiple options
308 cd "$1" && git ls-files --exclude-standard $2
309 ) 2>/dev/null
310}
fea16b47
MP
311
312
313# Execute git diff-index, returning paths relative to the directory
314# specified in the first argument, and using the tree object id
315# specified in the second argument.
316__git_diff_index_helper ()
317{
35ba83cc
MM
318 (
319 test -n "${CDPATH+set}" && unset CDPATH
320 cd "$1" && git diff-index --name-only --relative "$2"
321 ) 2>/dev/null
322}
fea16b47
MP
323
324# __git_index_files accepts 1 or 2 arguments:
325# 1: Options to pass to ls-files (required).
fea16b47
MP
326# 2: A directory path (optional).
327# If provided, only files within the specified directory are listed.
328# Sub directories are never recursed. Path must have a trailing
329# slash.
330__git_index_files ()
331{
332 local dir="$(__gitdir)" root="${2-.}"
333
334 if [ -d "$dir" ]; then
335 __git_ls_files_helper "$root" "$1" | __git_index_file_list_filter |
336 sort | uniq
337 fi
338}
339
340# __git_diff_index_files accepts 1 or 2 arguments:
341# 1) The id of a tree object.
342# 2) A directory path (optional).
343# If provided, only files within the specified directory are listed.
344# Sub directories are never recursed. Path must have a trailing
345# slash.
346__git_diff_index_files ()
347{
348 local dir="$(__gitdir)" root="${2-.}"
349
350 if [ -d "$dir" ]; then
351 __git_diff_index_helper "$root" "$1" | __git_index_file_list_filter |
352 sort | uniq
353 fi
354}
355
5de40f59
SP
356__git_heads ()
357{
6486ca6d 358 local dir="$(__gitdir)"
5de40f59 359 if [ -d "$dir" ]; then
05e8b3d6
SG
360 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
361 refs/heads
5de40f59
SP
362 return
363 fi
5de40f59
SP
364}
365
88e21dc7
SP
366__git_tags ()
367{
6486ca6d 368 local dir="$(__gitdir)"
88e21dc7 369 if [ -d "$dir" ]; then
05e8b3d6
SG
370 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
371 refs/tags
88e21dc7
SP
372 return
373 fi
88e21dc7
SP
374}
375
34a6bbb5
KB
376# __git_refs accepts 0, 1 (to pass to __gitdir), or 2 arguments
377# presence of 2nd argument means use the guess heuristic employed
378# by checkout for tracking branches
690d8824
JH
379__git_refs ()
380{
d8c0453e 381 local i hash dir="$(__gitdir "${1-}")" track="${2-}"
da4902a7 382 local format refs
873537fa 383 if [ -d "$dir" ]; then
608efb87
SG
384 case "$cur" in
385 refs|refs/*)
386 format="refname"
387 refs="${cur%/*}"
34a6bbb5 388 track=""
608efb87
SG
389 ;;
390 *)
d23e7570
IWC
391 for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do
392 if [ -e "$dir/$i" ]; then echo $i; fi
393 done
608efb87
SG
394 format="refname:short"
395 refs="refs/tags refs/heads refs/remotes"
396 ;;
397 esac
398 git --git-dir="$dir" for-each-ref --format="%($format)" \
399 $refs
34a6bbb5
KB
400 if [ -n "$track" ]; then
401 # employ the heuristic used by git checkout
402 # Try to find a remote branch that matches the completion word
403 # but only output if the branch name is unique
404 local ref entry
405 git --git-dir="$dir" for-each-ref --shell --format="ref=%(refname:short)" \
406 "refs/remotes/" | \
6f2dd720 407 while read -r entry; do
34a6bbb5
KB
408 eval "$entry"
409 ref="${ref#*/}"
410 if [[ "$ref" == "$cur"* ]]; then
411 echo "$ref"
412 fi
4db42b38 413 done | sort | uniq -u
34a6bbb5 414 fi
35e65ecc 415 return
690d8824 416 fi
fb772cca
SG
417 case "$cur" in
418 refs|refs/*)
419 git ls-remote "$dir" "$cur*" 2>/dev/null | \
6f2dd720 420 while read -r hash i; do
fb772cca
SG
421 case "$i" in
422 *^{}) ;;
423 *) echo "$i" ;;
424 esac
425 done
426 ;;
427 *)
428 git ls-remote "$dir" HEAD ORIG_HEAD 'refs/tags/*' 'refs/heads/*' 'refs/remotes/*' 2>/dev/null | \
6f2dd720 429 while read -r hash i; do
fb772cca
SG
430 case "$i" in
431 *^{}) ;;
432 refs/*) echo "${i#refs/*/}" ;;
433 *) echo "$i" ;;
434 esac
435 done
436 ;;
437 esac
690d8824
JH
438}
439
a42577d4 440# __git_refs2 requires 1 argument (to pass to __git_refs)
690d8824
JH
441__git_refs2 ()
442{
67ffa114
SP
443 local i
444 for i in $(__git_refs "$1"); do
445 echo "$i:$i"
690d8824
JH
446 done
447}
448
a42577d4 449# __git_refs_remotes requires 1 argument (to pass to ls-remote)
5de40f59
SP
450__git_refs_remotes ()
451{
48058f5d
SG
452 local i hash
453 git ls-remote "$1" 'refs/heads/*' 2>/dev/null | \
6f2dd720 454 while read -r hash i; do
48058f5d 455 echo "$i:refs/remotes/$1/${i#refs/heads/}"
5de40f59
SP
456 done
457}
458
690d8824
JH
459__git_remotes ()
460{
d79f81ad
FC
461 local i IFS=$'\n' d="$(__gitdir)"
462 test -d "$d/remotes" && ls -1 "$d/remotes"
518ef8f0
TZ
463 for i in $(git --git-dir="$d" config --get-regexp 'remote\..*\.url' 2>/dev/null); do
464 i="${i#remote.}"
465 echo "${i/.url*/}"
56fc25f2 466 done
690d8824
JH
467}
468
eaa4e6ee 469__git_list_merge_strategies ()
4ad91321 470{
25b3d4d6
JH
471 git merge -s help 2>&1 |
472 sed -n -e '/[Aa]vailable strategies are: /,/^$/{
473 s/\.$//
474 s/.*://
475 s/^[ ]*//
476 s/[ ]*$//
4ad91321 477 p
25b3d4d6 478 }'
4ad91321 479}
eaa4e6ee
JN
480
481__git_merge_strategies=
482# 'git merge -s help' (and thus detection of the merge strategy
483# list) fails, unfortunately, if run outside of any git working
484# tree. __git_merge_strategies is set to the empty string in
485# that case, and the detection will be repeated the next time it
486# is needed.
487__git_compute_merge_strategies ()
488{
cf0ff02a
FC
489 test -n "$__git_merge_strategies" ||
490 __git_merge_strategies=$(__git_list_merge_strategies)
eaa4e6ee 491}
4ad91321 492
1d66ec58 493__git_complete_revlist_file ()
690d8824 494{
da4902a7 495 local pfx ls ref cur_="$cur"
9244d69b 496 case "$cur_" in
1d66ec58
SG
497 *..?*:*)
498 return
499 ;;
690d8824 500 ?*:*)
9244d69b
SG
501 ref="${cur_%%:*}"
502 cur_="${cur_#*:}"
503 case "$cur_" in
690d8824 504 ?*/*)
9244d69b
SG
505 pfx="${cur_%/*}"
506 cur_="${cur_##*/}"
690d8824
JH
507 ls="$ref:$pfx"
508 pfx="$pfx/"
509 ;;
510 *)
511 ls="$ref"
512 ;;
80152b09 513 esac
db8a9ff0
SP
514
515 case "$COMP_WORDBREAKS" in
516 *:*) : great ;;
517 *) pfx="$ref:$pfx" ;;
518 esac
519
ca87dd62 520 __gitcomp_nl "$(git --git-dir="$(__gitdir)" ls-tree "$ls" 2>/dev/null \
778306e4
SP
521 | sed '/^100... blob /{
522 s,^.* ,,
523 s,$, ,
524 }
525 /^120000 blob /{
526 s,^.* ,,
527 s,$, ,
528 }
690d8824
JH
529 /^040000 tree /{
530 s,^.* ,,
531 s,$,/,
532 }
533 s/^.* //')" \
41e6229d 534 "$pfx" "$cur_" ""
690d8824 535 ;;
f53352fb 536 *...*)
9244d69b
SG
537 pfx="${cur_%...*}..."
538 cur_="${cur_#*...}"
a31e6262 539 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
f53352fb
SP
540 ;;
541 *..*)
9244d69b
SG
542 pfx="${cur_%..*}.."
543 cur_="${cur_#*..}"
a31e6262 544 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
b3391775 545 ;;
f53352fb 546 *)
a31e6262 547 __gitcomp_nl "$(__git_refs)"
f53352fb
SP
548 ;;
549 esac
550}
551
1d66ec58 552
fea16b47
MP
553# __git_complete_index_file requires 1 argument: the options to pass to
554# ls-file
555__git_complete_index_file ()
556{
557 local pfx cur_="$cur"
558
559 case "$cur_" in
560 ?*/*)
561 pfx="${cur_%/*}"
562 cur_="${cur_##*/}"
563 pfx="${pfx}/"
564
565 __gitcomp_file "$(__git_index_files "$1" "$pfx")" "$pfx" "$cur_"
566 ;;
567 *)
568 __gitcomp_file "$(__git_index_files "$1")" "" "$cur_"
569 ;;
570 esac
571}
572
573# __git_complete_diff_index_file requires 1 argument: the id of a tree
574# object
575__git_complete_diff_index_file ()
576{
577 local pfx cur_="$cur"
578
579 case "$cur_" in
580 ?*/*)
581 pfx="${cur_%/*}"
582 cur_="${cur_##*/}"
583 pfx="${pfx}/"
584
585 __gitcomp_file "$(__git_diff_index_files "$1" "$pfx")" "$pfx" "$cur_"
586 ;;
587 *)
588 __gitcomp_file "$(__git_diff_index_files "$1")" "" "$cur_"
589 ;;
590 esac
591}
592
1d66ec58
SG
593__git_complete_file ()
594{
595 __git_complete_revlist_file
596}
597
598__git_complete_revlist ()
599{
600 __git_complete_revlist_file
601}
602
52d5c3b5
JS
603__git_complete_remote_or_refspec ()
604{
9244d69b 605 local cur_="$cur" cmd="${words[1]}"
0a4e1472 606 local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0
f1c6ffe6 607 if [ "$cmd" = "remote" ]; then
6e8c755f 608 ((c++))
f1c6ffe6 609 fi
da48616f
PD
610 while [ $c -lt $cword ]; do
611 i="${words[c]}"
52d5c3b5 612 case "$i" in
e25e2b42
BG
613 --mirror) [ "$cmd" = "push" ] && no_complete_refspec=1 ;;
614 --all)
615 case "$cmd" in
616 push) no_complete_refspec=1 ;;
617 fetch)
e25e2b42
BG
618 return
619 ;;
620 *) ;;
621 esac
622 ;;
52d5c3b5
JS
623 -*) ;;
624 *) remote="$i"; break ;;
625 esac
6e8c755f 626 ((c++))
52d5c3b5
JS
627 done
628 if [ -z "$remote" ]; then
a31e6262 629 __gitcomp_nl "$(__git_remotes)"
52d5c3b5
JS
630 return
631 fi
0a4e1472 632 if [ $no_complete_refspec = 1 ]; then
0a4e1472
JS
633 return
634 fi
52d5c3b5 635 [ "$remote" = "." ] && remote=
9244d69b 636 case "$cur_" in
52d5c3b5
JS
637 *:*)
638 case "$COMP_WORDBREAKS" in
639 *:*) : great ;;
9244d69b 640 *) pfx="${cur_%%:*}:" ;;
52d5c3b5 641 esac
9244d69b 642 cur_="${cur_#*:}"
52d5c3b5
JS
643 lhs=0
644 ;;
645 +*)
646 pfx="+"
9244d69b 647 cur_="${cur_#+}"
52d5c3b5
JS
648 ;;
649 esac
650 case "$cmd" in
651 fetch)
652 if [ $lhs = 1 ]; then
a31e6262 653 __gitcomp_nl "$(__git_refs2 "$remote")" "$pfx" "$cur_"
52d5c3b5 654 else
a31e6262 655 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
52d5c3b5
JS
656 fi
657 ;;
f1c6ffe6 658 pull|remote)
52d5c3b5 659 if [ $lhs = 1 ]; then
a31e6262 660 __gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_"
52d5c3b5 661 else
a31e6262 662 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
52d5c3b5
JS
663 fi
664 ;;
665 push)
666 if [ $lhs = 1 ]; then
a31e6262 667 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
52d5c3b5 668 else
a31e6262 669 __gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_"
52d5c3b5
JS
670 fi
671 ;;
672 esac
673}
674
3c7b480a
JS
675__git_complete_strategy ()
676{
eaa4e6ee 677 __git_compute_merge_strategies
da48616f 678 case "$prev" in
3c7b480a 679 -s|--strategy)
eaa4e6ee 680 __gitcomp "$__git_merge_strategies"
3c7b480a
JS
681 return 0
682 esac
3c7b480a
JS
683 case "$cur" in
684 --strategy=*)
eaa4e6ee 685 __gitcomp "$__git_merge_strategies" "" "${cur##--strategy=}"
3c7b480a
JS
686 return 0
687 ;;
688 esac
689 return 1
690}
691
50478223
JH
692__git_commands () {
693 if test -n "${GIT_TESTING_COMMAND_COMPLETION:-}"
694 then
695 printf "%s" "${GIT_TESTING_COMMAND_COMPLETION}"
696 else
697 git help -a|egrep '^ [a-zA-Z0-9]'
698 fi
699}
700
eaa4e6ee 701__git_list_all_commands ()
f2bb9f88
SP
702{
703 local i IFS=" "$'\n'
50478223 704 for i in $(__git_commands)
1eb7e2f8
LM
705 do
706 case $i in
707 *--*) : helper pattern;;
708 *) echo $i;;
709 esac
710 done
711}
1eb7e2f8 712
eaa4e6ee
JN
713__git_all_commands=
714__git_compute_all_commands ()
715{
cf0ff02a
FC
716 test -n "$__git_all_commands" ||
717 __git_all_commands=$(__git_list_all_commands)
eaa4e6ee
JN
718}
719
720__git_list_porcelain_commands ()
1eb7e2f8 721{
1eb7e2f8 722 local i IFS=" "$'\n'
eaa4e6ee 723 __git_compute_all_commands
585b96bd 724 for i in $__git_all_commands
f2bb9f88
SP
725 do
726 case $i in
718a087a 727 *--*) : helper pattern;;
a925c6f1
SP
728 applymbox) : ask gittus;;
729 applypatch) : ask gittus;;
730 archimport) : import;;
2e3a430a 731 cat-file) : plumbing;;
56d99c67 732 check-attr) : plumbing;;
368aa529 733 check-ignore) : plumbing;;
f2bb9f88 734 check-ref-format) : plumbing;;
ff2549dc 735 checkout-index) : plumbing;;
f2bb9f88 736 commit-tree) : plumbing;;
ff2549dc 737 count-objects) : infrequent;;
1dad5c14
SG
738 credential-cache) : credentials helper;;
739 credential-store) : credentials helper;;
a925c6f1
SP
740 cvsexportcommit) : export;;
741 cvsimport) : import;;
f2bb9f88
SP
742 cvsserver) : daemon;;
743 daemon) : daemon;;
5cfb4fe5
SP
744 diff-files) : plumbing;;
745 diff-index) : plumbing;;
746 diff-tree) : plumbing;;
c6ec3b13 747 fast-import) : import;;
ff2549dc 748 fast-export) : export;;
a925c6f1 749 fsck-objects) : plumbing;;
f2bb9f88 750 fetch-pack) : plumbing;;
a925c6f1 751 fmt-merge-msg) : plumbing;;
56d99c67 752 for-each-ref) : plumbing;;
f2bb9f88
SP
753 hash-object) : plumbing;;
754 http-*) : transport;;
755 index-pack) : plumbing;;
a925c6f1 756 init-db) : deprecated;;
f2bb9f88 757 local-fetch) : plumbing;;
ff2549dc
PB
758 lost-found) : infrequent;;
759 ls-files) : plumbing;;
760 ls-remote) : plumbing;;
761 ls-tree) : plumbing;;
f2bb9f88
SP
762 mailinfo) : plumbing;;
763 mailsplit) : plumbing;;
764 merge-*) : plumbing;;
765 mktree) : plumbing;;
766 mktag) : plumbing;;
767 pack-objects) : plumbing;;
768 pack-redundant) : plumbing;;
769 pack-refs) : plumbing;;
770 parse-remote) : plumbing;;
771 patch-id) : plumbing;;
772 peek-remote) : plumbing;;
a925c6f1
SP
773 prune) : plumbing;;
774 prune-packed) : plumbing;;
775 quiltimport) : import;;
f2bb9f88
SP
776 read-tree) : plumbing;;
777 receive-pack) : plumbing;;
63d04a78 778 remote-*) : transport;;
5c66d0d4 779 repo-config) : deprecated;;
f2bb9f88
SP
780 rerere) : plumbing;;
781 rev-list) : plumbing;;
782 rev-parse) : plumbing;;
783 runstatus) : plumbing;;
784 sh-setup) : internal;;
785 shell) : daemon;;
ff2549dc 786 show-ref) : plumbing;;
f2bb9f88
SP
787 send-pack) : plumbing;;
788 show-index) : plumbing;;
789 ssh-*) : transport;;
790 stripspace) : plumbing;;
791 symbolic-ref) : plumbing;;
a925c6f1 792 tar-tree) : deprecated;;
f2bb9f88
SP
793 unpack-file) : plumbing;;
794 unpack-objects) : plumbing;;
a925c6f1 795 update-index) : plumbing;;
f2bb9f88
SP
796 update-ref) : plumbing;;
797 update-server-info) : daemon;;
798 upload-archive) : plumbing;;
799 upload-pack) : plumbing;;
800 write-tree) : plumbing;;
ff2549dc
PB
801 var) : infrequent;;
802 verify-pack) : infrequent;;
a925c6f1 803 verify-tag) : plumbing;;
f2bb9f88
SP
804 *) echo $i;;
805 esac
806 done
807}
eaa4e6ee
JN
808
809__git_porcelain_commands=
810__git_compute_porcelain_commands ()
811{
812 __git_compute_all_commands
cf0ff02a
FC
813 test -n "$__git_porcelain_commands" ||
814 __git_porcelain_commands=$(__git_list_porcelain_commands)
eaa4e6ee 815}
f2bb9f88 816
c3898111
SG
817__git_pretty_aliases ()
818{
819 local i IFS=$'\n'
820 for i in $(git --git-dir="$(__gitdir)" config --get-regexp "pretty\..*" 2>/dev/null); do
821 case "$i" in
822 pretty.*)
823 i="${i#pretty.}"
824 echo "${i/ */}"
825 ;;
826 esac
827 done
828}
829
367dce2a
DS
830__git_aliases ()
831{
56fc25f2 832 local i IFS=$'\n'
518ef8f0 833 for i in $(git --git-dir="$(__gitdir)" config --get-regexp "alias\..*" 2>/dev/null); do
e0d78059
SB
834 case "$i" in
835 alias.*)
836 i="${i#alias.}"
837 echo "${i/ */}"
838 ;;
839 esac
56fc25f2 840 done
367dce2a
DS
841}
842
a42577d4 843# __git_aliased_command requires 1 argument
367dce2a
DS
844__git_aliased_command ()
845{
873537fa 846 local word cmdline=$(git --git-dir="$(__gitdir)" \
e0d10e1c 847 config --get "alias.$1")
367dce2a 848 for word in $cmdline; do
c63437cb 849 case "$word" in
66729509
SG
850 \!gitk|gitk)
851 echo "gitk"
367dce2a 852 return
66729509 853 ;;
c63437cb
SG
854 \!*) : shell command alias ;;
855 -*) : option ;;
856 *=*) : setting env ;;
857 git) : git itself ;;
858 *)
859 echo "$word"
367dce2a 860 return
c63437cb 861 esac
367dce2a
DS
862 done
863}
864
918c03c2
SG
865# __git_find_on_cmdline requires 1 argument
866__git_find_on_cmdline ()
3ff1320d 867{
da4902a7 868 local word subcommand c=1
da48616f
PD
869 while [ $c -lt $cword ]; do
870 word="${words[c]}"
3ff1320d
SG
871 for subcommand in $1; do
872 if [ "$subcommand" = "$word" ]; then
873 echo "$subcommand"
874 return
875 fi
876 done
6e8c755f 877 ((c++))
3ff1320d
SG
878 done
879}
880
d773c631
SG
881__git_has_doubledash ()
882{
da4902a7 883 local c=1
da48616f
PD
884 while [ $c -lt $cword ]; do
885 if [ "--" = "${words[c]}" ]; then
d773c631
SG
886 return 0
887 fi
6e8c755f 888 ((c++))
d773c631
SG
889 done
890 return 1
891}
892
fea16b47
MP
893# Try to count non option arguments passed on the command line for the
894# specified git command.
895# When options are used, it is necessary to use the special -- option to
896# tell the implementation were non option arguments begin.
897# XXX this can not be improved, since options can appear everywhere, as
898# an example:
899# git mv x -n y
900#
901# __git_count_arguments requires 1 argument: the git command executed.
902__git_count_arguments ()
903{
904 local word i c=0
905
906 # Skip "git" (first argument)
907 for ((i=1; i < ${#words[@]}; i++)); do
908 word="${words[i]}"
909
910 case "$word" in
911 --)
912 # Good; we can assume that the following are only non
913 # option arguments.
914 ((c = 0))
915 ;;
916 "$1")
917 # Skip the specified git command and discard git
918 # main options
919 ((c = 0))
920 ;;
921 ?*)
922 ((c++))
923 ;;
924 esac
925 done
926
927 printf "%d" $c
928}
929
7950659d 930__git_whitespacelist="nowarn warn error error-all fix"
88329195
SP
931
932_git_am ()
933{
da4902a7 934 local dir="$(__gitdir)"
51ef1daa 935 if [ -d "$dir"/rebase-apply ]; then
85f6b439 936 __gitcomp "--skip --continue --resolved --abort"
88329195
SP
937 return
938 fi
939 case "$cur" in
940 --whitespace=*)
b3391775 941 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
88329195
SP
942 return
943 ;;
944 --*)
b3391775 945 __gitcomp "
43acdf24 946 --3way --committer-date-is-author-date --ignore-date
86c91f91 947 --ignore-whitespace --ignore-space-change
43acdf24 948 --interactive --keep --no-utf8 --signoff --utf8
af4e9e8c 949 --whitespace= --scissors
b3391775 950 "
88329195
SP
951 return
952 esac
88329195
SP
953}
954
955_git_apply ()
956{
88329195
SP
957 case "$cur" in
958 --whitespace=*)
b3391775 959 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
88329195
SP
960 return
961 ;;
962 --*)
b3391775 963 __gitcomp "
88329195
SP
964 --stat --numstat --summary --check --index
965 --cached --index-info --reverse --reject --unidiff-zero
966 --apply --no-add --exclude=
86c91f91 967 --ignore-whitespace --ignore-space-change
88329195 968 --whitespace= --inaccurate-eof --verbose
b3391775 969 "
88329195
SP
970 return
971 esac
88329195
SP
972}
973
8435b548
SP
974_git_add ()
975{
8435b548
SP
976 case "$cur" in
977 --*)
1d284cba
SG
978 __gitcomp "
979 --interactive --refresh --patch --update --dry-run
c9a114b5 980 --ignore-errors --intent-to-add
1d284cba 981 "
8435b548
SP
982 return
983 esac
fea16b47
MP
984
985 # XXX should we check for --update and --all options ?
986 __git_complete_index_file "--others --modified"
8435b548
SP
987}
988
b3191ce2
LM
989_git_archive ()
990{
b3191ce2
LM
991 case "$cur" in
992 --format=*)
993 __gitcomp "$(git archive --list)" "" "${cur##--format=}"
994 return
995 ;;
996 --remote=*)
a31e6262 997 __gitcomp_nl "$(__git_remotes)" "" "${cur##--remote=}"
b3191ce2
LM
998 return
999 ;;
1000 --*)
1001 __gitcomp "
1002 --format= --list --verbose
1003 --prefix= --remote= --exec=
1004 "
1005 return
1006 ;;
1007 esac
1008 __git_complete_file
1009}
1010
b2e69f62
SP
1011_git_bisect ()
1012{
d773c631
SG
1013 __git_has_doubledash && return
1014
bf11d461 1015 local subcommands="start bad good skip reset visualize replay log run"
918c03c2 1016 local subcommand="$(__git_find_on_cmdline "$subcommands")"
3ff1320d 1017 if [ -z "$subcommand" ]; then
128191f5
SG
1018 if [ -f "$(__gitdir)"/BISECT_START ]; then
1019 __gitcomp "$subcommands"
1020 else
1021 __gitcomp "replay start"
1022 fi
b2e69f62
SP
1023 return
1024 fi
1025
3ff1320d 1026 case "$subcommand" in
8205ff8e 1027 bad|good|reset|skip|start)
a31e6262 1028 __gitcomp_nl "$(__git_refs)"
b2e69f62
SP
1029 ;;
1030 *)
b2e69f62
SP
1031 ;;
1032 esac
1033}
1034
690d8824
JH
1035_git_branch ()
1036{
da4902a7 1037 local i c=1 only_local_ref="n" has_r="n"
b9217642 1038
da48616f
PD
1039 while [ $c -lt $cword ]; do
1040 i="${words[c]}"
b9217642
SG
1041 case "$i" in
1042 -d|-m) only_local_ref="y" ;;
1043 -r) has_r="y" ;;
1044 esac
6e8c755f 1045 ((c++))
b9217642
SG
1046 done
1047
da48616f 1048 case "$cur" in
ca45d0fa
MG
1049 --set-upstream-to=*)
1050 __gitcomp "$(__git_refs)" "" "${cur##--set-upstream-to=}"
1051 ;;
3b376b0c
SG
1052 --*)
1053 __gitcomp "
1054 --color --no-color --verbose --abbrev= --no-abbrev
50e61025 1055 --track --no-track --contains --merged --no-merged
04308e9d
CMN
1056 --set-upstream-to= --edit-description --list
1057 --unset-upstream
3b376b0c
SG
1058 "
1059 ;;
b9217642
SG
1060 *)
1061 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
a31e6262 1062 __gitcomp_nl "$(__git_heads)"
b9217642 1063 else
a31e6262 1064 __gitcomp_nl "$(__git_refs)"
b9217642
SG
1065 fi
1066 ;;
3b376b0c 1067 esac
690d8824
JH
1068}
1069
374a58c9
ML
1070_git_bundle ()
1071{
da48616f
PD
1072 local cmd="${words[2]}"
1073 case "$cword" in
8d8163f3 1074 2)
374a58c9
ML
1075 __gitcomp "create list-heads verify unbundle"
1076 ;;
8d8163f3 1077 3)
374a58c9
ML
1078 # looking for a file
1079 ;;
1080 *)
1081 case "$cmd" in
1082 create)
1083 __git_complete_revlist
1084 ;;
1085 esac
1086 ;;
1087 esac
1088}
1089
690d8824
JH
1090_git_checkout ()
1091{
c84bb14c
SG
1092 __git_has_doubledash && return
1093
e648f8b6
SG
1094 case "$cur" in
1095 --conflict=*)
1096 __gitcomp "diff3 merge" "" "${cur##--conflict=}"
1097 ;;
1098 --*)
1099 __gitcomp "
1100 --quiet --ours --theirs --track --no-track --merge
86e8e7a5 1101 --conflict= --orphan --patch
e648f8b6
SG
1102 "
1103 ;;
1104 *)
34a6bbb5
KB
1105 # check if --track, --no-track, or --no-guess was specified
1106 # if so, disable DWIM mode
1107 local flags="--track --no-track --no-guess" track=1
1108 if [ -n "$(__git_find_on_cmdline "$flags")" ]; then
1109 track=''
1110 fi
a31e6262 1111 __gitcomp_nl "$(__git_refs '' $track)"
e648f8b6
SG
1112 ;;
1113 esac
690d8824
JH
1114}
1115
d8a9fea5
SP
1116_git_cherry ()
1117{
1118 __gitcomp "$(__git_refs)"
1119}
1120
1273231e
SP
1121_git_cherry_pick ()
1122{
7655fa7f
FC
1123 local dir="$(__gitdir)"
1124 if [ -f "$dir"/CHERRY_PICK_HEAD ]; then
1125 __gitcomp "--continue --quit --abort"
1126 return
1127 fi
1273231e
SP
1128 case "$cur" in
1129 --*)
7655fa7f 1130 __gitcomp "--edit --no-commit --signoff --strategy= --mainline"
1273231e
SP
1131 ;;
1132 *)
a31e6262 1133 __gitcomp_nl "$(__git_refs)"
1273231e
SP
1134 ;;
1135 esac
1136}
1137
4181c7e8
LM
1138_git_clean ()
1139{
4181c7e8
LM
1140 case "$cur" in
1141 --*)
1142 __gitcomp "--dry-run --quiet"
1143 return
1144 ;;
1145 esac
fea16b47
MP
1146
1147 # XXX should we check for -x option ?
1148 __git_complete_index_file "--others"
4181c7e8
LM
1149}
1150
3eb11012
LM
1151_git_clone ()
1152{
3eb11012
LM
1153 case "$cur" in
1154 --*)
1155 __gitcomp "
1156 --local
1157 --no-hardlinks
1158 --shared
1159 --reference
1160 --quiet
1161 --no-checkout
1162 --bare
1163 --mirror
1164 --origin
1165 --upload-pack
1166 --template=
1167 --depth
4047fecf
RT
1168 --single-branch
1169 --branch
3eb11012
LM
1170 "
1171 return
1172 ;;
1173 esac
3eb11012
LM
1174}
1175
4548e855
SP
1176_git_commit ()
1177{
fea16b47
MP
1178 case "$prev" in
1179 -c|-C)
1180 __gitcomp_nl "$(__git_refs)" "" "${cur}"
1181 return
1182 ;;
1183 esac
d773c631 1184
4548e855 1185 case "$cur" in
9a424b27
SG
1186 --cleanup=*)
1187 __gitcomp "default strip verbatim whitespace
1188 " "" "${cur##--cleanup=}"
1189 return
1190 ;;
77653abd
TM
1191 --reuse-message=*|--reedit-message=*|\
1192 --fixup=*|--squash=*)
a31e6262 1193 __gitcomp_nl "$(__git_refs)" "" "${cur#*=}"
9a424b27
SG
1194 return
1195 ;;
1196 --untracked-files=*)
1197 __gitcomp "all no normal" "" "${cur##--untracked-files=}"
1198 return
1199 ;;
4548e855 1200 --*)
b3391775 1201 __gitcomp "
4548e855 1202 --all --author= --signoff --verify --no-verify
7dd9ab0c
YB
1203 --edit --no-edit
1204 --amend --include --only --interactive
9a424b27
SG
1205 --dry-run --reuse-message= --reedit-message=
1206 --reset-author --file= --message= --template=
1207 --cleanup= --untracked-files --untracked-files=
77653abd 1208 --verbose --quiet --fixup= --squash=
b3391775 1209 "
4548e855
SP
1210 return
1211 esac
fea16b47
MP
1212
1213 if git rev-parse --verify --quiet HEAD >/dev/null; then
1214 __git_complete_diff_index_file "HEAD"
1215 else
1216 # This is the first commit
1217 __git_complete_index_file "--cached"
1218 fi
4548e855
SP
1219}
1220
217926c0
SP
1221_git_describe ()
1222{
cbb504c9
TR
1223 case "$cur" in
1224 --*)
1225 __gitcomp "
1226 --all --tags --contains --abbrev= --candidates=
1227 --exact-match --debug --long --match --always
1228 "
1229 return
1230 esac
a31e6262 1231 __gitcomp_nl "$(__git_refs)"
217926c0
SP
1232}
1233
07924d4d
MP
1234__git_diff_algorithms="myers minimal patience histogram"
1235
20bf7292 1236__git_diff_common_options="--stat --numstat --shortstat --summary
b3a4f858
JS
1237 --patch-with-stat --name-only --name-status --color
1238 --no-color --color-words --no-renames --check
f135aacb 1239 --full-index --binary --abbrev --diff-filter=
47d5a8fa 1240 --find-copies-harder
b3a4f858
JS
1241 --text --ignore-space-at-eol --ignore-space-change
1242 --ignore-all-space --exit-code --quiet --ext-diff
aba201c6
PO
1243 --no-ext-diff
1244 --no-prefix --src-prefix= --dst-prefix=
6d0e674a 1245 --inter-hunk-context=
216120ab 1246 --patience --histogram --minimal
20bf7292 1247 --raw
8fd2cfa7
SB
1248 --dirstat --dirstat= --dirstat-by-file
1249 --dirstat-by-file= --cumulative
07924d4d 1250 --diff-algorithm=
20bf7292
TR
1251"
1252
1253_git_diff ()
1254{
1255 __git_has_doubledash && return
1256
20bf7292 1257 case "$cur" in
07924d4d
MP
1258 --diff-algorithm=*)
1259 __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
1260 return
1261 ;;
20bf7292 1262 --*)
ebd15bf0 1263 __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
861514d3 1264 --base --ours --theirs --no-index
20bf7292 1265 $__git_diff_common_options
aba201c6 1266 "
b3a4f858
JS
1267 return
1268 ;;
1269 esac
1d66ec58 1270 __git_complete_revlist_file
690d8824
JH
1271}
1272
e2dc2de9 1273__git_mergetools_common="diffuse ecmerge emerge kdiff3 meld opendiff
755e8b3f 1274 tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc3 codecompare
e2dc2de9
DA
1275"
1276
1277_git_difftool ()
1278{
f7ad96cf
MH
1279 __git_has_doubledash && return
1280
e2dc2de9
DA
1281 case "$cur" in
1282 --tool=*)
1283 __gitcomp "$__git_mergetools_common kompare" "" "${cur##--tool=}"
1284 return
1285 ;;
1286 --*)
f7ad96cf
MH
1287 __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
1288 --base --ours --theirs
1289 --no-renames --diff-filter= --find-copies-harder
1290 --relative --ignore-submodules
1291 --tool="
e2dc2de9
DA
1292 return
1293 ;;
1294 esac
f7ad96cf 1295 __git_complete_file
e2dc2de9
DA
1296}
1297
0a4e1472
JS
1298__git_fetch_options="
1299 --quiet --verbose --append --upload-pack --force --keep --depth=
e25e2b42 1300 --tags --no-tags --all --prune --dry-run
0a4e1472
JS
1301"
1302
690d8824
JH
1303_git_fetch ()
1304{
0a4e1472
JS
1305 case "$cur" in
1306 --*)
1307 __gitcomp "$__git_fetch_options"
1308 return
1309 ;;
1310 esac
52d5c3b5 1311 __git_complete_remote_or_refspec
690d8824
JH
1312}
1313
2f65494d
FC
1314__git_format_patch_options="
1315 --stdout --attach --no-attach --thread --thread= --output-directory
1316 --numbered --start-number --numbered-files --keep-subject --signoff
1317 --signature --no-signature --in-reply-to= --cc= --full-index --binary
1318 --not --all --cover-letter --no-prefix --src-prefix= --dst-prefix=
1319 --inline --suffix= --ignore-if-in-upstream --subject-prefix=
1320"
1321
f53352fb
SP
1322_git_format_patch ()
1323{
f53352fb 1324 case "$cur" in
e1d37937
SB
1325 --thread=*)
1326 __gitcomp "
1327 deep shallow
1328 " "" "${cur##--thread=}"
1329 return
1330 ;;
f53352fb 1331 --*)
2f65494d 1332 __gitcomp "$__git_format_patch_options"
f53352fb
SP
1333 return
1334 ;;
1335 esac
1336 __git_complete_revlist
1337}
1338
4bca8636
AJ
1339_git_fsck ()
1340{
4bca8636
AJ
1341 case "$cur" in
1342 --*)
1343 __gitcomp "
1344 --tags --root --unreachable --cache --no-reflogs --full
1345 --strict --verbose --lost-found
1346 "
1347 return
1348 ;;
1349 esac
4bca8636
AJ
1350}
1351
b26c8748
SP
1352_git_gc ()
1353{
b26c8748
SP
1354 case "$cur" in
1355 --*)
47e98eec 1356 __gitcomp "--prune --aggressive"
b26c8748
SP
1357 return
1358 ;;
1359 esac
b26c8748
SP
1360}
1361
66729509
SG
1362_git_gitk ()
1363{
1364 _gitk
1365}
1366
29eec71f
JK
1367__git_match_ctag() {
1368 awk "/^${1////\\/}/ { print \$1 }" "$2"
1369}
1370
c72e0db1
LM
1371_git_grep ()
1372{
1373 __git_has_doubledash && return
1374
c72e0db1
LM
1375 case "$cur" in
1376 --*)
1377 __gitcomp "
1378 --cached
1379 --text --ignore-case --word-regexp --invert-match
5a69eaf5 1380 --full-name --line-number
c72e0db1 1381 --extended-regexp --basic-regexp --fixed-strings
63e7e9d8 1382 --perl-regexp
c72e0db1
LM
1383 --files-with-matches --name-only
1384 --files-without-match
a91f453f 1385 --max-depth
c72e0db1
LM
1386 --count
1387 --and --or --not --all-match
1388 "
1389 return
1390 ;;
1391 esac
17225c49 1392
29eec71f
JK
1393 case "$cword,$prev" in
1394 2,*|*,-*)
1395 if test -r tags; then
d2c78075 1396 __gitcomp_nl "$(__git_match_ctag "$cur" tags)"
29eec71f
JK
1397 return
1398 fi
1399 ;;
1400 esac
1401
a31e6262 1402 __gitcomp_nl "$(__git_refs)"
c72e0db1
LM
1403}
1404
1eb7e2f8
LM
1405_git_help ()
1406{
1eb7e2f8
LM
1407 case "$cur" in
1408 --*)
1409 __gitcomp "--all --info --man --web"
1410 return
1411 ;;
1412 esac
eaa4e6ee 1413 __git_compute_all_commands
f85a6f0b 1414 __gitcomp "$__git_all_commands $(__git_aliases)
2946cccf
MG
1415 attributes cli core-tutorial cvs-migration
1416 diffcore gitk glossary hooks ignore modules
d49483f0 1417 namespaces repository-layout tutorial tutorial-2
99f0b599 1418 workflows
2946cccf 1419 "
1eb7e2f8
LM
1420}
1421
5dad868b
LM
1422_git_init ()
1423{
5dad868b
LM
1424 case "$cur" in
1425 --shared=*)
1426 __gitcomp "
1427 false true umask group all world everybody
1428 " "" "${cur##--shared=}"
1429 return
1430 ;;
1431 --*)
1432 __gitcomp "--quiet --bare --template= --shared --shared="
1433 return
1434 ;;
1435 esac
5dad868b
LM
1436}
1437
b1bc1494
LM
1438_git_ls_files ()
1439{
b1bc1494
LM
1440 case "$cur" in
1441 --*)
1442 __gitcomp "--cached --deleted --modified --others --ignored
1443 --stage --directory --no-empty-directory --unmerged
1444 --killed --exclude= --exclude-from=
1445 --exclude-per-directory= --exclude-standard
1446 --error-unmatch --with-tree= --full-name
1447 --abbrev --ignored --exclude-per-directory
1448 "
1449 return
1450 ;;
1451 esac
fea16b47
MP
1452
1453 # XXX ignore options like --modified and always suggest all cached
1454 # files.
1455 __git_complete_index_file "--cached"
b1bc1494
LM
1456}
1457
690d8824
JH
1458_git_ls_remote ()
1459{
a31e6262 1460 __gitcomp_nl "$(__git_remotes)"
690d8824
JH
1461}
1462
1463_git_ls_tree ()
1464{
1465 __git_complete_file
1466}
1467
a393777e
TR
1468# Options that go well for log, shortlog and gitk
1469__git_log_common_options="
1470 --not --all
1471 --branches --tags --remotes
4fe1a619 1472 --first-parent --merges --no-merges
a393777e
TR
1473 --max-count=
1474 --max-age= --since= --after=
1475 --min-age= --until= --before=
6a6ebded
MG
1476 --min-parents= --max-parents=
1477 --no-min-parents --no-max-parents
a393777e
TR
1478"
1479# Options that go well for log and gitk (not shortlog)
1480__git_log_gitk_options="
1481 --dense --sparse --full-history
1482 --simplify-merges --simplify-by-decoration
3925b575 1483 --left-right --notes --no-notes
a393777e
TR
1484"
1485# Options that go well for log and shortlog (not gitk)
1486__git_log_shortlog_options="
1487 --author= --committer= --grep=
1488 --all-match
1489"
1490
3d279863 1491__git_log_pretty_formats="oneline short medium full fuller email raw format:"
672c68cb 1492__git_log_date_formats="relative iso8601 rfc2822 short local default raw"
3d279863 1493
690d8824
JH
1494_git_log ()
1495{
d773c631
SG
1496 __git_has_doubledash && return
1497
bf3c20f6
TR
1498 local g="$(git rev-parse --git-dir 2>/dev/null)"
1499 local merge=""
ba7906f2 1500 if [ -f "$g/MERGE_HEAD" ]; then
bf3c20f6
TR
1501 merge="--merge"
1502 fi
6e31b866 1503 case "$cur" in
e67d71e5 1504 --pretty=*|--format=*)
c3898111 1505 __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
e67d71e5 1506 " "" "${cur#*=}"
72de29c2
TL
1507 return
1508 ;;
47e98eec 1509 --date=*)
672c68cb 1510 __gitcomp "$__git_log_date_formats" "" "${cur##--date=}"
47e98eec
SP
1511 return
1512 ;;
af4e9e8c
SB
1513 --decorate=*)
1514 __gitcomp "long short" "" "${cur##--decorate=}"
1515 return
1516 ;;
6e31b866 1517 --*)
b3391775 1518 __gitcomp "
a393777e
TR
1519 $__git_log_common_options
1520 $__git_log_shortlog_options
1521 $__git_log_gitk_options
8f87fae6 1522 --root --topo-order --date-order --reverse
5d0e6343 1523 --follow --full-diff
6e31b866 1524 --abbrev-commit --abbrev=
47e98eec 1525 --relative-date --date=
72de29c2 1526 --pretty= --format= --oneline
a393777e 1527 --cherry-pick
20827d99 1528 --graph
af4e9e8c 1529 --decorate --decorate=
20bf7292 1530 --walk-reflogs
a393777e 1531 --parents --children
bf3c20f6 1532 $merge
20bf7292 1533 $__git_diff_common_options
47d5a8fa 1534 --pickaxe-all --pickaxe-regex
b3391775 1535 "
6e31b866
SP
1536 return
1537 ;;
1538 esac
f53352fb 1539 __git_complete_revlist
690d8824
JH
1540}
1541
0a4e1472
JS
1542__git_merge_options="
1543 --no-commit --no-stat --log --no-log --squash --strategy
2ff14e31 1544 --commit --stat --no-squash --ff --no-ff --ff-only --edit --no-edit
0a4e1472
JS
1545"
1546
4ad91321
SP
1547_git_merge ()
1548{
3c7b480a
JS
1549 __git_complete_strategy && return
1550
4ad91321
SP
1551 case "$cur" in
1552 --*)
0a4e1472 1553 __gitcomp "$__git_merge_options"
4ad91321
SP
1554 return
1555 esac
a31e6262 1556 __gitcomp_nl "$(__git_refs)"
4ad91321
SP
1557}
1558
b4c72162
LM
1559_git_mergetool ()
1560{
b4c72162
LM
1561 case "$cur" in
1562 --tool=*)
e2dc2de9 1563 __gitcomp "$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"
b4c72162
LM
1564 return
1565 ;;
1566 --*)
1567 __gitcomp "--tool="
1568 return
1569 ;;
1570 esac
b4c72162
LM
1571}
1572
690d8824
JH
1573_git_merge_base ()
1574{
a31e6262 1575 __gitcomp_nl "$(__git_refs)"
690d8824
JH
1576}
1577
1127c51c
LM
1578_git_mv ()
1579{
1127c51c
LM
1580 case "$cur" in
1581 --*)
1582 __gitcomp "--dry-run"
1583 return
1584 ;;
1585 esac
fea16b47
MP
1586
1587 if [ $(__git_count_arguments "mv") -gt 0 ]; then
1588 # We need to show both cached and untracked files (including
1589 # empty directories) since this may not be the last argument.
1590 __git_complete_index_file "--cached --others --directory"
1591 else
1592 __git_complete_index_file "--cached"
1593 fi
1127c51c
LM
1594}
1595
d33909bf
SP
1596_git_name_rev ()
1597{
b3391775 1598 __gitcomp "--tags --all --stdin"
d33909bf
SP
1599}
1600
00f09d0e
SG
1601_git_notes ()
1602{
2a5da755
SG
1603 local subcommands='add append copy edit list prune remove show'
1604 local subcommand="$(__git_find_on_cmdline "$subcommands")"
00f09d0e 1605
2a5da755
SG
1606 case "$subcommand,$cur" in
1607 ,--*)
1608 __gitcomp '--ref'
1609 ;;
1610 ,*)
39540681 1611 case "$prev" in
2a5da755 1612 --ref)
a31e6262 1613 __gitcomp_nl "$(__git_refs)"
2a5da755
SG
1614 ;;
1615 *)
1616 __gitcomp "$subcommands --ref"
1617 ;;
1618 esac
1619 ;;
a8f89bfa 1620 add,--reuse-message=*|append,--reuse-message=*|\
2a5da755 1621 add,--reedit-message=*|append,--reedit-message=*)
a31e6262 1622 __gitcomp_nl "$(__git_refs)" "" "${cur#*=}"
2a5da755
SG
1623 ;;
1624 add,--*|append,--*)
1625 __gitcomp '--file= --message= --reedit-message=
1626 --reuse-message='
1627 ;;
1628 copy,--*)
1629 __gitcomp '--stdin'
1630 ;;
1631 prune,--*)
1632 __gitcomp '--dry-run --verbose'
1633 ;;
1634 prune,*)
00f09d0e
SG
1635 ;;
1636 *)
39540681 1637 case "$prev" in
2a5da755
SG
1638 -m|-F)
1639 ;;
1640 *)
a31e6262 1641 __gitcomp_nl "$(__git_refs)"
2a5da755
SG
1642 ;;
1643 esac
00f09d0e
SG
1644 ;;
1645 esac
1646}
1647
690d8824
JH
1648_git_pull ()
1649{
0a4e1472
JS
1650 __git_complete_strategy && return
1651
0a4e1472
JS
1652 case "$cur" in
1653 --*)
1654 __gitcomp "
1655 --rebase --no-rebase
1656 $__git_merge_options
1657 $__git_fetch_options
1658 "
1659 return
1660 ;;
1661 esac
52d5c3b5 1662 __git_complete_remote_or_refspec
690d8824
JH
1663}
1664
1665_git_push ()
1666{
da48616f 1667 case "$prev" in
0a4e1472 1668 --repo)
a31e6262 1669 __gitcomp_nl "$(__git_remotes)"
0a4e1472
JS
1670 return
1671 esac
1672 case "$cur" in
1673 --repo=*)
a31e6262 1674 __gitcomp_nl "$(__git_remotes)" "" "${cur##--repo=}"
0a4e1472
JS
1675 return
1676 ;;
1677 --*)
1678 __gitcomp "
1679 --all --mirror --tags --dry-run --force --verbose
3623dc03 1680 --receive-pack= --repo= --set-upstream
0a4e1472
JS
1681 "
1682 return
1683 ;;
1684 esac
52d5c3b5 1685 __git_complete_remote_or_refspec
690d8824
JH
1686}
1687
61d926a3
SP
1688_git_rebase ()
1689{
da48616f 1690 local dir="$(__gitdir)"
51ef1daa 1691 if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
b3391775 1692 __gitcomp "--continue --skip --abort"
61d926a3
SP
1693 return
1694 fi
3c7b480a 1695 __git_complete_strategy && return
61d926a3 1696 case "$cur" in
93cf50a4
BG
1697 --whitespace=*)
1698 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
1699 return
1700 ;;
61d926a3 1701 --*)
93cf50a4
BG
1702 __gitcomp "
1703 --onto --merge --strategy --interactive
1704 --preserve-merges --stat --no-stat
1705 --committer-date-is-author-date --ignore-date
1706 --ignore-whitespace --whitespace=
6d0d465e 1707 --autosquash
93cf50a4
BG
1708 "
1709
61d926a3
SP
1710 return
1711 esac
a31e6262 1712 __gitcomp_nl "$(__git_refs)"
61d926a3
SP
1713}
1714
057f3279
TRC
1715_git_reflog ()
1716{
1717 local subcommands="show delete expire"
1718 local subcommand="$(__git_find_on_cmdline "$subcommands")"
1719
1720 if [ -z "$subcommand" ]; then
1721 __gitcomp "$subcommands"
1722 else
a31e6262 1723 __gitcomp_nl "$(__git_refs)"
057f3279
TRC
1724 fi
1725}
1726
ae616de6 1727__git_send_email_confirm_options="always never auto cc compose"
cb8a9bd5 1728__git_send_email_suppresscc_options="author self cc bodycc sob cccmd body all"
ae616de6 1729
25a1f374
TL
1730_git_send_email ()
1731{
25a1f374 1732 case "$cur" in
ae616de6
SB
1733 --confirm=*)
1734 __gitcomp "
1735 $__git_send_email_confirm_options
1736 " "" "${cur##--confirm=}"
1737 return
1738 ;;
1739 --suppress-cc=*)
1740 __gitcomp "
1741 $__git_send_email_suppresscc_options
1742 " "" "${cur##--suppress-cc=}"
1743
1744 return
1745 ;;
1746 --smtp-encryption=*)
1747 __gitcomp "ssl tls" "" "${cur##--smtp-encryption=}"
1748 return
1749 ;;
2f65494d
FC
1750 --thread=*)
1751 __gitcomp "
1752 deep shallow
1753 " "" "${cur##--thread=}"
1754 return
1755 ;;
25a1f374 1756 --*)
77813151 1757 __gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to
ae616de6
SB
1758 --compose --confirm= --dry-run --envelope-sender
1759 --from --identity
25a1f374
TL
1760 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
1761 --no-suppress-from --no-thread --quiet
1762 --signed-off-by-cc --smtp-pass --smtp-server
ae616de6
SB
1763 --smtp-server-port --smtp-encryption= --smtp-user
1764 --subject --suppress-cc= --suppress-from --thread --to
2f65494d
FC
1765 --validate --no-validate
1766 $__git_format_patch_options"
25a1f374
TL
1767 return
1768 ;;
1769 esac
2f65494d 1770 __git_complete_revlist
25a1f374
TL
1771}
1772
424cce83
SG
1773_git_stage ()
1774{
1775 _git_add
1776}
1777
00652369
SB
1778__git_config_get_set_variables ()
1779{
da48616f 1780 local prevword word config_file= c=$cword
00652369 1781 while [ $c -gt 1 ]; do
da48616f 1782 word="${words[c]}"
00652369 1783 case "$word" in
66c0786c 1784 --system|--global|--local|--file=*)
00652369
SB
1785 config_file="$word"
1786 break
1787 ;;
1788 -f|--file)
1789 config_file="$word $prevword"
1790 break
1791 ;;
1792 esac
1793 prevword=$word
1794 c=$((--c))
1795 done
1796
f581de1b 1797 git --git-dir="$(__gitdir)" config $config_file --list 2>/dev/null |
6f2dd720 1798 while read -r line
f581de1b
SB
1799 do
1800 case "$line" in
1801 *.*=*)
1802 echo "${line/=*/}"
00652369
SB
1803 ;;
1804 esac
1805 done
1806}
1807
e0d10e1c 1808_git_config ()
5de40f59 1809{
da48616f 1810 case "$prev" in
5de40f59 1811 branch.*.remote)
a31e6262 1812 __gitcomp_nl "$(__git_remotes)"
5de40f59
SP
1813 return
1814 ;;
1815 branch.*.merge)
a31e6262 1816 __gitcomp_nl "$(__git_refs)"
5de40f59
SP
1817 return
1818 ;;
1819 remote.*.fetch)
da48616f 1820 local remote="${prev#remote.}"
5de40f59 1821 remote="${remote%.fetch}"
d51a8ecd 1822 if [ -z "$cur" ]; then
1ce23aad 1823 __gitcompadd "refs/heads/" "" "" ""
d51a8ecd
SG
1824 return
1825 fi
a31e6262 1826 __gitcomp_nl "$(__git_refs_remotes "$remote")"
5de40f59
SP
1827 return
1828 ;;
1829 remote.*.push)
da48616f 1830 local remote="${prev#remote.}"
5de40f59 1831 remote="${remote%.push}"
a31e6262 1832 __gitcomp_nl "$(git --git-dir="$(__gitdir)" \
5de40f59 1833 for-each-ref --format='%(refname):%(refname)' \
78d4d6a2
SP
1834 refs/heads)"
1835 return
1836 ;;
1837 pull.twohead|pull.octopus)
eaa4e6ee
JN
1838 __git_compute_merge_strategies
1839 __gitcomp "$__git_merge_strategies"
78d4d6a2
SP
1840 return
1841 ;;
6123d719
MH
1842 color.branch|color.diff|color.interactive|\
1843 color.showbranch|color.status|color.ui)
78d4d6a2
SP
1844 __gitcomp "always never auto"
1845 return
1846 ;;
901d615c
MK
1847 color.pager)
1848 __gitcomp "false true"
1849 return
1850 ;;
78d4d6a2
SP
1851 color.*.*)
1852 __gitcomp "
98171a07 1853 normal black red green yellow blue magenta cyan white
78d4d6a2
SP
1854 bold dim ul blink reverse
1855 "
5de40f59
SP
1856 return
1857 ;;
9b82d63b
SB
1858 help.format)
1859 __gitcomp "man info web html"
1860 return
1861 ;;
672c68cb
SB
1862 log.date)
1863 __gitcomp "$__git_log_date_formats"
1864 return
1865 ;;
ae616de6
SB
1866 sendemail.aliasesfiletype)
1867 __gitcomp "mutt mailrc pine elm gnus"
1868 return
1869 ;;
1870 sendemail.confirm)
1871 __gitcomp "$__git_send_email_confirm_options"
1872 return
1873 ;;
1874 sendemail.suppresscc)
1875 __gitcomp "$__git_send_email_suppresscc_options"
1876 return
1877 ;;
00652369 1878 --get|--get-all|--unset|--unset-all)
a31e6262 1879 __gitcomp_nl "$(__git_config_get_set_variables)"
00652369
SB
1880 return
1881 ;;
5de40f59 1882 *.*)
5de40f59
SP
1883 return
1884 ;;
1885 esac
1886 case "$cur" in
1887 --*)
78d4d6a2 1888 __gitcomp "
66c0786c 1889 --system --global --local --file=
12977705 1890 --list --replace-all
5de40f59 1891 --get --get-all --get-regexp
1b71eb35 1892 --add --unset --unset-all
12977705 1893 --remove-section --rename-section
78d4d6a2 1894 "
5de40f59
SP
1895 return
1896 ;;
1897 branch.*.*)
9244d69b
SG
1898 local pfx="${cur%.*}." cur_="${cur##*.}"
1899 __gitcomp "remote merge mergeoptions rebase" "$pfx" "$cur_"
5de40f59
SP
1900 return
1901 ;;
1902 branch.*)
9244d69b 1903 local pfx="${cur%.*}." cur_="${cur#*.}"
a31e6262 1904 __gitcomp_nl "$(__git_heads)" "$pfx" "$cur_" "."
5de40f59
SP
1905 return
1906 ;;
0aa62fd0 1907 guitool.*.*)
9244d69b 1908 local pfx="${cur%.*}." cur_="${cur##*.}"
0aa62fd0
SB
1909 __gitcomp "
1910 argprompt cmd confirm needsfile noconsole norescan
1911 prompt revprompt revunmerged title
9244d69b 1912 " "$pfx" "$cur_"
0aa62fd0
SB
1913 return
1914 ;;
1915 difftool.*.*)
9244d69b
SG
1916 local pfx="${cur%.*}." cur_="${cur##*.}"
1917 __gitcomp "cmd path" "$pfx" "$cur_"
0aa62fd0
SB
1918 return
1919 ;;
1920 man.*.*)
9244d69b
SG
1921 local pfx="${cur%.*}." cur_="${cur##*.}"
1922 __gitcomp "cmd path" "$pfx" "$cur_"
0aa62fd0
SB
1923 return
1924 ;;
1925 mergetool.*.*)
9244d69b
SG
1926 local pfx="${cur%.*}." cur_="${cur##*.}"
1927 __gitcomp "cmd path trustExitCode" "$pfx" "$cur_"
0aa62fd0
SB
1928 return
1929 ;;
1930 pager.*)
9244d69b 1931 local pfx="${cur%.*}." cur_="${cur#*.}"
eaa4e6ee 1932 __git_compute_all_commands
a31e6262 1933 __gitcomp_nl "$__git_all_commands" "$pfx" "$cur_"
0aa62fd0
SB
1934 return
1935 ;;
5de40f59 1936 remote.*.*)
9244d69b 1937 local pfx="${cur%.*}." cur_="${cur##*.}"
12977705 1938 __gitcomp "
98171a07 1939 url proxy fetch push mirror skipDefaultUpdate
6fac1b83 1940 receivepack uploadpack tagopt pushurl
9244d69b 1941 " "$pfx" "$cur_"
5de40f59
SP
1942 return
1943 ;;
1944 remote.*)
9244d69b 1945 local pfx="${cur%.*}." cur_="${cur#*.}"
a31e6262 1946 __gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "."
5de40f59
SP
1947 return
1948 ;;
0aa62fd0 1949 url.*.*)
9244d69b
SG
1950 local pfx="${cur%.*}." cur_="${cur##*.}"
1951 __gitcomp "insteadOf pushInsteadOf" "$pfx" "$cur_"
0aa62fd0
SB
1952 return
1953 ;;
5de40f59 1954 esac
78d4d6a2 1955 __gitcomp "
6068ac88
MZ
1956 add.ignoreErrors
1957 advice.commitBeforeMerge
1958 advice.detachedHead
1959 advice.implicitIdentity
1960 advice.pushNonFastForward
1961 advice.resolveConflict
1962 advice.statusHints
226b343c 1963 alias.
6068ac88 1964 am.keepcr
86c91f91 1965 apply.ignorewhitespace
5de40f59 1966 apply.whitespace
98171a07
LM
1967 branch.autosetupmerge
1968 branch.autosetuprebase
6068ac88 1969 browser.
2122591b 1970 clean.requireForce
78d4d6a2
SP
1971 color.branch
1972 color.branch.current
1973 color.branch.local
78d4d6a2 1974 color.branch.plain
025a1929 1975 color.branch.remote
6068ac88
MZ
1976 color.decorate.HEAD
1977 color.decorate.branch
1978 color.decorate.remoteBranch
1979 color.decorate.stash
1980 color.decorate.tag
a159ca0c 1981 color.diff
025a1929 1982 color.diff.commit
78d4d6a2 1983 color.diff.frag
6068ac88 1984 color.diff.func
025a1929 1985 color.diff.meta
78d4d6a2 1986 color.diff.new
025a1929
LM
1987 color.diff.old
1988 color.diff.plain
78d4d6a2 1989 color.diff.whitespace
226b343c 1990 color.grep
6068ac88
MZ
1991 color.grep.context
1992 color.grep.filename
1993 color.grep.function
1994 color.grep.linenumber
226b343c 1995 color.grep.match
6068ac88
MZ
1996 color.grep.selected
1997 color.grep.separator
98171a07 1998 color.interactive
6068ac88 1999 color.interactive.error
98171a07
LM
2000 color.interactive.header
2001 color.interactive.help
2002 color.interactive.prompt
a159ca0c 2003 color.pager
6123d719 2004 color.showbranch
a159ca0c 2005 color.status
78d4d6a2
SP
2006 color.status.added
2007 color.status.changed
025a1929 2008 color.status.header
98171a07 2009 color.status.nobranch
78d4d6a2 2010 color.status.untracked
98171a07
LM
2011 color.status.updated
2012 color.ui
6068ac88 2013 commit.status
98171a07 2014 commit.template
cdb791f6 2015 core.abbrev
6068ac88
MZ
2016 core.askpass
2017 core.attributesfile
98171a07
LM
2018 core.autocrlf
2019 core.bare
6068ac88 2020 core.bigFileThreshold
025a1929 2021 core.compression
226b343c 2022 core.createObject
98171a07
LM
2023 core.deltaBaseCacheLimit
2024 core.editor
6068ac88 2025 core.eol
98171a07 2026 core.excludesfile
025a1929 2027 core.fileMode
98171a07 2028 core.fsyncobjectfiles
025a1929 2029 core.gitProxy
98171a07 2030 core.ignoreCygwinFSTricks
025a1929 2031 core.ignoreStat
6068ac88 2032 core.ignorecase
025a1929
LM
2033 core.logAllRefUpdates
2034 core.loosecompression
6068ac88 2035 core.notesRef
025a1929
LM
2036 core.packedGitLimit
2037 core.packedGitWindowSize
98171a07 2038 core.pager
025a1929 2039 core.preferSymlinkRefs
98171a07
LM
2040 core.preloadindex
2041 core.quotepath
025a1929 2042 core.repositoryFormatVersion
98171a07 2043 core.safecrlf
025a1929 2044 core.sharedRepository
6068ac88 2045 core.sparseCheckout
98171a07
LM
2046 core.symlinks
2047 core.trustctime
025a1929 2048 core.warnAmbiguousRefs
98171a07
LM
2049 core.whitespace
2050 core.worktree
2051 diff.autorefreshindex
df44483a 2052 diff.statGraphWidth
98171a07 2053 diff.external
6068ac88 2054 diff.ignoreSubmodules
98171a07 2055 diff.mnemonicprefix
6068ac88 2056 diff.noprefix
78d4d6a2
SP
2057 diff.renameLimit
2058 diff.renames
226b343c
SB
2059 diff.suppressBlankEmpty
2060 diff.tool
2061 diff.wordRegex
07ab4dec 2062 diff.algorithm
0aa62fd0 2063 difftool.
226b343c 2064 difftool.prompt
6068ac88 2065 fetch.recurseSubmodules
78d4d6a2 2066 fetch.unpackLimit
226b343c
SB
2067 format.attach
2068 format.cc
78d4d6a2 2069 format.headers
98171a07
LM
2070 format.numbered
2071 format.pretty
d8e1e5df 2072 format.signature
226b343c
SB
2073 format.signoff
2074 format.subjectprefix
98171a07 2075 format.suffix
226b343c 2076 format.thread
6068ac88
MZ
2077 format.to
2078 gc.
98171a07
LM
2079 gc.aggressiveWindow
2080 gc.auto
2081 gc.autopacklimit
12977705 2082 gc.packrefs
98171a07 2083 gc.pruneexpire
78d4d6a2
SP
2084 gc.reflogexpire
2085 gc.reflogexpireunreachable
2086 gc.rerereresolved
2087 gc.rerereunresolved
025a1929 2088 gitcvs.allbinary
226b343c 2089 gitcvs.commitmsgannotation
98171a07 2090 gitcvs.dbTableNamePrefix
025a1929
LM
2091 gitcvs.dbdriver
2092 gitcvs.dbname
2093 gitcvs.dbpass
025a1929
LM
2094 gitcvs.dbuser
2095 gitcvs.enabled
2096 gitcvs.logfile
98171a07 2097 gitcvs.usecrlfattr
0aa62fd0 2098 guitool.
98171a07
LM
2099 gui.blamehistoryctx
2100 gui.commitmsgwidth
2101 gui.copyblamethreshold
2102 gui.diffcontext
2103 gui.encoding
2104 gui.fastcopyblame
2105 gui.matchtrackingbranch
2106 gui.newbranchtemplate
2107 gui.pruneduringfetch
2108 gui.spellingdictionary
2109 gui.trustmtime
2110 help.autocorrect
2111 help.browser
2112 help.format
78d4d6a2
SP
2113 http.lowSpeedLimit
2114 http.lowSpeedTime
025a1929 2115 http.maxRequests
6068ac88 2116 http.minSessions
5de40f59 2117 http.noEPSV
6068ac88 2118 http.postBuffer
98171a07 2119 http.proxy
025a1929
LM
2120 http.sslCAInfo
2121 http.sslCAPath
2122 http.sslCert
6068ac88 2123 http.sslCertPasswordProtected
025a1929
LM
2124 http.sslKey
2125 http.sslVerify
6068ac88 2126 http.useragent
78d4d6a2
SP
2127 i18n.commitEncoding
2128 i18n.logOutputEncoding
6068ac88 2129 imap.authMethod
226b343c
SB
2130 imap.folder
2131 imap.host
2132 imap.pass
2133 imap.port
2134 imap.preformattedHTML
2135 imap.sslverify
2136 imap.tunnel
2137 imap.user
6068ac88 2138 init.templatedir
98171a07
LM
2139 instaweb.browser
2140 instaweb.httpd
2141 instaweb.local
2142 instaweb.modulepath
2143 instaweb.port
226b343c 2144 interactive.singlekey
98171a07 2145 log.date
6068ac88 2146 log.decorate
78d4d6a2 2147 log.showroot
226b343c 2148 mailmap.file
0aa62fd0 2149 man.
98171a07 2150 man.viewer
6068ac88 2151 merge.
98171a07
LM
2152 merge.conflictstyle
2153 merge.log
2154 merge.renameLimit
6068ac88 2155 merge.renormalize
98171a07 2156 merge.stat
025a1929 2157 merge.tool
78d4d6a2 2158 merge.verbosity
0aa62fd0 2159 mergetool.
98171a07 2160 mergetool.keepBackup
6068ac88 2161 mergetool.keepTemporaries
226b343c 2162 mergetool.prompt
6068ac88
MZ
2163 notes.displayRef
2164 notes.rewrite.
2165 notes.rewrite.amend
2166 notes.rewrite.rebase
2167 notes.rewriteMode
2168 notes.rewriteRef
47e98eec 2169 pack.compression
47e98eec 2170 pack.deltaCacheLimit
025a1929
LM
2171 pack.deltaCacheSize
2172 pack.depth
98171a07
LM
2173 pack.indexVersion
2174 pack.packSizeLimit
2175 pack.threads
025a1929
LM
2176 pack.window
2177 pack.windowMemory
0aa62fd0 2178 pager.
6068ac88 2179 pretty.
78d4d6a2
SP
2180 pull.octopus
2181 pull.twohead
226b343c 2182 push.default
6068ac88 2183 rebase.autosquash
226b343c 2184 rebase.stat
6068ac88 2185 receive.autogc
98171a07 2186 receive.denyCurrentBranch
6068ac88 2187 receive.denyDeleteCurrent
98171a07 2188 receive.denyDeletes
025a1929 2189 receive.denyNonFastForwards
98171a07 2190 receive.fsckObjects
025a1929 2191 receive.unpackLimit
6068ac88
MZ
2192 receive.updateserverinfo
2193 remotes.
98171a07
LM
2194 repack.usedeltabaseoffset
2195 rerere.autoupdate
2196 rerere.enabled
6068ac88 2197 sendemail.
226b343c 2198 sendemail.aliasesfile
6068ac88 2199 sendemail.aliasfiletype
226b343c
SB
2200 sendemail.bcc
2201 sendemail.cc
2202 sendemail.cccmd
2203 sendemail.chainreplyto
2204 sendemail.confirm
2205 sendemail.envelopesender
6068ac88
MZ
2206 sendemail.from
2207 sendemail.identity
226b343c
SB
2208 sendemail.multiedit
2209 sendemail.signedoffbycc
6068ac88 2210 sendemail.smtpdomain
226b343c
SB
2211 sendemail.smtpencryption
2212 sendemail.smtppass
2213 sendemail.smtpserver
6068ac88 2214 sendemail.smtpserveroption
226b343c
SB
2215 sendemail.smtpserverport
2216 sendemail.smtpuser
2217 sendemail.suppresscc
2218 sendemail.suppressfrom
2219 sendemail.thread
2220 sendemail.to
2221 sendemail.validate
78d4d6a2 2222 showbranch.default
98171a07
LM
2223 status.relativePaths
2224 status.showUntrackedFiles
6068ac88
MZ
2225 status.submodulesummary
2226 submodule.
78d4d6a2
SP
2227 tar.umask
2228 transfer.unpackLimit
0aa62fd0 2229 url.
78d4d6a2 2230 user.email
025a1929 2231 user.name
78d4d6a2 2232 user.signingkey
98171a07 2233 web.browser
5de40f59 2234 branch. remote.
78d4d6a2 2235 "
5de40f59
SP
2236}
2237
88293c67
SP
2238_git_remote ()
2239{
e17dba8f 2240 local subcommands="add rename remove set-head set-branches set-url show prune update"
918c03c2 2241 local subcommand="$(__git_find_on_cmdline "$subcommands")"
3ff1320d 2242 if [ -z "$subcommand" ]; then
3903c618 2243 __gitcomp "$subcommands"
88293c67
SP
2244 return
2245 fi
2246
3ff1320d 2247 case "$subcommand" in
e17dba8f 2248 rename|remove|set-url|show|prune)
a31e6262 2249 __gitcomp_nl "$(__git_remotes)"
88293c67 2250 ;;
f1c6ffe6
PJ
2251 set-head|set-branches)
2252 __git_complete_remote_or_refspec
2253 ;;
fb72759b
SP
2254 update)
2255 local i c='' IFS=$'\n'
518ef8f0
TZ
2256 for i in $(git --git-dir="$(__gitdir)" config --get-regexp "remotes\..*" 2>/dev/null); do
2257 i="${i#remotes.}"
2258 c="$c ${i/ */}"
fb72759b
SP
2259 done
2260 __gitcomp "$c"
2261 ;;
88293c67 2262 *)
88293c67
SP
2263 ;;
2264 esac
2265}
2266
e1c1a067
BG
2267_git_replace ()
2268{
a31e6262 2269 __gitcomp_nl "$(__git_refs)"
e1c1a067
BG
2270}
2271
67e78c3b
SP
2272_git_reset ()
2273{
d773c631
SG
2274 __git_has_doubledash && return
2275
b3391775
SP
2276 case "$cur" in
2277 --*)
9f040e95 2278 __gitcomp "--merge --mixed --hard --soft --patch"
b3391775
SP
2279 return
2280 ;;
2281 esac
a31e6262 2282 __gitcomp_nl "$(__git_refs)"
67e78c3b
SP
2283}
2284
a6c2be24
LM
2285_git_revert ()
2286{
a6c2be24
LM
2287 case "$cur" in
2288 --*)
2289 __gitcomp "--edit --mainline --no-edit --no-commit --signoff"
2290 return
2291 ;;
2292 esac
a31e6262 2293 __gitcomp_nl "$(__git_refs)"
a6c2be24
LM
2294}
2295
08c701d4
LM
2296_git_rm ()
2297{
08c701d4
LM
2298 case "$cur" in
2299 --*)
2300 __gitcomp "--cached --dry-run --ignore-unmatch --quiet"
2301 return
2302 ;;
2303 esac
fea16b47
MP
2304
2305 __git_complete_index_file "--cached"
08c701d4
LM
2306}
2307
1fd6bec9
SP
2308_git_shortlog ()
2309{
d773c631
SG
2310 __git_has_doubledash && return
2311
1fd6bec9
SP
2312 case "$cur" in
2313 --*)
2314 __gitcomp "
a393777e
TR
2315 $__git_log_common_options
2316 $__git_log_shortlog_options
1fd6bec9
SP
2317 --numbered --summary
2318 "
2319 return
2320 ;;
2321 esac
2322 __git_complete_revlist
2323}
2324
90131924
SP
2325_git_show ()
2326{
41d8cf7d
MH
2327 __git_has_doubledash && return
2328
90131924 2329 case "$cur" in
e67d71e5 2330 --pretty=*|--format=*)
c3898111 2331 __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
e67d71e5 2332 " "" "${cur#*=}"
72de29c2
TL
2333 return
2334 ;;
07924d4d
MP
2335 --diff-algorithm=*)
2336 __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
2337 return
2338 ;;
90131924 2339 --*)
076c3237 2340 __gitcomp "--pretty= --format= --abbrev-commit --oneline
20bf7292
TR
2341 $__git_diff_common_options
2342 "
90131924
SP
2343 return
2344 ;;
2345 esac
2346 __git_complete_file
2347}
2348
2ca880fe
TR
2349_git_show_branch ()
2350{
2ca880fe
TR
2351 case "$cur" in
2352 --*)
2353 __gitcomp "
2354 --all --remotes --topo-order --current --more=
2355 --list --independent --merge-base --no-name
6123d719 2356 --color --no-color
076c3237 2357 --sha1-name --sparse --topics --reflog
2ca880fe
TR
2358 "
2359 return
2360 ;;
2361 esac
2362 __git_complete_revlist
2363}
2364
7fd53fce
JH
2365_git_stash ()
2366{
59d5eeee 2367 local save_opts='--keep-index --no-keep-index --quiet --patch'
95d43780 2368 local subcommands='save list show apply clear drop pop create branch'
918c03c2 2369 local subcommand="$(__git_find_on_cmdline "$subcommands")"
7bedebca 2370 if [ -z "$subcommand" ]; then
59d5eeee
SG
2371 case "$cur" in
2372 --*)
2373 __gitcomp "$save_opts"
2374 ;;
2375 *)
2376 if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then
2377 __gitcomp "$subcommands"
59d5eeee
SG
2378 fi
2379 ;;
2380 esac
7bedebca 2381 else
7bedebca
SG
2382 case "$subcommand,$cur" in
2383 save,--*)
59d5eeee 2384 __gitcomp "$save_opts"
7bedebca 2385 ;;
8513c54b 2386 apply,--*|pop,--*)
59d5eeee 2387 __gitcomp "--index --quiet"
95d43780 2388 ;;
8513c54b 2389 show,--*|drop,--*|branch,--*)
95d43780
LM
2390 ;;
2391 show,*|apply,*|drop,*|pop,*|branch,*)
a31e6262 2392 __gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \
95d43780
LM
2393 | sed -n -e 's/:.*//p')"
2394 ;;
7bedebca 2395 *)
7bedebca
SG
2396 ;;
2397 esac
3ff1320d 2398 fi
7fd53fce
JH
2399}
2400
be86f7a0
SP
2401_git_submodule ()
2402{
d773c631
SG
2403 __git_has_doubledash && return
2404
cf419828 2405 local subcommands="add status init deinit update summary foreach sync"
918c03c2 2406 if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then
be86f7a0
SP
2407 case "$cur" in
2408 --*)
2409 __gitcomp "--quiet --cached"
2410 ;;
2411 *)
3ff1320d 2412 __gitcomp "$subcommands"
be86f7a0
SP
2413 ;;
2414 esac
2415 return
2416 fi
2417}
2418
47f6ee28
SG
2419_git_svn ()
2420{
2421 local subcommands="
2422 init fetch clone rebase dcommit log find-rev
2423 set-tree commit-diff info create-ignore propget
4a5856cb 2424 proplist show-ignore show-externals branch tag blame
c18d5d82 2425 migrate mkdirs reset gc
47f6ee28 2426 "
918c03c2 2427 local subcommand="$(__git_find_on_cmdline "$subcommands")"
47f6ee28
SG
2428 if [ -z "$subcommand" ]; then
2429 __gitcomp "$subcommands"
2430 else
2431 local remote_opts="--username= --config-dir= --no-auth-cache"
2432 local fc_opts="
2433 --follow-parent --authors-file= --repack=
2434 --no-metadata --use-svm-props --use-svnsync-props
2435 --log-window-size= --no-checkout --quiet
4a5856cb
SG
2436 --repack-flags --use-log-author --localtime
2437 --ignore-paths= $remote_opts
47f6ee28
SG
2438 "
2439 local init_opts="
2440 --template= --shared= --trunk= --tags=
2441 --branches= --stdlayout --minimize-url
2442 --no-metadata --use-svm-props --use-svnsync-props
4a5856cb
SG
2443 --rewrite-root= --prefix= --use-log-author
2444 --add-author-from $remote_opts
47f6ee28
SG
2445 "
2446 local cmt_opts="
2447 --edit --rmdir --find-copies-harder --copy-similarity=
2448 "
2449
47f6ee28
SG
2450 case "$subcommand,$cur" in
2451 fetch,--*)
2452 __gitcomp "--revision= --fetch-all $fc_opts"
2453 ;;
2454 clone,--*)
2455 __gitcomp "--revision= $fc_opts $init_opts"
2456 ;;
2457 init,--*)
2458 __gitcomp "$init_opts"
2459 ;;
2460 dcommit,--*)
2461 __gitcomp "
2462 --merge --strategy= --verbose --dry-run
4a5856cb 2463 --fetch-all --no-rebase --commit-url
7b151f49 2464 --revision --interactive $cmt_opts $fc_opts
47f6ee28
SG
2465 "
2466 ;;
2467 set-tree,--*)
2468 __gitcomp "--stdin $cmt_opts $fc_opts"
2469 ;;
2470 create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\
c18d5d82 2471 show-externals,--*|mkdirs,--*)
47f6ee28
SG
2472 __gitcomp "--revision="
2473 ;;
2474 log,--*)
2475 __gitcomp "
2476 --limit= --revision= --verbose --incremental
2477 --oneline --show-commit --non-recursive
4a5856cb 2478 --authors-file= --color
47f6ee28
SG
2479 "
2480 ;;
2481 rebase,--*)
2482 __gitcomp "
2483 --merge --verbose --strategy= --local
4a5856cb 2484 --fetch-all --dry-run $fc_opts
47f6ee28
SG
2485 "
2486 ;;
2487 commit-diff,--*)
2488 __gitcomp "--message= --file= --revision= $cmt_opts"
2489 ;;
2490 info,--*)
2491 __gitcomp "--url"
2492 ;;
4a5856cb
SG
2493 branch,--*)
2494 __gitcomp "--dry-run --message --tag"
2495 ;;
2496 tag,--*)
2497 __gitcomp "--dry-run --message"
2498 ;;
2499 blame,--*)
2500 __gitcomp "--git-format"
2501 ;;
2502 migrate,--*)
2503 __gitcomp "
2504 --config-dir= --ignore-paths= --minimize
2505 --no-auth-cache --username=
2506 "
2507 ;;
c18d5d82
RZ
2508 reset,--*)
2509 __gitcomp "--revision= --parent"
2510 ;;
47f6ee28 2511 *)
47f6ee28
SG
2512 ;;
2513 esac
2514 fi
2515}
2516
88e21dc7
SP
2517_git_tag ()
2518{
2519 local i c=1 f=0
da48616f
PD
2520 while [ $c -lt $cword ]; do
2521 i="${words[c]}"
88e21dc7
SP
2522 case "$i" in
2523 -d|-v)
a31e6262 2524 __gitcomp_nl "$(__git_tags)"
88e21dc7
SP
2525 return
2526 ;;
2527 -f)
2528 f=1
2529 ;;
2530 esac
6e8c755f 2531 ((c++))
88e21dc7
SP
2532 done
2533
da48616f 2534 case "$prev" in
88e21dc7 2535 -m|-F)
88e21dc7 2536 ;;
8d8163f3 2537 -*|tag)
88e21dc7 2538 if [ $f = 1 ]; then
a31e6262 2539 __gitcomp_nl "$(__git_tags)"
88e21dc7
SP
2540 fi
2541 ;;
2542 *)
a31e6262 2543 __gitcomp_nl "$(__git_refs)"
88e21dc7
SP
2544 ;;
2545 esac
2546}
2547
424cce83
SG
2548_git_whatchanged ()
2549{
2550 _git_log
2551}
2552
93b291e0 2553__git_main ()
690d8824 2554{
873537fa
SP
2555 local i c=1 command __git_dir
2556
da48616f
PD
2557 while [ $c -lt $cword ]; do
2558 i="${words[c]}"
873537fa
SP
2559 case "$i" in
2560 --git-dir=*) __git_dir="${i#--git-dir=}" ;;
2561 --bare) __git_dir="." ;;
1eb7e2f8 2562 --help) command="help"; break ;;
911d5da6
SG
2563 -c) c=$((++c)) ;;
2564 -*) ;;
873537fa
SP
2565 *) command="$i"; break ;;
2566 esac
6e8c755f 2567 ((c++))
873537fa
SP
2568 done
2569
1d17b22e 2570 if [ -z "$command" ]; then
da48616f 2571 case "$cur" in
47e98eec 2572 --*) __gitcomp "
ce5a2c95 2573 --paginate
47e98eec
SP
2574 --no-pager
2575 --git-dir=
2576 --bare
2577 --version
2578 --exec-path
3ffcd086 2579 --exec-path=
89a56bfb 2580 --html-path
69ef3c02 2581 --info-path
ce5a2c95 2582 --work-tree=
a1bea2c1 2583 --namespace=
69ef3c02 2584 --no-replace-objects
ce5a2c95 2585 --help
47e98eec
SP
2586 "
2587 ;;
eaa4e6ee
JN
2588 *) __git_compute_porcelain_commands
2589 __gitcomp "$__git_porcelain_commands $(__git_aliases)" ;;
72e5e989
SP
2590 esac
2591 return
873537fa 2592 fi
367dce2a 2593
424cce83 2594 local completion_func="_git_${command//-/_}"
06f44c3c 2595 declare -f $completion_func >/dev/null && $completion_func && return
8024ea60 2596
873537fa 2597 local expansion=$(__git_aliased_command "$command")
8024ea60
SG
2598 if [ -n "$expansion" ]; then
2599 completion_func="_git_${expansion//-/_}"
06f44c3c 2600 declare -f $completion_func >/dev/null && $completion_func
8024ea60 2601 fi
690d8824
JH
2602}
2603
93b291e0 2604__gitk_main ()
690d8824 2605{
d773c631
SG
2606 __git_has_doubledash && return
2607
fa26a401 2608 local g="$(__gitdir)"
07ba53f7 2609 local merge=""
ba7906f2 2610 if [ -f "$g/MERGE_HEAD" ]; then
07ba53f7
RQ
2611 merge="--merge"
2612 fi
b3391775
SP
2613 case "$cur" in
2614 --*)
a393777e
TR
2615 __gitcomp "
2616 $__git_log_common_options
2617 $__git_log_gitk_options
2618 $merge
2619 "
b3391775
SP
2620 return
2621 ;;
2622 esac
ec804891 2623 __git_complete_revlist
690d8824
JH
2624}
2625
d8b45314
FC
2626if [[ -n ${ZSH_VERSION-} ]]; then
2627 echo "WARNING: this script is deprecated, please see git-completion.zsh" 1>&2
6b179adf 2628
9cd67bd2
FC
2629 autoload -U +X compinit && compinit
2630
d8b45314
FC
2631 __gitcomp ()
2632 {
2633 emulate -L zsh
6b179adf 2634
d8b45314
FC
2635 local cur_="${3-$cur}"
2636
2637 case "$cur_" in
2638 --*=)
2639 ;;
2640 *)
2641 local c IFS=$' \t\n'
2642 local -a array
2643 for c in ${=1}; do
2644 c="$c${4-}"
2645 case $c in
2646 --*=*|*.) ;;
2647 *) c="$c " ;;
2648 esac
50c5885e 2649 array[$#array+1]="$c"
d8b45314
FC
2650 done
2651 compset -P '*[=:]'
2652 compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
2653 ;;
2654 esac
2655 }
2656
2657 __gitcomp_nl ()
2658 {
2659 emulate -L zsh
2660
2661 local IFS=$'\n'
2662 compset -P '*[=:]'
2663 compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
2664 }
2665
fea16b47
MP
2666 __gitcomp_file ()
2667 {
2668 emulate -L zsh
2669
2670 local IFS=$'\n'
2671 compset -P '*[=:]'
2672 compadd -Q -p "${2-}" -f -- ${=1} && _ret=0
2673 }
2674
d8b45314
FC
2675 __git_zsh_helper ()
2676 {
2677 emulate -L ksh
2678 local cur cword prev
2679 cur=${words[CURRENT-1]}
2680 prev=${words[CURRENT-2]}
2681 let cword=CURRENT-1
2682 __${service}_main
2683 }
2684
2685 _git ()
2686 {
2687 emulate -L zsh
2688 local _ret=1
2689 __git_zsh_helper
2690 let _ret && _default -S '' && _ret=0
2691 return _ret
2692 }
2693
2694 compdef _git git gitk
2695 return
fea16b47
MP
2696elif [[ -n ${BASH_VERSION-} ]]; then
2697 if ((${BASH_VERSINFO[0]} < 4)); then
2698 # compopt is not supported
2699 __git_index_file_list_filter ()
2700 {
2701 __git_index_file_list_filter_compat
2702 }
2703 fi
d8b45314
FC
2704fi
2705
2706__git_func_wrap ()
2707{
6b179adf
FC
2708 local cur words cword prev
2709 _get_comp_words_by_ref -n =: cur words cword prev
2710 $1
2711}
2712
2713# Setup completion for certain functions defined above by setting common
2714# variables and workarounds.
2715# This is NOT a public function; use at your own risk.
2716__git_complete ()
2717{
2718 local wrapper="__git_wrap${2}"
2719 eval "$wrapper () { __git_func_wrap $2 ; }"
2720 complete -o bashdefault -o default -o nospace -F $wrapper $1 2>/dev/null \
2721 || complete -o default -o nospace -F $wrapper $1
2722}
2723
b0a4b2d2
FC
2724# wrapper for backwards compatibility
2725_git ()
2726{
93b291e0 2727 __git_wrap__git_main
b0a4b2d2
FC
2728}
2729
2730# wrapper for backwards compatibility
2731_gitk ()
2732{
93b291e0 2733 __git_wrap__gitk_main
b0a4b2d2
FC
2734}
2735
93b291e0
SG
2736__git_complete git __git_main
2737__git_complete gitk __gitk_main
690d8824
JH
2738
2739# The following are necessary only for Cygwin, and only are needed
2740# when the user has tab-completed the executable name and consequently
2741# included the '.exe' suffix.
2742#
76c3eb51 2743if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
93b291e0 2744__git_complete git.exe __git_main
76c3eb51 2745fi