You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

954 lines
41 KiB

  1. # -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
  2. # Copyright (c) 2018 Sebastian Gniazdowski
  3. #
  4. # Chroma function for command `git'. It colorizes the part of command
  5. # line that holds `git' invocation.
  6. (( FAST_HIGHLIGHT[-git.ch-chroma-def] )) && return 1
  7. FAST_HIGHLIGHT[-git.ch-chroma-def]=1
  8. typeset -gA fsh__git__chroma__def
  9. fsh__git__chroma__def=(
  10. ##
  11. ## No subcommand
  12. ##
  13. ## {{{
  14. subcmd:NULL "NULL_0_opt"
  15. NULL_0_opt "(-C|--exec-path=|--git-dir=|--work-tree=|--namespace=|--super-prefix=)
  16. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action
  17. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-ARG-action
  18. || -c
  19. <<>> __style=\${FAST_THEME_NAME}single-hyphen-option // NO-OP
  20. <<>> __style=\${FAST_THEME_NAME}optarg-string // NO-OP
  21. || (--version|--help|--html-path|--man-path|--info-path|-p|--paginate|
  22. -P|--no-pager|--no-replace-objects|--bare)
  23. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action"
  24. "subcommands" "::→chroma/-git-get-subcommands" # run a function (the :: causes this) and use `reply'
  25. #"subcommands" "(fetch|pull)" # run a function (the :: causes this) and use `reply'
  26. "subcmd-hook" "→chroma/-git-check-if-alias"
  27. "subcommands-blacklist" "mv,other"
  28. ## }}}
  29. ##
  30. ## `FETCH'
  31. ##
  32. ## {{{
  33. subcmd:fetch "FETCH_MULTIPLE_0_opt^ // FETCH_ALL_0_opt^ // FETCH_0_opt //
  34. REMOTE_GR_1_arg // REF_#_arg // NO_MATCH_#_opt"
  35. # Special options (^ - has directives, currently - an :add and :del directive)
  36. "FETCH_MULTIPLE_0_opt^" "
  37. --multiple
  38. <<>> __style=\${FAST_THEME_NAME}double-hyphen-option // NO-OP
  39. || --multiple:add
  40. <<>> REMOTE_GR_#_arg
  41. || --multiple:del
  42. <<>> REMOTE_GR_1_arg // REF_#_arg" # when --multiple is passed, then
  43. # there is no refspec argument, only remotes-ids
  44. # follow unlimited # of them, hence the # in the
  45. # REMOTE_GR_#_arg
  46. # Special options (^ - has directives - an :del-directive)
  47. "FETCH_ALL_0_opt^" "
  48. --all
  49. <<>> __style=\${FAST_THEME_NAME}double-hyphen-option // NO-OP
  50. || --all:del
  51. <<>> REMOTE_GR_1_arg // REF_#_arg" # --all can be only followed by options
  52. # FETCH_0_opt. FETCH-options (FETCH is an identifier) at position 0 ->
  53. # -> before any argument
  54. FETCH_0_opt "
  55. (--depth=|--deepen=|--shallow-exclude=|--shallow-since=|--receive-pack=|
  56. --refmap=|--recurse-submodules=|-j|--jobs=|--submodule-prefix=|
  57. --recurse-submodules-default=|-o|--server-option=|--upload-pack|
  58. --negotiation-tip=)
  59. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action
  60. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-ARG-action
  61. || (--help|--all|-a|--append|--unshallow|--update-shallow|--dry-run|-f|--force|
  62. -k|--keep|--multiple|-p|--prune|-n|--no-tags|-t|--tags|--no-recurse-submodules|
  63. -u|--update-head-ok|-q|--quiet|-v|--verbose|--progress|
  64. -4|--ipv4|-6|--ipv6)
  65. <<>> __style=\${FAST_THEME_NAME}single-hyphen-option // NO-OP"
  66. # Above: note the two <<>>-separated blocks for options that have
  67. # some arguments – the second pair of action/handler is being
  68. # run when an option argument is occurred (first one: the option
  69. # itself). If there is only one <<>>-separated block, then the option
  70. # is set to be argument-less. The argument is a) -o/--option argument
  71. # and b) -o/--option=argument.
  72. REMOTE_GR_1_arg "NO-OP // ::→chroma/-git-verify-remote-or-group" # This definition is generic, reused later
  73. "REF_#_arg" "NO-OP // ::→chroma/-git-verify-ref" # This too
  74. "REMOTE_GR_#_arg" "NO-OP // ::→chroma/-git-verify-remote-or-group" # and this too
  75. # The hash `#' above denotes: an argument at any position
  76. # It will nicely match any following (above the first explicitly
  77. # numbered ones) arguments passed when using --multiple
  78. # A generic action
  79. NO_MATCH_\#_opt "* <<>> __style=\${FAST_THEME_NAME}incorrect-subtle // NO-OP"
  80. NO_MATCH_\#_arg "__style=\${FAST_THEME_NAME}incorrect-subtle // NO-OP"
  81. ## }}}
  82. ##
  83. ## PUSH
  84. ##
  85. ## {{{
  86. subcmd:push "PUSH_0_opt // REMOTE_1_arg // REF_#_arg // NO_MATCH_#_opt"
  87. PUSH_0_opt "
  88. (--receive-pack=|--exec=|--repo=|--push-option=|--signed=|
  89. --force-with-lease=|--signed=|--recurse-submodules=)
  90. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action
  91. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-ARG-action
  92. || (--help|--all|--mirror|--tags|--follow-tags|--atomic|-n|--dry-run|
  93. --porcelain|--delete|--tags|--follow-tags|--signed|--no-signed|
  94. --atomic|--no-atomic|-o|--push-option|--force-with-lease|
  95. --no-force-with-lease|-f|--force|-u|--set-upstream|--thin|
  96. --no-thin|-q|--quiet|-v|--verbose|--progress|--no-recurse-submodules|
  97. --verify|--no-verify|-4|--ipv4|-6|--ipv6)
  98. <<>> __style=\${FAST_THEME_NAME}single-hyphen-option // NO-OP"
  99. REMOTE_1_arg "NO-OP // ::→chroma/-git-verify-remote" # This definition is generic, reused later
  100. ### }}}
  101. ##
  102. ## PULL
  103. ##
  104. ## {{{
  105. subcmd:pull "PULL_0_opt // REMOTE_1_arg // REF_#_arg // NO_MATCH_#_opt"
  106. PULL_0_opt "
  107. (--recurse-submodules=|-S|--gpg-sign=|--log=|-s|--strategy=|-X|
  108. --strategy-option=|--rebase=|--depth=|--deepen=|--shallow-exclude=|
  109. --shallow-since=|--negotiation-tip|--upload-pack|-o|--server-option=|
  110. --no-recurse-submodules=)
  111. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action
  112. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-ARG-action
  113. || (--help|-q|--quiet|-v|--verbose|--progress|--no-recurse-submodules|
  114. --commit|--no-commit|--edit|--no-edit|--ff|--no-ff|--ff-only|
  115. --log|--no-log|--signoff|--no-signoff|--stat|-n|--no-stat|--squash|
  116. --no-squash|--verify-signatures|--no-verify-signatures|--summary|
  117. --no-summary|--allow-unrelated-histories|-r|--rebase|--no-rebase|
  118. --autostash|--no-autostash|--all|-a|--append|--unshallow|
  119. --update-shallow|-f|--force|-k|--keep|--no-tags|-u|--update-head-ok|
  120. --progress|-4|--ipv4|-6|--ipv6|--recurse-submodules)
  121. <<>> __style=\${FAST_THEME_NAME}single-hyphen-option // NO-OP"
  122. ## }}}
  123. ##
  124. ## COMMIT
  125. ##
  126. ## {{{
  127. subcmd:commit "COMMIT_#_opt // FILE_#_arg // NO_MATCH_#_opt"
  128. "COMMIT_#_opt" "
  129. (-m|--message=|-am)
  130. <<>> NO-OP // ::→chroma/-git-commit-msg-opt-action
  131. <<>> NO-OP // ::→chroma/-git-commit-msg-opt-ARG-action
  132. || (--help|-a|--all|-p|--patch|--reset-author|--short|--branch|
  133. --porcelain|--long|-z|--null|-s|--signoff|-n|--no-verify|
  134. --allow-empty|--allow-empty-message|-e|--edit|--no-edit|
  135. --amend|--no-post-rewrite|-i|--include|-o|--only|--untracked-files|
  136. -v|--verbose|-q|--quiet|--dry-run|--status|--no-status|--no-gpg-sign)
  137. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action
  138. || (-C|--reuse-message=|-c|--reedit-message=|--fixup=|--squash=|
  139. -F|--file=|--author=|--date=|-t|--template=|--cleanup=|
  140. -u|--untracked-files=|-S|--gpg-sign=)
  141. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action
  142. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-ARG-action"
  143. # A generic action
  144. "FILE_#_arg" "NO-OP // ::→chroma/-git-verify-file"
  145. ## }}}
  146. ##
  147. ## MERGE
  148. ##
  149. ## {{{
  150. subcmd:merge "MERGE_0_opt // COMMIT_#_arg"
  151. MERGE_0_opt
  152. "(-m)
  153. <<>> NO-OP // ::→chroma/-git-commit-msg-opt-action
  154. <<>> NO-OP // ::→chroma/-git-commit-msg-opt-ARG-action
  155. (-S|--gpg-sign=|--log=|-e|--strategy=|-X|--strategy-option=|-F|
  156. --file)
  157. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action
  158. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-ARG-action
  159. || (--help|--commit|--no-commit|-e|--edit|--no-edit|--ff|--no-ff|--ff-only|
  160. --log|--no-log|--signoff|--no-signoff|-n|--stat|--no-stat|--squash|
  161. --no-squash|--verify-signatures|--no-verify-signatures|--summary|
  162. --no-summary|-q|--quiet|-v|--verbose|--progress|--no-progress|
  163. --allow-unrelated-histories|--rerere-autoupdate|--no-rerere-autoupdate|
  164. --abort|--continue)
  165. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action"
  166. COMMIT_\#_arg "NO-OP // ::→chroma/-git-verify-commit"
  167. ## }}}
  168. ##
  169. ## RESET
  170. ##
  171. ## {{{
  172. subcmd:reset "RESET_0_opt^ // RESET_0_opt // RESET_#_arg // NO_MATCH_#_opt"
  173. "RESET_0_opt^" "
  174. (--soft|--mixed|--hard|--merge|--keep)
  175. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action
  176. || (--soft|--mixed|--hard|--merge|--keep):del
  177. <<>> RESET_0_opt // RESET_#_arg
  178. || (--soft|--mixed|--hard|--merge|--keep):add
  179. <<>> RESET_1_arg // NO_MATCH_#_arg
  180. "
  181. RESET_0_opt "
  182. (-q|-p|--patch)
  183. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action"
  184. RESET_1_arg "NO-OP // ::→chroma/-git-verify-commit"
  185. "RESET_#_arg" "NO-OP // ::→chroma/-git-RESET-verify-commit-or-file"
  186. ## }}}
  187. ##
  188. ## REVERT
  189. ##
  190. ## {{{
  191. subcmd:revert "REVERT_SEQUENCER_0_opt^ // REVERT_0_opt // REVERT_#_arg // NO_MATCH_#_opt"
  192. REVERT_0_opt "
  193. (-m|--mainline|-S|--gpg-sign=|--strategy=|-X|--strategy-option=)
  194. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action
  195. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-ARG-action
  196. || (-e|--edit|--no-edit|-n|--no-commit|-s|--signoff)
  197. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action"
  198. "REVERT_SEQUENCER_0_opt^" "
  199. (--continue|--quit|--abort)
  200. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action
  201. || (--continue|--quit|--abort):del
  202. <<>> REVERT_0_opt // REVERT_#_arg
  203. || (--continue|--quit|--abort):add
  204. <<>> NO_MATCH_#_arg"
  205. "REVERT_#_arg" "NO-OP // ::→chroma/-git-verify-commit"
  206. ## }}}
  207. ##
  208. ## DIFF
  209. ##
  210. ## TODO: When a second argument is also a path and it points to a directory, then
  211. ## git appends the previous file name to it – good to implement this too
  212. ## {{{
  213. subcmd:diff "DIFF_NO_INDEX_0_opt^ // DIFF_0_opt // COMMIT_FILE_DIR_#_arg // NO_MATCH_#_opt"
  214. "DIFF_NO_INDEX_0_opt^" "
  215. --no-index
  216. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action
  217. || --no-index:del
  218. <<>> COMMIT_FILE_DIR_#_arg
  219. || --no-index:add
  220. <<>> FILE_1_arg // FILE_2_arg // NO_MATCH_#_arg"
  221. DIFF_0_opt "
  222. (-U|--unified=|--anchored=|--diff-algorithm=|--stat=|--dirstat|
  223. --submodule=|--color=|--color-moved=|--color-moved-ws=|--word-diff=|
  224. --word-diff-regex=|--color-words=|--ws-error-highlight=|--abbrev=|
  225. -B|--break-rewrites=|-M|--find-renames=|-C|--find-copies=|-l|
  226. --diff-filter=|-S|-G|--find-object=|--relative=|-O|--relative=|
  227. --inter-hunk-context=|--ignore-submodules=|--src-prefix=|--dst-prefix=|
  228. --line-prefix=)
  229. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action
  230. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-ARG-action
  231. || (-p|--patch|-u|-s|--no-patch|--raw|--patch-with-raw|--indent-heuristic|
  232. --no-indent-heuristic|--minimal|--patience|--histogram|--stat|
  233. --compact-summary|--numstat|--shortstat|--dirstat|--summary|
  234. --patch-with-stat|-z|--name-only|--name-status|--submodule|--no-color|
  235. --color-moved|--word-diff|--color-words|--no-renames|--check|
  236. --full-index|--binary|--abbrev|--break-rewrites|--find-renames|
  237. --find-copies|--find-copies-harder|-D|--pickaxe-all|--pickaxe-regex|
  238. --irreversible-delete|-R|--relative|-a|--text|--ignore-cr-at-eol|
  239. --ignore-space-at-eol|-b|--ignore-space-change|-w|--ignore-all-space|
  240. --ignore-blank-lines|-W|--function-context|--exit-code|--quiet|
  241. --ext-diff|--no-ext-diff|--textconv|--no-textconv|--ignore-submodules|
  242. --no-prefix|--ita-invisible-in-index|-1|--base|-2|--ours|-3|--theirs|
  243. -0|--cached)
  244. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action"
  245. # A generic action
  246. "COMMIT_FILE_DIR_#_arg" "NO-OP // ::→chroma/-git-verify-commit-or-file-or-dir"
  247. # A generic action
  248. "FILE_1_arg" "NO-OP // ::→chroma/-git-verify-file"
  249. # A generic action
  250. "FILE_2_arg" "NO-OP // ::→chroma/-git-verify-file"
  251. ## }}}
  252. ##
  253. ## ADD
  254. ##
  255. ## {{{
  256. subcmd:add "ADD_0_opt // FILE_OR_DIR_#_arg // NO_MATCH_#_opt"
  257. ADD_0_opt "
  258. --chmod=
  259. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action
  260. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-ARG-action
  261. || (-v|--verbose|-f|--force|-i|--interactive|-n|--dry-run|
  262. -p|--patch|-e|--edit|--all|--no-all|-A|--all|--no-all|
  263. --ignore-removal|--no-ignore-removal|-u|--update|-N|
  264. --intent-to-add|--refresh|--ignore-errors|--ignore-missing|
  265. --renormalize|--no-warn-embedded-repo)
  266. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action"
  267. FILE_OR_DIR_#_arg "NO-OP // ::→chroma/-git-verify-file-or-dir"
  268. ## }}}
  269. ##
  270. ## CHECKOUT
  271. ##
  272. ## {{{
  273. subcmd:checkout "CHECKOUT_BRANCH_0_opt^ //
  274. CHECKOUT_0_opt // FILE_OR_DIR_OR_BRANCH_OR_COMMIT_1_arg // FILE_#_arg //
  275. FILE_#_arg // NO_MATCH_#_opt"
  276. "CHECKOUT_BRANCH_0_opt^" "
  277. (-b|-B|--orphan)
  278. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action
  279. || (-b|-B|--orphan):del
  280. <<>> FILE_OR_DIR_OR_BRANCH_OR_COMMIT_1_arg // FILE_#_arg // FILE_#_arg
  281. || (-b|-B|--orphan):add
  282. <<>> NEW_BRANCH_1_arg // COMMIT_2_arg // NO_MATCH_#_arg"
  283. NEW_BRANCH_1_arg "NO-OP // ::→chroma/-git-verify-correct-branch-name"
  284. COMMIT_2_arg "NO-OP // ::→chroma/-git-verify-commit"
  285. CHECKOUT_0_opt "
  286. --conflict=
  287. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action
  288. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-ARG-action
  289. || (-q|--quiet|--progress|--no-progress|-f|--force|--ours|--theirs|
  290. -b|-B|-t|--track|--no-track|-l|--detach|--orphan|
  291. --ignore-skip-worktree-bits|-m|--merge|-p|--patch|
  292. --ignore-other-worktrees|--no-ignore-other-worktrees)
  293. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action"
  294. # A generic action
  295. COMMIT_1_arg "NO-OP // ::→chroma/-git-verify-commit"
  296. # Unused
  297. FILE_OR_BRANCH_OR_COMMIT_1_arg "NO-OP // ::→chroma/-git-file-or-ubranch-or-commit-verify"
  298. FILE_OR_DIR_OR_BRANCH_OR_COMMIT_1_arg "NO-OP // ::→chroma/-git-file-or-dir-or-ubranch-or-commit-verify"
  299. ## }}}
  300. ##
  301. ## REMOTE
  302. ##
  303. ## {{{
  304. subcmd:remote "REMOTE_0_opt // REMOTE_ADD_1_arg // REMOTE_RENAME_1_arg // REMOTE_REMOVE_1_arg //
  305. REMOTE_SET_HEAD_1_arg // REMOTE_SET_BRANCHES_1_arg //
  306. REMOTE_GET_URL_1_arg // REMOTE_SET_URL_1_arg // REMOTE_SHOW_1_arg //
  307. REMOTE_PRUNE_1_arg // REMOTE_UPDATE_1_arg"
  308. REMOTE_0_opt "(-v|--verbose)
  309. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action"
  310. REMOTE_ADD_1_arg "add ::::: __style=${FAST_THEME_NAME}subcommand // NO-OP <<>>
  311. add:REMOTE_ADD_OPTS_1_opt // REMOTE_A_NAME_2_arg //
  312. REMOTE_A_URL_3_arg // NO_MATCH_#_opt // NO_MATCH_#_arg"
  313. REMOTE_RENAME_1_arg "rename ::::: __style=${FAST_THEME_NAME}subcommand // NO-OP <<>>
  314. add:REMOTE_2_arg // REMOTE_A_NAME_3_arg // NO_MATCH_#_opt // NO_MATCH_#_arg"
  315. REMOTE_REMOVE_1_arg "remove ::::: __style=${FAST_THEME_NAME}subcommand // NO-OP <<>>
  316. add:REMOTE_2_arg // NO_MATCH_#_opt // NO_MATCH_#_arg"
  317. REMOTE_SET_HEAD_1_arg "set-head ::::: __style=${FAST_THEME_NAME}subcommand // NO-OP <<>>
  318. add:REMOTE_2_arg // BRANCH_3_arg //
  319. REMOTE_SET_HEAD_OPTS_1_opt // REMOTE_SET_HEAD_OPTS_2_opt //
  320. NO_MATCH_#_opt // NO_MATCH_#_arg"
  321. REMOTE_SET_BRANCHES_1_arg "set-branches ::::: __style=${FAST_THEME_NAME}subcommand // NO-OP <<>>
  322. add:REMOTE_SET_BRANCHES_OPTS_1_opt // REMOTE_2_arg //
  323. BRANCH_#_arg // NO_MATCH_#_opt"
  324. REMOTE_GET_URL_1_arg "get-url ::::: __style=${FAST_THEME_NAME}subcommand // NO-OP <<>>
  325. add:REMOTE_GET_URL_OPTS_1_opt // REMOTE_2_arg //
  326. NO_MATCH_#_opt // NO_MATCH_#_arg"
  327. REMOTE_SET_URL_1_arg "set-url ::::: __style=${FAST_THEME_NAME}subcommand // NO-OP <<>>
  328. add:REMOTE_SET_URL_OPTS_1_opt^ //
  329. REMOTE_2_arg // REMOTE_A_URL_3_arg // REMOTE_A_URL_4_arg //
  330. NO_MATCH_#_opt // NO_MATCH_#_arg"
  331. REMOTE_SHOW_1_arg "show ::::: __style=${FAST_THEME_NAME}subcommand // NO-OP <<>>
  332. add:REMOTE_SHOW_OPTS_1_opt // REMOTE_#_arg // NO_MATCH_#_opt"
  333. REMOTE_PRUNE_1_arg "prune ::::: __style=${FAST_THEME_NAME}subcommand // NO-OP <<>>
  334. add:REMOTE_PRUNE_OPTS_1_opt // REMOTE_#_arg // NO_MATCH_#_opt"
  335. REMOTE_UPDATE_1_arg "update ::::: __style=${FAST_THEME_NAME}subcommand // NO-OP <<>>
  336. add:REMOTE_UPDATE_OPTS_1_opt // REMOTE_GR_#_arg // NO_MATCH_#_opt"
  337. REMOTE_ADD_OPTS_1_opt "
  338. (-t|-m|--mirror=)
  339. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action
  340. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-ARG-action
  341. || (-f|--tags|--no-tags)
  342. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action"
  343. REMOTE_SET_HEAD_OPTS_1_opt "
  344. (-a|--auto|-d|--delete)
  345. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action"
  346. REMOTE_SET_HEAD_OPTS_2_opt "
  347. (-a|--auto|-d|--delete)
  348. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action"
  349. REMOTE_SET_BRANCHES_OPTS_1_opt "
  350. --add
  351. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action"
  352. REMOTE_GET_URL_OPTS_1_opt "
  353. (--push|--all)
  354. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action"
  355. "REMOTE_SET_URL_OPTS_1_opt^" "
  356. --push|--add|--delete
  357. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action
  358. || (--add|--delete):del
  359. <<>> REMOTE_A_URL_4_arg"
  360. REMOTE_SHOW_OPTS_1_opt "
  361. -n
  362. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action"
  363. REMOTE_PRUNE_OPTS_1_opt "
  364. (-n|--dry-run)
  365. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action"
  366. REMOTE_UPDATE_OPTS_1_opt "
  367. (-p|--prune)
  368. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action"
  369. REMOTE_A_NAME_2_arg "NO-OP // ::→chroma/-git-verify-correct-branch-name"
  370. REMOTE_A_NAME_3_arg "NO-OP // ::→chroma/-git-verify-correct-branch-name"
  371. REMOTE_A_URL_3_arg "NO-OP // ::→chroma/main-chroma-std-verify-url"
  372. REMOTE_A_URL_4_arg "NO-OP // ::→chroma/main-chroma-std-verify-url"
  373. BRANCH_3_arg "NO-OP // ::→chroma/-git-verify-branch"
  374. BRANCH_\#_arg "NO-OP // ::→chroma/-git-verify-branch"
  375. REMOTE_2_arg "NO-OP // ::→chroma/-git-verify-remote"
  376. REMOTE_\#_arg "NO-OP // ::→chroma/-git-verify-remote"
  377. ## }}}
  378. ##
  379. ## LOG
  380. ##
  381. subcmd:log "LOG_0_opt // LOG_1_arg // FILE_#_arg // NO_MATCH_#_opt"
  382. LOG_0_opt "
  383. (--decorate=|--decorate-refs=|--decorate-refs-exclude=|-L|-n|--max-count=|
  384. --skip=|--since=|--after=|--until=|--before=|--author=|--committer=|
  385. --grep-reflog=|--grep=|--min-parents=|--max-parents=|--branches=|--tags=|
  386. --remotes=|--glob=|--exclude=|--no-walk=|--pretty=|--format=|--encoding=|
  387. --expand-tabs=|--notes=|--show-notes=|--date=|--show-linear-break=|-U|
  388. --unified=|--anchored=|--diff-algorithm=|--stat=|--dirstat=|--submodule=|
  389. --color=|--color-moved=|--color-moved-ws=|--word-diff=|--word-diff-regex=|
  390. --color-words=|--ws-error-highlight=|--abbrev=|-B|--break-rewrites=|-M|
  391. --find-renames=|-C|--find-copies=|-l|--diff-filter=|-S|-G|--find-object=|
  392. --relative=|-O|--relative=|--inter-hunk-context=|--ignore-submodules=|
  393. --src-prefix=|--dst-prefix=|--line-prefix=)
  394. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action
  395. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-ARG-action
  396. || (--follow|--decorate|--no-decorate|--source|--use-mailmap|--full-diff|
  397. --log-size|--all-match|--invert-grep|-i|--regexp-ignore-case|--basic-regexp|
  398. -E|--extended-regexp|-F|--fixed-strings|-P|--perl-regexp|--remove-empty|
  399. --merges|--no-merges|--no-min-parents|--no-max-parents|--first-parent|
  400. --not|--all|--branches|--tags|--remotes|--reflog|--single-worktree|
  401. --ignore-missing|--bisect|--stdin|--cherry-mark|--cherry-pick|--left-only|
  402. --right-only|--cherry|-g|--walk-reflogs|--merge|--boundary|--simplify-by-decoration|
  403. --full-history|--dense|--sparse|--simplify-merges|--ancestry-path|--date-order|
  404. --author-date-order|--topo-order|--reverse|--no-walk|--do-walk|--pretty|
  405. --abbrev-commit|--no-abbrev-commit|--oneline|--expand-tabs|--no-expand-tabs|
  406. --notes|--no-notes|--show-notes|--no-standard-notes|--show-signature|
  407. --relative-date|--parents|--children|--left-right|--graph|--show-linear-break|
  408. -c|--cc|-m|-r|-t|-p|-u|--patch|-s|--no-patch|--raw|--patch-with-raw|
  409. --indent-heuristic|--no-indent-heuristic|--minimal|--patience|--histogram|
  410. --stat|--compact-summary|--numstat|--shortstat|--dirstat|--summary|
  411. --patch-with-stat|-z|--name-only|--name-status|--submodule|--color|--no-color|
  412. --color-moved|--word-diff|--color-words|--no-renames|--check|--full-index|
  413. --binary|--abbrev|--break-rewrites|--find-renames|
  414. --find-copies|--find-copies-harder|-D|--irreversible-delete|
  415. --pickaxe-all|--pickaxe-regex|-R|--relative|-a|--text|--ignore-cr-at-eol|
  416. --ignore-space-at-eol|-b|--ignore-space-change|-w|--ignore-all-space|
  417. --ignore-blank-lines|-W|--function-context|--ext-diff|--no-ext-diff|
  418. --textconv|--no-textconv|--ignore-submodules|--no-prefix|
  419. --ita-invisible-in-index)
  420. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action"
  421. LOG_1_arg "NO-OP // ::→chroma/-git-verify-rev-range-or-file"
  422. ##
  423. ## TAG
  424. ##
  425. subcmd:tag "TAG_D_0_opt^ // TAG_L_0_opt^ // TAG_V_0_opt^ // TAG_0_opt^"
  426. "TAG_0_opt^" "
  427. (-u|--local-user=|--cleanup=)
  428. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action
  429. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-ARG-action
  430. || -m
  431. <<>> NO-OP // ::→chroma/-git-commit-msg-opt-action
  432. <<>> NO-OP // ::→chroma/-git-commit-msg-opt-ARG-action
  433. || (-F|--file)
  434. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action
  435. <<>> NO-OP // ::→chroma/-git-verify-file
  436. || (-a|--annotate|-s|--sign|-f|-e|--edit)
  437. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action
  438. || (-u|--local-user=|--cleanup=|-m|-F|--file|-a|--annotate|-s|--sign|
  439. -f|-e|--edit):add
  440. <<>> TAG_NEW_1_arg // COMMIT_2_arg // NO_MATCH_#_arg //
  441. NO_MATCH_#_opt"
  442. TAG_NEW_1_arg "NO-OP // ::→chroma/-git-verify-correct-branch-name"
  443. TAG_1_arg "NO-OP // ::→chroma/-git-verify-tag-name"
  444. "TAG_D_0_opt^" "
  445. (-d)
  446. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action
  447. || -d:add
  448. <<>> TAG_#_arg // NO_MATCH_#_opt
  449. || -d:del
  450. <<>> TAG_0_opt // TAG_NEW_1_arg // COMMIT_2_arg"
  451. "TAG_#_arg" "NO-OP // ::→chroma/-git-verify-tag-name"
  452. "TAG_L_0_opt^" "
  453. (-l)
  454. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action
  455. || -l:add
  456. <<>> TAG_L_0_opt // TAG_PAT_#_arg // NO_MATCH_#_opt
  457. || -l:del
  458. <<>> TAG_0_opt // TAG_NEW_1_arg // COMMIT_2_arg"
  459. TAG_L_0_opt "
  460. (-n|--contains|--no-contains|--points-at|--column=|--sort=|--format=|
  461. --color=)
  462. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action
  463. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-ARG-action
  464. || (--column|--no-column|--create-reflog|--merged|--no-merged|--color|-i)
  465. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action"
  466. "TAG_PAT_#_arg" "NO-OP // ::→chroma/main-chroma-std-verify-pattern"
  467. "TAG_V_0_opt^" "
  468. (-v)
  469. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action
  470. || -v:add
  471. <<>> TAG_V_0_opt // TAG_#_arg // NO_MATCH_#_opt
  472. || -v:del
  473. <<>> TAG_0_opt // TAG_NEW_1_arg // COMMIT_2_arg"
  474. TAG_V_0_opt "
  475. --format=
  476. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-action
  477. <<>> NO-OP // ::→chroma/main-chroma-std-aopt-ARG-action"
  478. ##
  479. ## All remaining subcommands
  480. ##
  481. ## {{{
  482. "subcmd:*" "CATCH_ALL_#_opt"
  483. "CATCH_ALL_#_opt" "* <<>> NO-OP // ::→chroma/main-chroma-std-aopt-SEMI-action"
  484. ## }}}
  485. )
  486. # Called after entering just "git" on the command line
  487. →chroma/-git-first-call() {
  488. # Called for the first time - new command
  489. # FAST_HIGHLIGHT is used because it survives between calls, and
  490. # allows to use a single global hash only, instead of multiple
  491. # global variables
  492. FAST_HIGHLIGHT[chroma-git-counter]=0
  493. FAST_HIGHLIGHT[chroma-git-got-subcommand]=0
  494. FAST_HIGHLIGHT[chroma-git-subcommand]=""
  495. FAST_HIGHLIGHT[chrome-git-got-msg1]=0
  496. FAST_HIGHLIGHT[chrome-git-got-anymsg]=0
  497. FAST_HIGHLIGHT[chrome-git-occurred-double-hyphen]=0
  498. FAST_HIGHLIGHT[chroma-git-checkout-new]=0
  499. FAST_HIGHLIGHT[chroma-git-fetch-multiple]=0
  500. FAST_HIGHLIGHT[chroma-git-branch-change]=0
  501. FAST_HIGHLIGHT[chroma-git-option-with-argument-active]=0
  502. FAST_HIGHLIGHT[chroma-git-reset-etc-saw-commit]=0
  503. FAST_HIGHLIGHT[chroma-git-reset-etc-saw-file]=0
  504. return 1
  505. }
  506. →chroma/-git-check-if-alias() {
  507. local _wrd="$1"
  508. local -a _result
  509. typeset -ga fsh__chroma__git__aliases
  510. _result=( ${(M)fsh__chroma__git__aliases[@]:#${_wrd}[[:space:]]##*} )
  511. →chroma/main-chroma-print "Got is-alias-_result: $_result"
  512. [[ -n "$_result" ]] && \
  513. FAST_HIGHLIGHT[chroma-${FAST_HIGHLIGHT[chroma-current]}-subcommand]="${${${_result#* }## ##}%% *}"
  514. }
  515. # A hook that returns the list of git's
  516. # available subcommands in $reply
  517. →chroma/-git-get-subcommands() {
  518. local __svalue
  519. integer __ivalue
  520. LANG=C .fast-run-command "git help -a" chroma-${FAST_HIGHLIGHT[chroma-current]}-subcmd-list "" $(( 15 * 60 ))
  521. if [[ "${__lines_list[1]}" = See* ]]; then
  522. # (**)
  523. # git >= v2.20, the aliases in the `git help -a' command
  524. __lines_list=( ${${${${(M)__lines_list[@]:#([[:space:]](#c3,3)[a-zA-Z0-9_]*|Command aliases)}##[[:space:]]##}//(#s)Command\ aliases(#e)/Command_aliases}} )
  525. __svalue="+${__lines_list[(I)Command_aliases]}"
  526. __lines_list[1,__svalue-1]=( ${(@)__lines_list[1,__svalue-1]%%[[:space:]]##*} )
  527. else
  528. # (**)
  529. # git < v2.20, add aliases through extra code
  530. __lines_list=( ${(s: :)${(M)__lines_list[@]:# [a-z]*}} )
  531. __svalue=${#__lines_list}
  532. # This allows to check if the command is an alias - we want to
  533. # highlight the aliased command just like the target command of
  534. # the alias
  535. .fast-run-command "+git config --get-regexp 'alias.*'" chroma-${FAST_HIGHLIGHT[chroma-current]}-alias-list "[[:space:]]#alias." $(( 15 * 60 ))
  536. fi
  537. __tmp=${#__lines_list}
  538. typeset -ga fsh__chroma__git__aliases
  539. fsh__chroma__git__aliases=( ${__lines_list[__svalue+1,__tmp]} )
  540. [[ ${__lines_list[__svalue]} != "Command_aliases" ]] && (( ++ __svalue, __ivalue=0, 1 )) || (( __ivalue=1 ))
  541. __lines_list[__svalue,__tmp]=( ${(@)__lines_list[__svalue+__ivalue,__tmp]%%[[:space:]]##*} )
  542. reply=( "${__lines_list[@]}" )
  543. }
  544. # A generic handler
  545. →chroma/-git-verify-remote() {
  546. local _wrd="$4"
  547. .fast-run-git-command "git remote" "chroma-git-remotes-$PWD" "" 10
  548. [[ -n ${__lines_list[(r)$_wrd]} ]] && {
  549. __style=${FAST_THEME_NAME}correct-subtle; return 0
  550. } || {
  551. [[ $_wrd != *:* ]] && { __style=${FAST_THEME_NAME}incorrect-subtle; return 1; }
  552. }
  553. }
  554. # A generic handler - checks if given ref is correct
  555. →chroma/-git-verify-ref() {
  556. local _wrd="$4"
  557. _wrd="${_wrd%%:*}"
  558. .fast-run-git-command "git for-each-ref --format='%(refname:short)' refs/heads" "chroma-git-refs-$PWD" "refs/heads" 10
  559. [[ -n ${__lines_list[(r)$_wrd]} ]] && \
  560. { __style=${FAST_THEME_NAME}correct-subtle; return 0; } || \
  561. { __style=${FAST_THEME_NAME}incorrect-subtle; return 1; }
  562. }
  563. # A generic handler - checks if given remote or group is correct
  564. →chroma/-git-verify-remote-or-group() {
  565. →chroma/-git-verify-remote "$@" && return 0
  566. # The check for a group is to follow below
  567. integer _start="$2" _end="$3"
  568. local _scmd="$1" _wrd="$4"
  569. }
  570. # A generic handler - checks whether the file exists
  571. →chroma/-git-verify-file() {
  572. integer _start="$2" _end="$3" __pos __start __end
  573. local _wrd="$4" bg
  574. [[ -f $_wrd ]] && {
  575. (( __start=_start, __end=_end, __start >= 0 )) && \
  576. reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}correct-subtle]}")
  577. bg=${(M)FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}correct-subtle]%bg=*}
  578. ((1))
  579. } || {
  580. (( __start=_start, __end=_end, __start >= 0 )) && \
  581. reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}")
  582. bg=${(M)FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]%bg=*}
  583. }
  584. [[ -n ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path_pathseparator]} && \
  585. ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path]} != \
  586. ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path_pathseparator]}
  587. ]] && \
  588. for (( __pos = 1; __pos <= (_end-_start); __pos++ )) {
  589. [[ ${_wrd[__pos]} == "/" ]] && {
  590. [[ ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path_pathseparator]} = *bg=* ]] && {
  591. (( __start=_start+__pos-__PBUFLEN, __start >= 0 )) && \
  592. reply+=("$(( __start - 1 )) $__start ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path_pathseparator]}")
  593. ((1))
  594. } || {
  595. (( __start=_start+__pos-__PBUFLEN, __start >= 0 )) && \
  596. reply+=("$(( __start - 1 )) $__start ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path_pathseparator]}${bg:+,$bg}")
  597. }
  598. }
  599. }
  600. }
  601. # A generic handler - checks whether the file exists
  602. →chroma/-git-verify-file-or-dir() {
  603. integer _start="$2" _end="$3" __pos __start __end retval
  604. local _wrd="$4" bg
  605. __style=
  606. [[ -f $_wrd || -d $_wrd ]] && {
  607. (( __start=_start, __end=_end, __start >= 0 )) && \
  608. reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}correct-subtle]}")
  609. bg=${(M)FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}correct-subtle]%bg=*}
  610. ((1))
  611. } || {
  612. (( __start=_start, __end=_end, __start >= 0 )) && \
  613. reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}")
  614. bg=${(M)FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]%bg=*}
  615. retval=1
  616. }
  617. [[ -n ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path_pathseparator]} && \
  618. ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path]} != \
  619. ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path_pathseparator]}
  620. ]] && \
  621. for (( __pos = 1; __pos <= (_end-_start); __pos++ )) {
  622. [[ ${_wrd[__pos]} == "/" ]] && {
  623. [[ ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path_pathseparator]} = *bg=* ]] && {
  624. (( __start=_start+__pos-__PBUFLEN, __start >= 0 )) && \
  625. reply+=("$(( __start - 1 )) $__start ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path_pathseparator]}")
  626. ((1))
  627. } || {
  628. (( __start=_start+__pos-__PBUFLEN, __start >= 0 )) && \
  629. reply+=("$(( __start - 1 )) $__start ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}path_pathseparator]}${bg:+,$bg}")
  630. }
  631. }
  632. }
  633. return $retval
  634. }
  635. →chroma/-git-verify-branch() {
  636. local _wrd="$4"
  637. .fast-run-git-command "git for-each-ref --format='%(refname:short)'" "chroma-git-branches-$PWD" "refs/heads" 10
  638. if [[ -n ${__lines_list[(r)$_wrd]} ]] {
  639. __style=${FAST_THEME_NAME}correct-subtle; return 0
  640. } elif [[ -n ${__lines_list[(r)origin/$_wrd]} ]] {
  641. __style=${FAST_THEME_NAME}correct-subtle; return 0
  642. } else {
  643. __style=${FAST_THEME_NAME}incorrect-subtle; return 1
  644. }
  645. }
  646. →chroma/-git-verify-also-unfetched-ref() {
  647. local _wrd="$4"
  648. .fast-run-git-command "git config --get checkout.defaultRemote" \
  649. "chroma-git-defaultRemote-$PWD" "" 10
  650. local remote="${__lines_list[1]:-origin}"
  651. .fast-run-git-command "git rev-list --count --no-walk
  652. --glob=\"refs/remotes/$remote/$_wrd\"" \
  653. "chroma-git-unfetched-ref-$PWD" "" 10
  654. (( __lines_list[1] )) && { __style=${FAST_THEME_NAME}correct-subtle; return 0; } || \
  655. { __style=${FAST_THEME_NAME}incorrect-subtle; return 1; }
  656. }
  657. # A generic handler
  658. →chroma/-git-file-or-ubranch-or-commit-verify() {
  659. →chroma/-git-verify-commit "$@" && return
  660. →chroma/-git-verify-file "$@" && return
  661. →chroma/-git-verify-branch "$@" && return
  662. →chroma/-git-verify-also-unfetched-ref "$@"
  663. }
  664. # A generic handler
  665. →chroma/-git-file-or-dir-or-ubranch-or-commit-verify() {
  666. →chroma/-git-verify-commit "$@" && return
  667. →chroma/-git-verify-file-or-dir "$@" && return
  668. →chroma/-git-verify-branch "$@" && return
  669. →chroma/-git-verify-also-unfetched-ref "$@"
  670. }
  671. # A generic handler
  672. →chroma/-git-verify-correct-branch-name() {
  673. local _wrd="$4"
  674. →chroma/-git-verify-commit "$@" && \
  675. { __style=${FAST_THEME_NAME}incorrect-subtle; return 0; }
  676. →chroma/-git-verify-remote "$@" && \
  677. { __style=${FAST_THEME_NAME}incorrect-subtle; return 0; }
  678. [[ "$_wrd" != ./* && "$_wrd" != *..* && "$_wrd" != *[~\^\ $'\t']* &&
  679. "$_wrd" != */ && "$_wrd" != *.lock && "$_wrd" != *\\* ]] && \
  680. { __style=${FAST_THEME_NAME}correct-subtle; return 0; } || \
  681. { __style=${FAST_THEME_NAME}incorrect-subtle; return 1; }
  682. }
  683. # A generic handler that checks if given commit reference is correct
  684. →chroma/-git-verify-commit() {
  685. local _wrd="$4"
  686. __lines_list=()
  687. .fast-run-git-command --status "git rev-parse --verify --quiet \"$_wrd\"" \
  688. "chroma-git-commits-$PWD-$_wrd" "" $(( 1.5 * 60 ))
  689. if (( __lines_list[1] == 0 )); then
  690. __style=${FAST_THEME_NAME}correct-subtle
  691. return 0
  692. fi
  693. __style=${FAST_THEME_NAME}incorrect-subtle
  694. return 1
  695. }
  696. # A generic handler that checks if given commit reference
  697. # is correct or if it's a file that exists
  698. →chroma/-git-verify-commit-or-file() {
  699. →chroma/-git-verify-commit "$@" && return
  700. →chroma/-git-verify-file "$@"
  701. }
  702. # A generic handler that checks if given commit reference
  703. # is correct or if it's a file or directives that exists
  704. →chroma/-git-verify-commit-or-file-or-dir() {
  705. →chroma/-git-verify-commit "$@" && return
  706. →chroma/-git-verify-file-or-dir "$@"
  707. }
  708. # A generic handler that checks if given revision range
  709. # is correct or if a file of that name exists
  710. →chroma/-git-verify-rev-range-or-file() {
  711. local _wrd="$4"
  712. →chroma/-git-verify-commit "$@" && return 0
  713. if [[ "$_wrd" = *..* ]]; then
  714. (( FAST_HIGHLIGHT[chroma-git-reset-etc-saw-file] )) && {
  715. →chroma/-git-verify-file "$@" && return 0
  716. __style=${FAST_THEME_NAME}unknown-token
  717. return 1
  718. }
  719. __style=""
  720. return 0
  721. fi
  722. →chroma/-git-verify-file "$@" && \
  723. { FAST_HIGHLIGHT[chroma-git-reset-etc-saw-file]=1; return 0; }
  724. __style=""
  725. return 1
  726. }
  727. →chroma/-git-verify-tag-name() {
  728. local _wrd="$4"
  729. .fast-run-git-command "git tag" "chroma-git-tags-$PWD" "" $(( 2*60 ))
  730. [[ -n ${__lines_list[(r)$_wrd]} ]] && \
  731. __style=${FAST_THEME_NAME}correct-subtle || \
  732. __style=${FAST_THEME_NAME}incorrect-subtle
  733. }
  734. # A handler for the commit's -m/--message options.Currently
  735. # does the same what →chroma/main-chroma-std-aopt-action does
  736. →chroma/-git-commit-msg-opt-action() {
  737. →chroma/main-chroma-std-aopt-action "$@"
  738. }
  739. # A handler for the commit's -m/--message options' argument
  740. →chroma/-git-commit-msg-opt-ARG-action() {
  741. integer _start="$2" _end="$3"
  742. local _scmd="$1" _wrd="$4"
  743. (( __start >= 0 )) || return
  744. # Match the message body in case of an --message= option
  745. if [[ "$_wrd" = (#b)(--message=)(*) && -n "${match[2]}" ]]; then
  746. _wrd="${(Q)${match[2]//\`/x}}"
  747. # highlight --message=>>something<<
  748. reply+=("$(( __start+10 )) $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}double-quoted-argument]}")
  749. elif [[ "$_wrd" != --message ]]; then
  750. # highlight the message's body
  751. reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}double-quoted-argument]}")
  752. fi
  753. integer length=${FAST_HIGHLIGHT[git-cmsg-len]:-50}
  754. if (( ${#_wrd} > length )); then
  755. for (( __idx1 = 1, __idx2 = 1; __idx1 <= length; ++ __idx1, ++ __idx2 )); do
  756. # Use __arg from the fast-highlight-process's scope
  757. while [[ "${__arg[__idx2]}" != "${_wrd[__idx1]}" ]]; do
  758. (( ++ __idx2 ))
  759. (( __idx2 > __asize )) && { __idx2=-1; break; }
  760. done
  761. (( __idx2 == -1 )) && break
  762. done
  763. if (( __idx2 != -1 )); then
  764. if [[ -n "${match[1]}" ]]; then
  765. reply+=("$(( __start+__idx2 )) $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}")
  766. else
  767. reply+=("$(( __start+__idx2-1 )) $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}")
  768. fi
  769. fi
  770. fi
  771. }
  772. # A RESET handler
  773. # TODO: differentiate tree-ish from commit
  774. →chroma/-git-RESET-verify-commit-or-file() {
  775. →chroma/-git-verify-commit "$@" && {
  776. →chroma/-git-verify-file "$@" && {
  777. # TODO: with -p/--patch, the <paths> are optional,
  778. # and this argument will be taken as a commit in a
  779. # specific circumstances
  780. FAST_HIGHLIGHT[chroma-git-reset-etc-saw-file]=1
  781. return 0
  782. }
  783. (( FAST_HIGHLIGHT[chroma-git-reset-etc-saw-file] ||
  784. FAST_HIGHLIGHT[chroma-git-reset-etc-saw-commit] )) && \
  785. { __style=${FAST_THEME_NAME}unknown-token; return 1; }
  786. FAST_HIGHLIGHT[chroma-git-reset-etc-saw-commit]=1
  787. __style=${FAST_THEME_NAME}correct-subtle
  788. return 0
  789. }
  790. →chroma/-git-verify-file "$@" && \
  791. { FAST_HIGHLIGHT[chroma-git-reset-etc-saw-file]=1; return 0; }
  792. return 1
  793. }
  794. return 0
  795. # vim:ft=zsh:et:sw=4