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

Re: [PATCH 1/2] format-patch: have progress option while generating patches

From
Jeff King <peff@peff.net>
Date
May 31, 2017, 22:01 UTC
Message-ID
<20170531220100.t27w3w642sn33h7s@sigill.intra.peff.net>
In-Reply-To
<20170531150427.7820-2-kewillf@microsoft.com>
On Wed, May 31, 2017 at 08:04:26AM -0700, Kevin Willford wrote:
Show 9 quoted lines
> 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.
Show 9 quoted lines
> @@ -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.

Show 7 quoted lines
> @@ -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
Previous: Kevin WillfordNext: Junio C Hamano
Message 5 of 34 in “Add progress to format-patch and rebase”
  1. 0/2 Add progress to format-patch and rebaseKevin Willford, May 31, 2017
  2. 1/2 format-patch: have progress option while generating patchesKevin Willford, May 31, 2017
  3. Stefan BellerMay 31, 2017
  4. Kevin WillfordMay 31, 2017
  5. Jeff KingMay 31, 2017
  6. Junio C HamanoJun 1, 2017
  7. Johannes SchindelinJun 1, 2017
  8. Jeff KingJun 1, 2017
  9. 2/2 rebase: turn on progress option by default for format-patchKevin Willford, May 31, 2017
  10. Stefan BellerMay 31, 2017
  11. Kevin WillfordMay 31, 2017
  12. Stefan BellerMay 31, 2017
  13. Johannes SchindelinJun 1, 2017
  14. Jeff KingMay 31, 2017
  15. Junio C HamanoJun 3, 2017
  16. 0/2 Add progress for format-patch and rebaseKevin Willford, Aug 10, 2017
  17. 2/2 rebase: turn on progress option by default for format-patchKevin Willford, Aug 10, 2017
  18. Junio C HamanoAug 11, 2017
  19. 1/2 format-patch: have progress option while generating patchesKevin Willford, Aug 10, 2017
  20. Jeff KingAug 10, 2017
  21. Junio C HamanoAug 11, 2017
  22. Philip OakleyAug 12, 2017
  23. Jeff KingAug 13, 2017
  24. Junio C HamanoAug 14, 2017
  25. Junio C HamanoAug 14, 2017
  26. Jeff KingAug 14, 2017
  27. Junio C HamanoAug 14, 2017
  28. Jeff KingAug 14, 2017
  29. Junio C HamanoAug 14, 2017
  30. progress: simplify "delayed" progress APIJunio C Hamano, Aug 19, 2017
  31. Junio C HamanoAug 19, 2017
  32. Jeff KingAug 20, 2017
  33. Junio C HamanoAug 10, 2017
  34. Jeff KingAug 10, 2017

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.