]>
Commit | Line | Data |
---|---|---|
690d8824 JH |
1 | # |
2 | # bash completion support for core Git. | |
3 | # | |
c70680ce | 4 | # Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org> |
690d8824 | 5 | # Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/). |
c70680ce | 6 | # Distributed under the GNU General Public License, version 2.0. |
690d8824 JH |
7 | # |
8 | # The contained completion routines provide support for completing: | |
9 | # | |
10 | # *) local and remote branch names | |
11 | # *) local and remote tag names | |
12 | # *) .git/remotes file names | |
13 | # *) git 'subcommands' | |
14 | # *) tree paths within 'ref:path/to/file' expressions | |
c70680ce | 15 | # *) common --long-options |
690d8824 JH |
16 | # |
17 | # To use these routines: | |
18 | # | |
19 | # 1) Copy this file to somewhere (e.g. ~/.git-completion.sh). | |
20 | # 2) Added the following line to your .bashrc: | |
21 | # source ~/.git-completion.sh | |
22 | # | |
b51ec6bd SP |
23 | # 3) You may want to make sure the git executable is available |
24 | # in your PATH before this script is sourced, as some caching | |
25 | # is performed while the script loads. If git isn't found | |
26 | # at source time then all lookups will be done on demand, | |
27 | # which may be slightly slower. | |
28 | # | |
29 | # 4) Consider changing your PS1 to also show the current branch: | |
d3d717a4 SP |
30 | # PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ ' |
31 | # | |
32 | # The argument to __git_ps1 will be displayed only if you | |
33 | # are currently in a git repository. The %s token will be | |
34 | # the name of the current branch. | |
35 | # | |
c70680ce SP |
36 | # To submit patches: |
37 | # | |
38 | # *) Read Documentation/SubmittingPatches | |
39 | # *) Send all patches to the current maintainer: | |
40 | # | |
41 | # "Shawn O. Pearce" <spearce@spearce.org> | |
42 | # | |
43 | # *) Always CC the Git mailing list: | |
44 | # | |
45 | # git@vger.kernel.org | |
46 | # | |
690d8824 | 47 | |
873537fa SP |
48 | __gitdir () |
49 | { | |
67ffa114 SP |
50 | if [ -z "$1" ]; then |
51 | if [ -n "$__git_dir" ]; then | |
52 | echo "$__git_dir" | |
53 | elif [ -d .git ]; then | |
54 | echo .git | |
55 | else | |
56 | git rev-parse --git-dir 2>/dev/null | |
57 | fi | |
58 | elif [ -d "$1/.git" ]; then | |
59 | echo "$1/.git" | |
60 | else | |
61 | echo "$1" | |
62 | fi | |
873537fa SP |
63 | } |
64 | ||
d3d717a4 SP |
65 | __git_ps1 () |
66 | { | |
e7520196 RR |
67 | local g="$(git rev-parse --git-dir 2>/dev/null)" |
68 | if [ -n "$g" ]; then | |
69 | local r | |
70 | local b | |
71 | if [ -d "$g/../.dotest" ] | |
72 | then | |
3041c324 JH |
73 | if test -f "$g/../.dotest/rebasing" |
74 | then | |
75 | r="|REBASE" | |
76 | elif test -f "$g/../.dotest/applying" | |
77 | then | |
78 | r="|AM" | |
79 | else | |
80 | r="|AM/REBASE" | |
81 | fi | |
e7520196 RR |
82 | b="$(git symbolic-ref HEAD 2>/dev/null)" |
83 | elif [ -f "$g/.dotest-merge/interactive" ] | |
84 | then | |
85 | r="|REBASE-i" | |
a5c4f85b | 86 | b="$(cat "$g/.dotest-merge/head-name")" |
e7520196 RR |
87 | elif [ -d "$g/.dotest-merge" ] |
88 | then | |
89 | r="|REBASE-m" | |
a5c4f85b | 90 | b="$(cat "$g/.dotest-merge/head-name")" |
e7520196 RR |
91 | elif [ -f "$g/MERGE_HEAD" ] |
92 | then | |
93 | r="|MERGING" | |
94 | b="$(git symbolic-ref HEAD 2>/dev/null)" | |
95 | else | |
a5c4f85b | 96 | if [ -f "$g/BISECT_LOG" ] |
e7520196 RR |
97 | then |
98 | r="|BISECTING" | |
99 | fi | |
100 | if ! b="$(git symbolic-ref HEAD 2>/dev/null)" | |
101 | then | |
27c57888 SP |
102 | if ! b="$(git describe --exact-match HEAD 2>/dev/null)" |
103 | then | |
a5c4f85b | 104 | b="$(cut -c1-7 "$g/HEAD")..." |
27c57888 | 105 | fi |
e7520196 RR |
106 | fi |
107 | fi | |
108 | ||
d3d717a4 | 109 | if [ -n "$1" ]; then |
e7520196 | 110 | printf "$1" "${b##refs/heads/}$r" |
d3d717a4 | 111 | else |
e7520196 | 112 | printf " (%s)" "${b##refs/heads/}$r" |
d3d717a4 SP |
113 | fi |
114 | fi | |
115 | } | |
116 | ||
72e5e989 SP |
117 | __gitcomp () |
118 | { | |
119 | local all c s=$'\n' IFS=' '$'\t'$'\n' | |
78d4d6a2 | 120 | local cur="${COMP_WORDS[COMP_CWORD]}" |
b3391775 | 121 | if [ $# -gt 2 ]; then |
78d4d6a2 SP |
122 | cur="$3" |
123 | fi | |
72e5e989 | 124 | for c in $1; do |
78d4d6a2 SP |
125 | case "$c$4" in |
126 | --*=*) all="$all$c$4$s" ;; | |
127 | *.) all="$all$c$4$s" ;; | |
128 | *) all="$all$c$4 $s" ;; | |
72e5e989 SP |
129 | esac |
130 | done | |
131 | IFS=$s | |
78d4d6a2 | 132 | COMPREPLY=($(compgen -P "$2" -W "$all" -- "$cur")) |
72e5e989 SP |
133 | return |
134 | } | |
135 | ||
5de40f59 SP |
136 | __git_heads () |
137 | { | |
67ffa114 | 138 | local cmd i is_hash=y dir="$(__gitdir "$1")" |
5de40f59 SP |
139 | if [ -d "$dir" ]; then |
140 | for i in $(git --git-dir="$dir" \ | |
141 | for-each-ref --format='%(refname)' \ | |
142 | refs/heads ); do | |
143 | echo "${i#refs/heads/}" | |
144 | done | |
145 | return | |
146 | fi | |
67ffa114 | 147 | for i in $(git-ls-remote "$1" 2>/dev/null); do |
5de40f59 SP |
148 | case "$is_hash,$i" in |
149 | y,*) is_hash=n ;; | |
150 | n,*^{}) is_hash=y ;; | |
151 | n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;; | |
152 | n,*) is_hash=y; echo "$i" ;; | |
153 | esac | |
154 | done | |
155 | } | |
156 | ||
88e21dc7 SP |
157 | __git_tags () |
158 | { | |
159 | local cmd i is_hash=y dir="$(__gitdir "$1")" | |
160 | if [ -d "$dir" ]; then | |
161 | for i in $(git --git-dir="$dir" \ | |
162 | for-each-ref --format='%(refname)' \ | |
163 | refs/tags ); do | |
164 | echo "${i#refs/tags/}" | |
165 | done | |
166 | return | |
167 | fi | |
168 | for i in $(git-ls-remote "$1" 2>/dev/null); do | |
169 | case "$is_hash,$i" in | |
170 | y,*) is_hash=n ;; | |
171 | n,*^{}) is_hash=y ;; | |
172 | n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;; | |
173 | n,*) is_hash=y; echo "$i" ;; | |
174 | esac | |
175 | done | |
176 | } | |
177 | ||
690d8824 JH |
178 | __git_refs () |
179 | { | |
67ffa114 | 180 | local cmd i is_hash=y dir="$(__gitdir "$1")" |
873537fa | 181 | if [ -d "$dir" ]; then |
35e65ecc SP |
182 | if [ -e "$dir/HEAD" ]; then echo HEAD; fi |
183 | for i in $(git --git-dir="$dir" \ | |
184 | for-each-ref --format='%(refname)' \ | |
185 | refs/tags refs/heads refs/remotes); do | |
186 | case "$i" in | |
187 | refs/tags/*) echo "${i#refs/tags/}" ;; | |
188 | refs/heads/*) echo "${i#refs/heads/}" ;; | |
189 | refs/remotes/*) echo "${i#refs/remotes/}" ;; | |
190 | *) echo "$i" ;; | |
191 | esac | |
192 | done | |
193 | return | |
690d8824 | 194 | fi |
35e65ecc | 195 | for i in $(git-ls-remote "$dir" 2>/dev/null); do |
690d8824 JH |
196 | case "$is_hash,$i" in |
197 | y,*) is_hash=n ;; | |
198 | n,*^{}) is_hash=y ;; | |
199 | n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;; | |
200 | n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;; | |
35e65ecc | 201 | n,refs/remotes/*) is_hash=y; echo "${i#refs/remotes/}" ;; |
690d8824 JH |
202 | n,*) is_hash=y; echo "$i" ;; |
203 | esac | |
204 | done | |
205 | } | |
206 | ||
207 | __git_refs2 () | |
208 | { | |
67ffa114 SP |
209 | local i |
210 | for i in $(__git_refs "$1"); do | |
211 | echo "$i:$i" | |
690d8824 JH |
212 | done |
213 | } | |
214 | ||
5de40f59 SP |
215 | __git_refs_remotes () |
216 | { | |
217 | local cmd i is_hash=y | |
218 | for i in $(git-ls-remote "$1" 2>/dev/null); do | |
219 | case "$is_hash,$i" in | |
220 | n,refs/heads/*) | |
221 | is_hash=y | |
222 | echo "$i:refs/remotes/$1/${i#refs/heads/}" | |
223 | ;; | |
224 | y,*) is_hash=n ;; | |
225 | n,*^{}) is_hash=y ;; | |
226 | n,refs/tags/*) is_hash=y;; | |
227 | n,*) is_hash=y; ;; | |
228 | esac | |
229 | done | |
230 | } | |
231 | ||
690d8824 JH |
232 | __git_remotes () |
233 | { | |
873537fa | 234 | local i ngoff IFS=$'\n' d="$(__gitdir)" |
56fc25f2 | 235 | shopt -q nullglob || ngoff=1 |
690d8824 | 236 | shopt -s nullglob |
873537fa SP |
237 | for i in "$d/remotes"/*; do |
238 | echo ${i#$d/remotes/} | |
690d8824 | 239 | done |
56fc25f2 | 240 | [ "$ngoff" ] && shopt -u nullglob |
e0d10e1c | 241 | for i in $(git --git-dir="$d" config --list); do |
56fc25f2 SP |
242 | case "$i" in |
243 | remote.*.url=*) | |
244 | i="${i#remote.}" | |
245 | echo "${i/.url=*/}" | |
246 | ;; | |
247 | esac | |
248 | done | |
690d8824 JH |
249 | } |
250 | ||
4ad91321 SP |
251 | __git_merge_strategies () |
252 | { | |
b51ec6bd SP |
253 | if [ -n "$__git_merge_strategylist" ]; then |
254 | echo "$__git_merge_strategylist" | |
255 | return | |
256 | fi | |
4ad91321 SP |
257 | sed -n "/^all_strategies='/{ |
258 | s/^all_strategies='// | |
259 | s/'// | |
260 | p | |
261 | q | |
262 | }" "$(git --exec-path)/git-merge" | |
263 | } | |
b51ec6bd SP |
264 | __git_merge_strategylist= |
265 | __git_merge_strategylist="$(__git_merge_strategies 2>/dev/null)" | |
4ad91321 | 266 | |
690d8824 JH |
267 | __git_complete_file () |
268 | { | |
a79c6551 | 269 | local pfx ls ref cur="${COMP_WORDS[COMP_CWORD]}" |
690d8824 JH |
270 | case "$cur" in |
271 | ?*:*) | |
a79c6551 SP |
272 | ref="${cur%%:*}" |
273 | cur="${cur#*:}" | |
690d8824 JH |
274 | case "$cur" in |
275 | ?*/*) | |
a79c6551 SP |
276 | pfx="${cur%/*}" |
277 | cur="${cur##*/}" | |
690d8824 JH |
278 | ls="$ref:$pfx" |
279 | pfx="$pfx/" | |
280 | ;; | |
281 | *) | |
282 | ls="$ref" | |
283 | ;; | |
284 | esac | |
285 | COMPREPLY=($(compgen -P "$pfx" \ | |
873537fa | 286 | -W "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \ |
690d8824 JH |
287 | | sed '/^100... blob /s,^.* ,, |
288 | /^040000 tree /{ | |
289 | s,^.* ,, | |
290 | s,$,/, | |
291 | } | |
292 | s/^.* //')" \ | |
293 | -- "$cur")) | |
294 | ;; | |
295 | *) | |
b3391775 | 296 | __gitcomp "$(__git_refs)" |
690d8824 JH |
297 | ;; |
298 | esac | |
299 | } | |
300 | ||
f53352fb SP |
301 | __git_complete_revlist () |
302 | { | |
303 | local pfx cur="${COMP_WORDS[COMP_CWORD]}" | |
304 | case "$cur" in | |
305 | *...*) | |
306 | pfx="${cur%...*}..." | |
307 | cur="${cur#*...}" | |
b3391775 | 308 | __gitcomp "$(__git_refs)" "$pfx" "$cur" |
f53352fb SP |
309 | ;; |
310 | *..*) | |
311 | pfx="${cur%..*}.." | |
312 | cur="${cur#*..}" | |
b3391775 SP |
313 | __gitcomp "$(__git_refs)" "$pfx" "$cur" |
314 | ;; | |
315 | *.) | |
316 | __gitcomp "$cur." | |
f53352fb SP |
317 | ;; |
318 | *) | |
b3391775 | 319 | __gitcomp "$(__git_refs)" |
f53352fb SP |
320 | ;; |
321 | esac | |
322 | } | |
323 | ||
f2bb9f88 SP |
324 | __git_commands () |
325 | { | |
b51ec6bd SP |
326 | if [ -n "$__git_commandlist" ]; then |
327 | echo "$__git_commandlist" | |
328 | return | |
329 | fi | |
f2bb9f88 SP |
330 | local i IFS=" "$'\n' |
331 | for i in $(git help -a|egrep '^ ') | |
332 | do | |
333 | case $i in | |
718a087a | 334 | *--*) : helper pattern;; |
a925c6f1 SP |
335 | applymbox) : ask gittus;; |
336 | applypatch) : ask gittus;; | |
337 | archimport) : import;; | |
2e3a430a | 338 | cat-file) : plumbing;; |
56d99c67 | 339 | check-attr) : plumbing;; |
f2bb9f88 SP |
340 | check-ref-format) : plumbing;; |
341 | commit-tree) : plumbing;; | |
a925c6f1 SP |
342 | cvsexportcommit) : export;; |
343 | cvsimport) : import;; | |
f2bb9f88 SP |
344 | cvsserver) : daemon;; |
345 | daemon) : daemon;; | |
5cfb4fe5 SP |
346 | diff-files) : plumbing;; |
347 | diff-index) : plumbing;; | |
348 | diff-tree) : plumbing;; | |
c6ec3b13 | 349 | fast-import) : import;; |
a925c6f1 | 350 | fsck-objects) : plumbing;; |
f2bb9f88 | 351 | fetch-pack) : plumbing;; |
a925c6f1 | 352 | fmt-merge-msg) : plumbing;; |
56d99c67 | 353 | for-each-ref) : plumbing;; |
f2bb9f88 SP |
354 | hash-object) : plumbing;; |
355 | http-*) : transport;; | |
356 | index-pack) : plumbing;; | |
a925c6f1 | 357 | init-db) : deprecated;; |
f2bb9f88 SP |
358 | local-fetch) : plumbing;; |
359 | mailinfo) : plumbing;; | |
360 | mailsplit) : plumbing;; | |
361 | merge-*) : plumbing;; | |
362 | mktree) : plumbing;; | |
363 | mktag) : plumbing;; | |
364 | pack-objects) : plumbing;; | |
365 | pack-redundant) : plumbing;; | |
366 | pack-refs) : plumbing;; | |
367 | parse-remote) : plumbing;; | |
368 | patch-id) : plumbing;; | |
369 | peek-remote) : plumbing;; | |
a925c6f1 SP |
370 | prune) : plumbing;; |
371 | prune-packed) : plumbing;; | |
372 | quiltimport) : import;; | |
f2bb9f88 SP |
373 | read-tree) : plumbing;; |
374 | receive-pack) : plumbing;; | |
2e3a430a | 375 | reflog) : plumbing;; |
5c66d0d4 | 376 | repo-config) : deprecated;; |
f2bb9f88 SP |
377 | rerere) : plumbing;; |
378 | rev-list) : plumbing;; | |
379 | rev-parse) : plumbing;; | |
380 | runstatus) : plumbing;; | |
381 | sh-setup) : internal;; | |
382 | shell) : daemon;; | |
383 | send-pack) : plumbing;; | |
384 | show-index) : plumbing;; | |
385 | ssh-*) : transport;; | |
386 | stripspace) : plumbing;; | |
387 | symbolic-ref) : plumbing;; | |
a925c6f1 | 388 | tar-tree) : deprecated;; |
f2bb9f88 SP |
389 | unpack-file) : plumbing;; |
390 | unpack-objects) : plumbing;; | |
a925c6f1 | 391 | update-index) : plumbing;; |
f2bb9f88 SP |
392 | update-ref) : plumbing;; |
393 | update-server-info) : daemon;; | |
394 | upload-archive) : plumbing;; | |
395 | upload-pack) : plumbing;; | |
396 | write-tree) : plumbing;; | |
a925c6f1 | 397 | verify-tag) : plumbing;; |
f2bb9f88 SP |
398 | *) echo $i;; |
399 | esac | |
400 | done | |
401 | } | |
b51ec6bd SP |
402 | __git_commandlist= |
403 | __git_commandlist="$(__git_commands 2>/dev/null)" | |
f2bb9f88 | 404 | |
367dce2a DS |
405 | __git_aliases () |
406 | { | |
56fc25f2 | 407 | local i IFS=$'\n' |
e0d10e1c | 408 | for i in $(git --git-dir="$(__gitdir)" config --list); do |
56fc25f2 SP |
409 | case "$i" in |
410 | alias.*) | |
411 | i="${i#alias.}" | |
412 | echo "${i/=*/}" | |
413 | ;; | |
414 | esac | |
415 | done | |
367dce2a DS |
416 | } |
417 | ||
418 | __git_aliased_command () | |
419 | { | |
873537fa | 420 | local word cmdline=$(git --git-dir="$(__gitdir)" \ |
e0d10e1c | 421 | config --get "alias.$1") |
367dce2a DS |
422 | for word in $cmdline; do |
423 | if [ "${word##-*}" ]; then | |
424 | echo $word | |
425 | return | |
426 | fi | |
427 | done | |
428 | } | |
429 | ||
3ff1320d SG |
430 | __git_find_subcommand () |
431 | { | |
432 | local word subcommand c=1 | |
433 | ||
434 | while [ $c -lt $COMP_CWORD ]; do | |
435 | word="${COMP_WORDS[c]}" | |
436 | for subcommand in $1; do | |
437 | if [ "$subcommand" = "$word" ]; then | |
438 | echo "$subcommand" | |
439 | return | |
440 | fi | |
441 | done | |
442 | c=$((++c)) | |
443 | done | |
444 | } | |
445 | ||
88329195 SP |
446 | __git_whitespacelist="nowarn warn error error-all strip" |
447 | ||
448 | _git_am () | |
449 | { | |
450 | local cur="${COMP_WORDS[COMP_CWORD]}" | |
451 | if [ -d .dotest ]; then | |
b3391775 | 452 | __gitcomp "--skip --resolved" |
88329195 SP |
453 | return |
454 | fi | |
455 | case "$cur" in | |
456 | --whitespace=*) | |
b3391775 | 457 | __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}" |
88329195 SP |
458 | return |
459 | ;; | |
460 | --*) | |
b3391775 | 461 | __gitcomp " |
88329195 SP |
462 | --signoff --utf8 --binary --3way --interactive |
463 | --whitespace= | |
b3391775 | 464 | " |
88329195 SP |
465 | return |
466 | esac | |
467 | COMPREPLY=() | |
468 | } | |
469 | ||
470 | _git_apply () | |
471 | { | |
472 | local cur="${COMP_WORDS[COMP_CWORD]}" | |
473 | case "$cur" in | |
474 | --whitespace=*) | |
b3391775 | 475 | __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}" |
88329195 SP |
476 | return |
477 | ;; | |
478 | --*) | |
b3391775 | 479 | __gitcomp " |
88329195 SP |
480 | --stat --numstat --summary --check --index |
481 | --cached --index-info --reverse --reject --unidiff-zero | |
482 | --apply --no-add --exclude= | |
483 | --whitespace= --inaccurate-eof --verbose | |
b3391775 | 484 | " |
88329195 SP |
485 | return |
486 | esac | |
487 | COMPREPLY=() | |
488 | } | |
489 | ||
8435b548 SP |
490 | _git_add () |
491 | { | |
492 | local cur="${COMP_WORDS[COMP_CWORD]}" | |
493 | case "$cur" in | |
494 | --*) | |
47e98eec | 495 | __gitcomp "--interactive --refresh" |
8435b548 SP |
496 | return |
497 | esac | |
498 | COMPREPLY=() | |
499 | } | |
500 | ||
b2e69f62 SP |
501 | _git_bisect () |
502 | { | |
3ff1320d SG |
503 | local subcommands="start bad good reset visualize replay log" |
504 | local subcommand="$(__git_find_subcommand "$subcommands")" | |
505 | if [ -z "$subcommand" ]; then | |
506 | __gitcomp "$subcommands" | |
b2e69f62 SP |
507 | return |
508 | fi | |
509 | ||
3ff1320d | 510 | case "$subcommand" in |
b2e69f62 SP |
511 | bad|good|reset) |
512 | __gitcomp "$(__git_refs)" | |
513 | ;; | |
514 | *) | |
515 | COMPREPLY=() | |
516 | ;; | |
517 | esac | |
518 | } | |
519 | ||
690d8824 JH |
520 | _git_branch () |
521 | { | |
b9217642 SG |
522 | local i c=1 only_local_ref="n" has_r="n" |
523 | ||
524 | while [ $c -lt $COMP_CWORD ]; do | |
525 | i="${COMP_WORDS[c]}" | |
526 | case "$i" in | |
527 | -d|-m) only_local_ref="y" ;; | |
528 | -r) has_r="y" ;; | |
529 | esac | |
530 | c=$((++c)) | |
531 | done | |
532 | ||
3b376b0c SG |
533 | case "${COMP_WORDS[COMP_CWORD]}" in |
534 | --*=*) COMPREPLY=() ;; | |
535 | --*) | |
536 | __gitcomp " | |
537 | --color --no-color --verbose --abbrev= --no-abbrev | |
538 | --track --no-track | |
539 | " | |
540 | ;; | |
b9217642 SG |
541 | *) |
542 | if [ $only_local_ref = "y" -a $has_r = "n" ]; then | |
543 | __gitcomp "$(__git_heads)" | |
544 | else | |
545 | __gitcomp "$(__git_refs)" | |
546 | fi | |
547 | ;; | |
3b376b0c | 548 | esac |
690d8824 JH |
549 | } |
550 | ||
374a58c9 ML |
551 | _git_bundle () |
552 | { | |
553 | local mycword="$COMP_CWORD" | |
554 | case "${COMP_WORDS[0]}" in | |
555 | git) | |
556 | local cmd="${COMP_WORDS[2]}" | |
557 | mycword="$((mycword-1))" | |
558 | ;; | |
559 | git-bundle*) | |
560 | local cmd="${COMP_WORDS[1]}" | |
561 | ;; | |
562 | esac | |
563 | case "$mycword" in | |
564 | 1) | |
565 | __gitcomp "create list-heads verify unbundle" | |
566 | ;; | |
567 | 2) | |
568 | # looking for a file | |
569 | ;; | |
570 | *) | |
571 | case "$cmd" in | |
572 | create) | |
573 | __git_complete_revlist | |
574 | ;; | |
575 | esac | |
576 | ;; | |
577 | esac | |
578 | } | |
579 | ||
690d8824 JH |
580 | _git_checkout () |
581 | { | |
b3391775 | 582 | __gitcomp "$(__git_refs)" |
690d8824 JH |
583 | } |
584 | ||
d8a9fea5 SP |
585 | _git_cherry () |
586 | { | |
587 | __gitcomp "$(__git_refs)" | |
588 | } | |
589 | ||
1273231e SP |
590 | _git_cherry_pick () |
591 | { | |
592 | local cur="${COMP_WORDS[COMP_CWORD]}" | |
593 | case "$cur" in | |
594 | --*) | |
b3391775 | 595 | __gitcomp "--edit --no-commit" |
1273231e SP |
596 | ;; |
597 | *) | |
b3391775 | 598 | __gitcomp "$(__git_refs)" |
1273231e SP |
599 | ;; |
600 | esac | |
601 | } | |
602 | ||
4548e855 SP |
603 | _git_commit () |
604 | { | |
605 | local cur="${COMP_WORDS[COMP_CWORD]}" | |
606 | case "$cur" in | |
607 | --*) | |
b3391775 | 608 | __gitcomp " |
4548e855 SP |
609 | --all --author= --signoff --verify --no-verify |
610 | --edit --amend --include --only | |
b3391775 | 611 | " |
4548e855 SP |
612 | return |
613 | esac | |
614 | COMPREPLY=() | |
615 | } | |
616 | ||
217926c0 SP |
617 | _git_describe () |
618 | { | |
619 | __gitcomp "$(__git_refs)" | |
620 | } | |
621 | ||
690d8824 JH |
622 | _git_diff () |
623 | { | |
b3a4f858 JS |
624 | local cur="${COMP_WORDS[COMP_CWORD]}" |
625 | case "$cur" in | |
626 | --*) | |
627 | __gitcomp "--cached --stat --numstat --shortstat --summary | |
628 | --patch-with-stat --name-only --name-status --color | |
629 | --no-color --color-words --no-renames --check | |
630 | --full-index --binary --abbrev --diff-filter | |
631 | --find-copies-harder --pickaxe-all --pickaxe-regex | |
632 | --text --ignore-space-at-eol --ignore-space-change | |
633 | --ignore-all-space --exit-code --quiet --ext-diff | |
634 | --no-ext-diff" | |
635 | return | |
636 | ;; | |
637 | esac | |
690d8824 JH |
638 | __git_complete_file |
639 | } | |
640 | ||
641 | _git_diff_tree () | |
642 | { | |
b3391775 | 643 | __gitcomp "$(__git_refs)" |
690d8824 JH |
644 | } |
645 | ||
646 | _git_fetch () | |
647 | { | |
648 | local cur="${COMP_WORDS[COMP_CWORD]}" | |
649 | ||
650 | case "${COMP_WORDS[0]},$COMP_CWORD" in | |
651 | git-fetch*,1) | |
b3391775 | 652 | __gitcomp "$(__git_remotes)" |
690d8824 JH |
653 | ;; |
654 | git,2) | |
b3391775 | 655 | __gitcomp "$(__git_remotes)" |
690d8824 JH |
656 | ;; |
657 | *) | |
658 | case "$cur" in | |
659 | *:*) | |
b3391775 | 660 | __gitcomp "$(__git_refs)" "" "${cur#*:}" |
690d8824 JH |
661 | ;; |
662 | *) | |
663 | local remote | |
664 | case "${COMP_WORDS[0]}" in | |
665 | git-fetch) remote="${COMP_WORDS[1]}" ;; | |
666 | git) remote="${COMP_WORDS[2]}" ;; | |
667 | esac | |
b3391775 | 668 | __gitcomp "$(__git_refs2 "$remote")" |
690d8824 JH |
669 | ;; |
670 | esac | |
671 | ;; | |
672 | esac | |
673 | } | |
674 | ||
f53352fb SP |
675 | _git_format_patch () |
676 | { | |
677 | local cur="${COMP_WORDS[COMP_CWORD]}" | |
678 | case "$cur" in | |
679 | --*) | |
b3391775 | 680 | __gitcomp " |
f53352fb SP |
681 | --stdout --attach --thread |
682 | --output-directory | |
683 | --numbered --start-number | |
47e98eec | 684 | --numbered-files |
f53352fb SP |
685 | --keep-subject |
686 | --signoff | |
687 | --in-reply-to= | |
688 | --full-index --binary | |
ec804891 | 689 | --not --all |
be5f5bf0 | 690 | --cover-letter |
b3391775 | 691 | " |
f53352fb SP |
692 | return |
693 | ;; | |
694 | esac | |
695 | __git_complete_revlist | |
696 | } | |
697 | ||
b26c8748 SP |
698 | _git_gc () |
699 | { | |
700 | local cur="${COMP_WORDS[COMP_CWORD]}" | |
701 | case "$cur" in | |
702 | --*) | |
47e98eec | 703 | __gitcomp "--prune --aggressive" |
b26c8748 SP |
704 | return |
705 | ;; | |
706 | esac | |
707 | COMPREPLY=() | |
708 | } | |
709 | ||
690d8824 JH |
710 | _git_ls_remote () |
711 | { | |
b3391775 | 712 | __gitcomp "$(__git_remotes)" |
690d8824 JH |
713 | } |
714 | ||
715 | _git_ls_tree () | |
716 | { | |
717 | __git_complete_file | |
718 | } | |
719 | ||
720 | _git_log () | |
721 | { | |
6e31b866 SP |
722 | local cur="${COMP_WORDS[COMP_CWORD]}" |
723 | case "$cur" in | |
724 | --pretty=*) | |
b3391775 | 725 | __gitcomp " |
6e31b866 | 726 | oneline short medium full fuller email raw |
b3391775 | 727 | " "" "${cur##--pretty=}" |
6e31b866 SP |
728 | return |
729 | ;; | |
47e98eec SP |
730 | --date=*) |
731 | __gitcomp " | |
732 | relative iso8601 rfc2822 short local default | |
733 | " "" "${cur##--date=}" | |
734 | return | |
735 | ;; | |
6e31b866 | 736 | --*) |
b3391775 | 737 | __gitcomp " |
6e31b866 SP |
738 | --max-count= --max-age= --since= --after= |
739 | --min-age= --before= --until= | |
8f87fae6 | 740 | --root --topo-order --date-order --reverse |
47e98eec | 741 | --no-merges --follow |
6e31b866 | 742 | --abbrev-commit --abbrev= |
47e98eec | 743 | --relative-date --date= |
6e31b866 SP |
744 | --author= --committer= --grep= |
745 | --all-match | |
8f87fae6 | 746 | --pretty= --name-status --name-only --raw |
ec804891 | 747 | --not --all |
7d37b5bf | 748 | --left-right --cherry-pick |
b3391775 | 749 | " |
6e31b866 SP |
750 | return |
751 | ;; | |
752 | esac | |
f53352fb | 753 | __git_complete_revlist |
690d8824 JH |
754 | } |
755 | ||
4ad91321 SP |
756 | _git_merge () |
757 | { | |
758 | local cur="${COMP_WORDS[COMP_CWORD]}" | |
ce1e39d2 SP |
759 | case "${COMP_WORDS[COMP_CWORD-1]}" in |
760 | -s|--strategy) | |
b3391775 | 761 | __gitcomp "$(__git_merge_strategies)" |
ce1e39d2 SP |
762 | return |
763 | esac | |
4ad91321 | 764 | case "$cur" in |
ce1e39d2 | 765 | --strategy=*) |
b3391775 | 766 | __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}" |
ce1e39d2 SP |
767 | return |
768 | ;; | |
4ad91321 | 769 | --*) |
b3391775 | 770 | __gitcomp " |
61d926a3 | 771 | --no-commit --no-summary --squash --strategy |
b3391775 | 772 | " |
4ad91321 SP |
773 | return |
774 | esac | |
b3391775 | 775 | __gitcomp "$(__git_refs)" |
4ad91321 SP |
776 | } |
777 | ||
690d8824 JH |
778 | _git_merge_base () |
779 | { | |
b3391775 | 780 | __gitcomp "$(__git_refs)" |
690d8824 JH |
781 | } |
782 | ||
d33909bf SP |
783 | _git_name_rev () |
784 | { | |
b3391775 | 785 | __gitcomp "--tags --all --stdin" |
d33909bf SP |
786 | } |
787 | ||
690d8824 JH |
788 | _git_pull () |
789 | { | |
790 | local cur="${COMP_WORDS[COMP_CWORD]}" | |
791 | ||
792 | case "${COMP_WORDS[0]},$COMP_CWORD" in | |
793 | git-pull*,1) | |
b3391775 | 794 | __gitcomp "$(__git_remotes)" |
690d8824 JH |
795 | ;; |
796 | git,2) | |
b3391775 | 797 | __gitcomp "$(__git_remotes)" |
690d8824 JH |
798 | ;; |
799 | *) | |
800 | local remote | |
801 | case "${COMP_WORDS[0]}" in | |
802 | git-pull) remote="${COMP_WORDS[1]}" ;; | |
803 | git) remote="${COMP_WORDS[2]}" ;; | |
804 | esac | |
b3391775 | 805 | __gitcomp "$(__git_refs "$remote")" |
690d8824 JH |
806 | ;; |
807 | esac | |
808 | } | |
809 | ||
810 | _git_push () | |
811 | { | |
812 | local cur="${COMP_WORDS[COMP_CWORD]}" | |
813 | ||
814 | case "${COMP_WORDS[0]},$COMP_CWORD" in | |
815 | git-push*,1) | |
b3391775 | 816 | __gitcomp "$(__git_remotes)" |
690d8824 JH |
817 | ;; |
818 | git,2) | |
b3391775 | 819 | __gitcomp "$(__git_remotes)" |
690d8824 JH |
820 | ;; |
821 | *) | |
822 | case "$cur" in | |
823 | *:*) | |
824 | local remote | |
825 | case "${COMP_WORDS[0]}" in | |
826 | git-push) remote="${COMP_WORDS[1]}" ;; | |
827 | git) remote="${COMP_WORDS[2]}" ;; | |
828 | esac | |
b3391775 | 829 | __gitcomp "$(__git_refs "$remote")" "" "${cur#*:}" |
690d8824 | 830 | ;; |
161fea83 SP |
831 | +*) |
832 | __gitcomp "$(__git_refs)" + "${cur#+}" | |
833 | ;; | |
690d8824 | 834 | *) |
92d7c8e3 | 835 | __gitcomp "$(__git_refs)" |
690d8824 JH |
836 | ;; |
837 | esac | |
838 | ;; | |
839 | esac | |
840 | } | |
841 | ||
61d926a3 SP |
842 | _git_rebase () |
843 | { | |
51fe1209 SG |
844 | local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)" |
845 | if [ -d .dotest ] || [ -d "$dir"/.dotest-merge ]; then | |
b3391775 | 846 | __gitcomp "--continue --skip --abort" |
61d926a3 SP |
847 | return |
848 | fi | |
ce1e39d2 SP |
849 | case "${COMP_WORDS[COMP_CWORD-1]}" in |
850 | -s|--strategy) | |
b3391775 | 851 | __gitcomp "$(__git_merge_strategies)" |
ce1e39d2 SP |
852 | return |
853 | esac | |
61d926a3 | 854 | case "$cur" in |
ce1e39d2 | 855 | --strategy=*) |
b3391775 | 856 | __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}" |
ce1e39d2 SP |
857 | return |
858 | ;; | |
61d926a3 | 859 | --*) |
b3391775 | 860 | __gitcomp "--onto --merge --strategy" |
61d926a3 SP |
861 | return |
862 | esac | |
b3391775 | 863 | __gitcomp "$(__git_refs)" |
61d926a3 SP |
864 | } |
865 | ||
e0d10e1c | 866 | _git_config () |
5de40f59 SP |
867 | { |
868 | local cur="${COMP_WORDS[COMP_CWORD]}" | |
869 | local prv="${COMP_WORDS[COMP_CWORD-1]}" | |
870 | case "$prv" in | |
871 | branch.*.remote) | |
78d4d6a2 | 872 | __gitcomp "$(__git_remotes)" |
5de40f59 SP |
873 | return |
874 | ;; | |
875 | branch.*.merge) | |
78d4d6a2 | 876 | __gitcomp "$(__git_refs)" |
5de40f59 SP |
877 | return |
878 | ;; | |
879 | remote.*.fetch) | |
880 | local remote="${prv#remote.}" | |
881 | remote="${remote%.fetch}" | |
78d4d6a2 | 882 | __gitcomp "$(__git_refs_remotes "$remote")" |
5de40f59 SP |
883 | return |
884 | ;; | |
885 | remote.*.push) | |
886 | local remote="${prv#remote.}" | |
887 | remote="${remote%.push}" | |
78d4d6a2 | 888 | __gitcomp "$(git --git-dir="$(__gitdir)" \ |
5de40f59 | 889 | for-each-ref --format='%(refname):%(refname)' \ |
78d4d6a2 SP |
890 | refs/heads)" |
891 | return | |
892 | ;; | |
893 | pull.twohead|pull.octopus) | |
894 | __gitcomp "$(__git_merge_strategies)" | |
895 | return | |
896 | ;; | |
897 | color.branch|color.diff|color.status) | |
898 | __gitcomp "always never auto" | |
899 | return | |
900 | ;; | |
901 | color.*.*) | |
902 | __gitcomp " | |
903 | black red green yellow blue magenta cyan white | |
904 | bold dim ul blink reverse | |
905 | " | |
5de40f59 SP |
906 | return |
907 | ;; | |
908 | *.*) | |
909 | COMPREPLY=() | |
910 | return | |
911 | ;; | |
912 | esac | |
913 | case "$cur" in | |
914 | --*) | |
78d4d6a2 | 915 | __gitcomp " |
47e98eec | 916 | --global --system --file= |
12977705 | 917 | --list --replace-all |
5de40f59 | 918 | --get --get-all --get-regexp |
1b71eb35 | 919 | --add --unset --unset-all |
12977705 | 920 | --remove-section --rename-section |
78d4d6a2 | 921 | " |
5de40f59 SP |
922 | return |
923 | ;; | |
924 | branch.*.*) | |
925 | local pfx="${cur%.*}." | |
926 | cur="${cur##*.}" | |
78d4d6a2 | 927 | __gitcomp "remote merge" "$pfx" "$cur" |
5de40f59 SP |
928 | return |
929 | ;; | |
930 | branch.*) | |
931 | local pfx="${cur%.*}." | |
932 | cur="${cur#*.}" | |
78d4d6a2 | 933 | __gitcomp "$(__git_heads)" "$pfx" "$cur" "." |
5de40f59 SP |
934 | return |
935 | ;; | |
936 | remote.*.*) | |
937 | local pfx="${cur%.*}." | |
938 | cur="${cur##*.}" | |
12977705 SP |
939 | __gitcomp " |
940 | url fetch push skipDefaultUpdate | |
941 | receivepack uploadpack tagopt | |
942 | " "$pfx" "$cur" | |
5de40f59 SP |
943 | return |
944 | ;; | |
945 | remote.*) | |
946 | local pfx="${cur%.*}." | |
947 | cur="${cur#*.}" | |
78d4d6a2 | 948 | __gitcomp "$(__git_remotes)" "$pfx" "$cur" "." |
5de40f59 SP |
949 | return |
950 | ;; | |
951 | esac | |
78d4d6a2 | 952 | __gitcomp " |
5de40f59 SP |
953 | apply.whitespace |
954 | core.fileMode | |
955 | core.gitProxy | |
956 | core.ignoreStat | |
957 | core.preferSymlinkRefs | |
958 | core.logAllRefUpdates | |
47e98eec | 959 | core.loosecompression |
5de40f59 SP |
960 | core.repositoryFormatVersion |
961 | core.sharedRepository | |
962 | core.warnAmbiguousRefs | |
963 | core.compression | |
78d4d6a2 SP |
964 | core.packedGitWindowSize |
965 | core.packedGitLimit | |
2122591b | 966 | clean.requireForce |
78d4d6a2 SP |
967 | color.branch |
968 | color.branch.current | |
969 | color.branch.local | |
970 | color.branch.remote | |
971 | color.branch.plain | |
a159ca0c | 972 | color.diff |
78d4d6a2 SP |
973 | color.diff.plain |
974 | color.diff.meta | |
975 | color.diff.frag | |
976 | color.diff.old | |
977 | color.diff.new | |
978 | color.diff.commit | |
979 | color.diff.whitespace | |
a159ca0c | 980 | color.pager |
a159ca0c | 981 | color.status |
78d4d6a2 SP |
982 | color.status.header |
983 | color.status.added | |
984 | color.status.changed | |
985 | color.status.untracked | |
986 | diff.renameLimit | |
987 | diff.renames | |
988 | fetch.unpackLimit | |
989 | format.headers | |
47e98eec | 990 | format.subjectprefix |
78d4d6a2 SP |
991 | gitcvs.enabled |
992 | gitcvs.logfile | |
12977705 SP |
993 | gitcvs.allbinary |
994 | gitcvs.dbname gitcvs.dbdriver gitcvs.dbuser gitcvs.dvpass | |
995 | gc.packrefs | |
78d4d6a2 SP |
996 | gc.reflogexpire |
997 | gc.reflogexpireunreachable | |
998 | gc.rerereresolved | |
999 | gc.rerereunresolved | |
5de40f59 SP |
1000 | http.sslVerify |
1001 | http.sslCert | |
1002 | http.sslKey | |
1003 | http.sslCAInfo | |
1004 | http.sslCAPath | |
1005 | http.maxRequests | |
78d4d6a2 SP |
1006 | http.lowSpeedLimit |
1007 | http.lowSpeedTime | |
5de40f59 | 1008 | http.noEPSV |
78d4d6a2 SP |
1009 | i18n.commitEncoding |
1010 | i18n.logOutputEncoding | |
1011 | log.showroot | |
12977705 | 1012 | merge.tool |
78d4d6a2 SP |
1013 | merge.summary |
1014 | merge.verbosity | |
5de40f59 | 1015 | pack.window |
12977705 | 1016 | pack.depth |
47e98eec SP |
1017 | pack.windowMemory |
1018 | pack.compression | |
1019 | pack.deltaCacheSize | |
1020 | pack.deltaCacheLimit | |
78d4d6a2 SP |
1021 | pull.octopus |
1022 | pull.twohead | |
5de40f59 | 1023 | repack.useDeltaBaseOffset |
78d4d6a2 SP |
1024 | show.difftree |
1025 | showbranch.default | |
1026 | tar.umask | |
1027 | transfer.unpackLimit | |
5de40f59 SP |
1028 | receive.unpackLimit |
1029 | receive.denyNonFastForwards | |
78d4d6a2 SP |
1030 | user.name |
1031 | user.email | |
1032 | user.signingkey | |
1033 | whatchanged.difftree | |
5de40f59 | 1034 | branch. remote. |
78d4d6a2 | 1035 | " |
5de40f59 SP |
1036 | } |
1037 | ||
88293c67 SP |
1038 | _git_remote () |
1039 | { | |
3ff1320d SG |
1040 | local subcommands="add rm show prune update" |
1041 | local subcommand="$(__git_find_subcommand "$subcommands")" | |
1042 | if [ -z "$subcommand" ]; then | |
88293c67 SP |
1043 | return |
1044 | fi | |
1045 | ||
3ff1320d | 1046 | case "$subcommand" in |
a3b811a4 | 1047 | rm|show|prune) |
88293c67 SP |
1048 | __gitcomp "$(__git_remotes)" |
1049 | ;; | |
fb72759b SP |
1050 | update) |
1051 | local i c='' IFS=$'\n' | |
1052 | for i in $(git --git-dir="$(__gitdir)" config --list); do | |
1053 | case "$i" in | |
1054 | remotes.*) | |
1055 | i="${i#remotes.}" | |
1056 | c="$c ${i/=*/}" | |
1057 | ;; | |
1058 | esac | |
1059 | done | |
1060 | __gitcomp "$c" | |
1061 | ;; | |
88293c67 SP |
1062 | *) |
1063 | COMPREPLY=() | |
1064 | ;; | |
1065 | esac | |
1066 | } | |
1067 | ||
67e78c3b SP |
1068 | _git_reset () |
1069 | { | |
1070 | local cur="${COMP_WORDS[COMP_CWORD]}" | |
b3391775 SP |
1071 | case "$cur" in |
1072 | --*) | |
1073 | __gitcomp "--mixed --hard --soft" | |
1074 | return | |
1075 | ;; | |
1076 | esac | |
1077 | __gitcomp "$(__git_refs)" | |
67e78c3b SP |
1078 | } |
1079 | ||
1fd6bec9 SP |
1080 | _git_shortlog () |
1081 | { | |
1082 | local cur="${COMP_WORDS[COMP_CWORD]}" | |
1083 | case "$cur" in | |
1084 | --*) | |
1085 | __gitcomp " | |
1086 | --max-count= --max-age= --since= --after= | |
1087 | --min-age= --before= --until= | |
1088 | --no-merges | |
1089 | --author= --committer= --grep= | |
1090 | --all-match | |
1091 | --not --all | |
1092 | --numbered --summary | |
1093 | " | |
1094 | return | |
1095 | ;; | |
1096 | esac | |
1097 | __git_complete_revlist | |
1098 | } | |
1099 | ||
90131924 SP |
1100 | _git_show () |
1101 | { | |
1102 | local cur="${COMP_WORDS[COMP_CWORD]}" | |
1103 | case "$cur" in | |
1104 | --pretty=*) | |
b3391775 | 1105 | __gitcomp " |
90131924 | 1106 | oneline short medium full fuller email raw |
b3391775 | 1107 | " "" "${cur##--pretty=}" |
90131924 SP |
1108 | return |
1109 | ;; | |
1110 | --*) | |
b3391775 | 1111 | __gitcomp "--pretty=" |
90131924 SP |
1112 | return |
1113 | ;; | |
1114 | esac | |
1115 | __git_complete_file | |
1116 | } | |
1117 | ||
7fd53fce JH |
1118 | _git_stash () |
1119 | { | |
88b302f5 | 1120 | local subcommands='save list show apply clear drop pop create' |
3ff1320d SG |
1121 | if [ -z "$(__git_find_subcommand "$subcommands")" ]; then |
1122 | __gitcomp "$subcommands" | |
1123 | fi | |
7fd53fce JH |
1124 | } |
1125 | ||
be86f7a0 SP |
1126 | _git_submodule () |
1127 | { | |
3ff1320d SG |
1128 | local subcommands="add status init update" |
1129 | if [ -z "$(__git_find_subcommand "$subcommands")" ]; then | |
be86f7a0 SP |
1130 | local cur="${COMP_WORDS[COMP_CWORD]}" |
1131 | case "$cur" in | |
1132 | --*) | |
1133 | __gitcomp "--quiet --cached" | |
1134 | ;; | |
1135 | *) | |
3ff1320d | 1136 | __gitcomp "$subcommands" |
be86f7a0 SP |
1137 | ;; |
1138 | esac | |
1139 | return | |
1140 | fi | |
1141 | } | |
1142 | ||
47f6ee28 SG |
1143 | _git_svn () |
1144 | { | |
1145 | local subcommands=" | |
1146 | init fetch clone rebase dcommit log find-rev | |
1147 | set-tree commit-diff info create-ignore propget | |
1148 | proplist show-ignore show-externals | |
1149 | " | |
1150 | local subcommand="$(__git_find_subcommand "$subcommands")" | |
1151 | if [ -z "$subcommand" ]; then | |
1152 | __gitcomp "$subcommands" | |
1153 | else | |
1154 | local remote_opts="--username= --config-dir= --no-auth-cache" | |
1155 | local fc_opts=" | |
1156 | --follow-parent --authors-file= --repack= | |
1157 | --no-metadata --use-svm-props --use-svnsync-props | |
1158 | --log-window-size= --no-checkout --quiet | |
1159 | --repack-flags --user-log-author $remote_opts | |
1160 | " | |
1161 | local init_opts=" | |
1162 | --template= --shared= --trunk= --tags= | |
1163 | --branches= --stdlayout --minimize-url | |
1164 | --no-metadata --use-svm-props --use-svnsync-props | |
1165 | --rewrite-root= $remote_opts | |
1166 | " | |
1167 | local cmt_opts=" | |
1168 | --edit --rmdir --find-copies-harder --copy-similarity= | |
1169 | " | |
1170 | ||
1171 | local cur="${COMP_WORDS[COMP_CWORD]}" | |
1172 | case "$subcommand,$cur" in | |
1173 | fetch,--*) | |
1174 | __gitcomp "--revision= --fetch-all $fc_opts" | |
1175 | ;; | |
1176 | clone,--*) | |
1177 | __gitcomp "--revision= $fc_opts $init_opts" | |
1178 | ;; | |
1179 | init,--*) | |
1180 | __gitcomp "$init_opts" | |
1181 | ;; | |
1182 | dcommit,--*) | |
1183 | __gitcomp " | |
1184 | --merge --strategy= --verbose --dry-run | |
1185 | --fetch-all --no-rebase $cmt_opts $fc_opts | |
1186 | " | |
1187 | ;; | |
1188 | set-tree,--*) | |
1189 | __gitcomp "--stdin $cmt_opts $fc_opts" | |
1190 | ;; | |
1191 | create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\ | |
1192 | show-externals,--*) | |
1193 | __gitcomp "--revision=" | |
1194 | ;; | |
1195 | log,--*) | |
1196 | __gitcomp " | |
1197 | --limit= --revision= --verbose --incremental | |
1198 | --oneline --show-commit --non-recursive | |
1199 | --authors-file= | |
1200 | " | |
1201 | ;; | |
1202 | rebase,--*) | |
1203 | __gitcomp " | |
1204 | --merge --verbose --strategy= --local | |
1205 | --fetch-all $fc_opts | |
1206 | " | |
1207 | ;; | |
1208 | commit-diff,--*) | |
1209 | __gitcomp "--message= --file= --revision= $cmt_opts" | |
1210 | ;; | |
1211 | info,--*) | |
1212 | __gitcomp "--url" | |
1213 | ;; | |
1214 | *) | |
1215 | COMPREPLY=() | |
1216 | ;; | |
1217 | esac | |
1218 | fi | |
1219 | } | |
1220 | ||
88e21dc7 SP |
1221 | _git_tag () |
1222 | { | |
1223 | local i c=1 f=0 | |
1224 | while [ $c -lt $COMP_CWORD ]; do | |
1225 | i="${COMP_WORDS[c]}" | |
1226 | case "$i" in | |
1227 | -d|-v) | |
1228 | __gitcomp "$(__git_tags)" | |
1229 | return | |
1230 | ;; | |
1231 | -f) | |
1232 | f=1 | |
1233 | ;; | |
1234 | esac | |
1235 | c=$((++c)) | |
1236 | done | |
1237 | ||
1238 | case "${COMP_WORDS[COMP_CWORD-1]}" in | |
1239 | -m|-F) | |
1240 | COMPREPLY=() | |
1241 | ;; | |
1242 | -*|tag|git-tag) | |
1243 | if [ $f = 1 ]; then | |
1244 | __gitcomp "$(__git_tags)" | |
1245 | else | |
1246 | COMPREPLY=() | |
1247 | fi | |
1248 | ;; | |
1249 | *) | |
1250 | __gitcomp "$(__git_refs)" | |
1251 | ;; | |
1252 | esac | |
1253 | } | |
1254 | ||
690d8824 JH |
1255 | _git () |
1256 | { | |
873537fa SP |
1257 | local i c=1 command __git_dir |
1258 | ||
1259 | while [ $c -lt $COMP_CWORD ]; do | |
1260 | i="${COMP_WORDS[c]}" | |
1261 | case "$i" in | |
1262 | --git-dir=*) __git_dir="${i#--git-dir=}" ;; | |
1263 | --bare) __git_dir="." ;; | |
1264 | --version|--help|-p|--paginate) ;; | |
1265 | *) command="$i"; break ;; | |
1266 | esac | |
1267 | c=$((++c)) | |
1268 | done | |
1269 | ||
1d17b22e | 1270 | if [ -z "$command" ]; then |
72e5e989 SP |
1271 | case "${COMP_WORDS[COMP_CWORD]}" in |
1272 | --*=*) COMPREPLY=() ;; | |
47e98eec | 1273 | --*) __gitcomp " |
ce5a2c95 | 1274 | --paginate |
47e98eec SP |
1275 | --no-pager |
1276 | --git-dir= | |
1277 | --bare | |
1278 | --version | |
1279 | --exec-path | |
ce5a2c95 TL |
1280 | --work-tree= |
1281 | --help | |
47e98eec SP |
1282 | " |
1283 | ;; | |
72e5e989 SP |
1284 | *) __gitcomp "$(__git_commands) $(__git_aliases)" ;; |
1285 | esac | |
1286 | return | |
873537fa | 1287 | fi |
367dce2a | 1288 | |
873537fa SP |
1289 | local expansion=$(__git_aliased_command "$command") |
1290 | [ "$expansion" ] && command="$expansion" | |
367dce2a | 1291 | |
873537fa | 1292 | case "$command" in |
88329195 | 1293 | am) _git_am ;; |
8435b548 | 1294 | add) _git_add ;; |
88329195 | 1295 | apply) _git_apply ;; |
b2e69f62 | 1296 | bisect) _git_bisect ;; |
374a58c9 | 1297 | bundle) _git_bundle ;; |
873537fa | 1298 | branch) _git_branch ;; |
873537fa | 1299 | checkout) _git_checkout ;; |
d8a9fea5 | 1300 | cherry) _git_cherry ;; |
1273231e | 1301 | cherry-pick) _git_cherry_pick ;; |
4548e855 | 1302 | commit) _git_commit ;; |
e0d10e1c | 1303 | config) _git_config ;; |
217926c0 | 1304 | describe) _git_describe ;; |
873537fa | 1305 | diff) _git_diff ;; |
873537fa | 1306 | fetch) _git_fetch ;; |
f53352fb | 1307 | format-patch) _git_format_patch ;; |
b26c8748 | 1308 | gc) _git_gc ;; |
873537fa SP |
1309 | log) _git_log ;; |
1310 | ls-remote) _git_ls_remote ;; | |
1311 | ls-tree) _git_ls_tree ;; | |
4ad91321 | 1312 | merge) _git_merge;; |
873537fa | 1313 | merge-base) _git_merge_base ;; |
d33909bf | 1314 | name-rev) _git_name_rev ;; |
873537fa SP |
1315 | pull) _git_pull ;; |
1316 | push) _git_push ;; | |
61d926a3 | 1317 | rebase) _git_rebase ;; |
88293c67 | 1318 | remote) _git_remote ;; |
873537fa | 1319 | reset) _git_reset ;; |
1fd6bec9 | 1320 | shortlog) _git_shortlog ;; |
90131924 | 1321 | show) _git_show ;; |
873537fa | 1322 | show-branch) _git_log ;; |
7fd53fce | 1323 | stash) _git_stash ;; |
be86f7a0 | 1324 | submodule) _git_submodule ;; |
47f6ee28 | 1325 | svn) _git_svn ;; |
88e21dc7 | 1326 | tag) _git_tag ;; |
873537fa SP |
1327 | whatchanged) _git_log ;; |
1328 | *) COMPREPLY=() ;; | |
1329 | esac | |
690d8824 JH |
1330 | } |
1331 | ||
1332 | _gitk () | |
1333 | { | |
1334 | local cur="${COMP_WORDS[COMP_CWORD]}" | |
b3391775 SP |
1335 | case "$cur" in |
1336 | --*) | |
1337 | __gitcomp "--not --all" | |
1338 | return | |
1339 | ;; | |
1340 | esac | |
ec804891 | 1341 | __git_complete_revlist |
690d8824 JH |
1342 | } |
1343 | ||
1344 | complete -o default -o nospace -F _git git | |
b3391775 SP |
1345 | complete -o default -o nospace -F _gitk gitk |
1346 | complete -o default -o nospace -F _git_am git-am | |
1347 | complete -o default -o nospace -F _git_apply git-apply | |
b2e69f62 | 1348 | complete -o default -o nospace -F _git_bisect git-bisect |
b3391775 | 1349 | complete -o default -o nospace -F _git_branch git-branch |
374a58c9 | 1350 | complete -o default -o nospace -F _git_bundle git-bundle |
b3391775 | 1351 | complete -o default -o nospace -F _git_checkout git-checkout |
d8a9fea5 | 1352 | complete -o default -o nospace -F _git_cherry git-cherry |
b3391775 SP |
1353 | complete -o default -o nospace -F _git_cherry_pick git-cherry-pick |
1354 | complete -o default -o nospace -F _git_commit git-commit | |
217926c0 | 1355 | complete -o default -o nospace -F _git_describe git-describe |
690d8824 | 1356 | complete -o default -o nospace -F _git_diff git-diff |
690d8824 | 1357 | complete -o default -o nospace -F _git_fetch git-fetch |
f53352fb | 1358 | complete -o default -o nospace -F _git_format_patch git-format-patch |
b26c8748 | 1359 | complete -o default -o nospace -F _git_gc git-gc |
690d8824 | 1360 | complete -o default -o nospace -F _git_log git-log |
b3391775 | 1361 | complete -o default -o nospace -F _git_ls_remote git-ls-remote |
690d8824 | 1362 | complete -o default -o nospace -F _git_ls_tree git-ls-tree |
b3391775 SP |
1363 | complete -o default -o nospace -F _git_merge git-merge |
1364 | complete -o default -o nospace -F _git_merge_base git-merge-base | |
1365 | complete -o default -o nospace -F _git_name_rev git-name-rev | |
690d8824 JH |
1366 | complete -o default -o nospace -F _git_pull git-pull |
1367 | complete -o default -o nospace -F _git_push git-push | |
b3391775 SP |
1368 | complete -o default -o nospace -F _git_rebase git-rebase |
1369 | complete -o default -o nospace -F _git_config git-config | |
88293c67 | 1370 | complete -o default -o nospace -F _git_remote git-remote |
b3391775 | 1371 | complete -o default -o nospace -F _git_reset git-reset |
1fd6bec9 | 1372 | complete -o default -o nospace -F _git_shortlog git-shortlog |
90131924 | 1373 | complete -o default -o nospace -F _git_show git-show |
7fd53fce | 1374 | complete -o default -o nospace -F _git_stash git-stash |
be86f7a0 | 1375 | complete -o default -o nospace -F _git_submodule git-submodule |
47f6ee28 | 1376 | complete -o default -o nospace -F _git_svn git-svn |
144d33de | 1377 | complete -o default -o nospace -F _git_log git-show-branch |
88e21dc7 | 1378 | complete -o default -o nospace -F _git_tag git-tag |
690d8824 JH |
1379 | complete -o default -o nospace -F _git_log git-whatchanged |
1380 | ||
1381 | # The following are necessary only for Cygwin, and only are needed | |
1382 | # when the user has tab-completed the executable name and consequently | |
1383 | # included the '.exe' suffix. | |
1384 | # | |
76c3eb51 | 1385 | if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then |
b3391775 SP |
1386 | complete -o default -o nospace -F _git_add git-add.exe |
1387 | complete -o default -o nospace -F _git_apply git-apply.exe | |
144d33de | 1388 | complete -o default -o nospace -F _git git.exe |
b3391775 | 1389 | complete -o default -o nospace -F _git_branch git-branch.exe |
374a58c9 | 1390 | complete -o default -o nospace -F _git_bundle git-bundle.exe |
d8a9fea5 | 1391 | complete -o default -o nospace -F _git_cherry git-cherry.exe |
217926c0 | 1392 | complete -o default -o nospace -F _git_describe git-describe.exe |
690d8824 | 1393 | complete -o default -o nospace -F _git_diff git-diff.exe |
f53352fb | 1394 | complete -o default -o nospace -F _git_format_patch git-format-patch.exe |
690d8824 JH |
1395 | complete -o default -o nospace -F _git_log git-log.exe |
1396 | complete -o default -o nospace -F _git_ls_tree git-ls-tree.exe | |
b3391775 SP |
1397 | complete -o default -o nospace -F _git_merge_base git-merge-base.exe |
1398 | complete -o default -o nospace -F _git_name_rev git-name-rev.exe | |
690d8824 | 1399 | complete -o default -o nospace -F _git_push git-push.exe |
b3391775 | 1400 | complete -o default -o nospace -F _git_config git-config |
1fd6bec9 | 1401 | complete -o default -o nospace -F _git_shortlog git-shortlog.exe |
90131924 | 1402 | complete -o default -o nospace -F _git_show git-show.exe |
144d33de | 1403 | complete -o default -o nospace -F _git_log git-show-branch.exe |
88e21dc7 | 1404 | complete -o default -o nospace -F _git_tag git-tag.exe |
690d8824 | 1405 | complete -o default -o nospace -F _git_log git-whatchanged.exe |
76c3eb51 | 1406 | fi |