From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.devel Subject: Re: A project-files implementation for Git projects Date: Tue, 1 Oct 2019 11:11:43 +0300 Message-ID: <17994e8f-9940-2da5-216e-20a5d3842822@yandex.ru> References: <8736h9rdc4.fsf@gnu.org> <87mufcfz1u.fsf@gnu.org> <87tv9kz2x6.fsf@gnu.org> <87a7bbjdwe.fsf@gnu.org> <87a7ba8uvx.fsf@gnu.org> <87pnk2zvvy.fsf@gnu.org> <87sgows6wy.fsf@gnu.org> <87ef0dy18z.fsf@gnu.org> <87impk675h.fsf@gnu.org> <874l13h30l.fsf@gnu.org> <7386ef98-c151-e1ce-23fa-11470a16f0d3@yandex.ru> <87h84x1zoa.fsf@gnu.org> <4be972f9-45a3-f2aa-f532-d7b8fbe054fd@yandex.ru> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------0595F1BD98A7979FBE344C54" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="10730"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Oct 01 10:12:04 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iFDGN-0002g9-Qh for ged-emacs-devel@m.gmane.org; Tue, 01 Oct 2019 10:12:03 +0200 Original-Received: from localhost ([::1]:59690 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iFDGM-0000oO-HN for ged-emacs-devel@m.gmane.org; Tue, 01 Oct 2019 04:12:02 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53993) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iFDGB-0000o0-6I for emacs-devel@gnu.org; Tue, 01 Oct 2019 04:11:52 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iFDGA-0006eG-1N for emacs-devel@gnu.org; Tue, 01 Oct 2019 04:11:51 -0400 Original-Received: from mail-lj1-x236.google.com ([2a00:1450:4864:20::236]:46868) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iFDG9-0006dn-ML for emacs-devel@gnu.org; Tue, 01 Oct 2019 04:11:49 -0400 Original-Received: by mail-lj1-x236.google.com with SMTP id d1so12295792ljl.13 for ; Tue, 01 Oct 2019 01:11:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:references:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=DTNun2PflO5WpLLozpcdxHBqpcreJm6I4Yc0ojHmQMY=; b=U2FR67SB8bKgoDuKIEw+h7uswHFswr5BrdvqJXn2fz3FpMd3P8w+s2wQn5LGjjsrCA 0yqHE3DazSpXu2jXbppUsI8cgVR9tyNVekbokauvvpRDcmTQZg6huJDjKeNwG8mHBciE yABysjAK/u4yLCe/XYZyN2JE2+gtxtapURGFD95RL0D17oFYMMA6lsvIkrc+MCrwINcl E13/HHppQ0okoqILbHiItJfIl6ZFGsQgNnAUQE746cT27HTvhmFB3OTauqWVbzM8jDS7 /iAVm4LuTYvdHBRAw1lH4dUo/EweSBWCFwMuZ4AS7T02q5dnNFupzISkft6AX971u1PH 5nLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:references:message-id :date:user-agent:mime-version:in-reply-to:content-language; bh=DTNun2PflO5WpLLozpcdxHBqpcreJm6I4Yc0ojHmQMY=; b=gYk1ZO+t3jBF/P9S7F48OeDV8C98QZmvJlSBsVeMCKIKafGdCsaZke/1wgQfxgcbNI db3zJt0U81HccG9r7ntTd3jAgZcMp5SdG3SAToHuChp+YdenoqRsY0Q4HPmIfN4t9s/O gUwVYSniMN7aPNdde+oZP0joZKbXBbsUKWHwwaGTXee2kY0Y5riaevIfWKOwhgjyKIME EDEM1Co7ZwT/XK+vmcmwuJ15dTS8Zro8wkN3/cXFshl+VpIOuxv5h8XPoQH8VEfWymJK yCrmglruiyQhSy5s7hZ15+tl2tLYul/qkfJ33ZfyEQvBFPCj/pgYEocUH8gGohCa0Aww AiXQ== X-Gm-Message-State: APjAAAUMRT7CWDQ1a7nw8iWHuWvaDHu5GV/g6aye1crgYH4rbcwGpUE+ /ftaAG/bck43KqfcK1qrXyKstghx4Oc= X-Google-Smtp-Source: APXvYqyJcEzbpV0gbxKxJTU/xIHgtJne8dK25CaItBMiq5WJKsuw3saQ68pMEtGnk1qkNGrtbjfxJg== X-Received: by 2002:a2e:924f:: with SMTP id v15mr14887375ljg.199.1569917507535; Tue, 01 Oct 2019 01:11:47 -0700 (PDT) Original-Received: from [192.168.10.4] (62-201-46.netrun.cytanet.com.cy. [62.228.201.46]) by smtp.googlemail.com with ESMTPSA id y3sm3905522lji.53.2019.10.01.01.11.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Oct 2019 01:11:46 -0700 (PDT) In-Reply-To: <4be972f9-45a3-f2aa-f532-d7b8fbe054fd@yandex.ru> Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::236 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:240419 Archived-At: This is a multi-part message in MIME format. --------------0595F1BD98A7979FBE344C54 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Here's an updated patch. - project--vc-list-files now has '--' in its name. - Turns out that sometimes Git repositories include symlinks, and even broken ones. Grep, subsequently, chokes on those with "file not found", so we now suppress all "not found" messages from Grep. --------------0595F1BD98A7979FBE344C54 Content-Type: text/x-patch; name="vc-list-files.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="vc-list-files.diff" diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 4693d07fa8..4556c0bdb9 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -277,6 +277,67 @@ project-try-vc (funcall project-vc-external-roots-function))) (project-roots project))) +(cl-defmethod project-files ((project (head vc)) &optional dirs) + (cl-mapcan + (lambda (dir) + (let (backend) + (if (and (file-equal-p dir (cdr project)) + (setq backend (vc-responsible-backend dir)) + nil + (cond + ((eq backend 'Hg)) + ((and (eq backend 'Git) + (or + (not project-vc-ignores) + (version<= "1.9" (vc-git--program-version))))))) + (project--vc-list-files dir backend project-vc-ignores) + (project--files-in-directory + dir + (project--dir-ignores project dir))))) + (or dirs (project-roots project)))) + +(defun project--vc-list-files (dir backend extra-ignores) + (pcase backend + (`Git + (let ((default-directory dir) + (args '("-z"))) + (when t ;include-unregistered + (setq args (append args '("-c" "-o" "--exclude-standard")))) + (when extra-ignores + (setq args (append args + (cons "--" + (mapcar + (lambda (i) + (if (string-match "\\./" i) + (format ":!/:%s" (substring i 2)) + (format ":!:%s" i))) + extra-ignores))))) + (mapcar + #'expand-file-name + (split-string + (apply #'vc-git--run-command-string nil "ls-files" args) + "\0" t)))) + (`Hg + (let ((default-directory dir) + args + files) + (when t ;include-unregistered + (setq args (nconc args '("--all")))) + (when extra-ignores + (setq args (nconc args + (mapcan + (lambda (i) + (list "--exclude" i)) + (copy-list extra-ignores))))) + (with-temp-buffer + (apply #'vc-hg-command t 0 "." + "status" args) + (goto-char (point-min)) + (while (re-search-forward "^[?C]\s+\\(.*\\)$" nil t) + (setq files (cons (expand-file-name (match-string 1)) + files)))) + (nreverse files))))) + (cl-defmethod project-ignores ((project (head vc)) dir) (let* ((root (cdr project)) backend) @@ -391,7 +452,7 @@ project--find-regexp-in-files (status nil) (hits nil) (xrefs nil) - (command (format "xargs -0 grep %s -nHE -e %s" + (command (format "xargs -0 grep %s -snHE -e %s" (if (and case-fold-search (isearch-no-upper-case-p regexp t)) "-i" --------------0595F1BD98A7979FBE344C54--