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