zsh-workers
 help / color / mirror / code / Atom feed
From: Guido Cella <guidocella91@gmail.com>
To: zsh-workers@zsh.org
Subject: [PATCH v3] _git-grep: Complete files when outside git repos
Date: Sat, 26 Sep 2020 12:23:28 +0200	[thread overview]
Message-ID: <20200926102326.17435-1-guidocella91@gmail.com> (raw)
In-Reply-To: <20200925074703.11154-1-guidocella91@gmail.com>

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



      parent reply	other threads:[~2020-09-26 10:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-25  7:47 [PATCH v2] " Guido Cella
2020-09-25  7:52 ` Guido Cella
2020-09-26  5:27   ` Mikael Magnusson
2020-09-26 10:23 ` Guido Cella [this message]

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=20200926102326.17435-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).