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

Re: A nice, beauty progress metter for Git Clone + a feature request

From
Jeff King <peff@peff.net>
Date
Mar 15, 2023, 18:02 UTC
Message-ID
<ZBIIKqAIF+aF8vvx@coredump.intra.peff.net>
In-Reply-To
<CAKc7PVA14_mjZeuED1Ee0Mu5YoCSrR4FNNhSEKFHmnKnc-gESQ@mail.gmail.com>
On Fri, Mar 10, 2023 at 11:37:49AM +0000, Sebastian Gniazdowski wrote:
Show 9 quoted lines
> Check out: https://asciinema.org/a/566216
> 
> Feature request is: add a pipe={cmd} option to git, that would just
> pass through the git clone --progress output into {cmd}. This is
> EXTREMELY EASY TO DO SO, ONLY
> 
> FILE *pipe=popen(cmd_option_str, "w") ;
> 
> is needed, and one can then write to `pipe` file handler.

I think it would be neat to have options for prettier progress output. Unfortunately, it's not quite that easy.

Imagine we had a config option, progress.command or something, which specified a shell command to which we'd pipe machine-readable progress, and it would turn it into something pretty. There are two gotchas I can think of immediately:

  1. Progress is often created by multiple processes. For example, in a
     clone, you might see progress output from index-pack as it receives
     the pack and resolves the delta. But then you might also see
     progress during the checkout phase, as we write out the worktree
     files.
     One solution is to say that each progress command is independent,
     and we'd simply run it twice, once for each context. That's easy to
     do, but restricts some fancier options that a command could do.
     Another is for the parent clone command to kick off a progress
     process, and then tell child processes (perhaps through the
     environment) which descriptor they can use to talk to the progress
     command.
  2. Sometimes progress is shoved through a single descriptor along with
     other human-readable messages. I'm thinking specifically of the
     output you get from a clone/fetch _before_ we start receiving pack
     bytes from the server. There the server is giving progress on
     preparing the fetch. It comes over a sideband channel through Git's
     protocol, along with any regular stderr messages, and the client
     side just dumps it all to the local stderr.
     Obviously the remote side is not going to run our custom progress
     command. But it would be possible to add a protocol extension that
     says "hey, please send machine-readable progress data over sideband
     4" or something.

Now, none of that is _strictly_ necessary. We could just dump the same human-readable progress to the progress command that we dump to stderr now, and it could scrape it for things that look like progress, and pass everything else through. But then, you can already do that with:

  git clone --progress ... 2>&1 | my-progress-scraper

(and it looks like the asciinema you showed is probably just a syntactically nicer version of that with support from the shell?).

-Peff
Previous: Sebastian GniazdowskiNext: Sebastian Gniazdowski
Message 2 of 5 in “A nice, beauty progress metter for Git Clone + a feature request”
  1. Sebastian GniazdowskiMar 10, 2023
  2. Jeff KingMar 15, 2023
  3. Sebastian GniazdowskiMar 27, 2023
  4. Jeff KingMar 28, 2023
  5. Sebastian GniazdowskiMar 28, 2023

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.