git-completion.bash 116 KB

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