From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 30344 invoked from network); 25 Sep 2020 07:47:26 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 25 Sep 2020 07:47:26 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1601020046; b=XJBbKlPYISDklpvQfTmQcLn+sM+fXoVooQFoxfCx4/k2Ww+hR/looh5y/c4P/O025zkOx7xA6H 9ly4iHPyPMOmK9v0hZGuxPe2F9VKbnPPtqSMbbTghU6HytMovvPR1ED6RcfxM9IieIcr+A5nxX U9T/dP8FYo6nDDFloF7OnleuHhauBZ/oacWs4A3AoW1MBivuYjxsCum7K1GqvcJ1soryhLo/Oh Qi7pEoDOgw/Ehwku/ROAtpy2TVpSTfeby3i7PJh3nXRd388lUdXjs+BRBC3aivuHEmbBV8ayRE Ph1dwbSfJpz0pMS+zQuyxA3h2a62ztKchubVKS6uIeXAOQ==; ARC-Authentication-Results: i=1; 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1601020046; bh=Og35QveMoT2vbu9NejkxpPo2OFf/FngIFMGKhMq2oz4=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:MIME-Version:Message-ID:Date: Subject:To:From:DKIM-Signature:DKIM-Signature; b=bsUrv25zIHhIBxvzSD3bwZpKCmM2/tr49QtHQUHrUwQnXdvNvzy7kLi+pWQTVhJXkyiLRYGQnz azNBJpDPIlI8aEpMOQL+WrmNgu1+fDaIi0eCOjpWnhtECRYNaKHw+EHw0+pcE8lRCIhCYAe7OJ 4j9agijTVBu7mKW6B4HDcgCT8xc65Fig2xpzs7MPAdH+ZyhchSo5O1StfZuX0I2fv7yTRH4YAL 6QlTvcMeXajse8TYDDbcdYzfu4fLU+TUPgNBJ3JIrCE1lQZb+8XmfcqAd1kK9eLabx3df98mVK mRIQgcOREPKFVrPlXECh+8GeW0wXyWeNqZtMcQWoMX2glA==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References; bh=PDQksVlIEWDUUYg9C3CbdL6r4gVmYkMFyPeVFkMpZvk=; b=c25rTxY9HsIfz4G6+rWcj75c0/ r4yOwvfsg2QLguIjg55XX+cnRrXfDC0LG+YzBwdE8uvMitw0bHBF0m/SCSCLefAznpCvMVrms+rcs wIM75Lr+4qnKl7X6O7CZeiHaccLillIR5ZxHnQy9DSQ1dYsXxSqd6fuLLP7oomrWI8AikRPOGU4od lqPZYS7SHcG3t67vs/2qfqhCfDqaejOg/vfUhRoTE7iT9pOdogyvCI03HpgPa/oP9MC82qyO0TCk/ Or28/sO9fgNQpgEVjD1dfEGLdkActEDa3t3rDXLtvt8bW4HjPpcMYlC3OKblkikoP4gHZgAR52CGR 9lUoJIyg==; Received: from authenticated user by zero.zsh.org with local id 1kLiRx-000Hqu-6i; Fri, 25 Sep 2020 07:47:25 +0000 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 Received: from mail-wm1-f45.google.com ([209.85.128.45]:52147) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1kLiRe-000Hhj-90; Fri, 25 Sep 2020 07:47:06 +0000 Received: by mail-wm1-f45.google.com with SMTP id w2so2031798wmi.1 for ; Fri, 25 Sep 2020 00:47:06 -0700 (PDT) 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== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=PDQksVlIEWDUUYg9C3CbdL6r4gVmYkMFyPeVFkMpZvk=; b=buwGyD1REj8noSldueplhV8h/E/nFHM3XzEmJt2jlHlqHw3uSGoaPQOyehYIYK05O/ mtC35/rvD6Y7Ph3C00chwyVaf4ABRfpS7uwgmMSM3E5mH5dV7Q/9w7x5dJZ7zSLfw92l Ueom2s1g88Ko5NfD6t7Y6XprkUPmpK8j2WDwp0gqtcJXFfgh8kH8Q6vnjxETSfjCUwbC nUUAfv+KQOxTHzRitqCR3Jeq1P1DmloO8aUtjcVfzFSuSsgs4+9pljemlt8BALKJ/JOy cjQ9jhdHbVY6VoucxSka0zhG1z8/N+DpL1gcTuGxHXHUXud0v/utqWfvuMbSWHbdK9U5 4kWQ== X-Gm-Message-State: AOAM532ixWryH/EjVprr1Pjui/xJEomNC7y6i29+eFgHigokA0G13KLl 7vEL0dypVGfWA4Z0sulpomlxdzxXr9ZA1w== X-Google-Smtp-Source: ABdhPJzYVhpfB/694gcW4SITejRJtTHC+OO9jb5CuH/LPVXzDzUaWT+jI3qGp9j6yHyH8XHDYjx7mQ== X-Received: by 2002:a7b:c241:: with SMTP id b1mr1668490wmj.98.1601020025364; Fri, 25 Sep 2020 00:47:05 -0700 (PDT) Received: from aegis.localdomain ([2001:b07:6455:ac4f:3641:5dff:fe55:2a8f]) by smtp.gmail.com with ESMTPSA id z9sm1867207wmg.46.2020.09.25.00.47.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Sep 2020 00:47:05 -0700 (PDT) From: Guido Cella 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 Message-Id: <20200925074703.11154-1-guidocella91@gmail.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Seq: 47401 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Archived-At: --- 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