From: Stefan Kangas <stefan@marxist.se>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: 18481@debbugs.gnu.org, Emilio Lopes <eclig@gmx.net>
Subject: bug#18481: vc/vc-git.el: use `with-demoted-errors' instead of `ignore-errors'.
Date: Wed, 12 Aug 2020 10:06:21 -0700 [thread overview]
Message-ID: <CADwFkmnbfQbDki-qNQ1uwKEF2HGHzK+5dsSGDHuBfwVsCQMQnA@mail.gmail.com> (raw)
In-Reply-To: <87d0hmf6ko.fsf@mouse.gnus.org> (Lars Ingebrigtsen's message of "Sat, 03 Aug 2019 20:27:03 +0200")
Lars Ingebrigtsen <larsi@gnus.org> writes:
> Emilio Lopes <eclig@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@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
next prev parent reply other threads:[~2020-08-12 17:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-15 13:42 bug#18481: vc/vc-git.el: use `with-demoted-errors' instead of `ignore-errors' Emilio Lopes
2019-08-03 18:27 ` Lars Ingebrigtsen
2020-08-12 17:06 ` Stefan Kangas [this message]
2020-08-12 18:21 ` Dmitry Gutov
2020-08-13 8:02 ` Lars Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CADwFkmnbfQbDki-qNQ1uwKEF2HGHzK+5dsSGDHuBfwVsCQMQnA@mail.gmail.com \
--to=stefan@marxist.se \
--cc=18481@debbugs.gnu.org \
--cc=eclig@gmx.net \
--cc=larsi@gnus.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.