Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: 3.0.8: git completion update for cherry-pick
- X-seq: zsh-workers 36276
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: Mateusz Karbowy <mateusz.karbowy@xxxxxxxxx>
- Subject: Re: PATCH: 3.0.8: git completion update for cherry-pick
- Date: Sun, 23 Aug 2015 06:42:21 +0000
- Cc: zsh-workers@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=JFk4Wxar2Sun8Umz Oy0kR39UMh4=; b=B2wQhyNhRHM7nLn+sdQMwzYrvD2TctiPIRsyvrX9OjttZvIi 4OhyY0opl2cjlKMoyWJTjZ9zp4Z2dMABny8veg+Ive9sd0Tf2sORO6dIWYsd8+/x vdnbpmL4Ajhe11Tb640ESHDmXpjf73OzAosc2ALL5fr+hGidsQNGtQ2eiiY=
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=JFk4Wxar2Sun8Um zOy0kR39UMh4=; b=EdTwl7jeGpJVxJaEwRc3IEZWRG6Jj3K8BQT/OXlZIH9tEpz /iDenJd+9d9L8Qj/uT1Pp25V63i6j4rmyP2L3y9zNFYkysq61/z4QMOIlIHP0nKl OWJHr1Ra61K8H34Sn/V1KHGDpE922j/1ASL4J1AzQR6lylVsh6VUAcx6uZh8=
- In-reply-to: <CAFiR=Jvs_Jf=cE36xBgoi77AY5HJEFEVyiB_mQYuupCp=XtDCg@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CAFiR=Jv1ycq5jWvbyHQX=Csjyv8H1xSUKA45Mj6152Why5qhjg@mail.gmail.com> <20150722115307.GC2171@tarsus.local2> <CAFiR=JuAH5r4C9YHCvtLG1Gh0pSQFXpE37=hiXWaFf5oMQxPzA@mail.gmail.com> <20150811220632.GE1859@tarsus.local2> <CAFiR=JuQkL_iABz6YSh8wbVmu_fdbc94zN=JHe5U7r9ddSSJUg@mail.gmail.com> <CAFiR=Jvs_Jf=cE36xBgoi77AY5HJEFEVyiB_mQYuupCp=XtDCg@mail.gmail.com>
As mentioned on IRC — I'd like to review this but I don't have time to
do so right now. @zsh-workers, feel free to beat me to it.
Mateusz Karbowy wrote on Fri, Aug 21, 2015 at 20:55:07 +0100:
> Hey Daniel
>
> I think this covers it. I know you mentioned I shouldn't need to use
> the ${(P)} in __git_commit_ranges, but there were these two calls to
> __git_commits with either '$*' or '$* $suf', and they operated on
> compadd params before the change, so I thought it's safer this way.
> What do you think?
> diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
> index b8edc10..5f4fead 100644
> --- a/Completion/Unix/Command/_git
> +++ b/Completion/Unix/Command/_git
> @@ -495,6 +495,8 @@ _git-checkout () {
>
> (( $+functions[_git-cherry-pick] )) ||
> _git-cherry-pick () {
> + local -a git_commit_opts
> + git_commit_opts=(--all --not HEAD --not)
> _arguments \
> '(- :)--quit[end revert or cherry-pick sequence]' \
> '(- :)--continue[resume revert or cherry-pick sequence]' \
> @@ -511,7 +513,7 @@ _git-cherry-pick () {
> '*'{-s,--strategy=}'[use given merge strategy]:merge strategy:__git_merge_strategies' \
> '*'{-X,--strategy-option=}'[pass merge-strategy-specific option to merge strategy]' \
> '(-e --edit -x -n --no-commit -s --signoff)--ff[fast forward, if possible]' \
> - ': :__git_commit_ranges'
> + ': : __git_commit_ranges -O expl -C git_commit_opts'
> }
>
> (( $+functions[_git-citool] )) ||
> @@ -5602,20 +5604,29 @@ __git_remote_branch_names_noprefix () {
>
> (( $+functions[__git_commit_objects_prefer_recent] )) ||
> __git_commit_objects_prefer_recent () {
> - __git_recent_commits || __git_commit_objects
> + local -A commit_opts_array_name
> + zparseopts -D -E C:=commit_opts_array_name
> +
> + __git_recent_commits -C $commit_opts_array_name || __git_commit_objects
> }
>
> (( $+functions[__git_commits] )) ||
> __git_commits () {
> + # Separate compadd options with git commit options.
> + local -A compadd_opts_array_name commit_opts_array_name
> + zparseopts -D -E O:=compadd_opts_array_name C:=commit_opts_array_name
> + (( $#compadd_opts_array_name )) && set -- "${(@P)compadd_opts_array_name}"
> +
> # TODO: deal with things that __git_heads and __git_tags has in common (i.e.,
> # if both exists, they need to be completed to heads/x and tags/x.
> - local -a sopts ropt
> + local -a sopts ropt expl
> zparseopts -E -a sopts S: r:=ropt R: q
> sopts+=( $ropt:q )
> + expl=( $@ )
> _alternative \
> "heads::__git_heads $sopts" \
> "commit-tags::__git_commit_tags $sopts" \
> - 'commit-objects::__git_commit_objects_prefer_recent'
> + 'commit-objects:: __git_commit_objects_prefer_recent -O expl -C $commit_opts_array_name'
> }
>
> (( $+functions[__git_heads] )) ||
> @@ -5670,13 +5681,17 @@ __git_commit_objects () {
> (( $+functions[__git_recent_commits] )) ||
> __git_recent_commits () {
> local gitdir expl start
> - declare -a descr tags heads commits
> + local -A commit_opts_array_name
> + declare -a descr tags heads commits commit_opts
> local i j k ret
> integer distance_from_head
>
> + zparseopts -D -E C:=commit_opts_array_name
> + (( $#commit_opts_array_name )) && commit_opts=( "${(@P)commit_opts_array_name}" )
> +
> # Careful: most %d will expand to the empty string. Quote properly!
> # NOTE: we could use %D directly, but it's not available in git 1.9.1 at least.
> - commits=("${(f)"$(_call_program commits git --no-pager log -20 --format='%h%n%d%n%s\ \(%cr\)')"}")
> + commits=("${(f)"$(_call_program commits git --no-pager log $commit_opts -20 --format='%h%n%d%n%s\ \(%cr\)')"}")
> __git_command_successful $pipestatus || return 1
>
> for i j k in "$commits[@]" ; do
> @@ -5759,13 +5774,19 @@ __git_commits2 () {
>
> (( $+functions[__git_commit_ranges] )) ||
> __git_commit_ranges () {
> - local -a suf
> + local -A compadd_opts_array_name commit_opts_array_name
> + zparseopts -D -E O:=compadd_opts_array_name C:=commit_opts_array_name
> + (( $#compadd_opts_array_name )) && set -- "${(@P)compadd_opts_array_name}"
> +
> + local -a expl suf
> if compset -P '*..(.|)'; then
> - __git_commits $*
> + expl=( $* )
> else
> compset -S '..*' || suf=( -S .. -r '.@~ ^:\t\n\-' )
> - __git_commits $* $suf
> + expl=( $* $suf )
> fi
> +
> + __git_commits -O expl -C $commit_opts_array_name
> }
>
> (( $+functions[__git_commit_ranges2] )) ||
Messages sorted by:
Reverse Date,
Date,
Thread,
Author