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