From: Guido Cella <guidocella91@gmail.com>
To: zsh-workers@zsh.org
Subject: [PATCH v2] _git-grep: Complete files when outside git repos
Date: Fri, 25 Sep 2020 09:47:03 +0200 [thread overview]
Message-ID: <20200925074703.11154-1-guidocella91@gmail.com> (raw)
---
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
next reply other threads:[~2020-09-25 7:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-25 7:47 Guido Cella [this message]
2020-09-25 7:52 ` Guido Cella
2020-09-26 5:27 ` Mikael Magnusson
2020-09-26 10:23 ` [PATCH v3] " Guido Cella
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=20200925074703.11154-1-guidocella91@gmail.com \
--to=guidocella91@gmail.com \
--cc=zsh-workers@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).