bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#31497: 27.0.50; vc-hg doesn't separate standard error from standard


From: Lars Ingebrigtsen
Subject: bug#31497: 27.0.50; vc-hg doesn't separate standard error from standard output
Date: Wed, 09 Oct 2019 23:57:15 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Philipp Stephani <p.stephani2@gmail.com> writes:

> Create a Mercurial repository owned by root and add a hgrc file, e.g.:
>
> $ mkdir -p /tmp/hg
> $ cd /tmp/hg
> $ sudo -s
> # hg init
> # echo a > a.txt
> # hg addremove
> # hg commit -m 'commit message'
> # touch .hg/hgrc
>
> Then visit a.txt in Emacs as non-root:
>
> $ emacs -Q a.txt
>
> Instead of the revision number, the status line will show
> "Hg-not trusting file /tmp/hg/.hg/hgrc ..."
>
> This is because the status line runs something like
>
> $ hg log -l 1 -r . -T '{rev}'
>
> but that outputs
>
>   not trusting file /tmp/hg/.hg/hgrc from untrusted user root, group root
>   not trusting file /tmp/hg/.hg/hgrc from untrusted user root, group root
>
> on stderr, and Emacs merges stderr and stdout.  Rather it should ignore
> stderr in this case.

I can confirm that this bug is still present in Emacs 27.  The command
is started from vc-doc-command, which uses start-file-process, which
uses start-process, which doesn't even allow separating stderr from
stdin.

(In general, Emacs stderr/stdin handling is very frustrating.)

Would it make sense to alter this function

(defun vc-hg--run-log (template rev path)
  (ignore-errors
    (with-output-to-string
      (if path
          (vc-hg-command
           standard-output 0 nil
           "log" "-f" "-l1" "--template" template path)
        (vc-hg-command
         standard-output 0 nil
         "log" "-r" rev "-l1" "--template" template)))))

to filter out the "not trusting" lines, or is this just one of a
gazillion error messages that can be output here?

not trusting file /tmp/hg/.hg/hgrc from untrusted user root, group root
not trusting file /tmp/hg/.hg/hgrc from untrusted user root, group root
4d872e

I though perhaps we could redirect the error output with "-E", but "hg
log" doesn't seem to support that.

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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]