zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] _git-grep: Complete files when outside git repos
@ 2020-09-24 20:34 Guido Cella
  2020-09-25  6:34 ` Daniel Shahaf
  0 siblings, 1 reply; 4+ messages in thread
From: Guido Cella @ 2020-09-24 20:34 UTC (permalink / raw)
  To: zsh-workers

---
 Completion/Unix/Command/_git | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 05e2a23..67f06c5 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -1037,6 +1037,12 @@ _git-grep () {
   # don't complete treeishs.
   case $state in
     (tree-or-file)
+      # Check if we're not in a git repository.
+      if ! git rev-parse 2>/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



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-09-25  7:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-24 20:34 [PATCH] _git-grep: Complete files when outside git repos Guido Cella
2020-09-25  6:34 ` Daniel Shahaf
2020-09-25  6:49   ` Mikael Magnusson
2020-09-25  7:28     ` Daniel Shahaf

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