]>
Commit | Line | Data |
---|---|---|
b5a49471 | 1 | # bash/zsh completion support for core Git. |
690d8824 | 2 | # |
c70680ce | 3 | # Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org> |
690d8824 | 4 | # Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/). |
c70680ce | 5 | # Distributed under the GNU General Public License, version 2.0. |
690d8824 JH |
6 | # |
7 | # The contained completion routines provide support for completing: | |
8 | # | |
9 | # *) local and remote branch names | |
10 | # *) local and remote tag names | |
11 | # *) .git/remotes file names | |
12 | # *) git 'subcommands' | |
dfbe5eeb | 13 | # *) git email aliases for git-send-email |
690d8824 | 14 | # *) tree paths within 'ref:path/to/file' expressions |
fea16b47 | 15 | # *) file paths within current working directory and index |
c70680ce | 16 | # *) common --long-options |
690d8824 JH |
17 | # |
18 | # To use these routines: | |
19 | # | |
0e5ed7cc | 20 | # 1) Copy this file to somewhere (e.g. ~/.git-completion.bash). |
b5a49471 | 21 | # 2) Add the following line to your .bashrc/.zshrc: |
0e5ed7cc | 22 | # source ~/.git-completion.bash |
af31a456 FC |
23 | # 3) Consider changing your PS1 to also show the current branch, |
24 | # see git-prompt.sh for details. | |
56f24e80 SP |
25 | # |
26 | # If you use complex aliases of form '!f() { ... }; f', you can use the null | |
27 | # command ':' as the first command in the function body to declare the desired | |
28 | # completion style. For example '!f() { : git commit ; ... }; f' will | |
29 | # tell the completion to use commit completion. This also works with aliases | |
30 | # of form "!sh -c '...'". For example, "!sh -c ': git commit ; ... '". | |
60e71bbc JK |
31 | # |
32 | # You can set the following environment variables to influence the behavior of | |
33 | # the completion routines: | |
34 | # | |
35 | # GIT_COMPLETION_CHECKOUT_NO_GUESS | |
36 | # | |
37 | # When set to "1", do not include "DWIM" suggestions in git-checkout | |
38 | # completion (e.g., completing "foo" when "origin/foo" exists). | |
690d8824 | 39 | |
db8a9ff0 SP |
40 | case "$COMP_WORDBREAKS" in |
41 | *:*) : great ;; | |
42 | *) COMP_WORDBREAKS="$COMP_WORDBREAKS:" | |
43 | esac | |
44 | ||
beb6ee71 SG |
45 | # Discovers the path to the git repository taking any '--git-dir=<path>' and |
46 | # '-C <path>' options into account and stores it in the $__git_repo_path | |
47 | # variable. | |
48 | __git_find_repo_path () | |
49 | { | |
fad9484f SG |
50 | if [ -n "$__git_repo_path" ]; then |
51 | # we already know where it is | |
52 | return | |
53 | fi | |
54 | ||
beb6ee71 SG |
55 | if [ -n "${__git_C_args-}" ]; then |
56 | __git_repo_path="$(git "${__git_C_args[@]}" \ | |
57 | ${__git_dir:+--git-dir="$__git_dir"} \ | |
58 | rev-parse --absolute-git-dir 2>/dev/null)" | |
59 | elif [ -n "${__git_dir-}" ]; then | |
60 | test -d "$__git_dir" && | |
61 | __git_repo_path="$__git_dir" | |
62 | elif [ -n "${GIT_DIR-}" ]; then | |
63 | test -d "${GIT_DIR-}" && | |
64 | __git_repo_path="$GIT_DIR" | |
65 | elif [ -d .git ]; then | |
66 | __git_repo_path=.git | |
67 | else | |
68 | __git_repo_path="$(git rev-parse --git-dir 2>/dev/null)" | |
69 | fi | |
70 | } | |
71 | ||
fad9484f | 72 | # Deprecated: use __git_find_repo_path() and $__git_repo_path instead |
a42577d4 TP |
73 | # __gitdir accepts 0 or 1 arguments (i.e., location) |
74 | # returns location of .git repo | |
873537fa SP |
75 | __gitdir () |
76 | { | |
25a31f81 | 77 | if [ -z "${1-}" ]; then |
beb6ee71 SG |
78 | __git_find_repo_path || return 1 |
79 | echo "$__git_repo_path" | |
67ffa114 SP |
80 | elif [ -d "$1/.git" ]; then |
81 | echo "$1/.git" | |
82 | else | |
83 | echo "$1" | |
84 | fi | |
873537fa SP |
85 | } |
86 | ||
1cd23e9e SG |
87 | # Runs git with all the options given as argument, respecting any |
88 | # '--git-dir=<path>' and '-C <path>' options present on the command line | |
89 | __git () | |
90 | { | |
91 | git ${__git_C_args:+"${__git_C_args[@]}"} \ | |
e15098a3 | 92 | ${__git_dir:+--git-dir="$__git_dir"} "$@" 2>/dev/null |
1cd23e9e SG |
93 | } |
94 | ||
dbda3b10 JN |
95 | # The following function is based on code from: |
96 | # | |
97 | # bash_completion - programmable completion functions for bash 3.2+ | |
98 | # | |
99 | # Copyright © 2006-2008, Ian Macdonald <ian@caliban.org> | |
100 | # © 2009-2010, Bash Completion Maintainers | |
101 | # <bash-completion-devel@lists.alioth.debian.org> | |
102 | # | |
103 | # This program is free software; you can redistribute it and/or modify | |
104 | # it under the terms of the GNU General Public License as published by | |
105 | # the Free Software Foundation; either version 2, or (at your option) | |
106 | # any later version. | |
107 | # | |
108 | # This program is distributed in the hope that it will be useful, | |
109 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
110 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
111 | # GNU General Public License for more details. | |
112 | # | |
113 | # You should have received a copy of the GNU General Public License | |
48425792 | 114 | # along with this program; if not, see <http://www.gnu.org/licenses/>. |
dbda3b10 JN |
115 | # |
116 | # The latest version of this software can be obtained here: | |
117 | # | |
118 | # http://bash-completion.alioth.debian.org/ | |
119 | # | |
120 | # RELEASE: 2.x | |
121 | ||
122 | # This function can be used to access a tokenized list of words | |
123 | # on the command line: | |
124 | # | |
125 | # __git_reassemble_comp_words_by_ref '=:' | |
126 | # if test "${words_[cword_-1]}" = -w | |
127 | # then | |
128 | # ... | |
129 | # fi | |
130 | # | |
131 | # The argument should be a collection of characters from the list of | |
132 | # word completion separators (COMP_WORDBREAKS) to treat as ordinary | |
133 | # characters. | |
134 | # | |
135 | # This is roughly equivalent to going back in time and setting | |
136 | # COMP_WORDBREAKS to exclude those characters. The intent is to | |
137 | # make option types like --date=<type> and <rev>:<path> easy to | |
138 | # recognize by treating each shell word as a single token. | |
139 | # | |
140 | # It is best not to set COMP_WORDBREAKS directly because the value is | |
141 | # shared with other completion scripts. By the time the completion | |
142 | # function gets called, COMP_WORDS has already been populated so local | |
143 | # changes to COMP_WORDBREAKS have no effect. | |
144 | # | |
145 | # Output: words_, cword_, cur_. | |
146 | ||
147 | __git_reassemble_comp_words_by_ref() | |
148 | { | |
149 | local exclude i j first | |
150 | # Which word separators to exclude? | |
151 | exclude="${1//[^$COMP_WORDBREAKS]}" | |
152 | cword_=$COMP_CWORD | |
153 | if [ -z "$exclude" ]; then | |
154 | words_=("${COMP_WORDS[@]}") | |
155 | return | |
156 | fi | |
157 | # List of word completion separators has shrunk; | |
158 | # re-assemble words to complete. | |
159 | for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)); do | |
160 | # Append each nonempty word consisting of just | |
161 | # word separator characters to the current word. | |
162 | first=t | |
163 | while | |
164 | [ $i -gt 0 ] && | |
165 | [ -n "${COMP_WORDS[$i]}" ] && | |
166 | # word consists of excluded word separators | |
167 | [ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ] | |
168 | do | |
169 | # Attach to the previous token, | |
170 | # unless the previous token is the command name. | |
171 | if [ $j -ge 2 ] && [ -n "$first" ]; then | |
172 | ((j--)) | |
173 | fi | |
174 | first= | |
175 | words_[$j]=${words_[j]}${COMP_WORDS[i]} | |
176 | if [ $i = $COMP_CWORD ]; then | |
177 | cword_=$j | |
178 | fi | |
179 | if (($i < ${#COMP_WORDS[@]} - 1)); then | |
180 | ((i++)) | |
181 | else | |
182 | # Done. | |
183 | return | |
184 | fi | |
185 | done | |
186 | words_[$j]=${words_[j]}${COMP_WORDS[i]} | |
187 | if [ $i = $COMP_CWORD ]; then | |
188 | cword_=$j | |
189 | fi | |
190 | done | |
191 | } | |
192 | ||
da48616f PD |
193 | if ! type _get_comp_words_by_ref >/dev/null 2>&1; then |
194 | _get_comp_words_by_ref () | |
195 | { | |
dbda3b10 JN |
196 | local exclude cur_ words_ cword_ |
197 | if [ "$1" = "-n" ]; then | |
198 | exclude=$2 | |
199 | shift 2 | |
200 | fi | |
201 | __git_reassemble_comp_words_by_ref "$exclude" | |
202 | cur_=${words_[cword_]} | |
da48616f PD |
203 | while [ $# -gt 0 ]; do |
204 | case "$1" in | |
205 | cur) | |
dbda3b10 | 206 | cur=$cur_ |
da48616f PD |
207 | ;; |
208 | prev) | |
dbda3b10 | 209 | prev=${words_[$cword_-1]} |
da48616f PD |
210 | ;; |
211 | words) | |
dbda3b10 | 212 | words=("${words_[@]}") |
da48616f PD |
213 | ;; |
214 | cword) | |
dbda3b10 | 215 | cword=$cword_ |
da48616f PD |
216 | ;; |
217 | esac | |
218 | shift | |
219 | done | |
220 | } | |
221 | fi | |
222 | ||
fef56eb0 SG |
223 | # Fills the COMPREPLY array with prefiltered words without any additional |
224 | # processing. | |
225 | # Callers must take care of providing only words that match the current word | |
226 | # to be completed and adding any prefix and/or suffix (trailing space!), if | |
227 | # necessary. | |
228 | # 1: List of newline-separated matching completion words, complete with | |
229 | # prefix and suffix. | |
230 | __gitcomp_direct () | |
231 | { | |
232 | local IFS=$'\n' | |
233 | ||
234 | COMPREPLY=($1) | |
235 | } | |
236 | ||
f33c2c0f | 237 | __gitcompappend () |
1ce23aad | 238 | { |
852ff1c3 | 239 | local x i=${#COMPREPLY[@]} |
7d13e0a3 FC |
240 | for x in $1; do |
241 | if [[ "$x" == "$3"* ]]; then | |
242 | COMPREPLY[i++]="$2$x$4" | |
243 | fi | |
244 | done | |
1ce23aad FC |
245 | } |
246 | ||
f33c2c0f RR |
247 | __gitcompadd () |
248 | { | |
249 | COMPREPLY=() | |
250 | __gitcompappend "$@" | |
251 | } | |
252 | ||
7d13e0a3 FC |
253 | # Generates completion reply, appending a space to possible completion words, |
254 | # if necessary. | |
f674bb80 SG |
255 | # It accepts 1 to 4 arguments: |
256 | # 1: List of possible completion words. | |
257 | # 2: A prefix to be added to each possible completion word (optional). | |
258 | # 3: Generate possible completion matches for this word (optional). | |
259 | # 4: A suffix to be appended to each possible completion word (optional). | |
72e5e989 SP |
260 | __gitcomp () |
261 | { | |
583e4d57 | 262 | local cur_="${3-$cur}" |
9244d69b | 263 | |
9244d69b | 264 | case "$cur_" in |
5447aac7 | 265 | --*=) |
5447aac7 SG |
266 | ;; |
267 | *) | |
b4cfbc96 FC |
268 | local c i=0 IFS=$' \t\n' |
269 | for c in $1; do | |
270 | c="$c${4-}" | |
b4cfbc96 | 271 | if [[ $c == "$cur_"* ]]; then |
ddc996d7 FC |
272 | case $c in |
273 | --*=*|*.) ;; | |
274 | *) c="$c " ;; | |
275 | esac | |
b4cfbc96 FC |
276 | COMPREPLY[i++]="${2-}$c" |
277 | fi | |
278 | done | |
5447aac7 SG |
279 | ;; |
280 | esac | |
72e5e989 SP |
281 | } |
282 | ||
8b0eaa41 SG |
283 | # Clear the variables caching builtins' options when (re-)sourcing |
284 | # the completion script. | |
285 | unset $(set |sed -ne 's/^\(__gitcomp_builtin_[a-zA-Z0-9_][a-zA-Z0-9_]*\)=.*/\1/p') 2>/dev/null | |
286 | ||
d401f3de NTND |
287 | # This function is equivalent to |
288 | # | |
289 | # __gitcomp "$(git xxx --git-completion-helper) ..." | |
290 | # | |
291 | # except that the output is cached. Accept 1-3 arguments: | |
292 | # 1: the git command to execute, this is also the cache key | |
293 | # 2: extra options to be added on top (e.g. negative forms) | |
294 | # 3: options to be excluded | |
295 | __gitcomp_builtin () | |
296 | { | |
297 | # spaces must be replaced with underscore for multi-word | |
298 | # commands, e.g. "git remote add" becomes remote_add. | |
299 | local cmd="$1" | |
300 | local incl="$2" | |
301 | local excl="$3" | |
302 | ||
303 | local var=__gitcomp_builtin_"${cmd/-/_}" | |
304 | local options | |
305 | eval "options=\$$var" | |
306 | ||
307 | if [ -z "$options" ]; then | |
308 | # leading and trailing spaces are significant to make | |
309 | # option removal work correctly. | |
310 | options=" $(__git ${cmd/_/ } --git-completion-helper) $incl " | |
311 | for i in $excl; do | |
312 | options="${options/ $i / }" | |
313 | done | |
314 | eval "$var=\"$options\"" | |
315 | fi | |
316 | ||
317 | __gitcomp "$options" | |
318 | } | |
319 | ||
f33c2c0f RR |
320 | # Variation of __gitcomp_nl () that appends to the existing list of |
321 | # completion candidates, COMPREPLY. | |
322 | __gitcomp_nl_append () | |
323 | { | |
324 | local IFS=$'\n' | |
325 | __gitcompappend "$1" "${2-}" "${3-$cur}" "${4- }" | |
326 | } | |
327 | ||
7d13e0a3 FC |
328 | # Generates completion reply from newline-separated possible completion words |
329 | # by appending a space to all of them. | |
a31e6262 SG |
330 | # It accepts 1 to 4 arguments: |
331 | # 1: List of possible completion words, separated by a single newline. | |
332 | # 2: A prefix to be added to each possible completion word (optional). | |
333 | # 3: Generate possible completion matches for this word (optional). | |
334 | # 4: A suffix to be appended to each possible completion word instead of | |
335 | # the default space (optional). If specified but empty, nothing is | |
336 | # appended. | |
337 | __gitcomp_nl () | |
338 | { | |
f33c2c0f RR |
339 | COMPREPLY=() |
340 | __gitcomp_nl_append "$@" | |
a31e6262 SG |
341 | } |
342 | ||
fea16b47 MP |
343 | # Generates completion reply with compgen from newline-separated possible |
344 | # completion filenames. | |
345 | # It accepts 1 to 3 arguments: | |
346 | # 1: List of possible completion filenames, separated by a single newline. | |
347 | # 2: A directory prefix to be added to each possible completion filename | |
348 | # (optional). | |
349 | # 3: Generate possible completion matches for this word (optional). | |
350 | __gitcomp_file () | |
351 | { | |
352 | local IFS=$'\n' | |
353 | ||
354 | # XXX does not work when the directory prefix contains a tilde, | |
355 | # since tilde expansion is not applied. | |
356 | # This means that COMPREPLY will be empty and Bash default | |
357 | # completion will be used. | |
0afe8e9e | 358 | __gitcompadd "$1" "${2-}" "${3-$cur}" "" |
fea16b47 | 359 | |
3ffa4df4 | 360 | # use a hack to enable file mode in bash < 4 |
fbe45118 | 361 | compopt -o filenames +o nospace 2>/dev/null || |
3ffa4df4 | 362 | compgen -f /non-existing-dir/ > /dev/null |
fea16b47 MP |
363 | } |
364 | ||
f825972c FC |
365 | # Execute 'git ls-files', unless the --committable option is specified, in |
366 | # which case it runs 'git diff-index' to find out the files that can be | |
367 | # committed. It return paths relative to the directory specified in the first | |
368 | # argument, and using the options specified in the second argument. | |
fea16b47 MP |
369 | __git_ls_files_helper () |
370 | { | |
fca416a4 | 371 | if [ "$2" == "--committable" ]; then |
1cd23e9e | 372 | __git -C "$1" diff-index --name-only --relative HEAD |
fca416a4 JH |
373 | else |
374 | # NOTE: $2 is not quoted in order to support multiple options | |
1cd23e9e | 375 | __git -C "$1" ls-files --exclude-standard $2 |
e15098a3 | 376 | fi |
35ba83cc | 377 | } |
fea16b47 MP |
378 | |
379 | ||
fea16b47 MP |
380 | # __git_index_files accepts 1 or 2 arguments: |
381 | # 1: Options to pass to ls-files (required). | |
fea16b47 MP |
382 | # 2: A directory path (optional). |
383 | # If provided, only files within the specified directory are listed. | |
384 | # Sub directories are never recursed. Path must have a trailing | |
385 | # slash. | |
386 | __git_index_files () | |
387 | { | |
a958d40f | 388 | local root="${2-.}" file |
fea16b47 | 389 | |
a958d40f SG |
390 | __git_ls_files_helper "$root" "$1" | |
391 | while read -r file; do | |
392 | case "$file" in | |
393 | ?*/*) echo "${file%%/*}" ;; | |
394 | *) echo "$file" ;; | |
395 | esac | |
396 | done | sort | uniq | |
fea16b47 MP |
397 | } |
398 | ||
227307a6 SG |
399 | # Lists branches from the local repository. |
400 | # 1: A prefix to be added to each listed branch (optional). | |
401 | # 2: List only branches matching this word (optional; list all branches if | |
402 | # unset or empty). | |
403 | # 3: A suffix to be appended to each listed branch (optional). | |
5de40f59 SP |
404 | __git_heads () |
405 | { | |
227307a6 SG |
406 | local pfx="${1-}" cur_="${2-}" sfx="${3-}" |
407 | ||
408 | __git for-each-ref --format="${pfx//\%/%%}%(refname:strip=2)$sfx" \ | |
409 | "refs/heads/$cur_*" "refs/heads/$cur_*/**" | |
5de40f59 SP |
410 | } |
411 | ||
227307a6 SG |
412 | # Lists tags from the local repository. |
413 | # Accepts the same positional parameters as __git_heads() above. | |
88e21dc7 SP |
414 | __git_tags () |
415 | { | |
227307a6 SG |
416 | local pfx="${1-}" cur_="${2-}" sfx="${3-}" |
417 | ||
418 | __git for-each-ref --format="${pfx//\%/%%}%(refname:strip=2)$sfx" \ | |
419 | "refs/tags/$cur_*" "refs/tags/$cur_*/**" | |
88e21dc7 SP |
420 | } |
421 | ||
be6fbdb5 SG |
422 | # Lists refs from the local (by default) or from a remote repository. |
423 | # It accepts 0, 1 or 2 arguments: | |
424 | # 1: The remote to list refs from (optional; ignored, if set but empty). | |
91b7ea81 | 425 | # Can be the name of a configured remote, a path, or a URL. |
be6fbdb5 SG |
426 | # 2: In addition to local refs, list unique branches from refs/remotes/ for |
427 | # 'git checkout's tracking DWIMery (optional; ignored, if set but empty). | |
fef56eb0 | 428 | # 3: A prefix to be added to each listed ref (optional). |
e896369b SG |
429 | # 4: List only refs matching this word (optional; list all refs if unset or |
430 | # empty). | |
fef56eb0 SG |
431 | # 5: A suffix to be appended to each listed ref (optional; ignored, if set |
432 | # but empty). | |
15b4a163 SG |
433 | # |
434 | # Use __git_complete_refs() instead. | |
690d8824 JH |
435 | __git_refs () |
436 | { | |
fad9484f | 437 | local i hash dir track="${2-}" |
5c12f642 | 438 | local list_refs_from=path remote="${1-}" |
fef56eb0 SG |
439 | local format refs |
440 | local pfx="${3-}" cur_="${4-$cur}" sfx="${5-}" | |
e896369b | 441 | local match="${4-}" |
fef56eb0 | 442 | local fer_pfx="${pfx//\%/%%}" # "escape" for-each-ref format specifiers |
5c12f642 | 443 | |
fad9484f SG |
444 | __git_find_repo_path |
445 | dir="$__git_repo_path" | |
446 | ||
62a1b732 SG |
447 | if [ -z "$remote" ]; then |
448 | if [ -z "$dir" ]; then | |
449 | return | |
450 | fi | |
451 | else | |
69a77596 SG |
452 | if __git_is_configured_remote "$remote"; then |
453 | # configured remote takes precedence over a | |
454 | # local directory with the same name | |
455 | list_refs_from=remote | |
456 | elif [ -d "$remote/.git" ]; then | |
5c12f642 SG |
457 | dir="$remote/.git" |
458 | elif [ -d "$remote" ]; then | |
459 | dir="$remote" | |
460 | else | |
69a77596 | 461 | list_refs_from=url |
5c12f642 SG |
462 | fi |
463 | fi | |
464 | ||
62a1b732 | 465 | if [ "$list_refs_from" = path ]; then |
aed38813 | 466 | if [[ "$cur_" == ^* ]]; then |
fef56eb0 SG |
467 | pfx="$pfx^" |
468 | fer_pfx="$fer_pfx^" | |
aed38813 | 469 | cur_=${cur_#^} |
e896369b | 470 | match=${match#^} |
aed38813 | 471 | fi |
2ea328a1 | 472 | case "$cur_" in |
608efb87 SG |
473 | refs|refs/*) |
474 | format="refname" | |
e896369b | 475 | refs=("$match*" "$match*/**") |
34a6bbb5 | 476 | track="" |
608efb87 SG |
477 | ;; |
478 | *) | |
fbd7a232 | 479 | for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD REBASE_HEAD; do |
e896369b SG |
480 | case "$i" in |
481 | $match*) | |
482 | if [ -e "$dir/$i" ]; then | |
fef56eb0 | 483 | echo "$pfx$i$sfx" |
e896369b SG |
484 | fi |
485 | ;; | |
486 | esac | |
d23e7570 | 487 | done |
b2b68114 | 488 | format="refname:strip=2" |
e896369b SG |
489 | refs=("refs/tags/$match*" "refs/tags/$match*/**" |
490 | "refs/heads/$match*" "refs/heads/$match*/**" | |
491 | "refs/remotes/$match*" "refs/remotes/$match*/**") | |
608efb87 SG |
492 | ;; |
493 | esac | |
fef56eb0 | 494 | __git_dir="$dir" __git for-each-ref --format="$fer_pfx%($format)$sfx" \ |
e896369b | 495 | "${refs[@]}" |
34a6bbb5 KB |
496 | if [ -n "$track" ]; then |
497 | # employ the heuristic used by git checkout | |
498 | # Try to find a remote branch that matches the completion word | |
499 | # but only output if the branch name is unique | |
fef56eb0 | 500 | __git for-each-ref --format="$fer_pfx%(refname:strip=3)$sfx" \ |
400a7553 | 501 | --sort="refname:strip=3" \ |
824388d5 | 502 | "refs/remotes/*/$match*" "refs/remotes/*/$match*/**" | \ |
400a7553 | 503 | uniq -u |
34a6bbb5 | 504 | fi |
35e65ecc | 505 | return |
690d8824 | 506 | fi |
2ea328a1 | 507 | case "$cur_" in |
fb772cca | 508 | refs|refs/*) |
e896369b | 509 | __git ls-remote "$remote" "$match*" | \ |
6f2dd720 | 510 | while read -r hash i; do |
fb772cca SG |
511 | case "$i" in |
512 | *^{}) ;; | |
fef56eb0 | 513 | *) echo "$pfx$i$sfx" ;; |
fb772cca SG |
514 | esac |
515 | done | |
516 | ;; | |
517 | *) | |
91b7ea81 | 518 | if [ "$list_refs_from" = remote ]; then |
e896369b | 519 | case "HEAD" in |
fef56eb0 | 520 | $match*) echo "${pfx}HEAD$sfx" ;; |
e896369b | 521 | esac |
fef56eb0 | 522 | __git for-each-ref --format="$fer_pfx%(refname:strip=3)$sfx" \ |
e896369b | 523 | "refs/remotes/$remote/$match*" \ |
e8cb0234 | 524 | "refs/remotes/$remote/$match*/**" |
91b7ea81 | 525 | else |
e896369b SG |
526 | local query_symref |
527 | case "HEAD" in | |
528 | $match*) query_symref="HEAD" ;; | |
529 | esac | |
530 | __git ls-remote "$remote" $query_symref \ | |
531 | "refs/tags/$match*" "refs/heads/$match*" \ | |
532 | "refs/remotes/$match*" | | |
91b7ea81 SG |
533 | while read -r hash i; do |
534 | case "$i" in | |
535 | *^{}) ;; | |
fef56eb0 SG |
536 | refs/*) echo "$pfx${i#refs/*/}$sfx" ;; |
537 | *) echo "$pfx$i$sfx" ;; # symbolic refs | |
91b7ea81 SG |
538 | esac |
539 | done | |
540 | fi | |
fb772cca SG |
541 | ;; |
542 | esac | |
690d8824 JH |
543 | } |
544 | ||
15b4a163 SG |
545 | # Completes refs, short and long, local and remote, symbolic and pseudo. |
546 | # | |
547 | # Usage: __git_complete_refs [<option>]... | |
548 | # --remote=<remote>: The remote to list refs from, can be the name of a | |
549 | # configured remote, a path, or a URL. | |
550 | # --track: List unique remote branches for 'git checkout's tracking DWIMery. | |
551 | # --pfx=<prefix>: A prefix to be added to each ref. | |
552 | # --cur=<word>: The current ref to be completed. Defaults to the current | |
553 | # word to be completed. | |
554 | # --sfx=<suffix>: A suffix to be appended to each ref instead of the default | |
555 | # space. | |
556 | __git_complete_refs () | |
557 | { | |
558 | local remote track pfx cur_="$cur" sfx=" " | |
559 | ||
560 | while test $# != 0; do | |
561 | case "$1" in | |
562 | --remote=*) remote="${1##--remote=}" ;; | |
563 | --track) track="yes" ;; | |
564 | --pfx=*) pfx="${1##--pfx=}" ;; | |
565 | --cur=*) cur_="${1##--cur=}" ;; | |
566 | --sfx=*) sfx="${1##--sfx=}" ;; | |
567 | *) return 1 ;; | |
568 | esac | |
569 | shift | |
570 | done | |
571 | ||
fef56eb0 | 572 | __gitcomp_direct "$(__git_refs "$remote" "$track" "$pfx" "$cur_" "$sfx")" |
15b4a163 SG |
573 | } |
574 | ||
a42577d4 | 575 | # __git_refs2 requires 1 argument (to pass to __git_refs) |
aa0644f7 | 576 | # Deprecated: use __git_complete_fetch_refspecs() instead. |
690d8824 JH |
577 | __git_refs2 () |
578 | { | |
67ffa114 SP |
579 | local i |
580 | for i in $(__git_refs "$1"); do | |
581 | echo "$i:$i" | |
690d8824 JH |
582 | done |
583 | } | |
584 | ||
aa0644f7 SG |
585 | # Completes refspecs for fetching from a remote repository. |
586 | # 1: The remote repository. | |
587 | # 2: A prefix to be added to each listed refspec (optional). | |
588 | # 3: The ref to be completed as a refspec instead of the current word to be | |
589 | # completed (optional) | |
590 | # 4: A suffix to be appended to each listed refspec instead of the default | |
591 | # space (optional). | |
592 | __git_complete_fetch_refspecs () | |
593 | { | |
594 | local i remote="$1" pfx="${2-}" cur_="${3-$cur}" sfx="${4- }" | |
595 | ||
745d655d | 596 | __gitcomp_direct "$( |
aa0644f7 | 597 | for i in $(__git_refs "$remote" "" "" "$cur_") ; do |
745d655d | 598 | echo "$pfx$i:$i$sfx" |
aa0644f7 | 599 | done |
745d655d | 600 | )" |
aa0644f7 SG |
601 | } |
602 | ||
a42577d4 | 603 | # __git_refs_remotes requires 1 argument (to pass to ls-remote) |
5de40f59 SP |
604 | __git_refs_remotes () |
605 | { | |
48058f5d | 606 | local i hash |
e15098a3 | 607 | __git ls-remote "$1" 'refs/heads/*' | \ |
6f2dd720 | 608 | while read -r hash i; do |
48058f5d | 609 | echo "$i:refs/remotes/$1/${i#refs/heads/}" |
5de40f59 SP |
610 | done |
611 | } | |
612 | ||
690d8824 JH |
613 | __git_remotes () |
614 | { | |
fad9484f SG |
615 | __git_find_repo_path |
616 | test -d "$__git_repo_path/remotes" && ls -1 "$__git_repo_path/remotes" | |
1cd23e9e | 617 | __git remote |
690d8824 JH |
618 | } |
619 | ||
69a77596 SG |
620 | # Returns true if $1 matches the name of a configured remote, false otherwise. |
621 | __git_is_configured_remote () | |
622 | { | |
623 | local remote | |
624 | for remote in $(__git_remotes); do | |
625 | if [ "$remote" = "$1" ]; then | |
626 | return 0 | |
627 | fi | |
628 | done | |
629 | return 1 | |
690d8824 JH |
630 | } |
631 | ||
eaa4e6ee | 632 | __git_list_merge_strategies () |
4ad91321 | 633 | { |
7cc763aa | 634 | LANG=C LC_ALL=C git merge -s help 2>&1 | |
25b3d4d6 JH |
635 | sed -n -e '/[Aa]vailable strategies are: /,/^$/{ |
636 | s/\.$// | |
637 | s/.*:// | |
638 | s/^[ ]*// | |
639 | s/[ ]*$// | |
4ad91321 | 640 | p |
25b3d4d6 | 641 | }' |
4ad91321 | 642 | } |
eaa4e6ee JN |
643 | |
644 | __git_merge_strategies= | |
645 | # 'git merge -s help' (and thus detection of the merge strategy | |
646 | # list) fails, unfortunately, if run outside of any git working | |
647 | # tree. __git_merge_strategies is set to the empty string in | |
648 | # that case, and the detection will be repeated the next time it | |
649 | # is needed. | |
650 | __git_compute_merge_strategies () | |
651 | { | |
cf0ff02a FC |
652 | test -n "$__git_merge_strategies" || |
653 | __git_merge_strategies=$(__git_list_merge_strategies) | |
eaa4e6ee | 654 | } |
4ad91321 | 655 | |
1d66ec58 | 656 | __git_complete_revlist_file () |
690d8824 | 657 | { |
da4902a7 | 658 | local pfx ls ref cur_="$cur" |
9244d69b | 659 | case "$cur_" in |
1d66ec58 SG |
660 | *..?*:*) |
661 | return | |
662 | ;; | |
690d8824 | 663 | ?*:*) |
9244d69b SG |
664 | ref="${cur_%%:*}" |
665 | cur_="${cur_#*:}" | |
666 | case "$cur_" in | |
690d8824 | 667 | ?*/*) |
9244d69b SG |
668 | pfx="${cur_%/*}" |
669 | cur_="${cur_##*/}" | |
690d8824 JH |
670 | ls="$ref:$pfx" |
671 | pfx="$pfx/" | |
672 | ;; | |
673 | *) | |
674 | ls="$ref" | |
675 | ;; | |
80152b09 | 676 | esac |
db8a9ff0 SP |
677 | |
678 | case "$COMP_WORDBREAKS" in | |
679 | *:*) : great ;; | |
680 | *) pfx="$ref:$pfx" ;; | |
681 | esac | |
682 | ||
e15098a3 | 683 | __gitcomp_nl "$(__git ls-tree "$ls" \ |
778306e4 SP |
684 | | sed '/^100... blob /{ |
685 | s,^.* ,, | |
686 | s,$, , | |
687 | } | |
688 | /^120000 blob /{ | |
689 | s,^.* ,, | |
690 | s,$, , | |
691 | } | |
690d8824 JH |
692 | /^040000 tree /{ |
693 | s,^.* ,, | |
694 | s,$,/, | |
695 | } | |
696 | s/^.* //')" \ | |
41e6229d | 697 | "$pfx" "$cur_" "" |
690d8824 | 698 | ;; |
f53352fb | 699 | *...*) |
9244d69b SG |
700 | pfx="${cur_%...*}..." |
701 | cur_="${cur_#*...}" | |
15b4a163 | 702 | __git_complete_refs --pfx="$pfx" --cur="$cur_" |
f53352fb SP |
703 | ;; |
704 | *..*) | |
9244d69b SG |
705 | pfx="${cur_%..*}.." |
706 | cur_="${cur_#*..}" | |
15b4a163 | 707 | __git_complete_refs --pfx="$pfx" --cur="$cur_" |
b3391775 | 708 | ;; |
f53352fb | 709 | *) |
15b4a163 | 710 | __git_complete_refs |
f53352fb SP |
711 | ;; |
712 | esac | |
713 | } | |
714 | ||
1d66ec58 | 715 | |
f825972c FC |
716 | # __git_complete_index_file requires 1 argument: |
717 | # 1: the options to pass to ls-file | |
718 | # | |
719 | # The exception is --committable, which finds the files appropriate commit. | |
fea16b47 MP |
720 | __git_complete_index_file () |
721 | { | |
fda54ef1 | 722 | local pfx="" cur_="$cur" |
fea16b47 MP |
723 | |
724 | case "$cur_" in | |
725 | ?*/*) | |
726 | pfx="${cur_%/*}" | |
727 | cur_="${cur_##*/}" | |
728 | pfx="${pfx}/" | |
fea16b47 MP |
729 | ;; |
730 | esac | |
fea16b47 | 731 | |
fca416a4 | 732 | __gitcomp_file "$(__git_index_files "$1" ${pfx:+"$pfx"})" "$pfx" "$cur_" |
fea16b47 MP |
733 | } |
734 | ||
1d66ec58 SG |
735 | __git_complete_file () |
736 | { | |
737 | __git_complete_revlist_file | |
738 | } | |
739 | ||
740 | __git_complete_revlist () | |
741 | { | |
742 | __git_complete_revlist_file | |
743 | } | |
744 | ||
52d5c3b5 JS |
745 | __git_complete_remote_or_refspec () |
746 | { | |
9244d69b | 747 | local cur_="$cur" cmd="${words[1]}" |
0a4e1472 | 748 | local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0 |
f1c6ffe6 | 749 | if [ "$cmd" = "remote" ]; then |
6e8c755f | 750 | ((c++)) |
f1c6ffe6 | 751 | fi |
da48616f PD |
752 | while [ $c -lt $cword ]; do |
753 | i="${words[c]}" | |
52d5c3b5 | 754 | case "$i" in |
e25e2b42 | 755 | --mirror) [ "$cmd" = "push" ] && no_complete_refspec=1 ;; |
723c1d52 | 756 | -d|--delete) [ "$cmd" = "push" ] && lhs=0 ;; |
e25e2b42 BG |
757 | --all) |
758 | case "$cmd" in | |
759 | push) no_complete_refspec=1 ;; | |
760 | fetch) | |
e25e2b42 BG |
761 | return |
762 | ;; | |
763 | *) ;; | |
764 | esac | |
765 | ;; | |
52d5c3b5 JS |
766 | -*) ;; |
767 | *) remote="$i"; break ;; | |
768 | esac | |
6e8c755f | 769 | ((c++)) |
52d5c3b5 JS |
770 | done |
771 | if [ -z "$remote" ]; then | |
a31e6262 | 772 | __gitcomp_nl "$(__git_remotes)" |
52d5c3b5 JS |
773 | return |
774 | fi | |
0a4e1472 | 775 | if [ $no_complete_refspec = 1 ]; then |
0a4e1472 JS |
776 | return |
777 | fi | |
52d5c3b5 | 778 | [ "$remote" = "." ] && remote= |
9244d69b | 779 | case "$cur_" in |
52d5c3b5 JS |
780 | *:*) |
781 | case "$COMP_WORDBREAKS" in | |
782 | *:*) : great ;; | |
9244d69b | 783 | *) pfx="${cur_%%:*}:" ;; |
52d5c3b5 | 784 | esac |
9244d69b | 785 | cur_="${cur_#*:}" |
52d5c3b5 JS |
786 | lhs=0 |
787 | ;; | |
788 | +*) | |
789 | pfx="+" | |
9244d69b | 790 | cur_="${cur_#+}" |
52d5c3b5 JS |
791 | ;; |
792 | esac | |
793 | case "$cmd" in | |
794 | fetch) | |
795 | if [ $lhs = 1 ]; then | |
aa0644f7 | 796 | __git_complete_fetch_refspecs "$remote" "$pfx" "$cur_" |
52d5c3b5 | 797 | else |
15b4a163 | 798 | __git_complete_refs --pfx="$pfx" --cur="$cur_" |
52d5c3b5 JS |
799 | fi |
800 | ;; | |
f1c6ffe6 | 801 | pull|remote) |
52d5c3b5 | 802 | if [ $lhs = 1 ]; then |
15b4a163 | 803 | __git_complete_refs --remote="$remote" --pfx="$pfx" --cur="$cur_" |
52d5c3b5 | 804 | else |
15b4a163 | 805 | __git_complete_refs --pfx="$pfx" --cur="$cur_" |
52d5c3b5 JS |
806 | fi |
807 | ;; | |
808 | push) | |
809 | if [ $lhs = 1 ]; then | |
15b4a163 | 810 | __git_complete_refs --pfx="$pfx" --cur="$cur_" |
52d5c3b5 | 811 | else |
15b4a163 | 812 | __git_complete_refs --remote="$remote" --pfx="$pfx" --cur="$cur_" |
52d5c3b5 JS |
813 | fi |
814 | ;; | |
815 | esac | |
816 | } | |
817 | ||
3c7b480a JS |
818 | __git_complete_strategy () |
819 | { | |
eaa4e6ee | 820 | __git_compute_merge_strategies |
da48616f | 821 | case "$prev" in |
3c7b480a | 822 | -s|--strategy) |
eaa4e6ee | 823 | __gitcomp "$__git_merge_strategies" |
3c7b480a JS |
824 | return 0 |
825 | esac | |
3c7b480a JS |
826 | case "$cur" in |
827 | --strategy=*) | |
eaa4e6ee | 828 | __gitcomp "$__git_merge_strategies" "" "${cur##--strategy=}" |
3c7b480a JS |
829 | return 0 |
830 | ;; | |
831 | esac | |
832 | return 1 | |
833 | } | |
834 | ||
50478223 JH |
835 | __git_commands () { |
836 | if test -n "${GIT_TESTING_COMMAND_COMPLETION:-}" | |
837 | then | |
838 | printf "%s" "${GIT_TESTING_COMMAND_COMPLETION}" | |
839 | else | |
840 | git help -a|egrep '^ [a-zA-Z0-9]' | |
841 | fi | |
842 | } | |
843 | ||
eaa4e6ee | 844 | __git_list_all_commands () |
f2bb9f88 SP |
845 | { |
846 | local i IFS=" "$'\n' | |
50478223 | 847 | for i in $(__git_commands) |
1eb7e2f8 LM |
848 | do |
849 | case $i in | |
850 | *--*) : helper pattern;; | |
851 | *) echo $i;; | |
852 | esac | |
853 | done | |
854 | } | |
1eb7e2f8 | 855 | |
eaa4e6ee JN |
856 | __git_all_commands= |
857 | __git_compute_all_commands () | |
858 | { | |
cf0ff02a FC |
859 | test -n "$__git_all_commands" || |
860 | __git_all_commands=$(__git_list_all_commands) | |
eaa4e6ee JN |
861 | } |
862 | ||
863 | __git_list_porcelain_commands () | |
1eb7e2f8 | 864 | { |
1eb7e2f8 | 865 | local i IFS=" "$'\n' |
eaa4e6ee | 866 | __git_compute_all_commands |
585b96bd | 867 | for i in $__git_all_commands |
f2bb9f88 SP |
868 | do |
869 | case $i in | |
718a087a | 870 | *--*) : helper pattern;; |
a925c6f1 SP |
871 | applymbox) : ask gittus;; |
872 | applypatch) : ask gittus;; | |
873 | archimport) : import;; | |
2e3a430a | 874 | cat-file) : plumbing;; |
56d99c67 | 875 | check-attr) : plumbing;; |
368aa529 | 876 | check-ignore) : plumbing;; |
226ad348 | 877 | check-mailmap) : plumbing;; |
f2bb9f88 | 878 | check-ref-format) : plumbing;; |
ff2549dc | 879 | checkout-index) : plumbing;; |
160fcdb0 | 880 | column) : internal helper;; |
f2bb9f88 | 881 | commit-tree) : plumbing;; |
ff2549dc | 882 | count-objects) : infrequent;; |
a074aa90 SG |
883 | credential) : credentials;; |
884 | credential-*) : credentials helper;; | |
a925c6f1 SP |
885 | cvsexportcommit) : export;; |
886 | cvsimport) : import;; | |
f2bb9f88 SP |
887 | cvsserver) : daemon;; |
888 | daemon) : daemon;; | |
5cfb4fe5 SP |
889 | diff-files) : plumbing;; |
890 | diff-index) : plumbing;; | |
891 | diff-tree) : plumbing;; | |
c6ec3b13 | 892 | fast-import) : import;; |
ff2549dc | 893 | fast-export) : export;; |
a925c6f1 | 894 | fsck-objects) : plumbing;; |
f2bb9f88 | 895 | fetch-pack) : plumbing;; |
a925c6f1 | 896 | fmt-merge-msg) : plumbing;; |
56d99c67 | 897 | for-each-ref) : plumbing;; |
f2bb9f88 SP |
898 | hash-object) : plumbing;; |
899 | http-*) : transport;; | |
900 | index-pack) : plumbing;; | |
a925c6f1 | 901 | init-db) : deprecated;; |
f2bb9f88 | 902 | local-fetch) : plumbing;; |
ff2549dc PB |
903 | ls-files) : plumbing;; |
904 | ls-remote) : plumbing;; | |
905 | ls-tree) : plumbing;; | |
f2bb9f88 SP |
906 | mailinfo) : plumbing;; |
907 | mailsplit) : plumbing;; | |
908 | merge-*) : plumbing;; | |
909 | mktree) : plumbing;; | |
910 | mktag) : plumbing;; | |
911 | pack-objects) : plumbing;; | |
912 | pack-redundant) : plumbing;; | |
913 | pack-refs) : plumbing;; | |
914 | parse-remote) : plumbing;; | |
915 | patch-id) : plumbing;; | |
a925c6f1 SP |
916 | prune) : plumbing;; |
917 | prune-packed) : plumbing;; | |
918 | quiltimport) : import;; | |
f2bb9f88 SP |
919 | read-tree) : plumbing;; |
920 | receive-pack) : plumbing;; | |
63d04a78 | 921 | remote-*) : transport;; |
f2bb9f88 SP |
922 | rerere) : plumbing;; |
923 | rev-list) : plumbing;; | |
924 | rev-parse) : plumbing;; | |
925 | runstatus) : plumbing;; | |
926 | sh-setup) : internal;; | |
927 | shell) : daemon;; | |
ff2549dc | 928 | show-ref) : plumbing;; |
f2bb9f88 SP |
929 | send-pack) : plumbing;; |
930 | show-index) : plumbing;; | |
931 | ssh-*) : transport;; | |
932 | stripspace) : plumbing;; | |
933 | symbolic-ref) : plumbing;; | |
934 | unpack-file) : plumbing;; | |
935 | unpack-objects) : plumbing;; | |
a925c6f1 | 936 | update-index) : plumbing;; |
f2bb9f88 SP |
937 | update-ref) : plumbing;; |
938 | update-server-info) : daemon;; | |
939 | upload-archive) : plumbing;; | |
940 | upload-pack) : plumbing;; | |
941 | write-tree) : plumbing;; | |
ff2549dc PB |
942 | var) : infrequent;; |
943 | verify-pack) : infrequent;; | |
a925c6f1 | 944 | verify-tag) : plumbing;; |
f2bb9f88 SP |
945 | *) echo $i;; |
946 | esac | |
947 | done | |
948 | } | |
eaa4e6ee JN |
949 | |
950 | __git_porcelain_commands= | |
951 | __git_compute_porcelain_commands () | |
952 | { | |
cf0ff02a FC |
953 | test -n "$__git_porcelain_commands" || |
954 | __git_porcelain_commands=$(__git_list_porcelain_commands) | |
eaa4e6ee | 955 | } |
f2bb9f88 | 956 | |
e8f9e428 SG |
957 | # Lists all set config variables starting with the given section prefix, |
958 | # with the prefix removed. | |
959 | __git_get_config_variables () | |
c3898111 | 960 | { |
e8f9e428 | 961 | local section="$1" i IFS=$'\n' |
e15098a3 | 962 | for i in $(__git config --name-only --get-regexp "^$section\..*"); do |
905f2036 | 963 | echo "${i#$section.}" |
c3898111 SG |
964 | done |
965 | } | |
966 | ||
c3898111 SG |
967 | __git_pretty_aliases () |
968 | { | |
e8f9e428 | 969 | __git_get_config_variables "pretty" |
c3898111 SG |
970 | } |
971 | ||
367dce2a DS |
972 | __git_aliases () |
973 | { | |
e8f9e428 | 974 | __git_get_config_variables "alias" |
367dce2a DS |
975 | } |
976 | ||
a42577d4 | 977 | # __git_aliased_command requires 1 argument |
367dce2a DS |
978 | __git_aliased_command () |
979 | { | |
e15098a3 | 980 | local word cmdline=$(__git config --get "alias.$1") |
367dce2a | 981 | for word in $cmdline; do |
c63437cb | 982 | case "$word" in |
66729509 SG |
983 | \!gitk|gitk) |
984 | echo "gitk" | |
367dce2a | 985 | return |
66729509 | 986 | ;; |
c63437cb SG |
987 | \!*) : shell command alias ;; |
988 | -*) : option ;; | |
989 | *=*) : setting env ;; | |
990 | git) : git itself ;; | |
56f24e80 SP |
991 | \(\)) : skip parens of shell function definition ;; |
992 | {) : skip start of shell helper function ;; | |
993 | :) : skip null command ;; | |
994 | \'*) : skip opening quote after sh -c ;; | |
c63437cb SG |
995 | *) |
996 | echo "$word" | |
367dce2a | 997 | return |
c63437cb | 998 | esac |
367dce2a DS |
999 | done |
1000 | } | |
1001 | ||
918c03c2 SG |
1002 | # __git_find_on_cmdline requires 1 argument |
1003 | __git_find_on_cmdline () | |
3ff1320d | 1004 | { |
da4902a7 | 1005 | local word subcommand c=1 |
da48616f PD |
1006 | while [ $c -lt $cword ]; do |
1007 | word="${words[c]}" | |
3ff1320d SG |
1008 | for subcommand in $1; do |
1009 | if [ "$subcommand" = "$word" ]; then | |
1010 | echo "$subcommand" | |
1011 | return | |
1012 | fi | |
1013 | done | |
6e8c755f | 1014 | ((c++)) |
3ff1320d SG |
1015 | done |
1016 | } | |
1017 | ||
7c599e92 TB |
1018 | # Echo the value of an option set on the command line or config |
1019 | # | |
1020 | # $1: short option name | |
1021 | # $2: long option name including = | |
1022 | # $3: list of possible values | |
1023 | # $4: config string (optional) | |
1024 | # | |
1025 | # example: | |
1026 | # result="$(__git_get_option_value "-d" "--do-something=" \ | |
1027 | # "yes no" "core.doSomething")" | |
1028 | # | |
1029 | # result is then either empty (no option set) or "yes" or "no" | |
1030 | # | |
1031 | # __git_get_option_value requires 3 arguments | |
1032 | __git_get_option_value () | |
1033 | { | |
1034 | local c short_opt long_opt val | |
1035 | local result= values config_key word | |
1036 | ||
1037 | short_opt="$1" | |
1038 | long_opt="$2" | |
1039 | values="$3" | |
1040 | config_key="$4" | |
1041 | ||
1042 | ((c = $cword - 1)) | |
1043 | while [ $c -ge 0 ]; do | |
1044 | word="${words[c]}" | |
1045 | for val in $values; do | |
1046 | if [ "$short_opt$val" = "$word" ] || | |
1047 | [ "$long_opt$val" = "$word" ]; then | |
1048 | result="$val" | |
1049 | break 2 | |
1050 | fi | |
1051 | done | |
1052 | ((c--)) | |
1053 | done | |
1054 | ||
1055 | if [ -n "$config_key" ] && [ -z "$result" ]; then | |
1cd23e9e | 1056 | result="$(__git config "$config_key")" |
7c599e92 TB |
1057 | fi |
1058 | ||
1059 | echo "$result" | |
1060 | } | |
1061 | ||
d773c631 SG |
1062 | __git_has_doubledash () |
1063 | { | |
da4902a7 | 1064 | local c=1 |
da48616f PD |
1065 | while [ $c -lt $cword ]; do |
1066 | if [ "--" = "${words[c]}" ]; then | |
d773c631 SG |
1067 | return 0 |
1068 | fi | |
6e8c755f | 1069 | ((c++)) |
d773c631 SG |
1070 | done |
1071 | return 1 | |
1072 | } | |
1073 | ||
fea16b47 MP |
1074 | # Try to count non option arguments passed on the command line for the |
1075 | # specified git command. | |
1076 | # When options are used, it is necessary to use the special -- option to | |
1077 | # tell the implementation were non option arguments begin. | |
1078 | # XXX this can not be improved, since options can appear everywhere, as | |
1079 | # an example: | |
1080 | # git mv x -n y | |
1081 | # | |
1082 | # __git_count_arguments requires 1 argument: the git command executed. | |
1083 | __git_count_arguments () | |
1084 | { | |
1085 | local word i c=0 | |
1086 | ||
1087 | # Skip "git" (first argument) | |
1088 | for ((i=1; i < ${#words[@]}; i++)); do | |
1089 | word="${words[i]}" | |
1090 | ||
1091 | case "$word" in | |
1092 | --) | |
1093 | # Good; we can assume that the following are only non | |
1094 | # option arguments. | |
1095 | ((c = 0)) | |
1096 | ;; | |
1097 | "$1") | |
1098 | # Skip the specified git command and discard git | |
1099 | # main options | |
1100 | ((c = 0)) | |
1101 | ;; | |
1102 | ?*) | |
1103 | ((c++)) | |
1104 | ;; | |
1105 | esac | |
1106 | done | |
1107 | ||
1108 | printf "%d" $c | |
1109 | } | |
1110 | ||
7950659d | 1111 | __git_whitespacelist="nowarn warn error error-all fix" |
7fb6aefd | 1112 | __git_am_inprogress_options="--skip --continue --resolved --abort --quit --show-current-patch" |
88329195 SP |
1113 | |
1114 | _git_am () | |
1115 | { | |
fad9484f SG |
1116 | __git_find_repo_path |
1117 | if [ -d "$__git_repo_path"/rebase-apply ]; then | |
be3ce6b2 | 1118 | __gitcomp "$__git_am_inprogress_options" |
88329195 SP |
1119 | return |
1120 | fi | |
1121 | case "$cur" in | |
1122 | --whitespace=*) | |
b3391775 | 1123 | __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}" |
88329195 SP |
1124 | return |
1125 | ;; | |
1126 | --*) | |
be3ce6b2 NTND |
1127 | __gitcomp_builtin am "--no-utf8" \ |
1128 | "$__git_am_inprogress_options" | |
88329195 SP |
1129 | return |
1130 | esac | |
88329195 SP |
1131 | } |
1132 | ||
1133 | _git_apply () | |
1134 | { | |
88329195 SP |
1135 | case "$cur" in |
1136 | --whitespace=*) | |
b3391775 | 1137 | __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}" |
88329195 SP |
1138 | return |
1139 | ;; | |
1140 | --*) | |
b8e9d662 | 1141 | __gitcomp_builtin apply |
88329195 SP |
1142 | return |
1143 | esac | |
88329195 SP |
1144 | } |
1145 | ||
8435b548 SP |
1146 | _git_add () |
1147 | { | |
8435b548 SP |
1148 | case "$cur" in |
1149 | --*) | |
e1bea2c0 | 1150 | __gitcomp_builtin add |
8435b548 SP |
1151 | return |
1152 | esac | |
fea16b47 | 1153 | |
bd9ab9df CW |
1154 | local complete_opt="--others --modified --directory --no-empty-directory" |
1155 | if test -n "$(__git_find_on_cmdline "-u --update")" | |
1156 | then | |
1157 | complete_opt="--modified" | |
1158 | fi | |
1159 | __git_complete_index_file "$complete_opt" | |
8435b548 SP |
1160 | } |
1161 | ||
b3191ce2 LM |
1162 | _git_archive () |
1163 | { | |
b3191ce2 LM |
1164 | case "$cur" in |
1165 | --format=*) | |
1166 | __gitcomp "$(git archive --list)" "" "${cur##--format=}" | |
1167 | return | |
1168 | ;; | |
1169 | --remote=*) | |
a31e6262 | 1170 | __gitcomp_nl "$(__git_remotes)" "" "${cur##--remote=}" |
b3191ce2 LM |
1171 | return |
1172 | ;; | |
1173 | --*) | |
1174 | __gitcomp " | |
1175 | --format= --list --verbose | |
f483a0aa | 1176 | --prefix= --remote= --exec= --output |
b3191ce2 LM |
1177 | " |
1178 | return | |
1179 | ;; | |
1180 | esac | |
1181 | __git_complete_file | |
1182 | } | |
1183 | ||
b2e69f62 SP |
1184 | _git_bisect () |
1185 | { | |
d773c631 SG |
1186 | __git_has_doubledash && return |
1187 | ||
bf11d461 | 1188 | local subcommands="start bad good skip reset visualize replay log run" |
918c03c2 | 1189 | local subcommand="$(__git_find_on_cmdline "$subcommands")" |
3ff1320d | 1190 | if [ -z "$subcommand" ]; then |
fad9484f SG |
1191 | __git_find_repo_path |
1192 | if [ -f "$__git_repo_path"/BISECT_START ]; then | |
128191f5 SG |
1193 | __gitcomp "$subcommands" |
1194 | else | |
1195 | __gitcomp "replay start" | |
1196 | fi | |
b2e69f62 SP |
1197 | return |
1198 | fi | |
1199 | ||
3ff1320d | 1200 | case "$subcommand" in |
8205ff8e | 1201 | bad|good|reset|skip|start) |
15b4a163 | 1202 | __git_complete_refs |
b2e69f62 SP |
1203 | ;; |
1204 | *) | |
b2e69f62 SP |
1205 | ;; |
1206 | esac | |
1207 | } | |
1208 | ||
690d8824 JH |
1209 | _git_branch () |
1210 | { | |
da4902a7 | 1211 | local i c=1 only_local_ref="n" has_r="n" |
b9217642 | 1212 | |
da48616f PD |
1213 | while [ $c -lt $cword ]; do |
1214 | i="${words[c]}" | |
b9217642 | 1215 | case "$i" in |
2703c22f VS |
1216 | -d|--delete|-m|--move) only_local_ref="y" ;; |
1217 | -r|--remotes) has_r="y" ;; | |
b9217642 | 1218 | esac |
6e8c755f | 1219 | ((c++)) |
b9217642 SG |
1220 | done |
1221 | ||
da48616f | 1222 | case "$cur" in |
ca45d0fa | 1223 | --set-upstream-to=*) |
15b4a163 | 1224 | __git_complete_refs --cur="${cur##--set-upstream-to=}" |
ca45d0fa | 1225 | ;; |
3b376b0c | 1226 | --*) |
c01b56a3 NTND |
1227 | __gitcomp_builtin branch "--no-color --no-abbrev |
1228 | --no-track --no-column | |
3b376b0c SG |
1229 | " |
1230 | ;; | |
b9217642 SG |
1231 | *) |
1232 | if [ $only_local_ref = "y" -a $has_r = "n" ]; then | |
227307a6 | 1233 | __gitcomp_direct "$(__git_heads "" "$cur" " ")" |
b9217642 | 1234 | else |
15b4a163 | 1235 | __git_complete_refs |
b9217642 SG |
1236 | fi |
1237 | ;; | |
3b376b0c | 1238 | esac |
690d8824 JH |
1239 | } |
1240 | ||
374a58c9 ML |
1241 | _git_bundle () |
1242 | { | |
da48616f PD |
1243 | local cmd="${words[2]}" |
1244 | case "$cword" in | |
8d8163f3 | 1245 | 2) |
374a58c9 ML |
1246 | __gitcomp "create list-heads verify unbundle" |
1247 | ;; | |
8d8163f3 | 1248 | 3) |
374a58c9 ML |
1249 | # looking for a file |
1250 | ;; | |
1251 | *) | |
1252 | case "$cmd" in | |
1253 | create) | |
1254 | __git_complete_revlist | |
1255 | ;; | |
1256 | esac | |
1257 | ;; | |
1258 | esac | |
1259 | } | |
1260 | ||
690d8824 JH |
1261 | _git_checkout () |
1262 | { | |
c84bb14c SG |
1263 | __git_has_doubledash && return |
1264 | ||
e648f8b6 SG |
1265 | case "$cur" in |
1266 | --conflict=*) | |
1267 | __gitcomp "diff3 merge" "" "${cur##--conflict=}" | |
1268 | ;; | |
1269 | --*) | |
77afafb2 | 1270 | __gitcomp_builtin checkout "--no-track --no-recurse-submodules" |
e648f8b6 SG |
1271 | ;; |
1272 | *) | |
34a6bbb5 KB |
1273 | # check if --track, --no-track, or --no-guess was specified |
1274 | # if so, disable DWIM mode | |
15b4a163 | 1275 | local flags="--track --no-track --no-guess" track_opt="--track" |
60e71bbc JK |
1276 | if [ "$GIT_COMPLETION_CHECKOUT_NO_GUESS" = "1" ] || |
1277 | [ -n "$(__git_find_on_cmdline "$flags")" ]; then | |
15b4a163 | 1278 | track_opt='' |
34a6bbb5 | 1279 | fi |
15b4a163 | 1280 | __git_complete_refs $track_opt |
e648f8b6 SG |
1281 | ;; |
1282 | esac | |
690d8824 JH |
1283 | } |
1284 | ||
d8a9fea5 SP |
1285 | _git_cherry () |
1286 | { | |
15b4a163 | 1287 | __git_complete_refs |
d8a9fea5 SP |
1288 | } |
1289 | ||
660003e2 NTND |
1290 | __git_cherry_pick_inprogress_options="--continue --quit --abort" |
1291 | ||
1273231e SP |
1292 | _git_cherry_pick () |
1293 | { | |
fad9484f SG |
1294 | __git_find_repo_path |
1295 | if [ -f "$__git_repo_path"/CHERRY_PICK_HEAD ]; then | |
660003e2 | 1296 | __gitcomp "$__git_cherry_pick_inprogress_options" |
7655fa7f FC |
1297 | return |
1298 | fi | |
1273231e SP |
1299 | case "$cur" in |
1300 | --*) | |
660003e2 NTND |
1301 | __gitcomp_builtin cherry-pick "" \ |
1302 | "$__git_cherry_pick_inprogress_options" | |
1273231e SP |
1303 | ;; |
1304 | *) | |
15b4a163 | 1305 | __git_complete_refs |
1273231e SP |
1306 | ;; |
1307 | esac | |
1308 | } | |
1309 | ||
4181c7e8 LM |
1310 | _git_clean () |
1311 | { | |
4181c7e8 LM |
1312 | case "$cur" in |
1313 | --*) | |
26e90958 | 1314 | __gitcomp_builtin clean |
4181c7e8 LM |
1315 | return |
1316 | ;; | |
1317 | esac | |
fea16b47 MP |
1318 | |
1319 | # XXX should we check for -x option ? | |
ea95c7b8 | 1320 | __git_complete_index_file "--others --directory" |
4181c7e8 LM |
1321 | } |
1322 | ||
3eb11012 LM |
1323 | _git_clone () |
1324 | { | |
3eb11012 LM |
1325 | case "$cur" in |
1326 | --*) | |
4304d3d1 | 1327 | __gitcomp_builtin clone "--no-single-branch" |
3eb11012 LM |
1328 | return |
1329 | ;; | |
1330 | esac | |
3eb11012 LM |
1331 | } |
1332 | ||
21d2a9e3 TB |
1333 | __git_untracked_file_modes="all no normal" |
1334 | ||
4548e855 SP |
1335 | _git_commit () |
1336 | { | |
fea16b47 MP |
1337 | case "$prev" in |
1338 | -c|-C) | |
15b4a163 | 1339 | __git_complete_refs |
fea16b47 MP |
1340 | return |
1341 | ;; | |
1342 | esac | |
d773c631 | 1343 | |
4548e855 | 1344 | case "$cur" in |
9a424b27 | 1345 | --cleanup=*) |
72dbb365 | 1346 | __gitcomp "default scissors strip verbatim whitespace |
9a424b27 SG |
1347 | " "" "${cur##--cleanup=}" |
1348 | return | |
1349 | ;; | |
77653abd TM |
1350 | --reuse-message=*|--reedit-message=*|\ |
1351 | --fixup=*|--squash=*) | |
15b4a163 | 1352 | __git_complete_refs --cur="${cur#*=}" |
9a424b27 SG |
1353 | return |
1354 | ;; | |
1355 | --untracked-files=*) | |
21d2a9e3 | 1356 | __gitcomp "$__git_untracked_file_modes" "" "${cur##--untracked-files=}" |
9a424b27 SG |
1357 | return |
1358 | ;; | |
4548e855 | 1359 | --*) |
2e29dca6 | 1360 | __gitcomp_builtin commit "--no-edit --verify" |
4548e855 SP |
1361 | return |
1362 | esac | |
fea16b47 | 1363 | |
1cd23e9e | 1364 | if __git rev-parse --verify --quiet HEAD >/dev/null; then |
f825972c | 1365 | __git_complete_index_file "--committable" |
fea16b47 MP |
1366 | else |
1367 | # This is the first commit | |
1368 | __git_complete_index_file "--cached" | |
1369 | fi | |
4548e855 SP |
1370 | } |
1371 | ||
217926c0 SP |
1372 | _git_describe () |
1373 | { | |
cbb504c9 TR |
1374 | case "$cur" in |
1375 | --*) | |
ddced834 | 1376 | __gitcomp_builtin describe |
cbb504c9 TR |
1377 | return |
1378 | esac | |
15b4a163 | 1379 | __git_complete_refs |
217926c0 SP |
1380 | } |
1381 | ||
07924d4d MP |
1382 | __git_diff_algorithms="myers minimal patience histogram" |
1383 | ||
462f2134 | 1384 | __git_diff_submodule_formats="diff log short" |
ac76fd54 | 1385 | |
20bf7292 | 1386 | __git_diff_common_options="--stat --numstat --shortstat --summary |
b3a4f858 JS |
1387 | --patch-with-stat --name-only --name-status --color |
1388 | --no-color --color-words --no-renames --check | |
f135aacb | 1389 | --full-index --binary --abbrev --diff-filter= |
e9282f02 | 1390 | --find-copies-harder --ignore-cr-at-eol |
b3a4f858 | 1391 | --text --ignore-space-at-eol --ignore-space-change |
c2545167 TB |
1392 | --ignore-all-space --ignore-blank-lines --exit-code |
1393 | --quiet --ext-diff --no-ext-diff | |
aba201c6 | 1394 | --no-prefix --src-prefix= --dst-prefix= |
6d0e674a | 1395 | --inter-hunk-context= |
216120ab | 1396 | --patience --histogram --minimal |
e6414b46 | 1397 | --raw --word-diff --word-diff-regex= |
8fd2cfa7 SB |
1398 | --dirstat --dirstat= --dirstat-by-file |
1399 | --dirstat-by-file= --cumulative | |
07924d4d | 1400 | --diff-algorithm= |
6cc4bc15 | 1401 | --submodule --submodule= --ignore-submodules |
20bf7292 TR |
1402 | " |
1403 | ||
1404 | _git_diff () | |
1405 | { | |
1406 | __git_has_doubledash && return | |
1407 | ||
20bf7292 | 1408 | case "$cur" in |
07924d4d MP |
1409 | --diff-algorithm=*) |
1410 | __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}" | |
1411 | return | |
1412 | ;; | |
ac76fd54 JK |
1413 | --submodule=*) |
1414 | __gitcomp "$__git_diff_submodule_formats" "" "${cur##--submodule=}" | |
1415 | return | |
1416 | ;; | |
20bf7292 | 1417 | --*) |
ebd15bf0 | 1418 | __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex |
861514d3 | 1419 | --base --ours --theirs --no-index |
20bf7292 | 1420 | $__git_diff_common_options |
aba201c6 | 1421 | " |
b3a4f858 JS |
1422 | return |
1423 | ;; | |
1424 | esac | |
1d66ec58 | 1425 | __git_complete_revlist_file |
690d8824 JH |
1426 | } |
1427 | ||
c5f424fd | 1428 | __git_mergetools_common="diffuse diffmerge ecmerge emerge kdiff3 meld opendiff |
f13f9b0e | 1429 | tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc codecompare |
e2dc2de9 DA |
1430 | " |
1431 | ||
1432 | _git_difftool () | |
1433 | { | |
f7ad96cf MH |
1434 | __git_has_doubledash && return |
1435 | ||
e2dc2de9 DA |
1436 | case "$cur" in |
1437 | --tool=*) | |
1438 | __gitcomp "$__git_mergetools_common kompare" "" "${cur##--tool=}" | |
1439 | return | |
1440 | ;; | |
1441 | --*) | |
6cc4bc15 NTND |
1442 | __gitcomp_builtin difftool "$__git_diff_common_options |
1443 | --base --cached --ours --theirs | |
1444 | --pickaxe-all --pickaxe-regex | |
1445 | --relative --staged | |
1446 | " | |
e2dc2de9 DA |
1447 | return |
1448 | ;; | |
1449 | esac | |
d8517cc6 | 1450 | __git_complete_revlist_file |
e2dc2de9 DA |
1451 | } |
1452 | ||
4dd5c470 SYS |
1453 | __git_fetch_recurse_submodules="yes on-demand no" |
1454 | ||
690d8824 JH |
1455 | _git_fetch () |
1456 | { | |
0a4e1472 | 1457 | case "$cur" in |
4dd5c470 SYS |
1458 | --recurse-submodules=*) |
1459 | __gitcomp "$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}" | |
1460 | return | |
1461 | ;; | |
0a4e1472 | 1462 | --*) |
554a1df4 | 1463 | __gitcomp_builtin fetch "--no-tags" |
0a4e1472 JS |
1464 | return |
1465 | ;; | |
1466 | esac | |
52d5c3b5 | 1467 | __git_complete_remote_or_refspec |
690d8824 JH |
1468 | } |
1469 | ||
2f65494d | 1470 | __git_format_patch_options=" |
ea573521 | 1471 | --stdout --attach --no-attach --thread --thread= --no-thread |
2f65494d FC |
1472 | --numbered --start-number --numbered-files --keep-subject --signoff |
1473 | --signature --no-signature --in-reply-to= --cc= --full-index --binary | |
1474 | --not --all --cover-letter --no-prefix --src-prefix= --dst-prefix= | |
1475 | --inline --suffix= --ignore-if-in-upstream --subject-prefix= | |
ea573521 | 1476 | --output-directory --reroll-count --to= --quiet --notes |
2f65494d FC |
1477 | " |
1478 | ||
f53352fb SP |
1479 | _git_format_patch () |
1480 | { | |
f53352fb | 1481 | case "$cur" in |
e1d37937 SB |
1482 | --thread=*) |
1483 | __gitcomp " | |
1484 | deep shallow | |
1485 | " "" "${cur##--thread=}" | |
1486 | return | |
1487 | ;; | |
f53352fb | 1488 | --*) |
2f65494d | 1489 | __gitcomp "$__git_format_patch_options" |
f53352fb SP |
1490 | return |
1491 | ;; | |
1492 | esac | |
1493 | __git_complete_revlist | |
1494 | } | |
1495 | ||
4bca8636 AJ |
1496 | _git_fsck () |
1497 | { | |
4bca8636 AJ |
1498 | case "$cur" in |
1499 | --*) | |
4d77dd90 | 1500 | __gitcomp_builtin fsck "--no-reflogs" |
4bca8636 AJ |
1501 | return |
1502 | ;; | |
1503 | esac | |
4bca8636 AJ |
1504 | } |
1505 | ||
b26c8748 SP |
1506 | _git_gc () |
1507 | { | |
b26c8748 SP |
1508 | case "$cur" in |
1509 | --*) | |
7e1eeaa4 | 1510 | __gitcomp_builtin gc |
b26c8748 SP |
1511 | return |
1512 | ;; | |
1513 | esac | |
b26c8748 SP |
1514 | } |
1515 | ||
66729509 SG |
1516 | _git_gitk () |
1517 | { | |
1518 | _gitk | |
1519 | } | |
1520 | ||
7826a786 SG |
1521 | # Lists matching symbol names from a tag (as in ctags) file. |
1522 | # 1: List symbol names matching this word. | |
1523 | # 2: The tag file to list symbol names from. | |
1524 | # 3: A prefix to be added to each listed symbol name (optional). | |
1525 | # 4: A suffix to be appended to each listed symbol name (optional). | |
1526 | __git_match_ctag () { | |
1527 | awk -v pfx="${3-}" -v sfx="${4-}" " | |
1528 | /^${1//\//\\/}/ { print pfx \$1 sfx } | |
1529 | " "$2" | |
29eec71f JK |
1530 | } |
1531 | ||
2f779f91 SG |
1532 | # Complete symbol names from a tag file. |
1533 | # Usage: __git_complete_symbol [<option>]... | |
1534 | # --tags=<file>: The tag file to list symbol names from instead of the | |
1535 | # default "tags". | |
1536 | # --pfx=<prefix>: A prefix to be added to each symbol name. | |
1537 | # --cur=<word>: The current symbol name to be completed. Defaults to | |
1538 | # the current word to be completed. | |
1539 | # --sfx=<suffix>: A suffix to be appended to each symbol name instead | |
1540 | # of the default space. | |
1541 | __git_complete_symbol () { | |
1542 | local tags=tags pfx="" cur_="${cur-}" sfx=" " | |
1543 | ||
1544 | while test $# != 0; do | |
1545 | case "$1" in | |
1546 | --tags=*) tags="${1##--tags=}" ;; | |
1547 | --pfx=*) pfx="${1##--pfx=}" ;; | |
1548 | --cur=*) cur_="${1##--cur=}" ;; | |
1549 | --sfx=*) sfx="${1##--sfx=}" ;; | |
1550 | *) return 1 ;; | |
1551 | esac | |
1552 | shift | |
1553 | done | |
1554 | ||
1555 | if test -r "$tags"; then | |
1556 | __gitcomp_direct "$(__git_match_ctag "$cur_" "$tags" "$pfx" "$sfx")" | |
1557 | fi | |
29eec71f JK |
1558 | } |
1559 | ||
c72e0db1 LM |
1560 | _git_grep () |
1561 | { | |
1562 | __git_has_doubledash && return | |
1563 | ||
c72e0db1 LM |
1564 | case "$cur" in |
1565 | --*) | |
caf2de33 | 1566 | __gitcomp_builtin grep |
c72e0db1 LM |
1567 | return |
1568 | ;; | |
1569 | esac | |
17225c49 | 1570 | |
29eec71f JK |
1571 | case "$cword,$prev" in |
1572 | 2,*|*,-*) | |
2f779f91 | 1573 | __git_complete_symbol && return |
29eec71f JK |
1574 | ;; |
1575 | esac | |
1576 | ||
15b4a163 | 1577 | __git_complete_refs |
c72e0db1 LM |
1578 | } |
1579 | ||
1eb7e2f8 LM |
1580 | _git_help () |
1581 | { | |
1eb7e2f8 LM |
1582 | case "$cur" in |
1583 | --*) | |
8c13a8d7 | 1584 | __gitcomp_builtin help |
1eb7e2f8 LM |
1585 | return |
1586 | ;; | |
1587 | esac | |
eaa4e6ee | 1588 | __git_compute_all_commands |
f85a6f0b | 1589 | __gitcomp "$__git_all_commands $(__git_aliases) |
2946cccf | 1590 | attributes cli core-tutorial cvs-migration |
4d10b7e1 RT |
1591 | diffcore everyday gitk glossary hooks ignore modules |
1592 | namespaces repository-layout revisions tutorial tutorial-2 | |
99f0b599 | 1593 | workflows |
2946cccf | 1594 | " |
1eb7e2f8 LM |
1595 | } |
1596 | ||
5dad868b LM |
1597 | _git_init () |
1598 | { | |
5dad868b LM |
1599 | case "$cur" in |
1600 | --shared=*) | |
1601 | __gitcomp " | |
1602 | false true umask group all world everybody | |
1603 | " "" "${cur##--shared=}" | |
1604 | return | |
1605 | ;; | |
1606 | --*) | |
b00116b7 | 1607 | __gitcomp_builtin init |
5dad868b LM |
1608 | return |
1609 | ;; | |
1610 | esac | |
5dad868b LM |
1611 | } |
1612 | ||
b1bc1494 LM |
1613 | _git_ls_files () |
1614 | { | |
b1bc1494 LM |
1615 | case "$cur" in |
1616 | --*) | |
c893985d | 1617 | __gitcomp_builtin ls-files "--no-empty-directory" |
b1bc1494 LM |
1618 | return |
1619 | ;; | |
1620 | esac | |
fea16b47 MP |
1621 | |
1622 | # XXX ignore options like --modified and always suggest all cached | |
1623 | # files. | |
1624 | __git_complete_index_file "--cached" | |
b1bc1494 LM |
1625 | } |
1626 | ||
690d8824 JH |
1627 | _git_ls_remote () |
1628 | { | |
2c0f3a53 CW |
1629 | case "$cur" in |
1630 | --*) | |
cdc71c1c | 1631 | __gitcomp_builtin ls-remote |
2c0f3a53 CW |
1632 | return |
1633 | ;; | |
1634 | esac | |
a31e6262 | 1635 | __gitcomp_nl "$(__git_remotes)" |
690d8824 JH |
1636 | } |
1637 | ||
1638 | _git_ls_tree () | |
1639 | { | |
1640 | __git_complete_file | |
1641 | } | |
1642 | ||
a393777e TR |
1643 | # Options that go well for log, shortlog and gitk |
1644 | __git_log_common_options=" | |
1645 | --not --all | |
1646 | --branches --tags --remotes | |
4fe1a619 | 1647 | --first-parent --merges --no-merges |
a393777e TR |
1648 | --max-count= |
1649 | --max-age= --since= --after= | |
1650 | --min-age= --until= --before= | |
6a6ebded MG |
1651 | --min-parents= --max-parents= |
1652 | --no-min-parents --no-max-parents | |
a393777e TR |
1653 | " |
1654 | # Options that go well for log and gitk (not shortlog) | |
1655 | __git_log_gitk_options=" | |
1656 | --dense --sparse --full-history | |
1657 | --simplify-merges --simplify-by-decoration | |
3925b575 | 1658 | --left-right --notes --no-notes |
a393777e TR |
1659 | " |
1660 | # Options that go well for log and shortlog (not gitk) | |
1661 | __git_log_shortlog_options=" | |
1662 | --author= --committer= --grep= | |
22dfa8a2 | 1663 | --all-match --invert-grep |
a393777e TR |
1664 | " |
1665 | ||
3d279863 | 1666 | __git_log_pretty_formats="oneline short medium full fuller email raw format:" |
672c68cb | 1667 | __git_log_date_formats="relative iso8601 rfc2822 short local default raw" |
3d279863 | 1668 | |
690d8824 JH |
1669 | _git_log () |
1670 | { | |
d773c631 | 1671 | __git_has_doubledash && return |
fad9484f | 1672 | __git_find_repo_path |
d773c631 | 1673 | |
bf3c20f6 | 1674 | local merge="" |
fad9484f | 1675 | if [ -f "$__git_repo_path/MERGE_HEAD" ]; then |
bf3c20f6 TR |
1676 | merge="--merge" |
1677 | fi | |
41d2716c SG |
1678 | case "$prev,$cur" in |
1679 | -L,:*:*) | |
1680 | return # fall back to Bash filename completion | |
1681 | ;; | |
1682 | -L,:*) | |
1683 | __git_complete_symbol --cur="${cur#:}" --sfx=":" | |
1684 | return | |
1685 | ;; | |
1686 | -G,*|-S,*) | |
1687 | __git_complete_symbol | |
1688 | return | |
1689 | ;; | |
1690 | esac | |
6e31b866 | 1691 | case "$cur" in |
e67d71e5 | 1692 | --pretty=*|--format=*) |
c3898111 | 1693 | __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases) |
e67d71e5 | 1694 | " "" "${cur#*=}" |
72de29c2 TL |
1695 | return |
1696 | ;; | |
47e98eec | 1697 | --date=*) |
672c68cb | 1698 | __gitcomp "$__git_log_date_formats" "" "${cur##--date=}" |
47e98eec SP |
1699 | return |
1700 | ;; | |
af4e9e8c | 1701 | --decorate=*) |
af16bdaa | 1702 | __gitcomp "full short no" "" "${cur##--decorate=}" |
af4e9e8c SB |
1703 | return |
1704 | ;; | |
ac76fd54 JK |
1705 | --diff-algorithm=*) |
1706 | __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}" | |
1707 | return | |
1708 | ;; | |
1709 | --submodule=*) | |
1710 | __gitcomp "$__git_diff_submodule_formats" "" "${cur##--submodule=}" | |
1711 | return | |
1712 | ;; | |
6e31b866 | 1713 | --*) |
b3391775 | 1714 | __gitcomp " |
a393777e TR |
1715 | $__git_log_common_options |
1716 | $__git_log_shortlog_options | |
1717 | $__git_log_gitk_options | |
8f87fae6 | 1718 | --root --topo-order --date-order --reverse |
5d0e6343 | 1719 | --follow --full-diff |
6e31b866 | 1720 | --abbrev-commit --abbrev= |
47e98eec | 1721 | --relative-date --date= |
72de29c2 | 1722 | --pretty= --format= --oneline |
2ca0b197 | 1723 | --show-signature |
d3bfbf91 | 1724 | --cherry-mark |
a393777e | 1725 | --cherry-pick |
20827d99 | 1726 | --graph |
af4e9e8c | 1727 | --decorate --decorate= |
20bf7292 | 1728 | --walk-reflogs |
a393777e | 1729 | --parents --children |
bf3c20f6 | 1730 | $merge |
20bf7292 | 1731 | $__git_diff_common_options |
47d5a8fa | 1732 | --pickaxe-all --pickaxe-regex |
b3391775 | 1733 | " |
6e31b866 SP |
1734 | return |
1735 | ;; | |
41d2716c SG |
1736 | -L:*:*) |
1737 | return # fall back to Bash filename completion | |
1738 | ;; | |
1739 | -L:*) | |
1740 | __git_complete_symbol --cur="${cur#-L:}" --sfx=":" | |
1741 | return | |
1742 | ;; | |
1743 | -G*) | |
1744 | __git_complete_symbol --pfx="-G" --cur="${cur#-G}" | |
1745 | return | |
1746 | ;; | |
1747 | -S*) | |
1748 | __git_complete_symbol --pfx="-S" --cur="${cur#-S}" | |
1749 | return | |
1750 | ;; | |
6e31b866 | 1751 | esac |
f53352fb | 1752 | __git_complete_revlist |
690d8824 JH |
1753 | } |
1754 | ||
4ad91321 SP |
1755 | _git_merge () |
1756 | { | |
3c7b480a JS |
1757 | __git_complete_strategy && return |
1758 | ||
4ad91321 SP |
1759 | case "$cur" in |
1760 | --*) | |
b475e442 | 1761 | __gitcomp_builtin merge "--no-rerere-autoupdate |
640c325b NTND |
1762 | --no-commit --no-edit --no-ff |
1763 | --no-log --no-progress | |
1764 | --no-squash --no-stat | |
1765 | --no-verify-signatures | |
1766 | " | |
4ad91321 SP |
1767 | return |
1768 | esac | |
15b4a163 | 1769 | __git_complete_refs |
4ad91321 SP |
1770 | } |
1771 | ||
b4c72162 LM |
1772 | _git_mergetool () |
1773 | { | |
b4c72162 LM |
1774 | case "$cur" in |
1775 | --tool=*) | |
e2dc2de9 | 1776 | __gitcomp "$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}" |
b4c72162 LM |
1777 | return |
1778 | ;; | |
1779 | --*) | |
f483a0aa | 1780 | __gitcomp "--tool= --prompt --no-prompt" |
b4c72162 LM |
1781 | return |
1782 | ;; | |
1783 | esac | |
b4c72162 LM |
1784 | } |
1785 | ||
690d8824 JH |
1786 | _git_merge_base () |
1787 | { | |
85453fd1 JK |
1788 | case "$cur" in |
1789 | --*) | |
4429d8b2 | 1790 | __gitcomp_builtin merge-base |
85453fd1 JK |
1791 | return |
1792 | ;; | |
1793 | esac | |
15b4a163 | 1794 | __git_complete_refs |
690d8824 JH |
1795 | } |
1796 | ||
1127c51c LM |
1797 | _git_mv () |
1798 | { | |
1127c51c LM |
1799 | case "$cur" in |
1800 | --*) | |
61d15cd6 | 1801 | __gitcomp_builtin mv |
1127c51c LM |
1802 | return |
1803 | ;; | |
1804 | esac | |
fea16b47 MP |
1805 | |
1806 | if [ $(__git_count_arguments "mv") -gt 0 ]; then | |
1807 | # We need to show both cached and untracked files (including | |
1808 | # empty directories) since this may not be the last argument. | |
1809 | __git_complete_index_file "--cached --others --directory" | |
1810 | else | |
1811 | __git_complete_index_file "--cached" | |
1812 | fi | |
1127c51c LM |
1813 | } |
1814 | ||
d33909bf SP |
1815 | _git_name_rev () |
1816 | { | |
d73a59d1 | 1817 | __gitcomp_builtin name-rev |
d33909bf SP |
1818 | } |
1819 | ||
00f09d0e SG |
1820 | _git_notes () |
1821 | { | |
27b42d04 | 1822 | local subcommands='add append copy edit get-ref list merge prune remove show' |
2a5da755 | 1823 | local subcommand="$(__git_find_on_cmdline "$subcommands")" |
00f09d0e | 1824 | |
2a5da755 SG |
1825 | case "$subcommand,$cur" in |
1826 | ,--*) | |
7a60e3bb | 1827 | __gitcomp_builtin notes |
2a5da755 SG |
1828 | ;; |
1829 | ,*) | |
39540681 | 1830 | case "$prev" in |
2a5da755 | 1831 | --ref) |
15b4a163 | 1832 | __git_complete_refs |
2a5da755 SG |
1833 | ;; |
1834 | *) | |
1835 | __gitcomp "$subcommands --ref" | |
1836 | ;; | |
1837 | esac | |
1838 | ;; | |
b25e2e64 | 1839 | *,--reuse-message=*|*,--reedit-message=*) |
15b4a163 | 1840 | __git_complete_refs --cur="${cur#*=}" |
2a5da755 | 1841 | ;; |
4ea2c974 NTND |
1842 | *,--*) |
1843 | __gitcomp_builtin notes_$subcommand | |
2a5da755 | 1844 | ;; |
27b42d04 | 1845 | prune,*|get-ref,*) |
4ea2c974 | 1846 | # this command does not take a ref, do not complete it |
00f09d0e SG |
1847 | ;; |
1848 | *) | |
39540681 | 1849 | case "$prev" in |
2a5da755 SG |
1850 | -m|-F) |
1851 | ;; | |
1852 | *) | |
15b4a163 | 1853 | __git_complete_refs |
2a5da755 SG |
1854 | ;; |
1855 | esac | |
00f09d0e SG |
1856 | ;; |
1857 | esac | |
1858 | } | |
1859 | ||
690d8824 JH |
1860 | _git_pull () |
1861 | { | |
0a4e1472 JS |
1862 | __git_complete_strategy && return |
1863 | ||
0a4e1472 | 1864 | case "$cur" in |
4dd5c470 SYS |
1865 | --recurse-submodules=*) |
1866 | __gitcomp "$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}" | |
1867 | return | |
1868 | ;; | |
0a4e1472 | 1869 | --*) |
32e64e50 NTND |
1870 | __gitcomp_builtin pull "--no-autostash --no-commit --no-edit |
1871 | --no-ff --no-log --no-progress --no-rebase | |
1872 | --no-squash --no-stat --no-tags | |
1873 | --no-verify-signatures" | |
1874 | ||
0a4e1472 JS |
1875 | return |
1876 | ;; | |
1877 | esac | |
52d5c3b5 | 1878 | __git_complete_remote_or_refspec |
690d8824 JH |
1879 | } |
1880 | ||
446624ce | 1881 | __git_push_recurse_submodules="check on-demand only" |
4dd5c470 | 1882 | |
aaf7253f JK |
1883 | __git_complete_force_with_lease () |
1884 | { | |
1885 | local cur_=$1 | |
1886 | ||
1887 | case "$cur_" in | |
1888 | --*=) | |
1889 | ;; | |
1890 | *:*) | |
15b4a163 | 1891 | __git_complete_refs --cur="${cur_#*:}" |
aaf7253f JK |
1892 | ;; |
1893 | *) | |
15b4a163 | 1894 | __git_complete_refs --cur="$cur_" |
aaf7253f JK |
1895 | ;; |
1896 | esac | |
1897 | } | |
1898 | ||
690d8824 JH |
1899 | _git_push () |
1900 | { | |
da48616f | 1901 | case "$prev" in |
0a4e1472 | 1902 | --repo) |
a31e6262 | 1903 | __gitcomp_nl "$(__git_remotes)" |
0a4e1472 | 1904 | return |
3a224ff2 JK |
1905 | ;; |
1906 | --recurse-submodules) | |
1907 | __gitcomp "$__git_push_recurse_submodules" | |
1908 | return | |
1909 | ;; | |
0a4e1472 JS |
1910 | esac |
1911 | case "$cur" in | |
1912 | --repo=*) | |
a31e6262 | 1913 | __gitcomp_nl "$(__git_remotes)" "" "${cur##--repo=}" |
0a4e1472 JS |
1914 | return |
1915 | ;; | |
4dd5c470 SYS |
1916 | --recurse-submodules=*) |
1917 | __gitcomp "$__git_push_recurse_submodules" "" "${cur##--recurse-submodules=}" | |
1918 | return | |
1919 | ;; | |
aaf7253f JK |
1920 | --force-with-lease=*) |
1921 | __git_complete_force_with_lease "${cur##--force-with-lease=}" | |
1922 | return | |
1923 | ;; | |
0a4e1472 | 1924 | --*) |
f1e1bdd6 | 1925 | __gitcomp_builtin push |
0a4e1472 JS |
1926 | return |
1927 | ;; | |
1928 | esac | |
52d5c3b5 | 1929 | __git_complete_remote_or_refspec |
690d8824 JH |
1930 | } |
1931 | ||
61d926a3 SP |
1932 | _git_rebase () |
1933 | { | |
fad9484f SG |
1934 | __git_find_repo_path |
1935 | if [ -f "$__git_repo_path"/rebase-merge/interactive ]; then | |
66335298 | 1936 | __gitcomp "--continue --skip --abort --quit --edit-todo --show-current-patch" |
09bb6520 | 1937 | return |
fad9484f SG |
1938 | elif [ -d "$__git_repo_path"/rebase-apply ] || \ |
1939 | [ -d "$__git_repo_path"/rebase-merge ]; then | |
66335298 | 1940 | __gitcomp "--continue --skip --abort --quit --show-current-patch" |
61d926a3 SP |
1941 | return |
1942 | fi | |
3c7b480a | 1943 | __git_complete_strategy && return |
61d926a3 | 1944 | case "$cur" in |
93cf50a4 BG |
1945 | --whitespace=*) |
1946 | __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}" | |
1947 | return | |
1948 | ;; | |
61d926a3 | 1949 | --*) |
93cf50a4 BG |
1950 | __gitcomp " |
1951 | --onto --merge --strategy --interactive | |
1952 | --preserve-merges --stat --no-stat | |
1953 | --committer-date-is-author-date --ignore-date | |
1954 | --ignore-whitespace --whitespace= | |
fa4b5e3a JK |
1955 | --autosquash --no-autosquash |
1956 | --fork-point --no-fork-point | |
1957 | --autostash --no-autostash | |
1958 | --verify --no-verify | |
1959 | --keep-empty --root --force-rebase --no-ff | |
b475e442 | 1960 | --rerere-autoupdate |
fa4b5e3a | 1961 | --exec |
93cf50a4 BG |
1962 | " |
1963 | ||
61d926a3 SP |
1964 | return |
1965 | esac | |
15b4a163 | 1966 | __git_complete_refs |
61d926a3 SP |
1967 | } |
1968 | ||
057f3279 TRC |
1969 | _git_reflog () |
1970 | { | |
1971 | local subcommands="show delete expire" | |
1972 | local subcommand="$(__git_find_on_cmdline "$subcommands")" | |
1973 | ||
1974 | if [ -z "$subcommand" ]; then | |
1975 | __gitcomp "$subcommands" | |
1976 | else | |
15b4a163 | 1977 | __git_complete_refs |
057f3279 TRC |
1978 | fi |
1979 | } | |
1980 | ||
ae616de6 | 1981 | __git_send_email_confirm_options="always never auto cc compose" |
cb8a9bd5 | 1982 | __git_send_email_suppresscc_options="author self cc bodycc sob cccmd body all" |
ae616de6 | 1983 | |
25a1f374 TL |
1984 | _git_send_email () |
1985 | { | |
dfbe5eeb JK |
1986 | case "$prev" in |
1987 | --to|--cc|--bcc|--from) | |
e15098a3 | 1988 | __gitcomp "$(__git send-email --dump-aliases)" |
dfbe5eeb JK |
1989 | return |
1990 | ;; | |
1991 | esac | |
1992 | ||
25a1f374 | 1993 | case "$cur" in |
ae616de6 SB |
1994 | --confirm=*) |
1995 | __gitcomp " | |
1996 | $__git_send_email_confirm_options | |
1997 | " "" "${cur##--confirm=}" | |
1998 | return | |
1999 | ;; | |
2000 | --suppress-cc=*) | |
2001 | __gitcomp " | |
2002 | $__git_send_email_suppresscc_options | |
2003 | " "" "${cur##--suppress-cc=}" | |
2004 | ||
2005 | return | |
2006 | ;; | |
2007 | --smtp-encryption=*) | |
2008 | __gitcomp "ssl tls" "" "${cur##--smtp-encryption=}" | |
2009 | return | |
2010 | ;; | |
2f65494d FC |
2011 | --thread=*) |
2012 | __gitcomp " | |
2013 | deep shallow | |
2014 | " "" "${cur##--thread=}" | |
2015 | return | |
2016 | ;; | |
dfbe5eeb | 2017 | --to=*|--cc=*|--bcc=*|--from=*) |
e15098a3 | 2018 | __gitcomp "$(__git send-email --dump-aliases)" "" "${cur#--*=}" |
dfbe5eeb JK |
2019 | return |
2020 | ;; | |
25a1f374 | 2021 | --*) |
77813151 | 2022 | __gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to |
ae616de6 SB |
2023 | --compose --confirm= --dry-run --envelope-sender |
2024 | --from --identity | |
25a1f374 | 2025 | --in-reply-to --no-chain-reply-to --no-signed-off-by-cc |
d11c943c | 2026 | --no-suppress-from --no-thread --quiet --reply-to |
25a1f374 | 2027 | --signed-off-by-cc --smtp-pass --smtp-server |
ae616de6 SB |
2028 | --smtp-server-port --smtp-encryption= --smtp-user |
2029 | --subject --suppress-cc= --suppress-from --thread --to | |
2f65494d FC |
2030 | --validate --no-validate |
2031 | $__git_format_patch_options" | |
25a1f374 TL |
2032 | return |
2033 | ;; | |
2034 | esac | |
2f65494d | 2035 | __git_complete_revlist |
25a1f374 TL |
2036 | } |
2037 | ||
424cce83 SG |
2038 | _git_stage () |
2039 | { | |
2040 | _git_add | |
2041 | } | |
2042 | ||
634d2344 TB |
2043 | _git_status () |
2044 | { | |
2045 | local complete_opt | |
2046 | local untracked_state | |
2047 | ||
2048 | case "$cur" in | |
2049 | --ignore-submodules=*) | |
2050 | __gitcomp "none untracked dirty all" "" "${cur##--ignore-submodules=}" | |
2051 | return | |
2052 | ;; | |
2053 | --untracked-files=*) | |
2054 | __gitcomp "$__git_untracked_file_modes" "" "${cur##--untracked-files=}" | |
2055 | return | |
2056 | ;; | |
2057 | --column=*) | |
2058 | __gitcomp " | |
2059 | always never auto column row plain dense nodense | |
2060 | " "" "${cur##--column=}" | |
2061 | return | |
2062 | ;; | |
2063 | --*) | |
78331b6f | 2064 | __gitcomp_builtin status "--no-column" |
634d2344 TB |
2065 | return |
2066 | ;; | |
2067 | esac | |
2068 | ||
2069 | untracked_state="$(__git_get_option_value "-u" "--untracked-files=" \ | |
2070 | "$__git_untracked_file_modes" "status.showUntrackedFiles")" | |
2071 | ||
2072 | case "$untracked_state" in | |
2073 | no) | |
2074 | # --ignored option does not matter | |
2075 | complete_opt= | |
2076 | ;; | |
2077 | all|normal|*) | |
2078 | complete_opt="--cached --directory --no-empty-directory --others" | |
2079 | ||
2080 | if [ -n "$(__git_find_on_cmdline "--ignored")" ]; then | |
2081 | complete_opt="$complete_opt --ignored --exclude=*" | |
2082 | fi | |
2083 | ;; | |
2084 | esac | |
2085 | ||
2086 | __git_complete_index_file "$complete_opt" | |
2087 | } | |
2088 | ||
00652369 SB |
2089 | __git_config_get_set_variables () |
2090 | { | |
da48616f | 2091 | local prevword word config_file= c=$cword |
00652369 | 2092 | while [ $c -gt 1 ]; do |
da48616f | 2093 | word="${words[c]}" |
00652369 | 2094 | case "$word" in |
66c0786c | 2095 | --system|--global|--local|--file=*) |
00652369 SB |
2096 | config_file="$word" |
2097 | break | |
2098 | ;; | |
2099 | -f|--file) | |
2100 | config_file="$word $prevword" | |
2101 | break | |
2102 | ;; | |
2103 | esac | |
2104 | prevword=$word | |
2105 | c=$((--c)) | |
2106 | done | |
2107 | ||
e15098a3 | 2108 | __git config $config_file --name-only --list |
00652369 SB |
2109 | } |
2110 | ||
e0d10e1c | 2111 | _git_config () |
5de40f59 | 2112 | { |
da48616f | 2113 | case "$prev" in |
72f75077 | 2114 | branch.*.remote|branch.*.pushremote) |
a31e6262 | 2115 | __gitcomp_nl "$(__git_remotes)" |
5de40f59 SP |
2116 | return |
2117 | ;; | |
2118 | branch.*.merge) | |
15b4a163 | 2119 | __git_complete_refs |
5de40f59 SP |
2120 | return |
2121 | ;; | |
a05490ed | 2122 | branch.*.rebase) |
17c4ddbb | 2123 | __gitcomp "false true preserve interactive" |
a05490ed RR |
2124 | return |
2125 | ;; | |
7e6a0cc4 RR |
2126 | remote.pushdefault) |
2127 | __gitcomp_nl "$(__git_remotes)" | |
2128 | return | |
2129 | ;; | |
5de40f59 | 2130 | remote.*.fetch) |
da48616f | 2131 | local remote="${prev#remote.}" |
5de40f59 | 2132 | remote="${remote%.fetch}" |
d51a8ecd | 2133 | if [ -z "$cur" ]; then |
73704451 | 2134 | __gitcomp_nl "refs/heads/" "" "" "" |
d51a8ecd SG |
2135 | return |
2136 | fi | |
a31e6262 | 2137 | __gitcomp_nl "$(__git_refs_remotes "$remote")" |
5de40f59 SP |
2138 | return |
2139 | ;; | |
2140 | remote.*.push) | |
da48616f | 2141 | local remote="${prev#remote.}" |
5de40f59 | 2142 | remote="${remote%.push}" |
3ba04201 | 2143 | __gitcomp_nl "$(__git for-each-ref \ |
1cd23e9e | 2144 | --format='%(refname):%(refname)' refs/heads)" |
78d4d6a2 SP |
2145 | return |
2146 | ;; | |
2147 | pull.twohead|pull.octopus) | |
eaa4e6ee JN |
2148 | __git_compute_merge_strategies |
2149 | __gitcomp "$__git_merge_strategies" | |
78d4d6a2 SP |
2150 | return |
2151 | ;; | |
6123d719 MH |
2152 | color.branch|color.diff|color.interactive|\ |
2153 | color.showbranch|color.status|color.ui) | |
78d4d6a2 SP |
2154 | __gitcomp "always never auto" |
2155 | return | |
2156 | ;; | |
901d615c MK |
2157 | color.pager) |
2158 | __gitcomp "false true" | |
2159 | return | |
2160 | ;; | |
78d4d6a2 SP |
2161 | color.*.*) |
2162 | __gitcomp " | |
98171a07 | 2163 | normal black red green yellow blue magenta cyan white |
78d4d6a2 SP |
2164 | bold dim ul blink reverse |
2165 | " | |
5de40f59 SP |
2166 | return |
2167 | ;; | |
2651baae RR |
2168 | diff.submodule) |
2169 | __gitcomp "log short" | |
2170 | return | |
2171 | ;; | |
9b82d63b SB |
2172 | help.format) |
2173 | __gitcomp "man info web html" | |
2174 | return | |
2175 | ;; | |
672c68cb SB |
2176 | log.date) |
2177 | __gitcomp "$__git_log_date_formats" | |
2178 | return | |
2179 | ;; | |
ae616de6 SB |
2180 | sendemail.aliasesfiletype) |
2181 | __gitcomp "mutt mailrc pine elm gnus" | |
2182 | return | |
2183 | ;; | |
2184 | sendemail.confirm) | |
2185 | __gitcomp "$__git_send_email_confirm_options" | |
2186 | return | |
2187 | ;; | |
2188 | sendemail.suppresscc) | |
2189 | __gitcomp "$__git_send_email_suppresscc_options" | |
2190 | return | |
2191 | ;; | |
8d814084 PB |
2192 | sendemail.transferencoding) |
2193 | __gitcomp "7bit 8bit quoted-printable base64" | |
2194 | return | |
2195 | ;; | |
00652369 | 2196 | --get|--get-all|--unset|--unset-all) |
a31e6262 | 2197 | __gitcomp_nl "$(__git_config_get_set_variables)" |
00652369 SB |
2198 | return |
2199 | ;; | |
5de40f59 | 2200 | *.*) |
5de40f59 SP |
2201 | return |
2202 | ;; | |
2203 | esac | |
2204 | case "$cur" in | |
2205 | --*) | |
5983ba0d | 2206 | __gitcomp_builtin config |
5de40f59 SP |
2207 | return |
2208 | ;; | |
2209 | branch.*.*) | |
9244d69b | 2210 | local pfx="${cur%.*}." cur_="${cur##*.}" |
72f75077 | 2211 | __gitcomp "remote pushremote merge mergeoptions rebase" "$pfx" "$cur_" |
5de40f59 SP |
2212 | return |
2213 | ;; | |
2214 | branch.*) | |
9244d69b | 2215 | local pfx="${cur%.*}." cur_="${cur#*.}" |
227307a6 | 2216 | __gitcomp_direct "$(__git_heads "$pfx" "$cur_" ".")" |
422553df | 2217 | __gitcomp_nl_append $'autosetupmerge\nautosetuprebase\n' "$pfx" "$cur_" |
5de40f59 SP |
2218 | return |
2219 | ;; | |
0aa62fd0 | 2220 | guitool.*.*) |
9244d69b | 2221 | local pfx="${cur%.*}." cur_="${cur##*.}" |
0aa62fd0 SB |
2222 | __gitcomp " |
2223 | argprompt cmd confirm needsfile noconsole norescan | |
2224 | prompt revprompt revunmerged title | |
9244d69b | 2225 | " "$pfx" "$cur_" |
0aa62fd0 SB |
2226 | return |
2227 | ;; | |
2228 | difftool.*.*) | |
9244d69b SG |
2229 | local pfx="${cur%.*}." cur_="${cur##*.}" |
2230 | __gitcomp "cmd path" "$pfx" "$cur_" | |
0aa62fd0 SB |
2231 | return |
2232 | ;; | |
2233 | man.*.*) | |
9244d69b SG |
2234 | local pfx="${cur%.*}." cur_="${cur##*.}" |
2235 | __gitcomp "cmd path" "$pfx" "$cur_" | |
0aa62fd0 SB |
2236 | return |
2237 | ;; | |
2238 | mergetool.*.*) | |
9244d69b SG |
2239 | local pfx="${cur%.*}." cur_="${cur##*.}" |
2240 | __gitcomp "cmd path trustExitCode" "$pfx" "$cur_" | |
0aa62fd0 SB |
2241 | return |
2242 | ;; | |
2243 | pager.*) | |
9244d69b | 2244 | local pfx="${cur%.*}." cur_="${cur#*.}" |
eaa4e6ee | 2245 | __git_compute_all_commands |
a31e6262 | 2246 | __gitcomp_nl "$__git_all_commands" "$pfx" "$cur_" |
0aa62fd0 SB |
2247 | return |
2248 | ;; | |
5de40f59 | 2249 | remote.*.*) |
9244d69b | 2250 | local pfx="${cur%.*}." cur_="${cur##*.}" |
12977705 | 2251 | __gitcomp " |
98171a07 | 2252 | url proxy fetch push mirror skipDefaultUpdate |
6fac1b83 | 2253 | receivepack uploadpack tagopt pushurl |
9244d69b | 2254 | " "$pfx" "$cur_" |
5de40f59 SP |
2255 | return |
2256 | ;; | |
2257 | remote.*) | |
9244d69b | 2258 | local pfx="${cur%.*}." cur_="${cur#*.}" |
a31e6262 | 2259 | __gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "." |
c39a2f11 | 2260 | __gitcomp_nl_append "pushdefault" "$pfx" "$cur_" |
5de40f59 SP |
2261 | return |
2262 | ;; | |
0aa62fd0 | 2263 | url.*.*) |
9244d69b SG |
2264 | local pfx="${cur%.*}." cur_="${cur##*.}" |
2265 | __gitcomp "insteadOf pushInsteadOf" "$pfx" "$cur_" | |
0aa62fd0 SB |
2266 | return |
2267 | ;; | |
5de40f59 | 2268 | esac |
78d4d6a2 | 2269 | __gitcomp " |
6068ac88 | 2270 | add.ignoreErrors |
fd1552d5 | 2271 | advice.amWorkDir |
6068ac88 MZ |
2272 | advice.commitBeforeMerge |
2273 | advice.detachedHead | |
2274 | advice.implicitIdentity | |
fd1552d5 RF |
2275 | advice.pushAlreadyExists |
2276 | advice.pushFetchFirst | |
2277 | advice.pushNeedsForce | |
2278 | advice.pushNonFFCurrent | |
2279 | advice.pushNonFFMatching | |
2280 | advice.pushUpdateRejected | |
6068ac88 | 2281 | advice.resolveConflict |
fd1552d5 | 2282 | advice.rmHints |
6068ac88 | 2283 | advice.statusHints |
fd1552d5 | 2284 | advice.statusUoption |
f805a00a | 2285 | advice.ignoredHook |
226b343c | 2286 | alias. |
6068ac88 | 2287 | am.keepcr |
e8dec567 | 2288 | am.threeWay |
86c91f91 | 2289 | apply.ignorewhitespace |
5de40f59 | 2290 | apply.whitespace |
98171a07 LM |
2291 | branch.autosetupmerge |
2292 | branch.autosetuprebase | |
6068ac88 | 2293 | browser. |
2122591b | 2294 | clean.requireForce |
78d4d6a2 SP |
2295 | color.branch |
2296 | color.branch.current | |
2297 | color.branch.local | |
78d4d6a2 | 2298 | color.branch.plain |
025a1929 | 2299 | color.branch.remote |
6068ac88 MZ |
2300 | color.decorate.HEAD |
2301 | color.decorate.branch | |
2302 | color.decorate.remoteBranch | |
2303 | color.decorate.stash | |
2304 | color.decorate.tag | |
a159ca0c | 2305 | color.diff |
025a1929 | 2306 | color.diff.commit |
78d4d6a2 | 2307 | color.diff.frag |
6068ac88 | 2308 | color.diff.func |
025a1929 | 2309 | color.diff.meta |
78d4d6a2 | 2310 | color.diff.new |
025a1929 LM |
2311 | color.diff.old |
2312 | color.diff.plain | |
78d4d6a2 | 2313 | color.diff.whitespace |
226b343c | 2314 | color.grep |
6068ac88 MZ |
2315 | color.grep.context |
2316 | color.grep.filename | |
2317 | color.grep.function | |
2318 | color.grep.linenumber | |
226b343c | 2319 | color.grep.match |
6068ac88 MZ |
2320 | color.grep.selected |
2321 | color.grep.separator | |
98171a07 | 2322 | color.interactive |
6068ac88 | 2323 | color.interactive.error |
98171a07 LM |
2324 | color.interactive.header |
2325 | color.interactive.help | |
2326 | color.interactive.prompt | |
a159ca0c | 2327 | color.pager |
6123d719 | 2328 | color.showbranch |
a159ca0c | 2329 | color.status |
78d4d6a2 SP |
2330 | color.status.added |
2331 | color.status.changed | |
025a1929 | 2332 | color.status.header |
93fdf301 | 2333 | color.status.localBranch |
98171a07 | 2334 | color.status.nobranch |
93fdf301 | 2335 | color.status.remoteBranch |
0d6accc0 | 2336 | color.status.unmerged |
78d4d6a2 | 2337 | color.status.untracked |
98171a07 LM |
2338 | color.status.updated |
2339 | color.ui | |
9ee4aa95 RF |
2340 | commit.cleanup |
2341 | commit.gpgSign | |
6068ac88 | 2342 | commit.status |
98171a07 | 2343 | commit.template |
9ee4aa95 | 2344 | commit.verbose |
cdb791f6 | 2345 | core.abbrev |
6068ac88 MZ |
2346 | core.askpass |
2347 | core.attributesfile | |
98171a07 LM |
2348 | core.autocrlf |
2349 | core.bare | |
6068ac88 | 2350 | core.bigFileThreshold |
f254eab2 RF |
2351 | core.checkStat |
2352 | core.commentChar | |
025a1929 | 2353 | core.compression |
226b343c | 2354 | core.createObject |
98171a07 LM |
2355 | core.deltaBaseCacheLimit |
2356 | core.editor | |
6068ac88 | 2357 | core.eol |
98171a07 | 2358 | core.excludesfile |
025a1929 | 2359 | core.fileMode |
98171a07 | 2360 | core.fsyncobjectfiles |
025a1929 | 2361 | core.gitProxy |
f254eab2 RF |
2362 | core.hideDotFiles |
2363 | core.hooksPath | |
025a1929 | 2364 | core.ignoreStat |
6068ac88 | 2365 | core.ignorecase |
025a1929 LM |
2366 | core.logAllRefUpdates |
2367 | core.loosecompression | |
6068ac88 | 2368 | core.notesRef |
025a1929 LM |
2369 | core.packedGitLimit |
2370 | core.packedGitWindowSize | |
f254eab2 | 2371 | core.packedRefsTimeout |
98171a07 | 2372 | core.pager |
f254eab2 | 2373 | core.precomposeUnicode |
025a1929 | 2374 | core.preferSymlinkRefs |
98171a07 | 2375 | core.preloadindex |
f254eab2 RF |
2376 | core.protectHFS |
2377 | core.protectNTFS | |
98171a07 | 2378 | core.quotepath |
025a1929 | 2379 | core.repositoryFormatVersion |
98171a07 | 2380 | core.safecrlf |
025a1929 | 2381 | core.sharedRepository |
6068ac88 | 2382 | core.sparseCheckout |
f254eab2 RF |
2383 | core.splitIndex |
2384 | core.sshCommand | |
98171a07 LM |
2385 | core.symlinks |
2386 | core.trustctime | |
435ec090 | 2387 | core.untrackedCache |
025a1929 | 2388 | core.warnAmbiguousRefs |
98171a07 LM |
2389 | core.whitespace |
2390 | core.worktree | |
6ecef737 RF |
2391 | credential.helper |
2392 | credential.useHttpPath | |
2393 | credential.username | |
d78d237b | 2394 | credentialCache.ignoreSIGHUP |
98171a07 LM |
2395 | diff.autorefreshindex |
2396 | diff.external | |
6068ac88 | 2397 | diff.ignoreSubmodules |
98171a07 | 2398 | diff.mnemonicprefix |
6068ac88 | 2399 | diff.noprefix |
78d4d6a2 SP |
2400 | diff.renameLimit |
2401 | diff.renames | |
de7c201a | 2402 | diff.statGraphWidth |
2651baae | 2403 | diff.submodule |
226b343c SB |
2404 | diff.suppressBlankEmpty |
2405 | diff.tool | |
2406 | diff.wordRegex | |
07ab4dec | 2407 | diff.algorithm |
0aa62fd0 | 2408 | difftool. |
226b343c | 2409 | difftool.prompt |
6068ac88 | 2410 | fetch.recurseSubmodules |
78d4d6a2 | 2411 | fetch.unpackLimit |
226b343c SB |
2412 | format.attach |
2413 | format.cc | |
de06c13a | 2414 | format.coverLetter |
6bc6b6c0 | 2415 | format.from |
78d4d6a2 | 2416 | format.headers |
98171a07 LM |
2417 | format.numbered |
2418 | format.pretty | |
d8e1e5df | 2419 | format.signature |
226b343c SB |
2420 | format.signoff |
2421 | format.subjectprefix | |
98171a07 | 2422 | format.suffix |
226b343c | 2423 | format.thread |
6068ac88 MZ |
2424 | format.to |
2425 | gc. | |
19428042 | 2426 | gc.aggressiveDepth |
98171a07 LM |
2427 | gc.aggressiveWindow |
2428 | gc.auto | |
19428042 | 2429 | gc.autoDetach |
98171a07 | 2430 | gc.autopacklimit |
19428042 | 2431 | gc.logExpiry |
12977705 | 2432 | gc.packrefs |
98171a07 | 2433 | gc.pruneexpire |
78d4d6a2 SP |
2434 | gc.reflogexpire |
2435 | gc.reflogexpireunreachable | |
2436 | gc.rerereresolved | |
2437 | gc.rerereunresolved | |
19428042 | 2438 | gc.worktreePruneExpire |
025a1929 | 2439 | gitcvs.allbinary |
226b343c | 2440 | gitcvs.commitmsgannotation |
98171a07 | 2441 | gitcvs.dbTableNamePrefix |
025a1929 LM |
2442 | gitcvs.dbdriver |
2443 | gitcvs.dbname | |
2444 | gitcvs.dbpass | |
025a1929 LM |
2445 | gitcvs.dbuser |
2446 | gitcvs.enabled | |
2447 | gitcvs.logfile | |
98171a07 | 2448 | gitcvs.usecrlfattr |
0aa62fd0 | 2449 | guitool. |
98171a07 LM |
2450 | gui.blamehistoryctx |
2451 | gui.commitmsgwidth | |
2452 | gui.copyblamethreshold | |
2453 | gui.diffcontext | |
2454 | gui.encoding | |
2455 | gui.fastcopyblame | |
2456 | gui.matchtrackingbranch | |
2457 | gui.newbranchtemplate | |
2458 | gui.pruneduringfetch | |
2459 | gui.spellingdictionary | |
2460 | gui.trustmtime | |
2461 | help.autocorrect | |
2462 | help.browser | |
2463 | help.format | |
78d4d6a2 SP |
2464 | http.lowSpeedLimit |
2465 | http.lowSpeedTime | |
025a1929 | 2466 | http.maxRequests |
6068ac88 | 2467 | http.minSessions |
5de40f59 | 2468 | http.noEPSV |
6068ac88 | 2469 | http.postBuffer |
98171a07 | 2470 | http.proxy |
f6f2a9e4 | 2471 | http.sslCipherList |
01861cb7 | 2472 | http.sslVersion |
025a1929 LM |
2473 | http.sslCAInfo |
2474 | http.sslCAPath | |
2475 | http.sslCert | |
6068ac88 | 2476 | http.sslCertPasswordProtected |
025a1929 LM |
2477 | http.sslKey |
2478 | http.sslVerify | |
6068ac88 | 2479 | http.useragent |
78d4d6a2 SP |
2480 | i18n.commitEncoding |
2481 | i18n.logOutputEncoding | |
6068ac88 | 2482 | imap.authMethod |
226b343c SB |
2483 | imap.folder |
2484 | imap.host | |
2485 | imap.pass | |
2486 | imap.port | |
2487 | imap.preformattedHTML | |
2488 | imap.sslverify | |
2489 | imap.tunnel | |
2490 | imap.user | |
6068ac88 | 2491 | init.templatedir |
98171a07 LM |
2492 | instaweb.browser |
2493 | instaweb.httpd | |
2494 | instaweb.local | |
2495 | instaweb.modulepath | |
2496 | instaweb.port | |
226b343c | 2497 | interactive.singlekey |
98171a07 | 2498 | log.date |
6068ac88 | 2499 | log.decorate |
78d4d6a2 | 2500 | log.showroot |
226b343c | 2501 | mailmap.file |
0aa62fd0 | 2502 | man. |
98171a07 | 2503 | man.viewer |
6068ac88 | 2504 | merge. |
98171a07 LM |
2505 | merge.conflictstyle |
2506 | merge.log | |
2507 | merge.renameLimit | |
6068ac88 | 2508 | merge.renormalize |
98171a07 | 2509 | merge.stat |
025a1929 | 2510 | merge.tool |
78d4d6a2 | 2511 | merge.verbosity |
0aa62fd0 | 2512 | mergetool. |
98171a07 | 2513 | mergetool.keepBackup |
6068ac88 | 2514 | mergetool.keepTemporaries |
226b343c | 2515 | mergetool.prompt |
6068ac88 MZ |
2516 | notes.displayRef |
2517 | notes.rewrite. | |
2518 | notes.rewrite.amend | |
2519 | notes.rewrite.rebase | |
2520 | notes.rewriteMode | |
2521 | notes.rewriteRef | |
47e98eec | 2522 | pack.compression |
47e98eec | 2523 | pack.deltaCacheLimit |
025a1929 LM |
2524 | pack.deltaCacheSize |
2525 | pack.depth | |
98171a07 LM |
2526 | pack.indexVersion |
2527 | pack.packSizeLimit | |
2528 | pack.threads | |
025a1929 LM |
2529 | pack.window |
2530 | pack.windowMemory | |
0aa62fd0 | 2531 | pager. |
6068ac88 | 2532 | pretty. |
78d4d6a2 SP |
2533 | pull.octopus |
2534 | pull.twohead | |
226b343c | 2535 | push.default |
a8bc269f | 2536 | push.followTags |
6068ac88 | 2537 | rebase.autosquash |
226b343c | 2538 | rebase.stat |
6068ac88 | 2539 | receive.autogc |
98171a07 | 2540 | receive.denyCurrentBranch |
6068ac88 | 2541 | receive.denyDeleteCurrent |
98171a07 | 2542 | receive.denyDeletes |
025a1929 | 2543 | receive.denyNonFastForwards |
98171a07 | 2544 | receive.fsckObjects |
025a1929 | 2545 | receive.unpackLimit |
6068ac88 | 2546 | receive.updateserverinfo |
7e6a0cc4 | 2547 | remote.pushdefault |
6068ac88 | 2548 | remotes. |
98171a07 LM |
2549 | repack.usedeltabaseoffset |
2550 | rerere.autoupdate | |
2551 | rerere.enabled | |
6068ac88 | 2552 | sendemail. |
226b343c | 2553 | sendemail.aliasesfile |
6068ac88 | 2554 | sendemail.aliasfiletype |
226b343c SB |
2555 | sendemail.bcc |
2556 | sendemail.cc | |
2557 | sendemail.cccmd | |
2558 | sendemail.chainreplyto | |
2559 | sendemail.confirm | |
2560 | sendemail.envelopesender | |
6068ac88 MZ |
2561 | sendemail.from |
2562 | sendemail.identity | |
226b343c SB |
2563 | sendemail.multiedit |
2564 | sendemail.signedoffbycc | |
6068ac88 | 2565 | sendemail.smtpdomain |
226b343c SB |
2566 | sendemail.smtpencryption |
2567 | sendemail.smtppass | |
2568 | sendemail.smtpserver | |
6068ac88 | 2569 | sendemail.smtpserveroption |
226b343c SB |
2570 | sendemail.smtpserverport |
2571 | sendemail.smtpuser | |
2572 | sendemail.suppresscc | |
2573 | sendemail.suppressfrom | |
2574 | sendemail.thread | |
2575 | sendemail.to | |
5d3adff6 | 2576 | sendemail.tocmd |
226b343c | 2577 | sendemail.validate |
5453b83b | 2578 | sendemail.smtpbatchsize |
2579 | sendemail.smtprelogindelay | |
78d4d6a2 | 2580 | showbranch.default |
98171a07 LM |
2581 | status.relativePaths |
2582 | status.showUntrackedFiles | |
6068ac88 MZ |
2583 | status.submodulesummary |
2584 | submodule. | |
78d4d6a2 SP |
2585 | tar.umask |
2586 | transfer.unpackLimit | |
0aa62fd0 | 2587 | url. |
78d4d6a2 | 2588 | user.email |
025a1929 | 2589 | user.name |
78d4d6a2 | 2590 | user.signingkey |
98171a07 | 2591 | web.browser |
5de40f59 | 2592 | branch. remote. |
78d4d6a2 | 2593 | " |
5de40f59 SP |
2594 | } |
2595 | ||
88293c67 SP |
2596 | _git_remote () |
2597 | { | |
cac84960 CW |
2598 | local subcommands=" |
2599 | add rename remove set-head set-branches | |
2600 | get-url set-url show prune update | |
2601 | " | |
918c03c2 | 2602 | local subcommand="$(__git_find_on_cmdline "$subcommands")" |
3ff1320d | 2603 | if [ -z "$subcommand" ]; then |
cac84960 CW |
2604 | case "$cur" in |
2605 | --*) | |
ab6a11c5 | 2606 | __gitcomp_builtin remote |
cac84960 CW |
2607 | ;; |
2608 | *) | |
2609 | __gitcomp "$subcommands" | |
2610 | ;; | |
2611 | esac | |
88293c67 SP |
2612 | return |
2613 | fi | |
2614 | ||
cac84960 CW |
2615 | case "$subcommand,$cur" in |
2616 | add,--*) | |
ab6a11c5 | 2617 | __gitcomp_builtin remote_add "--no-tags" |
88293c67 | 2618 | ;; |
cac84960 CW |
2619 | add,*) |
2620 | ;; | |
2621 | set-head,--*) | |
ab6a11c5 | 2622 | __gitcomp_builtin remote_set-head |
cac84960 CW |
2623 | ;; |
2624 | set-branches,--*) | |
ab6a11c5 | 2625 | __gitcomp_builtin remote_set-branches |
88293c67 | 2626 | ;; |
cac84960 | 2627 | set-head,*|set-branches,*) |
f1c6ffe6 PJ |
2628 | __git_complete_remote_or_refspec |
2629 | ;; | |
cac84960 | 2630 | update,--*) |
ab6a11c5 | 2631 | __gitcomp_builtin remote_update |
cac84960 CW |
2632 | ;; |
2633 | update,*) | |
e8f9e428 | 2634 | __gitcomp "$(__git_get_config_variables "remotes")" |
fb72759b | 2635 | ;; |
cac84960 | 2636 | set-url,--*) |
ab6a11c5 | 2637 | __gitcomp_builtin remote_set-url |
cac84960 CW |
2638 | ;; |
2639 | get-url,--*) | |
ab6a11c5 | 2640 | __gitcomp_builtin remote_get-url |
cac84960 CW |
2641 | ;; |
2642 | prune,--*) | |
ab6a11c5 | 2643 | __gitcomp_builtin remote_prune |
cac84960 | 2644 | ;; |
88293c67 | 2645 | *) |
cac84960 | 2646 | __gitcomp_nl "$(__git_remotes)" |
88293c67 SP |
2647 | ;; |
2648 | esac | |
2649 | } | |
2650 | ||
e1c1a067 BG |
2651 | _git_replace () |
2652 | { | |
188fba11 CW |
2653 | case "$cur" in |
2654 | --*) | |
1b354755 | 2655 | __gitcomp_builtin replace |
188fba11 CW |
2656 | return |
2657 | ;; | |
2658 | esac | |
15b4a163 | 2659 | __git_complete_refs |
e1c1a067 BG |
2660 | } |
2661 | ||
e24a256b CW |
2662 | _git_rerere () |
2663 | { | |
2664 | local subcommands="clear forget diff remaining status gc" | |
2665 | local subcommand="$(__git_find_on_cmdline "$subcommands")" | |
2666 | if test -z "$subcommand" | |
2667 | then | |
2668 | __gitcomp "$subcommands" | |
2669 | return | |
2670 | fi | |
2671 | } | |
2672 | ||
67e78c3b SP |
2673 | _git_reset () |
2674 | { | |
d773c631 SG |
2675 | __git_has_doubledash && return |
2676 | ||
b3391775 SP |
2677 | case "$cur" in |
2678 | --*) | |
39073104 | 2679 | __gitcomp_builtin reset |
b3391775 SP |
2680 | return |
2681 | ;; | |
2682 | esac | |
15b4a163 | 2683 | __git_complete_refs |
67e78c3b SP |
2684 | } |
2685 | ||
e5f98518 NTND |
2686 | __git_revert_inprogress_options="--continue --quit --abort" |
2687 | ||
a6c2be24 LM |
2688 | _git_revert () |
2689 | { | |
fad9484f SG |
2690 | __git_find_repo_path |
2691 | if [ -f "$__git_repo_path"/REVERT_HEAD ]; then | |
e5f98518 | 2692 | __gitcomp "$__git_revert_inprogress_options" |
956352b6 TB |
2693 | return |
2694 | fi | |
a6c2be24 LM |
2695 | case "$cur" in |
2696 | --*) | |
e5f98518 NTND |
2697 | __gitcomp_builtin revert "--no-edit" \ |
2698 | "$__git_revert_inprogress_options" | |
a6c2be24 LM |
2699 | return |
2700 | ;; | |
2701 | esac | |
15b4a163 | 2702 | __git_complete_refs |
a6c2be24 LM |
2703 | } |
2704 | ||
08c701d4 LM |
2705 | _git_rm () |
2706 | { | |
08c701d4 LM |
2707 | case "$cur" in |
2708 | --*) | |
44c9a6d2 | 2709 | __gitcomp_builtin rm |
08c701d4 LM |
2710 | return |
2711 | ;; | |
2712 | esac | |
fea16b47 MP |
2713 | |
2714 | __git_complete_index_file "--cached" | |
08c701d4 LM |
2715 | } |
2716 | ||
1fd6bec9 SP |
2717 | _git_shortlog () |
2718 | { | |
d773c631 SG |
2719 | __git_has_doubledash && return |
2720 | ||
1fd6bec9 SP |
2721 | case "$cur" in |
2722 | --*) | |
2723 | __gitcomp " | |
a393777e TR |
2724 | $__git_log_common_options |
2725 | $__git_log_shortlog_options | |
f483a0aa | 2726 | --numbered --summary --email |
1fd6bec9 SP |
2727 | " |
2728 | return | |
2729 | ;; | |
2730 | esac | |
2731 | __git_complete_revlist | |
2732 | } | |
2733 | ||
90131924 SP |
2734 | _git_show () |
2735 | { | |
41d8cf7d MH |
2736 | __git_has_doubledash && return |
2737 | ||
90131924 | 2738 | case "$cur" in |
e67d71e5 | 2739 | --pretty=*|--format=*) |
c3898111 | 2740 | __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases) |
e67d71e5 | 2741 | " "" "${cur#*=}" |
72de29c2 TL |
2742 | return |
2743 | ;; | |
07924d4d MP |
2744 | --diff-algorithm=*) |
2745 | __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}" | |
2746 | return | |
2747 | ;; | |
ac76fd54 JK |
2748 | --submodule=*) |
2749 | __gitcomp "$__git_diff_submodule_formats" "" "${cur##--submodule=}" | |
2750 | return | |
2751 | ;; | |
90131924 | 2752 | --*) |
076c3237 | 2753 | __gitcomp "--pretty= --format= --abbrev-commit --oneline |
2ca0b197 | 2754 | --show-signature |
20bf7292 TR |
2755 | $__git_diff_common_options |
2756 | " | |
90131924 SP |
2757 | return |
2758 | ;; | |
2759 | esac | |
5269f7f8 | 2760 | __git_complete_revlist_file |
90131924 SP |
2761 | } |
2762 | ||
2ca880fe TR |
2763 | _git_show_branch () |
2764 | { | |
2ca880fe TR |
2765 | case "$cur" in |
2766 | --*) | |
09e271ad | 2767 | __gitcomp_builtin show-branch "--no-color" |
2ca880fe TR |
2768 | return |
2769 | ;; | |
2770 | esac | |
2771 | __git_complete_revlist | |
2772 | } | |
2773 | ||
7fd53fce JH |
2774 | _git_stash () |
2775 | { | |
d7d4ca87 | 2776 | local save_opts='--all --keep-index --no-keep-index --quiet --patch --include-untracked' |
3851e448 | 2777 | local subcommands='push save list show apply clear drop pop create branch' |
918c03c2 | 2778 | local subcommand="$(__git_find_on_cmdline "$subcommands")" |
7bedebca | 2779 | if [ -z "$subcommand" ]; then |
59d5eeee SG |
2780 | case "$cur" in |
2781 | --*) | |
2782 | __gitcomp "$save_opts" | |
2783 | ;; | |
2784 | *) | |
2785 | if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then | |
2786 | __gitcomp "$subcommands" | |
59d5eeee SG |
2787 | fi |
2788 | ;; | |
2789 | esac | |
7bedebca | 2790 | else |
7bedebca | 2791 | case "$subcommand,$cur" in |
3851e448 TG |
2792 | push,--*) |
2793 | __gitcomp "$save_opts --message" | |
2794 | ;; | |
7bedebca | 2795 | save,--*) |
59d5eeee | 2796 | __gitcomp "$save_opts" |
7bedebca | 2797 | ;; |
8513c54b | 2798 | apply,--*|pop,--*) |
59d5eeee | 2799 | __gitcomp "--index --quiet" |
95d43780 | 2800 | ;; |
d7d4ca87 PW |
2801 | drop,--*) |
2802 | __gitcomp "--quiet" | |
95d43780 | 2803 | ;; |
d7d4ca87 PW |
2804 | show,--*|branch,--*) |
2805 | ;; | |
2806 | branch,*) | |
59305aee | 2807 | if [ $cword -eq 3 ]; then |
15b4a163 | 2808 | __git_complete_refs |
d7d4ca87 | 2809 | else |
1cd23e9e | 2810 | __gitcomp_nl "$(__git stash list \ |
d7d4ca87 PW |
2811 | | sed -n -e 's/:.*//p')" |
2812 | fi | |
2813 | ;; | |
2814 | show,*|apply,*|drop,*|pop,*) | |
1cd23e9e | 2815 | __gitcomp_nl "$(__git stash list \ |
95d43780 LM |
2816 | | sed -n -e 's/:.*//p')" |
2817 | ;; | |
7bedebca | 2818 | *) |
7bedebca SG |
2819 | ;; |
2820 | esac | |
3ff1320d | 2821 | fi |
7fd53fce JH |
2822 | } |
2823 | ||
be86f7a0 SP |
2824 | _git_submodule () |
2825 | { | |
d773c631 SG |
2826 | __git_has_doubledash && return |
2827 | ||
cf419828 | 2828 | local subcommands="add status init deinit update summary foreach sync" |
65d5a1e0 CW |
2829 | local subcommand="$(__git_find_on_cmdline "$subcommands")" |
2830 | if [ -z "$subcommand" ]; then | |
be86f7a0 SP |
2831 | case "$cur" in |
2832 | --*) | |
65d5a1e0 | 2833 | __gitcomp "--quiet" |
be86f7a0 SP |
2834 | ;; |
2835 | *) | |
3ff1320d | 2836 | __gitcomp "$subcommands" |
be86f7a0 SP |
2837 | ;; |
2838 | esac | |
2839 | return | |
2840 | fi | |
65d5a1e0 CW |
2841 | |
2842 | case "$subcommand,$cur" in | |
2843 | add,--*) | |
2844 | __gitcomp "--branch --force --name --reference --depth" | |
2845 | ;; | |
2846 | status,--*) | |
2847 | __gitcomp "--cached --recursive" | |
2848 | ;; | |
2849 | deinit,--*) | |
2850 | __gitcomp "--force --all" | |
2851 | ;; | |
2852 | update,--*) | |
2853 | __gitcomp " | |
2854 | --init --remote --no-fetch | |
2855 | --recommend-shallow --no-recommend-shallow | |
2856 | --force --rebase --merge --reference --depth --recursive --jobs | |
2857 | " | |
2858 | ;; | |
2859 | summary,--*) | |
2860 | __gitcomp "--cached --files --summary-limit" | |
2861 | ;; | |
2862 | foreach,--*|sync,--*) | |
2863 | __gitcomp "--recursive" | |
2864 | ;; | |
2865 | *) | |
2866 | ;; | |
2867 | esac | |
be86f7a0 SP |
2868 | } |
2869 | ||
47f6ee28 SG |
2870 | _git_svn () |
2871 | { | |
2872 | local subcommands=" | |
2873 | init fetch clone rebase dcommit log find-rev | |
2874 | set-tree commit-diff info create-ignore propget | |
4a5856cb | 2875 | proplist show-ignore show-externals branch tag blame |
c18d5d82 | 2876 | migrate mkdirs reset gc |
47f6ee28 | 2877 | " |
918c03c2 | 2878 | local subcommand="$(__git_find_on_cmdline "$subcommands")" |
47f6ee28 SG |
2879 | if [ -z "$subcommand" ]; then |
2880 | __gitcomp "$subcommands" | |
2881 | else | |
2882 | local remote_opts="--username= --config-dir= --no-auth-cache" | |
2883 | local fc_opts=" | |
2884 | --follow-parent --authors-file= --repack= | |
2885 | --no-metadata --use-svm-props --use-svnsync-props | |
2886 | --log-window-size= --no-checkout --quiet | |
4a5856cb | 2887 | --repack-flags --use-log-author --localtime |
2cbad176 | 2888 | --add-author-from |
a7b10230 | 2889 | --ignore-paths= --include-paths= $remote_opts |
47f6ee28 SG |
2890 | " |
2891 | local init_opts=" | |
2892 | --template= --shared= --trunk= --tags= | |
2893 | --branches= --stdlayout --minimize-url | |
2894 | --no-metadata --use-svm-props --use-svnsync-props | |
2cbad176 | 2895 | --rewrite-root= --prefix= $remote_opts |
47f6ee28 SG |
2896 | " |
2897 | local cmt_opts=" | |
2898 | --edit --rmdir --find-copies-harder --copy-similarity= | |
2899 | " | |
2900 | ||
47f6ee28 SG |
2901 | case "$subcommand,$cur" in |
2902 | fetch,--*) | |
2903 | __gitcomp "--revision= --fetch-all $fc_opts" | |
2904 | ;; | |
2905 | clone,--*) | |
2906 | __gitcomp "--revision= $fc_opts $init_opts" | |
2907 | ;; | |
2908 | init,--*) | |
2909 | __gitcomp "$init_opts" | |
2910 | ;; | |
2911 | dcommit,--*) | |
2912 | __gitcomp " | |
2913 | --merge --strategy= --verbose --dry-run | |
4a5856cb | 2914 | --fetch-all --no-rebase --commit-url |
7b151f49 | 2915 | --revision --interactive $cmt_opts $fc_opts |
47f6ee28 SG |
2916 | " |
2917 | ;; | |
2918 | set-tree,--*) | |
2919 | __gitcomp "--stdin $cmt_opts $fc_opts" | |
2920 | ;; | |
2921 | create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\ | |
c18d5d82 | 2922 | show-externals,--*|mkdirs,--*) |
47f6ee28 SG |
2923 | __gitcomp "--revision=" |
2924 | ;; | |
2925 | log,--*) | |
2926 | __gitcomp " | |
2927 | --limit= --revision= --verbose --incremental | |
2928 | --oneline --show-commit --non-recursive | |
4a5856cb | 2929 | --authors-file= --color |
47f6ee28 SG |
2930 | " |
2931 | ;; | |
2932 | rebase,--*) | |
2933 | __gitcomp " | |
2934 | --merge --verbose --strategy= --local | |
4a5856cb | 2935 | --fetch-all --dry-run $fc_opts |
47f6ee28 SG |
2936 | " |
2937 | ;; | |
2938 | commit-diff,--*) | |
2939 | __gitcomp "--message= --file= --revision= $cmt_opts" | |
2940 | ;; | |
2941 | info,--*) | |
2942 | __gitcomp "--url" | |
2943 | ;; | |
4a5856cb SG |
2944 | branch,--*) |
2945 | __gitcomp "--dry-run --message --tag" | |
2946 | ;; | |
2947 | tag,--*) | |
2948 | __gitcomp "--dry-run --message" | |
2949 | ;; | |
2950 | blame,--*) | |
2951 | __gitcomp "--git-format" | |
2952 | ;; | |
2953 | migrate,--*) | |
2954 | __gitcomp " | |
2955 | --config-dir= --ignore-paths= --minimize | |
2956 | --no-auth-cache --username= | |
2957 | " | |
2958 | ;; | |
c18d5d82 RZ |
2959 | reset,--*) |
2960 | __gitcomp "--revision= --parent" | |
2961 | ;; | |
47f6ee28 | 2962 | *) |
47f6ee28 SG |
2963 | ;; |
2964 | esac | |
2965 | fi | |
2966 | } | |
2967 | ||
88e21dc7 SP |
2968 | _git_tag () |
2969 | { | |
2970 | local i c=1 f=0 | |
da48616f PD |
2971 | while [ $c -lt $cword ]; do |
2972 | i="${words[c]}" | |
88e21dc7 | 2973 | case "$i" in |
1775e990 | 2974 | -d|--delete|-v|--verify) |
227307a6 | 2975 | __gitcomp_direct "$(__git_tags "" "$cur" " ")" |
88e21dc7 SP |
2976 | return |
2977 | ;; | |
2978 | -f) | |
2979 | f=1 | |
2980 | ;; | |
2981 | esac | |
6e8c755f | 2982 | ((c++)) |
88e21dc7 SP |
2983 | done |
2984 | ||
da48616f | 2985 | case "$prev" in |
88e21dc7 | 2986 | -m|-F) |
88e21dc7 | 2987 | ;; |
8d8163f3 | 2988 | -*|tag) |
88e21dc7 | 2989 | if [ $f = 1 ]; then |
227307a6 | 2990 | __gitcomp_direct "$(__git_tags "" "$cur" " ")" |
88e21dc7 SP |
2991 | fi |
2992 | ;; | |
2993 | *) | |
15b4a163 | 2994 | __git_complete_refs |
88e21dc7 SP |
2995 | ;; |
2996 | esac | |
85ed2f32 RT |
2997 | |
2998 | case "$cur" in | |
2999 | --*) | |
80eb5197 | 3000 | __gitcomp_builtin tag |
85ed2f32 RT |
3001 | ;; |
3002 | esac | |
88e21dc7 SP |
3003 | } |
3004 | ||
424cce83 SG |
3005 | _git_whatchanged () |
3006 | { | |
3007 | _git_log | |
3008 | } | |
3009 | ||
b462c024 NTND |
3010 | _git_worktree () |
3011 | { | |
cc73385c | 3012 | local subcommands="add list lock move prune remove unlock" |
b462c024 NTND |
3013 | local subcommand="$(__git_find_on_cmdline "$subcommands")" |
3014 | if [ -z "$subcommand" ]; then | |
3015 | __gitcomp "$subcommands" | |
3016 | else | |
3017 | case "$subcommand,$cur" in | |
3018 | add,--*) | |
fc3d4e0c | 3019 | __gitcomp_builtin worktree_add |
b462c024 NTND |
3020 | ;; |
3021 | list,--*) | |
fc3d4e0c | 3022 | __gitcomp_builtin worktree_list |
b462c024 | 3023 | ;; |
58142c09 | 3024 | lock,--*) |
fc3d4e0c | 3025 | __gitcomp_builtin worktree_lock |
58142c09 | 3026 | ;; |
b462c024 | 3027 | prune,--*) |
fc3d4e0c | 3028 | __gitcomp_builtin worktree_prune |
b462c024 | 3029 | ;; |
cc73385c NTND |
3030 | remove,--*) |
3031 | __gitcomp "--force" | |
3032 | ;; | |
b462c024 NTND |
3033 | *) |
3034 | ;; | |
3035 | esac | |
3036 | fi | |
3037 | } | |
3038 | ||
93b291e0 | 3039 | __git_main () |
690d8824 | 3040 | { |
beb6ee71 | 3041 | local i c=1 command __git_dir __git_repo_path |
80ac0744 | 3042 | local __git_C_args C_args_count=0 |
873537fa | 3043 | |
da48616f PD |
3044 | while [ $c -lt $cword ]; do |
3045 | i="${words[c]}" | |
873537fa SP |
3046 | case "$i" in |
3047 | --git-dir=*) __git_dir="${i#--git-dir=}" ;; | |
776009d1 | 3048 | --git-dir) ((c++)) ; __git_dir="${words[c]}" ;; |
873537fa | 3049 | --bare) __git_dir="." ;; |
1eb7e2f8 | 3050 | --help) command="help"; break ;; |
776009d1 | 3051 | -c|--work-tree|--namespace) ((c++)) ;; |
80ac0744 SG |
3052 | -C) __git_C_args[C_args_count++]=-C |
3053 | ((c++)) | |
3054 | __git_C_args[C_args_count++]="${words[c]}" | |
3055 | ;; | |
911d5da6 | 3056 | -*) ;; |
873537fa SP |
3057 | *) command="$i"; break ;; |
3058 | esac | |
6e8c755f | 3059 | ((c++)) |
873537fa SP |
3060 | done |
3061 | ||
1d17b22e | 3062 | if [ -z "$command" ]; then |
7b329b9d SG |
3063 | case "$prev" in |
3064 | --git-dir|-C|--work-tree) | |
3065 | # these need a path argument, let's fall back to | |
3066 | # Bash filename completion | |
3067 | return | |
3068 | ;; | |
3069 | -c|--namespace) | |
3070 | # we don't support completing these options' arguments | |
3071 | return | |
3072 | ;; | |
3073 | esac | |
da48616f | 3074 | case "$cur" in |
47e98eec | 3075 | --*) __gitcomp " |
ce5a2c95 | 3076 | --paginate |
47e98eec SP |
3077 | --no-pager |
3078 | --git-dir= | |
3079 | --bare | |
3080 | --version | |
3081 | --exec-path | |
3ffcd086 | 3082 | --exec-path= |
89a56bfb | 3083 | --html-path |
66fb37d0 | 3084 | --man-path |
69ef3c02 | 3085 | --info-path |
ce5a2c95 | 3086 | --work-tree= |
a1bea2c1 | 3087 | --namespace= |
69ef3c02 | 3088 | --no-replace-objects |
ce5a2c95 | 3089 | --help |
47e98eec SP |
3090 | " |
3091 | ;; | |
eaa4e6ee JN |
3092 | *) __git_compute_porcelain_commands |
3093 | __gitcomp "$__git_porcelain_commands $(__git_aliases)" ;; | |
72e5e989 SP |
3094 | esac |
3095 | return | |
873537fa | 3096 | fi |
367dce2a | 3097 | |
424cce83 | 3098 | local completion_func="_git_${command//-/_}" |
336d694c | 3099 | declare -f $completion_func >/dev/null 2>/dev/null && $completion_func && return |
8024ea60 | 3100 | |
873537fa | 3101 | local expansion=$(__git_aliased_command "$command") |
8024ea60 | 3102 | if [ -n "$expansion" ]; then |
880111c1 | 3103 | words[1]=$expansion |
8024ea60 | 3104 | completion_func="_git_${expansion//-/_}" |
336d694c | 3105 | declare -f $completion_func >/dev/null 2>/dev/null && $completion_func |
8024ea60 | 3106 | fi |
690d8824 JH |
3107 | } |
3108 | ||
93b291e0 | 3109 | __gitk_main () |
690d8824 | 3110 | { |
d773c631 SG |
3111 | __git_has_doubledash && return |
3112 | ||
beb6ee71 | 3113 | local __git_repo_path |
fad9484f SG |
3114 | __git_find_repo_path |
3115 | ||
07ba53f7 | 3116 | local merge="" |
fad9484f | 3117 | if [ -f "$__git_repo_path/MERGE_HEAD" ]; then |
07ba53f7 RQ |
3118 | merge="--merge" |
3119 | fi | |
b3391775 SP |
3120 | case "$cur" in |
3121 | --*) | |
a393777e TR |
3122 | __gitcomp " |
3123 | $__git_log_common_options | |
3124 | $__git_log_gitk_options | |
3125 | $merge | |
3126 | " | |
b3391775 SP |
3127 | return |
3128 | ;; | |
3129 | esac | |
ec804891 | 3130 | __git_complete_revlist |
690d8824 JH |
3131 | } |
3132 | ||
d8b45314 FC |
3133 | if [[ -n ${ZSH_VERSION-} ]]; then |
3134 | echo "WARNING: this script is deprecated, please see git-completion.zsh" 1>&2 | |
6b179adf | 3135 | |
9cd67bd2 FC |
3136 | autoload -U +X compinit && compinit |
3137 | ||
d8b45314 FC |
3138 | __gitcomp () |
3139 | { | |
3140 | emulate -L zsh | |
6b179adf | 3141 | |
d8b45314 FC |
3142 | local cur_="${3-$cur}" |
3143 | ||
3144 | case "$cur_" in | |
3145 | --*=) | |
3146 | ;; | |
3147 | *) | |
3148 | local c IFS=$' \t\n' | |
3149 | local -a array | |
3150 | for c in ${=1}; do | |
3151 | c="$c${4-}" | |
3152 | case $c in | |
3153 | --*=*|*.) ;; | |
3154 | *) c="$c " ;; | |
3155 | esac | |
5d5812f4 | 3156 | array[${#array[@]}+1]="$c" |
d8b45314 FC |
3157 | done |
3158 | compset -P '*[=:]' | |
3159 | compadd -Q -S '' -p "${2-}" -a -- array && _ret=0 | |
3160 | ;; | |
3161 | esac | |
3162 | } | |
3163 | ||
fef56eb0 SG |
3164 | __gitcomp_direct () |
3165 | { | |
3166 | emulate -L zsh | |
3167 | ||
3168 | local IFS=$'\n' | |
3169 | compset -P '*[=:]' | |
3170 | compadd -Q -- ${=1} && _ret=0 | |
3171 | } | |
3172 | ||
d8b45314 FC |
3173 | __gitcomp_nl () |
3174 | { | |
3175 | emulate -L zsh | |
3176 | ||
3177 | local IFS=$'\n' | |
3178 | compset -P '*[=:]' | |
3179 | compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0 | |
3180 | } | |
3181 | ||
fea16b47 MP |
3182 | __gitcomp_file () |
3183 | { | |
3184 | emulate -L zsh | |
3185 | ||
3186 | local IFS=$'\n' | |
3187 | compset -P '*[=:]' | |
3188 | compadd -Q -p "${2-}" -f -- ${=1} && _ret=0 | |
3189 | } | |
3190 | ||
d8b45314 FC |
3191 | _git () |
3192 | { | |
2bcf694b FC |
3193 | local _ret=1 cur cword prev |
3194 | cur=${words[CURRENT]} | |
3195 | prev=${words[CURRENT-1]} | |
3196 | let cword=CURRENT-1 | |
3197 | emulate ksh -c __${service}_main | |
734b2f05 | 3198 | let _ret && _default && _ret=0 |
d8b45314 FC |
3199 | return _ret |
3200 | } | |
3201 | ||
3202 | compdef _git git gitk | |
3203 | return | |
3204 | fi | |
3205 | ||
3206 | __git_func_wrap () | |
3207 | { | |
6b179adf FC |
3208 | local cur words cword prev |
3209 | _get_comp_words_by_ref -n =: cur words cword prev | |
3210 | $1 | |
3211 | } | |
3212 | ||
3213 | # Setup completion for certain functions defined above by setting common | |
3214 | # variables and workarounds. | |
3215 | # This is NOT a public function; use at your own risk. | |
3216 | __git_complete () | |
3217 | { | |
3218 | local wrapper="__git_wrap${2}" | |
3219 | eval "$wrapper () { __git_func_wrap $2 ; }" | |
3220 | complete -o bashdefault -o default -o nospace -F $wrapper $1 2>/dev/null \ | |
3221 | || complete -o default -o nospace -F $wrapper $1 | |
3222 | } | |
3223 | ||
b0a4b2d2 FC |
3224 | # wrapper for backwards compatibility |
3225 | _git () | |
3226 | { | |
93b291e0 | 3227 | __git_wrap__git_main |
b0a4b2d2 FC |
3228 | } |
3229 | ||
3230 | # wrapper for backwards compatibility | |
3231 | _gitk () | |
3232 | { | |
93b291e0 | 3233 | __git_wrap__gitk_main |
b0a4b2d2 FC |
3234 | } |
3235 | ||
93b291e0 SG |
3236 | __git_complete git __git_main |
3237 | __git_complete gitk __gitk_main | |
690d8824 JH |
3238 | |
3239 | # The following are necessary only for Cygwin, and only are needed | |
3240 | # when the user has tab-completed the executable name and consequently | |
3241 | # included the '.exe' suffix. | |
3242 | # | |
76c3eb51 | 3243 | if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then |
93b291e0 | 3244 | __git_complete git.exe __git_main |
76c3eb51 | 3245 | fi |