zsh-workers
 help / color / mirror / code / Atom feed
From: Mikael Magnusson <mikachu@gmail.com>
To: Daniel Hahler <genml+zsh-workers@thequod.de>
Cc: "Zsh Hackers' List" <zsh-workers@zsh.org>
Subject: Re: Bug: git completion: __git_ignore_line ignores complete branch
Date: Sun, 2 Aug 2015 18:20:22 +0200	[thread overview]
Message-ID: <CAHYJk3SkYVj8CJ3PORdXobo_7-yx0wpNYVi=nkwJYweJ_TAjeA@mail.gmail.com> (raw)
In-Reply-To: <55BE2CC6.5060104@thequod.de>

On Sun, Aug 2, 2015 at 4:44 PM, Daniel Hahler
<genml+zsh-workers@thequod.de> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> __git_ignore_line_inside_arguments seems to be responsible for an error when trying
> to complete an already complete branch.
>
> E.g. "git branch -D branch<tab>" results in:
>  -- no matches found: `branch-name' --
>
> But "git branch -D branc<tab>" will complete "branch".
>
> This is the function:
>
> (( $+functions[__git_ignore_line] )) ||
> __git_ignore_line () {
>   declare -a ignored
>   ignored=()
>   ((CURRENT > 1)) &&
>     ignored+=(${line[1,CURRENT-1]//(#m)[\[\]()\\*?#<>~\^]/\\$MATCH})
>   ((CURRENT < $#line)) &&
>     ignored+=(${line[CURRENT+1,-1]//(#m)[\[\]()\\*?#<>~\^]/\\$MATCH})
>   $* -F ignored
> }
>
> (( $+functions[__git_ignore_line_inside_arguments] )) ||
> __git_ignore_line_inside_arguments () {
>   declare -a compadd_opts
>
>   zparseopts -D -E -a compadd_opts V: J: 1 2 n f X: M: P: S: r: R: q F:
>
>   __git_ignore_line $* $compadd_opts
> }
>
> And it is used like this in _git-branch:
>
>   dependent_deletion_args+='*: :__git_ignore_line_inside_arguments __git_branch_names'
>
> The problem is that it will ignore the current word, "branch", but should do so probably
> only if it is not being completed currently, i.e. has a space at the end?!
>
> It works when completing "branc", because then only "branc" will be ignored.
>
> $line in the context of __git_ignore_line will be the part after "git branch -D", and $CURRENT will be 3.  That seems to be off?!
>
> For the case at hand, using ${line[1,CURRENT-3]//...} seems to fix it, but probably
> an index matching the position in $line, and then -1 should be used?!

I haven't looked at the code but this sounds like huge confusion in
the code. The ignore-line style already does this generically for
anything you can complete, _git shouldn't be doing it manually in a
single specific case at all.

-- 
Mikael Magnusson


  reply	other threads:[~2015-08-02 16:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-02 14:44 Daniel Hahler
2015-08-02 16:20 ` Mikael Magnusson [this message]
2015-08-05 19:22   ` Daniel Hahler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAHYJk3SkYVj8CJ3PORdXobo_7-yx0wpNYVi=nkwJYweJ_TAjeA@mail.gmail.com' \
    --to=mikachu@gmail.com \
    --cc=genml+zsh-workers@thequod.de \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).