Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] _git-grep: Complete files when outside git repos
- X-seq: zsh-workers 47398
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: Guido Cella <guidocella91@xxxxxxxxx>
- Subject: Re: [PATCH] _git-grep: Complete files when outside git repos
- Date: Fri, 25 Sep 2020 06:34:11 +0000
- Archived-at: <https://zsh.org/workers/47398>
- Archived-at: <http://www.zsh.org/sympa/arcsearch_id/zsh-workers/2020-09/20200925063411.GD29504%40tarpaulin.shahaf.local2>
- Authentication-results: zsh.org; iprev=pass (out4-smtp.messagingengine.com) smtp.remote-ip=66.111.4.28; dkim=pass header.d=daniel.shahaf.name header.s=fm1 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm3 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none
- Cc: zsh-workers@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=date:from:to:cc:subject:message-id :references:mime-version:content-type:content-transfer-encoding :in-reply-to; s=fm1; bh=YcF652I765qxtx7yzu/l2ImOzxoUJcaAFP26IjDk Fbk=; b=eQwKQp8Iq3s08NN01NZRD0jb4T/lUIBImnmqx7oe4OgRYTCsmzjWt9EX kEe/DQaDsI72A6zEsJe/pViOzEig42NotpCkKQy9yAIQmIfg0AXp16lxXYSEiA/C pMHfbSeH/jxM1g/rE5mXl3uSJa8zCQgvv8fNQ2npJy3n+ksy4ViQnPcmjspQX6ob Xnu6oqAkMGiTpyyhZwD/vdJElJSqH+f5r04Inj7sncHv6tMDaVw226FnueaDJ9/T L3gZSqNFOlXdq3LpCzTvsLfXAvuflSr9p8ldyqpW/23y7CuOsyR7Eo5M/xvHrgR6 yfYRAtHE2BpJM6kv5BaGW6nkxPjvhw==
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=YcF652I765qxtx7yzu/l2ImOzxoUJcaAFP26IjDkF bk=; b=Qrl8jpfYQG7ywRYe3ACi8456BoeLm8wWx3/Rtsj40RciFmHuspzKRRscx 8n4F2a5QVfi7Tr8bDQ/8OYma8VLLPY3FH/X3kAY4HAAYFkFok8D2qD4o21/EgUvE E2y0Ui6MNrx6PJH960z70zJMk8lF0D3fGRC/ZfEQmacqvto09BSydTrs1oFee2J+ JC4ojgZHsKIvnsaurbyI8dQDLh+7wXq01Qi3dBVJvpV7fUdKuYHMGyH8HkEmNAdT VouwZd9i1w2kwvkdzG4ZVb4OHZEoIFh0tdOAkeRgs5MKtV4eir9TNaAO/YO9Mp0F FCq6DYv+AEd2wQLkWd4vJ7c2WlkFw==
- In-reply-to: <20200924203441.80963-1-guidocella91@gmail.com>
- List-archive: <http://www.zsh.org/sympa/arc/zsh-workers>
- List-help: <mailto:sympa@zsh.org?subject=help>
- List-id: <zsh-workers.zsh.org>
- List-owner: <mailto:zsh-workers-request@zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-subscribe: <mailto:sympa@zsh.org?subject=subscribe%20zsh-workers>
- List-unsubscribe: <mailto:sympa@zsh.org?subject=unsubscribe%20zsh-workers>
- References: <20200924203441.80963-1-guidocella91@gmail.com>
- Sender: zsh-workers-request@xxxxxxx
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?
> 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