git-completion.bash 114 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653
  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
  17. #
  18. # To use these routines:
  19. #
  20. # 1) Copy this file to somewhere (e.g. ~/.git-completion.bash).
  21. # 2) Add the following line to your .bashrc/.zshrc:
  22. # source ~/.git-completion.bash
  23. # 3) Consider changing your PS1 to also show the current branch,
  24. # see git-prompt.sh for details.
  25. #
  26. # If you use complex aliases of form '!f() { ... }; f', you can use the null
  27. # command ':' as the first command in the function body to declare the desired
  28. # completion style. For example '!f() { : git commit ; ... }; f' will
  29. # tell the completion to use commit completion. This also works with aliases
  30. # of form "!sh -c '...'". For example, "!sh -c ': git commit ; ... '".
  31. #
  32. # Compatible with bash 3.2.57.
  33. #
  34. # You can set the following environment variables to influence the behavior of
  35. # the completion routines:
  36. #
  37. # GIT_COMPLETION_CHECKOUT_NO_GUESS
  38. #
  39. # When set to "1", do not include "DWIM" suggestions in git-checkout
  40. # and git-switch completion (e.g., completing "foo" when "origin/foo"
  41. # exists).
  42. #
  43. # GIT_COMPLETION_SHOW_ALL
  44. #
  45. # When set to "1" suggest all options, including options which are
  46. # typically hidden (e.g. '--allow-empty' for 'git commit').
  47. # Discovers the path to the git repository taking any '--git-dir=<path>' and
  48. # '-C <path>' options into account and stores it in the $__git_repo_path
  49. # variable.
  50. __git_find_repo_path ()
  51. {
  52. if [ -n "${__git_repo_path-}" ]; then
  53. # we already know where it is
  54. return
  55. fi
  56. if [ -n "${__git_C_args-}" ]; then
  57. __git_repo_path="$(git "${__git_C_args[@]}" \
  58. ${__git_dir:+--git-dir="$__git_dir"} \
  59. rev-parse --absolute-git-dir 2>/dev/null)"
  60. elif [ -n "${__git_dir-}" ]; then
  61. test -d "$__git_dir" &&
  62. __git_repo_path="$__git_dir"
  63. elif [ -n "${GIT_DIR-}" ]; then
  64. test -d "${GIT_DIR-}" &&
  65. __git_repo_path="$GIT_DIR"
  66. elif [ -d .git ]; then
  67. __git_repo_path=.git
  68. else
  69. __git_repo_path="$(git rev-parse --git-dir 2>/dev/null)"
  70. fi
  71. }
  72. # Deprecated: use __git_find_repo_path() and $__git_repo_path instead
  73. # __gitdir accepts 0 or 1 arguments (i.e., location)
  74. # returns location of .git repo
  75. __gitdir ()
  76. {
  77. if [ -z "${1-}" ]; then
  78. __git_find_repo_path || return 1
  79. echo "$__git_repo_path"
  80. elif [ -d "$1/.git" ]; then
  81. echo "$1/.git"
  82. else
  83. echo "$1"
  84. fi
  85. }
  86. # Runs git with all the options given as argument, respecting any
  87. # '--git-dir=<path>' and '-C <path>' options present on the command line
  88. __git ()
  89. {
  90. git ${__git_C_args:+"${__git_C_args[@]}"} \
  91. ${__git_dir:+--git-dir="$__git_dir"} "$@" 2>/dev/null
  92. }
  93. # Removes backslash escaping, single quotes and double quotes from a word,
  94. # stores the result in the variable $dequoted_word.
  95. # 1: The word to dequote.
  96. __git_dequote ()
  97. {
  98. local rest="$1" len ch
  99. dequoted_word=""
  100. while test -n "$rest"; do
  101. len=${#dequoted_word}
  102. dequoted_word="$dequoted_word${rest%%[\\\'\"]*}"
  103. rest="${rest:$((${#dequoted_word}-$len))}"
  104. case "${rest:0:1}" in
  105. \\)
  106. ch="${rest:1:1}"
  107. case "$ch" in
  108. $'\n')
  109. ;;
  110. *)
  111. dequoted_word="$dequoted_word$ch"
  112. ;;
  113. esac
  114. rest="${rest:2}"
  115. ;;
  116. \')
  117. rest="${rest:1}"
  118. len=${#dequoted_word}
  119. dequoted_word="$dequoted_word${rest%%\'*}"
  120. rest="${rest:$((${#dequoted_word}-$len+1))}"
  121. ;;
  122. \")
  123. rest="${rest:1}"
  124. while test -n "$rest" ; do
  125. len=${#dequoted_word}
  126. dequoted_word="$dequoted_word${rest%%[\\\"]*}"
  127. rest="${rest:$((${#dequoted_word}-$len))}"
  128. case "${rest:0:1}" in
  129. \\)
  130. ch="${rest:1:1}"
  131. case "$ch" in
  132. \"|\\|\$|\`)
  133. dequoted_word="$dequoted_word$ch"
  134. ;;
  135. $'\n')
  136. ;;
  137. *)
  138. dequoted_word="$dequoted_word\\$ch"
  139. ;;
  140. esac
  141. rest="${rest:2}"
  142. ;;
  143. \")
  144. rest="${rest:1}"
  145. break
  146. ;;
  147. esac
  148. done
  149. ;;
  150. esac
  151. done
  152. }
  153. # The following function is based on code from:
  154. #
  155. # bash_completion - programmable completion functions for bash 3.2+
  156. #
  157. # Copyright © 2006-2008, Ian Macdonald <ian@caliban.org>
  158. # © 2009-2010, Bash Completion Maintainers
  159. # <bash-completion-devel@lists.alioth.debian.org>
  160. #
  161. # This program is free software; you can redistribute it and/or modify
  162. # it under the terms of the GNU General Public License as published by
  163. # the Free Software Foundation; either version 2, or (at your option)
  164. # any later version.
  165. #
  166. # This program is distributed in the hope that it will be useful,
  167. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  168. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  169. # GNU General Public License for more details.
  170. #
  171. # You should have received a copy of the GNU General Public License
  172. # along with this program; if not, see <http://www.gnu.org/licenses/>.
  173. #
  174. # The latest version of this software can be obtained here:
  175. #
  176. # http://bash-completion.alioth.debian.org/
  177. #
  178. # RELEASE: 2.x
  179. # This function can be used to access a tokenized list of words
  180. # on the command line:
  181. #
  182. # __git_reassemble_comp_words_by_ref '=:'
  183. # if test "${words_[cword_-1]}" = -w
  184. # then
  185. # ...
  186. # fi
  187. #
  188. # The argument should be a collection of characters from the list of
  189. # word completion separators (COMP_WORDBREAKS) to treat as ordinary
  190. # characters.
  191. #
  192. # This is roughly equivalent to going back in time and setting
  193. # COMP_WORDBREAKS to exclude those characters. The intent is to
  194. # make option types like --date=<type> and <rev>:<path> easy to
  195. # recognize by treating each shell word as a single token.
  196. #
  197. # It is best not to set COMP_WORDBREAKS directly because the value is
  198. # shared with other completion scripts. By the time the completion
  199. # function gets called, COMP_WORDS has already been populated so local
  200. # changes to COMP_WORDBREAKS have no effect.
  201. #
  202. # Output: words_, cword_, cur_.
  203. __git_reassemble_comp_words_by_ref()
  204. {
  205. local exclude i j first
  206. # Which word separators to exclude?
  207. exclude="${1//[^$COMP_WORDBREAKS]}"
  208. cword_=$COMP_CWORD
  209. if [ -z "$exclude" ]; then
  210. words_=("${COMP_WORDS[@]}")
  211. return
  212. fi
  213. # List of word completion separators has shrunk;
  214. # re-assemble words to complete.
  215. for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)); do
  216. # Append each nonempty word consisting of just
  217. # word separator characters to the current word.
  218. first=t
  219. while
  220. [ $i -gt 0 ] &&
  221. [ -n "${COMP_WORDS[$i]}" ] &&
  222. # word consists of excluded word separators
  223. [ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ]
  224. do
  225. # Attach to the previous token,
  226. # unless the previous token is the command name.
  227. if [ $j -ge 2 ] && [ -n "$first" ]; then
  228. ((j--))
  229. fi
  230. first=
  231. words_[$j]=${words_[j]}${COMP_WORDS[i]}
  232. if [ $i = $COMP_CWORD ]; then
  233. cword_=$j
  234. fi
  235. if (($i < ${#COMP_WORDS[@]} - 1)); then
  236. ((i++))
  237. else
  238. # Done.
  239. return
  240. fi
  241. done
  242. words_[$j]=${words_[j]}${COMP_WORDS[i]}
  243. if [ $i = $COMP_CWORD ]; then
  244. cword_=$j
  245. fi
  246. done
  247. }
  248. if ! type _get_comp_words_by_ref >/dev/null 2>&1; then
  249. _get_comp_words_by_ref ()
  250. {
  251. local exclude cur_ words_ cword_
  252. if [ "$1" = "-n" ]; then
  253. exclude=$2
  254. shift 2
  255. fi
  256. __git_reassemble_comp_words_by_ref "$exclude"
  257. cur_=${words_[cword_]}
  258. while [ $# -gt 0 ]; do
  259. case "$1" in
  260. cur)
  261. cur=$cur_
  262. ;;
  263. prev)
  264. prev=${words_[$cword_-1]}
  265. ;;
  266. words)
  267. words=("${words_[@]}")
  268. ;;
  269. cword)
  270. cword=$cword_
  271. ;;
  272. esac
  273. shift
  274. done
  275. }
  276. fi
  277. # Fills the COMPREPLY array with prefiltered words without any additional
  278. # processing.
  279. # Callers must take care of providing only words that match the current word
  280. # to be completed and adding any prefix and/or suffix (trailing space!), if
  281. # necessary.
  282. # 1: List of newline-separated matching completion words, complete with
  283. # prefix and suffix.
  284. __gitcomp_direct ()
  285. {
  286. local IFS=$'\n'
  287. COMPREPLY=($1)
  288. }
  289. # Similar to __gitcomp_direct, but appends to COMPREPLY instead.
  290. # Callers must take care of providing only words that match the current word
  291. # to be completed and adding any prefix and/or suffix (trailing space!), if
  292. # necessary.
  293. # 1: List of newline-separated matching completion words, complete with
  294. # prefix and suffix.
  295. __gitcomp_direct_append ()
  296. {
  297. local IFS=$'\n'
  298. COMPREPLY+=($1)
  299. }
  300. __gitcompappend ()
  301. {
  302. local x i=${#COMPREPLY[@]}
  303. for x in $1; do
  304. if [[ "$x" == "$3"* ]]; then
  305. COMPREPLY[i++]="$2$x$4"
  306. fi
  307. done
  308. }
  309. __gitcompadd ()
  310. {
  311. COMPREPLY=()
  312. __gitcompappend "$@"
  313. }
  314. # Generates completion reply, appending a space to possible completion words,
  315. # if necessary.
  316. # It accepts 1 to 4 arguments:
  317. # 1: List of possible completion words.
  318. # 2: A prefix to be added to each possible completion word (optional).
  319. # 3: Generate possible completion matches for this word (optional).
  320. # 4: A suffix to be appended to each possible completion word (optional).
  321. __gitcomp ()
  322. {
  323. local cur_="${3-$cur}"
  324. case "$cur_" in
  325. *=)
  326. ;;
  327. --no-*)
  328. local c i=0 IFS=$' \t\n'
  329. for c in $1; do
  330. if [[ $c == "--" ]]; then
  331. continue
  332. fi
  333. c="$c${4-}"
  334. if [[ $c == "$cur_"* ]]; then
  335. case $c in
  336. --*=|*.) ;;
  337. *) c="$c " ;;
  338. esac
  339. COMPREPLY[i++]="${2-}$c"
  340. fi
  341. done
  342. ;;
  343. *)
  344. local c i=0 IFS=$' \t\n'
  345. for c in $1; do
  346. if [[ $c == "--" ]]; then
  347. c="--no-...${4-}"
  348. if [[ $c == "$cur_"* ]]; then
  349. COMPREPLY[i++]="${2-}$c "
  350. fi
  351. break
  352. fi
  353. c="$c${4-}"
  354. if [[ $c == "$cur_"* ]]; then
  355. case $c in
  356. *=|*.) ;;
  357. *) c="$c " ;;
  358. esac
  359. COMPREPLY[i++]="${2-}$c"
  360. fi
  361. done
  362. ;;
  363. esac
  364. }
  365. # Clear the variables caching builtins' options when (re-)sourcing
  366. # the completion script.
  367. if [[ -n ${ZSH_VERSION-} ]]; then
  368. unset ${(M)${(k)parameters[@]}:#__gitcomp_builtin_*} 2>/dev/null
  369. else
  370. unset $(compgen -v __gitcomp_builtin_)
  371. fi
  372. __gitcomp_builtin_add_default=" --dry-run --verbose --interactive --patch --edit --force --update --renormalize --intent-to-add --all --ignore-removal --refresh --ignore-errors --ignore-missing --chmod= --pathspec-from-file= --pathspec-file-nul --no-dry-run -- --no-verbose --no-interactive --no-patch --no-edit --no-force --no-update --no-renormalize --no-intent-to-add --no-all --no-ignore-removal --no-refresh --no-ignore-errors --no-ignore-missing --no-chmod --no-pathspec-from-file --no-pathspec-file-nul"
  373. __gitcomp_builtin_am_default=" --interactive --3way --quiet --signoff --utf8 --keep --keep-non-patch --message-id --keep-cr --no-keep-cr --scissors --whitespace= --ignore-space-change --ignore-whitespace --directory= --exclude= --include= --patch-format= --reject --resolvemsg= --continue --resolved --skip --abort --quit --show-current-patch --committer-date-is-author-date --ignore-date --rerere-autoupdate --gpg-sign -- --no-interactive --no-3way --no-quiet --no-signoff --no-utf8 --no-keep --no-keep-non-patch --no-message-id --no-scissors --no-whitespace --no-ignore-space-change --no-ignore-whitespace --no-directory --no-exclude --no-include --no-patch-format --no-reject --no-resolvemsg --no-committer-date-is-author-date --no-ignore-date --no-rerere-autoupdate --no-gpg-sign"
  374. __gitcomp_builtin_apply_default=" --exclude= --include= --no-add --stat --numstat --summary --check --index --intent-to-add --cached --apply --3way --build-fake-ancestor= --whitespace= --ignore-space-change --ignore-whitespace --reverse --unidiff-zero --reject --allow-overlap --verbose --inaccurate-eof --recount --directory= --add -- --no-stat --no-numstat --no-summary --no-check --no-index --no-intent-to-add --no-cached --no-apply --no-3way --no-build-fake-ancestor --no-whitespace --no-ignore-space-change --no-ignore-whitespace --no-reverse --no-unidiff-zero --no-reject --no-allow-overlap --no-verbose --no-inaccurate-eof --no-recount --no-directory"
  375. __gitcomp_builtin_archive_default=" --output= --remote= --exec= --no-output -- --no-remote --no-exec"
  376. __gitcomp_builtin_bisect__helper_default=" --next-all --write-terms --bisect-clean-state --check-expected-revs --bisect-reset --bisect-write --check-and-set-terms --bisect-next-check --bisect-terms --bisect-start --bisect-next --bisect-auto-next --bisect-autostart --no-log --log"
  377. __gitcomp_builtin_blame_default=" --incremental --root --show-stats --progress --score-debug --show-name --show-number --porcelain --line-porcelain --show-email --ignore-rev= --ignore-revs-file= --color-lines --color-by-age --minimal --contents= --abbrev --no-incremental -- --no-root --no-show-stats --no-progress --no-score-debug --no-show-name --no-show-number --no-porcelain --no-line-porcelain --no-show-email --no-ignore-rev --no-ignore-revs-file --no-color-lines --no-color-by-age --no-minimal --no-contents --no-abbrev"
  378. __gitcomp_builtin_branch_default=" --verbose --quiet --track --set-upstream-to= --unset-upstream --color --remotes --contains --no-contains --abbrev --all --delete --move --copy --list --show-current --create-reflog --edit-description --merged --no-merged --column --sort= --points-at= --ignore-case --format= -- --no-verbose --no-quiet --no-track --no-set-upstream-to --no-unset-upstream --no-color --no-remotes --no-abbrev --no-all --no-delete --no-move --no-copy --no-list --no-show-current --no-create-reflog --no-edit-description --no-column --no-points-at --no-ignore-case --no-format"
  379. __gitcomp_builtin_bugreport_default=" --output-directory= --suffix= --no-output-directory -- --no-suffix"
  380. __gitcomp_builtin_cat_file_default=" --textconv --filters --path= --allow-unknown-type --buffer --batch --batch-check --follow-symlinks --batch-all-objects --unordered --no-path -- --no-allow-unknown-type --no-buffer --no-follow-symlinks --no-batch-all-objects --no-unordered"
  381. __gitcomp_builtin_check_attr_default=" --all --cached --stdin --no-all -- --no-cached --no-stdin"
  382. __gitcomp_builtin_check_ignore_default=" --quiet --verbose --stdin --non-matching --no-index --index -- --no-quiet --no-verbose --no-stdin --no-non-matching"
  383. __gitcomp_builtin_check_mailmap_default=" --stdin --no-stdin"
  384. __gitcomp_builtin_checkout_default=" --guess --overlay --quiet --recurse-submodules --progress --merge --conflict= --detach --track --orphan= --ignore-other-worktrees --ours --theirs --patch --ignore-skip-worktree-bits --pathspec-from-file= --pathspec-file-nul --no-guess -- --no-overlay --no-quiet --no-recurse-submodules --no-progress --no-merge --no-conflict --no-detach --no-track --no-orphan --no-ignore-other-worktrees --no-patch --no-ignore-skip-worktree-bits --no-pathspec-from-file --no-pathspec-file-nul"
  385. __gitcomp_builtin_checkout_index_default=" --all --force --quiet --no-create --index --stdin --temp --prefix= --stage= --create -- --no-all --no-force --no-quiet --no-index --no-stdin --no-temp --no-prefix"
  386. __gitcomp_builtin_cherry_default=" --abbrev --verbose --no-abbrev -- --no-verbose"
  387. __gitcomp_builtin_cherry_pick_default=" --quit --continue --abort --skip --cleanup= --no-commit --edit --signoff --mainline= --rerere-autoupdate --strategy= --strategy-option= --gpg-sign --ff --allow-empty --allow-empty-message --keep-redundant-commits --commit -- --no-cleanup --no-edit --no-signoff --no-mainline --no-rerere-autoupdate --no-strategy --no-strategy-option --no-gpg-sign --no-ff --no-allow-empty --no-allow-empty-message --no-keep-redundant-commits"
  388. __gitcomp_builtin_clean_default=" --quiet --dry-run --interactive --exclude= --no-quiet -- --no-dry-run --no-interactive"
  389. __gitcomp_builtin_clone_default=" --verbose --quiet --progress --no-checkout --bare --mirror --local --no-hardlinks --shared --recurse-submodules --recursive --jobs= --template= --reference= --reference-if-able= --dissociate --origin= --branch= --upload-pack= --depth= --shallow-since= --shallow-exclude= --single-branch --no-tags --shallow-submodules --separate-git-dir= --config= --server-option= --ipv4 --ipv6 --filter= --remote-submodules --sparse --checkout --hardlinks --tags -- --no-verbose --no-quiet --no-progress --no-bare --no-mirror --no-local --no-shared --no-recurse-submodules --no-recursive --no-jobs --no-template --no-reference --no-reference-if-able --no-dissociate --no-origin --no-branch --no-upload-pack --no-depth --no-shallow-since --no-shallow-exclude --no-single-branch --no-shallow-submodules --no-separate-git-dir --no-config --no-server-option --no-ipv4 --no-ipv6 --no-filter --no-remote-submodules --no-sparse"
  390. __gitcomp_builtin_column_default=" --command= --mode --raw-mode= --width= --indent= --nl= --padding= --no-command -- --no-mode --no-raw-mode --no-width --no-indent --no-nl --no-padding"
  391. __gitcomp_builtin_commit_default=" --quiet --verbose --file= --author= --date= --message= --reedit-message= --reuse-message= --fixup= --squash= --reset-author --signoff --template= --edit --cleanup= --status --gpg-sign --all --include --interactive --patch --only --no-verify --dry-run --short --branch --ahead-behind --porcelain --long --null --amend --no-post-rewrite --untracked-files --pathspec-from-file= --pathspec-file-nul --verify --post-rewrite -- --no-quiet --no-verbose --no-file --no-author --no-date --no-message --no-reedit-message --no-reuse-message --no-fixup --no-squash --no-reset-author --no-signoff --no-template --no-edit --no-cleanup --no-status --no-gpg-sign --no-all --no-include --no-interactive --no-patch --no-only --no-dry-run --no-short --no-branch --no-ahead-behind --no-porcelain --no-long --no-null --no-amend --no-untracked-files --no-pathspec-from-file --no-pathspec-file-nul"
  392. __gitcomp_builtin_commit_graph_default=" --object-dir= --no-object-dir"
  393. __gitcomp_builtin_config_default=" --global --system --local --worktree --file= --blob= --get --get-all --get-regexp --get-urlmatch --replace-all --add --unset --unset-all --rename-section --remove-section --list --edit --get-color --get-colorbool --type= --bool --int --bool-or-int --bool-or-str --path --expiry-date --null --name-only --includes --show-origin --show-scope --default= --no-global -- --no-system --no-local --no-worktree --no-file --no-blob --no-get --no-get-all --no-get-regexp --no-get-urlmatch --no-replace-all --no-add --no-unset --no-unset-all --no-rename-section --no-remove-section --no-list --no-edit --no-get-color --no-get-colorbool --no-type --no-null --no-name-only --no-includes --no-show-origin --no-show-scope --no-default"
  394. __gitcomp_builtin_count_objects_default=" --verbose --human-readable --no-verbose -- --no-human-readable"
  395. __gitcomp_builtin_credential_cache_default=" --timeout= --socket= --no-timeout -- --no-socket"
  396. __gitcomp_builtin_credential_cache__daemon_default=" --debug --no-debug"
  397. __gitcomp_builtin_credential_store_default=" --file= --no-file"
  398. __gitcomp_builtin_describe_default=" --contains --debug --all --tags --long --first-parent --abbrev --exact-match --candidates= --match= --exclude= --always --dirty --broken --no-contains -- --no-debug --no-all --no-tags --no-long --no-first-parent --no-abbrev --no-exact-match --no-candidates --no-match --no-exclude --no-always --no-dirty --no-broken"
  399. __gitcomp_builtin_difftool_default=" --gui --dir-diff --no-prompt --symlinks --tool= --tool-help --trust-exit-code --extcmd= --no-index -- --no-gui --no-dir-diff --no-symlinks --no-tool --no-tool-help --no-trust-exit-code --no-extcmd"
  400. __gitcomp_builtin_env__helper_default=" --type= --default= --exit-code --no-default -- --no-exit-code"
  401. __gitcomp_builtin_fast_export_default=" --progress= --signed-tags= --tag-of-filtered-object= --reencode= --export-marks= --import-marks= --import-marks-if-exists= --fake-missing-tagger --full-tree --use-done-feature --no-data --refspec= --anonymize --anonymize-map= --reference-excluded-parents --show-original-ids --mark-tags --data -- --no-progress --no-signed-tags --no-tag-of-filtered-object --no-reencode --no-export-marks --no-import-marks --no-import-marks-if-exists --no-fake-missing-tagger --no-full-tree --no-use-done-feature --no-refspec --no-anonymize --no-reference-excluded-parents --no-show-original-ids --no-mark-tags"
  402. __gitcomp_builtin_fetch_default=" --verbose --quiet --all --set-upstream --append --upload-pack= --force --multiple --tags --jobs= --prune --prune-tags --recurse-submodules --dry-run --write-fetch-head --keep --update-head-ok --progress --depth= --shallow-since= --shallow-exclude= --deepen= --unshallow --update-shallow --refmap= --server-option= --ipv4 --ipv6 --negotiation-tip= --filter= --auto-maintenance --auto-gc --show-forced-updates --write-commit-graph --stdin --no-verbose -- --no-quiet --no-all --no-set-upstream --no-append --no-upload-pack --no-force --no-multiple --no-tags --no-jobs --no-prune --no-prune-tags --no-recurse-submodules --no-dry-run --no-write-fetch-head --no-keep --no-update-head-ok --no-progress --no-depth --no-shallow-since --no-shallow-exclude --no-deepen --no-update-shallow --no-server-option --no-ipv4 --no-ipv6 --no-negotiation-tip --no-filter --no-auto-maintenance --no-auto-gc --no-show-forced-updates --no-write-commit-graph --no-stdin"
  403. __gitcomp_builtin_fmt_merge_msg_default=" --log --message= --file= --no-log -- --no-message --no-file"
  404. __gitcomp_builtin_for_each_ref_default=" --shell --perl --python --tcl --count= --format= --color --sort= --points-at= --merged --no-merged --contains --no-contains --ignore-case -- --no-shell --no-perl --no-python --no-tcl --no-count --no-format --no-color --no-points-at --no-ignore-case"
  405. __gitcomp_builtin_format_patch_default=" --numbered --no-numbered --signoff --stdout --cover-letter --numbered-files --suffix= --start-number= --reroll-count= --rfc --cover-from-description= --subject-prefix= --output-directory= --keep-subject --no-binary --zero-commit --ignore-if-in-upstream --no-stat --add-header= --to= --cc= --from --in-reply-to= --attach --inline --thread --signature= --base= --signature-file= --quiet --progress --interdiff= --range-diff= --creation-factor= --binary -- --no-numbered --no-signoff --no-stdout --no-cover-letter --no-numbered-files --no-suffix --no-start-number --no-reroll-count --no-cover-from-description --no-zero-commit --no-ignore-if-in-upstream --no-add-header --no-to --no-cc --no-from --no-in-reply-to --no-attach --no-thread --no-signature --no-base --no-signature-file --no-quiet --no-progress --no-interdiff --no-range-diff --no-creation-factor"
  406. __gitcomp_builtin_fsck_default=" --verbose --unreachable --dangling --tags --root --cache --reflogs --full --connectivity-only --strict --lost-found --progress --name-objects --no-verbose -- --no-unreachable --no-dangling --no-tags --no-root --no-cache --no-reflogs --no-full --no-connectivity-only --no-strict --no-lost-found --no-progress --no-name-objects"
  407. __gitcomp_builtin_fsck_objects_default=" --verbose --unreachable --dangling --tags --root --cache --reflogs --full --connectivity-only --strict --lost-found --progress --name-objects --no-verbose -- --no-unreachable --no-dangling --no-tags --no-root --no-cache --no-reflogs --no-full --no-connectivity-only --no-strict --no-lost-found --no-progress --no-name-objects"
  408. __gitcomp_builtin_gc_default=" --quiet --prune --aggressive --keep-largest-pack --no-quiet -- --no-prune --no-aggressive --no-keep-largest-pack"
  409. __gitcomp_builtin_grep_default=" --cached --no-index --untracked --exclude-standard --recurse-submodules --invert-match --ignore-case --word-regexp --text --textconv --recursive --max-depth= --extended-regexp --basic-regexp --fixed-strings --perl-regexp --line-number --column --full-name --files-with-matches --name-only --files-without-match --only-matching --count --color --break --heading --context= --before-context= --after-context= --threads= --show-function --function-context --and --or --not --quiet --all-match --index -- --no-cached --no-untracked --no-exclude-standard --no-recurse-submodules --no-invert-match --no-ignore-case --no-word-regexp --no-text --no-textconv --no-recursive --no-extended-regexp --no-basic-regexp --no-fixed-strings --no-perl-regexp --no-line-number --no-column --no-full-name --no-files-with-matches --no-name-only --no-files-without-match --no-only-matching --no-count --no-color --no-break --no-heading --no-context --no-before-context --no-after-context --no-threads --no-show-function --no-function-context --no-or --no-quiet --no-all-match"
  410. __gitcomp_builtin_hash_object_default=" --stdin --stdin-paths --no-filters --literally --path= --filters -- --no-stdin --no-stdin-paths --no-literally --no-path"
  411. __gitcomp_builtin_help_default=" --all --guides --config --man --web --info --verbose --no-all -- --no-guides --no-config --no-man --no-web --no-info --no-verbose"
  412. __gitcomp_builtin_init_default=" --template= --bare --shared --quiet --separate-git-dir= --initial-branch= --object-format= --no-template -- --no-bare --no-quiet --no-separate-git-dir --no-initial-branch --no-object-format"
  413. __gitcomp_builtin_init_db_default=" --template= --bare --shared --quiet --separate-git-dir= --initial-branch= --object-format= --no-template -- --no-bare --no-quiet --no-separate-git-dir --no-initial-branch --no-object-format"
  414. __gitcomp_builtin_interpret_trailers_default=" --in-place --trim-empty --where= --if-exists= --if-missing= --only-trailers --only-input --unfold --parse --no-divider --trailer= --divider -- --no-in-place --no-trim-empty --no-where --no-if-exists --no-if-missing --no-only-trailers --no-only-input --no-unfold --no-trailer"
  415. __gitcomp_builtin_log_default=" --quiet --source --use-mailmap --mailmap --decorate-refs= --decorate-refs-exclude= --decorate --no-quiet -- --no-source --no-use-mailmap --no-mailmap --no-decorate-refs --no-decorate-refs-exclude --no-decorate"
  416. __gitcomp_builtin_ls_files_default=" --cached --deleted --modified --others --ignored --stage --killed --directory --eol --empty-directory --unmerged --resolve-undo --exclude= --exclude-from= --exclude-per-directory= --exclude-standard --full-name --recurse-submodules --error-unmatch --with-tree= --abbrev --debug --no-cached -- --no-deleted --no-modified --no-others --no-ignored --no-stage --no-killed --no-directory --no-eol --no-empty-directory --no-unmerged --no-resolve-undo --no-exclude-per-directory --no-recurse-submodules --no-error-unmatch --no-with-tree --no-abbrev --no-debug"
  417. __gitcomp_builtin_ls_remote_default=" --quiet --upload-pack= --tags --heads --refs --get-url --sort= --symref --server-option= --no-quiet -- --no-upload-pack --no-tags --no-heads --no-refs --no-get-url --no-symref --no-server-option"
  418. __gitcomp_builtin_ls_tree_default=" --long --name-only --name-status --full-name --full-tree --abbrev --no-long -- --no-name-only --no-name-status --no-full-name --no-full-tree --no-abbrev"
  419. __gitcomp_builtin_merge_default=" --stat --summary --log --squash --commit --edit --cleanup= --ff --ff-only --rerere-autoupdate --verify-signatures --strategy= --strategy-option= --message= --file --verbose --quiet --abort --quit --continue --allow-unrelated-histories --progress --gpg-sign --autostash --overwrite-ignore --signoff --no-verify --verify -- --no-stat --no-summary --no-log --no-squash --no-commit --no-edit --no-cleanup --no-ff --no-rerere-autoupdate --no-verify-signatures --no-strategy --no-strategy-option --no-message --no-verbose --no-quiet --no-abort --no-quit --no-continue --no-allow-unrelated-histories --no-progress --no-gpg-sign --no-autostash --no-overwrite-ignore --no-signoff"
  420. __gitcomp_builtin_merge_base_default=" --all --octopus --independent --is-ancestor --fork-point --no-all"
  421. __gitcomp_builtin_merge_file_default=" --stdout --diff3 --ours --theirs --union --marker-size= --quiet --no-stdout -- --no-diff3 --no-ours --no-theirs --no-union --no-marker-size --no-quiet"
  422. __gitcomp_builtin_mktree_default=" --missing --batch --no-missing -- --no-batch"
  423. __gitcomp_builtin_multi_pack_index_default=" --object-dir= --progress --batch-size= --no-object-dir -- --no-progress"
  424. __gitcomp_builtin_mv_default=" --verbose --dry-run --no-verbose -- --no-dry-run"
  425. __gitcomp_builtin_name_rev_default=" --name-only --tags --refs= --exclude= --all --stdin --undefined --always --no-name-only -- --no-tags --no-refs --no-exclude --no-all --no-stdin --no-undefined --no-always"
  426. __gitcomp_builtin_notes_default=" --ref= --no-ref"
  427. __gitcomp_builtin_pack_objects_default=" --quiet --progress --all-progress --all-progress-implied --index-version= --max-pack-size= --local --incremental --window= --window-memory= --depth= --reuse-delta --reuse-object --delta-base-offset --threads= --non-empty --revs --unpacked --all --reflog --indexed-objects --stdout --include-tag --keep-unreachable --pack-loose-unreachable --unpack-unreachable --sparse --thin --shallow --honor-pack-keep --keep-pack= --compression= --keep-true-parents --use-bitmap-index --write-bitmap-index --filter= --missing= --exclude-promisor-objects --delta-islands --uri-protocol= --no-quiet -- --no-progress --no-all-progress --no-all-progress-implied --no-local --no-incremental --no-window --no-depth --no-reuse-delta --no-reuse-object --no-delta-base-offset --no-threads --no-non-empty --no-revs --no-stdout --no-include-tag --no-keep-unreachable --no-pack-loose-unreachable --no-unpack-unreachable --no-sparse --no-thin --no-shallow --no-honor-pack-keep --no-keep-pack --no-compression --no-keep-true-parents --no-use-bitmap-index --no-write-bitmap-index --no-filter --no-exclude-promisor-objects --no-delta-islands --no-uri-protocol"
  428. __gitcomp_builtin_pack_refs_default=" --all --prune --no-all -- --no-prune"
  429. __gitcomp_builtin_pickaxe_default=" --incremental --root --show-stats --progress --score-debug --show-name --show-number --porcelain --line-porcelain --show-email --ignore-rev= --ignore-revs-file= --color-lines --color-by-age --minimal --contents= --abbrev --no-incremental -- --no-root --no-show-stats --no-progress --no-score-debug --no-show-name --no-show-number --no-porcelain --no-line-porcelain --no-show-email --no-ignore-rev --no-ignore-revs-file --no-color-lines --no-color-by-age --no-minimal --no-contents --no-abbrev"
  430. __gitcomp_builtin_prune_default=" --dry-run --verbose --progress --expire= --exclude-promisor-objects --no-dry-run -- --no-verbose --no-progress --no-expire --no-exclude-promisor-objects"
  431. __gitcomp_builtin_prune_packed_default=" --dry-run --quiet --no-dry-run -- --no-quiet"
  432. __gitcomp_builtin_pull_default=" --verbose --quiet --progress --recurse-submodules --rebase --stat --log --signoff --squash --commit --edit --cleanup= --ff --ff-only --verify-signatures --autostash --strategy= --strategy-option= --gpg-sign --allow-unrelated-histories --all --append --upload-pack= --force --tags --prune --jobs --dry-run --keep --depth= --shallow-since= --shallow-exclude= --deepen= --unshallow --update-shallow --refmap= --server-option= --ipv4 --ipv6 --negotiation-tip= --show-forced-updates --set-upstream --no-verbose -- --no-quiet --no-progress --no-recurse-submodules --no-rebase --no-stat --no-log --no-signoff --no-squash --no-commit --no-edit --no-cleanup --no-ff --no-verify-signatures --no-autostash --no-strategy --no-strategy-option --no-gpg-sign --no-allow-unrelated-histories --no-all --no-append --no-upload-pack --no-force --no-tags --no-prune --no-jobs --no-dry-run --no-keep --no-depth --no-shallow-since --no-shallow-exclude --no-deepen --no-update-shallow --no-server-option --no-ipv4 --no-ipv6 --no-negotiation-tip --no-show-forced-updates --no-set-upstream"
  433. __gitcomp_builtin_push_default=" --verbose --quiet --repo= --all --mirror --delete --tags --dry-run --porcelain --force --force-with-lease --recurse-submodules= --receive-pack= --exec= --set-upstream --progress --prune --no-verify --follow-tags --signed --atomic --push-option= --ipv4 --ipv6 --verify -- --no-verbose --no-quiet --no-repo --no-all --no-mirror --no-delete --no-tags --no-dry-run --no-porcelain --no-force --no-force-with-lease --no-recurse-submodules --no-receive-pack --no-exec --no-set-upstream --no-progress --no-prune --no-follow-tags --no-signed --no-atomic --no-push-option --no-ipv4 --no-ipv6"
  434. __gitcomp_builtin_range_diff_default=" --creation-factor= --no-dual-color --notes --patch --no-patch --unified --function-context --raw --patch-with-raw --patch-with-stat --numstat --shortstat --dirstat --cumulative --dirstat-by-file --check --summary --name-only --name-status --stat --stat-width= --stat-name-width= --stat-graph-width= --stat-count= --compact-summary --binary --full-index --color --ws-error-highlight= --abbrev --src-prefix= --dst-prefix= --line-prefix= --no-prefix --inter-hunk-context= --output-indicator-new= --output-indicator-old= --output-indicator-context= --break-rewrites --find-renames --irreversible-delete --find-copies --find-copies-harder --no-renames --rename-empty --follow --minimal --ignore-all-space --ignore-space-change --ignore-space-at-eol --ignore-cr-at-eol --ignore-blank-lines --indent-heuristic --patience --histogram --diff-algorithm= --anchored= --word-diff --word-diff-regex= --color-words --color-moved --color-moved-ws= --relative --text --exit-code --quiet --ext-diff --textconv --ignore-submodules --submodule --ita-invisible-in-index --ita-visible-in-index --pickaxe-all --pickaxe-regex --find-object= --diff-filter= --output= --dual-color -- --no-creation-factor --no-notes --no-function-context --no-compact-summary --no-full-index --no-color --no-abbrev --no-find-copies-harder --no-rename-empty --no-follow --no-minimal --no-indent-heuristic --no-color-moved --no-color-moved-ws --no-relative --no-text --no-exit-code --no-quiet --no-ext-diff --no-textconv"
  435. __gitcomp_builtin_read_tree_default=" --index-output= --empty --verbose --trivial --aggressive --reset --prefix= --exclude-per-directory= --dry-run --no-sparse-checkout --debug-unpack --recurse-submodules --quiet --sparse-checkout -- --no-empty --no-verbose --no-trivial --no-aggressive --no-reset --no-dry-run --no-debug-unpack --no-recurse-submodules --no-quiet"
  436. __gitcomp_builtin_rebase_default=" --onto= --keep-base --no-verify --quiet --verbose --no-stat --signoff --committer-date-is-author-date --reset-author-date --ignore-whitespace --whitespace= --force-rebase --no-ff --continue --skip --abort --quit --edit-todo --show-current-patch --apply --merge --interactive --rerere-autoupdate --empty= --autosquash --gpg-sign --autostash --exec= --rebase-merges --fork-point --strategy= --strategy-option= --root --reschedule-failed-exec --reapply-cherry-picks --verify --stat --ff -- --no-onto --no-keep-base --no-quiet --no-verbose --no-signoff --no-committer-date-is-author-date --no-reset-author-date --no-ignore-whitespace --no-whitespace --no-force-rebase --no-rerere-autoupdate --no-autosquash --no-gpg-sign --no-autostash --no-exec --no-rebase-merges --no-fork-point --no-strategy --no-strategy-option --no-root --no-reschedule-failed-exec --no-reapply-cherry-picks"
  437. __gitcomp_builtin_rebase__interactive_default=" --ff --rebase-merges --rebase-cousins --autosquash --signoff --verbose --continue --skip --edit-todo --show-current-patch --shorten-ids --expand-ids --check-todo-list --rearrange-squash --add-exec-commands --onto= --restrict-revision= --squash-onto= --upstream= --head-name= --gpg-sign --strategy= --strategy-opts= --switch-to= --onto-name= --cmd= --rerere-autoupdate --reschedule-failed-exec --no-ff -- --no-rebase-merges --no-rebase-cousins --no-autosquash --no-signoff --no-verbose --no-head-name --no-gpg-sign --no-strategy --no-strategy-opts --no-switch-to --no-onto-name --no-cmd --no-rerere-autoupdate --no-reschedule-failed-exec"
  438. __gitcomp_builtin_receive_pack_default=" --quiet --no-quiet"
  439. __gitcomp_builtin_reflog_default=" --quiet --source --use-mailmap --mailmap --decorate-refs= --decorate-refs-exclude= --decorate --no-quiet -- --no-source --no-use-mailmap --no-mailmap --no-decorate-refs --no-decorate-refs-exclude --no-decorate"
  440. __gitcomp_builtin_remote_default=" --verbose --no-verbose"
  441. __gitcomp_builtin_repack_default=" --quiet --local --write-bitmap-index --delta-islands --unpack-unreachable= --keep-unreachable --window= --window-memory= --depth= --threads= --max-pack-size= --pack-kept-objects --keep-pack= --no-quiet -- --no-local --no-write-bitmap-index --no-delta-islands --no-unpack-unreachable --no-keep-unreachable --no-window --no-window-memory --no-depth --no-threads --no-max-pack-size --no-pack-kept-objects --no-keep-pack"
  442. __gitcomp_builtin_replace_default=" --list --delete --edit --graft --convert-graft-file --raw --format= --no-raw -- --no-format"
  443. __gitcomp_builtin_rerere_default=" --rerere-autoupdate --no-rerere-autoupdate"
  444. __gitcomp_builtin_reset_default=" --quiet --mixed --soft --hard --merge --keep --recurse-submodules --patch --intent-to-add --pathspec-from-file= --pathspec-file-nul --no-quiet -- --no-mixed --no-soft --no-hard --no-merge --no-keep --no-recurse-submodules --no-patch --no-intent-to-add --no-pathspec-from-file --no-pathspec-file-nul"
  445. __gitcomp_builtin_restore_default=" --source= --staged --worktree --ignore-unmerged --overlay --quiet --recurse-submodules --progress --merge --conflict= --ours --theirs --patch --ignore-skip-worktree-bits --pathspec-from-file= --pathspec-file-nul --no-source -- --no-staged --no-worktree --no-ignore-unmerged --no-overlay --no-quiet --no-recurse-submodules --no-progress --no-merge --no-conflict --no-patch --no-ignore-skip-worktree-bits --no-pathspec-from-file --no-pathspec-file-nul"
  446. __gitcomp_builtin_revert_default=" --quit --continue --abort --skip --cleanup= --no-commit --edit --signoff --mainline= --rerere-autoupdate --strategy= --strategy-option= --gpg-sign --commit -- --no-cleanup --no-edit --no-signoff --no-mainline --no-rerere-autoupdate --no-strategy --no-strategy-option --no-gpg-sign"
  447. __gitcomp_builtin_rm_default=" --dry-run --quiet --cached --ignore-unmatch --pathspec-from-file= --pathspec-file-nul --no-dry-run -- --no-quiet --no-cached --no-ignore-unmatch --no-pathspec-from-file --no-pathspec-file-nul"
  448. __gitcomp_builtin_send_pack_default=" --verbose --quiet --receive-pack= --exec= --remote= --all --dry-run --mirror --force --signed --push-option= --progress --thin --atomic --stateless-rpc --stdin --helper-status --force-with-lease --no-verbose -- --no-quiet --no-receive-pack --no-exec --no-remote --no-all --no-dry-run --no-mirror --no-force --no-signed --no-push-option --no-progress --no-thin --no-atomic --no-stateless-rpc --no-stdin --no-helper-status --no-force-with-lease"
  449. __gitcomp_builtin_shortlog_default=" --committer --numbered --summary --email --group= --no-committer -- --no-numbered --no-summary --no-email --no-group"
  450. __gitcomp_builtin_show_default=" --quiet --source --use-mailmap --mailmap --decorate-refs= --decorate-refs-exclude= --decorate --no-quiet -- --no-source --no-use-mailmap --no-mailmap --no-decorate-refs --no-decorate-refs-exclude --no-decorate"
  451. __gitcomp_builtin_show_branch_default=" --all --remotes --color --more --list --no-name --current --sha1-name --merge-base --independent --topo-order --topics --sparse --date-order --reflog --name -- --no-all --no-remotes --no-color --no-more --no-list --no-current --no-sha1-name --no-merge-base --no-independent --no-topo-order --no-topics --no-sparse --no-date-order"
  452. __gitcomp_builtin_show_index_default=" --object-format= --no-object-format"
  453. __gitcomp_builtin_show_ref_default=" --tags --heads --verify --head --dereference --hash --abbrev --quiet --exclude-existing --no-tags -- --no-heads --no-verify --no-head --no-dereference --no-hash --no-abbrev --no-quiet"
  454. __gitcomp_builtin_sparse_checkout_default=""
  455. __gitcomp_builtin_stage_default=" --dry-run --verbose --interactive --patch --edit --force --update --renormalize --intent-to-add --all --ignore-removal --refresh --ignore-errors --ignore-missing --chmod= --pathspec-from-file= --pathspec-file-nul --no-dry-run -- --no-verbose --no-interactive --no-patch --no-edit --no-force --no-update --no-renormalize --no-intent-to-add --no-all --no-ignore-removal --no-refresh --no-ignore-errors --no-ignore-missing --no-chmod --no-pathspec-from-file --no-pathspec-file-nul"
  456. __gitcomp_builtin_stash_default=""
  457. __gitcomp_builtin_status_default=" --verbose --short --branch --show-stash --ahead-behind --porcelain --long --null --untracked-files --ignored --ignore-submodules --column --no-renames --find-renames --renames -- --no-verbose --no-short --no-branch --no-show-stash --no-ahead-behind --no-porcelain --no-long --no-null --no-untracked-files --no-ignored --no-ignore-submodules --no-column"
  458. __gitcomp_builtin_stripspace_default=" --strip-comments --comment-lines"
  459. __gitcomp_builtin_switch_default=" --create= --force-create= --guess --discard-changes --quiet --recurse-submodules --progress --merge --conflict= --detach --track --orphan= --ignore-other-worktrees --no-create -- --no-force-create --no-guess --no-discard-changes --no-quiet --no-recurse-submodules --no-progress --no-merge --no-conflict --no-detach --no-track --no-orphan --no-ignore-other-worktrees"
  460. __gitcomp_builtin_symbolic_ref_default=" --quiet --delete --short --no-quiet -- --no-delete --no-short"
  461. __gitcomp_builtin_tag_default=" --list --delete --verify --annotate --message= --file= --edit --sign --cleanup= --local-user= --force --create-reflog --column --contains --no-contains --merged --no-merged --sort= --points-at --format= --color --ignore-case -- --no-annotate --no-file --no-edit --no-sign --no-cleanup --no-local-user --no-force --no-create-reflog --no-column --no-points-at --no-format --no-color --no-ignore-case"
  462. __gitcomp_builtin_update_index_default=" --ignore-submodules --add --replace --remove --unmerged --refresh --really-refresh --cacheinfo --chmod= --assume-unchanged --no-assume-unchanged --skip-worktree --no-skip-worktree --ignore-skip-worktree-entries --info-only --force-remove --stdin --index-info --unresolve --again --ignore-missing --verbose --clear-resolve-undo --index-version= --split-index --untracked-cache --test-untracked-cache --force-untracked-cache --force-write-index --fsmonitor --fsmonitor-valid --no-fsmonitor-valid -- --no-ignore-submodules --no-add --no-replace --no-remove --no-unmerged --no-ignore-skip-worktree-entries --no-info-only --no-force-remove --no-ignore-missing --no-verbose --no-index-version --no-split-index --no-untracked-cache --no-test-untracked-cache --no-force-untracked-cache --no-force-write-index --no-fsmonitor"
  463. __gitcomp_builtin_update_ref_default=" --no-deref --stdin --create-reflog --deref -- --no-stdin --no-create-reflog"
  464. __gitcomp_builtin_update_server_info_default=" --force --no-force"
  465. __gitcomp_builtin_upload_pack_default=" --stateless-rpc --advertise-refs --strict --timeout= --no-stateless-rpc -- --no-advertise-refs --no-strict --no-timeout"
  466. __gitcomp_builtin_verify_commit_default=" --verbose --raw --no-verbose -- --no-raw"
  467. __gitcomp_builtin_verify_pack_default=" --verbose --stat-only --object-format= --no-verbose -- --no-stat-only --no-object-format"
  468. __gitcomp_builtin_verify_tag_default=" --verbose --raw --format= --no-verbose -- --no-raw --no-format"
  469. __gitcomp_builtin_version_default=" --build-options --no-build-options"
  470. __gitcomp_builtin_whatchanged_default=" --quiet --source --use-mailmap --mailmap --decorate-refs= --decorate-refs-exclude= --decorate --no-quiet -- --no-source --no-use-mailmap --no-mailmap --no-decorate-refs --no-decorate-refs-exclude --no-decorate"
  471. __gitcomp_builtin_write_tree_default=" --missing-ok --prefix= --no-missing-ok -- --no-prefix"
  472. __gitcomp_builtin_send_email_default=" --numbered --no-numbered --signoff --stdout --cover-letter --numbered-files --suffix= --start-number= --reroll-count= --rfc --cover-from-description= --subject-prefix= --output-directory= --keep-subject --no-binary --zero-commit --ignore-if-in-upstream --no-stat --add-header= --to= --cc= --from --in-reply-to= --attach --inline --thread --signature= --base= --signature-file= --quiet --progress --interdiff= --range-diff= --creation-factor= --binary -- --no-numbered --no-signoff --no-stdout --no-cover-letter --no-numbered-files --no-suffix --no-start-number --no-reroll-count --no-cover-from-description --no-zero-commit --no-ignore-if-in-upstream --no-add-header --no-to --no-cc --no-from --no-in-reply-to --no-attach --no-thread --no-signature --no-base --no-signature-file --no-quiet --no-progress --no-interdiff --no-range-diff --no-creation-factor"
  473. __gitcomp_builtin_get_default ()
  474. {
  475. eval "test -n \"\$${1}_default\" && echo \"\$${1}_default\""
  476. }
  477. # This function is equivalent to
  478. #
  479. # __gitcomp "$(git xxx --git-completion-helper) ..."
  480. #
  481. # except that the output is cached. Accept 1-3 arguments:
  482. # 1: the git command to execute, this is also the cache key
  483. # 2: extra options to be added on top (e.g. negative forms)
  484. # 3: options to be excluded
  485. __gitcomp_builtin ()
  486. {
  487. # spaces must be replaced with underscore for multi-word
  488. # commands, e.g. "git remote add" becomes remote_add.
  489. local cmd="$1"
  490. local incl="${2-}"
  491. local excl="${3-}"
  492. local var=__gitcomp_builtin_"${cmd//-/_}"
  493. local options
  494. eval "options=\${$var-}"
  495. if [ -z "$options" ]; then
  496. local completion_helper
  497. if [ "$GIT_COMPLETION_SHOW_ALL" = "1" ]; then
  498. completion_helper="--git-completion-helper-all"
  499. else
  500. completion_helper="--git-completion-helper"
  501. fi
  502. completion="$(__git ${cmd/_/ } $completion_helper ||
  503. __gitcomp_builtin_get_default $var)" || return
  504. # leading and trailing spaces are significant to make
  505. # option removal work correctly.
  506. options=" $incl $completion "
  507. for i in $excl; do
  508. options="${options/ $i / }"
  509. done
  510. eval "$var=\"$options\""
  511. fi
  512. __gitcomp "$options"
  513. }
  514. # Variation of __gitcomp_nl () that appends to the existing list of
  515. # completion candidates, COMPREPLY.
  516. __gitcomp_nl_append ()
  517. {
  518. local IFS=$'\n'
  519. __gitcompappend "$1" "${2-}" "${3-$cur}" "${4- }"
  520. }
  521. # Generates completion reply from newline-separated possible completion words
  522. # by appending a space to all of them.
  523. # It accepts 1 to 4 arguments:
  524. # 1: List of possible completion words, separated by a single newline.
  525. # 2: A prefix to be added to each possible completion word (optional).
  526. # 3: Generate possible completion matches for this word (optional).
  527. # 4: A suffix to be appended to each possible completion word instead of
  528. # the default space (optional). If specified but empty, nothing is
  529. # appended.
  530. __gitcomp_nl ()
  531. {
  532. COMPREPLY=()
  533. __gitcomp_nl_append "$@"
  534. }
  535. # Fills the COMPREPLY array with prefiltered paths without any additional
  536. # processing.
  537. # Callers must take care of providing only paths that match the current path
  538. # to be completed and adding any prefix path components, if necessary.
  539. # 1: List of newline-separated matching paths, complete with all prefix
  540. # path components.
  541. __gitcomp_file_direct ()
  542. {
  543. local IFS=$'\n'
  544. COMPREPLY=($1)
  545. # use a hack to enable file mode in bash < 4
  546. compopt -o filenames +o nospace 2>/dev/null ||
  547. compgen -f /non-existing-dir/ >/dev/null ||
  548. true
  549. }
  550. # Generates completion reply with compgen from newline-separated possible
  551. # completion filenames.
  552. # It accepts 1 to 3 arguments:
  553. # 1: List of possible completion filenames, separated by a single newline.
  554. # 2: A directory prefix to be added to each possible completion filename
  555. # (optional).
  556. # 3: Generate possible completion matches for this word (optional).
  557. __gitcomp_file ()
  558. {
  559. local IFS=$'\n'
  560. # XXX does not work when the directory prefix contains a tilde,
  561. # since tilde expansion is not applied.
  562. # This means that COMPREPLY will be empty and Bash default
  563. # completion will be used.
  564. __gitcompadd "$1" "${2-}" "${3-$cur}" ""
  565. # use a hack to enable file mode in bash < 4
  566. compopt -o filenames +o nospace 2>/dev/null ||
  567. compgen -f /non-existing-dir/ >/dev/null ||
  568. true
  569. }
  570. # Execute 'git ls-files', unless the --committable option is specified, in
  571. # which case it runs 'git diff-index' to find out the files that can be
  572. # committed. It return paths relative to the directory specified in the first
  573. # argument, and using the options specified in the second argument.
  574. __git_ls_files_helper ()
  575. {
  576. if [ "$2" == "--committable" ]; then
  577. __git -C "$1" -c core.quotePath=false diff-index \
  578. --name-only --relative HEAD -- "${3//\\/\\\\}*"
  579. else
  580. # NOTE: $2 is not quoted in order to support multiple options
  581. __git -C "$1" -c core.quotePath=false ls-files \
  582. --exclude-standard $2 -- "${3//\\/\\\\}*"
  583. fi
  584. }
  585. # __git_index_files accepts 1 or 2 arguments:
  586. # 1: Options to pass to ls-files (required).
  587. # 2: A directory path (optional).
  588. # If provided, only files within the specified directory are listed.
  589. # Sub directories are never recursed. Path must have a trailing
  590. # slash.
  591. # 3: List only paths matching this path component (optional).
  592. __git_index_files ()
  593. {
  594. local root="$2" match="$3"
  595. __git_ls_files_helper "$root" "$1" "${match:-?}" |
  596. awk -F / -v pfx="${2//\\/\\\\}" '{
  597. paths[$1] = 1
  598. }
  599. END {
  600. for (p in paths) {
  601. if (substr(p, 1, 1) != "\"") {
  602. # No special characters, easy!
  603. print pfx p
  604. continue
  605. }
  606. # The path is quoted.
  607. p = dequote(p)
  608. if (p == "")
  609. continue
  610. # Even when a directory name itself does not contain
  611. # any special characters, it will still be quoted if
  612. # any of its (stripped) trailing path components do.
  613. # Because of this we may have seen the same directory
  614. # both quoted and unquoted.
  615. if (p in paths)
  616. # We have seen the same directory unquoted,
  617. # skip it.
  618. continue
  619. else
  620. print pfx p
  621. }
  622. }
  623. function dequote(p, bs_idx, out, esc, esc_idx, dec) {
  624. # Skip opening double quote.
  625. p = substr(p, 2)
  626. # Interpret backslash escape sequences.
  627. while ((bs_idx = index(p, "\\")) != 0) {
  628. out = out substr(p, 1, bs_idx - 1)
  629. esc = substr(p, bs_idx + 1, 1)
  630. p = substr(p, bs_idx + 2)
  631. if ((esc_idx = index("abtvfr\"\\", esc)) != 0) {
  632. # C-style one-character escape sequence.
  633. out = out substr("\a\b\t\v\f\r\"\\",
  634. esc_idx, 1)
  635. } else if (esc == "n") {
  636. # Uh-oh, a newline character.
  637. # We cannot reliably put a pathname
  638. # containing a newline into COMPREPLY,
  639. # and the newline would create a mess.
  640. # Skip this path.
  641. return ""
  642. } else {
  643. # Must be a \nnn octal value, then.
  644. dec = esc * 64 + \
  645. substr(p, 1, 1) * 8 + \
  646. substr(p, 2, 1)
  647. out = out sprintf("%c", dec)
  648. p = substr(p, 3)
  649. }
  650. }
  651. # Drop closing double quote, if there is one.
  652. # (There is not any if this is a directory, as it was
  653. # already stripped with the trailing path components.)
  654. if (substr(p, length(p), 1) == "\"")
  655. out = out substr(p, 1, length(p) - 1)
  656. else
  657. out = out p
  658. return out
  659. }'
  660. }
  661. # __git_complete_index_file requires 1 argument:
  662. # 1: the options to pass to ls-file
  663. #
  664. # The exception is --committable, which finds the files appropriate commit.
  665. __git_complete_index_file ()
  666. {
  667. local dequoted_word pfx="" cur_
  668. __git_dequote "$cur"
  669. case "$dequoted_word" in
  670. ?*/*)
  671. pfx="${dequoted_word%/*}/"
  672. cur_="${dequoted_word##*/}"
  673. ;;
  674. *)
  675. cur_="$dequoted_word"
  676. esac
  677. __gitcomp_file_direct "$(__git_index_files "$1" "$pfx" "$cur_")"
  678. }
  679. # Lists branches from the local repository.
  680. # 1: A prefix to be added to each listed branch (optional).
  681. # 2: List only branches matching this word (optional; list all branches if
  682. # unset or empty).
  683. # 3: A suffix to be appended to each listed branch (optional).
  684. __git_heads ()
  685. {
  686. local pfx="${1-}" cur_="${2-}" sfx="${3-}"
  687. __git for-each-ref --format="${pfx//\%/%%}%(refname:strip=2)$sfx" \
  688. "refs/heads/$cur_*" "refs/heads/$cur_*/**"
  689. }
  690. # Lists branches from remote repositories.
  691. # 1: A prefix to be added to each listed branch (optional).
  692. # 2: List only branches matching this word (optional; list all branches if
  693. # unset or empty).
  694. # 3: A suffix to be appended to each listed branch (optional).
  695. __git_remote_heads ()
  696. {
  697. local pfx="${1-}" cur_="${2-}" sfx="${3-}"
  698. __git for-each-ref --format="${pfx//\%/%%}%(refname:strip=2)$sfx" \
  699. "refs/remotes/$cur_*" "refs/remotes/$cur_*/**"
  700. }
  701. # Lists tags from the local repository.
  702. # Accepts the same positional parameters as __git_heads() above.
  703. __git_tags ()
  704. {
  705. local pfx="${1-}" cur_="${2-}" sfx="${3-}"
  706. __git for-each-ref --format="${pfx//\%/%%}%(refname:strip=2)$sfx" \
  707. "refs/tags/$cur_*" "refs/tags/$cur_*/**"
  708. }
  709. # List unique branches from refs/remotes used for 'git checkout' and 'git
  710. # switch' tracking DWIMery.
  711. # 1: A prefix to be added to each listed branch (optional)
  712. # 2: List only branches matching this word (optional; list all branches if
  713. # unset or empty).
  714. # 3: A suffix to be appended to each listed branch (optional).
  715. __git_dwim_remote_heads ()
  716. {
  717. local pfx="${1-}" cur_="${2-}" sfx="${3-}"
  718. local fer_pfx="${pfx//\%/%%}" # "escape" for-each-ref format specifiers
  719. # employ the heuristic used by git checkout and git switch
  720. # Try to find a remote branch that cur_es the completion word
  721. # but only output if the branch name is unique
  722. __git for-each-ref --format="$fer_pfx%(refname:strip=3)$sfx" \
  723. --sort="refname:strip=3" \
  724. "refs/remotes/*/$cur_*" "refs/remotes/*/$cur_*/**" | \
  725. uniq -u
  726. }
  727. # Lists refs from the local (by default) or from a remote repository.
  728. # It accepts 0, 1 or 2 arguments:
  729. # 1: The remote to list refs from (optional; ignored, if set but empty).
  730. # Can be the name of a configured remote, a path, or a URL.
  731. # 2: In addition to local refs, list unique branches from refs/remotes/ for
  732. # 'git checkout's tracking DWIMery (optional; ignored, if set but empty).
  733. # 3: A prefix to be added to each listed ref (optional).
  734. # 4: List only refs matching this word (optional; list all refs if unset or
  735. # empty).
  736. # 5: A suffix to be appended to each listed ref (optional; ignored, if set
  737. # but empty).
  738. #
  739. # Use __git_complete_refs() instead.
  740. __git_refs ()
  741. {
  742. local i hash dir track="${2-}"
  743. local list_refs_from=path remote="${1-}"
  744. local format refs
  745. local pfx="${3-}" cur_="${4-$cur}" sfx="${5-}"
  746. local match="${4-}"
  747. local fer_pfx="${pfx//\%/%%}" # "escape" for-each-ref format specifiers
  748. __git_find_repo_path
  749. dir="$__git_repo_path"
  750. if [ -z "$remote" ]; then
  751. if [ -z "$dir" ]; then
  752. return
  753. fi
  754. else
  755. if __git_is_configured_remote "$remote"; then
  756. # configured remote takes precedence over a
  757. # local directory with the same name
  758. list_refs_from=remote
  759. elif [ -d "$remote/.git" ]; then
  760. dir="$remote/.git"
  761. elif [ -d "$remote" ]; then
  762. dir="$remote"
  763. else
  764. list_refs_from=url
  765. fi
  766. fi
  767. if [ "$list_refs_from" = path ]; then
  768. if [[ "$cur_" == ^* ]]; then
  769. pfx="$pfx^"
  770. fer_pfx="$fer_pfx^"
  771. cur_=${cur_#^}
  772. match=${match#^}
  773. fi
  774. case "$cur_" in
  775. refs|refs/*)
  776. format="refname"
  777. refs=("$match*" "$match*/**")
  778. track=""
  779. ;;
  780. *)
  781. for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD REBASE_HEAD; do
  782. case "$i" in
  783. $match*)
  784. if [ -e "$dir/$i" ]; then
  785. echo "$pfx$i$sfx"
  786. fi
  787. ;;
  788. esac
  789. done
  790. format="refname:strip=2"
  791. refs=("refs/tags/$match*" "refs/tags/$match*/**"
  792. "refs/heads/$match*" "refs/heads/$match*/**"
  793. "refs/remotes/$match*" "refs/remotes/$match*/**")
  794. ;;
  795. esac
  796. __git_dir="$dir" __git for-each-ref --format="$fer_pfx%($format)$sfx" \
  797. "${refs[@]}"
  798. if [ -n "$track" ]; then
  799. __git_dwim_remote_heads "$pfx" "$match" "$sfx"
  800. fi
  801. return
  802. fi
  803. case "$cur_" in
  804. refs|refs/*)
  805. __git ls-remote "$remote" "$match*" | \
  806. while read -r hash i; do
  807. case "$i" in
  808. *^{}) ;;
  809. *) echo "$pfx$i$sfx" ;;
  810. esac
  811. done
  812. ;;
  813. *)
  814. if [ "$list_refs_from" = remote ]; then
  815. case "HEAD" in
  816. $match*) echo "${pfx}HEAD$sfx" ;;
  817. esac
  818. __git for-each-ref --format="$fer_pfx%(refname:strip=3)$sfx" \
  819. "refs/remotes/$remote/$match*" \
  820. "refs/remotes/$remote/$match*/**"
  821. else
  822. local query_symref
  823. case "HEAD" in
  824. $match*) query_symref="HEAD" ;;
  825. esac
  826. __git ls-remote "$remote" $query_symref \
  827. "refs/tags/$match*" "refs/heads/$match*" \
  828. "refs/remotes/$match*" |
  829. while read -r hash i; do
  830. case "$i" in
  831. *^{}) ;;
  832. refs/*) echo "$pfx${i#refs/*/}$sfx" ;;
  833. *) echo "$pfx$i$sfx" ;; # symbolic refs
  834. esac
  835. done
  836. fi
  837. ;;
  838. esac
  839. }
  840. # Completes refs, short and long, local and remote, symbolic and pseudo.
  841. #
  842. # Usage: __git_complete_refs [<option>]...
  843. # --remote=<remote>: The remote to list refs from, can be the name of a
  844. # configured remote, a path, or a URL.
  845. # --dwim: List unique remote branches for 'git switch's tracking DWIMery.
  846. # --pfx=<prefix>: A prefix to be added to each ref.
  847. # --cur=<word>: The current ref to be completed. Defaults to the current
  848. # word to be completed.
  849. # --sfx=<suffix>: A suffix to be appended to each ref instead of the default
  850. # space.
  851. # --mode=<mode>: What set of refs to complete, one of 'refs' (the default) to
  852. # complete all refs, 'heads' to complete only branches, or
  853. # 'remote-heads' to complete only remote branches. Note that
  854. # --remote is only compatible with --mode=refs.
  855. __git_complete_refs ()
  856. {
  857. local remote= dwim= pfx= cur_="$cur" sfx=" " mode="refs"
  858. while test $# != 0; do
  859. case "$1" in
  860. --remote=*) remote="${1##--remote=}" ;;
  861. --dwim) dwim="yes" ;;
  862. # --track is an old spelling of --dwim
  863. --track) dwim="yes" ;;
  864. --pfx=*) pfx="${1##--pfx=}" ;;
  865. --cur=*) cur_="${1##--cur=}" ;;
  866. --sfx=*) sfx="${1##--sfx=}" ;;
  867. --mode=*) mode="${1##--mode=}" ;;
  868. *) return 1 ;;
  869. esac
  870. shift
  871. done
  872. # complete references based on the specified mode
  873. case "$mode" in
  874. refs)
  875. __gitcomp_direct "$(__git_refs "$remote" "" "$pfx" "$cur_" "$sfx")" ;;
  876. heads)
  877. __gitcomp_direct "$(__git_heads "$pfx" "$cur_" "$sfx")" ;;
  878. remote-heads)
  879. __gitcomp_direct "$(__git_remote_heads "$pfx" "$cur_" "$sfx")" ;;
  880. *)
  881. return 1 ;;
  882. esac
  883. # Append DWIM remote branch names if requested
  884. if [ "$dwim" = "yes" ]; then
  885. __gitcomp_direct_append "$(__git_dwim_remote_heads "$pfx" "$cur_" "$sfx")"
  886. fi
  887. }
  888. # __git_refs2 requires 1 argument (to pass to __git_refs)
  889. # Deprecated: use __git_complete_fetch_refspecs() instead.
  890. __git_refs2 ()
  891. {
  892. local i
  893. for i in $(__git_refs "$1"); do
  894. echo "$i:$i"
  895. done
  896. }
  897. # Completes refspecs for fetching from a remote repository.
  898. # 1: The remote repository.
  899. # 2: A prefix to be added to each listed refspec (optional).
  900. # 3: The ref to be completed as a refspec instead of the current word to be
  901. # completed (optional)
  902. # 4: A suffix to be appended to each listed refspec instead of the default
  903. # space (optional).
  904. __git_complete_fetch_refspecs ()
  905. {
  906. local i remote="$1" pfx="${2-}" cur_="${3-$cur}" sfx="${4- }"
  907. __gitcomp_direct "$(
  908. for i in $(__git_refs "$remote" "" "" "$cur_") ; do
  909. echo "$pfx$i:$i$sfx"
  910. done
  911. )"
  912. }
  913. # __git_refs_remotes requires 1 argument (to pass to ls-remote)
  914. __git_refs_remotes ()
  915. {
  916. local i hash
  917. __git ls-remote "$1" 'refs/heads/*' | \
  918. while read -r hash i; do
  919. echo "$i:refs/remotes/$1/${i#refs/heads/}"
  920. done
  921. }
  922. __git_remotes ()
  923. {
  924. __git_find_repo_path
  925. test -d "$__git_repo_path/remotes" && ls -1 "$__git_repo_path/remotes"
  926. __git remote
  927. }
  928. # Returns true if $1 matches the name of a configured remote, false otherwise.
  929. __git_is_configured_remote ()
  930. {
  931. local remote
  932. for remote in $(__git_remotes); do
  933. if [ "$remote" = "$1" ]; then
  934. return 0
  935. fi
  936. done
  937. return 1
  938. }
  939. __git_list_merge_strategies ()
  940. {
  941. LANG=C LC_ALL=C git merge -s help 2>&1 |
  942. sed -n -e '/[Aa]vailable strategies are: /,/^$/{
  943. s/\.$//
  944. s/.*://
  945. s/^[ ]*//
  946. s/[ ]*$//
  947. p
  948. }'
  949. }
  950. __git_merge_strategies_default='octopus ours recursive resolve subtree'
  951. __git_merge_strategies=
  952. # 'git merge -s help' (and thus detection of the merge strategy
  953. # list) fails, unfortunately, if run outside of any git working
  954. # tree. __git_merge_strategies is set to the empty string in
  955. # that case, and the detection will be repeated the next time it
  956. # is needed.
  957. __git_compute_merge_strategies ()
  958. {
  959. test -n "$__git_merge_strategies" ||
  960. { __git_merge_strategies=$(__git_list_merge_strategies);
  961. __git_merge_strategies="${__git_merge_strategies:-__git_merge_strategies_default}"; }
  962. }
  963. __git_merge_strategy_options="ours theirs subtree subtree= patience
  964. histogram diff-algorithm= ignore-space-change ignore-all-space
  965. ignore-space-at-eol renormalize no-renormalize no-renames
  966. find-renames find-renames= rename-threshold="
  967. __git_complete_revlist_file ()
  968. {
  969. local dequoted_word pfx ls ref cur_="$cur"
  970. case "$cur_" in
  971. *..?*:*)
  972. return
  973. ;;
  974. ?*:*)
  975. ref="${cur_%%:*}"
  976. cur_="${cur_#*:}"
  977. __git_dequote "$cur_"
  978. case "$dequoted_word" in
  979. ?*/*)
  980. pfx="${dequoted_word%/*}"
  981. cur_="${dequoted_word##*/}"
  982. ls="$ref:$pfx"
  983. pfx="$pfx/"
  984. ;;
  985. *)
  986. cur_="$dequoted_word"
  987. ls="$ref"
  988. ;;
  989. esac
  990. case "$COMP_WORDBREAKS" in
  991. *:*) : great ;;
  992. *) pfx="$ref:$pfx" ;;
  993. esac
  994. __gitcomp_file "$(__git ls-tree "$ls" \
  995. | sed 's/^.* //
  996. s/$//')" \
  997. "$pfx" "$cur_"
  998. ;;
  999. *...*)
  1000. pfx="${cur_%...*}..."
  1001. cur_="${cur_#*...}"
  1002. __git_complete_refs --pfx="$pfx" --cur="$cur_"
  1003. ;;
  1004. *..*)
  1005. pfx="${cur_%..*}.."
  1006. cur_="${cur_#*..}"
  1007. __git_complete_refs --pfx="$pfx" --cur="$cur_"
  1008. ;;
  1009. *)
  1010. __git_complete_refs
  1011. ;;
  1012. esac
  1013. }
  1014. __git_complete_file ()
  1015. {
  1016. __git_complete_revlist_file
  1017. }
  1018. __git_complete_revlist ()
  1019. {
  1020. __git_complete_revlist_file
  1021. }
  1022. __git_complete_remote_or_refspec ()
  1023. {
  1024. local cur_="$cur" cmd="${words[1]}"
  1025. local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0
  1026. if [ "$cmd" = "remote" ]; then
  1027. ((c++))
  1028. fi
  1029. while [ $c -lt $cword ]; do
  1030. i="${words[c]}"
  1031. case "$i" in
  1032. --mirror) [ "$cmd" = "push" ] && no_complete_refspec=1 ;;
  1033. -d|--delete) [ "$cmd" = "push" ] && lhs=0 ;;
  1034. --all)
  1035. case "$cmd" in
  1036. push) no_complete_refspec=1 ;;
  1037. fetch)
  1038. return
  1039. ;;
  1040. *) ;;
  1041. esac
  1042. ;;
  1043. --multiple) no_complete_refspec=1; break ;;
  1044. -*) ;;
  1045. *) remote="$i"; break ;;
  1046. esac
  1047. ((c++))
  1048. done
  1049. if [ -z "$remote" ]; then
  1050. __gitcomp_nl "$(__git_remotes)"
  1051. return
  1052. fi
  1053. if [ $no_complete_refspec = 1 ]; then
  1054. return
  1055. fi
  1056. [ "$remote" = "." ] && remote=
  1057. case "$cur_" in
  1058. *:*)
  1059. case "$COMP_WORDBREAKS" in
  1060. *:*) : great ;;
  1061. *) pfx="${cur_%%:*}:" ;;
  1062. esac
  1063. cur_="${cur_#*:}"
  1064. lhs=0
  1065. ;;
  1066. +*)
  1067. pfx="+"
  1068. cur_="${cur_#+}"
  1069. ;;
  1070. esac
  1071. case "$cmd" in
  1072. fetch)
  1073. if [ $lhs = 1 ]; then
  1074. __git_complete_fetch_refspecs "$remote" "$pfx" "$cur_"
  1075. else
  1076. __git_complete_refs --pfx="$pfx" --cur="$cur_"
  1077. fi
  1078. ;;
  1079. pull|remote)
  1080. if [ $lhs = 1 ]; then
  1081. __git_complete_refs --remote="$remote" --pfx="$pfx" --cur="$cur_"
  1082. else
  1083. __git_complete_refs --pfx="$pfx" --cur="$cur_"
  1084. fi
  1085. ;;
  1086. push)
  1087. if [ $lhs = 1 ]; then
  1088. __git_complete_refs --pfx="$pfx" --cur="$cur_"
  1089. else
  1090. __git_complete_refs --remote="$remote" --pfx="$pfx" --cur="$cur_"
  1091. fi
  1092. ;;
  1093. esac
  1094. }
  1095. __git_complete_strategy ()
  1096. {
  1097. __git_compute_merge_strategies
  1098. case "$prev" in
  1099. -s|--strategy)
  1100. __gitcomp "$__git_merge_strategies"
  1101. return 0
  1102. ;;
  1103. -X)
  1104. __gitcomp "$__git_merge_strategy_options"
  1105. return 0
  1106. ;;
  1107. esac
  1108. case "$cur" in
  1109. --strategy=*)
  1110. __gitcomp "$__git_merge_strategies" "" "${cur##--strategy=}"
  1111. return 0
  1112. ;;
  1113. --strategy-option=*)
  1114. __gitcomp "$__git_merge_strategy_options" "" "${cur##--strategy-option=}"
  1115. return 0
  1116. ;;
  1117. esac
  1118. return 1
  1119. }
  1120. __git_all_commands=
  1121. __git_compute_all_commands ()
  1122. {
  1123. test -n "$__git_all_commands" ||
  1124. __git_all_commands=$(__git --list-cmds=main,others,alias,nohelpers)
  1125. }
  1126. # Lists all set config variables starting with the given section prefix,
  1127. # with the prefix removed.
  1128. __git_get_config_variables ()
  1129. {
  1130. local section="$1" i IFS=$'\n'
  1131. for i in $(__git config --name-only --get-regexp "^$section\..*"); do
  1132. echo "${i#$section.}"
  1133. done
  1134. }
  1135. __git_pretty_aliases ()
  1136. {
  1137. __git_get_config_variables "pretty"
  1138. }
  1139. # __git_aliased_command requires 1 argument
  1140. __git_aliased_command ()
  1141. {
  1142. local cur=$1 last list word cmdline
  1143. while [[ -n "$cur" ]]; do
  1144. if [[ "$list" == *" $cur "* ]]; then
  1145. # loop detected
  1146. return
  1147. fi
  1148. cmdline=$(__git config --get "alias.$cur")
  1149. list=" $cur $list"
  1150. last=$cur
  1151. cur=
  1152. for word in $cmdline; do
  1153. case "$word" in
  1154. \!gitk|gitk)
  1155. cur="gitk"
  1156. break
  1157. ;;
  1158. \!*) : shell command alias ;;
  1159. -*) : option ;;
  1160. *=*) : setting env ;;
  1161. git) : git itself ;;
  1162. \(\)) : skip parens of shell function definition ;;
  1163. {) : skip start of shell helper function ;;
  1164. :) : skip null command ;;
  1165. \'*) : skip opening quote after sh -c ;;
  1166. *)
  1167. cur="$word"
  1168. break
  1169. esac
  1170. done
  1171. done
  1172. cur=$last
  1173. if [[ "$cur" != "$1" ]]; then
  1174. echo "$cur"
  1175. fi
  1176. }
  1177. # Check whether one of the given words is present on the command line,
  1178. # and print the first word found.
  1179. #
  1180. # Usage: __git_find_on_cmdline [<option>]... "<wordlist>"
  1181. # --show-idx: Optionally show the index of the found word in the $words array.
  1182. __git_find_on_cmdline ()
  1183. {
  1184. local word c=1 show_idx
  1185. while test $# -gt 1; do
  1186. case "$1" in
  1187. --show-idx) show_idx=y ;;
  1188. *) return 1 ;;
  1189. esac
  1190. shift
  1191. done
  1192. local wordlist="$1"
  1193. while [ $c -lt $cword ]; do
  1194. for word in $wordlist; do
  1195. if [ "$word" = "${words[c]}" ]; then
  1196. if [ -n "${show_idx-}" ]; then
  1197. echo "$c $word"
  1198. else
  1199. echo "$word"
  1200. fi
  1201. return
  1202. fi
  1203. done
  1204. ((c++))
  1205. done
  1206. }
  1207. # Similar to __git_find_on_cmdline, except that it loops backwards and thus
  1208. # prints the *last* word found. Useful for finding which of two options that
  1209. # supersede each other came last, such as "--guess" and "--no-guess".
  1210. #
  1211. # Usage: __git_find_last_on_cmdline [<option>]... "<wordlist>"
  1212. # --show-idx: Optionally show the index of the found word in the $words array.
  1213. __git_find_last_on_cmdline ()
  1214. {
  1215. local word c=$cword show_idx
  1216. while test $# -gt 1; do
  1217. case "$1" in
  1218. --show-idx) show_idx=y ;;
  1219. *) return 1 ;;
  1220. esac
  1221. shift
  1222. done
  1223. local wordlist="$1"
  1224. while [ $c -gt 1 ]; do
  1225. ((c--))
  1226. for word in $wordlist; do
  1227. if [ "$word" = "${words[c]}" ]; then
  1228. if [ -n "$show_idx" ]; then
  1229. echo "$c $word"
  1230. else
  1231. echo "$word"
  1232. fi
  1233. return
  1234. fi
  1235. done
  1236. done
  1237. }
  1238. # Echo the value of an option set on the command line or config
  1239. #
  1240. # $1: short option name
  1241. # $2: long option name including =
  1242. # $3: list of possible values
  1243. # $4: config string (optional)
  1244. #
  1245. # example:
  1246. # result="$(__git_get_option_value "-d" "--do-something=" \
  1247. # "yes no" "core.doSomething")"
  1248. #
  1249. # result is then either empty (no option set) or "yes" or "no"
  1250. #
  1251. # __git_get_option_value requires 3 arguments
  1252. __git_get_option_value ()
  1253. {
  1254. local c short_opt long_opt val
  1255. local result= values config_key word
  1256. short_opt="$1"
  1257. long_opt="$2"
  1258. values="$3"
  1259. config_key="$4"
  1260. ((c = $cword - 1))
  1261. while [ $c -ge 0 ]; do
  1262. word="${words[c]}"
  1263. for val in $values; do
  1264. if [ "$short_opt$val" = "$word" ] ||
  1265. [ "$long_opt$val" = "$word" ]; then
  1266. result="$val"
  1267. break 2
  1268. fi
  1269. done
  1270. ((c--))
  1271. done
  1272. if [ -n "$config_key" ] && [ -z "$result" ]; then
  1273. result="$(__git config "$config_key")"
  1274. fi
  1275. echo "$result"
  1276. }
  1277. __git_has_doubledash ()
  1278. {
  1279. local c=1
  1280. while [ $c -lt $cword ]; do
  1281. if [ "--" = "${words[c]}" ]; then
  1282. return 0
  1283. fi
  1284. ((c++))
  1285. done
  1286. return 1
  1287. }
  1288. # Try to count non option arguments passed on the command line for the
  1289. # specified git command.
  1290. # When options are used, it is necessary to use the special -- option to
  1291. # tell the implementation were non option arguments begin.
  1292. # XXX this can not be improved, since options can appear everywhere, as
  1293. # an example:
  1294. # git mv x -n y
  1295. #
  1296. # __git_count_arguments requires 1 argument: the git command executed.
  1297. __git_count_arguments ()
  1298. {
  1299. local word i c=0
  1300. # Skip "git" (first argument)
  1301. for ((i=1; i < ${#words[@]}; i++)); do
  1302. word="${words[i]}"
  1303. case "$word" in
  1304. --)
  1305. # Good; we can assume that the following are only non
  1306. # option arguments.
  1307. ((c = 0))
  1308. ;;
  1309. "$1")
  1310. # Skip the specified git command and discard git
  1311. # main options
  1312. ((c = 0))
  1313. ;;
  1314. ?*)
  1315. ((c++))
  1316. ;;
  1317. esac
  1318. done
  1319. printf "%d" $c
  1320. }
  1321. __git_whitespacelist="nowarn warn error error-all fix"
  1322. __git_patchformat="mbox stgit stgit-series hg mboxrd"
  1323. __git_showcurrentpatch="diff raw"
  1324. __git_am_inprogress_options="--skip --continue --resolved --abort --quit --show-current-patch"
  1325. _git_am ()
  1326. {
  1327. __git_find_repo_path
  1328. if [ -d "$__git_repo_path"/rebase-apply ]; then
  1329. __gitcomp "$__git_am_inprogress_options"
  1330. return
  1331. fi
  1332. case "$cur" in
  1333. --whitespace=*)
  1334. __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
  1335. return
  1336. ;;
  1337. --patch-format=*)
  1338. __gitcomp "$__git_patchformat" "" "${cur##--patch-format=}"
  1339. return
  1340. ;;
  1341. --show-current-patch=*)
  1342. __gitcomp "$__git_showcurrentpatch" "" "${cur##--show-current-patch=}"
  1343. return
  1344. ;;
  1345. --*)
  1346. __gitcomp_builtin am "" \
  1347. "$__git_am_inprogress_options"
  1348. return
  1349. esac
  1350. }
  1351. _git_apply ()
  1352. {
  1353. case "$cur" in
  1354. --whitespace=*)
  1355. __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
  1356. return
  1357. ;;
  1358. --*)
  1359. __gitcomp_builtin apply
  1360. return
  1361. esac
  1362. }
  1363. _git_add ()
  1364. {
  1365. case "$cur" in
  1366. --chmod=*)
  1367. __gitcomp "+x -x" "" "${cur##--chmod=}"
  1368. return
  1369. ;;
  1370. --*)
  1371. __gitcomp_builtin add
  1372. return
  1373. esac
  1374. local complete_opt="--others --modified --directory --no-empty-directory"
  1375. if test -n "$(__git_find_on_cmdline "-u --update")"
  1376. then
  1377. complete_opt="--modified"
  1378. fi
  1379. __git_complete_index_file "$complete_opt"
  1380. }
  1381. _git_archive ()
  1382. {
  1383. case "$cur" in
  1384. --format=*)
  1385. __gitcomp "$(git archive --list)" "" "${cur##--format=}"
  1386. return
  1387. ;;
  1388. --remote=*)
  1389. __gitcomp_nl "$(__git_remotes)" "" "${cur##--remote=}"
  1390. return
  1391. ;;
  1392. --*)
  1393. __gitcomp_builtin archive "--format= --list --verbose --prefix= --worktree-attributes"
  1394. return
  1395. ;;
  1396. esac
  1397. __git_complete_file
  1398. }
  1399. _git_bisect ()
  1400. {
  1401. __git_has_doubledash && return
  1402. local subcommands="start bad good skip reset visualize replay log run"
  1403. local subcommand="$(__git_find_on_cmdline "$subcommands")"
  1404. if [ -z "$subcommand" ]; then
  1405. __git_find_repo_path
  1406. if [ -f "$__git_repo_path"/BISECT_START ]; then
  1407. __gitcomp "$subcommands"
  1408. else
  1409. __gitcomp "replay start"
  1410. fi
  1411. return
  1412. fi
  1413. case "$subcommand" in
  1414. bad|good|reset|skip|start)
  1415. __git_complete_refs
  1416. ;;
  1417. *)
  1418. ;;
  1419. esac
  1420. }
  1421. __git_ref_fieldlist="refname objecttype objectsize objectname upstream push HEAD symref"
  1422. _git_branch ()
  1423. {
  1424. local i c=1 only_local_ref="n" has_r="n"
  1425. while [ $c -lt $cword ]; do
  1426. i="${words[c]}"
  1427. case "$i" in
  1428. -d|--delete|-m|--move) only_local_ref="y" ;;
  1429. -r|--remotes) has_r="y" ;;
  1430. esac
  1431. ((c++))
  1432. done
  1433. case "$cur" in
  1434. --set-upstream-to=*)
  1435. __git_complete_refs --cur="${cur##--set-upstream-to=}"
  1436. ;;
  1437. --*)
  1438. __gitcomp_builtin branch
  1439. ;;
  1440. *)
  1441. if [ $only_local_ref = "y" -a $has_r = "n" ]; then
  1442. __gitcomp_direct "$(__git_heads "" "$cur" " ")"
  1443. else
  1444. __git_complete_refs
  1445. fi
  1446. ;;
  1447. esac
  1448. }
  1449. _git_bundle ()
  1450. {
  1451. local cmd="${words[2]}"
  1452. case "$cword" in
  1453. 2)
  1454. __gitcomp "create list-heads verify unbundle"
  1455. ;;
  1456. 3)
  1457. # looking for a file
  1458. ;;
  1459. *)
  1460. case "$cmd" in
  1461. create)
  1462. __git_complete_revlist
  1463. ;;
  1464. esac
  1465. ;;
  1466. esac
  1467. }
  1468. # Helper function to decide whether or not we should enable DWIM logic for
  1469. # git-switch and git-checkout.
  1470. #
  1471. # To decide between the following rules in priority order
  1472. # 1) the last provided of "--guess" or "--no-guess" explicitly enable or
  1473. # disable completion of DWIM logic respectively.
  1474. # 2) If the --no-track option is provided, take this as a hint to disable the
  1475. # DWIM completion logic
  1476. # 3) If GIT_COMPLETION_CHECKOUT_NO_GUESS is set, disable the DWIM completion
  1477. # logic, as requested by the user.
  1478. # 4) Enable DWIM logic otherwise.
  1479. #
  1480. __git_checkout_default_dwim_mode ()
  1481. {
  1482. local last_option dwim_opt="--dwim"
  1483. if [ "${GIT_COMPLETION_CHECKOUT_NO_GUESS-}" = "1" ]; then
  1484. dwim_opt=""
  1485. fi
  1486. # --no-track disables DWIM, but with lower priority than
  1487. # --guess/--no-guess
  1488. if [ -n "$(__git_find_on_cmdline "--no-track")" ]; then
  1489. dwim_opt=""
  1490. fi
  1491. # Find the last provided --guess or --no-guess
  1492. last_option="$(__git_find_last_on_cmdline "--guess --no-guess")"
  1493. case "$last_option" in
  1494. --guess)
  1495. dwim_opt="--dwim"
  1496. ;;
  1497. --no-guess)
  1498. dwim_opt=""
  1499. ;;
  1500. esac
  1501. echo "$dwim_opt"
  1502. }
  1503. _git_checkout ()
  1504. {
  1505. __git_has_doubledash && return
  1506. local dwim_opt="$(__git_checkout_default_dwim_mode)"
  1507. case "$prev" in
  1508. -b|-B|--orphan)
  1509. # Complete local branches (and DWIM branch
  1510. # remote branch names) for an option argument
  1511. # specifying a new branch name. This is for
  1512. # convenience, assuming new branches are
  1513. # possibly based on pre-existing branch names.
  1514. __git_complete_refs $dwim_opt --mode="heads"
  1515. return
  1516. ;;
  1517. *)
  1518. ;;
  1519. esac
  1520. case "$cur" in
  1521. --conflict=*)
  1522. __gitcomp "diff3 merge" "" "${cur##--conflict=}"
  1523. ;;
  1524. --*)
  1525. __gitcomp_builtin checkout
  1526. ;;
  1527. *)
  1528. # At this point, we've already handled special completion for
  1529. # the arguments to -b/-B, and --orphan. There are 3 main
  1530. # things left we can possibly complete:
  1531. # 1) a start-point for -b/-B, -d/--detach, or --orphan
  1532. # 2) a remote head, for --track
  1533. # 3) an arbitrary reference, possibly including DWIM names
  1534. #
  1535. if [ -n "$(__git_find_on_cmdline "-b -B -d --detach --orphan")" ]; then
  1536. __git_complete_refs --mode="refs"
  1537. elif [ -n "$(__git_find_on_cmdline "--track")" ]; then
  1538. __git_complete_refs --mode="remote-heads"
  1539. else
  1540. __git_complete_refs $dwim_opt --mode="refs"
  1541. fi
  1542. ;;
  1543. esac
  1544. }
  1545. __git_sequencer_inprogress_options="--continue --quit --abort --skip"
  1546. __git_cherry_pick_inprogress_options=$__git_sequencer_inprogress_options
  1547. _git_cherry_pick ()
  1548. {
  1549. __git_find_repo_path
  1550. if [ -f "$__git_repo_path"/CHERRY_PICK_HEAD ]; then
  1551. __gitcomp "$__git_cherry_pick_inprogress_options"
  1552. return
  1553. fi
  1554. __git_complete_strategy && return
  1555. case "$cur" in
  1556. --*)
  1557. __gitcomp_builtin cherry-pick "" \
  1558. "$__git_cherry_pick_inprogress_options"
  1559. ;;
  1560. *)
  1561. __git_complete_refs
  1562. ;;
  1563. esac
  1564. }
  1565. _git_clean ()
  1566. {
  1567. case "$cur" in
  1568. --*)
  1569. __gitcomp_builtin clean
  1570. return
  1571. ;;
  1572. esac
  1573. # XXX should we check for -x option ?
  1574. __git_complete_index_file "--others --directory"
  1575. }
  1576. _git_clone ()
  1577. {
  1578. case "$prev" in
  1579. -c|--config)
  1580. __git_complete_config_variable_name_and_value
  1581. return
  1582. ;;
  1583. esac
  1584. case "$cur" in
  1585. --config=*)
  1586. __git_complete_config_variable_name_and_value \
  1587. --cur="${cur##--config=}"
  1588. return
  1589. ;;
  1590. --*)
  1591. __gitcomp_builtin clone
  1592. return
  1593. ;;
  1594. esac
  1595. }
  1596. __git_untracked_file_modes="all no normal"
  1597. _git_commit ()
  1598. {
  1599. case "$prev" in
  1600. -c|-C)
  1601. __git_complete_refs
  1602. return
  1603. ;;
  1604. esac
  1605. case "$cur" in
  1606. --cleanup=*)
  1607. __gitcomp "default scissors strip verbatim whitespace
  1608. " "" "${cur##--cleanup=}"
  1609. return
  1610. ;;
  1611. --reuse-message=*|--reedit-message=*|\
  1612. --fixup=*|--squash=*)
  1613. __git_complete_refs --cur="${cur#*=}"
  1614. return
  1615. ;;
  1616. --untracked-files=*)
  1617. __gitcomp "$__git_untracked_file_modes" "" "${cur##--untracked-files=}"
  1618. return
  1619. ;;
  1620. --*)
  1621. __gitcomp_builtin commit
  1622. return
  1623. esac
  1624. if __git rev-parse --verify --quiet HEAD >/dev/null; then
  1625. __git_complete_index_file "--committable"
  1626. else
  1627. # This is the first commit
  1628. __git_complete_index_file "--cached"
  1629. fi
  1630. }
  1631. _git_describe ()
  1632. {
  1633. case "$cur" in
  1634. --*)
  1635. __gitcomp_builtin describe
  1636. return
  1637. esac
  1638. __git_complete_refs
  1639. }
  1640. __git_diff_algorithms="myers minimal patience histogram"
  1641. __git_diff_submodule_formats="diff log short"
  1642. __git_color_moved_opts="no default plain blocks zebra dimmed-zebra"
  1643. __git_color_moved_ws_opts="no ignore-space-at-eol ignore-space-change
  1644. ignore-all-space allow-indentation-change"
  1645. __git_diff_common_options="--stat --numstat --shortstat --summary
  1646. --patch-with-stat --name-only --name-status --color
  1647. --no-color --color-words --no-renames --check
  1648. --color-moved --color-moved= --no-color-moved
  1649. --color-moved-ws= --no-color-moved-ws
  1650. --full-index --binary --abbrev --diff-filter=
  1651. --find-copies-harder --ignore-cr-at-eol
  1652. --text --ignore-space-at-eol --ignore-space-change
  1653. --ignore-all-space --ignore-blank-lines --exit-code
  1654. --quiet --ext-diff --no-ext-diff
  1655. --no-prefix --src-prefix= --dst-prefix=
  1656. --inter-hunk-context=
  1657. --patience --histogram --minimal
  1658. --raw --word-diff --word-diff-regex=
  1659. --dirstat --dirstat= --dirstat-by-file
  1660. --dirstat-by-file= --cumulative
  1661. --diff-algorithm=
  1662. --submodule --submodule= --ignore-submodules
  1663. --indent-heuristic --no-indent-heuristic
  1664. --textconv --no-textconv
  1665. "
  1666. _git_diff ()
  1667. {
  1668. __git_has_doubledash && return
  1669. case "$cur" in
  1670. --diff-algorithm=*)
  1671. __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
  1672. return
  1673. ;;
  1674. --submodule=*)
  1675. __gitcomp "$__git_diff_submodule_formats" "" "${cur##--submodule=}"
  1676. return
  1677. ;;
  1678. --color-moved=*)
  1679. __gitcomp "$__git_color_moved_opts" "" "${cur##--color-moved=}"
  1680. return
  1681. ;;
  1682. --color-moved-ws=*)
  1683. __gitcomp "$__git_color_moved_ws_opts" "" "${cur##--color-moved-ws=}"
  1684. return
  1685. ;;
  1686. --*)
  1687. __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
  1688. --base --ours --theirs --no-index
  1689. $__git_diff_common_options
  1690. "
  1691. return
  1692. ;;
  1693. esac
  1694. __git_complete_revlist_file
  1695. }
  1696. __git_mergetools_common="diffuse diffmerge ecmerge emerge kdiff3 meld opendiff
  1697. tkdiff vimdiff nvimdiff gvimdiff xxdiff araxis p4merge
  1698. bc codecompare smerge
  1699. "
  1700. _git_difftool ()
  1701. {
  1702. __git_has_doubledash && return
  1703. case "$cur" in
  1704. --tool=*)
  1705. __gitcomp "$__git_mergetools_common kompare" "" "${cur##--tool=}"
  1706. return
  1707. ;;
  1708. --*)
  1709. __gitcomp_builtin difftool "$__git_diff_common_options
  1710. --base --cached --ours --theirs
  1711. --pickaxe-all --pickaxe-regex
  1712. --relative --staged
  1713. "
  1714. return
  1715. ;;
  1716. esac
  1717. __git_complete_revlist_file
  1718. }
  1719. __git_fetch_recurse_submodules="yes on-demand no"
  1720. _git_fetch ()
  1721. {
  1722. case "$cur" in
  1723. --recurse-submodules=*)
  1724. __gitcomp "$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}"
  1725. return
  1726. ;;
  1727. --filter=*)
  1728. __gitcomp "blob:none blob:limit= sparse:oid=" "" "${cur##--filter=}"
  1729. return
  1730. ;;
  1731. --*)
  1732. __gitcomp_builtin fetch
  1733. return
  1734. ;;
  1735. esac
  1736. __git_complete_remote_or_refspec
  1737. }
  1738. __git_format_patch_extra_options="
  1739. --full-index --not --all --no-prefix --src-prefix=
  1740. --dst-prefix= --notes
  1741. "
  1742. _git_format_patch ()
  1743. {
  1744. case "$cur" in
  1745. --thread=*)
  1746. __gitcomp "
  1747. deep shallow
  1748. " "" "${cur##--thread=}"
  1749. return
  1750. ;;
  1751. --base=*|--interdiff=*|--range-diff=*)
  1752. __git_complete_refs --cur="${cur#--*=}"
  1753. return
  1754. ;;
  1755. --*)
  1756. __gitcomp_builtin format-patch "$__git_format_patch_extra_options"
  1757. return
  1758. ;;
  1759. esac
  1760. __git_complete_revlist
  1761. }
  1762. _git_fsck ()
  1763. {
  1764. case "$cur" in
  1765. --*)
  1766. __gitcomp_builtin fsck
  1767. return
  1768. ;;
  1769. esac
  1770. }
  1771. _git_gitk ()
  1772. {
  1773. _gitk
  1774. }
  1775. # Lists matching symbol names from a tag (as in ctags) file.
  1776. # 1: List symbol names matching this word.
  1777. # 2: The tag file to list symbol names from.
  1778. # 3: A prefix to be added to each listed symbol name (optional).
  1779. # 4: A suffix to be appended to each listed symbol name (optional).
  1780. __git_match_ctag () {
  1781. awk -v pfx="${3-}" -v sfx="${4-}" "
  1782. /^${1//\//\\/}/ { print pfx \$1 sfx }
  1783. " "$2"
  1784. }
  1785. # Complete symbol names from a tag file.
  1786. # Usage: __git_complete_symbol [<option>]...
  1787. # --tags=<file>: The tag file to list symbol names from instead of the
  1788. # default "tags".
  1789. # --pfx=<prefix>: A prefix to be added to each symbol name.
  1790. # --cur=<word>: The current symbol name to be completed. Defaults to
  1791. # the current word to be completed.
  1792. # --sfx=<suffix>: A suffix to be appended to each symbol name instead
  1793. # of the default space.
  1794. __git_complete_symbol () {
  1795. local tags=tags pfx="" cur_="${cur-}" sfx=" "
  1796. while test $# != 0; do
  1797. case "$1" in
  1798. --tags=*) tags="${1##--tags=}" ;;
  1799. --pfx=*) pfx="${1##--pfx=}" ;;
  1800. --cur=*) cur_="${1##--cur=}" ;;
  1801. --sfx=*) sfx="${1##--sfx=}" ;;
  1802. *) return 1 ;;
  1803. esac
  1804. shift
  1805. done
  1806. if test -r "$tags"; then
  1807. __gitcomp_direct "$(__git_match_ctag "$cur_" "$tags" "$pfx" "$sfx")"
  1808. fi
  1809. }
  1810. _git_grep ()
  1811. {
  1812. __git_has_doubledash && return
  1813. case "$cur" in
  1814. --*)
  1815. __gitcomp_builtin grep
  1816. return
  1817. ;;
  1818. esac
  1819. case "$cword,$prev" in
  1820. 2,*|*,-*)
  1821. __git_complete_symbol && return
  1822. ;;
  1823. esac
  1824. __git_complete_refs
  1825. }
  1826. _git_help ()
  1827. {
  1828. case "$cur" in
  1829. --*)
  1830. __gitcomp_builtin help
  1831. return
  1832. ;;
  1833. esac
  1834. if test -n "$GIT_TESTING_ALL_COMMAND_LIST"
  1835. then
  1836. __gitcomp "$GIT_TESTING_ALL_COMMAND_LIST $(__git --list-cmds=alias,list-guide) gitk"
  1837. else
  1838. __gitcomp "$(__git --list-cmds=main,nohelpers,alias,list-guide) gitk"
  1839. fi
  1840. }
  1841. _git_init ()
  1842. {
  1843. case "$cur" in
  1844. --shared=*)
  1845. __gitcomp "
  1846. false true umask group all world everybody
  1847. " "" "${cur##--shared=}"
  1848. return
  1849. ;;
  1850. --*)
  1851. __gitcomp_builtin init
  1852. return
  1853. ;;
  1854. esac
  1855. }
  1856. _git_ls_files ()
  1857. {
  1858. case "$cur" in
  1859. --*)
  1860. __gitcomp_builtin ls-files
  1861. return
  1862. ;;
  1863. esac
  1864. # XXX ignore options like --modified and always suggest all cached
  1865. # files.
  1866. __git_complete_index_file "--cached"
  1867. }
  1868. _git_ls_remote ()
  1869. {
  1870. case "$cur" in
  1871. --*)
  1872. __gitcomp_builtin ls-remote
  1873. return
  1874. ;;
  1875. esac
  1876. __gitcomp_nl "$(__git_remotes)"
  1877. }
  1878. _git_ls_tree ()
  1879. {
  1880. case "$cur" in
  1881. --*)
  1882. __gitcomp_builtin ls-tree
  1883. return
  1884. ;;
  1885. esac
  1886. __git_complete_file
  1887. }
  1888. # Options that go well for log, shortlog and gitk
  1889. __git_log_common_options="
  1890. --not --all
  1891. --branches --tags --remotes
  1892. --first-parent --merges --no-merges
  1893. --max-count=
  1894. --max-age= --since= --after=
  1895. --min-age= --until= --before=
  1896. --min-parents= --max-parents=
  1897. --no-min-parents --no-max-parents
  1898. "
  1899. # Options that go well for log and gitk (not shortlog)
  1900. __git_log_gitk_options="
  1901. --dense --sparse --full-history
  1902. --simplify-merges --simplify-by-decoration
  1903. --left-right --notes --no-notes
  1904. "
  1905. # Options that go well for log and shortlog (not gitk)
  1906. __git_log_shortlog_options="
  1907. --author= --committer= --grep=
  1908. --all-match --invert-grep
  1909. "
  1910. __git_log_pretty_formats="oneline short medium full fuller reference email raw format: tformat: mboxrd"
  1911. __git_log_date_formats="relative iso8601 iso8601-strict rfc2822 short local default raw unix format:"
  1912. _git_log ()
  1913. {
  1914. __git_has_doubledash && return
  1915. __git_find_repo_path
  1916. local merge=""
  1917. if [ -f "$__git_repo_path/MERGE_HEAD" ]; then
  1918. merge="--merge"
  1919. fi
  1920. case "$prev,$cur" in
  1921. -L,:*:*)
  1922. return # fall back to Bash filename completion
  1923. ;;
  1924. -L,:*)
  1925. __git_complete_symbol --cur="${cur#:}" --sfx=":"
  1926. return
  1927. ;;
  1928. -G,*|-S,*)
  1929. __git_complete_symbol
  1930. return
  1931. ;;
  1932. esac
  1933. case "$cur" in
  1934. --pretty=*|--format=*)
  1935. __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
  1936. " "" "${cur#*=}"
  1937. return
  1938. ;;
  1939. --date=*)
  1940. __gitcomp "$__git_log_date_formats" "" "${cur##--date=}"
  1941. return
  1942. ;;
  1943. --decorate=*)
  1944. __gitcomp "full short no" "" "${cur##--decorate=}"
  1945. return
  1946. ;;
  1947. --diff-algorithm=*)
  1948. __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
  1949. return
  1950. ;;
  1951. --submodule=*)
  1952. __gitcomp "$__git_diff_submodule_formats" "" "${cur##--submodule=}"
  1953. return
  1954. ;;
  1955. --no-walk=*)
  1956. __gitcomp "sorted unsorted" "" "${cur##--no-walk=}"
  1957. return
  1958. ;;
  1959. --*)
  1960. __gitcomp "
  1961. $__git_log_common_options
  1962. $__git_log_shortlog_options
  1963. $__git_log_gitk_options
  1964. --root --topo-order --date-order --reverse
  1965. --follow --full-diff
  1966. --abbrev-commit --no-abbrev-commit --abbrev=
  1967. --relative-date --date=
  1968. --pretty= --format= --oneline
  1969. --show-signature
  1970. --cherry-mark
  1971. --cherry-pick
  1972. --graph
  1973. --decorate --decorate= --no-decorate
  1974. --walk-reflogs
  1975. --no-walk --no-walk= --do-walk
  1976. --parents --children
  1977. --expand-tabs --expand-tabs= --no-expand-tabs
  1978. --patch
  1979. $merge
  1980. $__git_diff_common_options
  1981. --pickaxe-all --pickaxe-regex
  1982. --patch --no-patch
  1983. "
  1984. return
  1985. ;;
  1986. -L:*:*)
  1987. return # fall back to Bash filename completion
  1988. ;;
  1989. -L:*)
  1990. __git_complete_symbol --cur="${cur#-L:}" --sfx=":"
  1991. return
  1992. ;;
  1993. -G*)
  1994. __git_complete_symbol --pfx="-G" --cur="${cur#-G}"
  1995. return
  1996. ;;
  1997. -S*)
  1998. __git_complete_symbol --pfx="-S" --cur="${cur#-S}"
  1999. return
  2000. ;;
  2001. esac
  2002. __git_complete_revlist
  2003. }
  2004. _git_merge ()
  2005. {
  2006. __git_complete_strategy && return
  2007. case "$cur" in
  2008. --*)
  2009. __gitcomp_builtin merge
  2010. return
  2011. esac
  2012. __git_complete_refs
  2013. }
  2014. _git_mergetool ()
  2015. {
  2016. case "$cur" in
  2017. --tool=*)
  2018. __gitcomp "$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"
  2019. return
  2020. ;;
  2021. --*)
  2022. __gitcomp "--tool= --prompt --no-prompt --gui --no-gui"
  2023. return
  2024. ;;
  2025. esac
  2026. }
  2027. _git_merge_base ()
  2028. {
  2029. case "$cur" in
  2030. --*)
  2031. __gitcomp_builtin merge-base
  2032. return
  2033. ;;
  2034. esac
  2035. __git_complete_refs
  2036. }
  2037. _git_mv ()
  2038. {
  2039. case "$cur" in
  2040. --*)
  2041. __gitcomp_builtin mv
  2042. return
  2043. ;;
  2044. esac
  2045. if [ $(__git_count_arguments "mv") -gt 0 ]; then
  2046. # We need to show both cached and untracked files (including
  2047. # empty directories) since this may not be the last argument.
  2048. __git_complete_index_file "--cached --others --directory"
  2049. else
  2050. __git_complete_index_file "--cached"
  2051. fi
  2052. }
  2053. _git_notes ()
  2054. {
  2055. local subcommands='add append copy edit get-ref list merge prune remove show'
  2056. local subcommand="$(__git_find_on_cmdline "$subcommands")"
  2057. case "$subcommand,$cur" in
  2058. ,--*)
  2059. __gitcomp_builtin notes
  2060. ;;
  2061. ,*)
  2062. case "$prev" in
  2063. --ref)
  2064. __git_complete_refs
  2065. ;;
  2066. *)
  2067. __gitcomp "$subcommands --ref"
  2068. ;;
  2069. esac
  2070. ;;
  2071. *,--reuse-message=*|*,--reedit-message=*)
  2072. __git_complete_refs --cur="${cur#*=}"
  2073. ;;
  2074. *,--*)
  2075. __gitcomp_builtin notes_$subcommand
  2076. ;;
  2077. prune,*|get-ref,*)
  2078. # this command does not take a ref, do not complete it
  2079. ;;
  2080. *)
  2081. case "$prev" in
  2082. -m|-F)
  2083. ;;
  2084. *)
  2085. __git_complete_refs
  2086. ;;
  2087. esac
  2088. ;;
  2089. esac
  2090. }
  2091. _git_pull ()
  2092. {
  2093. __git_complete_strategy && return
  2094. case "$cur" in
  2095. --recurse-submodules=*)
  2096. __gitcomp "$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}"
  2097. return
  2098. ;;
  2099. --*)
  2100. __gitcomp_builtin pull
  2101. return
  2102. ;;
  2103. esac
  2104. __git_complete_remote_or_refspec
  2105. }
  2106. __git_push_recurse_submodules="check on-demand only"
  2107. __git_complete_force_with_lease ()
  2108. {
  2109. local cur_=$1
  2110. case "$cur_" in
  2111. --*=)
  2112. ;;
  2113. *:*)
  2114. __git_complete_refs --cur="${cur_#*:}"
  2115. ;;
  2116. *)
  2117. __git_complete_refs --cur="$cur_"
  2118. ;;
  2119. esac
  2120. }
  2121. _git_push ()
  2122. {
  2123. case "$prev" in
  2124. --repo)
  2125. __gitcomp_nl "$(__git_remotes)"
  2126. return
  2127. ;;
  2128. --recurse-submodules)
  2129. __gitcomp "$__git_push_recurse_submodules"
  2130. return
  2131. ;;
  2132. esac
  2133. case "$cur" in
  2134. --repo=*)
  2135. __gitcomp_nl "$(__git_remotes)" "" "${cur##--repo=}"
  2136. return
  2137. ;;
  2138. --recurse-submodules=*)
  2139. __gitcomp "$__git_push_recurse_submodules" "" "${cur##--recurse-submodules=}"
  2140. return
  2141. ;;
  2142. --force-with-lease=*)
  2143. __git_complete_force_with_lease "${cur##--force-with-lease=}"
  2144. return
  2145. ;;
  2146. --*)
  2147. __gitcomp_builtin push
  2148. return
  2149. ;;
  2150. esac
  2151. __git_complete_remote_or_refspec
  2152. }
  2153. _git_range_diff ()
  2154. {
  2155. case "$cur" in
  2156. --*)
  2157. __gitcomp "
  2158. --creation-factor= --no-dual-color
  2159. $__git_diff_common_options
  2160. "
  2161. return
  2162. ;;
  2163. esac
  2164. __git_complete_revlist
  2165. }
  2166. __git_rebase_inprogress_options="--continue --skip --abort --quit --show-current-patch"
  2167. __git_rebase_interactive_inprogress_options="$__git_rebase_inprogress_options --edit-todo"
  2168. _git_rebase ()
  2169. {
  2170. __git_find_repo_path
  2171. if [ -f "$__git_repo_path"/rebase-merge/interactive ]; then
  2172. __gitcomp "$__git_rebase_interactive_inprogress_options"
  2173. return
  2174. elif [ -d "$__git_repo_path"/rebase-apply ] || \
  2175. [ -d "$__git_repo_path"/rebase-merge ]; then
  2176. __gitcomp "$__git_rebase_inprogress_options"
  2177. return
  2178. fi
  2179. __git_complete_strategy && return
  2180. case "$cur" in
  2181. --whitespace=*)
  2182. __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
  2183. return
  2184. ;;
  2185. --onto=*)
  2186. __git_complete_refs --cur="${cur##--onto=}"
  2187. return
  2188. ;;
  2189. --*)
  2190. __gitcomp_builtin rebase "" \
  2191. "$__git_rebase_interactive_inprogress_options"
  2192. return
  2193. esac
  2194. __git_complete_refs
  2195. }
  2196. _git_reflog ()
  2197. {
  2198. local subcommands="show delete expire"
  2199. local subcommand="$(__git_find_on_cmdline "$subcommands")"
  2200. if [ -z "$subcommand" ]; then
  2201. __gitcomp "$subcommands"
  2202. else
  2203. __git_complete_refs
  2204. fi
  2205. }
  2206. __git_send_email_confirm_options="always never auto cc compose"
  2207. __git_send_email_suppresscc_options="author self cc bodycc sob cccmd body all"
  2208. _git_send_email ()
  2209. {
  2210. case "$prev" in
  2211. --to|--cc|--bcc|--from)
  2212. __gitcomp "$(__git send-email --dump-aliases)"
  2213. return
  2214. ;;
  2215. esac
  2216. case "$cur" in
  2217. --confirm=*)
  2218. __gitcomp "
  2219. $__git_send_email_confirm_options
  2220. " "" "${cur##--confirm=}"
  2221. return
  2222. ;;
  2223. --suppress-cc=*)
  2224. __gitcomp "
  2225. $__git_send_email_suppresscc_options
  2226. " "" "${cur##--suppress-cc=}"
  2227. return
  2228. ;;
  2229. --smtp-encryption=*)
  2230. __gitcomp "ssl tls" "" "${cur##--smtp-encryption=}"
  2231. return
  2232. ;;
  2233. --thread=*)
  2234. __gitcomp "
  2235. deep shallow
  2236. " "" "${cur##--thread=}"
  2237. return
  2238. ;;
  2239. --to=*|--cc=*|--bcc=*|--from=*)
  2240. __gitcomp "$(__git send-email --dump-aliases)" "" "${cur#--*=}"
  2241. return
  2242. ;;
  2243. --*)
  2244. __gitcomp_builtin send-email "--annotate --bcc --cc --cc-cmd --chain-reply-to
  2245. --compose --confirm= --dry-run --envelope-sender
  2246. --from --identity
  2247. --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
  2248. --no-suppress-from --no-thread --quiet --reply-to
  2249. --signed-off-by-cc --smtp-pass --smtp-server
  2250. --smtp-server-port --smtp-encryption= --smtp-user
  2251. --subject --suppress-cc= --suppress-from --thread --to
  2252. --validate --no-validate
  2253. $__git_format_patch_extra_options"
  2254. return
  2255. ;;
  2256. esac
  2257. __git_complete_revlist
  2258. }
  2259. _git_stage ()
  2260. {
  2261. _git_add
  2262. }
  2263. _git_status ()
  2264. {
  2265. local complete_opt
  2266. local untracked_state
  2267. case "$cur" in
  2268. --ignore-submodules=*)
  2269. __gitcomp "none untracked dirty all" "" "${cur##--ignore-submodules=}"
  2270. return
  2271. ;;
  2272. --untracked-files=*)
  2273. __gitcomp "$__git_untracked_file_modes" "" "${cur##--untracked-files=}"
  2274. return
  2275. ;;
  2276. --column=*)
  2277. __gitcomp "
  2278. always never auto column row plain dense nodense
  2279. " "" "${cur##--column=}"
  2280. return
  2281. ;;
  2282. --*)
  2283. __gitcomp_builtin status
  2284. return
  2285. ;;
  2286. esac
  2287. untracked_state="$(__git_get_option_value "-u" "--untracked-files=" \
  2288. "$__git_untracked_file_modes" "status.showUntrackedFiles")"
  2289. case "$untracked_state" in
  2290. no)
  2291. # --ignored option does not matter
  2292. complete_opt=
  2293. ;;
  2294. all|normal|*)
  2295. complete_opt="--cached --directory --no-empty-directory --others"
  2296. if [ -n "$(__git_find_on_cmdline "--ignored")" ]; then
  2297. complete_opt="$complete_opt --ignored --exclude=*"
  2298. fi
  2299. ;;
  2300. esac
  2301. __git_complete_index_file "$complete_opt"
  2302. }
  2303. _git_switch ()
  2304. {
  2305. local dwim_opt="$(__git_checkout_default_dwim_mode)"
  2306. case "$prev" in
  2307. -c|-C|--orphan)
  2308. # Complete local branches (and DWIM branch
  2309. # remote branch names) for an option argument
  2310. # specifying a new branch name. This is for
  2311. # convenience, assuming new branches are
  2312. # possibly based on pre-existing branch names.
  2313. __git_complete_refs $dwim_opt --mode="heads"
  2314. return
  2315. ;;
  2316. *)
  2317. ;;
  2318. esac
  2319. case "$cur" in
  2320. --conflict=*)
  2321. __gitcomp "diff3 merge" "" "${cur##--conflict=}"
  2322. ;;
  2323. --*)
  2324. __gitcomp_builtin switch
  2325. ;;
  2326. *)
  2327. # Unlike in git checkout, git switch --orphan does not take
  2328. # a start point. Thus we really have nothing to complete after
  2329. # the branch name.
  2330. if [ -n "$(__git_find_on_cmdline "--orphan")" ]; then
  2331. return
  2332. fi
  2333. # At this point, we've already handled special completion for
  2334. # -c/-C, and --orphan. There are 3 main things left to
  2335. # complete:
  2336. # 1) a start-point for -c/-C or -d/--detach
  2337. # 2) a remote head, for --track
  2338. # 3) a branch name, possibly including DWIM remote branches
  2339. if [ -n "$(__git_find_on_cmdline "-c -C -d --detach")" ]; then
  2340. __git_complete_refs --mode="refs"
  2341. elif [ -n "$(__git_find_on_cmdline "--track")" ]; then
  2342. __git_complete_refs --mode="remote-heads"
  2343. else
  2344. __git_complete_refs $dwim_opt --mode="heads"
  2345. fi
  2346. ;;
  2347. esac
  2348. }
  2349. __git_config_get_set_variables ()
  2350. {
  2351. local prevword word config_file= c=$cword
  2352. while [ $c -gt 1 ]; do
  2353. word="${words[c]}"
  2354. case "$word" in
  2355. --system|--global|--local|--file=*)
  2356. config_file="$word"
  2357. break
  2358. ;;
  2359. -f|--file)
  2360. config_file="$word $prevword"
  2361. break
  2362. ;;
  2363. esac
  2364. prevword=$word
  2365. c=$((--c))
  2366. done
  2367. __git config $config_file --name-only --list
  2368. }
  2369. __git_config_vars=
  2370. __git_compute_config_vars ()
  2371. {
  2372. test -n "$__git_config_vars" ||
  2373. __git_config_vars="$(git help --config-for-completion | sort -u)"
  2374. }
  2375. # Completes possible values of various configuration variables.
  2376. #
  2377. # Usage: __git_complete_config_variable_value [<option>]...
  2378. # --varname=<word>: The name of the configuration variable whose value is
  2379. # to be completed. Defaults to the previous word on the
  2380. # command line.
  2381. # --cur=<word>: The current value to be completed. Defaults to the current
  2382. # word to be completed.
  2383. __git_complete_config_variable_value ()
  2384. {
  2385. local varname="$prev" cur_="$cur"
  2386. while test $# != 0; do
  2387. case "$1" in
  2388. --varname=*) varname="${1##--varname=}" ;;
  2389. --cur=*) cur_="${1##--cur=}" ;;
  2390. *) return 1 ;;
  2391. esac
  2392. shift
  2393. done
  2394. if [ "${BASH_VERSINFO[0]:-0}" -ge 4 ]; then
  2395. varname="${varname,,}"
  2396. else
  2397. varname="$(echo "$varname" |tr A-Z a-z)"
  2398. fi
  2399. case "$varname" in
  2400. branch.*.remote|branch.*.pushremote)
  2401. __gitcomp_nl "$(__git_remotes)" "" "$cur_"
  2402. return
  2403. ;;
  2404. branch.*.merge)
  2405. __git_complete_refs --cur="$cur_"
  2406. return
  2407. ;;
  2408. branch.*.rebase)
  2409. __gitcomp "false true merges preserve interactive" "" "$cur_"
  2410. return
  2411. ;;
  2412. remote.pushdefault)
  2413. __gitcomp_nl "$(__git_remotes)" "" "$cur_"
  2414. return
  2415. ;;
  2416. remote.*.fetch)
  2417. local remote="${varname#remote.}"
  2418. remote="${remote%.fetch}"
  2419. if [ -z "$cur_" ]; then
  2420. __gitcomp_nl "refs/heads/" "" "" ""
  2421. return
  2422. fi
  2423. __gitcomp_nl "$(__git_refs_remotes "$remote")" "" "$cur_"
  2424. return
  2425. ;;
  2426. remote.*.push)
  2427. local remote="${varname#remote.}"
  2428. remote="${remote%.push}"
  2429. __gitcomp_nl "$(__git for-each-ref \
  2430. --format='%(refname):%(refname)' refs/heads)" "" "$cur_"
  2431. return
  2432. ;;
  2433. pull.twohead|pull.octopus)
  2434. __git_compute_merge_strategies
  2435. __gitcomp "$__git_merge_strategies" "" "$cur_"
  2436. return
  2437. ;;
  2438. color.pager)
  2439. __gitcomp "false true" "" "$cur_"
  2440. return
  2441. ;;
  2442. color.*.*)
  2443. __gitcomp "
  2444. normal black red green yellow blue magenta cyan white
  2445. bold dim ul blink reverse
  2446. " "" "$cur_"
  2447. return
  2448. ;;
  2449. color.*)
  2450. __gitcomp "false true always never auto" "" "$cur_"
  2451. return
  2452. ;;
  2453. diff.submodule)
  2454. __gitcomp "$__git_diff_submodule_formats" "" "$cur_"
  2455. return
  2456. ;;
  2457. help.format)
  2458. __gitcomp "man info web html" "" "$cur_"
  2459. return
  2460. ;;
  2461. log.date)
  2462. __gitcomp "$__git_log_date_formats" "" "$cur_"
  2463. return
  2464. ;;
  2465. sendemail.aliasfiletype)
  2466. __gitcomp "mutt mailrc pine elm gnus" "" "$cur_"
  2467. return
  2468. ;;
  2469. sendemail.confirm)
  2470. __gitcomp "$__git_send_email_confirm_options" "" "$cur_"
  2471. return
  2472. ;;
  2473. sendemail.suppresscc)
  2474. __gitcomp "$__git_send_email_suppresscc_options" "" "$cur_"
  2475. return
  2476. ;;
  2477. sendemail.transferencoding)
  2478. __gitcomp "7bit 8bit quoted-printable base64" "" "$cur_"
  2479. return
  2480. ;;
  2481. *.*)
  2482. return
  2483. ;;
  2484. esac
  2485. }
  2486. # Completes configuration sections, subsections, variable names.
  2487. #
  2488. # Usage: __git_complete_config_variable_name [<option>]...
  2489. # --cur=<word>: The current configuration section/variable name to be
  2490. # completed. Defaults to the current word to be completed.
  2491. # --sfx=<suffix>: A suffix to be appended to each fully completed
  2492. # configuration variable name (but not to sections or
  2493. # subsections) instead of the default space.
  2494. __git_complete_config_variable_name ()
  2495. {
  2496. local cur_="$cur" sfx
  2497. while test $# != 0; do
  2498. case "$1" in
  2499. --cur=*) cur_="${1##--cur=}" ;;
  2500. --sfx=*) sfx="${1##--sfx=}" ;;
  2501. *) return 1 ;;
  2502. esac
  2503. shift
  2504. done
  2505. case "$cur_" in
  2506. branch.*.*)
  2507. local pfx="${cur_%.*}."
  2508. cur_="${cur_##*.}"
  2509. __gitcomp "remote pushRemote merge mergeOptions rebase" "$pfx" "$cur_" "$sfx"
  2510. return
  2511. ;;
  2512. branch.*)
  2513. local pfx="${cur_%.*}."
  2514. cur_="${cur_#*.}"
  2515. __gitcomp_direct "$(__git_heads "$pfx" "$cur_" ".")"
  2516. __gitcomp_nl_append $'autoSetupMerge\nautoSetupRebase\n' "$pfx" "$cur_" "${sfx:- }"
  2517. return
  2518. ;;
  2519. guitool.*.*)
  2520. local pfx="${cur_%.*}."
  2521. cur_="${cur_##*.}"
  2522. __gitcomp "
  2523. argPrompt cmd confirm needsFile noConsole noRescan
  2524. prompt revPrompt revUnmerged title
  2525. " "$pfx" "$cur_" "$sfx"
  2526. return
  2527. ;;
  2528. difftool.*.*)
  2529. local pfx="${cur_%.*}."
  2530. cur_="${cur_##*.}"
  2531. __gitcomp "cmd path" "$pfx" "$cur_" "$sfx"
  2532. return
  2533. ;;
  2534. man.*.*)
  2535. local pfx="${cur_%.*}."
  2536. cur_="${cur_##*.}"
  2537. __gitcomp "cmd path" "$pfx" "$cur_" "$sfx"
  2538. return
  2539. ;;
  2540. mergetool.*.*)
  2541. local pfx="${cur_%.*}."
  2542. cur_="${cur_##*.}"
  2543. __gitcomp "cmd path trustExitCode" "$pfx" "$cur_" "$sfx"
  2544. return
  2545. ;;
  2546. pager.*)
  2547. local pfx="${cur_%.*}."
  2548. cur_="${cur_#*.}"
  2549. __git_compute_all_commands
  2550. __gitcomp_nl "$__git_all_commands" "$pfx" "$cur_" "${sfx:- }"
  2551. return
  2552. ;;
  2553. remote.*.*)
  2554. local pfx="${cur_%.*}."
  2555. cur_="${cur_##*.}"
  2556. __gitcomp "
  2557. url proxy fetch push mirror skipDefaultUpdate
  2558. receivepack uploadpack tagOpt pushurl
  2559. " "$pfx" "$cur_" "$sfx"
  2560. return
  2561. ;;
  2562. remote.*)
  2563. local pfx="${cur_%.*}."
  2564. cur_="${cur_#*.}"
  2565. __gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "."
  2566. __gitcomp_nl_append "pushDefault" "$pfx" "$cur_" "${sfx:- }"
  2567. return
  2568. ;;
  2569. url.*.*)
  2570. local pfx="${cur_%.*}."
  2571. cur_="${cur_##*.}"
  2572. __gitcomp "insteadOf pushInsteadOf" "$pfx" "$cur_" "$sfx"
  2573. return
  2574. ;;
  2575. *.*)
  2576. __git_compute_config_vars
  2577. __gitcomp "$__git_config_vars" "" "$cur_" "$sfx"
  2578. ;;
  2579. *)
  2580. __git_compute_config_vars
  2581. __gitcomp "$(echo "$__git_config_vars" |
  2582. awk -F . '{
  2583. sections[$1] = 1
  2584. }
  2585. END {
  2586. for (s in sections)
  2587. print s "."
  2588. }
  2589. ')" "" "$cur_"
  2590. ;;
  2591. esac
  2592. }
  2593. # Completes '='-separated configuration sections/variable names and values
  2594. # for 'git -c section.name=value'.
  2595. #
  2596. # Usage: __git_complete_config_variable_name_and_value [<option>]...
  2597. # --cur=<word>: The current configuration section/variable name/value to be
  2598. # completed. Defaults to the current word to be completed.
  2599. __git_complete_config_variable_name_and_value ()
  2600. {
  2601. local cur_="$cur"
  2602. while test $# != 0; do
  2603. case "$1" in
  2604. --cur=*) cur_="${1##--cur=}" ;;
  2605. *) return 1 ;;
  2606. esac
  2607. shift
  2608. done
  2609. case "$cur_" in
  2610. *=*)
  2611. __git_complete_config_variable_value \
  2612. --varname="${cur_%%=*}" --cur="${cur_#*=}"
  2613. ;;
  2614. *)
  2615. __git_complete_config_variable_name --cur="$cur_" --sfx='='
  2616. ;;
  2617. esac
  2618. }
  2619. _git_config ()
  2620. {
  2621. case "$prev" in
  2622. --get|--get-all|--unset|--unset-all)
  2623. __gitcomp_nl "$(__git_config_get_set_variables)"
  2624. return
  2625. ;;
  2626. *.*)
  2627. __git_complete_config_variable_value
  2628. return
  2629. ;;
  2630. esac
  2631. case "$cur" in
  2632. --*)
  2633. __gitcomp_builtin config
  2634. ;;
  2635. *)
  2636. __git_complete_config_variable_name
  2637. ;;
  2638. esac
  2639. }
  2640. _git_remote ()
  2641. {
  2642. local subcommands="
  2643. add rename remove set-head set-branches
  2644. get-url set-url show prune update
  2645. "
  2646. local subcommand="$(__git_find_on_cmdline "$subcommands")"
  2647. if [ -z "$subcommand" ]; then
  2648. case "$cur" in
  2649. --*)
  2650. __gitcomp_builtin remote
  2651. ;;
  2652. *)
  2653. __gitcomp "$subcommands"
  2654. ;;
  2655. esac
  2656. return
  2657. fi
  2658. case "$subcommand,$cur" in
  2659. add,--*)
  2660. __gitcomp_builtin remote_add
  2661. ;;
  2662. add,*)
  2663. ;;
  2664. set-head,--*)
  2665. __gitcomp_builtin remote_set-head
  2666. ;;
  2667. set-branches,--*)
  2668. __gitcomp_builtin remote_set-branches
  2669. ;;
  2670. set-head,*|set-branches,*)
  2671. __git_complete_remote_or_refspec
  2672. ;;
  2673. update,--*)
  2674. __gitcomp_builtin remote_update
  2675. ;;
  2676. update,*)
  2677. __gitcomp "$(__git_remotes) $(__git_get_config_variables "remotes")"
  2678. ;;
  2679. set-url,--*)
  2680. __gitcomp_builtin remote_set-url
  2681. ;;
  2682. get-url,--*)
  2683. __gitcomp_builtin remote_get-url
  2684. ;;
  2685. prune,--*)
  2686. __gitcomp_builtin remote_prune
  2687. ;;
  2688. *)
  2689. __gitcomp_nl "$(__git_remotes)"
  2690. ;;
  2691. esac
  2692. }
  2693. _git_replace ()
  2694. {
  2695. case "$cur" in
  2696. --format=*)
  2697. __gitcomp "short medium long" "" "${cur##--format=}"
  2698. return
  2699. ;;
  2700. --*)
  2701. __gitcomp_builtin replace
  2702. return
  2703. ;;
  2704. esac
  2705. __git_complete_refs
  2706. }
  2707. _git_rerere ()
  2708. {
  2709. local subcommands="clear forget diff remaining status gc"
  2710. local subcommand="$(__git_find_on_cmdline "$subcommands")"
  2711. if test -z "$subcommand"
  2712. then
  2713. __gitcomp "$subcommands"
  2714. return
  2715. fi
  2716. }
  2717. _git_reset ()
  2718. {
  2719. __git_has_doubledash && return
  2720. case "$cur" in
  2721. --*)
  2722. __gitcomp_builtin reset
  2723. return
  2724. ;;
  2725. esac
  2726. __git_complete_refs
  2727. }
  2728. _git_restore ()
  2729. {
  2730. case "$prev" in
  2731. -s)
  2732. __git_complete_refs
  2733. return
  2734. ;;
  2735. esac
  2736. case "$cur" in
  2737. --conflict=*)
  2738. __gitcomp "diff3 merge" "" "${cur##--conflict=}"
  2739. ;;
  2740. --source=*)
  2741. __git_complete_refs --cur="${cur##--source=}"
  2742. ;;
  2743. --*)
  2744. __gitcomp_builtin restore
  2745. ;;
  2746. esac
  2747. }
  2748. __git_revert_inprogress_options=$__git_sequencer_inprogress_options
  2749. _git_revert ()
  2750. {
  2751. __git_find_repo_path
  2752. if [ -f "$__git_repo_path"/REVERT_HEAD ]; then
  2753. __gitcomp "$__git_revert_inprogress_options"
  2754. return
  2755. fi
  2756. __git_complete_strategy && return
  2757. case "$cur" in
  2758. --*)
  2759. __gitcomp_builtin revert "" \
  2760. "$__git_revert_inprogress_options"
  2761. return
  2762. ;;
  2763. esac
  2764. __git_complete_refs
  2765. }
  2766. _git_rm ()
  2767. {
  2768. case "$cur" in
  2769. --*)
  2770. __gitcomp_builtin rm
  2771. return
  2772. ;;
  2773. esac
  2774. __git_complete_index_file "--cached"
  2775. }
  2776. _git_shortlog ()
  2777. {
  2778. __git_has_doubledash && return
  2779. case "$cur" in
  2780. --*)
  2781. __gitcomp "
  2782. $__git_log_common_options
  2783. $__git_log_shortlog_options
  2784. --numbered --summary --email
  2785. "
  2786. return
  2787. ;;
  2788. esac
  2789. __git_complete_revlist
  2790. }
  2791. _git_show ()
  2792. {
  2793. __git_has_doubledash && return
  2794. case "$cur" in
  2795. --pretty=*|--format=*)
  2796. __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
  2797. " "" "${cur#*=}"
  2798. return
  2799. ;;
  2800. --diff-algorithm=*)
  2801. __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
  2802. return
  2803. ;;
  2804. --submodule=*)
  2805. __gitcomp "$__git_diff_submodule_formats" "" "${cur##--submodule=}"
  2806. return
  2807. ;;
  2808. --color-moved=*)
  2809. __gitcomp "$__git_color_moved_opts" "" "${cur##--color-moved=}"
  2810. return
  2811. ;;
  2812. --color-moved-ws=*)
  2813. __gitcomp "$__git_color_moved_ws_opts" "" "${cur##--color-moved-ws=}"
  2814. return
  2815. ;;
  2816. --*)
  2817. __gitcomp "--pretty= --format= --abbrev-commit --no-abbrev-commit
  2818. --oneline --show-signature --patch
  2819. --expand-tabs --expand-tabs= --no-expand-tabs
  2820. $__git_diff_common_options
  2821. "
  2822. return
  2823. ;;
  2824. esac
  2825. __git_complete_revlist_file
  2826. }
  2827. _git_show_branch ()
  2828. {
  2829. case "$cur" in
  2830. --*)
  2831. __gitcomp_builtin show-branch
  2832. return
  2833. ;;
  2834. esac
  2835. __git_complete_revlist
  2836. }
  2837. _git_sparse_checkout ()
  2838. {
  2839. local subcommands="list init set disable"
  2840. local subcommand="$(__git_find_on_cmdline "$subcommands")"
  2841. if [ -z "$subcommand" ]; then
  2842. __gitcomp "$subcommands"
  2843. return
  2844. fi
  2845. case "$subcommand,$cur" in
  2846. init,--*)
  2847. __gitcomp "--cone"
  2848. ;;
  2849. set,--*)
  2850. __gitcomp "--stdin"
  2851. ;;
  2852. *)
  2853. ;;
  2854. esac
  2855. }
  2856. _git_stash ()
  2857. {
  2858. local save_opts='--all --keep-index --no-keep-index --quiet --patch --include-untracked'
  2859. local subcommands='push list show apply clear drop pop create branch'
  2860. local subcommand="$(__git_find_on_cmdline "$subcommands save")"
  2861. if [ -z "$subcommand" -a -n "$(__git_find_on_cmdline "-p")" ]; then
  2862. subcommand="push"
  2863. fi
  2864. if [ -z "$subcommand" ]; then
  2865. case "$cur" in
  2866. --*)
  2867. __gitcomp "$save_opts"
  2868. ;;
  2869. sa*)
  2870. if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then
  2871. __gitcomp "save"
  2872. fi
  2873. ;;
  2874. *)
  2875. if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then
  2876. __gitcomp "$subcommands"
  2877. fi
  2878. ;;
  2879. esac
  2880. else
  2881. case "$subcommand,$cur" in
  2882. push,--*)
  2883. __gitcomp "$save_opts --message"
  2884. ;;
  2885. save,--*)
  2886. __gitcomp "$save_opts"
  2887. ;;
  2888. apply,--*|pop,--*)
  2889. __gitcomp "--index --quiet"
  2890. ;;
  2891. drop,--*)
  2892. __gitcomp "--quiet"
  2893. ;;
  2894. list,--*)
  2895. __gitcomp "--name-status --oneline --patch-with-stat"
  2896. ;;
  2897. show,--*|branch,--*)
  2898. ;;
  2899. branch,*)
  2900. if [ $cword -eq 3 ]; then
  2901. __git_complete_refs
  2902. else
  2903. __gitcomp_nl "$(__git stash list \
  2904. | sed -n -e 's/:.*//p')"
  2905. fi
  2906. ;;
  2907. show,*|apply,*|drop,*|pop,*)
  2908. __gitcomp_nl "$(__git stash list \
  2909. | sed -n -e 's/:.*//p')"
  2910. ;;
  2911. *)
  2912. ;;
  2913. esac
  2914. fi
  2915. }
  2916. _git_submodule ()
  2917. {
  2918. __git_has_doubledash && return
  2919. local subcommands="add status init deinit update set-branch set-url summary foreach sync absorbgitdirs"
  2920. local subcommand="$(__git_find_on_cmdline "$subcommands")"
  2921. if [ -z "$subcommand" ]; then
  2922. case "$cur" in
  2923. --*)
  2924. __gitcomp "--quiet"
  2925. ;;
  2926. *)
  2927. __gitcomp "$subcommands"
  2928. ;;
  2929. esac
  2930. return
  2931. fi
  2932. case "$subcommand,$cur" in
  2933. add,--*)
  2934. __gitcomp "--branch --force --name --reference --depth"
  2935. ;;
  2936. status,--*)
  2937. __gitcomp "--cached --recursive"
  2938. ;;
  2939. deinit,--*)
  2940. __gitcomp "--force --all"
  2941. ;;
  2942. update,--*)
  2943. __gitcomp "
  2944. --init --remote --no-fetch
  2945. --recommend-shallow --no-recommend-shallow
  2946. --force --rebase --merge --reference --depth --recursive --jobs
  2947. "
  2948. ;;
  2949. set-branch,--*)
  2950. __gitcomp "--default --branch"
  2951. ;;
  2952. summary,--*)
  2953. __gitcomp "--cached --files --summary-limit"
  2954. ;;
  2955. foreach,--*|sync,--*)
  2956. __gitcomp "--recursive"
  2957. ;;
  2958. *)
  2959. ;;
  2960. esac
  2961. }
  2962. _git_svn ()
  2963. {
  2964. local subcommands="
  2965. init fetch clone rebase dcommit log find-rev
  2966. set-tree commit-diff info create-ignore propget
  2967. proplist show-ignore show-externals branch tag blame
  2968. migrate mkdirs reset gc
  2969. "
  2970. local subcommand="$(__git_find_on_cmdline "$subcommands")"
  2971. if [ -z "$subcommand" ]; then
  2972. __gitcomp "$subcommands"
  2973. else
  2974. local remote_opts="--username= --config-dir= --no-auth-cache"
  2975. local fc_opts="
  2976. --follow-parent --authors-file= --repack=
  2977. --no-metadata --use-svm-props --use-svnsync-props
  2978. --log-window-size= --no-checkout --quiet
  2979. --repack-flags --use-log-author --localtime
  2980. --add-author-from
  2981. --recursive
  2982. --ignore-paths= --include-paths= $remote_opts
  2983. "
  2984. local init_opts="
  2985. --template= --shared= --trunk= --tags=
  2986. --branches= --stdlayout --minimize-url
  2987. --no-metadata --use-svm-props --use-svnsync-props
  2988. --rewrite-root= --prefix= $remote_opts
  2989. "
  2990. local cmt_opts="
  2991. --edit --rmdir --find-copies-harder --copy-similarity=
  2992. "
  2993. case "$subcommand,$cur" in
  2994. fetch,--*)
  2995. __gitcomp "--revision= --fetch-all $fc_opts"
  2996. ;;
  2997. clone,--*)
  2998. __gitcomp "--revision= $fc_opts $init_opts"
  2999. ;;
  3000. init,--*)
  3001. __gitcomp "$init_opts"
  3002. ;;
  3003. dcommit,--*)
  3004. __gitcomp "
  3005. --merge --strategy= --verbose --dry-run
  3006. --fetch-all --no-rebase --commit-url
  3007. --revision --interactive $cmt_opts $fc_opts
  3008. "
  3009. ;;
  3010. set-tree,--*)
  3011. __gitcomp "--stdin $cmt_opts $fc_opts"
  3012. ;;
  3013. create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\
  3014. show-externals,--*|mkdirs,--*)
  3015. __gitcomp "--revision="
  3016. ;;
  3017. log,--*)
  3018. __gitcomp "
  3019. --limit= --revision= --verbose --incremental
  3020. --oneline --show-commit --non-recursive
  3021. --authors-file= --color
  3022. "
  3023. ;;
  3024. rebase,--*)
  3025. __gitcomp "
  3026. --merge --verbose --strategy= --local
  3027. --fetch-all --dry-run $fc_opts
  3028. "
  3029. ;;
  3030. commit-diff,--*)
  3031. __gitcomp "--message= --file= --revision= $cmt_opts"
  3032. ;;
  3033. info,--*)
  3034. __gitcomp "--url"
  3035. ;;
  3036. branch,--*)
  3037. __gitcomp "--dry-run --message --tag"
  3038. ;;
  3039. tag,--*)
  3040. __gitcomp "--dry-run --message"
  3041. ;;
  3042. blame,--*)
  3043. __gitcomp "--git-format"
  3044. ;;
  3045. migrate,--*)
  3046. __gitcomp "
  3047. --config-dir= --ignore-paths= --minimize
  3048. --no-auth-cache --username=
  3049. "
  3050. ;;
  3051. reset,--*)
  3052. __gitcomp "--revision= --parent"
  3053. ;;
  3054. *)
  3055. ;;
  3056. esac
  3057. fi
  3058. }
  3059. _git_tag ()
  3060. {
  3061. local i c=1 f=0
  3062. while [ $c -lt $cword ]; do
  3063. i="${words[c]}"
  3064. case "$i" in
  3065. -d|--delete|-v|--verify)
  3066. __gitcomp_direct "$(__git_tags "" "$cur" " ")"
  3067. return
  3068. ;;
  3069. -f)
  3070. f=1
  3071. ;;
  3072. esac
  3073. ((c++))
  3074. done
  3075. case "$prev" in
  3076. -m|-F)
  3077. ;;
  3078. -*|tag)
  3079. if [ $f = 1 ]; then
  3080. __gitcomp_direct "$(__git_tags "" "$cur" " ")"
  3081. fi
  3082. ;;
  3083. *)
  3084. __git_complete_refs
  3085. ;;
  3086. esac
  3087. case "$cur" in
  3088. --*)
  3089. __gitcomp_builtin tag
  3090. ;;
  3091. esac
  3092. }
  3093. _git_whatchanged ()
  3094. {
  3095. _git_log
  3096. }
  3097. __git_complete_worktree_paths ()
  3098. {
  3099. local IFS=$'\n'
  3100. __gitcomp_nl "$(git worktree list --porcelain |
  3101. # Skip the first entry: it's the path of the main worktree,
  3102. # which can't be moved, removed, locked, etc.
  3103. sed -n -e '2,$ s/^worktree //p')"
  3104. }
  3105. _git_worktree ()
  3106. {
  3107. local subcommands="add list lock move prune remove unlock"
  3108. local subcommand subcommand_idx
  3109. subcommand="$(__git_find_on_cmdline --show-idx "$subcommands")"
  3110. subcommand_idx="${subcommand% *}"
  3111. subcommand="${subcommand#* }"
  3112. case "$subcommand,$cur" in
  3113. ,*)
  3114. __gitcomp "$subcommands"
  3115. ;;
  3116. *,--*)
  3117. __gitcomp_builtin worktree_$subcommand
  3118. ;;
  3119. add,*) # usage: git worktree add [<options>] <path> [<commit-ish>]
  3120. # Here we are not completing an --option, it's either the
  3121. # path or a ref.
  3122. case "$prev" in
  3123. -b|-B) # Complete refs for branch to be created/reset.
  3124. __git_complete_refs
  3125. ;;
  3126. -*) # The previous word is an -o|--option without an
  3127. # unstuck argument: have to complete the path for
  3128. # the new worktree, so don't list anything, but let
  3129. # Bash fall back to filename completion.
  3130. ;;
  3131. *) # The previous word is not an --option, so it must
  3132. # be either the 'add' subcommand, the unstuck
  3133. # argument of an option (e.g. branch for -b|-B), or
  3134. # the path for the new worktree.
  3135. if [ $cword -eq $((subcommand_idx+1)) ]; then
  3136. # Right after the 'add' subcommand: have to
  3137. # complete the path, so fall back to Bash
  3138. # filename completion.
  3139. :
  3140. else
  3141. case "${words[cword-2]}" in
  3142. -b|-B) # After '-b <branch>': have to
  3143. # complete the path, so fall back
  3144. # to Bash filename completion.
  3145. ;;
  3146. *) # After the path: have to complete
  3147. # the ref to be checked out.
  3148. __git_complete_refs
  3149. ;;
  3150. esac
  3151. fi
  3152. ;;
  3153. esac
  3154. ;;
  3155. lock,*|remove,*|unlock,*)
  3156. __git_complete_worktree_paths
  3157. ;;
  3158. move,*)
  3159. if [ $cword -eq $((subcommand_idx+1)) ]; then
  3160. # The first parameter must be an existing working
  3161. # tree to be moved.
  3162. __git_complete_worktree_paths
  3163. else
  3164. # The second parameter is the destination: it could
  3165. # be any path, so don't list anything, but let Bash
  3166. # fall back to filename completion.
  3167. :
  3168. fi
  3169. ;;
  3170. esac
  3171. }
  3172. __git_complete_common () {
  3173. local command="$1"
  3174. case "$cur" in
  3175. --*)
  3176. __gitcomp_builtin "$command"
  3177. ;;
  3178. esac
  3179. }
  3180. __git_cmds_with_parseopt_helper=
  3181. __git_support_parseopt_helper () {
  3182. test -n "$__git_cmds_with_parseopt_helper" ||
  3183. __git_cmds_with_parseopt_helper="$(__git --list-cmds=parseopt)"
  3184. case " $__git_cmds_with_parseopt_helper " in
  3185. *" $1 "*)
  3186. return 0
  3187. ;;
  3188. *)
  3189. return 1
  3190. ;;
  3191. esac
  3192. }
  3193. __git_complete_command () {
  3194. local command="$1"
  3195. local completion_func="_git_${command//-/_}"
  3196. if ! declare -f $completion_func >/dev/null 2>/dev/null &&
  3197. declare -f _completion_loader >/dev/null 2>/dev/null
  3198. then
  3199. _completion_loader "git-$command"
  3200. fi
  3201. if declare -f $completion_func >/dev/null 2>/dev/null
  3202. then
  3203. $completion_func
  3204. return 0
  3205. elif __git_support_parseopt_helper "$command"
  3206. then
  3207. __git_complete_common "$command"
  3208. return 0
  3209. else
  3210. return 1
  3211. fi
  3212. }
  3213. __git_main ()
  3214. {
  3215. local i c=1 command __git_dir __git_repo_path
  3216. local __git_C_args C_args_count=0
  3217. while [ $c -lt $cword ]; do
  3218. i="${words[c]}"
  3219. case "$i" in
  3220. --git-dir=*) __git_dir="${i#--git-dir=}" ;;
  3221. --git-dir) ((c++)) ; __git_dir="${words[c]}" ;;
  3222. --bare) __git_dir="." ;;
  3223. --help) command="help"; break ;;
  3224. -c|--work-tree|--namespace) ((c++)) ;;
  3225. -C) __git_C_args[C_args_count++]=-C
  3226. ((c++))
  3227. __git_C_args[C_args_count++]="${words[c]}"
  3228. ;;
  3229. -*) ;;
  3230. *) command="$i"; break ;;
  3231. esac
  3232. ((c++))
  3233. done
  3234. if [ -z "${command-}" ]; then
  3235. case "$prev" in
  3236. --git-dir|-C|--work-tree)
  3237. # these need a path argument, let's fall back to
  3238. # Bash filename completion
  3239. return
  3240. ;;
  3241. -c)
  3242. __git_complete_config_variable_name_and_value
  3243. return
  3244. ;;
  3245. --namespace)
  3246. # we don't support completing these options' arguments
  3247. return
  3248. ;;
  3249. esac
  3250. case "$cur" in
  3251. --*) __gitcomp "
  3252. --paginate
  3253. --no-pager
  3254. --git-dir=
  3255. --bare
  3256. --version
  3257. --exec-path
  3258. --exec-path=
  3259. --html-path
  3260. --man-path
  3261. --info-path
  3262. --work-tree=
  3263. --namespace=
  3264. --no-replace-objects
  3265. --help
  3266. "
  3267. ;;
  3268. *)
  3269. if test -n "${GIT_TESTING_PORCELAIN_COMMAND_LIST-}"
  3270. then
  3271. __gitcomp "$GIT_TESTING_PORCELAIN_COMMAND_LIST"
  3272. else
  3273. __gitcomp "$(__git --list-cmds=list-mainporcelain,others,nohelpers,alias,list-complete,config)"
  3274. fi
  3275. ;;
  3276. esac
  3277. return
  3278. fi
  3279. __git_complete_command "$command" && return
  3280. local expansion=$(__git_aliased_command "$command")
  3281. if [ -n "$expansion" ]; then
  3282. words[1]=$expansion
  3283. __git_complete_command "$expansion"
  3284. fi
  3285. }
  3286. __gitk_main ()
  3287. {
  3288. __git_has_doubledash && return
  3289. local __git_repo_path
  3290. __git_find_repo_path
  3291. local merge=""
  3292. if [ -f "$__git_repo_path/MERGE_HEAD" ]; then
  3293. merge="--merge"
  3294. fi
  3295. case "$cur" in
  3296. --*)
  3297. __gitcomp "
  3298. $__git_log_common_options
  3299. $__git_log_gitk_options
  3300. $merge
  3301. "
  3302. return
  3303. ;;
  3304. esac
  3305. __git_complete_revlist
  3306. }
  3307. if [[ -n ${ZSH_VERSION-} && -z ${GIT_SOURCING_ZSH_COMPLETION-} ]]; then
  3308. echo "ERROR: this script is obsolete, please see git-completion.zsh" 1>&2
  3309. return
  3310. fi
  3311. __git_func_wrap ()
  3312. {
  3313. local cur words cword prev
  3314. _get_comp_words_by_ref -n =: cur words cword prev
  3315. $1
  3316. }
  3317. # Setup completion for certain functions defined above by setting common
  3318. # variables and workarounds.
  3319. # This is NOT a public function; use at your own risk.
  3320. __git_complete ()
  3321. {
  3322. local wrapper="__git_wrap${2}"
  3323. eval "$wrapper () { __git_func_wrap $2 ; }"
  3324. complete -o bashdefault -o default -o nospace -F $wrapper $1 2>/dev/null \
  3325. || complete -o default -o nospace -F $wrapper $1
  3326. }
  3327. if ! git --list-cmds=main >/dev/null 2>&1; then
  3328. declare -A __git_cmds
  3329. __git_cmds[list-complete]="apply blame cherry config difftool fsck help instaweb mergetool prune reflog remote repack replace request-pull send-email show-branch stage whatchanged"
  3330. __git_cmds[list-guide]="attributes cli core-tutorial credentials cvs-migration diffcore everyday faq glossary hooks ignore modules namespaces remote-helpers repository-layout revisions submodules tutorial-2 tutorial workflows"
  3331. __git_cmds[list-mainporcelain]="add am archive bisect branch bundle checkout cherry-pick citool clean clone commit describe diff fetch format-patch gc grep gui init gitk log maintenance merge mv notes pull push range-diff rebase reset restore revert rm shortlog show sparse-checkout stash status submodule switch tag worktree"
  3332. __git_cmds[main]="add add--interactive am annotate apply archimport archive bisect bisect--helper blame branch bugreport bundle cat-file check-attr check-ignore check-mailmap check-ref-format checkout checkout-index cherry cherry-pick citool clean clone column commit commit-graph commit-tree config count-objects credential credential-cache credential-cache--daemon credential-gnome-keyring credential-libsecret credential-store cvsexportcommit cvsimport cvsserver daemon describe diff diff-files diff-index diff-tree difftool difftool--helper env--helper fast-export fast-import fetch fetch-pack filter-branch fmt-merge-msg for-each-ref format-patch fsck fsck-objects gc get-tar-commit-id grep gui gui--askpass hash-object help http-backend http-fetch http-push imap-send index-pack init init-db instaweb interpret-trailers log ls-files ls-remote ls-tree mailinfo mailsplit maintenance merge merge-base merge-file merge-index merge-octopus merge-one-file merge-ours merge-recursive merge-recursive-ours merge-recursive-theirs merge-resolve merge-subtree merge-tree mergetool mktag mktree multi-pack-index mv mw name-rev notes p4 pack-objects pack-redundant pack-refs patch-id pickaxe prune prune-packed pull push quiltimport range-diff read-tree rebase rebase--interactive receive-pack reflog remote remote-ext remote-fd remote-ftp remote-ftps remote-http remote-https remote-mediawiki repack replace request-pull rerere reset restore rev-list rev-parse revert rm send-email send-pack sh-i18n--envsubst shell shortlog show show-branch show-index show-ref sparse-checkout stage stash status stripspace submodule submodule--helper subtree svn switch symbolic-ref tag unpack-file unpack-objects update-index update-ref update-server-info upload-archive upload-archive--writer upload-pack var verify-commit verify-pack verify-tag version web--browse whatchanged worktree write-tree"
  3333. __git_cmds[others]="compare reintegrate related remote-hg remote-sync send-series smartlist"
  3334. __git_cmds[parseopt]="add am apply archive bisect--helper blame branch bugreport cat-file check-attr check-ignore check-mailmap checkout checkout-index cherry cherry-pick clean clone column commit commit-graph config count-objects credential-cache credential-cache--daemon credential-store describe difftool env--helper fast-export fetch fmt-merge-msg for-each-ref format-patch fsck fsck-objects gc grep hash-object help init init-db interpret-trailers log ls-files ls-remote ls-tree merge merge-base merge-file mktree multi-pack-index mv name-rev notes pack-objects pack-refs pickaxe prune prune-packed pull push range-diff read-tree rebase rebase--interactive receive-pack reflog remote repack replace rerere reset restore revert rm send-pack shortlog show show-branch show-index show-ref sparse-checkout stage stash status stripspace switch symbolic-ref tag update-index update-ref update-server-info upload-pack verify-commit verify-pack verify-tag version whatchanged write-tree "
  3335. # Override __git
  3336. __git ()
  3337. {
  3338. case "$1" in
  3339. --list-cmds=*)
  3340. while read -r -d ',' x; do
  3341. case "$x" in
  3342. nohelpers)
  3343. ;;
  3344. alias)
  3345. ;;
  3346. config)
  3347. ;;
  3348. *)
  3349. echo ${__git_cmds[$x]}
  3350. ;;
  3351. esac
  3352. done <<< "${1##--list-cmds=},"
  3353. return
  3354. ;;
  3355. esac
  3356. git ${__git_C_args:+"${__git_C_args[@]}"} \
  3357. ${__git_dir:+--git-dir="$__git_dir"} "$@" 2>/dev/null
  3358. }
  3359. fi
  3360. __git_complete git __git_main
  3361. __git_complete gitk __gitk_main
  3362. # The following are necessary only for Cygwin, and only are needed
  3363. # when the user has tab-completed the executable name and consequently
  3364. # included the '.exe' suffix.
  3365. #
  3366. if [ "$OSTYPE" = cygwin ]; then
  3367. __git_complete git.exe __git_main
  3368. fi