git-completion.bash 118 KB

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