On Sun, Sep 11, 2022 at 2:31 PM Jeff King <peff@xxxxxxxx> wrote: > On Sun, Sep 11, 2022 at 03:01:41AM -0400, Eric Sunshine wrote: > > > I wonder if color output for "# chainlint" and "?!" annotations would > > > help, too. It looks like that may be tricky, though, because the > > > annotations re-parsed internally in some cases. > > > > I had the exact same thought about coloring the "# chainlint:" lines > > and "?!FOO?!" annotations, and how helpful that could be to anyone > > (not just newcomers). Aside from not having much free time these days, > > a big reason I didn't tackle it was because doing so properly probably > > means relying upon some third-party Perl module, and I intentionally > > wanted to keep the linter independent of add-on modules. Even without > > a "coloring" module of some sort, if Perl had a standard `curses` > > module (which it doesn't), then it would have been easy enough to ask > > `curses` for the proper color codes and apply them as needed. I'm > > old-school, so it doesn't appeal to me, but an alternative would be to > > assume it's safe to use ANSI color codes, but even that may have to be > > done carefully (i.e. checking TERM and accepting only some whitelisted > > entries, and worrying about about Windows consoles). > > We're pretty happy to just use ANSI in the rest of Git, but there is a > complication on Windows. See compat/winansi.c where we decode those > internally into SetConsoleTextAttribute() calls. > > I think we can live with it as-is for now and see how people react. If > lots of people are getting confused by the output, then that motivates > finding a solution. If not, then it's probably not worth the time. Well, you nerd-sniped me anyhow. The result is at [1]. Following the example of t/test-lib.sh, it uses `tput` if available to avoid hardcoding color codes, and `tput` is invoked lazily, only if it detects problems in the tests, so a normal (non-problematic) run doesn't incur the overhead of shelling out to `tput`. My first attempt just assumed ANSI color codes, but then I discovered the precedence set by t/test-lib.sh of using `tput`, so I went with that (since I'm old-school). The ANSI-only version was, of course, much simpler. [1]: https://lore.kernel.org/git/pull.1324.git.git.1663023888412.gitgitgadget@xxxxxxxxx/