Skip to content

Discard git-rev-parse error messages in `ResolveRefish`

Patrick Steinhardt requested to merge pks-list-files-discard-errmsgs into master

To resolve references, we currently use git-rev-parse(1). It's totally expected that the executable may fail though, e.g. in the case where the reference simply doesn't exist. As such, we need to correctly cope with the error case.

One thing we don't handle nicely is error messages: as we don't provide stderr to commands.New() right now, the default stderr handler is in place. One thing this handler does is that it logs everything written to stderr as an error message. This can be extremely irritating when one inspects log messages, even more so as the failure mode of this command is in fact expected.

Fix the issue by passing ioutil.Discard as the stderr writer, which effectively discards all messages written to stderr.


This was found by @fjsanpedro. We first assumed that the ListFiles RPC was misbehavnig, which prompted me to improve test coverage as well as fix one bug in it.

Merge request reports