git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH/RFC] sideband: remove line padding (was: Re: [PATCH] progress: use \r as EOL only if isatty(stderr) is true)

From
SNSteffen Daode Nurpmeso <sdaoden@googlemail.com>
Date
Jun 30, 2011, 21:13 UTC
Message-ID
<20110630211329.GC63317@sherwood.local>
In-Reply-To
<alpine.LFD.2.00.1106291414140.2142@xanadu.home>
@ Nicolas Pitre <nico@fluxnic.net> wrote (2011-06-29 20:15+0200):
> Why?

Ok, they don't. (Your initial patch was from 2008, and since git(1) is evolving very fast, it might have been that padding is no longer of any use at all.) So, then, i'm the right person to turn the big wheel:

- Move color.* and even progress.* stuff into new visual.[hc].
- Add a vis[ual]_init() which does check isatty() for [012] and
  does the TERM check (i.e. "dumb" or otherwise).
  There could also be flags which could be used to restrict what
  is checked ...
- Replace calls to isatty(xy) by std{in,out,err}_is_tty(), defined
  in visual.h.
  Calling vis[ual]_init() would not be needed for these.
  (But they could be inline if it would be.)
- Add a series of vis_print functions in equal spirit to the
  color series which use detected terminal capabilities to ensure
  that a line consists only of the printed data.

I (almost) had that state hour ago, but it's ... (The problem with that print series is that in the dumb case the data is to be injected before a possibly contained NL/CR sequence, so that already inspected data is to be reinspected. Or data has to be copied around. Or writes have to be splitted, but here i'm talking about stderr, and that's unbuffered, and so each invocation goes through the OS.)

So what else could be done to remove TERM and ANSI escape sequence knowledge from a nice multiband stream splitter, and to avoid that it writes the escape sequence if output is stupidly redirected to a file? Well, visual.h could consist of a single function only:

    const char *ansi_el_if_tty_and_termok_else_null(void);
--
Ciao, Steffen
sdaoden(*)(gmail.com)
() ascii ribbon campaign - against html e-mail
/\ www.asciiribbon.org - against proprietary attachments
Previous: Nicolas PitreNext: Nicolas Pitre
Message 10 of 21 in “progress: use \r as EOL only if isatty(stderr) is true”
  1. progress: use \r as EOL only if isatty(stderr) is trueSteffen Daode Nurpmeso, Jun 28, 2011
  2. Junio C HamanoJun 28, 2011
  3. Steffen Daode NurpmesoJun 28, 2011
  4. Steffen Daode NurpmesoJun 28, 2011
  5. Jeff KingJun 28, 2011
  6. Junio C HamanoJun 29, 2011
  7. Miles BaderJun 30, 2011
  8. sideband: remove line padding (was: Re: [PATCH] progress: use \r as EOL only if isatty(stderr) is true)Steffen Daode Nurpmeso, Jun 29, 2011
  9. Nicolas PitreJun 29, 2011
  10. Steffen Daode NurpmesoJun 30, 2011
  11. Nicolas PitreJul 1, 2011
  12. checkout: be quiet if not on isatty()Steffen Daode Nurpmeso, Aug 27, 2011
  13. checkout: be quiet if not on isatty()Steffen Daode Nurpmeso, Aug 27, 2011
  14. Junio C HamanoAug 28, 2011
  15. martin f krafftAug 28, 2011
  16. checkout: add --verbose, and restrict progress reporting (was: Re: [PATCH] checkout: be quiet if not on isatty())Steffen Daode Nurpmeso, Aug 28, 2011
  17. 0/2 Add update_progress(), divert checkout messagessdaoden@googlemail.com, Aug 29, 2011
  18. 1/2 progress: add update_progress()sdaoden@googlemail.com, Aug 29, 2011
  19. 2/2 unpack-trees: divert check_updates() output via update_progress()sdaoden@googlemail.com, Aug 29, 2011
  20. Steffen Daode NurpmesoJun 28, 2011
  21. Steffen Daode NurpmesoJun 28, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.