GNU bug report logs - #18481
vc/vc-git.el: use `with-demoted-errors' instead of `ignore-errors'.

Previous Next

Package: emacs;

Reported by: Emilio Lopes <eclig <at> gmx.net>

Date: Mon, 15 Sep 2014 13:43:01 UTC

Severity: minor

Tags: fixed, patch

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 18481 in the body.
You can then email your comments to 18481 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#18481; Package emacs. (Mon, 15 Sep 2014 13:43:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Emilio Lopes <eclig <at> gmx.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 15 Sep 2014 13:43:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Emilio Lopes <eclig <at> gmx.net>
To: bug-gnu-emacs <at> gnu.org
Subject: vc/vc-git.el: use `with-demoted-errors' instead of `ignore-errors'.
Date: Mon, 15 Sep 2014 15:42:25 +0200
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  <eclig <at> gmx.net>
+
+    * 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.
+
 2014-09-15  Glenn Morris  <rgm <at> gnu.org>

     * image.el (image-multi-frame-p): Fix thinko - do not force

=== modified file 'lisp/vc/vc-git.el'
--- lisp/vc/vc-git.el    2014-09-04 16:34:45 +0000
+++ lisp/vc/vc-git.el    2014-09-15 13:36:10 +0000
@@ -185,7 +185,7 @@
                ;; 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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18481; Package emacs. (Sat, 03 Aug 2019 18:28:03 GMT) Full text and rfc822 format available.

Message #8 received at 18481 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Emilio Lopes <eclig <at> gmx.net>
Cc: 18481 <at> debbugs.gnu.org
Subject: Re: bug#18481: vc/vc-git.el: use `with-demoted-errors' instead of
 `ignore-errors'.
Date: Sat, 03 Aug 2019 20:27:03 +0200
Emilio Lopes <eclig <at> gmx.net> 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  <eclig <at> gmx.net>
> +
> +    * 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?

(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


-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) patch. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sat, 03 Aug 2019 18:28:04 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18481; Package emacs. (Wed, 12 Aug 2020 17:07:02 GMT) Full text and rfc822 format available.

Message #13 received at 18481 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefan <at> marxist.se>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 18481 <at> debbugs.gnu.org, Emilio Lopes <eclig <at> gmx.net>
Subject: Re: bug#18481: vc/vc-git.el: use `with-demoted-errors' instead of
 `ignore-errors'.
Date: Wed, 12 Aug 2020 10:06:21 -0700
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Emilio Lopes <eclig <at> gmx.net> 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  <eclig <at> gmx.net>
>> +
>> +    * 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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18481; Package emacs. (Wed, 12 Aug 2020 18:22:02 GMT) Full text and rfc822 format available.

Message #16 received at 18481 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Stefan Kangas <stefan <at> marxist.se>, Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 18481 <at> debbugs.gnu.org, Emilio Lopes <eclig <at> gmx.net>
Subject: Re: bug#18481: vc/vc-git.el: use `with-demoted-errors' instead of
 `ignore-errors'.
Date: Wed, 12 Aug 2020 21:21:36 +0300
On 12.08.2020 20:06, Stefan Kangas wrote:
> 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..

Yup.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18481; Package emacs. (Thu, 13 Aug 2020 08:03:01 GMT) Full text and rfc822 format available.

Message #19 received at 18481 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: 18481 <at> debbugs.gnu.org, Stefan Kangas <stefan <at> marxist.se>,
 Emilio Lopes <eclig <at> gmx.net>
Subject: Re: bug#18481: vc/vc-git.el: use `with-demoted-errors' instead of
 `ignore-errors'.
Date: Thu, 13 Aug 2020 10:02:33 +0200
Dmitry Gutov <dgutov <at> yandex.ru> writes:

> On 12.08.2020 20:06, Stefan Kangas wrote:
>> 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..
>
> Yup.

OK, I've now done this.  And if it gets annoying in some use cases, the
patch should be reverted.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Thu, 13 Aug 2020 08:04:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 28.1, send any further explanations to 18481 <at> debbugs.gnu.org and Emilio Lopes <eclig <at> gmx.net> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Thu, 13 Aug 2020 08:04:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 10 Sep 2020 11:24:14 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 200 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.