From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28029 invoked by alias); 25 Jan 2014 20:09:22 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 18368 Received: (qmail 16187 invoked from network); 25 Jan 2014 20:09:06 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 From: Bart Schaefer Message-id: <140125120906.ZM21966@torch.brasslantern.com> Date: Sat, 25 Jan 2014 12:09:06 -0800 In-reply-to: Comments: In reply to Nikolai Weibull "Re: [Feature suggestion] (user configurable) timeout for generating completion lists" (Jan 24, 10:00am) References: <140122000435.ZM1516@torch.brasslantern.com> <140123171659.ZM19422@torch.brasslantern.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: Zsh Users Subject: _git and partial completion, again MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Jan 24, 10:00am, Nikolai Weibull wrote: } } > We've already seen the "do it externally" plan break down with the _git } > issue discussed in the thread leading up to zsh-users/18321 (about which } > we're sort of awaiting your input, Nikolai). } } Uh, I've totally missed this. I guess a zstyle would work, but } couldn't one check if completion is being done by partial-path? I can't think of a good way to distinguish a partial completion from a full completion of a path that exists only on the remote repo. Someone suggested that we simply avoid calling __git_files in some cases, but I don't know git details well enough to make that determination. So, my best guess is below, which just calls ls-files more than once. There are probably cases where it could do better; e.g., for modified files it cbuld first glob $pref* locally and, if anything matches, use ls-files to filter for only the modified subset. However, that wouldn't be appropriate for deleted files, so this may be the best we can do without some kind of a switch on $opts. diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index 43a01d9..c09f255 100644 --- a/Completion/Unix/Command/_git +++ b/Completion/Unix/Command/_git @@ -5683,9 +5683,17 @@ __git_files () { # TODO: --directory should probably be added to $opts when --others is given. local pref=$gitcdup$gitprefix$PREFIX + + # First allow ls-files to pattern-match in case of remote repository files=(${(0)"$(_call_program files git ls-files -z --exclude-standard $opts -- ${pref:+$pref\\\*} 2>/dev/null)"}) __git_command_successful $pipestatus || return + # If ls-files succeeded but returned nothing, try again with no pattern + if [[ -z "$files" && -n "$pref" ]]; then + files=(${(0)"$(_call_program files git ls-files -z --exclude-standard $opts -- 2>/dev/null)"}) + __git_command_successful $pipestatus || return + fi + # _wanted $tag expl $description _files -g '{'${(j:,:)files}'}' $compadd_opts - _wanted $tag expl $description _multi_parts -f $compadd_opts - / files }