From unknown Sun Sep 21 01:06:59 2025 X-Loop: help-debbugs@gnu.org Subject: bug#19944: 25.0.50; vc-git-grep doesn't use grep-read-files correctly Resent-From: Rupert Swarbrick Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 25 Feb 2015 11:40:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 19944 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 19944@debbugs.gnu.org X-Debbugs-Original-To: Received: via spool by submit@debbugs.gnu.org id=B.142486439315034 (code B ref -1); Wed, 25 Feb 2015 11:40:02 +0000 Received: (at submit) by debbugs.gnu.org; 25 Feb 2015 11:39:53 +0000 Received: from localhost ([127.0.0.1]:57362 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YQaJk-0003uQ-R7 for submit@debbugs.gnu.org; Wed, 25 Feb 2015 06:39:53 -0500 Received: from eggs.gnu.org ([208.118.235.92]:45127) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YQaJi-0003u8-CQ for submit@debbugs.gnu.org; Wed, 25 Feb 2015 06:39:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YQaJc-0002dH-1M for submit@debbugs.gnu.org; Wed, 25 Feb 2015 06:39:45 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:52969) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQaJb-0002dC-Ug for submit@debbugs.gnu.org; Wed, 25 Feb 2015 06:39:43 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46831) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQaJa-0003c1-Gl for bug-gnu-emacs@gnu.org; Wed, 25 Feb 2015 06:39:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YQaJX-0002ak-7h for bug-gnu-emacs@gnu.org; Wed, 25 Feb 2015 06:39:42 -0500 Received: from mail-gw1-out.broadcom.com ([216.31.210.62]:11420) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQaJW-0002aM-Ux for bug-gnu-emacs@gnu.org; Wed, 25 Feb 2015 06:39:39 -0500 X-IronPort-AV: E=Sophos;i="5.09,644,1418112000"; d="scan'208";a="58123883" Received: from irvexchcas08.broadcom.com (HELO IRVEXCHCAS08.corp.ad.broadcom.com) ([10.9.208.57]) by mail-gw1-out.broadcom.com with ESMTP; 25 Feb 2015 06:09:10 -0800 Received: from IRVEXCHSMTP2.corp.ad.broadcom.com (10.9.207.52) by IRVEXCHCAS08.corp.ad.broadcom.com (10.9.208.57) with Microsoft SMTP Server (TLS) id 14.3.174.1; Wed, 25 Feb 2015 03:39:25 -0800 Received: from mail-irva-13.broadcom.com (10.10.10.20) by IRVEXCHSMTP2.corp.ad.broadcom.com (10.9.207.52) with Microsoft SMTP Server id 14.3.174.1; Wed, 25 Feb 2015 03:39:24 -0800 Received: from xl-cam-20.broadcom.com (xl-cam-20.cam.broadcom.com [10.177.132.80]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id 4FE0540FE8 for ; Wed, 25 Feb 2015 03:38:16 -0800 (PST) Received: by xl-cam-20.broadcom.com (Postfix, from userid 35990) id F0AEC180712; Wed, 25 Feb 2015 11:39:23 +0000 (GMT) From: Rupert Swarbrick Date: Wed, 25 Feb 2015 11:39:23 +0000 Message-ID: <889lhjmb4pg.fsf@broadcom.com> MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) The vc-git-grep function uses grep-read-files to figure out the list of files to check. This gets glued to the end of the git grep command line. With the default value of grep-files-aliases, if the user enters "all" for their files, grep-read-files returns the string "* .*". If you do the following: cd /path/to/my/git/repo git grep foo -- * .* then you get something like: /path/to/my/git/repo> git grep foo -- * .* fatal: ..: '..' is outside repository because .* expands to a list including "..". Now, the code in vc-git-grep constructs a string that looks basically like the above. If you run vc-git-grep in the top-level directory of a git repository and select "all" for file type then it errors out because of this problem. I did wonder whether this was a bug in grep.el, but it isn't: grep-read-files seems to be used only in "grep" and "lgrep", which construct commands like grep -nH foo * .* Since the grep invocation is non-recursive, this isn't a problem. If you run rgrep, it generates something more like find -name | grep and doesn't seem to use grep-read-files at all. We're also doing the wrong thing when the user gives a pattern. For example, if I go into the top-level Emacs directory and run M-x vc-git-grep enter vc-git-grep as the string to search for and enter *g* for the files to search, then I get: Grep started at Wed Feb 25 11:17:28 git --no-pager grep -n -e vc-git-grep -- *g* Grep finished with no matches found at Wed Feb 25 11:17:28 If I type '*g*' instead, I get: git --no-pager grep -n -e vc-git-grep -- '*g*' lisp/ChangeLog:16437: * vc/vc-git.el (vc-git-grep): Disable pager. lisp/ChangeLog.14:16592: (vc-git-extra-menu, vc-git-extra-status-menu, vc-git-grep): lisp/ChangeLog.16:18483: * vc/vc-git.el (vc-git-grep): Remove --no-color. (Bug#9408) lisp/ChangeLog.16:18484: (vc-git-grep): Prepend "PAGER=" to `compilation-environment' lisp/ChangeLog.16:18662: * vc/vc-git.el (vc-git-grep): Use --no-color. (Bug#9408) lisp/vc/vc-git.el:1124: '(menu-item "Git grep..." vc-git-grep lisp/vc/vc-git.el:1152:(defun vc-git-grep (regexp &optional files dir) Grep finished (matches found) at Wed Feb 25 11:18:17 (The strange looking pattern is so that there would be a match for the shell glob in the top level directory to make sure it got expanded: if I'd typed *.el, things would have worked as expected because there are no elisp files in the top-level Emacs directory) One possible fix is to write a vc-git-grep-read-files function that behaves very similarly to grep-read-files, but overrides some of the mapping with a vc-git-grep-files-aliases variable. That should be an alist that contains at least '("all" . "") by default. If it successfully looked up something in the dictionary, the function would then split on spaces and then shell quote each resulting word. If the result isn't from a dictionary lookup, an easy approach is to do the same thing: split on spaces and then quote. This lets the user enter something like *.c *.h and have the right thing happen. It doesn't allow the user to enter 'with a space.*' but maybe we don't care. Rupert In GNU Emacs 25.0.50.1 (x86_64-unknown-linux-gnu, X toolkit, Xaw scroll bars) of 2015-02-09 on lc-cam-077 Repository revision: 2f7008715326a49770fcb82003ed78eab28c0626 Windowing system distributor `The X.Org Foundation', version 11.0.11300000 System Description: Red Hat Enterprise Linux Server release 6.4 (Santiago) Configured using: `configure --prefix=/snipped/ --with-xml2 --without-sound --without-rsvg --without-imagemagick --with-x-toolkit=lucid' Configured features: XPM JPEG TIFF GIF PNG GPM DBUS GCONF NOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE XFT ZLIB [Rest snipped: it's not relevant to this bug report] From unknown Sun Sep 21 01:06:59 2025 X-Loop: help-debbugs@gnu.org Subject: bug#19944: 25.0.50; vc-git-grep doesn't use grep-read-files correctly Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 03 Dec 2020 11:51:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 19944 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Rupert Swarbrick Cc: 19944@debbugs.gnu.org Received: via spool by 19944-submit@debbugs.gnu.org id=B19944.160699622718470 (code B ref 19944); Thu, 03 Dec 2020 11:51:01 +0000 Received: (at 19944) by debbugs.gnu.org; 3 Dec 2020 11:50:27 +0000 Received: from localhost ([127.0.0.1]:38737 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kkn7z-0004np-3L for submit@debbugs.gnu.org; Thu, 03 Dec 2020 06:50:27 -0500 Received: from quimby.gnus.org ([95.216.78.240]:45490) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kkn7w-0004nZ-Ob for 19944@debbugs.gnu.org; Thu, 03 Dec 2020 06:50:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=MH3B6ugpa7etEwjjpIplxIcvQomqMRtia05hD2+RsRA=; b=deQWondUKx1LdkUS6aD7C0JzcN rmaiUBjHtNQrUMZEDeAKblD6TfhlaYglq2Cypjd5RfcaTakw7DDVGofySFBcR8Bmvlm4ESQq1+VTF qKCFrqnVsNKMW+X8HveHVtE4JFJhcY9CjPdJt4PdAj5c/E99qwhC9f9hkb3noXjRATnw=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kkn7n-00032V-Lz; Thu, 03 Dec 2020 12:50:18 +0100 From: Lars Ingebrigtsen References: <889lhjmb4pg.fsf@broadcom.com> X-Now-Playing: Portishead's _Only You_: "Only You (Edit)" Date: Thu, 03 Dec 2020 12:50:14 +0100 In-Reply-To: <889lhjmb4pg.fsf@broadcom.com> (Rupert Swarbrick's message of "Wed, 25 Feb 2015 11:39:23 +0000") Message-ID: <87y2ifqfbd.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Rupert Swarbrick writes: > The vc-git-grep function uses grep-read-files to figure out the list of > files to check. This gets glued to the end of the git grep command > line. With the default value of grep-files-aliases, if [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Rupert Swarbrick writes: > The vc-git-grep function uses grep-read-files to figure out the list of > files to check. This gets glued to the end of the git grep command > line. With the default value of grep-files-aliases, if the user enters > "all" for their files, grep-read-files returns the string "* .*". > > If you do the following: > > cd /path/to/my/git/repo > git grep foo -- * .* > > then you get something like: > > /path/to/my/git/repo> git grep foo -- * .* > fatal: ..: '..' is outside repository > > because .* expands to a list including "..". (This bug report unfortunately got no response at the time.) Looks like this has been fixed in more recent versions of Emacs. Trying this, I get: git --no-pager grep -n --color -i -e emacs -- \* .\[\!.\]\* ..\?\* and everything works are it should, I think. > We're also doing the wrong thing when the user gives a pattern. For > example, if I go into the top-level Emacs directory and run > > M-x vc-git-grep > > enter vc-git-grep as the string to search for and enter *g* for the > files to search, then I get: > > Grep started at Wed Feb 25 11:17:28 > > git --no-pager grep -n -e vc-git-grep -- *g* This, too -- I get: git --no-pager grep -n --color -i -e emacs -- \*g\* So I'm guessing this has been fixed, and I'm closing this bug report. If there's still a problem here, please respond to the debbugs address, and we'll reopen the bug report. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 03 06:50:31 2020 Received: (at control) by debbugs.gnu.org; 3 Dec 2020 11:50:31 +0000 Received: from localhost ([127.0.0.1]:38740 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kkn83-0004o6-Bt for submit@debbugs.gnu.org; Thu, 03 Dec 2020 06:50:31 -0500 Received: from quimby.gnus.org ([95.216.78.240]:45514) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kkn82-0004nn-Ny for control@debbugs.gnu.org; Thu, 03 Dec 2020 06:50:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Subject:From:To:Message-Id:Date:Sender:Reply-To:Cc: MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=hJw7avbBHxZRjrU8t5c+l9sbrySw+ydDwm6N3Xvw8Ak=; b=hopTibcqlvKeuIEhH8G9VdxkkR nqwOxBBoWiNxQl6ROwoYr0nfBz2cisu7QPUNDYeQpelPCBtq9QTELzyemyGOETMfe3AWKq/H0VXEA RTh5vA7ADcXVWI2Ndp1x7ma/paF0zNSJFfEUe3XmQJSosJp7CLZzyz7n8GrOXCAMGU0s=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kkn7u-00032d-Ug for control@debbugs.gnu.org; Thu, 03 Dec 2020 12:50:25 +0100 Date: Thu, 03 Dec 2020 12:50:22 +0100 Message-Id: <87wnxzqfb5.fsf@gnus.org> To: control@debbugs.gnu.org From: Lars Ingebrigtsen Subject: control message for bug #19944 X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: close 19944 quit Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) close 19944 quit