On Sat, Apr 2, 2022 at 11:15 AM Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> wrote: > On Fri, Apr 01 2022, Shaoxuan Yuan wrote: > > I actually did use advise(), but I noticed that it prints to stderr > > and ... nevermind, > > We've typically used stderr in git not to mean "error", but to > distinguish "chatty" and non-primary output from non-chatty. > > So (leaving aside that we're unlikely to add advice to plumbing) if you > emitted a warning() or advice from git-ls-tree you should be able to run > something like: > > git ls-tree -r HEAD >output-for-a-script > > And get the advise() on stderr, while the "primary" output is on stdout. > > There's a recent-ish (last year or so) thread where I think Jeff King > explained this better than I'm doing here, but I couldn't find it with a > quick search. You're probably thinking of [1] in which Peff referenced an earlier email[2] in which he stated his thoughts on the subject. The result of [1] was that git-workree was changed[3] to use stderr rather than stdout for its chatty messages, and (significant to this discussion) CodingGuidelines was updated[4] to cover this topic, so we can now refer people to CodingGuidelines. [1]: https://lore.kernel.org/git/YaaN0pibKWgjcVk3@xxxxxxxxxxxxxxxxxxxxxxx/ [2]: https://lore.kernel.org/git/20110907215716.GJ13364@xxxxxxxxxxxxxxxxxxxxx/ [3]: https://lore.kernel.org/git/20211203034420.47447-2-sunshine@xxxxxxxxxxxxxx/ [4]: https://lore.kernel.org/git/20211202223110.22062-1-sunshine@xxxxxxxxxxxxxx/