@noldova/checkpoints.git.darwin-arm64 0.0.0-stage → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/LICENSE +7 -0
  2. package/README.md +10 -2
  3. package/git/bin/git +0 -0
  4. package/git/bin/scalar +0 -0
  5. package/git/etc/gitconfig +13 -0
  6. package/git/libexec/git-core/git +0 -0
  7. package/git/libexec/git-core/git-archimport +4 -0
  8. package/git/libexec/git-core/git-cvsexportcommit +4 -0
  9. package/git/libexec/git-core/git-cvsimport +4 -0
  10. package/git/libexec/git-core/git-cvsserver +4 -0
  11. package/git/libexec/git-core/git-daemon +0 -0
  12. package/git/libexec/git-core/git-difftool--helper +125 -0
  13. package/git/libexec/git-core/git-filter-branch +665 -0
  14. package/git/libexec/git-core/git-http-backend +0 -0
  15. package/git/libexec/git-core/git-http-fetch +0 -0
  16. package/git/libexec/git-core/git-http-push +0 -0
  17. package/git/libexec/git-core/git-imap-send +0 -0
  18. package/git/libexec/git-core/git-instaweb +4 -0
  19. package/git/libexec/git-core/git-merge-octopus +112 -0
  20. package/git/libexec/git-core/git-merge-one-file +167 -0
  21. package/git/libexec/git-core/git-merge-resolve +64 -0
  22. package/git/libexec/git-core/git-mergetool +579 -0
  23. package/git/libexec/git-core/git-mergetool--lib +549 -0
  24. package/git/libexec/git-core/git-quiltimport +155 -0
  25. package/git/libexec/git-core/git-receive-pack +0 -0
  26. package/git/libexec/git-core/git-remote-ftp +0 -0
  27. package/git/libexec/git-core/git-remote-ftps +0 -0
  28. package/git/libexec/git-core/git-remote-http +0 -0
  29. package/git/libexec/git-core/git-remote-https +0 -0
  30. package/git/libexec/git-core/git-request-pull +178 -0
  31. package/git/libexec/git-core/git-send-email +4 -0
  32. package/git/libexec/git-core/git-sh-i18n +79 -0
  33. package/git/libexec/git-core/git-sh-i18n--envsubst +0 -0
  34. package/git/libexec/git-core/git-sh-setup +357 -0
  35. package/git/libexec/git-core/git-shell +0 -0
  36. package/git/libexec/git-core/git-submodule +671 -0
  37. package/git/libexec/git-core/git-upload-archive +0 -0
  38. package/git/libexec/git-core/git-upload-pack +0 -0
  39. package/git/libexec/git-core/git-web--browse +196 -0
  40. package/git/libexec/git-core/mergetools/araxis +26 -0
  41. package/git/libexec/git-core/mergetools/bc +37 -0
  42. package/git/libexec/git-core/mergetools/codecompare +31 -0
  43. package/git/libexec/git-core/mergetools/deltawalker +33 -0
  44. package/git/libexec/git-core/mergetools/diffmerge +26 -0
  45. package/git/libexec/git-core/mergetools/diffuse +23 -0
  46. package/git/libexec/git-core/mergetools/ecmerge +22 -0
  47. package/git/libexec/git-core/mergetools/emerge +34 -0
  48. package/git/libexec/git-core/mergetools/examdiff +24 -0
  49. package/git/libexec/git-core/mergetools/guiffy +26 -0
  50. package/git/libexec/git-core/mergetools/gvimdiff +1 -0
  51. package/git/libexec/git-core/mergetools/kdiff3 +44 -0
  52. package/git/libexec/git-core/mergetools/kompare +19 -0
  53. package/git/libexec/git-core/mergetools/meld +97 -0
  54. package/git/libexec/git-core/mergetools/nvimdiff +1 -0
  55. package/git/libexec/git-core/mergetools/opendiff +22 -0
  56. package/git/libexec/git-core/mergetools/p4merge +44 -0
  57. package/git/libexec/git-core/mergetools/smerge +20 -0
  58. package/git/libexec/git-core/mergetools/tkdiff +24 -0
  59. package/git/libexec/git-core/mergetools/tortoisemerge +40 -0
  60. package/git/libexec/git-core/mergetools/vimdiff +657 -0
  61. package/git/libexec/git-core/mergetools/vscode +19 -0
  62. package/git/libexec/git-core/mergetools/winmerge +23 -0
  63. package/git/libexec/git-core/mergetools/xxdiff +38 -0
  64. package/git/libexec/git-core/scalar +0 -0
  65. package/git/share/bash-completion/completions/git +4115 -0
  66. package/git/share/git-core/templates/description +1 -0
  67. package/git/share/git-core/templates/hooks/applypatch-msg.sample +15 -0
  68. package/git/share/git-core/templates/hooks/commit-msg.sample +74 -0
  69. package/git/share/git-core/templates/hooks/fsmonitor-watchman.sample +168 -0
  70. package/git/share/git-core/templates/hooks/post-update.sample +8 -0
  71. package/git/share/git-core/templates/hooks/pre-applypatch.sample +14 -0
  72. package/git/share/git-core/templates/hooks/pre-commit.sample +49 -0
  73. package/git/share/git-core/templates/hooks/pre-merge-commit.sample +13 -0
  74. package/git/share/git-core/templates/hooks/pre-push.sample +53 -0
  75. package/git/share/git-core/templates/hooks/pre-rebase.sample +169 -0
  76. package/git/share/git-core/templates/hooks/pre-receive.sample +24 -0
  77. package/git/share/git-core/templates/hooks/prepare-commit-msg.sample +42 -0
  78. package/git/share/git-core/templates/hooks/push-to-checkout.sample +78 -0
  79. package/git/share/git-core/templates/hooks/sendemail-validate.sample +77 -0
  80. package/git/share/git-core/templates/hooks/update.sample +128 -0
  81. package/git/share/git-core/templates/info/exclude +6 -0
  82. package/licenses/git/COPYING +360 -0
  83. package/licenses/git/LGPL-2.1 +511 -0
  84. package/package.json +122 -4
@@ -0,0 +1,4115 @@
1
+ # bash/zsh completion support for core Git.
2
+ #
3
+ # Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
4
+ # Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
5
+ # Distributed under the GNU General Public License, version 2.0.
6
+ #
7
+ # The contained completion routines provide support for completing:
8
+ #
9
+ # *) local and remote branch names
10
+ # *) local and remote tag names
11
+ # *) .git/remotes file names
12
+ # *) git 'subcommands'
13
+ # *) git email aliases for git-send-email
14
+ # *) tree paths within 'ref:path/to/file' expressions
15
+ # *) file paths within current working directory and index
16
+ # *) common --long-options but not single-letter options
17
+ # *) arguments to long and single-letter options
18
+ #
19
+ # To use these routines:
20
+ #
21
+ # 1) Copy this file to somewhere (e.g. ~/.git-completion.bash).
22
+ # 2) Add the following line to your .bashrc/.zshrc:
23
+ # source ~/.git-completion.bash
24
+ # 3) Consider changing your PS1 to also show the current branch,
25
+ # see git-prompt.sh for details.
26
+ #
27
+ # If you use complex aliases of form '!f() { ... }; f', you can use the null
28
+ # command ':' as the first command in the function body to declare the desired
29
+ # completion style. For example '!f() { : git commit ; ... }; f' will
30
+ # tell the completion to use commit completion. This also works with aliases
31
+ # of form "!sh -c '...'". For example, "!sh -c ': git commit ; ... '".
32
+ # Note that "git" is optional --- '!f() { : commit; ...}; f' would complete
33
+ # just like the 'git commit' command.
34
+ #
35
+ # To add completion for git subcommands that are implemented in external
36
+ # scripts, define a function of the form '_git_${subcommand}' while replacing
37
+ # all dashes with underscores, and the main git completion will make use of it.
38
+ # For example, to add completion for 'git do-stuff' (which could e.g. live
39
+ # in /usr/bin/git-do-stuff), name the completion function '_git_do_stuff'.
40
+ # See _git_show, _git_bisect etc. below for more examples.
41
+ #
42
+ # If you have a shell command that is not part of git (and is not called as a
43
+ # git subcommand), but you would still like git-style completion for it, use
44
+ # __git_complete. For example, to use the same completion as for 'git log' also
45
+ # for the 'gl' command:
46
+ #
47
+ # __git_complete gl git_log
48
+ #
49
+ # Or if the 'gk' command should be completed the same as 'gitk':
50
+ #
51
+ # __git_complete gk gitk
52
+ #
53
+ # The second parameter of __git_complete gives the completion function; it is
54
+ # resolved as a function named "$2", or "__$2_main", or "_$2" in that order.
55
+ # In the examples above, the actual functions used for completion will be
56
+ # _git_log and __gitk_main.
57
+ #
58
+ # Compatible with bash 3.2.57.
59
+ #
60
+ # You can set the following environment variables to influence the behavior of
61
+ # the completion routines:
62
+ #
63
+ # GIT_COMPLETION_CHECKOUT_NO_GUESS
64
+ #
65
+ # When set to "1", do not include "DWIM" suggestions in git-checkout
66
+ # and git-switch completion (e.g., completing "foo" when "origin/foo"
67
+ # exists).
68
+ #
69
+ # GIT_COMPLETION_SHOW_ALL_COMMANDS
70
+ #
71
+ # When set to "1" suggest all commands, including plumbing commands
72
+ # which are hidden by default (e.g. "cat-file" on "git ca<TAB>").
73
+ #
74
+ # GIT_COMPLETION_SHOW_ALL
75
+ #
76
+ # When set to "1" suggest all options, including options which are
77
+ # typically hidden (e.g. '--allow-empty' for 'git commit').
78
+ #
79
+ # GIT_COMPLETION_IGNORE_CASE
80
+ #
81
+ # When set, uses for-each-ref '--ignore-case' to find refs that match
82
+ # case insensitively, even on systems with case sensitive file systems
83
+ # (e.g., completing tag name "FOO" on "git checkout f<TAB>").
84
+
85
+ case "$COMP_WORDBREAKS" in
86
+ *:*) : great ;;
87
+ *) COMP_WORDBREAKS="$COMP_WORDBREAKS:"
88
+ esac
89
+
90
+ # Discovers the path to the git repository taking any '--git-dir=<path>' and
91
+ # '-C <path>' options into account and stores it in the $__git_repo_path
92
+ # variable.
93
+ __git_find_repo_path ()
94
+ {
95
+ if [ -n "${__git_repo_path-}" ]; then
96
+ # we already know where it is
97
+ return
98
+ fi
99
+
100
+ if [ -n "${__git_C_args-}" ]; then
101
+ __git_repo_path="$(git "${__git_C_args[@]}" \
102
+ ${__git_dir:+--git-dir="$__git_dir"} \
103
+ rev-parse --absolute-git-dir 2>/dev/null)"
104
+ elif [ -n "${__git_dir-}" ]; then
105
+ test -d "$__git_dir" &&
106
+ __git_repo_path="$__git_dir"
107
+ elif [ -n "${GIT_DIR-}" ]; then
108
+ test -d "$GIT_DIR" &&
109
+ __git_repo_path="$GIT_DIR"
110
+ elif [ -d .git ]; then
111
+ __git_repo_path=.git
112
+ else
113
+ __git_repo_path="$(git rev-parse --git-dir 2>/dev/null)"
114
+ fi
115
+ }
116
+
117
+ # Deprecated: use __git_find_repo_path() and $__git_repo_path instead
118
+ # __gitdir accepts 0 or 1 arguments (i.e., location)
119
+ # returns location of .git repo
120
+ __gitdir ()
121
+ {
122
+ if [ -z "${1-}" ]; then
123
+ __git_find_repo_path || return 1
124
+ echo "$__git_repo_path"
125
+ elif [ -d "$1/.git" ]; then
126
+ echo "$1/.git"
127
+ else
128
+ echo "$1"
129
+ fi
130
+ }
131
+
132
+ # Runs git with all the options given as argument, respecting any
133
+ # '--git-dir=<path>' and '-C <path>' options present on the command line
134
+ __git ()
135
+ {
136
+ git ${__git_C_args:+"${__git_C_args[@]}"} \
137
+ ${__git_dir:+--git-dir="$__git_dir"} "$@" 2>/dev/null
138
+ }
139
+
140
+ # Helper function to read the first line of a file into a variable.
141
+ # __git_eread requires 2 arguments, the file path and the name of the
142
+ # variable, in that order.
143
+ #
144
+ # This is taken from git-prompt.sh.
145
+ __git_eread ()
146
+ {
147
+ test -r "$1" && IFS=$'\r\n' read -r "$2" <"$1"
148
+ }
149
+
150
+ # Runs git in $__git_repo_path to determine whether a pseudoref exists.
151
+ # 1: The pseudo-ref to search
152
+ __git_pseudoref_exists ()
153
+ {
154
+ local ref=$1
155
+ local head
156
+
157
+ __git_find_repo_path
158
+
159
+ # If the reftable is in use, we have to shell out to 'git rev-parse'
160
+ # to determine whether the ref exists instead of looking directly in
161
+ # the filesystem to determine whether the ref exists. Otherwise, use
162
+ # Bash builtins since executing Git commands are expensive on some
163
+ # platforms.
164
+ if __git_eread "$__git_repo_path/HEAD" head; then
165
+ if [ "$head" == "ref: refs/heads/.invalid" ]; then
166
+ __git show-ref --exists "$ref"
167
+ return $?
168
+ fi
169
+ fi
170
+
171
+ [ -f "$__git_repo_path/$ref" ]
172
+ }
173
+
174
+ # Removes backslash escaping, single quotes and double quotes from a word,
175
+ # stores the result in the variable $dequoted_word.
176
+ # 1: The word to dequote.
177
+ __git_dequote ()
178
+ {
179
+ local rest="$1" len ch
180
+
181
+ dequoted_word=""
182
+
183
+ while test -n "$rest"; do
184
+ len=${#dequoted_word}
185
+ dequoted_word="$dequoted_word${rest%%[\\\'\"]*}"
186
+ rest="${rest:$((${#dequoted_word}-$len))}"
187
+
188
+ case "${rest:0:1}" in
189
+ \\)
190
+ ch="${rest:1:1}"
191
+ case "$ch" in
192
+ $'\n')
193
+ ;;
194
+ *)
195
+ dequoted_word="$dequoted_word$ch"
196
+ ;;
197
+ esac
198
+ rest="${rest:2}"
199
+ ;;
200
+ \')
201
+ rest="${rest:1}"
202
+ len=${#dequoted_word}
203
+ dequoted_word="$dequoted_word${rest%%\'*}"
204
+ rest="${rest:$((${#dequoted_word}-$len+1))}"
205
+ ;;
206
+ \")
207
+ rest="${rest:1}"
208
+ while test -n "$rest" ; do
209
+ len=${#dequoted_word}
210
+ dequoted_word="$dequoted_word${rest%%[\\\"]*}"
211
+ rest="${rest:$((${#dequoted_word}-$len))}"
212
+ case "${rest:0:1}" in
213
+ \\)
214
+ ch="${rest:1:1}"
215
+ case "$ch" in
216
+ \"|\\|\$|\`)
217
+ dequoted_word="$dequoted_word$ch"
218
+ ;;
219
+ $'\n')
220
+ ;;
221
+ *)
222
+ dequoted_word="$dequoted_word\\$ch"
223
+ ;;
224
+ esac
225
+ rest="${rest:2}"
226
+ ;;
227
+ \")
228
+ rest="${rest:1}"
229
+ break
230
+ ;;
231
+ esac
232
+ done
233
+ ;;
234
+ esac
235
+ done
236
+ }
237
+
238
+ # Prints the number of slash-separated components in a path.
239
+ # 1: Path to count components of.
240
+ __git_count_path_components ()
241
+ {
242
+ local path="$1"
243
+ local relative="${path#/}"
244
+ relative="${relative%/}"
245
+ local slashes="/${relative//[^\/]}"
246
+ echo "${#slashes}"
247
+ }
248
+
249
+ # The following function is based on code from:
250
+ #
251
+ # bash_completion - programmable completion functions for bash 3.2+
252
+ #
253
+ # Copyright © 2006-2008, Ian Macdonald <ian@caliban.org>
254
+ # © 2009-2010, Bash Completion Maintainers
255
+ # <bash-completion-devel@lists.alioth.debian.org>
256
+ #
257
+ # This program is free software; you can redistribute it and/or modify
258
+ # it under the terms of the GNU General Public License as published by
259
+ # the Free Software Foundation; either version 2, or (at your option)
260
+ # any later version.
261
+ #
262
+ # This program is distributed in the hope that it will be useful,
263
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
264
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
265
+ # GNU General Public License for more details.
266
+ #
267
+ # You should have received a copy of the GNU General Public License
268
+ # along with this program; if not, see <http://www.gnu.org/licenses/>.
269
+ #
270
+ # The latest version of this software can be obtained here:
271
+ #
272
+ # http://bash-completion.alioth.debian.org/
273
+ #
274
+ # RELEASE: 2.x
275
+
276
+ # This function can be used to access a tokenized list of words
277
+ # on the command line:
278
+ #
279
+ # __git_reassemble_comp_words_by_ref '=:'
280
+ # if test "${words_[cword_-1]}" = -w
281
+ # then
282
+ # ...
283
+ # fi
284
+ #
285
+ # The argument should be a collection of characters from the list of
286
+ # word completion separators (COMP_WORDBREAKS) to treat as ordinary
287
+ # characters.
288
+ #
289
+ # This is roughly equivalent to going back in time and setting
290
+ # COMP_WORDBREAKS to exclude those characters. The intent is to
291
+ # make option types like --date=<type> and <rev>:<path> easy to
292
+ # recognize by treating each shell word as a single token.
293
+ #
294
+ # It is best not to set COMP_WORDBREAKS directly because the value is
295
+ # shared with other completion scripts. By the time the completion
296
+ # function gets called, COMP_WORDS has already been populated so local
297
+ # changes to COMP_WORDBREAKS have no effect.
298
+ #
299
+ # Output: words_, cword_, cur_.
300
+
301
+ __git_reassemble_comp_words_by_ref()
302
+ {
303
+ local exclude i j first
304
+ # Which word separators to exclude?
305
+ exclude="${1//[^$COMP_WORDBREAKS]}"
306
+ cword_=$COMP_CWORD
307
+ if [ -z "$exclude" ]; then
308
+ words_=("${COMP_WORDS[@]}")
309
+ return
310
+ fi
311
+ # List of word completion separators has shrunk;
312
+ # re-assemble words to complete.
313
+ for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)); do
314
+ # Append each nonempty word consisting of just
315
+ # word separator characters to the current word.
316
+ first=t
317
+ while
318
+ [ $i -gt 0 ] &&
319
+ [ -n "${COMP_WORDS[$i]}" ] &&
320
+ # word consists of excluded word separators
321
+ [ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ]
322
+ do
323
+ # Attach to the previous token,
324
+ # unless the previous token is the command name.
325
+ if [ $j -ge 2 ] && [ -n "$first" ]; then
326
+ ((j--))
327
+ fi
328
+ first=
329
+ words_[$j]=${words_[j]}${COMP_WORDS[i]}
330
+ if [ $i = $COMP_CWORD ]; then
331
+ cword_=$j
332
+ fi
333
+ if (($i < ${#COMP_WORDS[@]} - 1)); then
334
+ ((i++))
335
+ else
336
+ # Done.
337
+ return
338
+ fi
339
+ done
340
+ words_[$j]=${words_[j]}${COMP_WORDS[i]}
341
+ if [ $i = $COMP_CWORD ]; then
342
+ cword_=$j
343
+ fi
344
+ done
345
+ }
346
+
347
+ if ! type _get_comp_words_by_ref >/dev/null 2>&1; then
348
+ _get_comp_words_by_ref ()
349
+ {
350
+ local exclude cur_ words_ cword_
351
+ if [ "$1" = "-n" ]; then
352
+ exclude=$2
353
+ shift 2
354
+ fi
355
+ __git_reassemble_comp_words_by_ref "$exclude"
356
+ cur_=${words_[cword_]}
357
+ while [ $# -gt 0 ]; do
358
+ case "$1" in
359
+ cur)
360
+ cur=$cur_
361
+ ;;
362
+ prev)
363
+ prev=${words_[$cword_-1]}
364
+ ;;
365
+ words)
366
+ words=("${words_[@]}")
367
+ ;;
368
+ cword)
369
+ cword=$cword_
370
+ ;;
371
+ esac
372
+ shift
373
+ done
374
+ }
375
+ fi
376
+
377
+ # Fills the COMPREPLY array with prefiltered words without any additional
378
+ # processing.
379
+ # Callers must take care of providing only words that match the current word
380
+ # to be completed and adding any prefix and/or suffix (trailing space!), if
381
+ # necessary.
382
+ # 1: List of newline-separated matching completion words, complete with
383
+ # prefix and suffix.
384
+ __gitcomp_direct ()
385
+ {
386
+ local IFS=$'\n'
387
+
388
+ COMPREPLY=($1)
389
+ }
390
+
391
+ # Similar to __gitcomp_direct, but appends to COMPREPLY instead.
392
+ # Callers must take care of providing only words that match the current word
393
+ # to be completed and adding any prefix and/or suffix (trailing space!), if
394
+ # necessary.
395
+ # 1: List of newline-separated matching completion words, complete with
396
+ # prefix and suffix.
397
+ __gitcomp_direct_append ()
398
+ {
399
+ local IFS=$'\n'
400
+
401
+ COMPREPLY+=($1)
402
+ }
403
+
404
+ __gitcompappend ()
405
+ {
406
+ local x i=${#COMPREPLY[@]}
407
+ for x in $1; do
408
+ if [[ "$x" == "$3"* ]]; then
409
+ COMPREPLY[i++]="$2$x$4"
410
+ fi
411
+ done
412
+ }
413
+
414
+ __gitcompadd ()
415
+ {
416
+ COMPREPLY=()
417
+ __gitcompappend "$@"
418
+ }
419
+
420
+ # Generates completion reply, appending a space to possible completion words,
421
+ # if necessary.
422
+ # It accepts 1 to 4 arguments:
423
+ # 1: List of possible completion words.
424
+ # 2: A prefix to be added to each possible completion word (optional).
425
+ # 3: Generate possible completion matches for this word (optional).
426
+ # 4: A suffix to be appended to each possible completion word (optional).
427
+ __gitcomp ()
428
+ {
429
+ local cur_="${3-$cur}"
430
+
431
+ case "$cur_" in
432
+ *=)
433
+ ;;
434
+ --no-*)
435
+ local c i=0 IFS=$' \t\n'
436
+ for c in $1; do
437
+ if [[ $c == "--" ]]; then
438
+ continue
439
+ fi
440
+ c="$c${4-}"
441
+ if [[ $c == "$cur_"* ]]; then
442
+ case $c in
443
+ --*=|*.) ;;
444
+ *) c="$c " ;;
445
+ esac
446
+ COMPREPLY[i++]="${2-}$c"
447
+ fi
448
+ done
449
+ ;;
450
+ *)
451
+ local c i=0 IFS=$' \t\n'
452
+ for c in $1; do
453
+ if [[ $c == "--" ]]; then
454
+ c="--no-...${4-}"
455
+ if [[ $c == "$cur_"* ]]; then
456
+ COMPREPLY[i++]="${2-}$c "
457
+ fi
458
+ break
459
+ fi
460
+ c="$c${4-}"
461
+ if [[ $c == "$cur_"* ]]; then
462
+ case $c in
463
+ *=|*.) ;;
464
+ *) c="$c " ;;
465
+ esac
466
+ COMPREPLY[i++]="${2-}$c"
467
+ fi
468
+ done
469
+ ;;
470
+ esac
471
+ }
472
+
473
+ # Clear the variables caching builtins' options when (re-)sourcing
474
+ # the completion script.
475
+ if [[ -n ${ZSH_VERSION-} ]]; then
476
+ unset ${(M)${(k)parameters[@]}:#__gitcomp_builtin_*} 2>/dev/null
477
+ else
478
+ unset $(compgen -v __gitcomp_builtin_)
479
+ fi
480
+
481
+ # This function is equivalent to
482
+ #
483
+ # ___git_resolved_builtins=$(git xxx --git-completion-helper)
484
+ #
485
+ # except that the result of the execution is cached.
486
+ #
487
+ # Accept 1-3 arguments:
488
+ # 1: the git command to execute, this is also the cache key
489
+ # (use "_" when the command contains spaces, e.g. "remote add"
490
+ # becomes "remote_add")
491
+ # 2: extra options to be added on top (e.g. negative forms)
492
+ # 3: options to be excluded
493
+ __git_resolve_builtins ()
494
+ {
495
+ local cmd="$1"
496
+ local incl="${2-}"
497
+ local excl="${3-}"
498
+
499
+ local var=__gitcomp_builtin_"${cmd//-/_}"
500
+ local options
501
+ eval "options=\${$var-}"
502
+
503
+ if [ -z "$options" ]; then
504
+ local completion_helper
505
+ if [ "${GIT_COMPLETION_SHOW_ALL-}" = "1" ]; then
506
+ completion_helper="--git-completion-helper-all"
507
+ else
508
+ completion_helper="--git-completion-helper"
509
+ fi
510
+ # leading and trailing spaces are significant to make
511
+ # option removal work correctly.
512
+ options=" $incl $(__git ${cmd/_/ } $completion_helper) " || return
513
+
514
+ for i in $excl; do
515
+ options="${options/ $i / }"
516
+ done
517
+ eval "$var=\"$options\""
518
+ fi
519
+
520
+ ___git_resolved_builtins="$options"
521
+ }
522
+
523
+ # This function is equivalent to
524
+ #
525
+ # __gitcomp "$(git xxx --git-completion-helper) ..."
526
+ #
527
+ # except that the output is cached. Accept 1-3 arguments:
528
+ # 1: the git command to execute, this is also the cache key
529
+ # (use "_" when the command contains spaces, e.g. "remote add"
530
+ # becomes "remote_add")
531
+ # 2: extra options to be added on top (e.g. negative forms)
532
+ # 3: options to be excluded
533
+ __gitcomp_builtin ()
534
+ {
535
+ __git_resolve_builtins "$1" "$2" "$3"
536
+
537
+ __gitcomp "$___git_resolved_builtins"
538
+ }
539
+
540
+ # Variation of __gitcomp_nl () that appends to the existing list of
541
+ # completion candidates, COMPREPLY.
542
+ __gitcomp_nl_append ()
543
+ {
544
+ local IFS=$'\n'
545
+ __gitcompappend "$1" "${2-}" "${3-$cur}" "${4- }"
546
+ }
547
+
548
+ # Generates completion reply from newline-separated possible completion words
549
+ # by appending a space to all of them.
550
+ # It accepts 1 to 4 arguments:
551
+ # 1: List of possible completion words, separated by a single newline.
552
+ # 2: A prefix to be added to each possible completion word (optional).
553
+ # 3: Generate possible completion matches for this word (optional).
554
+ # 4: A suffix to be appended to each possible completion word instead of
555
+ # the default space (optional). If specified but empty, nothing is
556
+ # appended.
557
+ __gitcomp_nl ()
558
+ {
559
+ COMPREPLY=()
560
+ __gitcomp_nl_append "$@"
561
+ }
562
+
563
+ # Fills the COMPREPLY array with prefiltered paths without any additional
564
+ # processing.
565
+ # Callers must take care of providing only paths that match the current path
566
+ # to be completed and adding any prefix path components, if necessary.
567
+ # 1: List of newline-separated matching paths, complete with all prefix
568
+ # path components.
569
+ __gitcomp_file_direct ()
570
+ {
571
+ local IFS=$'\n'
572
+
573
+ COMPREPLY=($1)
574
+
575
+ # use a hack to enable file mode in bash < 4
576
+ compopt -o filenames +o nospace 2>/dev/null ||
577
+ compgen -f /non-existing-dir/ >/dev/null ||
578
+ true
579
+ }
580
+
581
+ # Generates completion reply with compgen from newline-separated possible
582
+ # completion filenames.
583
+ # It accepts 1 to 3 arguments:
584
+ # 1: List of possible completion filenames, separated by a single newline.
585
+ # 2: A directory prefix to be added to each possible completion filename
586
+ # (optional).
587
+ # 3: Generate possible completion matches for this word (optional).
588
+ __gitcomp_file ()
589
+ {
590
+ local IFS=$'\n'
591
+
592
+ # XXX does not work when the directory prefix contains a tilde,
593
+ # since tilde expansion is not applied.
594
+ # This means that COMPREPLY will be empty and Bash default
595
+ # completion will be used.
596
+ __gitcompadd "$1" "${2-}" "${3-$cur}" ""
597
+
598
+ # use a hack to enable file mode in bash < 4
599
+ compopt -o filenames +o nospace 2>/dev/null ||
600
+ compgen -f /non-existing-dir/ >/dev/null ||
601
+ true
602
+ }
603
+
604
+ # Find the current subcommand for commands that follow the syntax:
605
+ #
606
+ # git <command> <subcommand>
607
+ #
608
+ # 1: List of possible subcommands.
609
+ # 2: Optional subcommand to return when none is found.
610
+ __git_find_subcommand ()
611
+ {
612
+ local subcommand subcommands="$1" default_subcommand="$2"
613
+
614
+ for subcommand in $subcommands; do
615
+ if [ "$subcommand" = "${words[__git_cmd_idx+1]}" ]; then
616
+ echo $subcommand
617
+ return
618
+ fi
619
+ done
620
+
621
+ echo $default_subcommand
622
+ }
623
+
624
+ # Execute 'git ls-files', unless the --committable option is specified, in
625
+ # which case it runs 'git diff-index' to find out the files that can be
626
+ # committed. It return paths relative to the directory specified in the first
627
+ # argument, and using the options specified in the second argument.
628
+ __git_ls_files_helper ()
629
+ {
630
+ if [ "$2" = "--committable" ]; then
631
+ __git -C "$1" -c core.quotePath=false diff-index \
632
+ --name-only --relative HEAD -- "${3//\\/\\\\}*"
633
+ else
634
+ # NOTE: $2 is not quoted in order to support multiple options
635
+ __git -C "$1" -c core.quotePath=false ls-files \
636
+ --exclude-standard $2 -- "${3//\\/\\\\}*"
637
+ fi
638
+ }
639
+
640
+
641
+ # __git_index_files accepts 1 or 2 arguments:
642
+ # 1: Options to pass to ls-files (required).
643
+ # 2: A directory path (optional).
644
+ # If provided, only files within the specified directory are listed.
645
+ # Sub directories are never recursed. Path must have a trailing
646
+ # slash.
647
+ # 3: List only paths matching this path component (optional).
648
+ __git_index_files ()
649
+ {
650
+ local root="$2" match="$3"
651
+
652
+ __git_ls_files_helper "$root" "$1" "${match:-?}" |
653
+ awk -F / -v pfx="${2//\\/\\\\}" '{
654
+ paths[$1] = 1
655
+ }
656
+ END {
657
+ for (p in paths) {
658
+ if (substr(p, 1, 1) != "\"") {
659
+ # No special characters, easy!
660
+ print pfx p
661
+ continue
662
+ }
663
+
664
+ # The path is quoted.
665
+ p = dequote(p)
666
+ if (p == "")
667
+ continue
668
+
669
+ # Even when a directory name itself does not contain
670
+ # any special characters, it will still be quoted if
671
+ # any of its (stripped) trailing path components do.
672
+ # Because of this we may have seen the same directory
673
+ # both quoted and unquoted.
674
+ if (p in paths)
675
+ # We have seen the same directory unquoted,
676
+ # skip it.
677
+ continue
678
+ else
679
+ print pfx p
680
+ }
681
+ }
682
+ function dequote(p, bs_idx, out, esc, esc_idx, dec) {
683
+ # Skip opening double quote.
684
+ p = substr(p, 2)
685
+
686
+ # Interpret backslash escape sequences.
687
+ while ((bs_idx = index(p, "\\")) != 0) {
688
+ out = out substr(p, 1, bs_idx - 1)
689
+ esc = substr(p, bs_idx + 1, 1)
690
+ p = substr(p, bs_idx + 2)
691
+
692
+ if ((esc_idx = index("abtvfr\"\\", esc)) != 0) {
693
+ # C-style one-character escape sequence.
694
+ out = out substr("\a\b\t\v\f\r\"\\",
695
+ esc_idx, 1)
696
+ } else if (esc == "n") {
697
+ # Uh-oh, a newline character.
698
+ # We cannot reliably put a pathname
699
+ # containing a newline into COMPREPLY,
700
+ # and the newline would create a mess.
701
+ # Skip this path.
702
+ return ""
703
+ } else {
704
+ # Must be a \nnn octal value, then.
705
+ dec = esc * 64 + \
706
+ substr(p, 1, 1) * 8 + \
707
+ substr(p, 2, 1)
708
+ out = out sprintf("%c", dec)
709
+ p = substr(p, 3)
710
+ }
711
+ }
712
+ # Drop closing double quote, if there is one.
713
+ # (There is not any if this is a directory, as it was
714
+ # already stripped with the trailing path components.)
715
+ if (substr(p, length(p), 1) == "\"")
716
+ out = out substr(p, 1, length(p) - 1)
717
+ else
718
+ out = out p
719
+
720
+ return out
721
+ }'
722
+ }
723
+
724
+ # __git_complete_index_file requires 1 argument:
725
+ # 1: the options to pass to ls-file
726
+ #
727
+ # The exception is --committable, which finds the files appropriate commit.
728
+ __git_complete_index_file ()
729
+ {
730
+ local dequoted_word pfx="" cur_
731
+
732
+ __git_dequote "$cur"
733
+
734
+ case "$dequoted_word" in
735
+ ?*/*)
736
+ pfx="${dequoted_word%/*}/"
737
+ cur_="${dequoted_word##*/}"
738
+ ;;
739
+ *)
740
+ cur_="$dequoted_word"
741
+ esac
742
+
743
+ __gitcomp_file_direct "$(__git_index_files "$1" "$pfx" "$cur_")"
744
+ }
745
+
746
+ # Lists branches from the local repository.
747
+ # 1: A prefix to be added to each listed branch (optional).
748
+ # 2: List only branches matching this word (optional; list all branches if
749
+ # unset or empty).
750
+ # 3: A suffix to be appended to each listed branch (optional).
751
+ __git_heads ()
752
+ {
753
+ local pfx="${1-}" cur_="${2-}" sfx="${3-}"
754
+
755
+ __git for-each-ref --format="${pfx//\%/%%}%(refname:strip=2)$sfx" \
756
+ ${GIT_COMPLETION_IGNORE_CASE+--ignore-case} \
757
+ "refs/heads/$cur_*" "refs/heads/$cur_*/**"
758
+ }
759
+
760
+ # Lists branches from remote repositories.
761
+ # 1: A prefix to be added to each listed branch (optional).
762
+ # 2: List only branches matching this word (optional; list all branches if
763
+ # unset or empty).
764
+ # 3: A suffix to be appended to each listed branch (optional).
765
+ __git_remote_heads ()
766
+ {
767
+ local pfx="${1-}" cur_="${2-}" sfx="${3-}"
768
+
769
+ __git for-each-ref --format="${pfx//\%/%%}%(refname:strip=2)$sfx" \
770
+ ${GIT_COMPLETION_IGNORE_CASE+--ignore-case} \
771
+ "refs/remotes/$cur_*" "refs/remotes/$cur_*/**"
772
+ }
773
+
774
+ # Lists tags from the local repository.
775
+ # Accepts the same positional parameters as __git_heads() above.
776
+ __git_tags ()
777
+ {
778
+ local pfx="${1-}" cur_="${2-}" sfx="${3-}"
779
+
780
+ __git for-each-ref --format="${pfx//\%/%%}%(refname:strip=2)$sfx" \
781
+ ${GIT_COMPLETION_IGNORE_CASE+--ignore-case} \
782
+ "refs/tags/$cur_*" "refs/tags/$cur_*/**"
783
+ }
784
+
785
+ # List unique branches from refs/remotes used for 'git checkout' and 'git
786
+ # switch' tracking DWIMery.
787
+ # 1: A prefix to be added to each listed branch (optional)
788
+ # 2: List only branches matching this word (optional; list all branches if
789
+ # unset or empty).
790
+ # 3: A suffix to be appended to each listed branch (optional).
791
+ __git_dwim_remote_heads ()
792
+ {
793
+ local pfx="${1-}" cur_="${2-}" sfx="${3-}"
794
+
795
+ # employ the heuristic used by git checkout and git switch
796
+ # Try to find a remote branch that cur_es the completion word
797
+ # but only output if the branch name is unique
798
+ local awk_script='
799
+ function casemap(s) {
800
+ if (ENVIRON["IGNORE_CASE"])
801
+ return tolower(s)
802
+ else
803
+ return s
804
+ }
805
+ BEGIN {
806
+ split(ENVIRON["REMOTES"], remotes, /\n/)
807
+ for (i in remotes)
808
+ remotes[i] = "refs/remotes/" casemap(remotes[i])
809
+ cur_ = casemap(ENVIRON["CUR_"])
810
+ }
811
+ {
812
+ ref_case = casemap($0)
813
+ for (i in remotes) {
814
+ if (index(ref_case, remotes[i] "/" cur_) == 1) {
815
+ branch = substr($0, length(remotes[i] "/") + 1)
816
+ print ENVIRON["PFX"] branch ENVIRON["SFX"]
817
+ break
818
+ }
819
+ }
820
+ }
821
+ '
822
+ __git for-each-ref --format='%(refname)' refs/remotes/ |
823
+ PFX="$pfx" SFX="$sfx" CUR_="$cur_" \
824
+ IGNORE_CASE=${GIT_COMPLETION_IGNORE_CASE+1} \
825
+ REMOTES="$(__git_remotes | sort -r)" awk "$awk_script" |
826
+ sort | uniq -u
827
+ }
828
+
829
+ # Lists refs from the local (by default) or from a remote repository.
830
+ # It accepts 0, 1 or 2 arguments:
831
+ # 1: The remote to list refs from (optional; ignored, if set but empty).
832
+ # Can be the name of a configured remote, a path, or a URL.
833
+ # 2: In addition to local refs, list unique branches from refs/remotes/ for
834
+ # 'git checkout's tracking DWIMery (optional; ignored, if set but empty).
835
+ # 3: A prefix to be added to each listed ref (optional).
836
+ # 4: List only refs matching this word (optional; list all refs if unset or
837
+ # empty).
838
+ # 5: A suffix to be appended to each listed ref (optional; ignored, if set
839
+ # but empty).
840
+ #
841
+ # Use __git_complete_refs() instead.
842
+ __git_refs ()
843
+ {
844
+ local i hash dir track="${2-}"
845
+ local list_refs_from=path remote="${1-}"
846
+ local format refs
847
+ local pfx="${3-}" cur_="${4-$cur}" sfx="${5-}"
848
+ local match="${4-}"
849
+ local umatch="${4-}"
850
+ local fer_pfx="${pfx//\%/%%}" # "escape" for-each-ref format specifiers
851
+
852
+ __git_find_repo_path
853
+ dir="$__git_repo_path"
854
+
855
+ if [ -z "$remote" ]; then
856
+ if [ -z "$dir" ]; then
857
+ return
858
+ fi
859
+ else
860
+ if __git_is_configured_remote "$remote"; then
861
+ # configured remote takes precedence over a
862
+ # local directory with the same name
863
+ list_refs_from=remote
864
+ elif [ -d "$remote/.git" ]; then
865
+ dir="$remote/.git"
866
+ elif [ -d "$remote" ]; then
867
+ dir="$remote"
868
+ else
869
+ list_refs_from=url
870
+ fi
871
+ fi
872
+
873
+ if test "${GIT_COMPLETION_IGNORE_CASE:+1}" = "1"
874
+ then
875
+ # uppercase with tr instead of ${match,^^} for bash 3.2 compatibility
876
+ umatch=$(echo "$match" | tr a-z A-Z 2>/dev/null || echo "$match")
877
+ fi
878
+
879
+ if [ "$list_refs_from" = path ]; then
880
+ if [[ "$cur_" == ^* ]]; then
881
+ pfx="$pfx^"
882
+ fer_pfx="$fer_pfx^"
883
+ cur_=${cur_#^}
884
+ match=${match#^}
885
+ umatch=${umatch#^}
886
+ fi
887
+ case "$cur_" in
888
+ refs|refs/*)
889
+ format="refname"
890
+ refs=("$match*" "$match*/**")
891
+ track=""
892
+ ;;
893
+ *)
894
+ for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD REBASE_HEAD CHERRY_PICK_HEAD REVERT_HEAD BISECT_HEAD AUTO_MERGE; do
895
+ case "$i" in
896
+ $match*|$umatch*)
897
+ if [ -e "$dir/$i" ]; then
898
+ echo "$pfx$i$sfx"
899
+ fi
900
+ ;;
901
+ esac
902
+ done
903
+ format="refname:strip=2"
904
+ refs=("refs/tags/$match*" "refs/tags/$match*/**"
905
+ "refs/heads/$match*" "refs/heads/$match*/**"
906
+ "refs/remotes/$match*" "refs/remotes/$match*/**")
907
+ ;;
908
+ esac
909
+ __git_dir="$dir" __git for-each-ref --format="$fer_pfx%($format)$sfx" \
910
+ ${GIT_COMPLETION_IGNORE_CASE+--ignore-case} \
911
+ "${refs[@]}"
912
+ if [ -n "$track" ]; then
913
+ __git_dwim_remote_heads "$pfx" "$match" "$sfx"
914
+ fi
915
+ return
916
+ fi
917
+ case "$cur_" in
918
+ refs|refs/*)
919
+ __git ls-remote "$remote" "$match*" | \
920
+ while read -r hash i; do
921
+ case "$i" in
922
+ *^{}) ;;
923
+ *) echo "$pfx$i$sfx" ;;
924
+ esac
925
+ done
926
+ ;;
927
+ *)
928
+ if [ "$list_refs_from" = remote ]; then
929
+ case "HEAD" in
930
+ $match*|$umatch*) echo "${pfx}HEAD$sfx" ;;
931
+ esac
932
+ local strip="$(__git_count_path_components "refs/remotes/$remote")"
933
+ __git for-each-ref --format="$fer_pfx%(refname:strip=$strip)$sfx" \
934
+ ${GIT_COMPLETION_IGNORE_CASE+--ignore-case} \
935
+ "refs/remotes/$remote/$match*" \
936
+ "refs/remotes/$remote/$match*/**"
937
+ else
938
+ local query_symref
939
+ case "HEAD" in
940
+ $match*|$umatch*) query_symref="HEAD" ;;
941
+ esac
942
+ __git ls-remote "$remote" $query_symref \
943
+ "refs/tags/$match*" "refs/heads/$match*" \
944
+ "refs/remotes/$match*" |
945
+ while read -r hash i; do
946
+ case "$i" in
947
+ *^{}) ;;
948
+ refs/*) echo "$pfx${i#refs/*/}$sfx" ;;
949
+ *) echo "$pfx$i$sfx" ;; # symbolic refs
950
+ esac
951
+ done
952
+ fi
953
+ ;;
954
+ esac
955
+ }
956
+
957
+ # Completes refs, short and long, local and remote, symbolic and pseudo.
958
+ #
959
+ # Usage: __git_complete_refs [<option>]...
960
+ # --remote=<remote>: The remote to list refs from, can be the name of a
961
+ # configured remote, a path, or a URL.
962
+ # --dwim: List unique remote branches for 'git switch's tracking DWIMery.
963
+ # --pfx=<prefix>: A prefix to be added to each ref.
964
+ # --cur=<word>: The current ref to be completed. Defaults to the current
965
+ # word to be completed.
966
+ # --sfx=<suffix>: A suffix to be appended to each ref instead of the default
967
+ # space.
968
+ # --mode=<mode>: What set of refs to complete, one of 'refs' (the default) to
969
+ # complete all refs, 'heads' to complete only branches, or
970
+ # 'remote-heads' to complete only remote branches. Note that
971
+ # --remote is only compatible with --mode=refs.
972
+ __git_complete_refs ()
973
+ {
974
+ local remote= dwim= pfx= cur_="$cur" sfx=" " mode="refs"
975
+
976
+ while test $# != 0; do
977
+ case "$1" in
978
+ --remote=*) remote="${1##--remote=}" ;;
979
+ --dwim) dwim="yes" ;;
980
+ # --track is an old spelling of --dwim
981
+ --track) dwim="yes" ;;
982
+ --pfx=*) pfx="${1##--pfx=}" ;;
983
+ --cur=*) cur_="${1##--cur=}" ;;
984
+ --sfx=*) sfx="${1##--sfx=}" ;;
985
+ --mode=*) mode="${1##--mode=}" ;;
986
+ *) return 1 ;;
987
+ esac
988
+ shift
989
+ done
990
+
991
+ # complete references based on the specified mode
992
+ case "$mode" in
993
+ refs)
994
+ __gitcomp_direct "$(__git_refs "$remote" "" "$pfx" "$cur_" "$sfx")" ;;
995
+ heads)
996
+ __gitcomp_direct "$(__git_heads "$pfx" "$cur_" "$sfx")" ;;
997
+ remote-heads)
998
+ __gitcomp_direct "$(__git_remote_heads "$pfx" "$cur_" "$sfx")" ;;
999
+ *)
1000
+ return 1 ;;
1001
+ esac
1002
+
1003
+ # Append DWIM remote branch names if requested
1004
+ if [ "$dwim" = "yes" ]; then
1005
+ __gitcomp_direct_append "$(__git_dwim_remote_heads "$pfx" "$cur_" "$sfx")"
1006
+ fi
1007
+ }
1008
+
1009
+ # __git_refs2 requires 1 argument (to pass to __git_refs)
1010
+ # Deprecated: use __git_complete_fetch_refspecs() instead.
1011
+ __git_refs2 ()
1012
+ {
1013
+ local i
1014
+ for i in $(__git_refs "$1"); do
1015
+ echo "$i:$i"
1016
+ done
1017
+ }
1018
+
1019
+ # Completes refspecs for fetching from a remote repository.
1020
+ # 1: The remote repository.
1021
+ # 2: A prefix to be added to each listed refspec (optional).
1022
+ # 3: The ref to be completed as a refspec instead of the current word to be
1023
+ # completed (optional)
1024
+ # 4: A suffix to be appended to each listed refspec instead of the default
1025
+ # space (optional).
1026
+ __git_complete_fetch_refspecs ()
1027
+ {
1028
+ local i remote="$1" pfx="${2-}" cur_="${3-$cur}" sfx="${4- }"
1029
+
1030
+ __gitcomp_direct "$(
1031
+ for i in $(__git_refs "$remote" "" "" "$cur_") ; do
1032
+ echo "$pfx$i:$i$sfx"
1033
+ done
1034
+ )"
1035
+ }
1036
+
1037
+ # __git_refs_remotes requires 1 argument (to pass to ls-remote)
1038
+ __git_refs_remotes ()
1039
+ {
1040
+ local i hash
1041
+ __git ls-remote "$1" 'refs/heads/*' | \
1042
+ while read -r hash i; do
1043
+ echo "$i:refs/remotes/$1/${i#refs/heads/}"
1044
+ done
1045
+ }
1046
+
1047
+ __git_remotes ()
1048
+ {
1049
+ __git_find_repo_path
1050
+ test -d "$__git_repo_path/remotes" && ls -1 "$__git_repo_path/remotes"
1051
+ __git remote
1052
+ }
1053
+
1054
+ # Returns true if $1 matches the name of a configured remote, false otherwise.
1055
+ __git_is_configured_remote ()
1056
+ {
1057
+ local remote
1058
+ for remote in $(__git_remotes); do
1059
+ if [ "$remote" = "$1" ]; then
1060
+ return 0
1061
+ fi
1062
+ done
1063
+ return 1
1064
+ }
1065
+
1066
+ __git_list_merge_strategies ()
1067
+ {
1068
+ LANG=C LC_ALL=C git merge -s help 2>&1 |
1069
+ sed -n -e '/[Aa]vailable strategies are: /,/^$/{
1070
+ s/\.$//
1071
+ s/.*://
1072
+ s/^[ ]*//
1073
+ s/[ ]*$//
1074
+ p
1075
+ }'
1076
+ }
1077
+
1078
+ __git_merge_strategies=
1079
+ # 'git merge -s help' (and thus detection of the merge strategy
1080
+ # list) fails, unfortunately, if run outside of any git working
1081
+ # tree. __git_merge_strategies is set to the empty string in
1082
+ # that case, and the detection will be repeated the next time it
1083
+ # is needed.
1084
+ __git_compute_merge_strategies ()
1085
+ {
1086
+ test -n "$__git_merge_strategies" ||
1087
+ __git_merge_strategies=$(__git_list_merge_strategies)
1088
+ }
1089
+
1090
+ __git_merge_strategy_options="ours theirs subtree subtree= patience
1091
+ histogram diff-algorithm= ignore-space-change ignore-all-space
1092
+ ignore-space-at-eol renormalize no-renormalize no-renames
1093
+ find-renames find-renames= rename-threshold="
1094
+
1095
+ __git_complete_revlist_file ()
1096
+ {
1097
+ local dequoted_word pfx ls ref cur_="$cur"
1098
+ case "$cur_" in
1099
+ *..?*:*)
1100
+ return
1101
+ ;;
1102
+ ?*:*)
1103
+ ref="${cur_%%:*}"
1104
+ cur_="${cur_#*:}"
1105
+
1106
+ __git_dequote "$cur_"
1107
+
1108
+ case "$dequoted_word" in
1109
+ ?*/*)
1110
+ pfx="${dequoted_word%/*}"
1111
+ cur_="${dequoted_word##*/}"
1112
+ ls="$ref:$pfx"
1113
+ pfx="$pfx/"
1114
+ ;;
1115
+ *)
1116
+ cur_="$dequoted_word"
1117
+ ls="$ref"
1118
+ ;;
1119
+ esac
1120
+
1121
+ case "$COMP_WORDBREAKS" in
1122
+ *:*) : great ;;
1123
+ *) pfx="$ref:$pfx" ;;
1124
+ esac
1125
+
1126
+ __gitcomp_file "$(__git ls-tree "$ls" \
1127
+ | sed 's/^.* //
1128
+ s/$//')" \
1129
+ "$pfx" "$cur_"
1130
+ ;;
1131
+ *...*)
1132
+ pfx="${cur_%...*}..."
1133
+ cur_="${cur_#*...}"
1134
+ __git_complete_refs --pfx="$pfx" --cur="$cur_"
1135
+ ;;
1136
+ *..*)
1137
+ pfx="${cur_%..*}.."
1138
+ cur_="${cur_#*..}"
1139
+ __git_complete_refs --pfx="$pfx" --cur="$cur_"
1140
+ ;;
1141
+ *)
1142
+ __git_complete_refs
1143
+ ;;
1144
+ esac
1145
+ }
1146
+
1147
+ __git_complete_file ()
1148
+ {
1149
+ __git_complete_revlist_file
1150
+ }
1151
+
1152
+ __git_complete_revlist ()
1153
+ {
1154
+ __git_complete_revlist_file
1155
+ }
1156
+
1157
+ __git_complete_remote_or_refspec ()
1158
+ {
1159
+ local cur_="$cur" cmd="${words[__git_cmd_idx]}"
1160
+ local i c=$((__git_cmd_idx+1)) remote="" pfx="" lhs=1 no_complete_refspec=0
1161
+ if [ "$cmd" = "remote" ]; then
1162
+ ((c++))
1163
+ fi
1164
+ while [ $c -lt $cword ]; do
1165
+ i="${words[c]}"
1166
+ case "$i" in
1167
+ --mirror) [ "$cmd" = "push" ] && no_complete_refspec=1 ;;
1168
+ -d|--delete) [ "$cmd" = "push" ] && lhs=0 ;;
1169
+ --all)
1170
+ case "$cmd" in
1171
+ push) no_complete_refspec=1 ;;
1172
+ fetch)
1173
+ return
1174
+ ;;
1175
+ *) ;;
1176
+ esac
1177
+ ;;
1178
+ --multiple) no_complete_refspec=1; break ;;
1179
+ -*) ;;
1180
+ *) remote="$i"; break ;;
1181
+ esac
1182
+ ((c++))
1183
+ done
1184
+ if [ -z "$remote" ]; then
1185
+ __gitcomp_nl "$(__git_remotes)"
1186
+ return
1187
+ fi
1188
+ if [ $no_complete_refspec = 1 ]; then
1189
+ return
1190
+ fi
1191
+ [ "$remote" = "." ] && remote=
1192
+ case "$cur_" in
1193
+ *:*)
1194
+ case "$COMP_WORDBREAKS" in
1195
+ *:*) : great ;;
1196
+ *) pfx="${cur_%%:*}:" ;;
1197
+ esac
1198
+ cur_="${cur_#*:}"
1199
+ lhs=0
1200
+ ;;
1201
+ +*)
1202
+ pfx="+"
1203
+ cur_="${cur_#+}"
1204
+ ;;
1205
+ esac
1206
+ case "$cmd" in
1207
+ fetch)
1208
+ if [ $lhs = 1 ]; then
1209
+ __git_complete_fetch_refspecs "$remote" "$pfx" "$cur_"
1210
+ else
1211
+ __git_complete_refs --pfx="$pfx" --cur="$cur_"
1212
+ fi
1213
+ ;;
1214
+ pull|remote)
1215
+ if [ $lhs = 1 ]; then
1216
+ __git_complete_refs --remote="$remote" --pfx="$pfx" --cur="$cur_"
1217
+ else
1218
+ __git_complete_refs --pfx="$pfx" --cur="$cur_"
1219
+ fi
1220
+ ;;
1221
+ push)
1222
+ if [ $lhs = 1 ]; then
1223
+ __git_complete_refs --pfx="$pfx" --cur="$cur_"
1224
+ else
1225
+ __git_complete_refs --remote="$remote" --pfx="$pfx" --cur="$cur_"
1226
+ fi
1227
+ ;;
1228
+ esac
1229
+ }
1230
+
1231
+ __git_complete_strategy ()
1232
+ {
1233
+ __git_compute_merge_strategies
1234
+ case "$prev" in
1235
+ -s|--strategy)
1236
+ __gitcomp "$__git_merge_strategies"
1237
+ return 0
1238
+ ;;
1239
+ -X)
1240
+ __gitcomp "$__git_merge_strategy_options"
1241
+ return 0
1242
+ ;;
1243
+ esac
1244
+ case "$cur" in
1245
+ --strategy=*)
1246
+ __gitcomp "$__git_merge_strategies" "" "${cur##--strategy=}"
1247
+ return 0
1248
+ ;;
1249
+ --strategy-option=*)
1250
+ __gitcomp "$__git_merge_strategy_options" "" "${cur##--strategy-option=}"
1251
+ return 0
1252
+ ;;
1253
+ esac
1254
+ return 1
1255
+ }
1256
+
1257
+ __git_all_commands=
1258
+ __git_compute_all_commands ()
1259
+ {
1260
+ test -n "$__git_all_commands" ||
1261
+ __git_all_commands=$(__git --list-cmds=main,others,alias,nohelpers)
1262
+ }
1263
+
1264
+ # Lists all set config variables starting with the given section prefix,
1265
+ # with the prefix removed.
1266
+ __git_get_config_variables ()
1267
+ {
1268
+ local section="$1" i IFS=$'\n'
1269
+ for i in $(__git config --name-only --get-regexp "^$section\..*"); do
1270
+ echo "${i#$section.}"
1271
+ done
1272
+ }
1273
+
1274
+ __git_pretty_aliases ()
1275
+ {
1276
+ __git_get_config_variables "pretty"
1277
+ }
1278
+
1279
+ # __git_aliased_command requires 1 argument
1280
+ __git_aliased_command ()
1281
+ {
1282
+ local cur=$1 last list= word cmdline
1283
+
1284
+ while [[ -n "$cur" ]]; do
1285
+ if [[ "$list" == *" $cur "* ]]; then
1286
+ # loop detected
1287
+ return
1288
+ fi
1289
+
1290
+ cmdline=$(__git config --get "alias.$cur")
1291
+ list=" $cur $list"
1292
+ last=$cur
1293
+ cur=
1294
+
1295
+ for word in $cmdline; do
1296
+ case "$word" in
1297
+ \!gitk|gitk)
1298
+ cur="gitk"
1299
+ break
1300
+ ;;
1301
+ \!*) : shell command alias ;;
1302
+ -*) : option ;;
1303
+ *=*) : setting env ;;
1304
+ git) : git itself ;;
1305
+ \(\)) : skip parens of shell function definition ;;
1306
+ {) : skip start of shell helper function ;;
1307
+ :) : skip null command ;;
1308
+ \'*) : skip opening quote after sh -c ;;
1309
+ *)
1310
+ cur="${word%;}"
1311
+ break
1312
+ esac
1313
+ done
1314
+ done
1315
+
1316
+ cur=$last
1317
+ if [[ "$cur" != "$1" ]]; then
1318
+ echo "$cur"
1319
+ fi
1320
+ }
1321
+
1322
+ # Check whether one of the given words is present on the command line,
1323
+ # and print the first word found.
1324
+ #
1325
+ # Usage: __git_find_on_cmdline [<option>]... "<wordlist>"
1326
+ # --show-idx: Optionally show the index of the found word in the $words array.
1327
+ __git_find_on_cmdline ()
1328
+ {
1329
+ local word c="$__git_cmd_idx" show_idx
1330
+
1331
+ while test $# -gt 1; do
1332
+ case "$1" in
1333
+ --show-idx) show_idx=y ;;
1334
+ *) return 1 ;;
1335
+ esac
1336
+ shift
1337
+ done
1338
+ local wordlist="$1"
1339
+
1340
+ while [ $c -lt $cword ]; do
1341
+ for word in $wordlist; do
1342
+ if [ "$word" = "${words[c]}" ]; then
1343
+ if [ -n "${show_idx-}" ]; then
1344
+ echo "$c $word"
1345
+ else
1346
+ echo "$word"
1347
+ fi
1348
+ return
1349
+ fi
1350
+ done
1351
+ ((c++))
1352
+ done
1353
+ }
1354
+
1355
+ # Similar to __git_find_on_cmdline, except that it loops backwards and thus
1356
+ # prints the *last* word found. Useful for finding which of two options that
1357
+ # supersede each other came last, such as "--guess" and "--no-guess".
1358
+ #
1359
+ # Usage: __git_find_last_on_cmdline [<option>]... "<wordlist>"
1360
+ # --show-idx: Optionally show the index of the found word in the $words array.
1361
+ __git_find_last_on_cmdline ()
1362
+ {
1363
+ local word c=$cword show_idx
1364
+
1365
+ while test $# -gt 1; do
1366
+ case "$1" in
1367
+ --show-idx) show_idx=y ;;
1368
+ *) return 1 ;;
1369
+ esac
1370
+ shift
1371
+ done
1372
+ local wordlist="$1"
1373
+
1374
+ while [ $c -gt "$__git_cmd_idx" ]; do
1375
+ ((c--))
1376
+ for word in $wordlist; do
1377
+ if [ "$word" = "${words[c]}" ]; then
1378
+ if [ -n "$show_idx" ]; then
1379
+ echo "$c $word"
1380
+ else
1381
+ echo "$word"
1382
+ fi
1383
+ return
1384
+ fi
1385
+ done
1386
+ done
1387
+ }
1388
+
1389
+ # Echo the value of an option set on the command line or config
1390
+ #
1391
+ # $1: short option name
1392
+ # $2: long option name including =
1393
+ # $3: list of possible values
1394
+ # $4: config string (optional)
1395
+ #
1396
+ # example:
1397
+ # result="$(__git_get_option_value "-d" "--do-something=" \
1398
+ # "yes no" "core.doSomething")"
1399
+ #
1400
+ # result is then either empty (no option set) or "yes" or "no"
1401
+ #
1402
+ # __git_get_option_value requires 3 arguments
1403
+ __git_get_option_value ()
1404
+ {
1405
+ local c short_opt long_opt val
1406
+ local result= values config_key word
1407
+
1408
+ short_opt="$1"
1409
+ long_opt="$2"
1410
+ values="$3"
1411
+ config_key="$4"
1412
+
1413
+ ((c = $cword - 1))
1414
+ while [ $c -ge 0 ]; do
1415
+ word="${words[c]}"
1416
+ for val in $values; do
1417
+ if [ "$short_opt$val" = "$word" ] ||
1418
+ [ "$long_opt$val" = "$word" ]; then
1419
+ result="$val"
1420
+ break 2
1421
+ fi
1422
+ done
1423
+ ((c--))
1424
+ done
1425
+
1426
+ if [ -n "$config_key" ] && [ -z "$result" ]; then
1427
+ result="$(__git config "$config_key")"
1428
+ fi
1429
+
1430
+ echo "$result"
1431
+ }
1432
+
1433
+ __git_has_doubledash ()
1434
+ {
1435
+ local c=1
1436
+ while [ $c -lt $cword ]; do
1437
+ if [ "--" = "${words[c]}" ]; then
1438
+ return 0
1439
+ fi
1440
+ ((c++))
1441
+ done
1442
+ return 1
1443
+ }
1444
+
1445
+ # Try to count non option arguments passed on the command line for the
1446
+ # specified git command.
1447
+ # When options are used, it is necessary to use the special -- option to
1448
+ # tell the implementation were non option arguments begin.
1449
+ # XXX this can not be improved, since options can appear everywhere, as
1450
+ # an example:
1451
+ # git mv x -n y
1452
+ #
1453
+ # __git_count_arguments requires 1 argument: the git command executed.
1454
+ __git_count_arguments ()
1455
+ {
1456
+ local word i c=0
1457
+
1458
+ # Skip "git" (first argument)
1459
+ for ((i=$__git_cmd_idx; i < ${#words[@]}; i++)); do
1460
+ word="${words[i]}"
1461
+
1462
+ case "$word" in
1463
+ --)
1464
+ # Good; we can assume that the following are only non
1465
+ # option arguments.
1466
+ ((c = 0))
1467
+ ;;
1468
+ "$1")
1469
+ # Skip the specified git command and discard git
1470
+ # main options
1471
+ ((c = 0))
1472
+ ;;
1473
+ ?*)
1474
+ ((c++))
1475
+ ;;
1476
+ esac
1477
+ done
1478
+
1479
+ printf "%d" $c
1480
+ }
1481
+
1482
+ __git_whitespacelist="nowarn warn error error-all fix"
1483
+ __git_patchformat="mbox stgit stgit-series hg mboxrd"
1484
+ __git_showcurrentpatch="diff raw"
1485
+ __git_am_inprogress_options="--skip --continue --resolved --abort --quit --show-current-patch"
1486
+ __git_quoted_cr="nowarn warn strip"
1487
+
1488
+ _git_am ()
1489
+ {
1490
+ __git_find_repo_path
1491
+ if [ -d "$__git_repo_path"/rebase-apply ]; then
1492
+ __gitcomp "$__git_am_inprogress_options"
1493
+ return
1494
+ fi
1495
+ case "$cur" in
1496
+ --whitespace=*)
1497
+ __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
1498
+ return
1499
+ ;;
1500
+ --patch-format=*)
1501
+ __gitcomp "$__git_patchformat" "" "${cur##--patch-format=}"
1502
+ return
1503
+ ;;
1504
+ --show-current-patch=*)
1505
+ __gitcomp "$__git_showcurrentpatch" "" "${cur##--show-current-patch=}"
1506
+ return
1507
+ ;;
1508
+ --quoted-cr=*)
1509
+ __gitcomp "$__git_quoted_cr" "" "${cur##--quoted-cr=}"
1510
+ return
1511
+ ;;
1512
+ --*)
1513
+ __gitcomp_builtin am "" \
1514
+ "$__git_am_inprogress_options"
1515
+ return
1516
+ esac
1517
+ }
1518
+
1519
+ _git_apply ()
1520
+ {
1521
+ case "$cur" in
1522
+ --whitespace=*)
1523
+ __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
1524
+ return
1525
+ ;;
1526
+ --*)
1527
+ __gitcomp_builtin apply
1528
+ return
1529
+ esac
1530
+ }
1531
+
1532
+ _git_add ()
1533
+ {
1534
+ case "$cur" in
1535
+ --chmod=*)
1536
+ __gitcomp "+x -x" "" "${cur##--chmod=}"
1537
+ return
1538
+ ;;
1539
+ --*)
1540
+ __gitcomp_builtin add
1541
+ return
1542
+ esac
1543
+
1544
+ local complete_opt="--others --modified --directory --no-empty-directory"
1545
+ if test -n "$(__git_find_on_cmdline "-u --update")"
1546
+ then
1547
+ complete_opt="--modified"
1548
+ fi
1549
+ __git_complete_index_file "$complete_opt"
1550
+ }
1551
+
1552
+ _git_archive ()
1553
+ {
1554
+ case "$cur" in
1555
+ --format=*)
1556
+ __gitcomp "$(git archive --list)" "" "${cur##--format=}"
1557
+ return
1558
+ ;;
1559
+ --remote=*)
1560
+ __gitcomp_nl "$(__git_remotes)" "" "${cur##--remote=}"
1561
+ return
1562
+ ;;
1563
+ --*)
1564
+ __gitcomp_builtin archive "--format= --list --verbose --prefix= --worktree-attributes"
1565
+ return
1566
+ ;;
1567
+ esac
1568
+ __git_complete_file
1569
+ }
1570
+
1571
+ _git_bisect ()
1572
+ {
1573
+ __git_has_doubledash && return
1574
+
1575
+ __git_find_repo_path
1576
+
1577
+ # If a bisection is in progress get the terms being used.
1578
+ local term_bad term_good
1579
+ if [ -f "$__git_repo_path"/BISECT_TERMS ]; then
1580
+ term_bad=$(__git bisect terms --term-bad)
1581
+ term_good=$(__git bisect terms --term-good)
1582
+ fi
1583
+
1584
+ # We will complete any custom terms, but still always complete the
1585
+ # more usual bad/new/good/old because git bisect gives a good error
1586
+ # message if these are given when not in use, and that's better than
1587
+ # silent refusal to complete if the user is confused.
1588
+ #
1589
+ # We want to recognize 'view' but not complete it, because it overlaps
1590
+ # with 'visualize' too much and is just an alias for it.
1591
+ #
1592
+ local completable_subcommands="start bad new $term_bad good old $term_good terms skip reset visualize replay log run help"
1593
+ local all_subcommands="$completable_subcommands view"
1594
+
1595
+ local subcommand="$(__git_find_on_cmdline "$all_subcommands")"
1596
+
1597
+ if [ -z "$subcommand" ]; then
1598
+ __git_find_repo_path
1599
+ if [ -f "$__git_repo_path"/BISECT_START ]; then
1600
+ __gitcomp "$completable_subcommands"
1601
+ else
1602
+ __gitcomp "replay start"
1603
+ fi
1604
+ return
1605
+ fi
1606
+
1607
+ case "$subcommand" in
1608
+ start)
1609
+ case "$cur" in
1610
+ --*)
1611
+ __gitcomp "--first-parent --no-checkout --term-new --term-bad --term-old --term-good"
1612
+ return
1613
+ ;;
1614
+ *)
1615
+ __git_complete_refs
1616
+ ;;
1617
+ esac
1618
+ ;;
1619
+ terms)
1620
+ __gitcomp "--term-good --term-old --term-bad --term-new"
1621
+ return
1622
+ ;;
1623
+ visualize|view)
1624
+ __git_complete_log_opts
1625
+ return
1626
+ ;;
1627
+ bad|new|"$term_bad"|good|old|"$term_good"|reset|skip)
1628
+ __git_complete_refs
1629
+ ;;
1630
+ *)
1631
+ ;;
1632
+ esac
1633
+ }
1634
+
1635
+ __git_ref_fieldlist="refname objecttype objectsize objectname upstream push HEAD symref"
1636
+
1637
+ _git_branch ()
1638
+ {
1639
+ local i c="$__git_cmd_idx" only_local_ref="n" has_r="n"
1640
+
1641
+ while [ $c -lt $cword ]; do
1642
+ i="${words[c]}"
1643
+ case "$i" in
1644
+ -d|-D|--delete|-m|-M|--move|-c|-C|--copy)
1645
+ only_local_ref="y" ;;
1646
+ -r|--remotes)
1647
+ has_r="y" ;;
1648
+ esac
1649
+ ((c++))
1650
+ done
1651
+
1652
+ case "$cur" in
1653
+ --set-upstream-to=*)
1654
+ __git_complete_refs --cur="${cur##--set-upstream-to=}"
1655
+ ;;
1656
+ --*)
1657
+ __gitcomp_builtin branch
1658
+ ;;
1659
+ *)
1660
+ if [ $only_local_ref = "y" -a $has_r = "n" ]; then
1661
+ __gitcomp_direct "$(__git_heads "" "$cur" " ")"
1662
+ else
1663
+ __git_complete_refs
1664
+ fi
1665
+ ;;
1666
+ esac
1667
+ }
1668
+
1669
+ _git_bundle ()
1670
+ {
1671
+ local cmd="${words[__git_cmd_idx+1]}"
1672
+ case "$cword" in
1673
+ $((__git_cmd_idx+1)))
1674
+ __gitcomp "create list-heads verify unbundle"
1675
+ ;;
1676
+ $((__git_cmd_idx+2)))
1677
+ # looking for a file
1678
+ ;;
1679
+ *)
1680
+ case "$cmd" in
1681
+ create)
1682
+ __git_complete_revlist
1683
+ ;;
1684
+ esac
1685
+ ;;
1686
+ esac
1687
+ }
1688
+
1689
+ # Helper function to decide whether or not we should enable DWIM logic for
1690
+ # git-switch and git-checkout.
1691
+ #
1692
+ # To decide between the following rules in decreasing priority order:
1693
+ # - the last provided of "--guess" or "--no-guess" explicitly enable or
1694
+ # disable completion of DWIM logic respectively.
1695
+ # - If checkout.guess is false, disable completion of DWIM logic.
1696
+ # - If the --no-track option is provided, take this as a hint to disable the
1697
+ # DWIM completion logic
1698
+ # - If GIT_COMPLETION_CHECKOUT_NO_GUESS is set, disable the DWIM completion
1699
+ # logic, as requested by the user.
1700
+ # - Enable DWIM logic otherwise.
1701
+ #
1702
+ __git_checkout_default_dwim_mode ()
1703
+ {
1704
+ local last_option dwim_opt="--dwim"
1705
+
1706
+ if [ "${GIT_COMPLETION_CHECKOUT_NO_GUESS-}" = "1" ]; then
1707
+ dwim_opt=""
1708
+ fi
1709
+
1710
+ # --no-track disables DWIM, but with lower priority than
1711
+ # --guess/--no-guess/checkout.guess
1712
+ if [ -n "$(__git_find_on_cmdline "--no-track")" ]; then
1713
+ dwim_opt=""
1714
+ fi
1715
+
1716
+ # checkout.guess = false disables DWIM, but with lower priority than
1717
+ # --guess/--no-guess
1718
+ if [ "$(__git config --type=bool checkout.guess)" = "false" ]; then
1719
+ dwim_opt=""
1720
+ fi
1721
+
1722
+ # Find the last provided --guess or --no-guess
1723
+ last_option="$(__git_find_last_on_cmdline "--guess --no-guess")"
1724
+ case "$last_option" in
1725
+ --guess)
1726
+ dwim_opt="--dwim"
1727
+ ;;
1728
+ --no-guess)
1729
+ dwim_opt=""
1730
+ ;;
1731
+ esac
1732
+
1733
+ echo "$dwim_opt"
1734
+ }
1735
+
1736
+ _git_checkout ()
1737
+ {
1738
+ if ! __git_has_doubledash; then
1739
+ local dwim_opt="$(__git_checkout_default_dwim_mode)"
1740
+
1741
+ case "$prev" in
1742
+ -b|-B|--orphan)
1743
+ # Complete local branches (and DWIM branch
1744
+ # remote branch names) for an option argument
1745
+ # specifying a new branch name. This is for
1746
+ # convenience, assuming new branches are
1747
+ # possibly based on pre-existing branch names.
1748
+ __git_complete_refs $dwim_opt --mode="heads"
1749
+ return
1750
+ ;;
1751
+ *)
1752
+ ;;
1753
+ esac
1754
+
1755
+ case "$cur" in
1756
+ --conflict=*)
1757
+ __gitcomp "diff3 merge zdiff3" "" "${cur##--conflict=}"
1758
+ return
1759
+ ;;
1760
+ --*)
1761
+ __gitcomp_builtin checkout
1762
+ return
1763
+ ;;
1764
+ *)
1765
+ # At this point, we've already handled special completion for
1766
+ # the arguments to -b/-B, and --orphan. There are 3 main
1767
+ # things left we can possibly complete:
1768
+ # 1) a start-point for -b/-B, -d/--detach, or --orphan
1769
+ # 2) a remote head, for --track
1770
+ # 3) an arbitrary reference, possibly including DWIM names
1771
+ #
1772
+
1773
+ if [ -n "$(__git_find_on_cmdline "-b -B -d --detach --orphan")" ]; then
1774
+ __git_complete_refs --mode="refs"
1775
+ elif [ -n "$(__git_find_on_cmdline "-t --track")" ]; then
1776
+ __git_complete_refs --mode="remote-heads"
1777
+ else
1778
+ __git_complete_refs $dwim_opt --mode="refs"
1779
+ fi
1780
+ ;;
1781
+ esac
1782
+ fi
1783
+
1784
+ if [ ${#COMPREPLY[@]} -eq 0 ]; then
1785
+ __git_complete_index_file ""
1786
+ fi
1787
+
1788
+ if [ ${#COMPREPLY[@]} -eq 0 ]; then
1789
+ __git_complete_index_file "--others --directory"
1790
+ fi
1791
+ }
1792
+
1793
+ __git_sequencer_inprogress_options="--continue --quit --abort --skip"
1794
+
1795
+ __git_cherry_pick_inprogress_options=$__git_sequencer_inprogress_options
1796
+
1797
+ _git_cherry_pick ()
1798
+ {
1799
+ if __git_pseudoref_exists CHERRY_PICK_HEAD; then
1800
+ __gitcomp "$__git_cherry_pick_inprogress_options"
1801
+ return
1802
+ fi
1803
+
1804
+ __git_complete_strategy && return
1805
+
1806
+ case "$cur" in
1807
+ --*)
1808
+ __gitcomp_builtin cherry-pick "" \
1809
+ "$__git_cherry_pick_inprogress_options"
1810
+ ;;
1811
+ *)
1812
+ __git_complete_refs
1813
+ ;;
1814
+ esac
1815
+ }
1816
+
1817
+ _git_clean ()
1818
+ {
1819
+ case "$cur" in
1820
+ --*)
1821
+ __gitcomp_builtin clean
1822
+ return
1823
+ ;;
1824
+ esac
1825
+
1826
+ # XXX should we check for -x option ?
1827
+ __git_complete_index_file "--others --directory"
1828
+ }
1829
+
1830
+ _git_clone ()
1831
+ {
1832
+ case "$prev" in
1833
+ -c|--config)
1834
+ __git_complete_config_variable_name_and_value
1835
+ return
1836
+ ;;
1837
+ esac
1838
+ case "$cur" in
1839
+ --config=*)
1840
+ __git_complete_config_variable_name_and_value \
1841
+ --cur="${cur##--config=}"
1842
+ return
1843
+ ;;
1844
+ --*)
1845
+ __gitcomp_builtin clone
1846
+ return
1847
+ ;;
1848
+ esac
1849
+ }
1850
+
1851
+ __git_untracked_file_modes="all no normal"
1852
+
1853
+ __git_trailer_tokens ()
1854
+ {
1855
+ __git config --name-only --get-regexp '^trailer\..*\.key$' | cut -d. -f 2- | rev | cut -d. -f2- | rev
1856
+ }
1857
+
1858
+ _git_commit ()
1859
+ {
1860
+ case "$prev" in
1861
+ -c|-C)
1862
+ __git_complete_refs
1863
+ return
1864
+ ;;
1865
+ esac
1866
+
1867
+ case "$cur" in
1868
+ --cleanup=*)
1869
+ __gitcomp "default scissors strip verbatim whitespace
1870
+ " "" "${cur##--cleanup=}"
1871
+ return
1872
+ ;;
1873
+ --reuse-message=*|--reedit-message=*|\
1874
+ --fixup=*|--squash=*)
1875
+ __git_complete_refs --cur="${cur#*=}"
1876
+ return
1877
+ ;;
1878
+ --untracked-files=*)
1879
+ __gitcomp "$__git_untracked_file_modes" "" "${cur##--untracked-files=}"
1880
+ return
1881
+ ;;
1882
+ --trailer=*)
1883
+ __gitcomp_nl "$(__git_trailer_tokens)" "" "${cur##--trailer=}" ":"
1884
+ return
1885
+ ;;
1886
+ --*)
1887
+ __gitcomp_builtin commit
1888
+ return
1889
+ esac
1890
+
1891
+ if __git rev-parse --verify --quiet HEAD >/dev/null; then
1892
+ __git_complete_index_file "--committable"
1893
+ else
1894
+ # This is the first commit
1895
+ __git_complete_index_file "--cached"
1896
+ fi
1897
+ }
1898
+
1899
+ _git_describe ()
1900
+ {
1901
+ case "$cur" in
1902
+ --*)
1903
+ __gitcomp_builtin describe
1904
+ return
1905
+ esac
1906
+ __git_complete_refs
1907
+ }
1908
+
1909
+ __git_diff_algorithms="myers minimal patience histogram"
1910
+
1911
+ __git_diff_submodule_formats="diff log short"
1912
+
1913
+ __git_color_moved_opts="no default plain blocks zebra dimmed-zebra"
1914
+
1915
+ __git_color_moved_ws_opts="no ignore-space-at-eol ignore-space-change
1916
+ ignore-all-space allow-indentation-change"
1917
+
1918
+ __git_ws_error_highlight_opts="context old new all default"
1919
+
1920
+ # Options for the diff machinery (diff, log, show, stash, range-diff, ...)
1921
+ __git_diff_common_options="--stat --numstat --shortstat --summary
1922
+ --patch-with-stat --name-only --name-status --color
1923
+ --no-color --color-words --no-renames --check
1924
+ --color-moved --color-moved= --no-color-moved
1925
+ --color-moved-ws= --no-color-moved-ws
1926
+ --full-index --binary --abbrev --diff-filter=
1927
+ --find-copies --find-object --find-renames
1928
+ --no-relative --relative
1929
+ --find-copies-harder --ignore-cr-at-eol
1930
+ --text --ignore-space-at-eol --ignore-space-change
1931
+ --ignore-all-space --ignore-blank-lines --exit-code
1932
+ --quiet --ext-diff --no-ext-diff --unified=
1933
+ --no-prefix --src-prefix= --dst-prefix=
1934
+ --inter-hunk-context= --function-context
1935
+ --patience --histogram --minimal
1936
+ --raw --word-diff --word-diff-regex=
1937
+ --dirstat --dirstat= --dirstat-by-file
1938
+ --dirstat-by-file= --cumulative
1939
+ --diff-algorithm= --default-prefix
1940
+ --submodule --submodule= --ignore-submodules
1941
+ --indent-heuristic --no-indent-heuristic
1942
+ --textconv --no-textconv --break-rewrites
1943
+ --patch --no-patch --cc --combined-all-paths
1944
+ --anchored= --compact-summary --ignore-matching-lines=
1945
+ --irreversible-delete --line-prefix --no-stat
1946
+ --output= --output-indicator-context=
1947
+ --output-indicator-new= --output-indicator-old=
1948
+ --ws-error-highlight=
1949
+ --pickaxe-all --pickaxe-regex --patch-with-raw
1950
+ "
1951
+
1952
+ # Options for diff/difftool
1953
+ __git_diff_difftool_options="--cached --staged
1954
+ --base --ours --theirs --no-index --merge-base
1955
+ --ita-invisible-in-index --ita-visible-in-index
1956
+ $__git_diff_common_options"
1957
+
1958
+ _git_diff ()
1959
+ {
1960
+ if ! __git_has_doubledash; then
1961
+ case "$cur" in
1962
+ --diff-algorithm=*)
1963
+ __gitcomp "$__git_diff_algorithms" \
1964
+ "" "${cur##--diff-algorithm=}"
1965
+ return
1966
+ ;;
1967
+ --submodule=*)
1968
+ __gitcomp "$__git_diff_submodule_formats" \
1969
+ "" "${cur##--submodule=}"
1970
+ return
1971
+ ;;
1972
+ --color-moved=*)
1973
+ __gitcomp "$__git_color_moved_opts" \
1974
+ "" "${cur##--color-moved=}"
1975
+ return
1976
+ ;;
1977
+ --color-moved-ws=*)
1978
+ __gitcomp "$__git_color_moved_ws_opts" \
1979
+ "" "${cur##--color-moved-ws=}"
1980
+ return
1981
+ ;;
1982
+ --ws-error-highlight=*)
1983
+ __gitcomp "$__git_ws_error_highlight_opts" \
1984
+ "" "${cur##--ws-error-highlight=}"
1985
+ return
1986
+ ;;
1987
+ --*)
1988
+ __gitcomp "$__git_diff_difftool_options"
1989
+ return
1990
+ ;;
1991
+ esac
1992
+ __git_complete_revlist_file
1993
+ fi
1994
+
1995
+ if [ ${#COMPREPLY[@]} -eq 0 ]; then
1996
+ __git_complete_index_file ""
1997
+ fi
1998
+
1999
+ if [ ${#COMPREPLY[@]} -eq 0 ]; then
2000
+ __git_complete_index_file "--others --directory"
2001
+ fi
2002
+ }
2003
+
2004
+ __git_mergetools_common="diffuse diffmerge ecmerge emerge kdiff3 meld opendiff
2005
+ tkdiff vimdiff nvimdiff gvimdiff xxdiff araxis p4merge
2006
+ bc codecompare smerge
2007
+ "
2008
+
2009
+ _git_difftool ()
2010
+ {
2011
+ __git_has_doubledash && return
2012
+
2013
+ case "$cur" in
2014
+ --tool=*)
2015
+ __gitcomp "$__git_mergetools_common kompare" "" "${cur##--tool=}"
2016
+ return
2017
+ ;;
2018
+ --*)
2019
+ __gitcomp_builtin difftool "$__git_diff_difftool_options"
2020
+ return
2021
+ ;;
2022
+ esac
2023
+ __git_complete_revlist_file
2024
+ }
2025
+
2026
+ __git_fetch_recurse_submodules="yes on-demand no"
2027
+
2028
+ _git_fetch ()
2029
+ {
2030
+ case "$cur" in
2031
+ --recurse-submodules=*)
2032
+ __gitcomp "$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}"
2033
+ return
2034
+ ;;
2035
+ --filter=*)
2036
+ __gitcomp "blob:none blob:limit= sparse:oid=" "" "${cur##--filter=}"
2037
+ return
2038
+ ;;
2039
+ --*)
2040
+ __gitcomp_builtin fetch
2041
+ return
2042
+ ;;
2043
+ esac
2044
+ __git_complete_remote_or_refspec
2045
+ }
2046
+
2047
+ __git_format_patch_extra_options="
2048
+ --full-index --not --all --no-prefix --src-prefix=
2049
+ --dst-prefix= --notes
2050
+ "
2051
+
2052
+ _git_format_patch ()
2053
+ {
2054
+ case "$cur" in
2055
+ --thread=*)
2056
+ __gitcomp "
2057
+ deep shallow
2058
+ " "" "${cur##--thread=}"
2059
+ return
2060
+ ;;
2061
+ --base=*|--interdiff=*|--range-diff=*)
2062
+ __git_complete_refs --cur="${cur#--*=}"
2063
+ return
2064
+ ;;
2065
+ --*)
2066
+ __gitcomp_builtin format-patch "$__git_format_patch_extra_options"
2067
+ return
2068
+ ;;
2069
+ esac
2070
+ __git_complete_revlist
2071
+ }
2072
+
2073
+ _git_fsck ()
2074
+ {
2075
+ case "$cur" in
2076
+ --*)
2077
+ __gitcomp_builtin fsck
2078
+ return
2079
+ ;;
2080
+ esac
2081
+ }
2082
+
2083
+ _git_gitk ()
2084
+ {
2085
+ __gitk_main
2086
+ }
2087
+
2088
+ # Lists matching symbol names from a tag (as in ctags) file.
2089
+ # 1: List symbol names matching this word.
2090
+ # 2: The tag file to list symbol names from.
2091
+ # 3: A prefix to be added to each listed symbol name (optional).
2092
+ # 4: A suffix to be appended to each listed symbol name (optional).
2093
+ __git_match_ctag () {
2094
+ awk -v pfx="${3-}" -v sfx="${4-}" "
2095
+ /^${1//\//\\/}/ { print pfx \$1 sfx }
2096
+ " "$2"
2097
+ }
2098
+
2099
+ # Complete symbol names from a tag file.
2100
+ # Usage: __git_complete_symbol [<option>]...
2101
+ # --tags=<file>: The tag file to list symbol names from instead of the
2102
+ # default "tags".
2103
+ # --pfx=<prefix>: A prefix to be added to each symbol name.
2104
+ # --cur=<word>: The current symbol name to be completed. Defaults to
2105
+ # the current word to be completed.
2106
+ # --sfx=<suffix>: A suffix to be appended to each symbol name instead
2107
+ # of the default space.
2108
+ __git_complete_symbol () {
2109
+ local tags=tags pfx="" cur_="${cur-}" sfx=" "
2110
+
2111
+ while test $# != 0; do
2112
+ case "$1" in
2113
+ --tags=*) tags="${1##--tags=}" ;;
2114
+ --pfx=*) pfx="${1##--pfx=}" ;;
2115
+ --cur=*) cur_="${1##--cur=}" ;;
2116
+ --sfx=*) sfx="${1##--sfx=}" ;;
2117
+ *) return 1 ;;
2118
+ esac
2119
+ shift
2120
+ done
2121
+
2122
+ if test -r "$tags"; then
2123
+ __gitcomp_direct "$(__git_match_ctag "$cur_" "$tags" "$pfx" "$sfx")"
2124
+ fi
2125
+ }
2126
+
2127
+ _git_grep ()
2128
+ {
2129
+ __git_has_doubledash && return
2130
+
2131
+ case "$cur" in
2132
+ --*)
2133
+ __gitcomp_builtin grep
2134
+ return
2135
+ ;;
2136
+ esac
2137
+
2138
+ case "$cword,$prev" in
2139
+ $((__git_cmd_idx+1)),*|*,-*)
2140
+ __git_complete_symbol && return
2141
+ ;;
2142
+ esac
2143
+
2144
+ __git_complete_refs
2145
+ }
2146
+
2147
+ _git_help ()
2148
+ {
2149
+ case "$cur" in
2150
+ --*)
2151
+ __gitcomp_builtin help
2152
+ return
2153
+ ;;
2154
+ esac
2155
+ if test -n "${GIT_TESTING_ALL_COMMAND_LIST-}"
2156
+ then
2157
+ __gitcomp "$GIT_TESTING_ALL_COMMAND_LIST $(__git --list-cmds=alias,list-guide) gitk"
2158
+ else
2159
+ __gitcomp "$(__git --list-cmds=main,nohelpers,alias,list-guide) gitk"
2160
+ fi
2161
+ }
2162
+
2163
+ __git_history_has_revision ()
2164
+ {
2165
+ local i
2166
+
2167
+ for ((i = __git_cmd_idx + 2; i < cword; i++)); do
2168
+ case "${words[i]}" in
2169
+ -*)
2170
+ ;;
2171
+ *)
2172
+ return 0
2173
+ ;;
2174
+ esac
2175
+ done
2176
+ return 1
2177
+ }
2178
+
2179
+ _git_history ()
2180
+ {
2181
+ local subcommands subcommand
2182
+
2183
+ __git_resolve_builtins "history"
2184
+
2185
+ subcommands="$___git_resolved_builtins"
2186
+ subcommand="$(__git_find_subcommand "$subcommands")"
2187
+
2188
+ if [ -z "$subcommand" ]; then
2189
+ __gitcomp "$subcommands"
2190
+ return
2191
+ fi
2192
+
2193
+ if ! __git_has_doubledash; then
2194
+ case "$cur" in
2195
+ --empty=*)
2196
+ case "$subcommand" in
2197
+ drop|fixup)
2198
+ __gitcomp "drop keep abort" "" \
2199
+ "${cur##--empty=}"
2200
+ ;;
2201
+ esac
2202
+ return
2203
+ ;;
2204
+ --update-refs=*)
2205
+ __gitcomp "branches head" "" \
2206
+ "${cur##--update-refs=}"
2207
+ return
2208
+ ;;
2209
+ --*)
2210
+ __gitcomp_builtin "history_$subcommand"
2211
+ return
2212
+ ;;
2213
+ esac
2214
+ fi
2215
+
2216
+ if ! __git_history_has_revision; then
2217
+ __git_complete_refs
2218
+ return
2219
+ fi
2220
+
2221
+ case "$subcommand" in
2222
+ split)
2223
+ __git_complete_index_file "--cached"
2224
+ ;;
2225
+ esac
2226
+ }
2227
+
2228
+ _git_init ()
2229
+ {
2230
+ case "$cur" in
2231
+ --shared=*)
2232
+ __gitcomp "
2233
+ false true umask group all world everybody
2234
+ " "" "${cur##--shared=}"
2235
+ return
2236
+ ;;
2237
+ --*)
2238
+ __gitcomp_builtin init
2239
+ return
2240
+ ;;
2241
+ esac
2242
+ }
2243
+
2244
+ _git_ls_files ()
2245
+ {
2246
+ case "$cur" in
2247
+ --*)
2248
+ __gitcomp_builtin ls-files
2249
+ return
2250
+ ;;
2251
+ esac
2252
+
2253
+ # XXX ignore options like --modified and always suggest all cached
2254
+ # files.
2255
+ __git_complete_index_file "--cached"
2256
+ }
2257
+
2258
+ _git_ls_remote ()
2259
+ {
2260
+ case "$cur" in
2261
+ --*)
2262
+ __gitcomp_builtin ls-remote
2263
+ return
2264
+ ;;
2265
+ esac
2266
+ __gitcomp_nl "$(__git_remotes)"
2267
+ }
2268
+
2269
+ _git_ls_tree ()
2270
+ {
2271
+ case "$cur" in
2272
+ --*)
2273
+ __gitcomp_builtin ls-tree
2274
+ return
2275
+ ;;
2276
+ esac
2277
+
2278
+ __git_complete_file
2279
+ }
2280
+
2281
+ # Options that go well for log, shortlog and gitk
2282
+ __git_log_common_options="
2283
+ --not --all
2284
+ --branches --tags --remotes
2285
+ --first-parent --merges --no-merges
2286
+ --max-count= --max-count-oldest=
2287
+ --max-age= --since= --after=
2288
+ --min-age= --until= --before=
2289
+ --min-parents= --max-parents=
2290
+ --no-min-parents --no-max-parents
2291
+ --alternate-refs --ancestry-path
2292
+ --author-date-order --basic-regexp
2293
+ --bisect --boundary --exclude-first-parent-only
2294
+ --exclude-hidden --extended-regexp
2295
+ --fixed-strings --grep-reflog
2296
+ --ignore-missing --left-only --perl-regexp
2297
+ --reflog --regexp-ignore-case --remove-empty
2298
+ --right-only --show-linear-break
2299
+ --show-notes-by-default --show-pulls
2300
+ --since-as-filter --single-worktree
2301
+ "
2302
+ # Options that go well for log and gitk (not shortlog)
2303
+ __git_log_gitk_options="
2304
+ --dense --sparse --full-history
2305
+ --simplify-merges --simplify-by-decoration
2306
+ --left-right --notes --no-notes
2307
+ "
2308
+ # Options that go well for log and shortlog (not gitk)
2309
+ __git_log_shortlog_options="
2310
+ --author= --grep= --exclude=
2311
+ --all-match --invert-grep
2312
+ "
2313
+ # Options accepted by log and show
2314
+ __git_log_show_options="
2315
+ --diff-merges --diff-merges= --no-diff-merges --dd --remerge-diff
2316
+ --encoding=
2317
+ "
2318
+
2319
+ __git_diff_merges_opts="off none on first-parent 1 separate m combined c dense-combined cc remerge r"
2320
+
2321
+ __git_log_pretty_formats="oneline short medium full fuller reference email raw format: tformat: mboxrd"
2322
+ __git_log_date_formats="relative iso8601 iso8601-strict rfc2822 short local default human raw unix auto: format:"
2323
+
2324
+ # Complete porcelain (i.e. not git-rev-list) options and at least some
2325
+ # option arguments accepted by git-log. Note that this same set of options
2326
+ # are also accepted by some other git commands besides git-log.
2327
+ __git_complete_log_opts ()
2328
+ {
2329
+ COMPREPLY=()
2330
+
2331
+ local merge=""
2332
+ if __git_pseudoref_exists MERGE_HEAD; then
2333
+ merge="--merge"
2334
+ fi
2335
+ case "$prev,$cur" in
2336
+ -L,:*:*)
2337
+ return # fall back to Bash filename completion
2338
+ ;;
2339
+ -L,:*)
2340
+ __git_complete_symbol --cur="${cur#:}" --sfx=":"
2341
+ return
2342
+ ;;
2343
+ -G,*|-S,*)
2344
+ __git_complete_symbol
2345
+ return
2346
+ ;;
2347
+ esac
2348
+ case "$cur" in
2349
+ --pretty=*|--format=*)
2350
+ __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
2351
+ " "" "${cur#*=}"
2352
+ return
2353
+ ;;
2354
+ --date=*)
2355
+ __gitcomp "$__git_log_date_formats" "" "${cur##--date=}"
2356
+ return
2357
+ ;;
2358
+ --decorate=*)
2359
+ __gitcomp "full short no" "" "${cur##--decorate=}"
2360
+ return
2361
+ ;;
2362
+ --diff-algorithm=*)
2363
+ __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
2364
+ return
2365
+ ;;
2366
+ --submodule=*)
2367
+ __gitcomp "$__git_diff_submodule_formats" "" "${cur##--submodule=}"
2368
+ return
2369
+ ;;
2370
+ --ws-error-highlight=*)
2371
+ __gitcomp "$__git_ws_error_highlight_opts" "" "${cur##--ws-error-highlight=}"
2372
+ return
2373
+ ;;
2374
+ --no-walk=*)
2375
+ __gitcomp "sorted unsorted" "" "${cur##--no-walk=}"
2376
+ return
2377
+ ;;
2378
+ --diff-merges=*)
2379
+ __gitcomp "$__git_diff_merges_opts" "" "${cur##--diff-merges=}"
2380
+ return
2381
+ ;;
2382
+ --*)
2383
+ __gitcomp "
2384
+ $__git_log_common_options
2385
+ $__git_log_shortlog_options
2386
+ $__git_log_gitk_options
2387
+ $__git_log_show_options
2388
+ --committer=
2389
+ --root --topo-order --date-order --reverse
2390
+ --follow --full-diff
2391
+ --abbrev-commit --no-abbrev-commit --abbrev=
2392
+ --relative-date --date=
2393
+ --pretty= --format= --oneline
2394
+ --show-signature
2395
+ --cherry-mark
2396
+ --cherry-pick
2397
+ --graph
2398
+ --decorate --decorate= --no-decorate
2399
+ --walk-reflogs
2400
+ --no-walk --no-walk= --do-walk
2401
+ --parents --children
2402
+ --expand-tabs --expand-tabs= --no-expand-tabs
2403
+ --clear-decorations --decorate-refs=
2404
+ --decorate-refs-exclude=
2405
+ $merge
2406
+ $__git_diff_common_options
2407
+ "
2408
+ return
2409
+ ;;
2410
+ -L:*:*)
2411
+ return # fall back to Bash filename completion
2412
+ ;;
2413
+ -L:*)
2414
+ __git_complete_symbol --cur="${cur#-L:}" --sfx=":"
2415
+ return
2416
+ ;;
2417
+ -G*)
2418
+ __git_complete_symbol --pfx="-G" --cur="${cur#-G}"
2419
+ return
2420
+ ;;
2421
+ -S*)
2422
+ __git_complete_symbol --pfx="-S" --cur="${cur#-S}"
2423
+ return
2424
+ ;;
2425
+ esac
2426
+ }
2427
+
2428
+ _git_log ()
2429
+ {
2430
+ __git_has_doubledash && return
2431
+ __git_find_repo_path
2432
+
2433
+ __git_complete_log_opts
2434
+ [ ${#COMPREPLY[@]} -eq 0 ] || return
2435
+
2436
+ __git_complete_revlist
2437
+ }
2438
+
2439
+ _git_merge ()
2440
+ {
2441
+ __git_complete_strategy && return
2442
+
2443
+ case "$cur" in
2444
+ --*)
2445
+ __gitcomp_builtin merge
2446
+ return
2447
+ esac
2448
+ __git_complete_refs
2449
+ }
2450
+
2451
+ _git_mergetool ()
2452
+ {
2453
+ case "$cur" in
2454
+ --tool=*)
2455
+ __gitcomp "$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"
2456
+ return
2457
+ ;;
2458
+ --*)
2459
+ __gitcomp "--tool= --tool-help --prompt --no-prompt --gui --no-gui"
2460
+ return
2461
+ ;;
2462
+ esac
2463
+ }
2464
+
2465
+ _git_merge_base ()
2466
+ {
2467
+ case "$cur" in
2468
+ --*)
2469
+ __gitcomp_builtin merge-base
2470
+ return
2471
+ ;;
2472
+ esac
2473
+ __git_complete_refs
2474
+ }
2475
+
2476
+ _git_mv ()
2477
+ {
2478
+ case "$cur" in
2479
+ --*)
2480
+ __gitcomp_builtin mv
2481
+ return
2482
+ ;;
2483
+ esac
2484
+
2485
+ if [ $(__git_count_arguments "mv") -gt 0 ]; then
2486
+ # We need to show both cached and untracked files (including
2487
+ # empty directories) since this may not be the last argument.
2488
+ __git_complete_index_file "--cached --others --directory"
2489
+ else
2490
+ __git_complete_index_file "--cached"
2491
+ fi
2492
+ }
2493
+
2494
+ _git_notes ()
2495
+ {
2496
+ local subcommands='add append copy edit get-ref list merge prune remove show'
2497
+ local subcommand="$(__git_find_on_cmdline "$subcommands")"
2498
+
2499
+ case "$subcommand,$cur" in
2500
+ ,--*)
2501
+ __gitcomp_builtin notes
2502
+ ;;
2503
+ ,*)
2504
+ case "$prev" in
2505
+ --ref)
2506
+ __git_complete_refs
2507
+ ;;
2508
+ *)
2509
+ __gitcomp "$subcommands --ref"
2510
+ ;;
2511
+ esac
2512
+ ;;
2513
+ *,--reuse-message=*|*,--reedit-message=*)
2514
+ __git_complete_refs --cur="${cur#*=}"
2515
+ ;;
2516
+ *,--*)
2517
+ __gitcomp_builtin notes_$subcommand
2518
+ ;;
2519
+ prune,*|get-ref,*)
2520
+ # this command does not take a ref, do not complete it
2521
+ ;;
2522
+ *)
2523
+ case "$prev" in
2524
+ -m|-F)
2525
+ ;;
2526
+ *)
2527
+ __git_complete_refs
2528
+ ;;
2529
+ esac
2530
+ ;;
2531
+ esac
2532
+ }
2533
+
2534
+ _git_pull ()
2535
+ {
2536
+ __git_complete_strategy && return
2537
+
2538
+ case "$cur" in
2539
+ --recurse-submodules=*)
2540
+ __gitcomp "$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}"
2541
+ return
2542
+ ;;
2543
+ --*)
2544
+ __gitcomp_builtin pull
2545
+
2546
+ return
2547
+ ;;
2548
+ esac
2549
+ __git_complete_remote_or_refspec
2550
+ }
2551
+
2552
+ __git_push_recurse_submodules="check on-demand only"
2553
+
2554
+ __git_complete_force_with_lease ()
2555
+ {
2556
+ local cur_=$1
2557
+
2558
+ case "$cur_" in
2559
+ --*=)
2560
+ ;;
2561
+ *:*)
2562
+ __git_complete_refs --cur="${cur_#*:}"
2563
+ ;;
2564
+ *)
2565
+ __git_complete_refs --cur="$cur_"
2566
+ ;;
2567
+ esac
2568
+ }
2569
+
2570
+ _git_push ()
2571
+ {
2572
+ case "$prev" in
2573
+ --repo)
2574
+ __gitcomp_nl "$(__git_remotes)"
2575
+ return
2576
+ ;;
2577
+ --recurse-submodules)
2578
+ __gitcomp "$__git_push_recurse_submodules"
2579
+ return
2580
+ ;;
2581
+ esac
2582
+ case "$cur" in
2583
+ --repo=*)
2584
+ __gitcomp_nl "$(__git_remotes)" "" "${cur##--repo=}"
2585
+ return
2586
+ ;;
2587
+ --recurse-submodules=*)
2588
+ __gitcomp "$__git_push_recurse_submodules" "" "${cur##--recurse-submodules=}"
2589
+ return
2590
+ ;;
2591
+ --force-with-lease=*)
2592
+ __git_complete_force_with_lease "${cur##--force-with-lease=}"
2593
+ return
2594
+ ;;
2595
+ --*)
2596
+ __gitcomp_builtin push
2597
+ return
2598
+ ;;
2599
+ esac
2600
+ __git_complete_remote_or_refspec
2601
+ }
2602
+
2603
+ _git_range_diff ()
2604
+ {
2605
+ case "$cur" in
2606
+ --*)
2607
+ __gitcomp "
2608
+ --creation-factor= --no-dual-color
2609
+ $__git_diff_common_options
2610
+ "
2611
+ return
2612
+ ;;
2613
+ esac
2614
+ __git_complete_revlist
2615
+ }
2616
+
2617
+ __git_rebase_inprogress_options="--continue --skip --abort --quit --show-current-patch"
2618
+ __git_rebase_interactive_inprogress_options="$__git_rebase_inprogress_options --edit-todo"
2619
+
2620
+ _git_rebase ()
2621
+ {
2622
+ __git_find_repo_path
2623
+ if [ -f "$__git_repo_path"/rebase-merge/interactive ]; then
2624
+ __gitcomp "$__git_rebase_interactive_inprogress_options"
2625
+ return
2626
+ elif [ -d "$__git_repo_path"/rebase-apply ] || \
2627
+ [ -d "$__git_repo_path"/rebase-merge ]; then
2628
+ __gitcomp "$__git_rebase_inprogress_options"
2629
+ return
2630
+ fi
2631
+ __git_complete_strategy && return
2632
+ case "$cur" in
2633
+ --whitespace=*)
2634
+ __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
2635
+ return
2636
+ ;;
2637
+ --onto=*)
2638
+ __git_complete_refs --cur="${cur##--onto=}"
2639
+ return
2640
+ ;;
2641
+ --*)
2642
+ __gitcomp_builtin rebase "" \
2643
+ "$__git_rebase_interactive_inprogress_options"
2644
+
2645
+ return
2646
+ esac
2647
+ __git_complete_refs
2648
+ }
2649
+
2650
+ _git_reflog ()
2651
+ {
2652
+ local subcommands subcommand
2653
+
2654
+ __git_resolve_builtins "reflog"
2655
+
2656
+ subcommands="$___git_resolved_builtins"
2657
+ subcommand="$(__git_find_subcommand "$subcommands" "show")"
2658
+
2659
+ case "$subcommand,$cur" in
2660
+ show,--*)
2661
+ __gitcomp "
2662
+ $__git_log_common_options
2663
+ "
2664
+ return
2665
+ ;;
2666
+ $subcommand,--*)
2667
+ __gitcomp_builtin "reflog_$subcommand"
2668
+ return
2669
+ ;;
2670
+ esac
2671
+
2672
+ __git_complete_refs
2673
+
2674
+ if [ $((cword - __git_cmd_idx)) -eq 1 ]; then
2675
+ __gitcompappend "$subcommands" "" "$cur" " "
2676
+ fi
2677
+ }
2678
+
2679
+ __git_send_email_confirm_options="always never auto cc compose"
2680
+ __git_send_email_suppresscc_options="author self cc bodycc sob cccmd body all"
2681
+
2682
+ _git_send_email ()
2683
+ {
2684
+ case "$prev" in
2685
+ --to|--cc|--bcc|--from)
2686
+ __gitcomp "$(__git send-email --dump-aliases)"
2687
+ return
2688
+ ;;
2689
+ esac
2690
+
2691
+ case "$cur" in
2692
+ --confirm=*)
2693
+ __gitcomp "
2694
+ $__git_send_email_confirm_options
2695
+ " "" "${cur##--confirm=}"
2696
+ return
2697
+ ;;
2698
+ --suppress-cc=*)
2699
+ __gitcomp "
2700
+ $__git_send_email_suppresscc_options
2701
+ " "" "${cur##--suppress-cc=}"
2702
+
2703
+ return
2704
+ ;;
2705
+ --smtp-encryption=*)
2706
+ __gitcomp "ssl tls" "" "${cur##--smtp-encryption=}"
2707
+ return
2708
+ ;;
2709
+ --thread=*)
2710
+ __gitcomp "
2711
+ deep shallow
2712
+ " "" "${cur##--thread=}"
2713
+ return
2714
+ ;;
2715
+ --to=*|--cc=*|--bcc=*|--from=*)
2716
+ __gitcomp "$(__git send-email --dump-aliases)" "" "${cur#--*=}"
2717
+ return
2718
+ ;;
2719
+ --*)
2720
+ __gitcomp_builtin send-email "$__git_format_patch_extra_options"
2721
+ return
2722
+ ;;
2723
+ esac
2724
+ __git_complete_revlist
2725
+ }
2726
+
2727
+ _git_stage ()
2728
+ {
2729
+ _git_add
2730
+ }
2731
+
2732
+ _git_status ()
2733
+ {
2734
+ local complete_opt
2735
+ local untracked_state
2736
+
2737
+ case "$cur" in
2738
+ --ignore-submodules=*)
2739
+ __gitcomp "none untracked dirty all" "" "${cur##--ignore-submodules=}"
2740
+ return
2741
+ ;;
2742
+ --untracked-files=*)
2743
+ __gitcomp "$__git_untracked_file_modes" "" "${cur##--untracked-files=}"
2744
+ return
2745
+ ;;
2746
+ --column=*)
2747
+ __gitcomp "
2748
+ always never auto column row plain dense nodense
2749
+ " "" "${cur##--column=}"
2750
+ return
2751
+ ;;
2752
+ --*)
2753
+ __gitcomp_builtin status
2754
+ return
2755
+ ;;
2756
+ esac
2757
+
2758
+ untracked_state="$(__git_get_option_value "-u" "--untracked-files=" \
2759
+ "$__git_untracked_file_modes" "status.showUntrackedFiles")"
2760
+
2761
+ case "$untracked_state" in
2762
+ no)
2763
+ # --ignored option does not matter
2764
+ complete_opt=
2765
+ ;;
2766
+ all|normal|*)
2767
+ complete_opt="--cached --directory --no-empty-directory --others"
2768
+
2769
+ if [ -n "$(__git_find_on_cmdline "--ignored")" ]; then
2770
+ complete_opt="$complete_opt --ignored --exclude=*"
2771
+ fi
2772
+ ;;
2773
+ esac
2774
+
2775
+ __git_complete_index_file "$complete_opt"
2776
+ }
2777
+
2778
+ _git_switch ()
2779
+ {
2780
+ local dwim_opt="$(__git_checkout_default_dwim_mode)"
2781
+
2782
+ case "$prev" in
2783
+ -c|-C|--orphan)
2784
+ # Complete local branches (and DWIM branch
2785
+ # remote branch names) for an option argument
2786
+ # specifying a new branch name. This is for
2787
+ # convenience, assuming new branches are
2788
+ # possibly based on pre-existing branch names.
2789
+ __git_complete_refs $dwim_opt --mode="heads"
2790
+ return
2791
+ ;;
2792
+ *)
2793
+ ;;
2794
+ esac
2795
+
2796
+ case "$cur" in
2797
+ --conflict=*)
2798
+ __gitcomp "diff3 merge zdiff3" "" "${cur##--conflict=}"
2799
+ ;;
2800
+ --*)
2801
+ __gitcomp_builtin switch
2802
+ ;;
2803
+ *)
2804
+ # Unlike in git checkout, git switch --orphan does not take
2805
+ # a start point. Thus we really have nothing to complete after
2806
+ # the branch name.
2807
+ if [ -n "$(__git_find_on_cmdline "--orphan")" ]; then
2808
+ return
2809
+ fi
2810
+
2811
+ # At this point, we've already handled special completion for
2812
+ # -c/-C, and --orphan. There are 3 main things left to
2813
+ # complete:
2814
+ # 1) a start-point for -c/-C or -d/--detach
2815
+ # 2) a remote head, for --track
2816
+ # 3) a branch name, possibly including DWIM remote branches
2817
+
2818
+ if [ -n "$(__git_find_on_cmdline "-c -C -d --detach")" ]; then
2819
+ __git_complete_refs --mode="refs"
2820
+ elif [ -n "$(__git_find_on_cmdline "-t --track")" ]; then
2821
+ __git_complete_refs --mode="remote-heads"
2822
+ else
2823
+ __git_complete_refs $dwim_opt --mode="heads"
2824
+ fi
2825
+ ;;
2826
+ esac
2827
+ }
2828
+
2829
+ __git_config_get_set_variables ()
2830
+ {
2831
+ local prevword word config_file= c=$cword
2832
+ while [ $c -gt "$__git_cmd_idx" ]; do
2833
+ word="${words[c]}"
2834
+ case "$word" in
2835
+ --system|--global|--local|--file=*)
2836
+ config_file="$word"
2837
+ break
2838
+ ;;
2839
+ -f|--file)
2840
+ config_file="$word $prevword"
2841
+ break
2842
+ ;;
2843
+ esac
2844
+ prevword=$word
2845
+ c=$((--c))
2846
+ done
2847
+
2848
+ __git config $config_file --name-only --list
2849
+ }
2850
+
2851
+ __git_config_vars=
2852
+ __git_compute_config_vars ()
2853
+ {
2854
+ test -n "$__git_config_vars" ||
2855
+ __git_config_vars="$(git help --config-for-completion)"
2856
+ }
2857
+
2858
+ __git_config_vars_all=
2859
+ __git_compute_config_vars_all ()
2860
+ {
2861
+ test -n "$__git_config_vars_all" ||
2862
+ __git_config_vars_all="$(git --no-pager help --config)"
2863
+ }
2864
+
2865
+ __git_indirect()
2866
+ {
2867
+ eval printf '%s' "\"\$$1\""
2868
+ }
2869
+
2870
+ __git_compute_first_level_config_vars_for_section ()
2871
+ {
2872
+ local section="$1"
2873
+ __git_compute_config_vars
2874
+ local this_section="__git_first_level_config_vars_for_section_${section}"
2875
+ test -n "$(__git_indirect "${this_section}")" ||
2876
+ printf -v "__git_first_level_config_vars_for_section_${section}" %s \
2877
+ "$(echo "$__git_config_vars" | awk -F. "/^${section}\.[a-z]/ { print \$2 }")"
2878
+ }
2879
+
2880
+ __git_compute_second_level_config_vars_for_section ()
2881
+ {
2882
+ local section="$1"
2883
+ __git_compute_config_vars_all
2884
+ local this_section="__git_second_level_config_vars_for_section_${section}"
2885
+ test -n "$(__git_indirect "${this_section}")" ||
2886
+ printf -v "__git_second_level_config_vars_for_section_${section}" %s \
2887
+ "$(echo "$__git_config_vars_all" | awk -F. "/^${section}\.</ { print \$3 }")"
2888
+ }
2889
+
2890
+ __git_config_sections=
2891
+ __git_compute_config_sections ()
2892
+ {
2893
+ test -n "$__git_config_sections" ||
2894
+ __git_config_sections="$(git help --config-sections-for-completion)"
2895
+ }
2896
+
2897
+ # Completes possible values of various configuration variables.
2898
+ #
2899
+ # Usage: __git_complete_config_variable_value [<option>]...
2900
+ # --varname=<word>: The name of the configuration variable whose value is
2901
+ # to be completed. Defaults to the previous word on the
2902
+ # command line.
2903
+ # --cur=<word>: The current value to be completed. Defaults to the current
2904
+ # word to be completed.
2905
+ __git_complete_config_variable_value ()
2906
+ {
2907
+ local varname="$prev" cur_="$cur"
2908
+
2909
+ while test $# != 0; do
2910
+ case "$1" in
2911
+ --varname=*) varname="${1##--varname=}" ;;
2912
+ --cur=*) cur_="${1##--cur=}" ;;
2913
+ *) return 1 ;;
2914
+ esac
2915
+ shift
2916
+ done
2917
+
2918
+ if [ "${BASH_VERSINFO[0]:-0}" -ge 4 ]; then
2919
+ varname="${varname,,}"
2920
+ else
2921
+ varname="$(echo "$varname" |tr A-Z a-z)"
2922
+ fi
2923
+
2924
+ case "$varname" in
2925
+ branch.*.remote|branch.*.pushremote)
2926
+ __gitcomp_nl "$(__git_remotes)" "" "$cur_"
2927
+ return
2928
+ ;;
2929
+ branch.*.merge)
2930
+ __git_complete_refs --cur="$cur_"
2931
+ return
2932
+ ;;
2933
+ branch.*.rebase)
2934
+ __gitcomp "false true merges interactive" "" "$cur_"
2935
+ return
2936
+ ;;
2937
+ remote.pushdefault)
2938
+ __gitcomp_nl "$(__git_remotes)" "" "$cur_"
2939
+ return
2940
+ ;;
2941
+ remote.*.fetch)
2942
+ local remote="${varname#remote.}"
2943
+ remote="${remote%.fetch}"
2944
+ if [ -z "$cur_" ]; then
2945
+ __gitcomp_nl "refs/heads/" "" "" ""
2946
+ return
2947
+ fi
2948
+ __gitcomp_nl "$(__git_refs_remotes "$remote")" "" "$cur_"
2949
+ return
2950
+ ;;
2951
+ remote.*.push)
2952
+ local remote="${varname#remote.}"
2953
+ remote="${remote%.push}"
2954
+ __gitcomp_nl "$(__git for-each-ref \
2955
+ --format='%(refname):%(refname)' refs/heads)" "" "$cur_"
2956
+ return
2957
+ ;;
2958
+ pull.twohead|pull.octopus)
2959
+ __git_compute_merge_strategies
2960
+ __gitcomp "$__git_merge_strategies" "" "$cur_"
2961
+ return
2962
+ ;;
2963
+ color.pager)
2964
+ __gitcomp "false true" "" "$cur_"
2965
+ return
2966
+ ;;
2967
+ color.*.*)
2968
+ __gitcomp "
2969
+ normal black red green yellow blue magenta cyan white
2970
+ bold dim ul blink reverse
2971
+ " "" "$cur_"
2972
+ return
2973
+ ;;
2974
+ color.*)
2975
+ __gitcomp "false true always never auto" "" "$cur_"
2976
+ return
2977
+ ;;
2978
+ diff.submodule)
2979
+ __gitcomp "$__git_diff_submodule_formats" "" "$cur_"
2980
+ return
2981
+ ;;
2982
+ help.format)
2983
+ __gitcomp "man info web html" "" "$cur_"
2984
+ return
2985
+ ;;
2986
+ log.date)
2987
+ __gitcomp "$__git_log_date_formats" "" "$cur_"
2988
+ return
2989
+ ;;
2990
+ sendemail.aliasfiletype)
2991
+ __gitcomp "mutt mailrc pine elm gnus" "" "$cur_"
2992
+ return
2993
+ ;;
2994
+ sendemail.confirm)
2995
+ __gitcomp "$__git_send_email_confirm_options" "" "$cur_"
2996
+ return
2997
+ ;;
2998
+ sendemail.suppresscc)
2999
+ __gitcomp "$__git_send_email_suppresscc_options" "" "$cur_"
3000
+ return
3001
+ ;;
3002
+ sendemail.transferencoding)
3003
+ __gitcomp "7bit 8bit quoted-printable base64" "" "$cur_"
3004
+ return
3005
+ ;;
3006
+ *.*)
3007
+ return
3008
+ ;;
3009
+ esac
3010
+ }
3011
+
3012
+ # Completes configuration sections, subsections, variable names.
3013
+ #
3014
+ # Usage: __git_complete_config_variable_name [<option>]...
3015
+ # --cur=<word>: The current configuration section/variable name to be
3016
+ # completed. Defaults to the current word to be completed.
3017
+ # --sfx=<suffix>: A suffix to be appended to each fully completed
3018
+ # configuration variable name (but not to sections or
3019
+ # subsections) instead of the default space.
3020
+ __git_complete_config_variable_name ()
3021
+ {
3022
+ local cur_="$cur" sfx
3023
+
3024
+ while test $# != 0; do
3025
+ case "$1" in
3026
+ --cur=*) cur_="${1##--cur=}" ;;
3027
+ --sfx=*) sfx="${1##--sfx=}" ;;
3028
+ *) return 1 ;;
3029
+ esac
3030
+ shift
3031
+ done
3032
+
3033
+ case "$cur_" in
3034
+ branch.*.*|guitool.*.*|difftool.*.*|man.*.*|mergetool.*.*|remote.*.*|submodule.*.*|url.*.*)
3035
+ local pfx="${cur_%.*}."
3036
+ cur_="${cur_##*.}"
3037
+ local section="${pfx%.*.}"
3038
+ __git_compute_second_level_config_vars_for_section "${section}"
3039
+ local this_section="__git_second_level_config_vars_for_section_${section}"
3040
+ __gitcomp "$(__git_indirect "${this_section}")" "$pfx" "$cur_" "$sfx"
3041
+ return
3042
+ ;;
3043
+ branch.*)
3044
+ local pfx="${cur_%.*}."
3045
+ cur_="${cur_#*.}"
3046
+ local section="${pfx%.}"
3047
+ __gitcomp_direct "$(__git_heads "$pfx" "$cur_" ".")"
3048
+ __git_compute_first_level_config_vars_for_section "${section}"
3049
+ local this_section="__git_first_level_config_vars_for_section_${section}"
3050
+ __gitcomp_nl_append "$(__git_indirect "${this_section}")" "$pfx" "$cur_" "${sfx:- }"
3051
+ return
3052
+ ;;
3053
+ pager.*)
3054
+ local pfx="${cur_%.*}."
3055
+ cur_="${cur_#*.}"
3056
+ __git_compute_all_commands
3057
+ __gitcomp_nl "$__git_all_commands" "$pfx" "$cur_" "${sfx:- }"
3058
+ return
3059
+ ;;
3060
+ remote.*)
3061
+ local pfx="${cur_%.*}."
3062
+ cur_="${cur_#*.}"
3063
+ local section="${pfx%.}"
3064
+ __gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "."
3065
+ __git_compute_first_level_config_vars_for_section "${section}"
3066
+ local this_section="__git_first_level_config_vars_for_section_${section}"
3067
+ __gitcomp_nl_append "$(__git_indirect "${this_section}")" "$pfx" "$cur_" "${sfx:- }"
3068
+ return
3069
+ ;;
3070
+ submodule.*)
3071
+ local pfx="${cur_%.*}."
3072
+ cur_="${cur_#*.}"
3073
+ local section="${pfx%.}"
3074
+ __gitcomp_nl "$(__git config -f "$(__git rev-parse --show-toplevel)/.gitmodules" --get-regexp 'submodule.*.path' | awk -F. '{print $2}')" "$pfx" "$cur_" "."
3075
+ __git_compute_first_level_config_vars_for_section "${section}"
3076
+ local this_section="__git_first_level_config_vars_for_section_${section}"
3077
+ __gitcomp_nl_append "$(__git_indirect "${this_section}")" "$pfx" "$cur_" "${sfx:- }"
3078
+ return
3079
+ ;;
3080
+ *.*)
3081
+ __git_compute_config_vars
3082
+ __gitcomp "$__git_config_vars" "" "$cur_" "$sfx"
3083
+ ;;
3084
+ *)
3085
+ __git_compute_config_sections
3086
+ __gitcomp "$__git_config_sections" "" "$cur_" "."
3087
+ ;;
3088
+ esac
3089
+ }
3090
+
3091
+ # Completes '='-separated configuration sections/variable names and values
3092
+ # for 'git -c section.name=value'.
3093
+ #
3094
+ # Usage: __git_complete_config_variable_name_and_value [<option>]...
3095
+ # --cur=<word>: The current configuration section/variable name/value to be
3096
+ # completed. Defaults to the current word to be completed.
3097
+ __git_complete_config_variable_name_and_value ()
3098
+ {
3099
+ local cur_="$cur"
3100
+
3101
+ while test $# != 0; do
3102
+ case "$1" in
3103
+ --cur=*) cur_="${1##--cur=}" ;;
3104
+ *) return 1 ;;
3105
+ esac
3106
+ shift
3107
+ done
3108
+
3109
+ case "$cur_" in
3110
+ *=*)
3111
+ __git_complete_config_variable_value \
3112
+ --varname="${cur_%%=*}" --cur="${cur_#*=}"
3113
+ ;;
3114
+ *)
3115
+ __git_complete_config_variable_name --cur="$cur_" --sfx='='
3116
+ ;;
3117
+ esac
3118
+ }
3119
+
3120
+ _git_config ()
3121
+ {
3122
+ local subcommands subcommand
3123
+
3124
+ __git_resolve_builtins "config"
3125
+
3126
+ subcommands="$___git_resolved_builtins"
3127
+ subcommand="$(__git_find_subcommand "$subcommands")"
3128
+
3129
+ if [ -z "$subcommand" ]
3130
+ then
3131
+ __gitcomp "$subcommands"
3132
+ return
3133
+ fi
3134
+
3135
+ case "$cur" in
3136
+ --*)
3137
+ __gitcomp_builtin "config_$subcommand"
3138
+ return
3139
+ ;;
3140
+ esac
3141
+
3142
+ case "$subcommand" in
3143
+ get)
3144
+ __gitcomp_nl "$(__git_config_get_set_variables)"
3145
+ ;;
3146
+ set)
3147
+ case "$prev" in
3148
+ *.*)
3149
+ __git_complete_config_variable_value
3150
+ ;;
3151
+ *)
3152
+ __git_complete_config_variable_name
3153
+ ;;
3154
+ esac
3155
+ ;;
3156
+ unset)
3157
+ __gitcomp_nl "$(__git_config_get_set_variables)"
3158
+ ;;
3159
+ esac
3160
+ }
3161
+
3162
+ _git_remote ()
3163
+ {
3164
+ local subcommands="
3165
+ add rename remove set-head set-branches
3166
+ get-url set-url show prune update
3167
+ "
3168
+ local subcommand="$(__git_find_on_cmdline "$subcommands")"
3169
+ if [ -z "$subcommand" ]; then
3170
+ case "$cur" in
3171
+ --*)
3172
+ __gitcomp_builtin remote
3173
+ ;;
3174
+ *)
3175
+ __gitcomp "$subcommands"
3176
+ ;;
3177
+ esac
3178
+ return
3179
+ fi
3180
+
3181
+ case "$subcommand,$cur" in
3182
+ add,--*)
3183
+ __gitcomp_builtin remote_add
3184
+ ;;
3185
+ add,*)
3186
+ ;;
3187
+ set-head,--*)
3188
+ __gitcomp_builtin remote_set-head
3189
+ ;;
3190
+ set-branches,--*)
3191
+ __gitcomp_builtin remote_set-branches
3192
+ ;;
3193
+ set-head,*|set-branches,*)
3194
+ __git_complete_remote_or_refspec
3195
+ ;;
3196
+ update,--*)
3197
+ __gitcomp_builtin remote_update
3198
+ ;;
3199
+ update,*)
3200
+ __gitcomp "$(__git_remotes) $(__git_get_config_variables "remotes")"
3201
+ ;;
3202
+ set-url,--*)
3203
+ __gitcomp_builtin remote_set-url
3204
+ ;;
3205
+ get-url,--*)
3206
+ __gitcomp_builtin remote_get-url
3207
+ ;;
3208
+ prune,--*)
3209
+ __gitcomp_builtin remote_prune
3210
+ ;;
3211
+ *)
3212
+ __gitcomp_nl "$(__git_remotes)"
3213
+ ;;
3214
+ esac
3215
+ }
3216
+
3217
+ _git_replace ()
3218
+ {
3219
+ case "$cur" in
3220
+ --format=*)
3221
+ __gitcomp "short medium long" "" "${cur##--format=}"
3222
+ return
3223
+ ;;
3224
+ --*)
3225
+ __gitcomp_builtin replace
3226
+ return
3227
+ ;;
3228
+ esac
3229
+ __git_complete_refs
3230
+ }
3231
+
3232
+ _git_rerere ()
3233
+ {
3234
+ local subcommands="clear forget diff remaining status gc"
3235
+ local subcommand="$(__git_find_on_cmdline "$subcommands")"
3236
+ if test -z "$subcommand"
3237
+ then
3238
+ __gitcomp "$subcommands"
3239
+ return
3240
+ fi
3241
+ }
3242
+
3243
+ _git_reset ()
3244
+ {
3245
+ __git_has_doubledash && return
3246
+
3247
+ case "$cur" in
3248
+ --*)
3249
+ __gitcomp_builtin reset
3250
+ return
3251
+ ;;
3252
+ esac
3253
+ __git_complete_refs
3254
+ }
3255
+
3256
+ _git_restore ()
3257
+ {
3258
+ case "$prev" in
3259
+ -s)
3260
+ __git_complete_refs
3261
+ return
3262
+ ;;
3263
+ esac
3264
+
3265
+ case "$cur" in
3266
+ --conflict=*)
3267
+ __gitcomp "diff3 merge zdiff3" "" "${cur##--conflict=}"
3268
+ ;;
3269
+ --source=*)
3270
+ __git_complete_refs --cur="${cur##--source=}"
3271
+ ;;
3272
+ --*)
3273
+ __gitcomp_builtin restore
3274
+ ;;
3275
+ *)
3276
+ if __git_pseudoref_exists HEAD; then
3277
+ __git_complete_index_file "--modified"
3278
+ fi
3279
+ esac
3280
+ }
3281
+
3282
+ __git_revert_inprogress_options=$__git_sequencer_inprogress_options
3283
+
3284
+ _git_revert ()
3285
+ {
3286
+ if __git_pseudoref_exists REVERT_HEAD; then
3287
+ __gitcomp "$__git_revert_inprogress_options"
3288
+ return
3289
+ fi
3290
+ __git_complete_strategy && return
3291
+ case "$cur" in
3292
+ --*)
3293
+ __gitcomp_builtin revert "" \
3294
+ "$__git_revert_inprogress_options"
3295
+ return
3296
+ ;;
3297
+ esac
3298
+ __git_complete_refs
3299
+ }
3300
+
3301
+ _git_rm ()
3302
+ {
3303
+ case "$cur" in
3304
+ --*)
3305
+ __gitcomp_builtin rm
3306
+ return
3307
+ ;;
3308
+ esac
3309
+
3310
+ __git_complete_index_file "--cached"
3311
+ }
3312
+
3313
+ _git_shortlog ()
3314
+ {
3315
+ __git_has_doubledash && return
3316
+
3317
+ case "$cur" in
3318
+ --*)
3319
+ __gitcomp "
3320
+ $__git_log_common_options
3321
+ $__git_log_shortlog_options
3322
+ --committer --numbered --summary --email
3323
+ "
3324
+ return
3325
+ ;;
3326
+ esac
3327
+ __git_complete_revlist
3328
+ }
3329
+
3330
+ _git_show ()
3331
+ {
3332
+ __git_has_doubledash && return
3333
+
3334
+ case "$cur" in
3335
+ --pretty=*|--format=*)
3336
+ __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
3337
+ " "" "${cur#*=}"
3338
+ return
3339
+ ;;
3340
+ --diff-algorithm=*)
3341
+ __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
3342
+ return
3343
+ ;;
3344
+ --submodule=*)
3345
+ __gitcomp "$__git_diff_submodule_formats" "" "${cur##--submodule=}"
3346
+ return
3347
+ ;;
3348
+ --color-moved=*)
3349
+ __gitcomp "$__git_color_moved_opts" "" "${cur##--color-moved=}"
3350
+ return
3351
+ ;;
3352
+ --color-moved-ws=*)
3353
+ __gitcomp "$__git_color_moved_ws_opts" "" "${cur##--color-moved-ws=}"
3354
+ return
3355
+ ;;
3356
+ --ws-error-highlight=*)
3357
+ __gitcomp "$__git_ws_error_highlight_opts" "" "${cur##--ws-error-highlight=}"
3358
+ return
3359
+ ;;
3360
+ --diff-merges=*)
3361
+ __gitcomp "$__git_diff_merges_opts" "" "${cur##--diff-merges=}"
3362
+ return
3363
+ ;;
3364
+ --*)
3365
+ __gitcomp "--pretty= --format= --abbrev-commit --no-abbrev-commit
3366
+ --oneline --show-signature
3367
+ --expand-tabs --expand-tabs= --no-expand-tabs
3368
+ $__git_log_show_options
3369
+ $__git_diff_common_options
3370
+ "
3371
+ return
3372
+ ;;
3373
+ esac
3374
+ __git_complete_revlist_file
3375
+ }
3376
+
3377
+ _git_show_branch ()
3378
+ {
3379
+ case "$cur" in
3380
+ --*)
3381
+ __gitcomp_builtin show-branch
3382
+ return
3383
+ ;;
3384
+ esac
3385
+ __git_complete_revlist
3386
+ }
3387
+
3388
+ __gitcomp_directories ()
3389
+ {
3390
+ local _tmp_dir _tmp_completions _found=0
3391
+
3392
+ # Get the directory of the current token; this differs from dirname
3393
+ # in that it keeps up to the final trailing slash. If no slash found
3394
+ # that's fine too.
3395
+ [[ "$cur" =~ .*/ ]]
3396
+ _tmp_dir=$BASH_REMATCH
3397
+
3398
+ # Find possible directory completions, adding trailing '/' characters,
3399
+ # de-quoting, and handling unusual characters.
3400
+ while IFS= read -r -d $'\0' c ; do
3401
+ # If there are directory completions, find ones that start
3402
+ # with "$cur", the current token, and put those in COMPREPLY
3403
+ if [[ $c == "$cur"* ]]; then
3404
+ COMPREPLY+=("$c/")
3405
+ _found=1
3406
+ fi
3407
+ done < <(__git ls-tree -z -d --name-only HEAD $_tmp_dir)
3408
+
3409
+ if [[ $_found == 0 ]] && [[ "$cur" =~ /$ ]]; then
3410
+ # No possible further completions any deeper, so assume we're at
3411
+ # a leaf directory and just consider it complete
3412
+ __gitcomp_direct_append "$cur "
3413
+ elif [[ $_found == 0 ]]; then
3414
+ # No possible completions found. Avoid falling back to
3415
+ # bash's default file and directory completion, because all
3416
+ # valid completions have already been searched and the
3417
+ # fallbacks can do nothing but mislead. In fact, they can
3418
+ # mislead in three different ways:
3419
+ # 1) Fallback file completion makes no sense when asking
3420
+ # for directory completions, as this function does.
3421
+ # 2) Fallback directory completion is bad because
3422
+ # e.g. "/pro" is invalid and should NOT complete to
3423
+ # "/proc".
3424
+ # 3) Fallback file/directory completion only completes
3425
+ # on paths that exist in the current working tree,
3426
+ # i.e. which are *already* part of their
3427
+ # sparse-checkout. Thus, normal file and directory
3428
+ # completion is always useless for "git
3429
+ # sparse-checkout add" and is also problematic for
3430
+ # "git sparse-checkout set" unless using it to
3431
+ # strictly narrow the checkout.
3432
+ COMPREPLY=( "" )
3433
+ fi
3434
+ }
3435
+
3436
+ # In non-cone mode, the arguments to {set,add} are supposed to be
3437
+ # patterns, relative to the toplevel directory. These can be any kind
3438
+ # of general pattern, like 'subdir/*.c' and we can't complete on all
3439
+ # of those. However, if the user presses Tab to get tab completion, we
3440
+ # presume that they are trying to provide a pattern that names a specific
3441
+ # path.
3442
+ __gitcomp_slash_leading_paths ()
3443
+ {
3444
+ local dequoted_word pfx="" cur_ toplevel
3445
+
3446
+ # Since we are dealing with a sparse-checkout, subdirectories may not
3447
+ # exist in the local working copy. Therefore, we want to run all
3448
+ # ls-files commands relative to the repository toplevel.
3449
+ toplevel="$(git rev-parse --show-toplevel)/"
3450
+
3451
+ __git_dequote "$cur"
3452
+
3453
+ # If the paths provided by the user already start with '/', then
3454
+ # they are considered relative to the toplevel of the repository
3455
+ # already. If they do not start with /, then we need to adjust
3456
+ # them to start with the appropriate prefix.
3457
+ case "$cur" in
3458
+ /*)
3459
+ cur="${cur:1}"
3460
+ ;;
3461
+ *)
3462
+ pfx="$(__git rev-parse --show-prefix)"
3463
+ esac
3464
+
3465
+ # Since sparse-index is limited to cone-mode, in non-cone-mode the
3466
+ # list of valid paths is precisely the cached files in the index.
3467
+ #
3468
+ # NEEDSWORK:
3469
+ # 1) We probably need to take care of cases where ls-files
3470
+ # responds with special quoting.
3471
+ # 2) We probably need to take care of cases where ${cur} has
3472
+ # some kind of special quoting.
3473
+ # 3) On top of any quoting from 1 & 2, we have to provide an extra
3474
+ # level of quoting for any paths that contain a '*', '?', '\',
3475
+ # '[', ']', or leading '#' or '!' since those will be
3476
+ # interpreted by sparse-checkout as something other than a
3477
+ # literal path character.
3478
+ # Since there are two types of quoting here, this might get really
3479
+ # complex. For now, just punt on all of this...
3480
+ completions="$(__git -C "${toplevel}" -c core.quotePath=false \
3481
+ ls-files --cached -- "${pfx}${cur}*" \
3482
+ | sed -e s%^%/% -e 's%$% %')"
3483
+ # Note, above, though that we needed all of the completions to be
3484
+ # prefixed with a '/', and we want to add a space so that bash
3485
+ # completion will actually complete an entry and let us move on to
3486
+ # the next one.
3487
+
3488
+ # Return what we've found.
3489
+ if test -n "$completions"; then
3490
+ # We found some completions; return them
3491
+ local IFS=$'\n'
3492
+ COMPREPLY=($completions)
3493
+ else
3494
+ # Do NOT fall back to bash-style all-local-files-and-dirs
3495
+ # when we find no match. Such options are worse than
3496
+ # useless:
3497
+ # 1. "git sparse-checkout add" needs paths that are NOT
3498
+ # currently in the working copy. "git
3499
+ # sparse-checkout set" does as well, except in the
3500
+ # special cases when users are only trying to narrow
3501
+ # their sparse checkout to a subset of what they
3502
+ # already have.
3503
+ #
3504
+ # 2. A path like '.config' is ambiguous as to whether
3505
+ # the user wants all '.config' files throughout the
3506
+ # tree, or just the one under the current directory.
3507
+ # It would result in a warning from the
3508
+ # sparse-checkout command due to this. As such, all
3509
+ # completions of paths should be prefixed with a
3510
+ # '/'.
3511
+ #
3512
+ # 3. We don't want paths prefixed with a '/' to
3513
+ # complete files in the system root directory, we
3514
+ # want it to complete on files relative to the
3515
+ # repository root.
3516
+ #
3517
+ # As such, make sure that NO completions are offered rather
3518
+ # than falling back to bash's default completions.
3519
+ COMPREPLY=( "" )
3520
+ fi
3521
+ }
3522
+
3523
+ _git_sparse_checkout ()
3524
+ {
3525
+ local subcommands="list init set disable add reapply"
3526
+ local subcommand="$(__git_find_on_cmdline "$subcommands")"
3527
+ local using_cone=true
3528
+ if [ -z "$subcommand" ]; then
3529
+ __gitcomp "$subcommands"
3530
+ return
3531
+ fi
3532
+
3533
+ case "$subcommand,$cur" in
3534
+ *,--*)
3535
+ __gitcomp_builtin sparse-checkout_$subcommand "" "--"
3536
+ ;;
3537
+ set,*|add,*)
3538
+ if [[ "$(__git config core.sparseCheckout)" == "true" &&
3539
+ "$(__git config core.sparseCheckoutCone)" == "false" &&
3540
+ -z "$(__git_find_on_cmdline --cone)" ]]; then
3541
+ using_cone=false
3542
+ fi
3543
+ if [[ -n "$(__git_find_on_cmdline --no-cone)" ]]; then
3544
+ using_cone=false
3545
+ fi
3546
+ if [[ "$using_cone" == "true" ]]; then
3547
+ __gitcomp_directories
3548
+ else
3549
+ __gitcomp_slash_leading_paths
3550
+ fi
3551
+ esac
3552
+ }
3553
+
3554
+ _git_stash ()
3555
+ {
3556
+ local subcommands='push list show apply clear drop pop create branch import export'
3557
+ local subcommand="$(__git_find_on_cmdline "$subcommands save")"
3558
+
3559
+ if [ -z "$subcommand" ]; then
3560
+ case "$((cword - __git_cmd_idx)),$cur" in
3561
+ *,--*)
3562
+ __gitcomp_builtin stash_push
3563
+ ;;
3564
+ 1,sa*)
3565
+ __gitcomp "save"
3566
+ ;;
3567
+ 1,*)
3568
+ __gitcomp "$subcommands"
3569
+ ;;
3570
+ esac
3571
+ return
3572
+ fi
3573
+
3574
+ case "$subcommand,$cur" in
3575
+ list,--*)
3576
+ # NEEDSWORK: can we somehow unify this with the options in _git_log() and _git_show()
3577
+ __gitcomp_builtin stash_list "$__git_log_common_options $__git_diff_common_options"
3578
+ ;;
3579
+ show,--*)
3580
+ __gitcomp_builtin stash_show "$__git_diff_common_options"
3581
+ ;;
3582
+ export,--*)
3583
+ __gitcomp_builtin stash_export "--print --to-ref"
3584
+ ;;
3585
+ *,--*)
3586
+ __gitcomp_builtin "stash_$subcommand"
3587
+ ;;
3588
+ branch,*)
3589
+ if [ $cword -eq $((__git_cmd_idx+2)) ]; then
3590
+ __git_complete_refs
3591
+ else
3592
+ __gitcomp_nl "$(__git stash list \
3593
+ | sed -n -e 's/:.*//p')"
3594
+ fi
3595
+ ;;
3596
+ import,*)
3597
+ __git_complete_refs
3598
+ ;;
3599
+ show,*|apply,*|drop,*|pop,*|export,*)
3600
+ __gitcomp_nl "$(__git stash list \
3601
+ | sed -n -e 's/:.*//p')"
3602
+ ;;
3603
+ esac
3604
+ }
3605
+
3606
+ _git_submodule ()
3607
+ {
3608
+ __git_has_doubledash && return
3609
+
3610
+ local subcommands="add status init deinit update set-branch set-url summary foreach sync absorbgitdirs"
3611
+ local subcommand="$(__git_find_on_cmdline "$subcommands")"
3612
+ if [ -z "$subcommand" ]; then
3613
+ case "$cur" in
3614
+ --*)
3615
+ __gitcomp "--quiet"
3616
+ ;;
3617
+ *)
3618
+ __gitcomp "$subcommands"
3619
+ ;;
3620
+ esac
3621
+ return
3622
+ fi
3623
+
3624
+ case "$subcommand,$cur" in
3625
+ add,--*)
3626
+ __gitcomp "--branch --force --name --reference --depth"
3627
+ ;;
3628
+ status,--*)
3629
+ __gitcomp "--cached --recursive"
3630
+ ;;
3631
+ deinit,--*)
3632
+ __gitcomp "--force --all"
3633
+ ;;
3634
+ update,--*)
3635
+ __gitcomp "
3636
+ --init --remote --no-fetch
3637
+ --recommend-shallow --no-recommend-shallow
3638
+ --force --rebase --merge --reference --depth --recursive --jobs
3639
+ "
3640
+ ;;
3641
+ set-branch,--*)
3642
+ __gitcomp "--default --branch"
3643
+ ;;
3644
+ summary,--*)
3645
+ __gitcomp "--cached --files --summary-limit"
3646
+ ;;
3647
+ foreach,--*|sync,--*)
3648
+ __gitcomp "--recursive"
3649
+ ;;
3650
+ *)
3651
+ ;;
3652
+ esac
3653
+ }
3654
+
3655
+ _git_svn ()
3656
+ {
3657
+ local subcommands="
3658
+ init fetch clone rebase dcommit log find-rev
3659
+ set-tree commit-diff info create-ignore propget
3660
+ proplist show-ignore show-externals branch tag blame
3661
+ migrate mkdirs reset gc
3662
+ "
3663
+ local subcommand="$(__git_find_on_cmdline "$subcommands")"
3664
+ if [ -z "$subcommand" ]; then
3665
+ __gitcomp "$subcommands"
3666
+ else
3667
+ local remote_opts="--username= --config-dir= --no-auth-cache"
3668
+ local fc_opts="
3669
+ --follow-parent --authors-file= --repack=
3670
+ --no-metadata --use-svm-props --use-svnsync-props
3671
+ --log-window-size= --no-checkout --quiet
3672
+ --repack-flags --use-log-author --localtime
3673
+ --add-author-from
3674
+ --recursive
3675
+ --ignore-paths= --include-paths= $remote_opts
3676
+ "
3677
+ local init_opts="
3678
+ --template= --shared= --trunk= --tags=
3679
+ --branches= --stdlayout --minimize-url
3680
+ --no-metadata --use-svm-props --use-svnsync-props
3681
+ --rewrite-root= --prefix= $remote_opts
3682
+ "
3683
+ local cmt_opts="
3684
+ --edit --rmdir --find-copies-harder --copy-similarity=
3685
+ "
3686
+
3687
+ case "$subcommand,$cur" in
3688
+ fetch,--*)
3689
+ __gitcomp "--revision= --fetch-all $fc_opts"
3690
+ ;;
3691
+ clone,--*)
3692
+ __gitcomp "--revision= $fc_opts $init_opts"
3693
+ ;;
3694
+ init,--*)
3695
+ __gitcomp "$init_opts"
3696
+ ;;
3697
+ dcommit,--*)
3698
+ __gitcomp "
3699
+ --merge --strategy= --verbose --dry-run
3700
+ --fetch-all --no-rebase --commit-url
3701
+ --revision --interactive $cmt_opts $fc_opts
3702
+ "
3703
+ ;;
3704
+ set-tree,--*)
3705
+ __gitcomp "--stdin $cmt_opts $fc_opts"
3706
+ ;;
3707
+ create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\
3708
+ show-externals,--*|mkdirs,--*)
3709
+ __gitcomp "--revision="
3710
+ ;;
3711
+ log,--*)
3712
+ __gitcomp "
3713
+ --limit= --revision= --verbose --incremental
3714
+ --oneline --show-commit --non-recursive
3715
+ --authors-file= --color
3716
+ "
3717
+ ;;
3718
+ rebase,--*)
3719
+ __gitcomp "
3720
+ --merge --verbose --strategy= --local
3721
+ --fetch-all --dry-run $fc_opts
3722
+ "
3723
+ ;;
3724
+ commit-diff,--*)
3725
+ __gitcomp "--message= --file= --revision= $cmt_opts"
3726
+ ;;
3727
+ info,--*)
3728
+ __gitcomp "--url"
3729
+ ;;
3730
+ branch,--*)
3731
+ __gitcomp "--dry-run --message --tag"
3732
+ ;;
3733
+ tag,--*)
3734
+ __gitcomp "--dry-run --message"
3735
+ ;;
3736
+ blame,--*)
3737
+ __gitcomp "--git-format"
3738
+ ;;
3739
+ migrate,--*)
3740
+ __gitcomp "
3741
+ --config-dir= --ignore-paths= --minimize
3742
+ --no-auth-cache --username=
3743
+ "
3744
+ ;;
3745
+ reset,--*)
3746
+ __gitcomp "--revision= --parent"
3747
+ ;;
3748
+ *)
3749
+ ;;
3750
+ esac
3751
+ fi
3752
+ }
3753
+
3754
+ _git_symbolic_ref () {
3755
+ case "$cur" in
3756
+ --*)
3757
+ __gitcomp_builtin symbolic-ref
3758
+ return
3759
+ ;;
3760
+ esac
3761
+
3762
+ __git_complete_refs
3763
+ }
3764
+
3765
+ _git_tag ()
3766
+ {
3767
+ local i c="$__git_cmd_idx" f=0
3768
+ while [ $c -lt $cword ]; do
3769
+ i="${words[c]}"
3770
+ case "$i" in
3771
+ -d|--delete|-v|--verify)
3772
+ __gitcomp_direct "$(__git_tags "" "$cur" " ")"
3773
+ return
3774
+ ;;
3775
+ -f)
3776
+ f=1
3777
+ ;;
3778
+ esac
3779
+ ((c++))
3780
+ done
3781
+
3782
+ case "$prev" in
3783
+ -m|-F)
3784
+ ;;
3785
+ -*|tag)
3786
+ if [ $f = 1 ]; then
3787
+ __gitcomp_direct "$(__git_tags "" "$cur" " ")"
3788
+ fi
3789
+ ;;
3790
+ *)
3791
+ __git_complete_refs
3792
+ ;;
3793
+ esac
3794
+
3795
+ case "$cur" in
3796
+ --*)
3797
+ __gitcomp_builtin tag
3798
+ ;;
3799
+ esac
3800
+ }
3801
+
3802
+ _git_whatchanged ()
3803
+ {
3804
+ _git_log
3805
+ }
3806
+
3807
+ __git_complete_worktree_paths ()
3808
+ {
3809
+ local IFS=$'\n'
3810
+ # Generate completion reply from worktree list skipping the first
3811
+ # entry: it's the path of the main worktree, which can't be moved,
3812
+ # removed, locked, etc.
3813
+ __gitcomp_nl "$(__git worktree list --porcelain |
3814
+ sed -n -e '2,$ s/^worktree //p')"
3815
+ }
3816
+
3817
+ _git_worktree ()
3818
+ {
3819
+ local subcommands="add list lock move prune remove unlock"
3820
+ local subcommand subcommand_idx
3821
+
3822
+ subcommand="$(__git_find_on_cmdline --show-idx "$subcommands")"
3823
+ subcommand_idx="${subcommand% *}"
3824
+ subcommand="${subcommand#* }"
3825
+
3826
+ case "$subcommand,$cur" in
3827
+ ,*)
3828
+ __gitcomp "$subcommands"
3829
+ ;;
3830
+ *,--*)
3831
+ __gitcomp_builtin worktree_$subcommand
3832
+ ;;
3833
+ add,*) # usage: git worktree add [<options>] <path> [<commit-ish>]
3834
+ # Here we are not completing an --option, it's either the
3835
+ # path or a ref.
3836
+ case "$prev" in
3837
+ -b|-B) # Complete refs for branch to be created/reset.
3838
+ __git_complete_refs
3839
+ ;;
3840
+ -*) # The previous word is an -o|--option without an
3841
+ # unstuck argument: have to complete the path for
3842
+ # the new worktree, so don't list anything, but let
3843
+ # Bash fall back to filename completion.
3844
+ ;;
3845
+ *) # The previous word is not an --option, so it must
3846
+ # be either the 'add' subcommand, the unstuck
3847
+ # argument of an option (e.g. branch for -b|-B), or
3848
+ # the path for the new worktree.
3849
+ if [ $cword -eq $((subcommand_idx+1)) ]; then
3850
+ # Right after the 'add' subcommand: have to
3851
+ # complete the path, so fall back to Bash
3852
+ # filename completion.
3853
+ :
3854
+ else
3855
+ case "${words[cword-2]}" in
3856
+ -b|-B) # After '-b <branch>': have to
3857
+ # complete the path, so fall back
3858
+ # to Bash filename completion.
3859
+ ;;
3860
+ *) # After the path: have to complete
3861
+ # the ref to be checked out.
3862
+ __git_complete_refs
3863
+ ;;
3864
+ esac
3865
+ fi
3866
+ ;;
3867
+ esac
3868
+ ;;
3869
+ lock,*|remove,*|unlock,*)
3870
+ __git_complete_worktree_paths
3871
+ ;;
3872
+ move,*)
3873
+ if [ $cword -eq $((subcommand_idx+1)) ]; then
3874
+ # The first parameter must be an existing working
3875
+ # tree to be moved.
3876
+ __git_complete_worktree_paths
3877
+ else
3878
+ # The second parameter is the destination: it could
3879
+ # be any path, so don't list anything, but let Bash
3880
+ # fall back to filename completion.
3881
+ :
3882
+ fi
3883
+ ;;
3884
+ esac
3885
+ }
3886
+
3887
+ __git_complete_common () {
3888
+ local command="$1"
3889
+
3890
+ case "$cur" in
3891
+ --*)
3892
+ __gitcomp_builtin "$command"
3893
+ ;;
3894
+ esac
3895
+ }
3896
+
3897
+ __git_cmds_with_parseopt_helper=
3898
+ __git_support_parseopt_helper () {
3899
+ test -n "$__git_cmds_with_parseopt_helper" ||
3900
+ __git_cmds_with_parseopt_helper="$(__git --list-cmds=parseopt)"
3901
+
3902
+ case " $__git_cmds_with_parseopt_helper " in
3903
+ *" $1 "*)
3904
+ return 0
3905
+ ;;
3906
+ *)
3907
+ return 1
3908
+ ;;
3909
+ esac
3910
+ }
3911
+
3912
+ __git_have_func () {
3913
+ declare -f -- "$1" >/dev/null 2>&1
3914
+ }
3915
+
3916
+ __git_complete_command () {
3917
+ local command="$1"
3918
+ local completion_func="_git_${command//-/_}"
3919
+ if ! __git_have_func $completion_func &&
3920
+ __git_have_func _completion_loader
3921
+ then
3922
+ _completion_loader "git-$command"
3923
+ fi
3924
+ if __git_have_func $completion_func
3925
+ then
3926
+ $completion_func
3927
+ return 0
3928
+ elif __git_support_parseopt_helper "$command"
3929
+ then
3930
+ __git_complete_common "$command"
3931
+ return 0
3932
+ else
3933
+ return 1
3934
+ fi
3935
+ }
3936
+
3937
+ __git_main ()
3938
+ {
3939
+ local i c=1 command __git_dir __git_repo_path
3940
+ local __git_C_args C_args_count=0
3941
+ local __git_cmd_idx
3942
+
3943
+ while [ $c -lt $cword ]; do
3944
+ i="${words[c]}"
3945
+ case "$i" in
3946
+ --git-dir=*)
3947
+ __git_dir="${i#--git-dir=}"
3948
+ ;;
3949
+ --git-dir)
3950
+ ((c++))
3951
+ __git_dir="${words[c]}"
3952
+ ;;
3953
+ --bare)
3954
+ __git_dir="."
3955
+ ;;
3956
+ --help)
3957
+ command="help"
3958
+ break
3959
+ ;;
3960
+ -c|--work-tree|--namespace)
3961
+ ((c++))
3962
+ ;;
3963
+ -C)
3964
+ __git_C_args[C_args_count++]=-C
3965
+ ((c++))
3966
+ __git_C_args[C_args_count++]="${words[c]}"
3967
+ ;;
3968
+ -*)
3969
+ ;;
3970
+ *)
3971
+ command="$i"
3972
+ __git_cmd_idx="$c"
3973
+ break
3974
+ ;;
3975
+ esac
3976
+ ((c++))
3977
+ done
3978
+
3979
+ if [ -z "${command-}" ]; then
3980
+ case "$prev" in
3981
+ --git-dir|-C|--work-tree)
3982
+ # these need a path argument, let's fall back to
3983
+ # Bash filename completion
3984
+ return
3985
+ ;;
3986
+ -c)
3987
+ __git_complete_config_variable_name_and_value
3988
+ return
3989
+ ;;
3990
+ --namespace)
3991
+ # we don't support completing these options' arguments
3992
+ return
3993
+ ;;
3994
+ esac
3995
+ case "$cur" in
3996
+ --*)
3997
+ __gitcomp "
3998
+ --paginate
3999
+ --no-pager
4000
+ --git-dir=
4001
+ --bare
4002
+ --version
4003
+ --exec-path
4004
+ --exec-path=
4005
+ --html-path
4006
+ --man-path
4007
+ --info-path
4008
+ --work-tree=
4009
+ --namespace=
4010
+ --no-replace-objects
4011
+ --help
4012
+ "
4013
+ ;;
4014
+ *)
4015
+ if test -n "${GIT_TESTING_PORCELAIN_COMMAND_LIST-}"
4016
+ then
4017
+ __gitcomp "$GIT_TESTING_PORCELAIN_COMMAND_LIST"
4018
+ else
4019
+ local list_cmds=list-mainporcelain,others,nohelpers,alias,list-complete,config
4020
+
4021
+ if test "${GIT_COMPLETION_SHOW_ALL_COMMANDS-}" = "1"
4022
+ then
4023
+ list_cmds=builtins,$list_cmds
4024
+ fi
4025
+ __gitcomp "$(__git --list-cmds=$list_cmds)"
4026
+ fi
4027
+ ;;
4028
+ esac
4029
+ return
4030
+ fi
4031
+
4032
+ __git_complete_command "$command" && return
4033
+
4034
+ local expansion=$(__git_aliased_command "$command")
4035
+ if [ -n "$expansion" ]; then
4036
+ words[1]=$expansion
4037
+ __git_complete_command "$expansion"
4038
+ fi
4039
+ }
4040
+
4041
+ __gitk_main ()
4042
+ {
4043
+ __git_has_doubledash && return
4044
+
4045
+ local __git_repo_path
4046
+ __git_find_repo_path
4047
+
4048
+ local merge=""
4049
+ if __git_pseudoref_exists MERGE_HEAD; then
4050
+ merge="--merge"
4051
+ fi
4052
+ case "$cur" in
4053
+ --*)
4054
+ __gitcomp "
4055
+ $__git_log_common_options
4056
+ $__git_log_gitk_options
4057
+ $merge
4058
+ "
4059
+ return
4060
+ ;;
4061
+ esac
4062
+ __git_complete_revlist
4063
+ }
4064
+
4065
+ if [[ -n ${ZSH_VERSION-} && -z ${GIT_SOURCING_ZSH_COMPLETION-} ]]; then
4066
+ echo "ERROR: this script is obsolete, please see git-completion.zsh" 1>&2
4067
+ return
4068
+ fi
4069
+
4070
+ __git_func_wrap ()
4071
+ {
4072
+ local cur words cword prev
4073
+ local __git_cmd_idx=0
4074
+ _get_comp_words_by_ref -n =: cur words cword prev
4075
+ $1
4076
+ }
4077
+
4078
+ ___git_complete ()
4079
+ {
4080
+ local wrapper="__git_wrap${2}"
4081
+ eval "$wrapper () { __git_func_wrap $2 ; }"
4082
+ complete -o bashdefault -o default -o nospace -F $wrapper $1 2>/dev/null \
4083
+ || complete -o default -o nospace -F $wrapper $1
4084
+ }
4085
+
4086
+ # Setup the completion for git commands
4087
+ # 1: command or alias
4088
+ # 2: function to call (e.g. `git`, `gitk`, `git_fetch`)
4089
+ __git_complete ()
4090
+ {
4091
+ local func
4092
+
4093
+ if __git_have_func $2; then
4094
+ func=$2
4095
+ elif __git_have_func __$2_main; then
4096
+ func=__$2_main
4097
+ elif __git_have_func _$2; then
4098
+ func=_$2
4099
+ else
4100
+ echo "ERROR: could not find function '$2'" 1>&2
4101
+ return 1
4102
+ fi
4103
+ ___git_complete $1 $func
4104
+ }
4105
+
4106
+ ___git_complete git __git_main
4107
+ ___git_complete gitk __gitk_main
4108
+
4109
+ # The following are necessary only for Cygwin, and only are needed
4110
+ # when the user has tab-completed the executable name and consequently
4111
+ # included the '.exe' suffix.
4112
+ #
4113
+ if [ "$OSTYPE" = cygwin ]; then
4114
+ ___git_complete git.exe __git_main
4115
+ fi