From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Kangas Newsgroups: gmane.emacs.bugs Subject: bug#18481: vc/vc-git.el: use `with-demoted-errors' instead of `ignore-errors'. Date: Wed, 12 Aug 2020 10:06:21 -0700 Message-ID: References: <87d0hmf6ko.fsf@mouse.gnus.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21152"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 18481@debbugs.gnu.org, Emilio Lopes To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Aug 12 19:07:14 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k5uDZ-0005NY-OV for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 12 Aug 2020 19:07:13 +0200 Original-Received: from localhost ([::1]:50902 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k5uDY-0002nq-Oq for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 12 Aug 2020 13:07:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52788) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5uDO-0002lq-Rk for bug-gnu-emacs@gnu.org; Wed, 12 Aug 2020 13:07:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:33870) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k5uDO-0007qb-IG for bug-gnu-emacs@gnu.org; Wed, 12 Aug 2020 13:07:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1k5uDO-000349-DM for bug-gnu-emacs@gnu.org; Wed, 12 Aug 2020 13:07:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Kangas Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 12 Aug 2020 17:07:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 18481 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 18481-submit@debbugs.gnu.org id=B18481.159725199111746 (code B ref 18481); Wed, 12 Aug 2020 17:07:02 +0000 Original-Received: (at 18481) by debbugs.gnu.org; 12 Aug 2020 17:06:31 +0000 Original-Received: from localhost ([127.0.0.1]:45416 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k5uCs-00033O-H1 for submit@debbugs.gnu.org; Wed, 12 Aug 2020 13:06:30 -0400 Original-Received: from mail-yb1-f193.google.com ([209.85.219.193]:43597) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k5uCp-00032r-9f for 18481@debbugs.gnu.org; Wed, 12 Aug 2020 13:06:29 -0400 Original-Received: by mail-yb1-f193.google.com with SMTP id m200so1732966ybf.10 for <18481@debbugs.gnu.org>; Wed, 12 Aug 2020 10:06:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:in-reply-to:references:user-agent :mime-version:date:message-id:subject:to:cc; bh=mmt5G/wlXQZFNrNCO6DHlj764Ck4plIW4IOd6URZ1ho=; b=r1ZWYCptj1YW10oji0WBwTrhpqzIM42gu5pTIBMMdrfWu8MgDjdCLwoVyUKCFDxgkj da3hbhPzv5mkKLyr9gNOlWgEd1lE9+/PU4HNTg/EDEFxX71GPGsyxcdNcVjuEEnyeS34 FTb3EnrtbfaWoEI0soI9RxF5Qkc+viqc1zAzkhaJiAEcbvf6IuLaAszFajgyfNRra0mS 4O55rGZXVp2xZ8qJnQyGNhG5xLEHIOChv/+UDt4kcAhw6aQegrayNd6w9TsroHn3RgWN rw6IgyWoc5D5+y1ZN+QfXFUnmRBVzV3mk5ZIMA9VpeWKl0OzjLQ5+1JfVcp+HgU+A8dS 7oPA== X-Gm-Message-State: AOAM5329SMJNoI4jigYM7BOqWp+kdKwg3IcDWHWrwD8DtBV0itTut8lV 0QVDL50juprbYJHe7FS8wdGpI2E9bNmVWfhLZLw= X-Google-Smtp-Source: ABdhPJwm47iBm62ytKXJkqcNeC8KNF1ULnrD/LcpYcOBo89CWrV1zQzFtPjZYO0s6xJ+7uIa8cuXZeFznsDYj+xXOyo= X-Received: by 2002:a25:880e:: with SMTP id c14mr448670ybl.181.1597251981895; Wed, 12 Aug 2020 10:06:21 -0700 (PDT) Original-Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Wed, 12 Aug 2020 10:06:21 -0700 In-Reply-To: <87d0hmf6ko.fsf@mouse.gnus.org> (Lars Ingebrigtsen's message of "Sat, 03 Aug 2019 20:27:03 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:184845 Archived-At: Lars Ingebrigtsen writes: > Emilio Lopes writes: > >> cf. http://lists.gnu.org/archive/html/bug-gnu-emacs/2014-09/msg00394.html >> >> --- lisp/ChangeLog 2014-09-15 00:20:21 +0000 >> +++ lisp/ChangeLog 2014-09-15 13:36:10 +0000 >> @@ -1,3 +1,14 @@ >> +2014-09-15 Emilio C. Lopes >> + >> + * vc/vc-git.el (vc-git-registered): use `with-demoted-errors' >> + instead of `ignore-errors' so that the user is informed if >> + something unexpected happens. > > (I'm going through old bug reports that unfortunately have not received > any responses yet.) > > So, in that URL Stefan suggested using with-demoted-errors instead of > ignore-errors here, and that seems sensible. But I'm wondering whether > this code is expected to fail, and whether the errors (in that case) are > totally uninteresting? > > I've done some testing (without the `ignore-errors'), and in my tests > the code doesn't fail, so I think the patch suggested makes sense. > > Does this patch makes sense to everybody else, too? I'm not a heavy user of vc, but FWIW it seems to me that it should be safe enough to catch fewer errors. Maybe we could just install it and see what blows up, if the patch works for you... > (defun vc-git-registered (file) > "Check whether FILE is registered with git." > (let ((dir (vc-git-root file))) > (when dir > (with-temp-buffer > (let* (process-file-side-effects > ;; Do not use the `file-name-directory' here: git-ls-files > ;; sometimes fails to return the correct status for relative > ;; path specs. > ;; See also: http://marc.info/?l=git&m=125787684318129&w=2 > (name (file-relative-name file dir)) > (str (ignore-errors > (cd dir) > (vc-git--out-ok "ls-files" "-c" "-z" "--" name) > ;; If result is empty, use ls-tree to check for deleted > ;; file. > (when (eq (point-min) (point-max)) > (vc-git--out-ok "ls-tree" "--name-only" "-z" "HEAD" > "--" name)) > (buffer-string)))) > (and str > (> (length str) (length name)) > (string= (substring str 0 (1+ (length name))) > (concat name "\0")))))))) > > >> ;; path specs. >> ;; See also: http://marc.info/?l=git&m=125787684318129&w=2 >> (name (file-relative-name file dir)) >> - (str (ignore-errors >> + (str (with-demoted-errors "Error: %S" >> (cd dir) >> (vc-git--out-ok "ls-files" "-c" "-z" "--" name) >> ;; If result is empty, use ls-tree to check for deleted Best regards, Stefan Kangas