From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh Users <zsh-users@zsh.org>
Subject: _git and partial completion, again
Date: Sat, 25 Jan 2014 12:09:06 -0800 [thread overview]
Message-ID: <140125120906.ZM21966@torch.brasslantern.com> (raw)
In-Reply-To: <CADdV=MtDhQXkFQ2iaE4FTFi1bB5LiPiSn30_3q8xRCvaewDowA@mail.gmail.com>
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
}
next prev parent reply other threads:[~2014-01-25 20:09 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-20 7:13 [Feature suggestion] (user configurable) timeout for generating completion lists Arseny Tolmachev
2014-01-22 8:04 ` Bart Schaefer
2014-01-23 12:04 ` Nikolai Weibull
2014-01-24 1:16 ` Bart Schaefer
2014-01-24 9:00 ` Nikolai Weibull
2014-01-25 20:09 ` Bart Schaefer [this message]
2014-01-24 14:46 ` Greg Klanderman
2014-01-25 20:49 ` Bart Schaefer
2014-01-29 16:29 ` Greg Klanderman
2014-02-25 15:35 ` Greg Klanderman
2014-01-22 13:51 ` Shawn Wilson
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=140125120906.ZM21966@torch.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=zsh-users@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).