From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17201 invoked by alias); 2 Aug 2015 16:20:30 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 35971 Received: (qmail 15693 invoked from network); 2 Aug 2015 16:20:27 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2 autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=Mn3v1jNycP18bnmtHLQbpPKXIJCg5jVp4K5vpeMfRjY=; b=qsT0hMsbTHg2UOpVJwf3g6ldL7jVkVkP1R1yHmorNCko2i7PMN5KX+CtPp1P0NqmkK S3EqTCvbiIAyqQU3LS4VkM5RZIDgSiVkI5MGxnJf634m1rG/BfeTaTtFPIutk/2eumBQ drJ9KzgBuFh4i5zo/1WBH+cfpV9ckD+ivdE1avWAVBMy0d3wRUIp8LhHQj2SJztBc64C qjHWvzeclWXSZizOQM2G6Q1gc2w0SHaHCKnf+rkIkwi/zb0Jq3GuFQi2RuezGCtK4v8T 2a56Cswjvqm8BDy27hlxNi9XMYjStmsqsQtWcXWgq1refADt6blmnAm/ReUPBt8asDfR 9yJA== MIME-Version: 1.0 X-Received: by 10.107.31.134 with SMTP id f128mr15359688iof.19.1438532422612; Sun, 02 Aug 2015 09:20:22 -0700 (PDT) In-Reply-To: <55BE2CC6.5060104@thequod.de> References: <55BE2CC6.5060104@thequod.de> Date: Sun, 2 Aug 2015 18:20:22 +0200 Message-ID: Subject: Re: Bug: git completion: __git_ignore_line ignores complete branch From: Mikael Magnusson To: Daniel Hahler Cc: "Zsh Hackers' List" Content-Type: text/plain; charset=UTF-8 On Sun, Aug 2, 2015 at 4:44 PM, Daniel Hahler 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" results in: > -- no matches found: `branch-name' -- > > But "git branch -D branc" 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