Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH v3] _git-grep: Complete files when outside git repos
- X-seq: zsh-workers 47404
- From: Guido Cella <guidocella91@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH v3] _git-grep: Complete files when outside git repos
- Date: Sat, 26 Sep 2020 12:23:28 +0200
- Archived-at: <https://zsh.org/workers/47404>
- Archived-at: <http://www.zsh.org/sympa/arcsearch_id/zsh-workers/2020-09/20200926102326.17435-1-guidocella91%40gmail.com>
- Authentication-results: zsh.org; iprev=pass (mail-wr1-f51.google.com) smtp.remote-ip=209.85.221.51; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=UfNyIZW/Yf0iOWI2e3W+plpXmOwbxNPbmHnx34h75LE=; b=E1tKdDNT9f6oxXahRYKcdiVJ1JuvbeRfQpw2YuT1qpKAsNoA24spLUSH6ZRidmKoRA 0ytySHsN524WqyUE4VkRI+Hjxu10vcpIXe7uPXEHstQJlWAmGrDWaY4lNQ4tFH2KOWF0 u8RnOI3eaOcSAIVx/A2n+1hSC12IZE0o5n2cQ5w4zms+5rNuFoyw5jqwfLV9CLm/wnW0 AQUJK3OJ7JF5PMwbSi4ncyFBmLO0TMV1MH5YUc62/hDkxeZ1J4snn0cbJXrqRced4LaG pQi0PLebp+Nr5M1qn8G9JQUOizhtqxTKVJgtsH7bGs6V1eaJQoTKnI/hOaY39dxCJ5tK LO1A==
- In-reply-to: <20200925074703.11154-1-guidocella91@gmail.com>
- List-archive: <http://www.zsh.org/sympa/arc/zsh-workers>
- List-help: <mailto:sympa@zsh.org?subject=help>
- List-id: <zsh-workers.zsh.org>
- List-owner: <mailto:zsh-workers-request@zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-subscribe: <mailto:sympa@zsh.org?subject=subscribe%20zsh-workers>
- List-unsubscribe: <mailto:sympa@zsh.org?subject=unsubscribe%20zsh-workers>
- References: <20200925074703.11154-1-guidocella91@gmail.com>
- Sender: zsh-workers-request@xxxxxxx
This works only if you passed --no-index or have git config
grep.fallbackToNoIndex set to true, but we have no other completions to
provide outside of git repositories anyway so we skip the check.
---
I misunderstood the request to use _call_program as referring to getting
the config because I was in a rush to fix the error. Now this just
completes all files whenever we're outside a git repository but with the
ability to change the called program (I initially just used rev-parse
because it's called directly in 2 other places).
Also, we're not done with --no-index since it still has the effect of
not being able to complete treeishs within git repositories.
Completion/Unix/Command/_git | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 05e2a23..4f5fdf4 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -1037,6 +1037,11 @@ _git-grep () {
# don't complete treeishs.
case $state in
(tree-or-file)
+ if ! _call_program within-repo git rev-parse >&/dev/null; then
+ _files && ret=0
+ return ret
+ fi
+
integer first_tree last_tree start end i
(( start = words[(I)(-f|-e)] > 0 ? 1 : 2 ))
--
2.28.0
Messages sorted by:
Reverse Date,
Date,
Thread,
Author