From: Mikael Magnusson <mikachu@gmail.com>
To: Daniel Shahaf <d.s@daniel.shahaf.name>
Cc: Guido Cella <guidocella91@gmail.com>, zsh-workers@zsh.org
Subject: Re: [PATCH] _git-grep: Complete files when outside git repos
Date: Fri, 25 Sep 2020 08:49:30 +0200 [thread overview]
Message-ID: <CAHYJk3Tg4pNf7H5ZP08cgB1ONH7D5dt3oLw-pWpHZ8sBF3xGHA@mail.gmail.com> (raw)
In-Reply-To: <20200925063411.GD29504@tarpaulin.shahaf.local2>
On 9/25/20, Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
> Guido Cella wrote on Thu, Sep 24, 2020 at 22:34:41 +0200:
>> ---
>> 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
>
> Why is this correct? When cwd isn't a repository, «git grep foo ./bar»
> just errors out:
> .
> % ls
> iota
> % git grep This iota
> fatal: not a git repository (or any parent up to mount point /)
> Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not
> set).
> zsh: exit 128
>
> Does newer git behave differently? If not, shouldn't the behaviour be
> conditional on --no-index having been passed?
grep.fallbackToNoIndex
If set to true, fall back to git grep --no-index if git grep is executed
outside of a git repository. Defaults to false.
I guess if we want to be fancy we can check for this option / command
line switch, but it seems easier to just complete files in this
context since git can be configured to accept them here.
--
Mikael Magnusson
next prev parent reply other threads:[~2020-09-25 6:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-24 20:34 Guido Cella
2020-09-25 6:34 ` Daniel Shahaf
2020-09-25 6:49 ` Mikael Magnusson [this message]
2020-09-25 7:28 ` Daniel Shahaf
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=CAHYJk3Tg4pNf7H5ZP08cgB1ONH7D5dt3oLw-pWpHZ8sBF3xGHA@mail.gmail.com \
--to=mikachu@gmail.com \
--cc=d.s@daniel.shahaf.name \
--cc=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).