Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH v3] _git-grep: Complete files when outside git repos



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