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,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 28417 invoked from network); 25 Sep 2020 07:28:41 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 25 Sep 2020 07:28:41 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1601018921; b=WOj130ApluQSP5pUvS5E+gPJD+BVHSCPgPPe2W6Ub7LdTNrdRO0FC+/S/gBG+8nQIZFLi8tis3 GR6Dm7tSRi4bFQi89Hq7FkAM4ipGHEXNF0pjXwTCUsDXBJ0UzD7A7foD7Xo44o4zvP1LCj0g11 GjSn4tts9yvCPQ1Kx79gavvx5FYJXzFCFm1vwES+umlj+eh5xQnM/enPL5okbam0xixE9SIqBY sRS8donI5x6zueu2elhqX5e6KEsorhw6MBpPZ94tVJytAvyupEpg7l5pMEY7Tw40Y3BKdusuKX AyrtZMB5yvwka1hzoInXyuUDoGFbUksdIHQ0ljiQMq4jjA==; ARC-Authentication-Results: i=1; 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1601018921; bh=PZBkTdwYH6AmJVj7vQmp+/OOy/qkCQxgvHsYV1NXrnY=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:Subject:Cc:To:From: Date:References:In-Reply-To:Message-ID:MIME-Version:DKIM-Signature: DKIM-Signature:DKIM-Signature; b=jIAOGTP3hYF/EbwuisUcFpVcJK4IaemlihNy46AV3nNttBikklJ/n0chfKDR8D+EaUR3v1XFbz w8tOJBXCJLUjBqPRnPs8a7TkYFlQ0eVhllQe5Gh2CEPX4Tgp3UFEvgOjuA560r78z3MtUhABY5 bJJ3CzvrelbHtjqTEdWZeIHBdJb5SkWCTTTZILve/7pxiQIkRTk/cvS1WQwj76hn6+Jbnm9wY8 hPZeQ11kF+XV6aYaX8O/yleuVDkV/DxFdw5CIEpH1Mm2JtmsPAIPFtOHZDxdKB4K2e5hyjJP5K uYO1WUfQaGu8yQoBM0FekCMLk1OOiCB87xKn4LNKTGsFSw==; 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: Content-Type:Subject:Cc:To:From:Date:References:In-Reply-To:Message-Id: Mime-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=uhTE5/6VN2XKDX4pyjpRWwN3g38DSvvuYtUZV44Rz+w=; b=thdViEfAEr13qFCQQ+nTXfMSfX EXRcJCd5xB7yGtCpude3GAkBUy3feowwj/66PkDigaJ2PXRQeYC2AcUEbWPdFml480+MKdqhD1mbf axi6pAaYSjrVTMJ8AQik6HAk1IfG1vvHoChiKM9kCBmwQyCSPLM7wN3U/pgAnTTBKNjidoveXj/11 V2Te2I2sGNOIzD9wK5/Ckt6D0gNkf+0a5VAzdsl6Zlsu3nyyI59vfSxYvoEldGIXTE5Ei4fFECDGp i0oCQeQLLxJUET1eNykR9JuRArTkFyOp9P8qmnOoSH98iAYe2e2lbk7F9I9v1fxFr/CHukE/42TLe 57TJxK3g==; Received: from authenticated user by zero.zsh.org with local id 1kLi9p-000H4r-Dr; Fri, 25 Sep 2020 07:28:41 +0000 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 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:40565) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1kLi9Z-000Gvr-9N; Fri, 25 Sep 2020 07:28:26 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 669595C017E; Fri, 25 Sep 2020 03:28:24 -0400 (EDT) Received: from imap37 ([10.202.2.87]) by compute4.internal (MEProxy); Fri, 25 Sep 2020 03:28:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=mime-version:message-id:in-reply-to :references:date:from:to:cc:subject:content-type :content-transfer-encoding; s=fm1; bh=uhTE5/6VN2XKDX4pyjpRWwN3g3 8DSvvuYtUZV44Rz+w=; b=l1t5dlhWTyZE483FwaD1GWrOdyQwjEITtk4GrT0Gxs pfMO0iSxyMQyH3S6cdKO/IzxOdDdlnQG9sLAOlL02UV8Hzgo4Jf34CWr7YV1QmtZ ziUEWgq02dM+6QVfNMvRtqEbBGqKtmD0e2/Exhdv3hsHuWqKKTAWqyyeibaq6W0Z Vr6+pbB42vY1EnBXXdEyWRP/4uOSBDrjqWvGDH0O8+U+jIWVQ3DufEC8D1wtCkwy /lnN7XrYDPmQBa+knmK78UNCTqhrZkh9LhnxbC0aD/riuYx6cRjRdHZlHerofKRA vj4hlKPkdPRhdG1e4wKjQJmk95GkLjaWW52Qd1WJX8/A== 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=uhTE5/6VN2XKDX4pyjpRWwN3g38DSvvuYtUZV44Rz +w=; b=ui/xMfdU/SYHESmZ4QDy9LUNz/1lmKA+/yJFaCW6hPKadSQjxrtIAMsu1 hQQMVGbwW8/5FJ6zvP4BBhw1o5J7d1F5ajizRP+t1SkK3bDODshA4JVX2AQJciJm VtVBQskDfk+MBAqm7Dj+qBN8Hl6EsDAPreRQ0s3Z0DdKbyE9ZKW5yiK/bvrmCvRW ch6Kd3eUpydwNETStZA1aDVAYB1vUGLOw9776o2DTcbE/eP7wKOEiNVV/oKLTWgc sYrJbkRTtCuyvHF0L9HWtqzXZkgzAuLrwGKCcYrvCbavfp0ovhpPmOBSm8dVY0Bd rTHs6ciCXLIymsQEn0z9LcCrlqAIg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrudelgdduudehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgfgsehtqhertderreejnecuhfhrohhmpedfffgr nhhivghlucfuhhgrhhgrfhdfuceougdrshesuggrnhhivghlrdhshhgrhhgrfhdrnhgrmh gvqeenucggtffrrghtthgvrhhnpeefhfekfeevieelleehiefftdekudejledvhfdtjedt geegvdeuffefleehhfdvgfenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpegurdhssegurghnihgvlhdrshhhrghhrghfrdhnrghmvg X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id D7D9C190006D; Fri, 25 Sep 2020 03:28:23 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.3.0-355-g3ece53b-fm-20200922.004-g3ece53b9 Mime-Version: 1.0 Message-Id: <810e70b7-18c3-4f75-adfd-4ec7da540849@www.fastmail.com> In-Reply-To: References: <20200924203441.80963-1-guidocella91@gmail.com> <20200925063411.GD29504@tarpaulin.shahaf.local2> Date: Fri, 25 Sep 2020 07:28:03 +0000 From: "Daniel Shahaf" To: "Mikael Magnusson" Cc: "Guido Cella" , zsh-workers@zsh.org Subject: Re: [PATCH] _git-grep: Complete files when outside git repos Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Seq: 47400 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: Mikael Magnusson wrote on Fri, 25 Sep 2020 06:49 +00:00: > On 9/25/20, Daniel Shahaf 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=3D0 > >> + return ret > >> + fi > > > > Why is this correct? When cwd isn't a repository, =C2=ABgit grep fo= o ./bar=C2=BB > > 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? >=20 > grep.fallbackToNoIndex > If set to true, fall back to git grep --no-index if git grep is ex= ecuted > outside of a git repository. Defaults to false. >=20 > [...] it seems easier to just complete files in this > context since git can be configured to accept them here. Fair enough. In this case, the patch should be revised to use _call_program (and possibly discard stdout?). > I guess if we want to be fancy we can check for this option / command > line switch, [...] If we wanted to be fancy, we'd parse the output of `git config --null` into an associative array at the top of _git, so all _git-foo() functions would be able to check such things cheaply. (May want to make= this conditional on some opt-in style for performance reasons?) Cheers, Daniel