completion: split __git_ps1 into a separate script
[git.git] / contrib / completion / git-completion.bash
Commit [+]AuthorDateLineData
a42577d4 Ted Pavlic2009-01-15 11:02:23 -05001#!bash
690d8824 Junio C Hamano2006-09-28 02:31:25 -07002#
b5a49471 Marius Storm-Olsen2011-04-26 22:23:35 -05003# bash/zsh completion support for core Git.
690d8824 Junio C Hamano2006-09-28 02:31:25 -07004#
c70680ce Shawn O. Pearce2007-05-24 01:36:46 -04005# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
690d8824 Junio C Hamano2006-09-28 02:31:25 -07006# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
c70680ce Shawn O. Pearce2007-05-24 01:36:46 -04007# Distributed under the GNU General Public License, version 2.0.
690d8824
JH
Junio C Hamano2006-09-28 02:31:25 -07008#
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 Shawn O. Pearce2007-05-24 01:36:46 -040016# *) common --long-options
690d8824
JH
Junio C Hamano2006-09-28 02:31:25 -070017#
18# To use these routines:
19#
20# 1) Copy this file to somewhere (e.g. ~/.git-completion.sh).
b5a49471 Marius Storm-Olsen2011-04-26 22:23:35 -050021# 2) Add the following line to your .bashrc/.zshrc:
06f44c3c Mark Lodato2010-09-06 08:33:19 -040022# source ~/.git-completion.sh
af31a456
FC
Felipe Contreras2012-05-22 22:46:40 +020023# 3) Consider changing your PS1 to also show the current branch,
24# see git-prompt.sh for details.
690d8824 Junio C Hamano2006-09-28 02:31:25 -070025
b5a49471
MSO
Marius Storm-Olsen2011-04-26 22:23:35 -050026if [[ -n ${ZSH_VERSION-} ]]; then
27 autoload -U +X bashcompinit && bashcompinit
28fi
29
db8a9ff0
SP
Shawn O. Pearce2008-07-15 05:52:04 +000030case "$COMP_WORDBREAKS" in
31*:*) : great ;;
32*) COMP_WORDBREAKS="$COMP_WORDBREAKS:"
33esac
34
a42577d4
TP
Ted Pavlic2009-01-15 11:02:23 -050035# __gitdir accepts 0 or 1 arguments (i.e., location)
36# returns location of .git repo
873537fa
SP
Shawn O. Pearce2006-11-05 06:21:57 -050037__gitdir ()
38{
25a31f81 Ted Pavlic2009-01-15 11:02:21 -050039 if [ -z "${1-}" ]; then
5c9cc64a Ted Pavlic2009-02-11 13:03:26 -050040 if [ -n "${__git_dir-}" ]; then
67ffa114
SP
Shawn O. Pearce2006-11-28 12:12:26 -050041 echo "$__git_dir"
42 elif [ -d .git ]; then
43 echo .git
44 else
45 git rev-parse --git-dir 2>/dev/null
46 fi
47 elif [ -d "$1/.git" ]; then
48 echo "$1/.git"
49 else
50 echo "$1"
51 fi
873537fa
SP
Shawn O. Pearce2006-11-05 06:21:57 -050052}
53
ab02dfe5
SP
Shawn O. Pearce2008-07-13 02:37:42 +000054__gitcomp_1 ()
55{
3bf421ea Felipe Contreras2012-04-15 22:44:16 +030056 local c IFS=$' \t\n'
ab02dfe5 Shawn O. Pearce2008-07-13 02:37:42 +000057 for c in $1; do
3bf421ea
FC
Felipe Contreras2012-04-15 22:44:16 +030058 c="$c$2"
59 case $c in
60 --*=*|*.) ;;
61 *) c="$c " ;;
ab02dfe5 Shawn O. Pearce2008-07-13 02:37:42 +000062 esac
3bf421ea Felipe Contreras2012-04-15 22:44:16 +030063 printf '%s\n' "$c"
ab02dfe5
SP
Shawn O. Pearce2008-07-13 02:37:42 +000064 done
65}
66
dbda3b10
JN
Jonathan Nieder2010-12-14 22:57:58 -060067# The following function is based on code from:
68#
69# bash_completion - programmable completion functions for bash 3.2+
70#
71# Copyright © 2006-2008, Ian Macdonald <ian@caliban.org>
72# © 2009-2010, Bash Completion Maintainers
73# <bash-completion-devel@lists.alioth.debian.org>
74#
75# This program is free software; you can redistribute it and/or modify
76# it under the terms of the GNU General Public License as published by
77# the Free Software Foundation; either version 2, or (at your option)
78# any later version.
79#
80# This program is distributed in the hope that it will be useful,
81# but WITHOUT ANY WARRANTY; without even the implied warranty of
82# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
83# GNU General Public License for more details.
84#
85# You should have received a copy of the GNU General Public License
86# along with this program; if not, write to the Free Software Foundation,
87# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
88#
89# The latest version of this software can be obtained here:
90#
91# http://bash-completion.alioth.debian.org/
92#
93# RELEASE: 2.x
94
95# This function can be used to access a tokenized list of words
96# on the command line:
97#
98# __git_reassemble_comp_words_by_ref '=:'
99# if test "${words_[cword_-1]}" = -w
100# then
101# ...
102# fi
103#
104# The argument should be a collection of characters from the list of
105# word completion separators (COMP_WORDBREAKS) to treat as ordinary
106# characters.
107#
108# This is roughly equivalent to going back in time and setting
109# COMP_WORDBREAKS to exclude those characters. The intent is to
110# make option types like --date=<type> and <rev>:<path> easy to
111# recognize by treating each shell word as a single token.
112#
113# It is best not to set COMP_WORDBREAKS directly because the value is
114# shared with other completion scripts. By the time the completion
115# function gets called, COMP_WORDS has already been populated so local
116# changes to COMP_WORDBREAKS have no effect.
117#
118# Output: words_, cword_, cur_.
119
120__git_reassemble_comp_words_by_ref()
121{
122 local exclude i j first
123 # Which word separators to exclude?
124 exclude="${1//[^$COMP_WORDBREAKS]}"
125 cword_=$COMP_CWORD
126 if [ -z "$exclude" ]; then
127 words_=("${COMP_WORDS[@]}")
128 return
129 fi
130 # List of word completion separators has shrunk;
131 # re-assemble words to complete.
132 for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)); do
133 # Append each nonempty word consisting of just
134 # word separator characters to the current word.
135 first=t
136 while
137 [ $i -gt 0 ] &&
138 [ -n "${COMP_WORDS[$i]}" ] &&
139 # word consists of excluded word separators
140 [ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ]
141 do
142 # Attach to the previous token,
143 # unless the previous token is the command name.
144 if [ $j -ge 2 ] && [ -n "$first" ]; then
145 ((j--))
146 fi
147 first=
148 words_[$j]=${words_[j]}${COMP_WORDS[i]}
149 if [ $i = $COMP_CWORD ]; then
150 cword_=$j
151 fi
152 if (($i < ${#COMP_WORDS[@]} - 1)); then
153 ((i++))
154 else
155 # Done.
156 return
157 fi
158 done
159 words_[$j]=${words_[j]}${COMP_WORDS[i]}
160 if [ $i = $COMP_CWORD ]; then
161 cword_=$j
162 fi
163 done
164}
165
da48616f Peter van der Does2010-12-02 02:17:13 -0600166if ! type _get_comp_words_by_ref >/dev/null 2>&1; then
52c9d8e2 Jonathan Nieder2010-12-15 00:05:33 -0600167if [[ -z ${ZSH_VERSION:+set} ]]; then
da48616f
PD
Peter van der Does2010-12-02 02:17:13 -0600168_get_comp_words_by_ref ()
169{
dbda3b10
JN
Jonathan Nieder2010-12-14 22:57:58 -0600170 local exclude cur_ words_ cword_
171 if [ "$1" = "-n" ]; then
172 exclude=$2
173 shift 2
174 fi
175 __git_reassemble_comp_words_by_ref "$exclude"
176 cur_=${words_[cword_]}
da48616f
PD
Peter van der Does2010-12-02 02:17:13 -0600177 while [ $# -gt 0 ]; do
178 case "$1" in
179 cur)
dbda3b10 Jonathan Nieder2010-12-14 22:57:58 -0600180 cur=$cur_
da48616f
PD
Peter van der Does2010-12-02 02:17:13 -0600181 ;;
182 prev)
dbda3b10 Jonathan Nieder2010-12-14 22:57:58 -0600183 prev=${words_[$cword_-1]}
da48616f
PD
Peter van der Does2010-12-02 02:17:13 -0600184 ;;
185 words)
dbda3b10 Jonathan Nieder2010-12-14 22:57:58 -0600186 words=("${words_[@]}")
da48616f
PD
Peter van der Does2010-12-02 02:17:13 -0600187 ;;
188 cword)
dbda3b10 Jonathan Nieder2010-12-14 22:57:58 -0600189 cword=$cword_
da48616f
PD
Peter van der Does2010-12-02 02:17:13 -0600190 ;;
191 esac
192 shift
193 done
194}
52c9d8e2
JN
Jonathan Nieder2010-12-15 00:05:33 -0600195else
196_get_comp_words_by_ref ()
197{
198 while [ $# -gt 0 ]; do
199 case "$1" in
200 cur)
201 cur=${COMP_WORDS[COMP_CWORD]}
202 ;;
203 prev)
204 prev=${COMP_WORDS[COMP_CWORD-1]}
205 ;;
206 words)
207 words=("${COMP_WORDS[@]}")
208 ;;
209 cword)
210 cword=$COMP_CWORD
211 ;;
212 -n)
213 # assume COMP_WORDBREAKS is already set sanely
214 shift
215 ;;
216 esac
217 shift
218 done
219}
220fi
da48616f
PD
Peter van der Does2010-12-02 02:17:13 -0600221fi
222
f674bb80
SG
SZEDER Gábor2011-10-08 16:54:35 +0200223# Generates completion reply with compgen, appending a space to possible
224# completion words, if necessary.
225# It accepts 1 to 4 arguments:
226# 1: List of possible completion words.
227# 2: A prefix to be added to each possible completion word (optional).
228# 3: Generate possible completion matches for this word (optional).
229# 4: A suffix to be appended to each possible completion word (optional).
72e5e989
SP
Shawn O. Pearce2007-02-04 02:38:27 -0500230__gitcomp ()
231{
583e4d57 Felipe Contreras2012-02-02 11:48:08 -0800232 local cur_="${3-$cur}"
9244d69b SZEDER Gábor2011-04-28 18:01:51 +0200233
9244d69b SZEDER Gábor2011-04-28 18:01:51 +0200234 case "$cur_" in
5447aac7
SG
SZEDER Gábor2008-03-05 20:07:49 +0100235 --*=)
236 COMPREPLY=()
5447aac7
SG
SZEDER Gábor2008-03-05 20:07:49 +0100237 ;;
238 *)
ab02dfe5 Shawn O. Pearce2008-07-13 02:37:42 +0000239 local IFS=$'\n'
25a31f81
TP
Ted Pavlic2009-01-15 11:02:21 -0500240 COMPREPLY=($(compgen -P "${2-}" \
241 -W "$(__gitcomp_1 "${1-}" "${4-}")" \
9244d69b SZEDER Gábor2011-04-28 18:01:51 +0200242 -- "$cur_"))
5447aac7
SG
SZEDER Gábor2008-03-05 20:07:49 +0100243 ;;
244 esac
72e5e989
SP
Shawn O. Pearce2007-02-04 02:38:27 -0500245}
246
a31e6262
SG
SZEDER Gábor2011-10-15 14:57:23 +0200247# Generates completion reply with compgen from newline-separated possible
248# completion words by appending a space to all of them.
249# It accepts 1 to 4 arguments:
250# 1: List of possible completion words, separated by a single newline.
251# 2: A prefix to be added to each possible completion word (optional).
252# 3: Generate possible completion matches for this word (optional).
253# 4: A suffix to be appended to each possible completion word instead of
254# the default space (optional). If specified but empty, nothing is
255# appended.
256__gitcomp_nl ()
257{
583e4d57
FC
Felipe Contreras2012-02-02 11:48:08 -0800258 local IFS=$'\n'
259 COMPREPLY=($(compgen -P "${2-}" -S "${4- }" -W "$1" -- "${3-$cur}"))
a31e6262
SG
SZEDER Gábor2011-10-15 14:57:23 +0200260}
261
5de40f59
SP
Shawn O. Pearce2006-11-27 04:44:47 -0500262__git_heads ()
263{
6486ca6d SZEDER Gábor2011-10-08 16:54:43 +0200264 local dir="$(__gitdir)"
5de40f59 Shawn O. Pearce2006-11-27 04:44:47 -0500265 if [ -d "$dir" ]; then
05e8b3d6
SG
SZEDER Gábor2008-09-20 00:15:25 +0200266 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
267 refs/heads
5de40f59
SP
Shawn O. Pearce2006-11-27 04:44:47 -0500268 return
269 fi
5de40f59
SP
Shawn O. Pearce2006-11-27 04:44:47 -0500270}
271
88e21dc7
SP
Shawn O. Pearce2007-08-31 23:47:01 -0400272__git_tags ()
273{
6486ca6d SZEDER Gábor2011-10-08 16:54:43 +0200274 local dir="$(__gitdir)"
88e21dc7 Shawn O. Pearce2007-08-31 23:47:01 -0400275 if [ -d "$dir" ]; then
05e8b3d6
SG
SZEDER Gábor2008-09-20 00:15:25 +0200276 git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
277 refs/tags
88e21dc7
SP
Shawn O. Pearce2007-08-31 23:47:01 -0400278 return
279 fi
88e21dc7
SP
Shawn O. Pearce2007-08-31 23:47:01 -0400280}
281
34a6bbb5
KB
Kevin Ballard2010-10-12 14:38:12 -0700282# __git_refs accepts 0, 1 (to pass to __gitdir), or 2 arguments
283# presence of 2nd argument means use the guess heuristic employed
284# by checkout for tracking branches
690d8824
JH
Junio C Hamano2006-09-28 02:31:25 -0700285__git_refs ()
286{
d8c0453e SZEDER Gábor2011-10-08 16:54:38 +0200287 local i hash dir="$(__gitdir "${1-}")" track="${2-}"
da4902a7 SZEDER Gábor2011-04-28 18:01:52 +0200288 local format refs
873537fa Shawn O. Pearce2006-11-05 06:21:57 -0500289 if [ -d "$dir" ]; then
608efb87
SG
SZEDER Gábor2008-11-28 01:46:38 +0100290 case "$cur" in
291 refs|refs/*)
292 format="refname"
293 refs="${cur%/*}"
34a6bbb5 Kevin Ballard2010-10-12 14:38:12 -0700294 track=""
608efb87
SG
SZEDER Gábor2008-11-28 01:46:38 +0100295 ;;
296 *)
d23e7570
IWC
Ian Ward Comfort2010-03-17 02:20:35 -0700297 for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do
298 if [ -e "$dir/$i" ]; then echo $i; fi
299 done
608efb87
SG
SZEDER Gábor2008-11-28 01:46:38 +0100300 format="refname:short"
301 refs="refs/tags refs/heads refs/remotes"
302 ;;
303 esac
304 git --git-dir="$dir" for-each-ref --format="%($format)" \
305 $refs
34a6bbb5
KB
Kevin Ballard2010-10-12 14:38:12 -0700306 if [ -n "$track" ]; then
307 # employ the heuristic used by git checkout
308 # Try to find a remote branch that matches the completion word
309 # but only output if the branch name is unique
310 local ref entry
311 git --git-dir="$dir" for-each-ref --shell --format="ref=%(refname:short)" \
312 "refs/remotes/" | \
6f2dd720 Thomas Rast2011-12-21 16:54:14 +0100313 while read -r entry; do
34a6bbb5
KB
Kevin Ballard2010-10-12 14:38:12 -0700314 eval "$entry"
315 ref="${ref#*/}"
316 if [[ "$ref" == "$cur"* ]]; then
317 echo "$ref"
318 fi
319 done | uniq -u
320 fi
35e65ecc Shawn O. Pearce2006-11-27 03:42:32 -0500321 return
690d8824 Junio C Hamano2006-09-28 02:31:25 -0700322 fi
fb772cca
SG
SZEDER Gábor2011-10-08 16:54:39 +0200323 case "$cur" in
324 refs|refs/*)
325 git ls-remote "$dir" "$cur*" 2>/dev/null | \
6f2dd720 Thomas Rast2011-12-21 16:54:14 +0100326 while read -r hash i; do
fb772cca
SG
SZEDER Gábor2011-10-08 16:54:39 +0200327 case "$i" in
328 *^{}) ;;
329 *) echo "$i" ;;
330 esac
331 done
332 ;;
333 *)
334 git ls-remote "$dir" HEAD ORIG_HEAD 'refs/tags/*' 'refs/heads/*' 'refs/remotes/*' 2>/dev/null | \
6f2dd720 Thomas Rast2011-12-21 16:54:14 +0100335 while read -r hash i; do
fb772cca
SG
SZEDER Gábor2011-10-08 16:54:39 +0200336 case "$i" in
337 *^{}) ;;
338 refs/*) echo "${i#refs/*/}" ;;
339 *) echo "$i" ;;
340 esac
341 done
342 ;;
343 esac
690d8824
JH
Junio C Hamano2006-09-28 02:31:25 -0700344}
345
a42577d4 Ted Pavlic2009-01-15 11:02:23 -0500346# __git_refs2 requires 1 argument (to pass to __git_refs)
690d8824
JH
Junio C Hamano2006-09-28 02:31:25 -0700347__git_refs2 ()
348{
67ffa114
SP
Shawn O. Pearce2006-11-28 12:12:26 -0500349 local i
350 for i in $(__git_refs "$1"); do
351 echo "$i:$i"
690d8824
JH
Junio C Hamano2006-09-28 02:31:25 -0700352 done
353}
354
a42577d4 Ted Pavlic2009-01-15 11:02:23 -0500355# __git_refs_remotes requires 1 argument (to pass to ls-remote)
5de40f59
SP
Shawn O. Pearce2006-11-27 04:44:47 -0500356__git_refs_remotes ()
357{
48058f5d
SG
SZEDER Gábor2011-10-08 16:54:41 +0200358 local i hash
359 git ls-remote "$1" 'refs/heads/*' 2>/dev/null | \
6f2dd720 Thomas Rast2011-12-21 16:54:14 +0100360 while read -r hash i; do
48058f5d SZEDER Gábor2011-10-08 16:54:41 +0200361 echo "$i:refs/remotes/$1/${i#refs/heads/}"
5de40f59
SP
Shawn O. Pearce2006-11-27 04:44:47 -0500362 done
363}
364
690d8824
JH
Junio C Hamano2006-09-28 02:31:25 -0700365__git_remotes ()
366{
d79f81ad
FC
Felipe Contreras2012-02-02 03:05:29 -0600367 local i IFS=$'\n' d="$(__gitdir)"
368 test -d "$d/remotes" && ls -1 "$d/remotes"
518ef8f0
TZ
Todd Zullinger2009-09-11 19:23:45 -0400369 for i in $(git --git-dir="$d" config --get-regexp 'remote\..*\.url' 2>/dev/null); do
370 i="${i#remote.}"
371 echo "${i/.url*/}"
56fc25f2 Shawn O. Pearce2006-11-05 06:21:03 -0500372 done
690d8824
JH
Junio C Hamano2006-09-28 02:31:25 -0700373}
374
eaa4e6ee Jonathan Nieder2009-11-17 18:49:10 -0600375__git_list_merge_strategies ()
4ad91321 Shawn O. Pearce2006-11-27 03:40:47 -0500376{
25b3d4d6
JH
Junio C Hamano2008-08-20 14:13:42 -0700377 git merge -s help 2>&1 |
378 sed -n -e '/[Aa]vailable strategies are: /,/^$/{
379 s/\.$//
380 s/.*://
381 s/^[ ]*//
382 s/[ ]*$//
4ad91321 Shawn O. Pearce2006-11-27 03:40:47 -0500383 p
25b3d4d6 Junio C Hamano2008-08-20 14:13:42 -0700384 }'
4ad91321 Shawn O. Pearce2006-11-27 03:40:47 -0500385}
eaa4e6ee
JN
Jonathan Nieder2009-11-17 18:49:10 -0600386
387__git_merge_strategies=
388# 'git merge -s help' (and thus detection of the merge strategy
389# list) fails, unfortunately, if run outside of any git working
390# tree. __git_merge_strategies is set to the empty string in
391# that case, and the detection will be repeated the next time it
392# is needed.
393__git_compute_merge_strategies ()
394{
cf0ff02a
FC
Felipe Contreras2012-02-02 11:26:15 -0800395 test -n "$__git_merge_strategies" ||
396 __git_merge_strategies=$(__git_list_merge_strategies)
eaa4e6ee Jonathan Nieder2009-11-17 18:49:10 -0600397}
4ad91321 Shawn O. Pearce2006-11-27 03:40:47 -0500398
1d66ec58 SZEDER Gábor2011-03-10 19:12:29 +0100399__git_complete_revlist_file ()
690d8824 Junio C Hamano2006-09-28 02:31:25 -0700400{
da4902a7 SZEDER Gábor2011-04-28 18:01:52 +0200401 local pfx ls ref cur_="$cur"
9244d69b SZEDER Gábor2011-04-28 18:01:51 +0200402 case "$cur_" in
1d66ec58
SG
SZEDER Gábor2011-03-10 19:12:29 +0100403 *..?*:*)
404 return
405 ;;
690d8824 Junio C Hamano2006-09-28 02:31:25 -0700406 ?*:*)
9244d69b
SG
SZEDER Gábor2011-04-28 18:01:51 +0200407 ref="${cur_%%:*}"
408 cur_="${cur_#*:}"
409 case "$cur_" in
690d8824 Junio C Hamano2006-09-28 02:31:25 -0700410 ?*/*)
9244d69b
SG
SZEDER Gábor2011-04-28 18:01:51 +0200411 pfx="${cur_%/*}"
412 cur_="${cur_##*/}"
690d8824
JH
Junio C Hamano2006-09-28 02:31:25 -0700413 ls="$ref:$pfx"
414 pfx="$pfx/"
415 ;;
416 *)
417 ls="$ref"
418 ;;
80152b09 SZEDER Gábor2011-03-10 19:12:28 +0100419 esac
db8a9ff0
SP
Shawn O. Pearce2008-07-15 05:52:04 +0000420
421 case "$COMP_WORDBREAKS" in
422 *:*) : great ;;
423 *) pfx="$ref:$pfx" ;;
424 esac
425
778306e4 Shawn O. Pearce2008-07-14 00:22:03 +0000426 local IFS=$'\n'
690d8824 Junio C Hamano2006-09-28 02:31:25 -0700427 COMPREPLY=($(compgen -P "$pfx" \
873537fa Shawn O. Pearce2006-11-05 06:21:57 -0500428 -W "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \
778306e4
SP
Shawn O. Pearce2008-07-14 00:22:03 +0000429 | sed '/^100... blob /{
430 s,^.* ,,
431 s,$, ,
432 }
433 /^120000 blob /{
434 s,^.* ,,
435 s,$, ,
436 }
690d8824
JH
Junio C Hamano2006-09-28 02:31:25 -0700437 /^040000 tree /{
438 s,^.* ,,
439 s,$,/,
440 }
441 s/^.* //')" \
9244d69b SZEDER Gábor2011-04-28 18:01:51 +0200442 -- "$cur_"))
690d8824 Junio C Hamano2006-09-28 02:31:25 -0700443 ;;
f53352fb Shawn O. Pearce2006-11-27 03:41:43 -0500444 *...*)
9244d69b
SG
SZEDER Gábor2011-04-28 18:01:51 +0200445 pfx="${cur_%...*}..."
446 cur_="${cur_#*...}"
a31e6262 SZEDER Gábor2011-10-15 14:57:23 +0200447 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
f53352fb
SP
Shawn O. Pearce2006-11-27 03:41:43 -0500448 ;;
449 *..*)
9244d69b
SG
SZEDER Gábor2011-04-28 18:01:51 +0200450 pfx="${cur_%..*}.."
451 cur_="${cur_#*..}"
a31e6262 SZEDER Gábor2011-10-15 14:57:23 +0200452 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
b3391775 Shawn O. Pearce2007-02-04 02:38:43 -0500453 ;;
f53352fb Shawn O. Pearce2006-11-27 03:41:43 -0500454 *)
a31e6262 SZEDER Gábor2011-10-15 14:57:23 +0200455 __gitcomp_nl "$(__git_refs)"
f53352fb
SP
Shawn O. Pearce2006-11-27 03:41:43 -0500456 ;;
457 esac
458}
459
1d66ec58
SG
SZEDER Gábor2011-03-10 19:12:29 +0100460
461__git_complete_file ()
462{
463 __git_complete_revlist_file
464}
465
466__git_complete_revlist ()
467{
468 __git_complete_revlist_file
469}
470
52d5c3b5
JS
Jay Soffian2009-03-05 23:39:31 -0500471__git_complete_remote_or_refspec ()
472{
9244d69b SZEDER Gábor2011-04-28 18:01:51 +0200473 local cur_="$cur" cmd="${words[1]}"
0a4e1472 Jay Soffian2009-03-05 23:39:33 -0500474 local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0
f1c6ffe6 Philip Jägenstedt2012-02-22 09:58:10 +0100475 if [ "$cmd" = "remote" ]; then
6e8c755f Philip Jägenstedt2012-02-22 09:58:11 +0100476 ((c++))
f1c6ffe6 Philip Jägenstedt2012-02-22 09:58:10 +0100477 fi
da48616f
PD
Peter van der Does2010-12-02 02:17:13 -0600478 while [ $c -lt $cword ]; do
479 i="${words[c]}"
52d5c3b5 Jay Soffian2009-03-05 23:39:31 -0500480 case "$i" in
e25e2b42
BG
Björn Gustavsson2009-12-12 11:21:46 +0100481 --mirror) [ "$cmd" = "push" ] && no_complete_refspec=1 ;;
482 --all)
483 case "$cmd" in
484 push) no_complete_refspec=1 ;;
485 fetch)
486 COMPREPLY=()
487 return
488 ;;
489 *) ;;
490 esac
491 ;;
52d5c3b5
JS
Jay Soffian2009-03-05 23:39:31 -0500492 -*) ;;
493 *) remote="$i"; break ;;
494 esac
6e8c755f Philip Jägenstedt2012-02-22 09:58:11 +0100495 ((c++))
52d5c3b5
JS
Jay Soffian2009-03-05 23:39:31 -0500496 done
497 if [ -z "$remote" ]; then
a31e6262 SZEDER Gábor2011-10-15 14:57:23 +0200498 __gitcomp_nl "$(__git_remotes)"
52d5c3b5
JS
Jay Soffian2009-03-05 23:39:31 -0500499 return
500 fi
0a4e1472
JS
Jay Soffian2009-03-05 23:39:33 -0500501 if [ $no_complete_refspec = 1 ]; then
502 COMPREPLY=()
503 return
504 fi
52d5c3b5 Jay Soffian2009-03-05 23:39:31 -0500505 [ "$remote" = "." ] && remote=
9244d69b SZEDER Gábor2011-04-28 18:01:51 +0200506 case "$cur_" in
52d5c3b5
JS
Jay Soffian2009-03-05 23:39:31 -0500507 *:*)
508 case "$COMP_WORDBREAKS" in
509 *:*) : great ;;
9244d69b SZEDER Gábor2011-04-28 18:01:51 +0200510 *) pfx="${cur_%%:*}:" ;;
52d5c3b5 Jay Soffian2009-03-05 23:39:31 -0500511 esac
9244d69b SZEDER Gábor2011-04-28 18:01:51 +0200512 cur_="${cur_#*:}"
52d5c3b5
JS
Jay Soffian2009-03-05 23:39:31 -0500513 lhs=0
514 ;;
515 +*)
516 pfx="+"
9244d69b SZEDER Gábor2011-04-28 18:01:51 +0200517 cur_="${cur_#+}"
52d5c3b5
JS
Jay Soffian2009-03-05 23:39:31 -0500518 ;;
519 esac
520 case "$cmd" in
521 fetch)
522 if [ $lhs = 1 ]; then
a31e6262 SZEDER Gábor2011-10-15 14:57:23 +0200523 __gitcomp_nl "$(__git_refs2 "$remote")" "$pfx" "$cur_"
52d5c3b5 Jay Soffian2009-03-05 23:39:31 -0500524 else
a31e6262 SZEDER Gábor2011-10-15 14:57:23 +0200525 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
52d5c3b5
JS
Jay Soffian2009-03-05 23:39:31 -0500526 fi
527 ;;
f1c6ffe6 Philip Jägenstedt2012-02-22 09:58:10 +0100528 pull|remote)
52d5c3b5 Jay Soffian2009-03-05 23:39:31 -0500529 if [ $lhs = 1 ]; then
a31e6262 SZEDER Gábor2011-10-15 14:57:23 +0200530 __gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_"
52d5c3b5 Jay Soffian2009-03-05 23:39:31 -0500531 else
a31e6262 SZEDER Gábor2011-10-15 14:57:23 +0200532 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
52d5c3b5
JS
Jay Soffian2009-03-05 23:39:31 -0500533 fi
534 ;;
535 push)
536 if [ $lhs = 1 ]; then
a31e6262 SZEDER Gábor2011-10-15 14:57:23 +0200537 __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"
52d5c3b5 Jay Soffian2009-03-05 23:39:31 -0500538 else
a31e6262 SZEDER Gábor2011-10-15 14:57:23 +0200539 __gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_"
52d5c3b5
JS
Jay Soffian2009-03-05 23:39:31 -0500540 fi
541 ;;
542 esac
543}
544
3c7b480a
JS
Jay Soffian2009-03-06 11:30:44 -0500545__git_complete_strategy ()
546{
eaa4e6ee Jonathan Nieder2009-11-17 18:49:10 -0600547 __git_compute_merge_strategies
da48616f Peter van der Does2010-12-02 02:17:13 -0600548 case "$prev" in
3c7b480a Jay Soffian2009-03-06 11:30:44 -0500549 -s|--strategy)
eaa4e6ee Jonathan Nieder2009-11-17 18:49:10 -0600550 __gitcomp "$__git_merge_strategies"
3c7b480a
JS
Jay Soffian2009-03-06 11:30:44 -0500551 return 0
552 esac
3c7b480a
JS
Jay Soffian2009-03-06 11:30:44 -0500553 case "$cur" in
554 --strategy=*)
eaa4e6ee Jonathan Nieder2009-11-17 18:49:10 -0600555 __gitcomp "$__git_merge_strategies" "" "${cur##--strategy=}"
3c7b480a
JS
Jay Soffian2009-03-06 11:30:44 -0500556 return 0
557 ;;
558 esac
559 return 1
560}
561
eaa4e6ee Jonathan Nieder2009-11-17 18:49:10 -0600562__git_list_all_commands ()
f2bb9f88
SP
Shawn O. Pearce2006-11-27 03:41:01 -0500563{
564 local i IFS=" "$'\n'
427e586b Stephen Boyd2009-10-08 23:21:43 -0700565 for i in $(git help -a|egrep '^ [a-zA-Z0-9]')
f2bb9f88
SP
Shawn O. Pearce2006-11-27 03:41:01 -0500566 do
567 case $i in
718a087a Jeff King2007-12-15 06:11:54 -0500568 *--*) : helper pattern;;
1eb7e2f8
LM
Lee Marlow2008-07-23 18:07:23 -0600569 *) echo $i;;
570 esac
571 done
572}
1eb7e2f8 Lee Marlow2008-07-23 18:07:23 -0600573
eaa4e6ee
JN
Jonathan Nieder2009-11-17 18:49:10 -0600574__git_all_commands=
575__git_compute_all_commands ()
576{
cf0ff02a
FC
Felipe Contreras2012-02-02 11:26:15 -0800577 test -n "$__git_all_commands" ||
578 __git_all_commands=$(__git_list_all_commands)
eaa4e6ee
JN
Jonathan Nieder2009-11-17 18:49:10 -0600579}
580
581__git_list_porcelain_commands ()
1eb7e2f8 Lee Marlow2008-07-23 18:07:23 -0600582{
1eb7e2f8 Lee Marlow2008-07-23 18:07:23 -0600583 local i IFS=" "$'\n'
eaa4e6ee
JN
Jonathan Nieder2009-11-17 18:49:10 -0600584 __git_compute_all_commands
585 for i in "help" $__git_all_commands
1eb7e2f8
LM
Lee Marlow2008-07-23 18:07:23 -0600586 do
587 case $i in
588 *--*) : helper pattern;;
a925c6f1
SP
Shawn O. Pearce2007-02-04 02:38:30 -0500589 applymbox) : ask gittus;;
590 applypatch) : ask gittus;;
591 archimport) : import;;
2e3a430a Shawn O. Pearce2007-02-04 02:38:21 -0500592 cat-file) : plumbing;;
56d99c67 Jonas Fonseca2007-05-19 23:35:21 +0200593 check-attr) : plumbing;;
f2bb9f88 Shawn O. Pearce2006-11-27 03:41:01 -0500594 check-ref-format) : plumbing;;
ff2549dc Petr Baudis2008-08-26 19:11:44 +0200595 checkout-index) : plumbing;;
f2bb9f88 Shawn O. Pearce2006-11-27 03:41:01 -0500596 commit-tree) : plumbing;;
ff2549dc Petr Baudis2008-08-26 19:11:44 +0200597 count-objects) : infrequent;;
a925c6f1
SP
Shawn O. Pearce2007-02-04 02:38:30 -0500598 cvsexportcommit) : export;;
599 cvsimport) : import;;
f2bb9f88
SP
Shawn O. Pearce2006-11-27 03:41:01 -0500600 cvsserver) : daemon;;
601 daemon) : daemon;;
5cfb4fe5
SP
Shawn O. Pearce2007-05-24 01:01:02 -0400602 diff-files) : plumbing;;
603 diff-index) : plumbing;;
604 diff-tree) : plumbing;;
c6ec3b13 Shawn O. Pearce2007-02-11 19:55:22 -0500605 fast-import) : import;;
ff2549dc Petr Baudis2008-08-26 19:11:44 +0200606 fast-export) : export;;
a925c6f1 Shawn O. Pearce2007-02-04 02:38:30 -0500607 fsck-objects) : plumbing;;
f2bb9f88 Shawn O. Pearce2006-11-27 03:41:01 -0500608 fetch-pack) : plumbing;;
a925c6f1 Shawn O. Pearce2007-02-04 02:38:30 -0500609 fmt-merge-msg) : plumbing;;
56d99c67 Jonas Fonseca2007-05-19 23:35:21 +0200610 for-each-ref) : plumbing;;
f2bb9f88
SP
Shawn O. Pearce2006-11-27 03:41:01 -0500611 hash-object) : plumbing;;
612 http-*) : transport;;
613 index-pack) : plumbing;;
a925c6f1 Shawn O. Pearce2007-02-04 02:38:30 -0500614 init-db) : deprecated;;
f2bb9f88 Shawn O. Pearce2006-11-27 03:41:01 -0500615 local-fetch) : plumbing;;
ff2549dc
PB
Petr Baudis2008-08-26 19:11:44 +0200616 lost-found) : infrequent;;
617 ls-files) : plumbing;;
618 ls-remote) : plumbing;;
619 ls-tree) : plumbing;;
f2bb9f88
SP
Shawn O. Pearce2006-11-27 03:41:01 -0500620 mailinfo) : plumbing;;
621 mailsplit) : plumbing;;
622 merge-*) : plumbing;;
623 mktree) : plumbing;;
624 mktag) : plumbing;;
625 pack-objects) : plumbing;;
626 pack-redundant) : plumbing;;
627 pack-refs) : plumbing;;
628 parse-remote) : plumbing;;
629 patch-id) : plumbing;;
630 peek-remote) : plumbing;;
a925c6f1
SP
Shawn O. Pearce2007-02-04 02:38:30 -0500631 prune) : plumbing;;
632 prune-packed) : plumbing;;
633 quiltimport) : import;;
f2bb9f88
SP
Shawn O. Pearce2006-11-27 03:41:01 -0500634 read-tree) : plumbing;;
635 receive-pack) : plumbing;;
63d04a78 SZEDER Gábor2010-01-22 11:54:51 +0100636 remote-*) : transport;;
5c66d0d4 Junio C Hamano2008-01-17 22:52:40 -0800637 repo-config) : deprecated;;
f2bb9f88
SP
Shawn O. Pearce2006-11-27 03:41:01 -0500638 rerere) : plumbing;;
639 rev-list) : plumbing;;
640 rev-parse) : plumbing;;
641 runstatus) : plumbing;;
642 sh-setup) : internal;;
643 shell) : daemon;;
ff2549dc Petr Baudis2008-08-26 19:11:44 +0200644 show-ref) : plumbing;;
f2bb9f88
SP
Shawn O. Pearce2006-11-27 03:41:01 -0500645 send-pack) : plumbing;;
646 show-index) : plumbing;;
647 ssh-*) : transport;;
648 stripspace) : plumbing;;
649 symbolic-ref) : plumbing;;
a925c6f1 Shawn O. Pearce2007-02-04 02:38:30 -0500650 tar-tree) : deprecated;;
f2bb9f88
SP
Shawn O. Pearce2006-11-27 03:41:01 -0500651 unpack-file) : plumbing;;
652 unpack-objects) : plumbing;;
a925c6f1 Shawn O. Pearce2007-02-04 02:38:30 -0500653 update-index) : plumbing;;
f2bb9f88
SP
Shawn O. Pearce2006-11-27 03:41:01 -0500654 update-ref) : plumbing;;
655 update-server-info) : daemon;;
656 upload-archive) : plumbing;;
657 upload-pack) : plumbing;;
658 write-tree) : plumbing;;
ff2549dc
PB
Petr Baudis2008-08-26 19:11:44 +0200659 var) : infrequent;;
660 verify-pack) : infrequent;;
a925c6f1 Shawn O. Pearce2007-02-04 02:38:30 -0500661 verify-tag) : plumbing;;
f2bb9f88
SP
Shawn O. Pearce2006-11-27 03:41:01 -0500662 *) echo $i;;
663 esac
664 done
665}
eaa4e6ee
JN
Jonathan Nieder2009-11-17 18:49:10 -0600666
667__git_porcelain_commands=
668__git_compute_porcelain_commands ()
669{
670 __git_compute_all_commands
cf0ff02a
FC
Felipe Contreras2012-02-02 11:26:15 -0800671 test -n "$__git_porcelain_commands" ||
672 __git_porcelain_commands=$(__git_list_porcelain_commands)
eaa4e6ee Jonathan Nieder2009-11-17 18:49:10 -0600673}
f2bb9f88 Shawn O. Pearce2006-11-27 03:41:01 -0500674
c3898111
SG
SZEDER Gábor2010-10-11 00:06:22 +0200675__git_pretty_aliases ()
676{
677 local i IFS=$'\n'
678 for i in $(git --git-dir="$(__gitdir)" config --get-regexp "pretty\..*" 2>/dev/null); do
679 case "$i" in
680 pretty.*)
681 i="${i#pretty.}"
682 echo "${i/ */}"
683 ;;
684 esac
685 done
686}
687
367dce2a
DS
Dennis Stosberg2006-10-28 14:12:20 +0200688__git_aliases ()
689{
56fc25f2 Shawn O. Pearce2006-11-05 06:21:03 -0500690 local i IFS=$'\n'
518ef8f0 Todd Zullinger2009-09-11 19:23:45 -0400691 for i in $(git --git-dir="$(__gitdir)" config --get-regexp "alias\..*" 2>/dev/null); do
e0d78059
SB
Stephen Boyd2009-10-08 23:21:44 -0700692 case "$i" in
693 alias.*)
694 i="${i#alias.}"
695 echo "${i/ */}"
696 ;;
697 esac
56fc25f2 Shawn O. Pearce2006-11-05 06:21:03 -0500698 done
367dce2a
DS
Dennis Stosberg2006-10-28 14:12:20 +0200699}
700
a42577d4 Ted Pavlic2009-01-15 11:02:23 -0500701# __git_aliased_command requires 1 argument
367dce2a
DS
Dennis Stosberg2006-10-28 14:12:20 +0200702__git_aliased_command ()
703{
873537fa Shawn O. Pearce2006-11-05 06:21:57 -0500704 local word cmdline=$(git --git-dir="$(__gitdir)" \
e0d10e1c Tom Prince2007-01-28 16:16:53 -0800705 config --get "alias.$1")
367dce2a Dennis Stosberg2006-10-28 14:12:20 +0200706 for word in $cmdline; do
c63437cb SZEDER Gábor2010-02-23 22:02:57 +0100707 case "$word" in
66729509
SG
SZEDER Gábor2010-02-23 22:03:00 +0100708 \!gitk|gitk)
709 echo "gitk"
367dce2a Dennis Stosberg2006-10-28 14:12:20 +0200710 return
66729509 SZEDER Gábor2010-02-23 22:03:00 +0100711 ;;
c63437cb
SG
SZEDER Gábor2010-02-23 22:02:57 +0100712 \!*) : shell command alias ;;
713 -*) : option ;;
714 *=*) : setting env ;;
715 git) : git itself ;;
716 *)
717 echo "$word"
367dce2a Dennis Stosberg2006-10-28 14:12:20 +0200718 return
c63437cb SZEDER Gábor2010-02-23 22:02:57 +0100719 esac
367dce2a
DS
Dennis Stosberg2006-10-28 14:12:20 +0200720 done
721}
722
918c03c2
SG
SZEDER Gábor2009-09-15 12:21:43 +0200723# __git_find_on_cmdline requires 1 argument
724__git_find_on_cmdline ()
3ff1320d SZEDER Gábor2008-03-10 16:02:23 +0100725{
da4902a7 SZEDER Gábor2011-04-28 18:01:52 +0200726 local word subcommand c=1
da48616f
PD
Peter van der Does2010-12-02 02:17:13 -0600727 while [ $c -lt $cword ]; do
728 word="${words[c]}"
3ff1320d
SG
SZEDER Gábor2008-03-10 16:02:23 +0100729 for subcommand in $1; do
730 if [ "$subcommand" = "$word" ]; then
731 echo "$subcommand"
732 return
733 fi
734 done
6e8c755f Philip Jägenstedt2012-02-22 09:58:11 +0100735 ((c++))
3ff1320d
SG
SZEDER Gábor2008-03-10 16:02:23 +0100736 done
737}
738
d773c631
SG
SZEDER Gábor2008-07-08 18:56:14 +0200739__git_has_doubledash ()
740{
da4902a7 SZEDER Gábor2011-04-28 18:01:52 +0200741 local c=1
da48616f
PD
Peter van der Does2010-12-02 02:17:13 -0600742 while [ $c -lt $cword ]; do
743 if [ "--" = "${words[c]}" ]; then
d773c631
SG
SZEDER Gábor2008-07-08 18:56:14 +0200744 return 0
745 fi
6e8c755f Philip Jägenstedt2012-02-22 09:58:11 +0100746 ((c++))
d773c631
SG
SZEDER Gábor2008-07-08 18:56:14 +0200747 done
748 return 1
749}
750
7950659d Eric Raible2008-08-14 10:12:54 -0700751__git_whitespacelist="nowarn warn error error-all fix"
88329195
SP
Shawn O. Pearce2006-11-27 15:12:03 -0500752
753_git_am ()
754{
da4902a7 SZEDER Gábor2011-04-28 18:01:52 +0200755 local dir="$(__gitdir)"
51ef1daa Johannes Schindelin2008-07-21 12:51:02 +0200756 if [ -d "$dir"/rebase-apply ]; then
85f6b439 SZEDER Gábor2010-02-12 15:11:47 +0100757 __gitcomp "--skip --continue --resolved --abort"
88329195
SP
Shawn O. Pearce2006-11-27 15:12:03 -0500758 return
759 fi
760 case "$cur" in
761 --whitespace=*)
b3391775 Shawn O. Pearce2007-02-04 02:38:43 -0500762 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
88329195
SP
Shawn O. Pearce2006-11-27 15:12:03 -0500763 return
764 ;;
765 --*)
b3391775 Shawn O. Pearce2007-02-04 02:38:43 -0500766 __gitcomp "
43acdf24 Todd Zullinger2009-04-05 12:33:38 -0400767 --3way --committer-date-is-author-date --ignore-date
86c91f91 Giuseppe Bilotta2009-08-04 13:16:49 +0200768 --ignore-whitespace --ignore-space-change
43acdf24 Todd Zullinger2009-04-05 12:33:38 -0400769 --interactive --keep --no-utf8 --signoff --utf8
af4e9e8c Stephen Boyd2009-10-07 01:48:50 -0700770 --whitespace= --scissors
b3391775 Shawn O. Pearce2007-02-04 02:38:43 -0500771 "
88329195
SP
Shawn O. Pearce2006-11-27 15:12:03 -0500772 return
773 esac
774 COMPREPLY=()
775}
776
777_git_apply ()
778{
88329195
SP
Shawn O. Pearce2006-11-27 15:12:03 -0500779 case "$cur" in
780 --whitespace=*)
b3391775 Shawn O. Pearce2007-02-04 02:38:43 -0500781 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
88329195
SP
Shawn O. Pearce2006-11-27 15:12:03 -0500782 return
783 ;;
784 --*)
b3391775 Shawn O. Pearce2007-02-04 02:38:43 -0500785 __gitcomp "
88329195
SP
Shawn O. Pearce2006-11-27 15:12:03 -0500786 --stat --numstat --summary --check --index
787 --cached --index-info --reverse --reject --unidiff-zero
788 --apply --no-add --exclude=
86c91f91 Giuseppe Bilotta2009-08-04 13:16:49 +0200789 --ignore-whitespace --ignore-space-change
88329195 Shawn O. Pearce2006-11-27 15:12:03 -0500790 --whitespace= --inaccurate-eof --verbose
b3391775 Shawn O. Pearce2007-02-04 02:38:43 -0500791 "
88329195
SP
Shawn O. Pearce2006-11-27 15:12:03 -0500792 return
793 esac
794 COMPREPLY=()
795}
796
8435b548
SP
Shawn O. Pearce2007-02-04 02:38:23 -0500797_git_add ()
798{
d773c631
SG
SZEDER Gábor2008-07-08 18:56:14 +0200799 __git_has_doubledash && return
800
8435b548
SP
Shawn O. Pearce2007-02-04 02:38:23 -0500801 case "$cur" in
802 --*)
1d284cba
SG
SZEDER Gábor2008-06-14 11:48:01 +0200803 __gitcomp "
804 --interactive --refresh --patch --update --dry-run
c9a114b5 Lee Marlow2008-12-10 12:39:17 -0700805 --ignore-errors --intent-to-add
1d284cba SZEDER Gábor2008-06-14 11:48:01 +0200806 "
8435b548
SP
Shawn O. Pearce2007-02-04 02:38:23 -0500807 return
808 esac
809 COMPREPLY=()
810}
811
b3191ce2
LM
Lee Marlow2008-08-04 23:50:36 -0600812_git_archive ()
813{
b3191ce2
LM
Lee Marlow2008-08-04 23:50:36 -0600814 case "$cur" in
815 --format=*)
816 __gitcomp "$(git archive --list)" "" "${cur##--format=}"
817 return
818 ;;
819 --remote=*)
a31e6262 SZEDER Gábor2011-10-15 14:57:23 +0200820 __gitcomp_nl "$(__git_remotes)" "" "${cur##--remote=}"
b3191ce2
LM
Lee Marlow2008-08-04 23:50:36 -0600821 return
822 ;;
823 --*)
824 __gitcomp "
825 --format= --list --verbose
826 --prefix= --remote= --exec=
827 "
828 return
829 ;;
830 esac
831 __git_complete_file
832}
833
b2e69f62
SP
Shawn O. Pearce2007-02-05 15:44:37 -0500834_git_bisect ()
835{
d773c631
SG
SZEDER Gábor2008-07-08 18:56:14 +0200836 __git_has_doubledash && return
837
bf11d461 Dmitry Potapov2008-07-02 17:29:50 +0400838 local subcommands="start bad good skip reset visualize replay log run"
918c03c2 SZEDER Gábor2009-09-15 12:21:43 +0200839 local subcommand="$(__git_find_on_cmdline "$subcommands")"
3ff1320d SZEDER Gábor2008-03-10 16:02:23 +0100840 if [ -z "$subcommand" ]; then
128191f5
SG
SZEDER Gábor2010-10-10 23:39:34 +0200841 if [ -f "$(__gitdir)"/BISECT_START ]; then
842 __gitcomp "$subcommands"
843 else
844 __gitcomp "replay start"
845 fi
b2e69f62
SP
Shawn O. Pearce2007-02-05 15:44:37 -0500846 return
847 fi
848
3ff1320d SZEDER Gábor2008-03-10 16:02:23 +0100849 case "$subcommand" in
8205ff8e SZEDER Gábor2010-10-10 23:39:33 +0200850 bad|good|reset|skip|start)
a31e6262 SZEDER Gábor2011-10-15 14:57:23 +0200851 __gitcomp_nl "$(__git_refs)"
b2e69f62
SP
Shawn O. Pearce2007-02-05 15:44:37 -0500852 ;;
853 *)
854 COMPREPLY=()
855 ;;
856 esac
857}
858
690d8824
JH
Junio C Hamano2006-09-28 02:31:25 -0700859_git_branch ()
860{
da4902a7 SZEDER Gábor2011-04-28 18:01:52 +0200861 local i c=1 only_local_ref="n" has_r="n"
b9217642 SZEDER Gábor2008-03-04 19:00:59 +0100862
da48616f
PD
Peter van der Does2010-12-02 02:17:13 -0600863 while [ $c -lt $cword ]; do
864 i="${words[c]}"
b9217642
SG
SZEDER Gábor2008-03-04 19:00:59 +0100865 case "$i" in
866 -d|-m) only_local_ref="y" ;;
867 -r) has_r="y" ;;
868 esac
6e8c755f Philip Jägenstedt2012-02-22 09:58:11 +0100869 ((c++))
b9217642
SG
SZEDER Gábor2008-03-04 19:00:59 +0100870 done
871
da48616f Peter van der Does2010-12-02 02:17:13 -0600872 case "$cur" in
3b376b0c
SG
SZEDER Gábor2008-03-04 19:00:58 +0100873 --*)
874 __gitcomp "
875 --color --no-color --verbose --abbrev= --no-abbrev
50e61025 Eric Raible2008-07-07 13:41:54 -0700876 --track --no-track --contains --merged --no-merged
a7fab08b Ralf Thielow2012-02-15 21:36:58 +0100877 --set-upstream --edit-description --list
3b376b0c
SG
SZEDER Gábor2008-03-04 19:00:58 +0100878 "
879 ;;
b9217642
SG
SZEDER Gábor2008-03-04 19:00:59 +0100880 *)
881 if [ $only_local_ref = "y" -a $has_r = "n" ]; then
a31e6262 SZEDER Gábor2011-10-15 14:57:23 +0200882 __gitcomp_nl "$(__git_heads)"
b9217642 SZEDER Gábor2008-03-04 19:00:59 +0100883 else
a31e6262 SZEDER Gábor2011-10-15 14:57:23 +0200884 __gitcomp_nl "$(__git_refs)"
b9217642
SG
SZEDER Gábor2008-03-04 19:00:59 +0100885 fi
886 ;;
3b376b0c SZEDER Gábor2008-03-04 19:00:58 +0100887 esac
690d8824
JH
Junio C Hamano2006-09-28 02:31:25 -0700888}
889
374a58c9
ML
Mark Levedahl2007-08-12 14:46:12 -0400890_git_bundle ()
891{
da48616f
PD
Peter van der Does2010-12-02 02:17:13 -0600892 local cmd="${words[2]}"
893 case "$cword" in
8d8163f3 SZEDER Gábor2008-11-27 14:35:38 +0100894 2)
374a58c9
ML
Mark Levedahl2007-08-12 14:46:12 -0400895 __gitcomp "create list-heads verify unbundle"
896 ;;
8d8163f3 SZEDER Gábor2008-11-27 14:35:38 +0100897 3)
374a58c9
ML
Mark Levedahl2007-08-12 14:46:12 -0400898 # looking for a file
899 ;;
900 *)
901 case "$cmd" in
902 create)
903 __git_complete_revlist
904 ;;
905 esac
906 ;;
907 esac
908}
909
690d8824
JH
Junio C Hamano2006-09-28 02:31:25 -0700910_git_checkout ()
911{
c84bb14c
SG
SZEDER Gábor2008-07-23 13:49:22 +0200912 __git_has_doubledash && return
913
e648f8b6
SG
SZEDER Gábor2009-09-24 14:23:15 +0200914 case "$cur" in
915 --conflict=*)
916 __gitcomp "diff3 merge" "" "${cur##--conflict=}"
917 ;;
918 --*)
919 __gitcomp "
920 --quiet --ours --theirs --track --no-track --merge
86e8e7a5 Erick Mattos2010-05-21 21:43:52 -0300921 --conflict= --orphan --patch
e648f8b6
SG
SZEDER Gábor2009-09-24 14:23:15 +0200922 "
923 ;;
924 *)
34a6bbb5
KB
Kevin Ballard2010-10-12 14:38:12 -0700925 # check if --track, --no-track, or --no-guess was specified
926 # if so, disable DWIM mode
927 local flags="--track --no-track --no-guess" track=1
928 if [ -n "$(__git_find_on_cmdline "$flags")" ]; then
929 track=''
930 fi
a31e6262 SZEDER Gábor2011-10-15 14:57:23 +0200931 __gitcomp_nl "$(__git_refs '' $track)"
e648f8b6
SG
SZEDER Gábor2009-09-24 14:23:15 +0200932 ;;
933 esac
690d8824
JH
Junio C Hamano2006-09-28 02:31:25 -0700934}
935
d8a9fea5
SP
Shawn O. Pearce2007-02-05 15:44:22 -0500936_git_cherry ()
937{
938 __gitcomp "$(__git_refs)"
939}
940
1273231e
SP
Shawn O. Pearce2006-11-27 03:41:59 -0500941_git_cherry_pick ()
942{
1273231e
SP
Shawn O. Pearce2006-11-27 03:41:59 -0500943 case "$cur" in
944 --*)
b3391775 Shawn O. Pearce2007-02-04 02:38:43 -0500945 __gitcomp "--edit --no-commit"
1273231e
SP
Shawn O. Pearce2006-11-27 03:41:59 -0500946 ;;
947 *)
a31e6262 SZEDER Gábor2011-10-15 14:57:23 +0200948 __gitcomp_nl "$(__git_refs)"
1273231e
SP
Shawn O. Pearce2006-11-27 03:41:59 -0500949 ;;
950 esac
951}
952
4181c7e8
LM
Lee Marlow2008-08-04 23:50:32 -0600953_git_clean ()
954{
955 __git_has_doubledash && return
956
4181c7e8
LM
Lee Marlow2008-08-04 23:50:32 -0600957 case "$cur" in
958 --*)
959 __gitcomp "--dry-run --quiet"
960 return
961 ;;
962 esac
963 COMPREPLY=()
964}
965
3eb11012
LM
Lee Marlow2008-08-04 23:50:31 -0600966_git_clone ()
967{
3eb11012
LM
Lee Marlow2008-08-04 23:50:31 -0600968 case "$cur" in
969 --*)
970 __gitcomp "
971 --local
972 --no-hardlinks
973 --shared
974 --reference
975 --quiet
976 --no-checkout
977 --bare
978 --mirror
979 --origin
980 --upload-pack
981 --template=
982 --depth
983 "
984 return
985 ;;
986 esac
987 COMPREPLY=()
988}
989
4548e855
SP
Shawn O. Pearce2006-11-28 12:12:08 -0500990_git_commit ()
991{
d773c631
SG
SZEDER Gábor2008-07-08 18:56:14 +0200992 __git_has_doubledash && return
993
4548e855 Shawn O. Pearce2006-11-28 12:12:08 -0500994 case "$cur" in
9a424b27
SG
SZEDER Gábor2009-12-05 01:51:41 +0100995 --cleanup=*)
996 __gitcomp "default strip verbatim whitespace
997 " "" "${cur##--cleanup=}"
998 return
999 ;;
77653abd
TM
Teemu Matilainen2011-10-06 21:40:30 +03001000 --reuse-message=*|--reedit-message=*|\
1001 --fixup=*|--squash=*)
a31e6262 SZEDER Gábor2011-10-15 14:57:23 +02001002 __gitcomp_nl "$(__git_refs)" "" "${cur#*=}"
9a424b27
SG
SZEDER Gábor2009-12-05 01:51:41 +01001003 return
1004 ;;
1005 --untracked-files=*)
1006 __gitcomp "all no normal" "" "${cur##--untracked-files=}"
1007 return
1008 ;;
4548e855 Shawn O. Pearce2006-11-28 12:12:08 -05001009 --*)
b3391775 Shawn O. Pearce2007-02-04 02:38:43 -05001010 __gitcomp "
4548e855 Shawn O. Pearce2006-11-28 12:12:08 -05001011 --all --author= --signoff --verify --no-verify
aa5735be Eric Raible2008-09-10 17:40:20 -07001012 --edit --amend --include --only --interactive
9a424b27
SG
SZEDER Gábor2009-12-05 01:51:41 +01001013 --dry-run --reuse-message= --reedit-message=
1014 --reset-author --file= --message= --template=
1015 --cleanup= --untracked-files --untracked-files=
77653abd Teemu Matilainen2011-10-06 21:40:30 +03001016 --verbose --quiet --fixup= --squash=
b3391775 Shawn O. Pearce2007-02-04 02:38:43 -05001017 "
4548e855
SP
Shawn O. Pearce2006-11-28 12:12:08 -05001018 return
1019 esac
1020 COMPREPLY=()
1021}
1022
217926c0
SP
Shawn O. Pearce2007-08-23 01:42:11 -04001023_git_describe ()
1024{
cbb504c9
TR
Thomas Rast2008-07-26 12:26:56 +02001025 case "$cur" in
1026 --*)
1027 __gitcomp "
1028 --all --tags --contains --abbrev= --candidates=
1029 --exact-match --debug --long --match --always
1030 "
1031 return
1032 esac
a31e6262 SZEDER Gábor2011-10-15 14:57:23 +02001033 __gitcomp_nl "$(__git_refs)"
217926c0
SP
Shawn O. Pearce2007-08-23 01:42:11 -04001034}
1035
20bf7292 Thomas Rast2009-01-19 22:18:00 +01001036__git_diff_common_options="--stat --numstat --shortstat --summary
b3a4f858
JS
Johannes Schindelin2007-11-23 01:11:35 +00001037 --patch-with-stat --name-only --name-status --color
1038 --no-color --color-words --no-renames --check
f135aacb Eric Raible2008-08-22 10:25:06 -07001039 --full-index --binary --abbrev --diff-filter=
47d5a8fa Thomas Rast2009-01-19 22:17:59 +01001040 --find-copies-harder
b3a4f858
JS
Johannes Schindelin2007-11-23 01:11:35 +00001041 --text --ignore-space-at-eol --ignore-space-change
1042 --ignore-all-space --exit-code --quiet --ext-diff
aba201c6
PO
Pascal Obry2008-04-06 18:56:08 +02001043 --no-ext-diff
1044 --no-prefix --src-prefix= --dst-prefix=
6d0e674a René Scharfe2008-12-28 19:45:32 +01001045 --inter-hunk-context=
cc545709 Johannes Schindelin2009-01-01 17:39:37 +01001046 --patience
20bf7292 Thomas Rast2009-01-19 22:18:00 +01001047 --raw
8fd2cfa7
SB
Stephen Boyd2009-10-07 01:48:51 -07001048 --dirstat --dirstat= --dirstat-by-file
1049 --dirstat-by-file= --cumulative
20bf7292
TR
Thomas Rast2009-01-19 22:18:00 +01001050"
1051
1052_git_diff ()
1053{
1054 __git_has_doubledash && return
1055
20bf7292
TR
Thomas Rast2009-01-19 22:18:00 +01001056 case "$cur" in
1057 --*)
ebd15bf0 Kevin McConnell2009-03-21 16:29:27 -07001058 __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
861514d3 Michael J Gruber2010-09-23 14:33:51 +02001059 --base --ours --theirs --no-index
20bf7292 Thomas Rast2009-01-19 22:18:00 +01001060 $__git_diff_common_options
aba201c6 Pascal Obry2008-04-06 18:56:08 +02001061 "
b3a4f858
JS
Johannes Schindelin2007-11-23 01:11:35 +00001062 return
1063 ;;
1064 esac
1d66ec58 SZEDER Gábor2011-03-10 19:12:29 +01001065 __git_complete_revlist_file
690d8824
JH
Junio C Hamano2006-09-28 02:31:25 -07001066}
1067
e2dc2de9 David Aguilar2009-04-06 01:31:27 -07001068__git_mergetools_common="diffuse ecmerge emerge kdiff3 meld opendiff
ffe6dc08 Sebastian Schuberth2011-02-27 12:32:46 +01001069 tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc3
e2dc2de9
DA
David Aguilar2009-04-06 01:31:27 -07001070"
1071
1072_git_difftool ()
1073{
f7ad96cf
MH
Markus Heidelberg2009-10-28 10:45:38 +01001074 __git_has_doubledash && return
1075
e2dc2de9
DA
David Aguilar2009-04-06 01:31:27 -07001076 case "$cur" in
1077 --tool=*)
1078 __gitcomp "$__git_mergetools_common kompare" "" "${cur##--tool=}"
1079 return
1080 ;;
1081 --*)
f7ad96cf
MH
Markus Heidelberg2009-10-28 10:45:38 +01001082 __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
1083 --base --ours --theirs
1084 --no-renames --diff-filter= --find-copies-harder
1085 --relative --ignore-submodules
1086 --tool="
e2dc2de9
DA
David Aguilar2009-04-06 01:31:27 -07001087 return
1088 ;;
1089 esac
f7ad96cf Markus Heidelberg2009-10-28 10:45:38 +01001090 __git_complete_file
e2dc2de9
DA
David Aguilar2009-04-06 01:31:27 -07001091}
1092
0a4e1472
JS
Jay Soffian2009-03-05 23:39:33 -05001093__git_fetch_options="
1094 --quiet --verbose --append --upload-pack --force --keep --depth=
e25e2b42 Björn Gustavsson2009-12-12 11:21:46 +01001095 --tags --no-tags --all --prune --dry-run
0a4e1472
JS
Jay Soffian2009-03-05 23:39:33 -05001096"
1097
690d8824
JH
Junio C Hamano2006-09-28 02:31:25 -07001098_git_fetch ()
1099{
0a4e1472
JS
Jay Soffian2009-03-05 23:39:33 -05001100 case "$cur" in
1101 --*)
1102 __gitcomp "$__git_fetch_options"
1103 return
1104 ;;
1105 esac
52d5c3b5 Jay Soffian2009-03-05 23:39:31 -05001106 __git_complete_remote_or_refspec
690d8824
JH
Junio C Hamano2006-09-28 02:31:25 -07001107}
1108
f53352fb
SP
Shawn O. Pearce2006-11-27 03:41:43 -05001109_git_format_patch ()
1110{
f53352fb Shawn O. Pearce2006-11-27 03:41:43 -05001111 case "$cur" in
e1d37937
SB
Stephen Boyd2009-03-23 03:26:51 -07001112 --thread=*)
1113 __gitcomp "
1114 deep shallow
1115 " "" "${cur##--thread=}"
1116 return
1117 ;;
f53352fb Shawn O. Pearce2006-11-27 03:41:43 -05001118 --*)
b3391775 Shawn O. Pearce2007-02-04 02:38:43 -05001119 __gitcomp "
e1d37937 Stephen Boyd2009-03-23 03:26:51 -07001120 --stdout --attach --no-attach --thread --thread=
f53352fb
SP
Shawn O. Pearce2006-11-27 03:41:43 -05001121 --output-directory
1122 --numbered --start-number
47e98eec Shawn O. Pearce2007-08-23 01:39:22 -04001123 --numbered-files
f53352fb Shawn O. Pearce2006-11-27 03:41:43 -05001124 --keep-subject
d8e1e5df Stephen Boyd2010-06-15 22:59:26 -07001125 --signoff --signature --no-signature
3f7df3a7 Stephen Boyd2009-03-23 03:26:50 -07001126 --in-reply-to= --cc=
f53352fb Shawn O. Pearce2006-11-27 03:41:43 -05001127 --full-index --binary
ec804891 Shawn O. Pearce2007-02-04 02:38:47 -05001128 --not --all
be5f5bf0 Johannes Schindelin2008-02-21 16:21:49 +00001129 --cover-letter
aba201c6 Pascal Obry2008-04-06 18:56:08 +02001130 --no-prefix --src-prefix= --dst-prefix=
81085134
SG
SZEDER Gábor2009-01-16 17:02:04 +01001131 --inline --suffix= --ignore-if-in-upstream
1132 --subject-prefix=
b3391775 Shawn O. Pearce2007-02-04 02:38:43 -05001133 "
f53352fb
SP
Shawn O. Pearce2006-11-27 03:41:43 -05001134 return
1135 ;;
1136 esac
1137 __git_complete_revlist
1138}
1139
4bca8636
AJ
Arto Jonsson2009-03-22 20:49:07 +02001140_git_fsck ()
1141{
4bca8636
AJ
Arto Jonsson2009-03-22 20:49:07 +02001142 case "$cur" in
1143 --*)
1144 __gitcomp "
1145 --tags --root --unreachable --cache --no-reflogs --full
1146 --strict --verbose --lost-found
1147 "
1148 return
1149 ;;
1150 esac
1151 COMPREPLY=()
1152}
1153
b26c8748
SP
Shawn O. Pearce2007-02-05 15:44:28 -05001154_git_gc ()
1155{
b26c8748
SP
Shawn O. Pearce2007-02-05 15:44:28 -05001156 case "$cur" in
1157 --*)
47e98eec Shawn O. Pearce2007-08-23 01:39:22 -04001158 __gitcomp "--prune --aggressive"
b26c8748
SP
Shawn O. Pearce2007-02-05 15:44:28 -05001159 return
1160 ;;
1161 esac
1162 COMPREPLY=()
1163}
1164
66729509
SG
SZEDER Gábor2010-02-23 22:03:00 +01001165_git_gitk ()
1166{
1167 _gitk
1168}
1169
29eec71f
JK
Jeff King2011-10-21 13:30:21 -04001170__git_match_ctag() {
1171 awk "/^${1////\\/}/ { print \$1 }" "$2"
1172}
1173
c72e0db1
LM
Lee Marlow2008-08-01 18:56:33 -06001174_git_grep ()
1175{
1176 __git_has_doubledash && return
1177
c72e0db1
LM
Lee Marlow2008-08-01 18:56:33 -06001178 case "$cur" in
1179 --*)
1180 __gitcomp "
1181 --cached
1182 --text --ignore-case --word-regexp --invert-match
5a69eaf5 Michał Kiedrowicz2011-05-05 00:00:18 +02001183 --full-name --line-number
c72e0db1 Lee Marlow2008-08-01 18:56:33 -06001184 --extended-regexp --basic-regexp --fixed-strings
63e7e9d8 Michał Kiedrowicz2011-05-09 23:52:05 +02001185 --perl-regexp
c72e0db1
LM
Lee Marlow2008-08-01 18:56:33 -06001186 --files-with-matches --name-only
1187 --files-without-match
a91f453f Michał Kiedrowicz2009-07-22 19:52:15 +02001188 --max-depth
c72e0db1
LM
Lee Marlow2008-08-01 18:56:33 -06001189 --count
1190 --and --or --not --all-match
1191 "
1192 return
1193 ;;
1194 esac
17225c49 Thomas Rast2009-10-12 11:00:09 +02001195
29eec71f
JK
Jeff King2011-10-21 13:30:21 -04001196 case "$cword,$prev" in
1197 2,*|*,-*)
1198 if test -r tags; then
d2c78075 Junio C Hamano2011-12-09 13:37:18 -08001199 __gitcomp_nl "$(__git_match_ctag "$cur" tags)"
29eec71f
JK
Jeff King2011-10-21 13:30:21 -04001200 return
1201 fi
1202 ;;
1203 esac
1204
a31e6262 SZEDER Gábor2011-10-15 14:57:23 +02001205 __gitcomp_nl "$(__git_refs)"
c72e0db1
LM
Lee Marlow2008-08-01 18:56:33 -06001206}
1207
1eb7e2f8
LM
Lee Marlow2008-07-23 18:07:23 -06001208_git_help ()
1209{
1eb7e2f8
LM
Lee Marlow2008-07-23 18:07:23 -06001210 case "$cur" in
1211 --*)
1212 __gitcomp "--all --info --man --web"
1213 return
1214 ;;
1215 esac
eaa4e6ee Jonathan Nieder2009-11-17 18:49:10 -06001216 __git_compute_all_commands
f85a6f0b Jakob Pfender2011-03-21 10:25:06 +01001217 __gitcomp "$__git_all_commands $(__git_aliases)
2946cccf
MG
Marcus Griep2008-08-15 13:59:28 -04001218 attributes cli core-tutorial cvs-migration
1219 diffcore gitk glossary hooks ignore modules
d49483f0 Josh Triplett2011-07-08 16:14:10 -07001220 namespaces repository-layout tutorial tutorial-2
99f0b599 Lee Marlow2008-10-20 11:31:38 -06001221 workflows
2946cccf Marcus Griep2008-08-15 13:59:28 -04001222 "
1eb7e2f8
LM
Lee Marlow2008-07-23 18:07:23 -06001223}
1224
5dad868b
LM
Lee Marlow2008-08-04 23:50:33 -06001225_git_init ()
1226{
5dad868b
LM
Lee Marlow2008-08-04 23:50:33 -06001227 case "$cur" in
1228 --shared=*)
1229 __gitcomp "
1230 false true umask group all world everybody
1231 " "" "${cur##--shared=}"
1232 return
1233 ;;
1234 --*)
1235 __gitcomp "--quiet --bare --template= --shared --shared="
1236 return
1237 ;;
1238 esac
1239 COMPREPLY=()
1240}
1241
b1bc1494
LM
Lee Marlow2008-08-04 23:50:37 -06001242_git_ls_files ()
1243{
1244 __git_has_doubledash && return
1245
b1bc1494
LM
Lee Marlow2008-08-04 23:50:37 -06001246 case "$cur" in
1247 --*)
1248 __gitcomp "--cached --deleted --modified --others --ignored
1249 --stage --directory --no-empty-directory --unmerged
1250 --killed --exclude= --exclude-from=
1251 --exclude-per-directory= --exclude-standard
1252 --error-unmatch --with-tree= --full-name
1253 --abbrev --ignored --exclude-per-directory
1254 "
1255 return
1256 ;;
1257 esac
1258 COMPREPLY=()
1259}
1260
690d8824
JH
Junio C Hamano2006-09-28 02:31:25 -07001261_git_ls_remote ()
1262{
a31e6262 SZEDER Gábor2011-10-15 14:57:23 +02001263 __gitcomp_nl "$(__git_remotes)"
690d8824
JH
Junio C Hamano2006-09-28 02:31:25 -07001264}
1265
1266_git_ls_tree ()
1267{
1268 __git_complete_file
1269}
1270
a393777e
TR
Thomas Rast2009-02-16 17:34:56 +01001271# Options that go well for log, shortlog and gitk
1272__git_log_common_options="
1273 --not --all
1274 --branches --tags --remotes
4fe1a619 SZEDER Gábor2009-07-13 17:11:45 +02001275 --first-parent --merges --no-merges
a393777e
TR
Thomas Rast2009-02-16 17:34:56 +01001276 --max-count=
1277 --max-age= --since= --after=
1278 --min-age= --until= --before=
6a6ebded
MG
Michael J Gruber2011-03-23 10:38:51 +01001279 --min-parents= --max-parents=
1280 --no-min-parents --no-max-parents
a393777e
TR
Thomas Rast2009-02-16 17:34:56 +01001281"
1282# Options that go well for log and gitk (not shortlog)
1283__git_log_gitk_options="
1284 --dense --sparse --full-history
1285 --simplify-merges --simplify-by-decoration
3925b575 Michael J Gruber2011-04-14 19:53:13 +02001286 --left-right --notes --no-notes
a393777e
TR
Thomas Rast2009-02-16 17:34:56 +01001287"
1288# Options that go well for log and shortlog (not gitk)
1289__git_log_shortlog_options="
1290 --author= --committer= --grep=
1291 --all-match
1292"
1293
3d279863 SZEDER Gábor2009-01-16 17:02:15 +01001294__git_log_pretty_formats="oneline short medium full fuller email raw format:"
672c68cb Stephen Boyd2009-05-03 23:25:34 -07001295__git_log_date_formats="relative iso8601 rfc2822 short local default raw"
3d279863 SZEDER Gábor2009-01-16 17:02:15 +01001296
690d8824
JH
Junio C Hamano2006-09-28 02:31:25 -07001297_git_log ()
1298{
d773c631
SG
SZEDER Gábor2008-07-08 18:56:14 +02001299 __git_has_doubledash && return
1300
bf3c20f6
TR
Thomas Rast2009-02-16 17:34:57 +01001301 local g="$(git rev-parse --git-dir 2>/dev/null)"
1302 local merge=""
ba7906f2 Daniel Cheng (aka SDiZ)2009-03-30 19:27:37 +08001303 if [ -f "$g/MERGE_HEAD" ]; then
bf3c20f6
TR
Thomas Rast2009-02-16 17:34:57 +01001304 merge="--merge"
1305 fi
6e31b866 Shawn O. Pearce2006-11-27 03:42:18 -05001306 case "$cur" in
e67d71e5 SZEDER Gábor2011-10-08 03:09:34 +02001307 --pretty=*|--format=*)
c3898111 SZEDER Gábor2010-10-11 00:06:22 +02001308 __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
e67d71e5 SZEDER Gábor2011-10-08 03:09:34 +02001309 " "" "${cur#*=}"
72de29c2
TL
Teemu Likonen2009-02-24 15:33:29 +02001310 return
1311 ;;
47e98eec Shawn O. Pearce2007-08-23 01:39:22 -04001312 --date=*)
672c68cb Stephen Boyd2009-05-03 23:25:34 -07001313 __gitcomp "$__git_log_date_formats" "" "${cur##--date=}"
47e98eec
SP
Shawn O. Pearce2007-08-23 01:39:22 -04001314 return
1315 ;;
af4e9e8c
SB
Stephen Boyd2009-10-07 01:48:50 -07001316 --decorate=*)
1317 __gitcomp "long short" "" "${cur##--decorate=}"
1318 return
1319 ;;
6e31b866 Shawn O. Pearce2006-11-27 03:42:18 -05001320 --*)
b3391775 Shawn O. Pearce2007-02-04 02:38:43 -05001321 __gitcomp "
a393777e
TR
Thomas Rast2009-02-16 17:34:56 +01001322 $__git_log_common_options
1323 $__git_log_shortlog_options
1324 $__git_log_gitk_options
8f87fae6 Shawn O. Pearce2007-05-24 01:51:30 -04001325 --root --topo-order --date-order --reverse
5d0e6343 Todd Zullinger2009-06-03 16:20:58 -04001326 --follow --full-diff
6e31b866 Shawn O. Pearce2006-11-27 03:42:18 -05001327 --abbrev-commit --abbrev=
47e98eec Shawn O. Pearce2007-08-23 01:39:22 -04001328 --relative-date --date=
72de29c2 Teemu Likonen2009-02-24 15:33:29 +02001329 --pretty= --format= --oneline
a393777e Thomas Rast2009-02-16 17:34:56 +01001330 --cherry-pick
20827d99 Dan McGee2008-06-19 16:15:53 -05001331 --graph
af4e9e8c Stephen Boyd2009-10-07 01:48:50 -07001332 --decorate --decorate=
20bf7292 Thomas Rast2009-01-19 22:18:00 +01001333 --walk-reflogs
a393777e Thomas Rast2009-02-16 17:34:56 +01001334 --parents --children
bf3c20f6 Thomas Rast2009-02-16 17:34:57 +01001335 $merge
20bf7292 Thomas Rast2009-01-19 22:18:00 +01001336 $__git_diff_common_options
47d5a8fa Thomas Rast2009-01-19 22:17:59 +01001337 --pickaxe-all --pickaxe-regex
b3391775 Shawn O. Pearce2007-02-04 02:38:43 -05001338 "
6e31b866
SP
Shawn O. Pearce2006-11-27 03:42:18 -05001339 return
1340 ;;
1341 esac
f53352fb Shawn O. Pearce2006-11-27 03:41:43 -05001342 __git_complete_revlist
690d8824
JH
Junio C Hamano2006-09-28 02:31:25 -07001343}
1344
0a4e1472
JS
Jay Soffian2009-03-05 23:39:33 -05001345__git_merge_options="
1346 --no-commit --no-stat --log --no-log --squash --strategy
2ff14e31 Adrian Weimann2012-01-30 20:29:33 +01001347 --commit --stat --no-squash --ff --no-ff --ff-only --edit --no-edit
0a4e1472
JS
Jay Soffian2009-03-05 23:39:33 -05001348"
1349
4ad91321
SP
Shawn O. Pearce2006-11-27 03:40:47 -05001350_git_merge ()
1351{
3c7b480a
JS
Jay Soffian2009-03-06 11:30:44 -05001352 __git_complete_strategy && return
1353
4ad91321
SP
Shawn O. Pearce2006-11-27 03:40:47 -05001354 case "$cur" in
1355 --*)
0a4e1472 Jay Soffian2009-03-05 23:39:33 -05001356 __gitcomp "$__git_merge_options"
4ad91321
SP
Shawn O. Pearce2006-11-27 03:40:47 -05001357 return
1358 esac
a31e6262 SZEDER Gábor2011-10-15 14:57:23 +02001359 __gitcomp_nl "$(__git_refs)"
4ad91321
SP
Shawn O. Pearce2006-11-27 03:40:47 -05001360}
1361
b4c72162
LM
Lee Marlow2008-08-14 16:41:10 -06001362_git_mergetool ()
1363{
b4c72162
LM
Lee Marlow2008-08-14 16:41:10 -06001364 case "$cur" in
1365 --tool=*)
e2dc2de9 David Aguilar2009-04-06 01:31:27 -07001366 __gitcomp "$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"
b4c72162
LM
Lee Marlow2008-08-14 16:41:10 -06001367 return
1368 ;;
1369 --*)
1370 __gitcomp "--tool="
1371 return
1372 ;;
1373 esac
1374 COMPREPLY=()
1375}
1376
690d8824
JH
Junio C Hamano2006-09-28 02:31:25 -07001377_git_merge_base ()
1378{
a31e6262 SZEDER Gábor2011-10-15 14:57:23 +02001379 __gitcomp_nl "$(__git_refs)"
690d8824
JH
Junio C Hamano2006-09-28 02:31:25 -07001380}
1381
1127c51c
LM
Lee Marlow2008-08-04 23:50:38 -06001382_git_mv ()
1383{
1127c51c
LM
Lee Marlow2008-08-04 23:50:38 -06001384 case "$cur" in
1385 --*)
1386 __gitcomp "--dry-run"
1387 return
1388 ;;
1389 esac
1390 COMPREPLY=()
1391}
1392
d33909bf
SP
Shawn O. Pearce2006-11-27 03:41:12 -05001393_git_name_rev ()
1394{
b3391775 Shawn O. Pearce2007-02-04 02:38:43 -05001395 __gitcomp "--tags --all --stdin"
d33909bf
SP
Shawn O. Pearce2006-11-27 03:41:12 -05001396}
1397
00f09d0e
SG
SZEDER Gábor2010-01-28 02:05:55 +01001398_git_notes ()
1399{
2a5da755
SG
SZEDER Gábor2010-10-10 23:43:33 +02001400 local subcommands='add append copy edit list prune remove show'
1401 local subcommand="$(__git_find_on_cmdline "$subcommands")"
00f09d0e SZEDER Gábor2010-01-28 02:05:55 +01001402
2a5da755
SG
SZEDER Gábor2010-10-10 23:43:33 +02001403 case "$subcommand,$cur" in
1404 ,--*)
1405 __gitcomp '--ref'
1406 ;;
1407 ,*)
39540681 Felipe Contreras2012-04-15 22:44:17 +03001408 case "$prev" in
2a5da755 SZEDER Gábor2010-10-10 23:43:33 +02001409 --ref)
a31e6262 SZEDER Gábor2011-10-15 14:57:23 +02001410 __gitcomp_nl "$(__git_refs)"
2a5da755
SG
SZEDER Gábor2010-10-10 23:43:33 +02001411 ;;
1412 *)
1413 __gitcomp "$subcommands --ref"
1414 ;;
1415 esac
1416 ;;
a8f89bfa SZEDER Gábor2011-10-08 03:06:34 +02001417 add,--reuse-message=*|append,--reuse-message=*|\
2a5da755 SZEDER Gábor2010-10-10 23:43:33 +02001418 add,--reedit-message=*|append,--reedit-message=*)
a31e6262 SZEDER Gábor2011-10-15 14:57:23 +02001419 __gitcomp_nl "$(__git_refs)" "" "${cur#*=}"
2a5da755
SG
SZEDER Gábor2010-10-10 23:43:33 +02001420 ;;
1421 add,--*|append,--*)
1422 __gitcomp '--file= --message= --reedit-message=
1423 --reuse-message='
1424 ;;
1425 copy,--*)
1426 __gitcomp '--stdin'
1427 ;;
1428 prune,--*)
1429 __gitcomp '--dry-run --verbose'
1430 ;;
1431 prune,*)
00f09d0e
SG
SZEDER Gábor2010-01-28 02:05:55 +01001432 ;;
1433 *)
39540681 Felipe Contreras2012-04-15 22:44:17 +03001434 case "$prev" in
2a5da755
SG
SZEDER Gábor2010-10-10 23:43:33 +02001435 -m|-F)
1436 ;;
1437 *)
a31e6262 SZEDER Gábor2011-10-15 14:57:23 +02001438 __gitcomp_nl "$(__git_refs)"
2a5da755
SG
SZEDER Gábor2010-10-10 23:43:33 +02001439 ;;
1440 esac
00f09d0e
SG
SZEDER Gábor2010-01-28 02:05:55 +01001441 ;;
1442 esac
1443}
1444
690d8824
JH
Junio C Hamano2006-09-28 02:31:25 -07001445_git_pull ()
1446{
0a4e1472
JS
Jay Soffian2009-03-05 23:39:33 -05001447 __git_complete_strategy && return
1448
0a4e1472
JS
Jay Soffian2009-03-05 23:39:33 -05001449 case "$cur" in
1450 --*)
1451 __gitcomp "
1452 --rebase --no-rebase
1453 $__git_merge_options
1454 $__git_fetch_options
1455 "
1456 return
1457 ;;
1458 esac
52d5c3b5 Jay Soffian2009-03-05 23:39:31 -05001459 __git_complete_remote_or_refspec
690d8824
JH
Junio C Hamano2006-09-28 02:31:25 -07001460}
1461
1462_git_push ()
1463{
da48616f Peter van der Does2010-12-02 02:17:13 -06001464 case "$prev" in
0a4e1472 Jay Soffian2009-03-05 23:39:33 -05001465 --repo)
a31e6262 SZEDER Gábor2011-10-15 14:57:23 +02001466 __gitcomp_nl "$(__git_remotes)"
0a4e1472
JS
Jay Soffian2009-03-05 23:39:33 -05001467 return
1468 esac
1469 case "$cur" in
1470 --repo=*)
a31e6262 SZEDER Gábor2011-10-15 14:57:23 +02001471 __gitcomp_nl "$(__git_remotes)" "" "${cur##--repo=}"
0a4e1472
JS
Jay Soffian2009-03-05 23:39:33 -05001472 return
1473 ;;
1474 --*)
1475 __gitcomp "
1476 --all --mirror --tags --dry-run --force --verbose
3623dc03 Teemu Matilainen2011-10-06 21:40:31 +03001477 --receive-pack= --repo= --set-upstream
0a4e1472
JS
Jay Soffian2009-03-05 23:39:33 -05001478 "
1479 return
1480 ;;
1481 esac
52d5c3b5 Jay Soffian2009-03-05 23:39:31 -05001482 __git_complete_remote_or_refspec
690d8824
JH
Junio C Hamano2006-09-28 02:31:25 -07001483}
1484
61d926a3
SP
Shawn O. Pearce2006-11-27 03:42:07 -05001485_git_rebase ()
1486{
da48616f Peter van der Does2010-12-02 02:17:13 -06001487 local dir="$(__gitdir)"
51ef1daa Johannes Schindelin2008-07-21 12:51:02 +02001488 if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
b3391775 Shawn O. Pearce2007-02-04 02:38:43 -05001489 __gitcomp "--continue --skip --abort"
61d926a3
SP
Shawn O. Pearce2006-11-27 03:42:07 -05001490 return
1491 fi
3c7b480a Jay Soffian2009-03-06 11:30:44 -05001492 __git_complete_strategy && return
61d926a3 Shawn O. Pearce2006-11-27 03:42:07 -05001493 case "$cur" in
93cf50a4
BG
Björn Gustavsson2009-10-17 11:33:38 +02001494 --whitespace=*)
1495 __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
1496 return
1497 ;;
61d926a3 Shawn O. Pearce2006-11-27 03:42:07 -05001498 --*)
93cf50a4
BG
Björn Gustavsson2009-10-17 11:33:38 +02001499 __gitcomp "
1500 --onto --merge --strategy --interactive
1501 --preserve-merges --stat --no-stat
1502 --committer-date-is-author-date --ignore-date
1503 --ignore-whitespace --whitespace=
6d0d465e Björn Gustavsson2010-02-06 09:37:53 +01001504 --autosquash
93cf50a4
BG
Björn Gustavsson2009-10-17 11:33:38 +02001505 "
1506
61d926a3
SP
Shawn O. Pearce2006-11-27 03:42:07 -05001507 return
1508 esac
a31e6262 SZEDER Gábor2011-10-15 14:57:23 +02001509 __gitcomp_nl "$(__git_refs)"
61d926a3
SP
Shawn O. Pearce2006-11-27 03:42:07 -05001510}
1511
057f3279
TRC
Tay Ray Chuan2010-12-16 14:56:08 +08001512_git_reflog ()
1513{
1514 local subcommands="show delete expire"
1515 local subcommand="$(__git_find_on_cmdline "$subcommands")"
1516
1517 if [ -z "$subcommand" ]; then
1518 __gitcomp "$subcommands"
1519 else
a31e6262 SZEDER Gábor2011-10-15 14:57:23 +02001520 __gitcomp_nl "$(__git_refs)"
057f3279
TRC
Tay Ray Chuan2010-12-16 14:56:08 +08001521 fi
1522}
1523
ae616de6 Stephen Boyd2009-05-03 23:25:35 -07001524__git_send_email_confirm_options="always never auto cc compose"
cb8a9bd5 Paolo Bonzini2009-06-18 14:31:32 +02001525__git_send_email_suppresscc_options="author self cc bodycc sob cccmd body all"
ae616de6 Stephen Boyd2009-05-03 23:25:35 -07001526
25a1f374
TL
Teemu Likonen2008-07-14 11:21:02 +03001527_git_send_email ()
1528{
25a1f374 Teemu Likonen2008-07-14 11:21:02 +03001529 case "$cur" in
ae616de6
SB
Stephen Boyd2009-05-03 23:25:35 -07001530 --confirm=*)
1531 __gitcomp "
1532 $__git_send_email_confirm_options
1533 " "" "${cur##--confirm=}"
1534 return
1535 ;;
1536 --suppress-cc=*)
1537 __gitcomp "
1538 $__git_send_email_suppresscc_options
1539 " "" "${cur##--suppress-cc=}"
1540
1541 return
1542 ;;
1543 --smtp-encryption=*)
1544 __gitcomp "ssl tls" "" "${cur##--smtp-encryption=}"
1545 return
1546 ;;
25a1f374 Teemu Likonen2008-07-14 11:21:02 +03001547 --*)
77813151 Stephen Boyd2009-03-23 03:26:49 -07001548 __gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to
ae616de6
SB
Stephen Boyd2009-05-03 23:25:35 -07001549 --compose --confirm= --dry-run --envelope-sender
1550 --from --identity
25a1f374
TL
Teemu Likonen2008-07-14 11:21:02 +03001551 --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
1552 --no-suppress-from --no-thread --quiet
1553 --signed-off-by-cc --smtp-pass --smtp-server
ae616de6
SB
Stephen Boyd2009-05-03 23:25:35 -07001554 --smtp-server-port --smtp-encryption= --smtp-user
1555 --subject --suppress-cc= --suppress-from --thread --to
fd3a8dcb Teemu Likonen2008-09-28 07:51:21 +03001556 --validate --no-validate"
25a1f374
TL
Teemu Likonen2008-07-14 11:21:02 +03001557 return
1558 ;;
1559 esac
1560 COMPREPLY=()
1561}
1562
424cce83
SG
SZEDER Gábor2010-02-23 22:02:58 +01001563_git_stage ()
1564{
1565 _git_add
1566}
1567
00652369
SB
Stephen Boyd2009-05-08 18:23:32 -07001568__git_config_get_set_variables ()
1569{
da48616f Peter van der Does2010-12-02 02:17:13 -06001570 local prevword word config_file= c=$cword
00652369 Stephen Boyd2009-05-08 18:23:32 -07001571 while [ $c -gt 1 ]; do
da48616f Peter van der Does2010-12-02 02:17:13 -06001572 word="${words[c]}"
00652369
SB
Stephen Boyd2009-05-08 18:23:32 -07001573 case "$word" in
1574 --global|--system|--file=*)
1575 config_file="$word"
1576 break
1577 ;;
1578 -f|--file)
1579 config_file="$word $prevword"
1580 break
1581 ;;
1582 esac
1583 prevword=$word
1584 c=$((--c))
1585 done
1586
f581de1b Stephen Boyd2009-06-29 22:08:38 -07001587 git --git-dir="$(__gitdir)" config $config_file --list 2>/dev/null |
6f2dd720 Thomas Rast2011-12-21 16:54:14 +01001588 while read -r line
f581de1b
SB
Stephen Boyd2009-06-29 22:08:38 -07001589 do
1590 case "$line" in
1591 *.*=*)
1592 echo "${line/=*/}"
00652369
SB
Stephen Boyd2009-05-08 18:23:32 -07001593 ;;
1594 esac
1595 done
1596}
1597
e0d10e1c Tom Prince2007-01-28 16:16:53 -08001598_git_config ()
5de40f59 Shawn O. Pearce2006-11-27 04:44:47 -05001599{
da48616f Peter van der Does2010-12-02 02:17:13 -06001600 case "$prev" in
5de40f59 Shawn O. Pearce2006-11-27 04:44:47 -05001601 branch.*.remote)
a31e6262 SZEDER Gábor2011-10-15 14:57:23 +02001602 __gitcomp_nl "$(__git_remotes)"
5de40f59
SP
Shawn O. Pearce2006-11-27 04:44:47 -05001603 return
1604 ;;
1605 branch.*.merge)
a31e6262 SZEDER Gábor2011-10-15 14:57:23 +02001606 __gitcomp_nl "$(__git_refs)"
5de40f59
SP
Shawn O. Pearce2006-11-27 04:44:47 -05001607 return
1608 ;;
1609 remote.*.fetch)
da48616f Peter van der Does2010-12-02 02:17:13 -06001610 local remote="${prev#remote.}"
5de40f59 Shawn O. Pearce2006-11-27 04:44:47 -05001611 remote="${remote%.fetch}"
d51a8ecd
SG
SZEDER Gábor2011-10-08 16:54:42 +02001612 if [ -z "$cur" ]; then
1613 COMPREPLY=("refs/heads/")
1614 return
1615 fi
a31e6262 SZEDER Gábor2011-10-15 14:57:23 +02001616 __gitcomp_nl "$(__git_refs_remotes "$remote")"
5de40f59
SP
Shawn O. Pearce2006-11-27 04:44:47 -05001617 return
1618 ;;
1619 remote.*.push)
da48616f Peter van der Does2010-12-02 02:17:13 -06001620 local remote="${prev#remote.}"
5de40f59 Shawn O. Pearce2006-11-27 04:44:47 -05001621 remote="${remote%.push}"
a31e6262 SZEDER Gábor2011-10-15 14:57:23 +02001622 __gitcomp_nl "$(git --git-dir="$(__gitdir)" \
5de40f59 Shawn O. Pearce2006-11-27 04:44:47 -05001623 for-each-ref --format='%(refname):%(refname)' \
78d4d6a2
SP
Shawn O. Pearce2007-02-04 02:38:37 -05001624 refs/heads)"
1625 return
1626 ;;
1627 pull.twohead|pull.octopus)
eaa4e6ee
JN
Jonathan Nieder2009-11-17 18:49:10 -06001628 __git_compute_merge_strategies
1629 __gitcomp "$__git_merge_strategies"
78d4d6a2
SP
Shawn O. Pearce2007-02-04 02:38:37 -05001630 return
1631 ;;
6123d719
MH
Markus Heidelberg2009-04-25 13:46:14 +02001632 color.branch|color.diff|color.interactive|\
1633 color.showbranch|color.status|color.ui)
78d4d6a2
SP
Shawn O. Pearce2007-02-04 02:38:37 -05001634 __gitcomp "always never auto"
1635 return
1636 ;;
901d615c
MK
Matt Kraai2009-02-12 07:55:54 -08001637 color.pager)
1638 __gitcomp "false true"
1639 return
1640 ;;
78d4d6a2
SP
Shawn O. Pearce2007-02-04 02:38:37 -05001641 color.*.*)
1642 __gitcomp "
98171a07 Lee Marlow2008-12-15 10:45:49 -07001643 normal black red green yellow blue magenta cyan white
78d4d6a2
SP
Shawn O. Pearce2007-02-04 02:38:37 -05001644 bold dim ul blink reverse
1645 "
5de40f59
SP
Shawn O. Pearce2006-11-27 04:44:47 -05001646 return
1647 ;;
9b82d63b
SB
Stephen Boyd2009-05-03 23:25:33 -07001648 help.format)
1649 __gitcomp "man info web html"
1650 return
1651 ;;
672c68cb
SB
Stephen Boyd2009-05-03 23:25:34 -07001652 log.date)
1653 __gitcomp "$__git_log_date_formats"
1654 return
1655 ;;
ae616de6
SB
Stephen Boyd2009-05-03 23:25:35 -07001656 sendemail.aliasesfiletype)
1657 __gitcomp "mutt mailrc pine elm gnus"
1658 return
1659 ;;
1660 sendemail.confirm)
1661 __gitcomp "$__git_send_email_confirm_options"
1662 return
1663 ;;
1664 sendemail.suppresscc)
1665 __gitcomp "$__git_send_email_suppresscc_options"
1666 return
1667 ;;
00652369 Stephen Boyd2009-05-08 18:23:32 -07001668 --get|--get-all|--unset|--unset-all)
a31e6262 SZEDER Gábor2011-10-15 14:57:23 +02001669 __gitcomp_nl "$(__git_config_get_set_variables)"
00652369
SB
Stephen Boyd2009-05-08 18:23:32 -07001670 return
1671 ;;
5de40f59
SP
Shawn O. Pearce2006-11-27 04:44:47 -05001672 *.*)
1673 COMPREPLY=()
1674 return
1675 ;;
1676 esac
1677 case "$cur" in
1678 --*)
78d4d6a2 Shawn O. Pearce2007-02-04 02:38:37 -05001679 __gitcomp "
47e98eec Shawn O. Pearce2007-08-23 01:39:22 -04001680 --global --system --file=
12977705 Shawn O. Pearce2007-05-24 02:07:45 -04001681 --list --replace-all
5de40f59 Shawn O. Pearce2006-11-27 04:44:47 -05001682 --get --get-all --get-regexp
1b71eb35 Shawn O. Pearce2007-02-05 15:44:32 -05001683 --add --unset --unset-all
12977705 Shawn O. Pearce2007-05-24 02:07:45 -04001684 --remove-section --rename-section
78d4d6a2 Shawn O. Pearce2007-02-04 02:38:37 -05001685 "
5de40f59
SP
Shawn O. Pearce2006-11-27 04:44:47 -05001686 return
1687 ;;
1688 branch.*.*)
9244d69b
SG
SZEDER Gábor2011-04-28 18:01:51 +02001689 local pfx="${cur%.*}." cur_="${cur##*.}"
1690 __gitcomp "remote merge mergeoptions rebase" "$pfx" "$cur_"
5de40f59
SP
Shawn O. Pearce2006-11-27 04:44:47 -05001691 return
1692 ;;
1693 branch.*)
9244d69b SZEDER Gábor2011-04-28 18:01:51 +02001694 local pfx="${cur%.*}." cur_="${cur#*.}"
a31e6262 SZEDER Gábor2011-10-15 14:57:23 +02001695 __gitcomp_nl "$(__git_heads)" "$pfx" "$cur_" "."
5de40f59
SP
Shawn O. Pearce2006-11-27 04:44:47 -05001696 return
1697 ;;
0aa62fd0 Stephen Boyd2009-05-03 23:25:32 -07001698 guitool.*.*)
9244d69b SZEDER Gábor2011-04-28 18:01:51 +02001699 local pfx="${cur%.*}." cur_="${cur##*.}"
0aa62fd0
SB
Stephen Boyd2009-05-03 23:25:32 -07001700 __gitcomp "
1701 argprompt cmd confirm needsfile noconsole norescan
1702 prompt revprompt revunmerged title
9244d69b SZEDER Gábor2011-04-28 18:01:51 +02001703 " "$pfx" "$cur_"
0aa62fd0
SB
Stephen Boyd2009-05-03 23:25:32 -07001704 return
1705 ;;
1706 difftool.*.*)
9244d69b
SG
SZEDER Gábor2011-04-28 18:01:51 +02001707 local pfx="${cur%.*}." cur_="${cur##*.}"
1708 __gitcomp "cmd path" "$pfx" "$cur_"
0aa62fd0
SB
Stephen Boyd2009-05-03 23:25:32 -07001709 return
1710 ;;
1711 man.*.*)
9244d69b
SG
SZEDER Gábor2011-04-28 18:01:51 +02001712 local pfx="${cur%.*}." cur_="${cur##*.}"
1713 __gitcomp "cmd path" "$pfx" "$cur_"
0aa62fd0
SB
Stephen Boyd2009-05-03 23:25:32 -07001714 return
1715 ;;
1716 mergetool.*.*)
9244d69b
SG
SZEDER Gábor2011-04-28 18:01:51 +02001717 local pfx="${cur%.*}." cur_="${cur##*.}"
1718 __gitcomp "cmd path trustExitCode" "$pfx" "$cur_"
0aa62fd0
SB
Stephen Boyd2009-05-03 23:25:32 -07001719 return
1720 ;;
1721 pager.*)
9244d69b SZEDER Gábor2011-04-28 18:01:51 +02001722 local pfx="${cur%.*}." cur_="${cur#*.}"
eaa4e6ee Jonathan Nieder2009-11-17 18:49:10 -06001723 __git_compute_all_commands
a31e6262 SZEDER Gábor2011-10-15 14:57:23 +02001724 __gitcomp_nl "$__git_all_commands" "$pfx" "$cur_"
0aa62fd0
SB
Stephen Boyd2009-05-03 23:25:32 -07001725 return
1726 ;;
5de40f59 Shawn O. Pearce2006-11-27 04:44:47 -05001727 remote.*.*)
9244d69b SZEDER Gábor2011-04-28 18:01:51 +02001728 local pfx="${cur%.*}." cur_="${cur##*.}"
12977705 Shawn O. Pearce2007-05-24 02:07:45 -04001729 __gitcomp "
98171a07 Lee Marlow2008-12-15 10:45:49 -07001730 url proxy fetch push mirror skipDefaultUpdate
6fac1b83 Stephen Boyd2009-06-29 21:24:24 -07001731 receivepack uploadpack tagopt pushurl
9244d69b SZEDER Gábor2011-04-28 18:01:51 +02001732 " "$pfx" "$cur_"
5de40f59
SP
Shawn O. Pearce2006-11-27 04:44:47 -05001733 return
1734 ;;
1735 remote.*)
9244d69b SZEDER Gábor2011-04-28 18:01:51 +02001736 local pfx="${cur%.*}." cur_="${cur#*.}"
a31e6262 SZEDER Gábor2011-10-15 14:57:23 +02001737 __gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "."
5de40f59
SP
Shawn O. Pearce2006-11-27 04:44:47 -05001738 return
1739 ;;
0aa62fd0 Stephen Boyd2009-05-03 23:25:32 -07001740 url.*.*)
9244d69b
SG
SZEDER Gábor2011-04-28 18:01:51 +02001741 local pfx="${cur%.*}." cur_="${cur##*.}"
1742 __gitcomp "insteadOf pushInsteadOf" "$pfx" "$cur_"
0aa62fd0
SB
Stephen Boyd2009-05-03 23:25:32 -07001743 return
1744 ;;
5de40f59 Shawn O. Pearce2006-11-27 04:44:47 -05001745 esac
78d4d6a2 Shawn O. Pearce2007-02-04 02:38:37 -05001746 __gitcomp "
6068ac88
MZ
Martin von Zweigbergk2010-12-20 16:18:25 +01001747 add.ignoreErrors
1748 advice.commitBeforeMerge
1749 advice.detachedHead
1750 advice.implicitIdentity
1751 advice.pushNonFastForward
1752 advice.resolveConflict
1753 advice.statusHints
226b343c Stephen Boyd2009-05-03 23:25:31 -07001754 alias.
6068ac88 Martin von Zweigbergk2010-12-20 16:18:25 +01001755 am.keepcr
86c91f91 Giuseppe Bilotta2009-08-04 13:16:49 +02001756 apply.ignorewhitespace
5de40f59 Shawn O. Pearce2006-11-27 04:44:47 -05001757 apply.whitespace
98171a07
LM
Lee Marlow2008-12-15 10:45:49 -07001758 branch.autosetupmerge
1759 branch.autosetuprebase
6068ac88 Martin von Zweigbergk2010-12-20 16:18:25 +01001760 browser.
2122591b Josh Triplett2007-04-23 17:18:16 -07001761 clean.requireForce
78d4d6a2
SP
Shawn O. Pearce2007-02-04 02:38:37 -05001762 color.branch
1763 color.branch.current
1764 color.branch.local
78d4d6a2 Shawn O. Pearce2007-02-04 02:38:37 -05001765 color.branch.plain
025a1929 Lee Marlow2008-12-15 10:45:48 -07001766 color.branch.remote
6068ac88
MZ
Martin von Zweigbergk2010-12-20 16:18:25 +01001767 color.decorate.HEAD
1768 color.decorate.branch
1769 color.decorate.remoteBranch
1770 color.decorate.stash
1771 color.decorate.tag
a159ca0c Andy Parkins2006-12-13 09:13:28 +00001772 color.diff
025a1929 Lee Marlow2008-12-15 10:45:48 -07001773 color.diff.commit
78d4d6a2 Shawn O. Pearce2007-02-04 02:38:37 -05001774 color.diff.frag
6068ac88 Martin von Zweigbergk2010-12-20 16:18:25 +01001775 color.diff.func
025a1929 Lee Marlow2008-12-15 10:45:48 -07001776 color.diff.meta
78d4d6a2 Shawn O. Pearce2007-02-04 02:38:37 -05001777 color.diff.new
025a1929
LM
Lee Marlow2008-12-15 10:45:48 -07001778 color.diff.old
1779 color.diff.plain
78d4d6a2 Shawn O. Pearce2007-02-04 02:38:37 -05001780 color.diff.whitespace
226b343c Stephen Boyd2009-05-03 23:25:31 -07001781 color.grep
6068ac88
MZ
Martin von Zweigbergk2010-12-20 16:18:25 +01001782 color.grep.context
1783 color.grep.filename
1784 color.grep.function
1785 color.grep.linenumber
226b343c Stephen Boyd2009-05-03 23:25:31 -07001786 color.grep.match
6068ac88
MZ
Martin von Zweigbergk2010-12-20 16:18:25 +01001787 color.grep.selected
1788 color.grep.separator
98171a07 Lee Marlow2008-12-15 10:45:49 -07001789 color.interactive
6068ac88 Martin von Zweigbergk2010-12-20 16:18:25 +01001790 color.interactive.error
98171a07
LM
Lee Marlow2008-12-15 10:45:49 -07001791 color.interactive.header
1792 color.interactive.help
1793 color.interactive.prompt
a159ca0c Andy Parkins2006-12-13 09:13:28 +00001794 color.pager
6123d719 Markus Heidelberg2009-04-25 13:46:14 +02001795 color.showbranch
a159ca0c Andy Parkins2006-12-13 09:13:28 +00001796 color.status
78d4d6a2
SP
Shawn O. Pearce2007-02-04 02:38:37 -05001797 color.status.added
1798 color.status.changed
025a1929 Lee Marlow2008-12-15 10:45:48 -07001799 color.status.header
98171a07 Lee Marlow2008-12-15 10:45:49 -07001800 color.status.nobranch
78d4d6a2 Shawn O. Pearce2007-02-04 02:38:37 -05001801 color.status.untracked
98171a07
LM
Lee Marlow2008-12-15 10:45:49 -07001802 color.status.updated
1803 color.ui
6068ac88 Martin von Zweigbergk2010-12-20 16:18:25 +01001804 commit.status
98171a07 Lee Marlow2008-12-15 10:45:49 -07001805 commit.template
cdb791f6 Namhyung Kim2011-06-24 15:17:42 +09001806 core.abbrev
6068ac88
MZ
Martin von Zweigbergk2010-12-20 16:18:25 +01001807 core.askpass
1808 core.attributesfile
98171a07
LM
Lee Marlow2008-12-15 10:45:49 -07001809 core.autocrlf
1810 core.bare
6068ac88 Martin von Zweigbergk2010-12-20 16:18:25 +01001811 core.bigFileThreshold
025a1929 Lee Marlow2008-12-15 10:45:48 -07001812 core.compression
226b343c Stephen Boyd2009-05-03 23:25:31 -07001813 core.createObject
98171a07
LM
Lee Marlow2008-12-15 10:45:49 -07001814 core.deltaBaseCacheLimit
1815 core.editor
6068ac88 Martin von Zweigbergk2010-12-20 16:18:25 +01001816 core.eol
98171a07 Lee Marlow2008-12-15 10:45:49 -07001817 core.excludesfile
025a1929 Lee Marlow2008-12-15 10:45:48 -07001818 core.fileMode
98171a07 Lee Marlow2008-12-15 10:45:49 -07001819 core.fsyncobjectfiles
025a1929 Lee Marlow2008-12-15 10:45:48 -07001820 core.gitProxy
98171a07 Lee Marlow2008-12-15 10:45:49 -07001821 core.ignoreCygwinFSTricks
025a1929 Lee Marlow2008-12-15 10:45:48 -07001822 core.ignoreStat
6068ac88 Martin von Zweigbergk2010-12-20 16:18:25 +01001823 core.ignorecase
025a1929
LM
Lee Marlow2008-12-15 10:45:48 -07001824 core.logAllRefUpdates
1825 core.loosecompression
6068ac88 Martin von Zweigbergk2010-12-20 16:18:25 +01001826 core.notesRef
025a1929
LM
Lee Marlow2008-12-15 10:45:48 -07001827 core.packedGitLimit
1828 core.packedGitWindowSize
98171a07 Lee Marlow2008-12-15 10:45:49 -07001829 core.pager
025a1929 Lee Marlow2008-12-15 10:45:48 -07001830 core.preferSymlinkRefs
98171a07
LM
Lee Marlow2008-12-15 10:45:49 -07001831 core.preloadindex
1832 core.quotepath
025a1929 Lee Marlow2008-12-15 10:45:48 -07001833 core.repositoryFormatVersion
98171a07 Lee Marlow2008-12-15 10:45:49 -07001834 core.safecrlf
025a1929 Lee Marlow2008-12-15 10:45:48 -07001835 core.sharedRepository
6068ac88 Martin von Zweigbergk2010-12-20 16:18:25 +01001836 core.sparseCheckout
98171a07
LM
Lee Marlow2008-12-15 10:45:49 -07001837 core.symlinks
1838 core.trustctime
025a1929 Lee Marlow2008-12-15 10:45:48 -07001839 core.warnAmbiguousRefs
98171a07
LM
Lee Marlow2008-12-15 10:45:49 -07001840 core.whitespace
1841 core.worktree
1842 diff.autorefreshindex
df44483a Zbigniew Jędrzejewski-Szmek2012-03-01 13:26:46 +01001843 diff.statGraphWidth
98171a07 Lee Marlow2008-12-15 10:45:49 -07001844 diff.external
6068ac88 Martin von Zweigbergk2010-12-20 16:18:25 +01001845 diff.ignoreSubmodules
98171a07 Lee Marlow2008-12-15 10:45:49 -07001846 diff.mnemonicprefix
6068ac88 Martin von Zweigbergk2010-12-20 16:18:25 +01001847 diff.noprefix
78d4d6a2
SP
Shawn O. Pearce2007-02-04 02:38:37 -05001848 diff.renameLimit
1849 diff.renames
226b343c
SB
Stephen Boyd2009-05-03 23:25:31 -07001850 diff.suppressBlankEmpty
1851 diff.tool
1852 diff.wordRegex
0aa62fd0 Stephen Boyd2009-05-03 23:25:32 -07001853 difftool.
226b343c Stephen Boyd2009-05-03 23:25:31 -07001854 difftool.prompt
6068ac88 Martin von Zweigbergk2010-12-20 16:18:25 +01001855 fetch.recurseSubmodules
78d4d6a2 Shawn O. Pearce2007-02-04 02:38:37 -05001856 fetch.unpackLimit
226b343c
SB
Stephen Boyd2009-05-03 23:25:31 -07001857 format.attach
1858 format.cc
78d4d6a2 Shawn O. Pearce2007-02-04 02:38:37 -05001859 format.headers
98171a07
LM
Lee Marlow2008-12-15 10:45:49 -07001860 format.numbered
1861 format.pretty
d8e1e5df Stephen Boyd2010-06-15 22:59:26 -07001862 format.signature
226b343c
SB
Stephen Boyd2009-05-03 23:25:31 -07001863 format.signoff
1864 format.subjectprefix
98171a07 Lee Marlow2008-12-15 10:45:49 -07001865 format.suffix
226b343c Stephen Boyd2009-05-03 23:25:31 -07001866 format.thread
6068ac88
MZ
Martin von Zweigbergk2010-12-20 16:18:25 +01001867 format.to
1868 gc.
98171a07
LM
Lee Marlow2008-12-15 10:45:49 -07001869 gc.aggressiveWindow
1870 gc.auto
1871 gc.autopacklimit
12977705 Shawn O. Pearce2007-05-24 02:07:45 -04001872 gc.packrefs
98171a07 Lee Marlow2008-12-15 10:45:49 -07001873 gc.pruneexpire
78d4d6a2
SP
Shawn O. Pearce2007-02-04 02:38:37 -05001874 gc.reflogexpire
1875 gc.reflogexpireunreachable
1876 gc.rerereresolved
1877 gc.rerereunresolved
025a1929 Lee Marlow2008-12-15 10:45:48 -07001878 gitcvs.allbinary
226b343c Stephen Boyd2009-05-03 23:25:31 -07001879 gitcvs.commitmsgannotation
98171a07 Lee Marlow2008-12-15 10:45:49 -07001880 gitcvs.dbTableNamePrefix
025a1929
LM
Lee Marlow2008-12-15 10:45:48 -07001881 gitcvs.dbdriver
1882 gitcvs.dbname
1883 gitcvs.dbpass
025a1929
LM
Lee Marlow2008-12-15 10:45:48 -07001884 gitcvs.dbuser
1885 gitcvs.enabled
1886 gitcvs.logfile
98171a07 Lee Marlow2008-12-15 10:45:49 -07001887 gitcvs.usecrlfattr
0aa62fd0 Stephen Boyd2009-05-03 23:25:32 -07001888 guitool.
98171a07
LM
Lee Marlow2008-12-15 10:45:49 -07001889 gui.blamehistoryctx
1890 gui.commitmsgwidth
1891 gui.copyblamethreshold
1892 gui.diffcontext
1893 gui.encoding
1894 gui.fastcopyblame
1895 gui.matchtrackingbranch
1896 gui.newbranchtemplate
1897 gui.pruneduringfetch
1898 gui.spellingdictionary
1899 gui.trustmtime
1900 help.autocorrect
1901 help.browser
1902 help.format
78d4d6a2
SP
Shawn O. Pearce2007-02-04 02:38:37 -05001903 http.lowSpeedLimit
1904 http.lowSpeedTime
025a1929 Lee Marlow2008-12-15 10:45:48 -07001905 http.maxRequests
6068ac88 Martin von Zweigbergk2010-12-20 16:18:25 +01001906 http.minSessions
5de40f59 Shawn O. Pearce2006-11-27 04:44:47 -05001907 http.noEPSV
6068ac88 Martin von Zweigbergk2010-12-20 16:18:25 +01001908 http.postBuffer
98171a07 Lee Marlow2008-12-15 10:45:49 -07001909 http.proxy
025a1929
LM
Lee Marlow2008-12-15 10:45:48 -07001910 http.sslCAInfo
1911 http.sslCAPath
1912 http.sslCert
6068ac88 Martin von Zweigbergk2010-12-20 16:18:25 +01001913 http.sslCertPasswordProtected
025a1929
LM
Lee Marlow2008-12-15 10:45:48 -07001914 http.sslKey
1915 http.sslVerify
6068ac88 Martin von Zweigbergk2010-12-20 16:18:25 +01001916 http.useragent
78d4d6a2
SP
Shawn O. Pearce2007-02-04 02:38:37 -05001917 i18n.commitEncoding
1918 i18n.logOutputEncoding
6068ac88 Martin von Zweigbergk2010-12-20 16:18:25 +01001919 imap.authMethod
226b343c
SB
Stephen Boyd2009-05-03 23:25:31 -07001920 imap.folder
1921 imap.host
1922 imap.pass
1923 imap.port
1924 imap.preformattedHTML
1925 imap.sslverify
1926 imap.tunnel
1927 imap.user
6068ac88 Martin von Zweigbergk2010-12-20 16:18:25 +01001928 init.templatedir
98171a07
LM
Lee Marlow2008-12-15 10:45:49 -07001929 instaweb.browser
1930 instaweb.httpd
1931 instaweb.local
1932 instaweb.modulepath
1933 instaweb.port
226b343c Stephen Boyd2009-05-03 23:25:31 -07001934 interactive.singlekey
98171a07 Lee Marlow2008-12-15 10:45:49 -07001935 log.date
6068ac88 Martin von Zweigbergk2010-12-20 16:18:25 +01001936 log.decorate
78d4d6a2 Shawn O. Pearce2007-02-04 02:38:37 -05001937 log.showroot
226b343c Stephen Boyd2009-05-03 23:25:31 -07001938 mailmap.file
0aa62fd0 Stephen Boyd2009-05-03 23:25:32 -07001939 man.
98171a07 Lee Marlow2008-12-15 10:45:49 -07001940 man.viewer
6068ac88 Martin von Zweigbergk2010-12-20 16:18:25 +01001941 merge.
98171a07
LM
Lee Marlow2008-12-15 10:45:49 -07001942 merge.conflictstyle
1943 merge.log
1944 merge.renameLimit
6068ac88 Martin von Zweigbergk2010-12-20 16:18:25 +01001945 merge.renormalize
98171a07 Lee Marlow2008-12-15 10:45:49 -07001946 merge.stat
025a1929 Lee Marlow2008-12-15 10:45:48 -07001947 merge.tool
78d4d6a2 Shawn O. Pearce2007-02-04 02:38:37 -05001948 merge.verbosity
0aa62fd0 Stephen Boyd2009-05-03 23:25:32 -07001949 mergetool.
98171a07 Lee Marlow2008-12-15 10:45:49 -07001950 mergetool.keepBackup
6068ac88 Martin von Zweigbergk2010-12-20 16:18:25 +01001951 mergetool.keepTemporaries
226b343c Stephen Boyd2009-05-03 23:25:31 -07001952 mergetool.prompt
6068ac88
MZ
Martin von Zweigbergk2010-12-20 16:18:25 +01001953 notes.displayRef
1954 notes.rewrite.
1955 notes.rewrite.amend
1956 notes.rewrite.rebase
1957 notes.rewriteMode
1958 notes.rewriteRef
47e98eec Shawn O. Pearce2007-08-23 01:39:22 -04001959 pack.compression
47e98eec Shawn O. Pearce2007-08-23 01:39:22 -04001960 pack.deltaCacheLimit
025a1929
LM
Lee Marlow2008-12-15 10:45:48 -07001961 pack.deltaCacheSize
1962 pack.depth
98171a07
LM
Lee Marlow2008-12-15 10:45:49 -07001963 pack.indexVersion
1964 pack.packSizeLimit
1965 pack.threads
025a1929
LM
Lee Marlow2008-12-15 10:45:48 -07001966 pack.window
1967 pack.windowMemory
0aa62fd0 Stephen Boyd2009-05-03 23:25:32 -07001968 pager.
6068ac88 Martin von Zweigbergk2010-12-20 16:18:25 +01001969 pretty.
78d4d6a2
SP
Shawn O. Pearce2007-02-04 02:38:37 -05001970 pull.octopus
1971 pull.twohead
226b343c Stephen Boyd2009-05-03 23:25:31 -07001972 push.default
6068ac88 Martin von Zweigbergk2010-12-20 16:18:25 +01001973 rebase.autosquash
226b343c Stephen Boyd2009-05-03 23:25:31 -07001974 rebase.stat
6068ac88 Martin von Zweigbergk2010-12-20 16:18:25 +01001975 receive.autogc
98171a07 Lee Marlow2008-12-15 10:45:49 -07001976 receive.denyCurrentBranch
6068ac88 Martin von Zweigbergk2010-12-20 16:18:25 +01001977 receive.denyDeleteCurrent
98171a07 Lee Marlow2008-12-15 10:45:49 -07001978 receive.denyDeletes
025a1929 Lee Marlow2008-12-15 10:45:48 -07001979 receive.denyNonFastForwards
98171a07 Lee Marlow2008-12-15 10:45:49 -07001980 receive.fsckObjects
025a1929 Lee Marlow2008-12-15 10:45:48 -07001981 receive.unpackLimit
6068ac88
MZ
Martin von Zweigbergk2010-12-20 16:18:25 +01001982 receive.updateserverinfo
1983 remotes.
98171a07
LM
Lee Marlow2008-12-15 10:45:49 -07001984 repack.usedeltabaseoffset
1985 rerere.autoupdate
1986 rerere.enabled
6068ac88 Martin von Zweigbergk2010-12-20 16:18:25 +01001987 sendemail.
226b343c Stephen Boyd2009-05-03 23:25:31 -07001988 sendemail.aliasesfile
6068ac88 Martin von Zweigbergk2010-12-20 16:18:25 +01001989 sendemail.aliasfiletype
226b343c
SB
Stephen Boyd2009-05-03 23:25:31 -07001990 sendemail.bcc
1991 sendemail.cc
1992 sendemail.cccmd
1993 sendemail.chainreplyto
1994 sendemail.confirm
1995 sendemail.envelopesender
6068ac88
MZ
Martin von Zweigbergk2010-12-20 16:18:25 +01001996 sendemail.from
1997 sendemail.identity
226b343c
SB
Stephen Boyd2009-05-03 23:25:31 -07001998 sendemail.multiedit
1999 sendemail.signedoffbycc
6068ac88 Martin von Zweigbergk2010-12-20 16:18:25 +01002000 sendemail.smtpdomain
226b343c
SB
Stephen Boyd2009-05-03 23:25:31 -07002001 sendemail.smtpencryption
2002 sendemail.smtppass
2003 sendemail.smtpserver
6068ac88 Martin von Zweigbergk2010-12-20 16:18:25 +01002004 sendemail.smtpserveroption
226b343c
SB
Stephen Boyd2009-05-03 23:25:31 -07002005 sendemail.smtpserverport
2006 sendemail.smtpuser
2007 sendemail.suppresscc
2008 sendemail.suppressfrom
2009 sendemail.thread
2010 sendemail.to
2011 sendemail.validate
78d4d6a2 Shawn O. Pearce2007-02-04 02:38:37 -05002012 showbranch.default
98171a07
LM
Lee Marlow2008-12-15 10:45:49 -07002013 status.relativePaths
2014 status.showUntrackedFiles
6068ac88
MZ
Martin von Zweigbergk2010-12-20 16:18:25 +01002015 status.submodulesummary
2016 submodule.
78d4d6a2
SP
Shawn O. Pearce2007-02-04 02:38:37 -05002017 tar.umask
2018 transfer.unpackLimit
0aa62fd0 Stephen Boyd2009-05-03 23:25:32 -07002019 url.
78d4d6a2 Shawn O. Pearce2007-02-04 02:38:37 -05002020 user.email
025a1929 Lee Marlow2008-12-15 10:45:48 -07002021 user.name
78d4d6a2 Shawn O. Pearce2007-02-04 02:38:37 -05002022 user.signingkey
98171a07 Lee Marlow2008-12-15 10:45:49 -07002023 web.browser
5de40f59 Shawn O. Pearce2006-11-27 04:44:47 -05002024 branch. remote.
78d4d6a2 Shawn O. Pearce2007-02-04 02:38:37 -05002025 "
5de40f59
SP
Shawn O. Pearce2006-11-27 04:44:47 -05002026}
2027
88293c67
SP
Shawn O. Pearce2007-02-04 23:52:08 -05002028_git_remote ()
2029{
f1c6ffe6 Philip Jägenstedt2012-02-22 09:58:10 +01002030 local subcommands="add rename rm set-head set-branches set-url show prune update"
918c03c2 SZEDER Gábor2009-09-15 12:21:43 +02002031 local subcommand="$(__git_find_on_cmdline "$subcommands")"
3ff1320d SZEDER Gábor2008-03-10 16:02:23 +01002032 if [ -z "$subcommand" ]; then
3903c618 Dan McGee2008-04-20 14:34:07 -05002033 __gitcomp "$subcommands"
88293c67
SP
Shawn O. Pearce2007-02-04 23:52:08 -05002034 return
2035 fi
2036
3ff1320d SZEDER Gábor2008-03-10 16:02:23 +01002037 case "$subcommand" in
f1c6ffe6 Philip Jägenstedt2012-02-22 09:58:10 +01002038 rename|rm|set-url|show|prune)
a31e6262 SZEDER Gábor2011-10-15 14:57:23 +02002039 __gitcomp_nl "$(__git_remotes)"
88293c67 Shawn O. Pearce2007-02-04 23:52:08 -05002040 ;;
f1c6ffe6
PJ
Philip Jägenstedt2012-02-22 09:58:10 +01002041 set-head|set-branches)
2042 __git_complete_remote_or_refspec
2043 ;;
fb72759b
SP
Shawn O. Pearce2007-05-24 01:46:49 -04002044 update)
2045 local i c='' IFS=$'\n'
518ef8f0
TZ
Todd Zullinger2009-09-11 19:23:45 -04002046 for i in $(git --git-dir="$(__gitdir)" config --get-regexp "remotes\..*" 2>/dev/null); do
2047 i="${i#remotes.}"
2048 c="$c ${i/ */}"
fb72759b
SP
Shawn O. Pearce2007-05-24 01:46:49 -04002049 done
2050 __gitcomp "$c"
2051 ;;
88293c67
SP
Shawn O. Pearce2007-02-04 23:52:08 -05002052 *)
2053 COMPREPLY=()
2054 ;;
2055 esac
2056}
2057
e1c1a067
BG
Björn Gustavsson2009-10-09 22:49:06 +02002058_git_replace ()
2059{
a31e6262 SZEDER Gábor2011-10-15 14:57:23 +02002060 __gitcomp_nl "$(__git_refs)"
e1c1a067
BG
Björn Gustavsson2009-10-09 22:49:06 +02002061}
2062
67e78c3b
SP
Shawn O. Pearce2006-11-04 13:57:44 -05002063_git_reset ()
2064{
d773c631
SG
SZEDER Gábor2008-07-08 18:56:14 +02002065 __git_has_doubledash && return
2066
b3391775
SP
Shawn O. Pearce2007-02-04 02:38:43 -05002067 case "$cur" in
2068 --*)
9f040e95 SZEDER Gábor2009-09-15 12:21:45 +02002069 __gitcomp "--merge --mixed --hard --soft --patch"
b3391775
SP
Shawn O. Pearce2007-02-04 02:38:43 -05002070 return
2071 ;;
2072 esac
a31e6262 SZEDER Gábor2011-10-15 14:57:23 +02002073 __gitcomp_nl "$(__git_refs)"
67e78c3b
SP
Shawn O. Pearce2006-11-04 13:57:44 -05002074}
2075
a6c2be24
LM
Lee Marlow2008-08-04 23:50:34 -06002076_git_revert ()
2077{
a6c2be24
LM
Lee Marlow2008-08-04 23:50:34 -06002078 case "$cur" in
2079 --*)
2080 __gitcomp "--edit --mainline --no-edit --no-commit --signoff"
2081 return
2082 ;;
2083 esac
a31e6262 SZEDER Gábor2011-10-15 14:57:23 +02002084 __gitcomp_nl "$(__git_refs)"
a6c2be24
LM
Lee Marlow2008-08-04 23:50:34 -06002085}
2086
08c701d4
LM
Lee Marlow2008-07-23 15:21:08 -06002087_git_rm ()
2088{
2089 __git_has_doubledash && return
2090
08c701d4
LM
Lee Marlow2008-07-23 15:21:08 -06002091 case "$cur" in
2092 --*)
2093 __gitcomp "--cached --dry-run --ignore-unmatch --quiet"
2094 return
2095 ;;
2096 esac
2097 COMPREPLY=()
2098}
2099
1fd6bec9
SP
Shawn O. Pearce2007-05-24 01:25:34 -04002100_git_shortlog ()
2101{
d773c631
SG
SZEDER Gábor2008-07-08 18:56:14 +02002102 __git_has_doubledash && return
2103
1fd6bec9
SP
Shawn O. Pearce2007-05-24 01:25:34 -04002104 case "$cur" in
2105 --*)
2106 __gitcomp "
a393777e
TR
Thomas Rast2009-02-16 17:34:56 +01002107 $__git_log_common_options
2108 $__git_log_shortlog_options
1fd6bec9
SP
Shawn O. Pearce2007-05-24 01:25:34 -04002109 --numbered --summary
2110 "
2111 return
2112 ;;
2113 esac
2114 __git_complete_revlist
2115}
2116
90131924
SP
Shawn O. Pearce2006-12-15 02:20:03 -05002117_git_show ()
2118{
41d8cf7d
MH
Markus Heidelberg2008-10-31 01:04:46 +01002119 __git_has_doubledash && return
2120
90131924 Shawn O. Pearce2006-12-15 02:20:03 -05002121 case "$cur" in
e67d71e5 SZEDER Gábor2011-10-08 03:09:34 +02002122 --pretty=*|--format=*)
c3898111 SZEDER Gábor2010-10-11 00:06:22 +02002123 __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
e67d71e5 SZEDER Gábor2011-10-08 03:09:34 +02002124 " "" "${cur#*=}"
72de29c2
TL
Teemu Likonen2009-02-24 15:33:29 +02002125 return
2126 ;;
90131924 Shawn O. Pearce2006-12-15 02:20:03 -05002127 --*)
076c3237 Stephen Boyd2009-05-16 20:42:43 -07002128 __gitcomp "--pretty= --format= --abbrev-commit --oneline
20bf7292
TR
Thomas Rast2009-01-19 22:18:00 +01002129 $__git_diff_common_options
2130 "
90131924
SP
Shawn O. Pearce2006-12-15 02:20:03 -05002131 return
2132 ;;
2133 esac
2134 __git_complete_file
2135}
2136
2ca880fe
TR
Thomas Rast2008-07-23 23:36:15 +02002137_git_show_branch ()
2138{
2ca880fe
TR
Thomas Rast2008-07-23 23:36:15 +02002139 case "$cur" in
2140 --*)
2141 __gitcomp "
2142 --all --remotes --topo-order --current --more=
2143 --list --independent --merge-base --no-name
6123d719 Markus Heidelberg2009-04-25 13:46:14 +02002144 --color --no-color
076c3237 Stephen Boyd2009-05-16 20:42:43 -07002145 --sha1-name --sparse --topics --reflog
2ca880fe
TR
Thomas Rast2008-07-23 23:36:15 +02002146 "
2147 return
2148 ;;
2149 esac
2150 __git_complete_revlist
2151}
2152
7fd53fce
JH
Junio C Hamano2007-08-03 02:04:37 -07002153_git_stash ()
2154{
59d5eeee SZEDER Gábor2009-09-15 12:21:44 +02002155 local save_opts='--keep-index --no-keep-index --quiet --patch'
95d43780 Lee Marlow2008-08-04 23:50:35 -06002156 local subcommands='save list show apply clear drop pop create branch'
918c03c2 SZEDER Gábor2009-09-15 12:21:43 +02002157 local subcommand="$(__git_find_on_cmdline "$subcommands")"
7bedebca SZEDER Gábor2008-06-27 16:37:15 +02002158 if [ -z "$subcommand" ]; then
59d5eeee
SG
SZEDER Gábor2009-09-15 12:21:44 +02002159 case "$cur" in
2160 --*)
2161 __gitcomp "$save_opts"
2162 ;;
2163 *)
2164 if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then
2165 __gitcomp "$subcommands"
2166 else
2167 COMPREPLY=()
2168 fi
2169 ;;
2170 esac
7bedebca SZEDER Gábor2008-06-27 16:37:15 +02002171 else
7bedebca
SG
SZEDER Gábor2008-06-27 16:37:15 +02002172 case "$subcommand,$cur" in
2173 save,--*)
59d5eeee SZEDER Gábor2009-09-15 12:21:44 +02002174 __gitcomp "$save_opts"
7bedebca SZEDER Gábor2008-06-27 16:37:15 +02002175 ;;
8513c54b SZEDER Gábor2009-06-09 00:57:39 +02002176 apply,--*|pop,--*)
59d5eeee SZEDER Gábor2009-09-15 12:21:44 +02002177 __gitcomp "--index --quiet"
95d43780 Lee Marlow2008-08-04 23:50:35 -06002178 ;;
8513c54b SZEDER Gábor2009-06-09 00:57:39 +02002179 show,--*|drop,--*|branch,--*)
95d43780
LM
Lee Marlow2008-08-04 23:50:35 -06002180 COMPREPLY=()
2181 ;;
2182 show,*|apply,*|drop,*|pop,*|branch,*)
a31e6262 SZEDER Gábor2011-10-15 14:57:23 +02002183 __gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \
95d43780
LM
Lee Marlow2008-08-04 23:50:35 -06002184 | sed -n -e 's/:.*//p')"
2185 ;;
7bedebca
SG
SZEDER Gábor2008-06-27 16:37:15 +02002186 *)
2187 COMPREPLY=()
2188 ;;
2189 esac
3ff1320d SZEDER Gábor2008-03-10 16:02:23 +01002190 fi
7fd53fce
JH
Junio C Hamano2007-08-03 02:04:37 -07002191}
2192
be86f7a0
SP
Shawn O. Pearce2007-08-23 01:50:49 -04002193_git_submodule ()
2194{
d773c631
SG
SZEDER Gábor2008-07-08 18:56:14 +02002195 __git_has_doubledash && return
2196
1b0f7978 Matthias Kestenholz2008-08-28 10:57:55 +02002197 local subcommands="add status init update summary foreach sync"
918c03c2 SZEDER Gábor2009-09-15 12:21:43 +02002198 if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then
be86f7a0
SP
Shawn O. Pearce2007-08-23 01:50:49 -04002199 case "$cur" in
2200 --*)
2201 __gitcomp "--quiet --cached"
2202 ;;
2203 *)
3ff1320d SZEDER Gábor2008-03-10 16:02:23 +01002204 __gitcomp "$subcommands"
be86f7a0
SP
Shawn O. Pearce2007-08-23 01:50:49 -04002205 ;;
2206 esac
2207 return
2208 fi
2209}
2210
47f6ee28
SG
SZEDER Gábor2008-03-10 16:02:25 +01002211_git_svn ()
2212{
2213 local subcommands="
2214 init fetch clone rebase dcommit log find-rev
2215 set-tree commit-diff info create-ignore propget
4a5856cb SZEDER Gábor2009-02-14 17:21:53 +01002216 proplist show-ignore show-externals branch tag blame
c18d5d82 Robert Zeh2009-12-29 18:58:48 -06002217 migrate mkdirs reset gc
47f6ee28 SZEDER Gábor2008-03-10 16:02:25 +01002218 "
918c03c2 SZEDER Gábor2009-09-15 12:21:43 +02002219 local subcommand="$(__git_find_on_cmdline "$subcommands")"
47f6ee28
SG
SZEDER Gábor2008-03-10 16:02:25 +01002220 if [ -z "$subcommand" ]; then
2221 __gitcomp "$subcommands"
2222 else
2223 local remote_opts="--username= --config-dir= --no-auth-cache"
2224 local fc_opts="
2225 --follow-parent --authors-file= --repack=
2226 --no-metadata --use-svm-props --use-svnsync-props
2227 --log-window-size= --no-checkout --quiet
4a5856cb
SG
SZEDER Gábor2009-02-14 17:21:53 +01002228 --repack-flags --use-log-author --localtime
2229 --ignore-paths= $remote_opts
47f6ee28
SG
SZEDER Gábor2008-03-10 16:02:25 +01002230 "
2231 local init_opts="
2232 --template= --shared= --trunk= --tags=
2233 --branches= --stdlayout --minimize-url
2234 --no-metadata --use-svm-props --use-svnsync-props
4a5856cb
SG
SZEDER Gábor2009-02-14 17:21:53 +01002235 --rewrite-root= --prefix= --use-log-author
2236 --add-author-from $remote_opts
47f6ee28
SG
SZEDER Gábor2008-03-10 16:02:25 +01002237 "
2238 local cmt_opts="
2239 --edit --rmdir --find-copies-harder --copy-similarity=
2240 "
2241
47f6ee28
SG
SZEDER Gábor2008-03-10 16:02:25 +01002242 case "$subcommand,$cur" in
2243 fetch,--*)
2244 __gitcomp "--revision= --fetch-all $fc_opts"
2245 ;;
2246 clone,--*)
2247 __gitcomp "--revision= $fc_opts $init_opts"
2248 ;;
2249 init,--*)
2250 __gitcomp "$init_opts"
2251 ;;
2252 dcommit,--*)
2253 __gitcomp "
2254 --merge --strategy= --verbose --dry-run
4a5856cb SZEDER Gábor2009-02-14 17:21:53 +01002255 --fetch-all --no-rebase --commit-url
7b151f49 Frédéric Heitzmann2011-11-03 19:33:30 +01002256 --revision --interactive $cmt_opts $fc_opts
47f6ee28
SG
SZEDER Gábor2008-03-10 16:02:25 +01002257 "
2258 ;;
2259 set-tree,--*)
2260 __gitcomp "--stdin $cmt_opts $fc_opts"
2261 ;;
2262 create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\
c18d5d82 Robert Zeh2009-12-29 18:58:48 -06002263 show-externals,--*|mkdirs,--*)
47f6ee28
SG
SZEDER Gábor2008-03-10 16:02:25 +01002264 __gitcomp "--revision="
2265 ;;
2266 log,--*)
2267 __gitcomp "
2268 --limit= --revision= --verbose --incremental
2269 --oneline --show-commit --non-recursive
4a5856cb SZEDER Gábor2009-02-14 17:21:53 +01002270 --authors-file= --color
47f6ee28
SG
SZEDER Gábor2008-03-10 16:02:25 +01002271 "
2272 ;;
2273 rebase,--*)
2274 __gitcomp "
2275 --merge --verbose --strategy= --local
4a5856cb SZEDER Gábor2009-02-14 17:21:53 +01002276 --fetch-all --dry-run $fc_opts
47f6ee28
SG
SZEDER Gábor2008-03-10 16:02:25 +01002277 "
2278 ;;
2279 commit-diff,--*)
2280 __gitcomp "--message= --file= --revision= $cmt_opts"
2281 ;;
2282 info,--*)
2283 __gitcomp "--url"
2284 ;;
4a5856cb
SG
SZEDER Gábor2009-02-14 17:21:53 +01002285 branch,--*)
2286 __gitcomp "--dry-run --message --tag"
2287 ;;
2288 tag,--*)
2289 __gitcomp "--dry-run --message"
2290 ;;
2291 blame,--*)
2292 __gitcomp "--git-format"
2293 ;;
2294 migrate,--*)
2295 __gitcomp "
2296 --config-dir= --ignore-paths= --minimize
2297 --no-auth-cache --username=
2298 "
2299 ;;
c18d5d82
RZ
Robert Zeh2009-12-29 18:58:48 -06002300 reset,--*)
2301 __gitcomp "--revision= --parent"
2302 ;;
47f6ee28
SG
SZEDER Gábor2008-03-10 16:02:25 +01002303 *)
2304 COMPREPLY=()
2305 ;;
2306 esac
2307 fi
2308}
2309
88e21dc7
SP
Shawn O. Pearce2007-08-31 23:47:01 -04002310_git_tag ()
2311{
2312 local i c=1 f=0
da48616f
PD
Peter van der Does2010-12-02 02:17:13 -06002313 while [ $c -lt $cword ]; do
2314 i="${words[c]}"
88e21dc7
SP
Shawn O. Pearce2007-08-31 23:47:01 -04002315 case "$i" in
2316 -d|-v)
a31e6262 SZEDER Gábor2011-10-15 14:57:23 +02002317 __gitcomp_nl "$(__git_tags)"
88e21dc7
SP
Shawn O. Pearce2007-08-31 23:47:01 -04002318 return
2319 ;;
2320 -f)
2321 f=1
2322 ;;
2323 esac
6e8c755f Philip Jägenstedt2012-02-22 09:58:11 +01002324 ((c++))
88e21dc7
SP
Shawn O. Pearce2007-08-31 23:47:01 -04002325 done
2326
da48616f Peter van der Does2010-12-02 02:17:13 -06002327 case "$prev" in
88e21dc7
SP
Shawn O. Pearce2007-08-31 23:47:01 -04002328 -m|-F)
2329 COMPREPLY=()
2330 ;;
8d8163f3 SZEDER Gábor2008-11-27 14:35:38 +01002331 -*|tag)
88e21dc7 Shawn O. Pearce2007-08-31 23:47:01 -04002332 if [ $f = 1 ]; then
a31e6262 SZEDER Gábor2011-10-15 14:57:23 +02002333 __gitcomp_nl "$(__git_tags)"
88e21dc7
SP
Shawn O. Pearce2007-08-31 23:47:01 -04002334 else
2335 COMPREPLY=()
2336 fi
2337 ;;
2338 *)
a31e6262 SZEDER Gábor2011-10-15 14:57:23 +02002339 __gitcomp_nl "$(__git_refs)"
88e21dc7
SP
Shawn O. Pearce2007-08-31 23:47:01 -04002340 ;;
2341 esac
2342}
2343
424cce83
SG
SZEDER Gábor2010-02-23 22:02:58 +01002344_git_whatchanged ()
2345{
2346 _git_log
2347}
2348
690d8824
JH
Junio C Hamano2006-09-28 02:31:25 -07002349_git ()
2350{
873537fa
SP
Shawn O. Pearce2006-11-05 06:21:57 -05002351 local i c=1 command __git_dir
2352
da48616f
PD
Peter van der Does2010-12-02 02:17:13 -06002353 while [ $c -lt $cword ]; do
2354 i="${words[c]}"
873537fa
SP
Shawn O. Pearce2006-11-05 06:21:57 -05002355 case "$i" in
2356 --git-dir=*) __git_dir="${i#--git-dir=}" ;;
2357 --bare) __git_dir="." ;;
1eb7e2f8 Lee Marlow2008-07-23 18:07:23 -06002358 --help) command="help"; break ;;
911d5da6
SG
SZEDER Gábor2012-04-15 22:44:20 +03002359 -c) c=$((++c)) ;;
2360 -*) ;;
873537fa
SP
Shawn O. Pearce2006-11-05 06:21:57 -05002361 *) command="$i"; break ;;
2362 esac
6e8c755f Philip Jägenstedt2012-02-22 09:58:11 +01002363 ((c++))
873537fa
SP
Shawn O. Pearce2006-11-05 06:21:57 -05002364 done
2365
1d17b22e SZEDER Gábor2008-03-10 16:02:22 +01002366 if [ -z "$command" ]; then
da48616f Peter van der Does2010-12-02 02:17:13 -06002367 case "$cur" in
47e98eec Shawn O. Pearce2007-08-23 01:39:22 -04002368 --*) __gitcomp "
ce5a2c95 Teemu Likonen2008-03-06 18:52:37 +02002369 --paginate
47e98eec
SP
Shawn O. Pearce2007-08-23 01:39:22 -04002370 --no-pager
2371 --git-dir=
2372 --bare
2373 --version
2374 --exec-path
3ffcd086 Jonathan Nieder2012-04-15 22:44:19 +03002375 --exec-path=
89a56bfb Markus Heidelberg2009-04-05 04:15:16 +02002376 --html-path
69ef3c02 Felipe Contreras2012-04-15 22:44:18 +03002377 --info-path
ce5a2c95 Teemu Likonen2008-03-06 18:52:37 +02002378 --work-tree=
a1bea2c1 Josh Triplett2011-07-05 10:54:44 -07002379 --namespace=
69ef3c02 Felipe Contreras2012-04-15 22:44:18 +03002380 --no-replace-objects
ce5a2c95 Teemu Likonen2008-03-06 18:52:37 +02002381 --help
47e98eec
SP
Shawn O. Pearce2007-08-23 01:39:22 -04002382 "
2383 ;;
eaa4e6ee
JN
Jonathan Nieder2009-11-17 18:49:10 -06002384 *) __git_compute_porcelain_commands
2385 __gitcomp "$__git_porcelain_commands $(__git_aliases)" ;;
72e5e989
SP
Shawn O. Pearce2007-02-04 02:38:27 -05002386 esac
2387 return
873537fa Shawn O. Pearce2006-11-05 06:21:57 -05002388 fi
367dce2a Dennis Stosberg2006-10-28 14:12:20 +02002389
424cce83 SZEDER Gábor2010-02-23 22:02:58 +01002390 local completion_func="_git_${command//-/_}"
06f44c3c Mark Lodato2010-09-06 08:33:19 -04002391 declare -f $completion_func >/dev/null && $completion_func && return
8024ea60 SZEDER Gábor2010-02-23 22:02:59 +01002392
873537fa Shawn O. Pearce2006-11-05 06:21:57 -05002393 local expansion=$(__git_aliased_command "$command")
8024ea60
SG
SZEDER Gábor2010-02-23 22:02:59 +01002394 if [ -n "$expansion" ]; then
2395 completion_func="_git_${expansion//-/_}"
06f44c3c Mark Lodato2010-09-06 08:33:19 -04002396 declare -f $completion_func >/dev/null && $completion_func
8024ea60 SZEDER Gábor2010-02-23 22:02:59 +01002397 fi
690d8824
JH
Junio C Hamano2006-09-28 02:31:25 -07002398}
2399
2400_gitk ()
2401{
d773c631
SG
SZEDER Gábor2008-07-08 18:56:14 +02002402 __git_has_doubledash && return
2403
fa26a401 Ted Pavlic2009-02-11 13:03:23 -05002404 local g="$(__gitdir)"
07ba53f7 Richard Quirk2008-04-27 17:35:10 +02002405 local merge=""
ba7906f2 Daniel Cheng (aka SDiZ)2009-03-30 19:27:37 +08002406 if [ -f "$g/MERGE_HEAD" ]; then
07ba53f7
RQ
Richard Quirk2008-04-27 17:35:10 +02002407 merge="--merge"
2408 fi
b3391775
SP
Shawn O. Pearce2007-02-04 02:38:43 -05002409 case "$cur" in
2410 --*)
a393777e
TR
Thomas Rast2009-02-16 17:34:56 +01002411 __gitcomp "
2412 $__git_log_common_options
2413 $__git_log_gitk_options
2414 $merge
2415 "
b3391775
SP
Shawn O. Pearce2007-02-04 02:38:43 -05002416 return
2417 ;;
2418 esac
ec804891 Shawn O. Pearce2007-02-04 02:38:47 -05002419 __git_complete_revlist
690d8824
JH
Junio C Hamano2006-09-28 02:31:25 -07002420}
2421
6b179adf
FC
Felipe Contreras2012-05-14 17:35:18 +02002422__git_func_wrap ()
2423{
2424 if [[ -n ${ZSH_VERSION-} ]]; then
2425 emulate -L bash
2426 setopt KSH_TYPESET
2427
2428 # workaround zsh's bug that leaves 'words' as a special
2429 # variable in versions < 4.3.12
2430 typeset -h words
2431
2432 # workaround zsh's bug that quotes spaces in the COMPREPLY
2433 # array if IFS doesn't contain spaces.
2434 typeset -h IFS
2435 fi
2436 local cur words cword prev
2437 _get_comp_words_by_ref -n =: cur words cword prev
2438 $1
2439}
2440
2441# Setup completion for certain functions defined above by setting common
2442# variables and workarounds.
2443# This is NOT a public function; use at your own risk.
2444__git_complete ()
2445{
2446 local wrapper="__git_wrap${2}"
2447 eval "$wrapper () { __git_func_wrap $2 ; }"
2448 complete -o bashdefault -o default -o nospace -F $wrapper $1 2>/dev/null \
2449 || complete -o default -o nospace -F $wrapper $1
2450}
2451
2452__git_complete git _git
2453__git_complete gitk _gitk
690d8824
JH
Junio C Hamano2006-09-28 02:31:25 -07002454
2455# The following are necessary only for Cygwin, and only are needed
2456# when the user has tab-completed the executable name and consequently
2457# included the '.exe' suffix.
2458#
76c3eb51 Shawn O. Pearce2006-11-05 06:20:25 -05002459if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
6b179adf Felipe Contreras2012-05-14 17:35:18 +02002460__git_complete git.exe _git
76c3eb51 Shawn O. Pearce2006-11-05 06:20:25 -05002461fi