Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH v2] _git-grep: Complete files when outside git repos
- X-seq: zsh-workers 47401
- From: Guido Cella <guidocella91@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH v2] _git-grep: Complete files when outside git repos
- Date: Fri, 25 Sep 2020 09:47:03 +0200
- Archived-at: <https://zsh.org/workers/47401>
- Archived-at: <http://www.zsh.org/sympa/arcsearch_id/zsh-workers/2020-09/20200925074703.11154-1-guidocella91%40gmail.com>
- Authentication-results: zsh.org; iprev=pass (mail-wm1-f45.google.com) smtp.remote-ip=209.85.128.45; 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:mime-version :content-transfer-encoding; bh=PDQksVlIEWDUUYg9C3CbdL6r4gVmYkMFyPeVFkMpZvk=; b=LQjgbqc2xY3KA2poDK36FVQJjOITCy3eHh9sf5bPrs+bkn67utYxJvdO4RreLvDBGD JxtQIctCHcoGGfpfpBDPC4aQZfE6HjjC2nW9xprlQ3vzewC5D5f4bnlTB2MNIXct/Jdt MyDhk+bCkzHaSqG/0EvTPpaPMsg0aclRP6URIWx5djmtk5BJH5wQ95NqhwnQbIxrFDqK vpvCvHYZwGufpPVaSWGBpy2q1jRLXO+Bd6P5fR40AFO14vGRZnzFlLg86SC32g/auxSv tesmaEJd3yfoAxDhp9X/ibFNMS35tj8ibK5GhlOEMFccsw/nsLhClAnl3UkVfUWrFFXG kgeA==
- 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>
- Sender: zsh-workers-request@xxxxxxx
---
Completion/Unix/Command/_git | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 05e2a23..2847d1c 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -1033,10 +1033,21 @@ _git-grep () {
': :_guard "^-*" pattern' \
'*:: :->tree-or-file' && ret=0
- # TODO: If --cached, --no-index, -O, or --open-files-in-pager was given,
+ # TODO: If --cached, -O, or --open-files-in-pager was given,
# don't complete treeishs.
case $state in
(tree-or-file)
+ # Check if we're not in a git repository
+ # from the exit status of an arbitrary git command.
+ if ! git rev-parse 2>/dev/null && [[
+ words[(I)--no-index] -ne 0 ||
+ "$(_call_program get-grep-fallbacktonoindex-option git config --type=bool grep.fallbackToNoIndex)" \
+ == 'true'
+ ]]; then
+ _files && ret=0
+ return ret
+ fi
+
integer first_tree last_tree start end i
(( start = words[(I)(-f|-e)] > 0 ? 1 : 2 ))
@@ -1052,7 +1063,7 @@ _git-grep () {
fi
done
- # TODO: Need to respect --cached and --no-index here.
+ # TODO: Need to respect --cached here.
if (( last_tree == 0 || last_tree == end )); then
if (( first_tree == 0 )); then
_alternative \
--
2.28.0
Messages sorted by:
Reverse Date,
Date,
Thread,
Author