git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Kevin Willford <kcwillford@gmail.com>
Cc: git@vger.kernel.org, gitster@pobox.com,
	Kevin Willford <kewillf@microsoft.com>
Subject: Re: [PATCH 1/2] format-patch: have progress option while generating patches
Date: Wed, 31 May 2017 18:01:01 -0400	[thread overview]
Message-ID: <20170531220100.t27w3w642sn33h7s@sigill.intra.peff.net> (raw)
In-Reply-To: <20170531150427.7820-2-kewillf@microsoft.com>

On Wed, May 31, 2017 at 08:04:26AM -0700, Kevin Willford wrote:

> When generating patches for the rebase command if the user does
> not realize the branch they are rebasing onto is thousands of
> commits different there is no progress indication after initial
> rewinding message.
> 
> This patch allows a progress option to be passed to format-patch
> so that the user can be informed the progress of generating the
> patch.  This option will then be used by the rebase command when
> calling format-patch.

I'm generally in favor of progress meters, though it does seem a little
funny to me that we'd need one on format-patch. It's basically the same
operation as "git log -p", after all. I guess one difference is that
usually the output of "log" would stream to the pager, so the user would
see immediate output. That's true of format-patch, too, but in the
instance you care about we're probably doing something more like:

  git format-patch "$@" >patches

and the user sees nothing.

That makes me wonder two things:

  1. Should this really be tied to isatty(2), as the documentation
     claims?  It seems like you'd really only want it to kick in for
     certain cases. Arguably whenever stdout is _not_ going to a tty
     you'd want progress, but I think probably the caller should
     probably just decide whether to ask for it or not.

  2. Should this apply to other commands in the log family besides
     format-patch? E.g., should "git log --progress -p >commits" work?

     I added a progress meter to rev-list a while ago (for connectivity
     checks). I don't think we could push this down as far as the
     revision traversal code, because only its callers really understand
     what's the right unit to be counting.

     It may not be worth the trouble, though. Only "format-patch" does a
     pre-pass to find the total number of commits. So "git log
     --progress" would inherently just be counting up, with no clue what
     the final number is.

> @@ -283,6 +285,12 @@ you can use `--suffix=-patch` to get `0001-description-of-my-change-patch`.
>  	range are always formatted as creation patches, independently
>  	of this flag.
>  
> +--progress::
> +	Progress status is reported on the standard error stream
> +	by default when it is attached to a terminal, unless -q
> +	is specified. This flag forces progress status even if the
> +	standard error stream is not directed to a terminal.

Checking whether stderr is a tty would match our usual progress meters.
But I don't actually see any code in the patch implementing this.

As I said above, I think I'd prefer it to require "--progress", as
format-patch is quite often used as plumbing. But we'd need to fix the
documentation here to match.

> @@ -1739,8 +1744,12 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
>  		start_number--;
>  	}
>  	rev.add_signoff = do_signoff;
> +
> +	if (show_progress && !quiet)
> +		progress = start_progress(_("Generating patch"), total);

The meter code here all looks correct, but let me bikeshed for a moment. :)

Should this use start_progress_delay()? In most cases the command will
complete very quickly, and the progress report is just noise. For many
commands (e.g., checkout) we wait 1-2 seconds before bothering to show
progress output.

I would have expected this to say "Generating patches"; most of our
other progress messages are pluralized. You could use Q_() to handle the
mono/plural case, but I think it's fine to just always say "patches"
(that's what other messages do).

One final thought is whether callers would want to customize this
message, since it will often be used as plumbing. E.g., would rebase
want to say something besides "Generating patches". I'm not sure.
Anyway, if you're interested in that direction, there's prior art in
the way rev-list handles "--progress" (and its sole caller,
check_connected()).

-Peff

  parent reply	other threads:[~2017-05-31 22:01 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-31 15:04 [PATCH 0/2] Add progress to format-patch and rebase Kevin Willford
2017-05-31 15:04 ` [PATCH 1/2] format-patch: have progress option while generating patches Kevin Willford
2017-05-31 18:40   ` Stefan Beller
2017-05-31 19:31     ` Kevin Willford
2017-05-31 22:01   ` Jeff King [this message]
2017-06-01  4:10     ` Junio C Hamano
2017-06-01 11:15     ` Johannes Schindelin
2017-06-01 15:54       ` Jeff King
2017-05-31 15:04 ` [PATCH 2/2] rebase: turn on progress option by default for format-patch Kevin Willford
2017-05-31 19:08   ` Stefan Beller
2017-05-31 19:46     ` Kevin Willford
2017-05-31 20:27       ` Stefan Beller
2017-06-01 11:11     ` Johannes Schindelin
2017-05-31 22:11   ` Jeff King
2017-06-03 23:45     ` Junio C Hamano
2017-08-10 18:32 ` [PATCH v2 0/2] Add progress for format-patch and rebase Kevin Willford
2017-08-10 22:48   ` Junio C Hamano
2017-08-10 23:17     ` Jeff King
2017-08-10 18:32 ` [PATCH v2 1/2] format-patch: have progress option while generating patches Kevin Willford
2017-08-10 23:20   ` Jeff King
2017-08-11 22:18     ` Junio C Hamano
2017-08-12  8:06       ` Philip Oakley
2017-08-13  4:39         ` Jeff King
2017-08-14 16:45           ` Junio C Hamano
2017-08-14 18:35             ` Junio C Hamano
2017-08-14 22:29               ` Jeff King
2017-08-14 22:42                 ` Junio C Hamano
2017-08-14 23:08                   ` Jeff King
2017-08-14 23:23                     ` Junio C Hamano
2017-08-19 17:39                 ` [PATCH] progress: simplify "delayed" progress API Junio C Hamano
2017-08-19 20:58                   ` Junio C Hamano
2017-08-20  7:43                   ` Jeff King
2017-08-10 18:32 ` [PATCH v2 2/2] rebase: turn on progress option by default for format-patch Kevin Willford
2017-08-11 22:22   ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170531220100.t27w3w642sn33h7s@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=kcwillford@gmail.com \
    --cc=kewillf@microsoft.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).