git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* A nice, beauty progress metter for Git Clone + a feature request
       [not found] <CAKc7PVD_65vB5+meeO3xcu4ASbqr85LBGUO8Ntb7SvbO+NNHmQ@mail.gmail.com>
@ 2023-03-10 11:37 ` Sebastian Gniazdowski
  2023-03-15 18:02   ` Jeff King
  0 siblings, 1 reply; 5+ messages in thread
From: Sebastian Gniazdowski @ 2023-03-10 11:37 UTC (permalink / raw)
  To: git

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.

-- 
Best regards,
Sebastian Gniazdowski

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: A nice, beauty progress metter for Git Clone + a feature request
  2023-03-10 11:37 ` A nice, beauty progress metter for Git Clone + a feature request Sebastian Gniazdowski
@ 2023-03-15 18:02   ` Jeff King
  2023-03-27 10:59     ` Sebastian Gniazdowski
  0 siblings, 1 reply; 5+ messages in thread
From: Jeff King @ 2023-03-15 18:02 UTC (permalink / raw)
  To: Sebastian Gniazdowski; +Cc: git

On Fri, Mar 10, 2023 at 11:37:49AM +0000, Sebastian Gniazdowski wrote:

> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: A nice, beauty progress metter for Git Clone + a feature request
  2023-03-15 18:02   ` Jeff King
@ 2023-03-27 10:59     ` Sebastian Gniazdowski
  2023-03-28 17:51       ` Jeff King
  0 siblings, 1 reply; 5+ messages in thread
From: Sebastian Gniazdowski @ 2023-03-27 10:59 UTC (permalink / raw)
  To: Jeff King; +Cc: git

On Wed, 15 Mar 2023 at 18:02, Jeff King <peff@peff.net> wrote:
> 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

Yes, that's what the asciinema does  – it pipes git clone --progress
to a script, and that's pretty much it. That's why I thought about a
core.pipe option, that would hold the my-progress-scrapper command.
That's a very easy change, could it be added to git source code? The
scrapper from the asciinema doesn't care if it's count, retrieve or
resolve, etc. currently ongoing, it simply displays a gauge with the
current percentage for the current stage. After a while one discovers
that it's resolve that's the final stage, and the gauge is intuitive
either before or after this revelation.





-- 
Best regards,
Sebastian Gniazdowski

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: A nice, beauty progress metter for Git Clone + a feature request
  2023-03-27 10:59     ` Sebastian Gniazdowski
@ 2023-03-28 17:51       ` Jeff King
  2023-03-28 20:49         ` Sebastian Gniazdowski
  0 siblings, 1 reply; 5+ messages in thread
From: Jeff King @ 2023-03-28 17:51 UTC (permalink / raw)
  To: Sebastian Gniazdowski; +Cc: git

On Mon, Mar 27, 2023 at 10:59:56AM +0000, Sebastian Gniazdowski wrote:

> On Wed, 15 Mar 2023 at 18:02, Jeff King <peff@peff.net> wrote:
> > 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?).
> 
> Yes, that's what the asciinema does  – it pipes git clone --progress
> to a script, and that's pretty much it. That's why I thought about a
> core.pipe option, that would hold the my-progress-scrapper command.
> That's a very easy change, could it be added to git source code?

For the reasons I gave earlier, it has to scrape all of stderr, and not
just progress output. I'm still skeptical that this buys a lot over just
redirecting stderr entirely via the shell, but it's at least
conceptually simple (it's basically the same as a pager for stderr).

The implementation might have some tricky bits to think about, though,
since we have an extra process to handle. For real pagers, we take some
care to terminate them on close. Maybe we wouldn't need the same here,
though (since the filter isn't interactive, and we don't want Git to
wait on exiting until it's done).

So I dunno. It might only be a few lines. It just feels like a weird
feature to add.

-Peff

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: A nice, beauty progress metter for Git Clone + a feature request
  2023-03-28 17:51       ` Jeff King
@ 2023-03-28 20:49         ` Sebastian Gniazdowski
  0 siblings, 0 replies; 5+ messages in thread
From: Sebastian Gniazdowski @ 2023-03-28 20:49 UTC (permalink / raw)
  To: Jeff King; +Cc: git

On Tue, 28 Mar 2023 at 17:51, Jeff King <peff@peff.net> wrote:
> So I dunno. It might only be a few lines. It just feels like a weird
> feature to add.

I would perceive the feature as a nice, versatile trick instead of
weird… Current git clone progress is quite unexpected – when I was
starting to use Git I've had a sensation of disappointment each time
I've run clone – was expecting some nice progress bar and was served
with bunch of text lines with numbers that weren't any percentages…
I'm not saying that the progress in the asciinema is some uber cool
solution, but then, it may serve as an example to draw attention to
beautifying the progress and the freedom of hooking any command via a
core.progress_pipe might result in some other nice scripts/apps to
bloom out there.

-- 
Best regards,
Sebastian Gniazdowski

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-03-28 19:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CAKc7PVD_65vB5+meeO3xcu4ASbqr85LBGUO8Ntb7SvbO+NNHmQ@mail.gmail.com>
2023-03-10 11:37 ` A nice, beauty progress metter for Git Clone + a feature request Sebastian Gniazdowski
2023-03-15 18:02   ` Jeff King
2023-03-27 10:59     ` Sebastian Gniazdowski
2023-03-28 17:51       ` Jeff King
2023-03-28 20:49         ` Sebastian Gniazdowski

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).